コード例 #1
0
 public function cancel($id)
 {
     $registration = \montserrat\Registration::findOrFail($id);
     $registration->canceled_at = \Carbon\Carbon::now();
     $registration->save();
     return Redirect::back();
 }
コード例 #2
0
 public function store_retreat(Request $request)
 {
     //
     $this->validate($request, ['event_id' => 'required|integer|min:0', 'touched_at' => 'required|date', 'staff_id' => 'required|integer|min:0', 'type' => 'in:Email,Call,Letter,Face,Other']);
     $event_id = $request->input('event_id');
     $participants = \montserrat\Registration::whereEventId($event_id)->whereRoleId(PARTICIPANT_ROLE_ID_RETREATANT)->whereNull('canceled_at')->get();
     foreach ($participants as $participant) {
         $touchpoint = new \montserrat\Touchpoint();
         $touchpoint->person_id = $participant->contact_id;
         $touchpoint->staff_id = $request->input('staff_id');
         $touchpoint->touched_at = Carbon::parse($request->input('touched_at'));
         $touchpoint->type = $request->input('type');
         $touchpoint->notes = $request->input('notes');
         $touchpoint->save();
     }
     return Redirect::action('RetreatsController@show', $event_id);
 }
コード例 #3
0
 public function retreatrosterreport($id)
 {
     $retreat = \montserrat\Retreat::where('idnumber', '=', $id)->first();
     //        $registrations = \montserrat\Registration::where('event_id','=',$retreat->id)->with('retreat','retreatant.suffix','retreatant.address_primary','retreatant.prefix')->get();
     //dd($registrations);
     $registrations = \montserrat\Registration::select(\DB::raw('participant.*', 'contact.*'))->join('contact', 'participant.contact_id', '=', 'contact.id')->where('participant.event_id', '=', $retreat->id)->whereCanceledAt(NULL)->with('retreat', 'retreatant.languages', 'retreatant.parish.contact_a.address_primary', 'retreatant.prefix', 'retreatant.suffix', 'retreatant.address_primary.state', 'retreatant.phones.location', 'retreatant.emails.location', 'retreatant.emergency_contact', 'retreatant.notes', 'retreatant.occupation')->orderBy('contact.sort_name', 'asc')->orderBy('participant.notes', 'asc')->get();
     return view('reports.retreatroster', compact('registrations'));
     //
 }
コード例 #4
0
 public function room_update(Request $request)
 {
     //
     //dd($request);
     $this->validate($request, ['retreat_id' => 'integer|min:0']);
     if (null !== $request->input('registrations')) {
         foreach ($request->input('registrations') as $key => $value) {
             $registration = \montserrat\Registration::findOrFail($key);
             $registration->room_id = $value;
             $registration->save();
             //dd($registration,$value);
         }
     }
     if (null !== $request->input('notes')) {
         foreach ($request->input('notes') as $key => $value) {
             $registration = \montserrat\Registration::findOrFail($key);
             $registration->notes = $value;
             $registration->save();
             //dd($registration,$value);
         }
     }
     return Redirect::action('RetreatsController@index');
 }
