예제 #1
0
 /**
  *
  * show the available slots for spefic doctor
  * @return view
  */
 public function show($id)
 {
     $doctor = null;
     $userRequested = null;
     $doctor = Doctor::where('id', $id)->first();
     if (!is_null($doctor)) {
         $userRequested = user::where('email', '=', $doctor->email)->first();
         if (!is_null($userRequested)) {
             $timeSlots = Timeslots::where('doctor_id', '=', $doctor->id)->first();
             if (!is_null($timeSlots) && $doctor->available == 1) {
                 //getting the time period
                 $period = explode(".", $timeSlots->period);
                 if (count($period) != 2) {
                     return view('user.appointmetns.place')->with('user', Session::get('user'))->with('userReq', $userRequested)->with('doctor', $doctor);
                 }
                 $periodMinutes = $period[1];
                 $periodHours = $period[0];
                 $periodMinutes = $periodMinutes + $periodHours * 60;
                 // end of the processing the time format initialiation
                 $dt = Carbon::now('Asia/Colombo');
                 $dt->second = 0;
                 //$dt = Carbon::parse('2012-9-6 23:26:11.123789');
                 $dayCount = 0;
                 $dt->addDays(2);
                 $timetable = array();
                 $timevals = array();
                 while ($dayCount < 7) {
                     $day = array();
                     if ($dt->dayOfWeek == 1) {
                         //echo "monday<br>";
                         $day = $this->stringDateToArray($timeSlots->monday);
                     } elseif ($dt->dayOfWeek == 2) {
                         $day = $this->stringDateToArray($timeSlots->tuesday);
                         //echo "tuesday<br>";
                     } elseif ($dt->dayOfWeek == 3) {
                         $day = $this->stringDateToArray($timeSlots->wednesday);
                         //echo "wedensday<br>";
                     } elseif ($dt->dayOfWeek == 4) {
                         $day = $this->stringDateToArray($timeSlots->thursday);
                         //echo "Thursday<br>";
                     } elseif ($dt->dayOfWeek == 5) {
                         $day = $this->stringDateToArray($timeSlots->friday);
                         //echo "Friday<br>";
                     } elseif ($dt->dayOfWeek == 6) {
                         $day = $this->stringDateToArray($timeSlots->saturday);
                         //echo "Saturday<br>";
                     } elseif ($dt->dayOfWeek == 0) {
                         $day = $this->stringDateToArray($timeSlots->sunday);
                         //echo "Sunday<br>";
                     }
                     if (count($day) != 4) {
                         $dt->addDay();
                         $dayCount++;
                         continue;
                     }
                     $cancelTimeDb = cancelSlots::where('did', '=', $doctor->id)->where('slotdate', '=', $dt->toDateString())->first();
                     $tempCancel = $this->stringDateToArray("0.00-0.00");
                     if (!is_null($cancelTimeDb)) {
                         $tempCancel = $this->stringDateToArray($cancelTimeDb->time);
                         if (count($tempCancel) != 4) {
                             $tempCancel = $this->stringDateToArray("0.00-0.00");
                         }
                     }
                     $key = $dt->toDateString();
                     $returnArray = array();
                     $returnArray = $this->timeCal($day, $tempCancel, $periodMinutes, $dt, $doctor->id);
                     //$timetable[$key]=$this->timeCal($day,$tempCancel,$periodMinutes,$dt,$doctor->id);
                     $timetable[$key] = $returnArray['times'];
                     $timevals[$key] = $returnArray['vals'];
                     $dt->addDay();
                     $dayCount++;
                 }
                 Session::put('requestedDoctor', $doctor->id);
                 Session::put('timeval', $timevals);
                 return view('user.appointmetns.place')->with('user', Session::get('user'))->with('userReq', $userRequested)->with('doctor', $doctor)->with('timetable', $timetable)->with('timevals', $timevals);
             } else {
                 return view('user.appointmetns.place')->with('user', Session::get('user'))->with('userReq', $userRequested)->with('doctor', $doctor);
             }
             return view('user.appointmetns.place')->with('user', Session::get('user'))->with('userReq', $userRequested)->with('doctor', $doctor);
         }
     }
     return view('user.appointmetns.place')->with('user', Session::get('user'));
 }
예제 #2
0
 /**
  * Shows the Doctor List to the user.
  *
  * @return index view
  */
 public function updateSchedule()
 {
     $user = Session::get('user');
     $ifExists = Timeslots::where('doctor_id', $user->id)->get();
     $created = 0;
     if (count($ifExists) > 0) {
         Timeslots::where('doctor_id', $user->id)->update(['monday' => Request::get('monday_from') . '-' . Request::get('monday_till')]);
         Timeslots::where('doctor_id', $user->id)->update(['tuesday' => Request::get('tuesday_from') . '-' . Request::get('tuesday_till')]);
         Timeslots::where('doctor_id', $user->id)->update(['wednesday' => Request::get('wednesday_from') . '-' . Request::get('wednesday_till')]);
         Timeslots::where('doctor_id', $user->id)->update(['thursday' => Request::get('thursday_from') . '-' . Request::get('thursday_till')]);
         Timeslots::where('doctor_id', $user->id)->update(['friday' => Request::get('friday_from') . '-' . Request::get('friday_till')]);
         Timeslots::where('doctor_id', $user->id)->update(['saturday' => Request::get('saturday_from') . '-' . Request::get('saturday_till')]);
         Timeslots::where('doctor_id', $user->id)->update(['sunday' => Request::get('sunday_from') . '-' . Request::get('sunday_till')]);
         Timeslots::where('doctor_id', $user->id)->update(['notes' => 'None']);
         $created = 1;
     } else {
         $newTimeslot = new Timeslots();
         $newTimeslot->doctor_id = $user->id;
         $newTimeslot->monday = Request::get('monday_from') . '-' . Request::get('monday_till');
         $newTimeslot->tuesday = Request::get('tuesday_from') . '-' . Request::get('tuesday_till');
         $newTimeslot->wednesday = Request::get('wednesday_from') . '-' . Request::get('wednesday_till');
         $newTimeslot->thursday = Request::get('thursday_from') . '-' . Request::get('thursday_till');
         $newTimeslot->friday = Request::get('friday_from') . '-' . Request::get('friday_till');
         $newTimeslot->saturday = Request::get('saturday_from') . '-' . Request::get('saturday_till');
         $newTimeslot->sunday = Request::get('sunday_from') . '-' . Request::get('sunday_till');
         $newTimeslot->created = 1;
         $newTimeslot->notes = 'None';
         $newTimeslot->save();
     }
     return view('doctor.createschedule')->with('user', $user)->with('created', $created);
     //return $doctors;
 }