예제 #1
0
 public function autocomplete()
 {
     $term = Input::get('term');
     $results = array();
     $queries = \montserrat\Contact::orderBy('sort_name')->where('display_name', 'LIKE', '%' . $term . '%')->whereDeletedAt(NULL)->take(20)->get();
     if ($queries->count() == 0) {
         $results[0] = 'Add new contact (No results)';
     }
     foreach ($queries as $query) {
         $results[] = ['id' => $query->id, 'value' => $query->full_name_with_city];
     }
     return Response::json($results);
 }
예제 #2
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     //
     $staff = \montserrat\Contact::with('groups')->whereHas('groups', function ($query) {
         $query->where('group_id', '=', GROUP_ID_STAFF);
     })->orderBy('sort_name')->pluck('sort_name', 'id');
     // TODO: replace this with an autocomplete text box for performance rather than a dropdown box
     $persons = \montserrat\Contact::orderBy('sort_name')->pluck('sort_name', 'id');
     $current_user = Auth::user();
     $user_email = \montserrat\Email::whereEmail($current_user->email)->first();
     if (empty($user_email->contact_id)) {
         $defaults['user_id'] = 0;
     } else {
         $defaults['user_id'] = $user_email->contact_id;
     }
     return view('touchpoints.create', compact('staff', 'persons', 'defaults'));
 }
 public function register($retreat_id = 0, $contact_id = 0)
 {
     //
     //$retreats = \montserrat\Retreat::where('end','>',\Carbon\Carbon::today())->pluck('idnumber','title','id');
     if ($retreat_id > 0) {
         $retreats = \montserrat\Retreat::select(\DB::raw('CONCAT(idnumber, "-", title, " (",DATE_FORMAT(start_date,"%m-%d-%Y"),")") as description'), 'id')->where("end_date", ">", \Carbon\Carbon::today())->whereId($retreat_id)->orderBy('start_date')->pluck('description', 'id');
     } else {
         $retreats = \montserrat\Retreat::select(\DB::raw('CONCAT(idnumber, "-", title, " (",DATE_FORMAT(start_date,"%m-%d-%Y"),")") as description'), 'id')->where("end_date", ">", \Carbon\Carbon::today())->orderBy('start_date')->pluck('description', 'id');
     }
     $retreats->prepend('Unassigned', 0);
     if ($contact_id > 0) {
         $retreatants = \montserrat\Contact::whereId($contact_id)->orderBy('sort_name')->pluck('sort_name', 'id');
     } else {
         $retreatants = \montserrat\Contact::orderBy('sort_name')->pluck('sort_name', 'id');
     }
     $retreatants->prepend('Unassigned', 0);
     $rooms = \montserrat\Room::orderby('name')->pluck('name', 'id');
     $rooms->prepend('Unassigned', 0);
     $dt_today = \Carbon\Carbon::today();
     $defaults['retreat_id'] = $retreat_id;
     $defaults['contact_id'] = $contact_id;
     $defaults['today'] = $dt_today->month . '/' . $dt_today->day . '/' . $dt_today->year;
     return view('registrations.create', compact('retreats', 'retreatants', 'rooms', 'defaults'));
     //dd($retreatants);
 }
예제 #4
0
 public function role($role)
 {
     // TODO: figure out how to handle roles
     $contacts = \montserrat\Contact::orderBy('last_name', 'asc', 'first_name', 'asc')->where($role['field'], '1')->get();
     //dd($contacts);
     return view('contacts.role', compact('contacts', 'role'));
     //
 }