コード例 #5
0
 /**
  * Display the room schedules for a particular month/year - default this month.
  *
  * @param  int  $ym
  * @return \Illuminate\Http\Response
  */
 public function schedule($ym = null, $building = null)
 {
     //dd($ym);
     //
     if (!isset($ym) or $ym == 0) {
         $dt = Carbon::now();
         //dd($dt);
     } else {
         if (!($dt = Carbon::parse($ym))) {
             return view('404');
         }
     }
     $upcoming = clone $dt;
     $previous_dt = clone $dt;
     $path = url('rooms/' . $previous_dt->subDays(31)->format('Ymd'));
     $previous_link = '<a href="' . $path . '">&#171;</a>';
     $dts[0] = $dt;
     //dd($dts);
     for ($i = 1; $i <= 31; $i++) {
         $dts[$i] = Carbon::parse($upcoming->addDays(1));
     }
     $path = url('rooms/' . $upcoming->format('Ymd'));
     $next_link = '<a href="' . $path . '">&#187;</a>';
     //dd($dts);
     $rooms = \montserrat\Room::with('location')->get();
     //dd($rooms);
     //foreach ($rooms as $room) {
     //    $room->building = \montserrat\Location::findOrFail($room->building_id)->name;
     //}
     $roomsort = $rooms->sortBy(function ($room) {
         return sprintf('%-12s%s', $room->building_id, $room->name);
     });
     //dd($dts);
     $registrations_start = \montserrat\Registration::with('room', 'room.location', 'retreatant', 'retreat')->whereNull('canceled_at')->where('room_id', '>', 0)->whereHas('retreat', function ($query) use($dts) {
         $query->where('start_date', '>=', $dts[0])->where('start_date', '<=', $dts[30]);
     })->get();
     $registrations_end = \montserrat\Registration::with('room', 'room.location', 'retreatant', 'retreat')->whereNull('canceled_at')->where('room_id', '>', 0)->whereHas('retreat', function ($query) use($dts) {
         $query->where('end_date', '>=', $dts[0])->where('start_date', '<=', $dts[0]);
     })->get();
     //dd($registrations_start, $registrations_end);
     //$endregistrations = \montserrat\Registration::where('end','>=',$dts[0])->where('end','<=',$dts[30])->with('room','room.location','retreatant','retreat')->where('room_id','>',0)->get();
     /* get registrations that are not inclusive of the date range */
     // dd($endregistrations);
     // $registrations->merge($endregistrations);
     // create matrix of rooms and dates
     foreach ($rooms as $room) {
         foreach ($dts as $dt) {
             //dd($dt);
             $m[$room->id][$dt->toDateString()]['status'] = 'A';
             $m[$room->id][$dt->toDateString()]['registration_id'] = NULL;
             $m[$room->id][$dt->toDateString()]['retreatant_id'] = NULL;
             $m[$room->id][$dt->toDateString()]['retreatant_name'] = NULL;
             $m[$room->id]['room'] = $room->name;
             $m[$room->id]['building'] = $room->location->name;
             $m[$room->id]['occupancy'] = $room->occupancy;
         }
     }
     /* 
      * for each registration, get the number of days 
      * for each day, check if the status is set (in other words it is in the room schedule matrix)
      * if it is in the matrix update the status to reserved
      */
     foreach ($registrations_start as $registration) {
         $numdays = $registration->retreat->end_date->diffInDays($registration->retreat->start_date);
         for ($i = 0; $i <= $numdays; $i++) {
             $matrixdate = $registration->retreat->start_date->copy()->addDays($i);
             if (array_key_exists($matrixdate->toDateString(), $m[$registration->room_id])) {
                 $m[$registration->room_id][$matrixdate->toDateString()]['status'] = 'R';
                 if (!empty($registration->arrived_at) && empty($registration->departed_at)) {
                     $m[$registration->room_id][$matrixdate->toDateString()]['status'] = 'O';
                 }
                 $m[$registration->room_id][$matrixdate->toDateString()]['registration_id'] = $registration->id;
                 $m[$registration->room_id][$matrixdate->toDateString()]['retreatant_id'] = $registration->contact_id;
                 $m[$registration->room_id][$matrixdate->toDateString()]['retreatant_name'] = $registration->retreatant->display_name;
                 $m[$registration->room_id][$matrixdate->toDateString()]['retreat_name'] = $registration->retreat_name;
                 /* For now just handle marking the room as reserved with a URL to the registration and name in the title when hovering over it
                  * I am thinking about using diffInDays to see if the retreatant arrived on the day that we are looking at or sooner
                  * If they have not yet arrived then the first day should be reserved but not occupied. 
                  * Occupied will be the same link to the registration. 
                  */
             }
         }
     }
     foreach ($registrations_end as $registration) {
         $numdays = $registration->retreat->end_date->diffInDays($registration->retreat->start_date);
         for ($i = 0; $i <= $numdays; $i++) {
             $matrixdate = $registration->retreat->start_date->copy()->addDays($i);
             if (array_key_exists($matrixdate->toDateString(), $m[$registration->room_id])) {
                 $m[$registration->room_id][$matrixdate->toDateString()]['status'] = 'R';
                 if (!empty($registration->arrived_at) && empty($registration->departed_at)) {
                     $m[$registration->room_id][$matrixdate->toDateString()]['status'] = 'O';
                 }
                 $m[$registration->room_id][$matrixdate->toDateString()]['registration_id'] = $registration->id;
                 $m[$registration->room_id][$matrixdate->toDateString()]['retreatant_id'] = $registration->contact_id;
                 $m[$registration->room_id][$matrixdate->toDateString()]['retreatant_name'] = $registration->retreatant->display_name;
                 $m[$registration->room_id][$matrixdate->toDateString()]['retreat_name'] = $registration->retreat_name;
                 /* For now just handle marking the room as reserved with a URL to the registration and name in the title when hovering over it
                  * I am thinking about using diffInDays to see if the retreatant arrived on the day that we are looking at or sooner
                  * If they have not yet arrived then the first day should be reserved but not occupied. 
                  * Occupied will be the same link to the registration. 
                  */
             }
         }
     }
     //dd($m);
     return view('rooms.sched2', compact('dts', 'roomsort', 'm', 'previous_link', 'next_link'));
 }
コード例 #6
0
 public function merge_destroy($id)
 {
     // TODO: consider creating a restore/{id} or undelete/{id}
     //delete existing groups and relationships when deleting user
     \montserrat\Relationship::whereContactIdA($id)->delete();
     \montserrat\Relationship::whereContactIdB($id)->delete();
     \montserrat\GroupContact::whereContactId($id)->delete();
     //delete address, email, phone, website, emergency contact, notes for deleted users
     \montserrat\Address::whereContactId($id)->delete();
     \montserrat\Email::whereContactId($id)->delete();
     \montserrat\Phone::whereContactId($id)->delete();
     \montserrat\Website::whereContactId($id)->delete();
     \montserrat\EmergencyContact::whereContactId($id)->delete();
     \montserrat\Note::whereContactId($id)->delete();
     \montserrat\Touchpoint::wherePersonId($id)->delete();
     //delete registrations
     \montserrat\Registration::whereContactId($id)->delete();
     \montserrat\Contact::destroy($id);
     return Redirect::back();
 }