示例#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
 /**
  * Inserts a new Cancel Slot.
  *
  * @return createcancelslot view
  */
 public function insertCancelSlot()
 {
     $user = Session::get('user');
     $from = Request::get('from');
     $till = Request::get('till');
     $date = Request::get('date');
     $newCancelSlot = new cancelSlots();
     $startDateTime = Carbon::createFromFormat('Y/m/d-H.i', $date . '-' . $from);
     $endDateTime = Carbon::createFromFormat('Y/m/d-H.i', $date . '-' . $till);
     $newCancelSlot->did = $user->id;
     $newCancelSlot->time = $from . '-' . $till;
     $newCancelSlot->slotdate = $startDateTime->toDateString();
     $newCancelSlot->save();
     $appointments = doctorSchedule::where(function ($query) use($startDateTime, $endDateTime) {
         $query->where('schedule_start', '>', $startDateTime->toDateTimeString())->where('schedule_start', '<', $endDateTime->toDateTimeString());
     })->orWhere(function ($query) use($startDateTime, $endDateTime) {
         $query->where('schedule_end', '>', $startDateTime->toDateTimeString())->where('schedule_end', '<', $endDateTime->toDateTimeString());
     })->get();
     $currentDoctor = Doctor::find($user->id);
     $doctorName = $currentDoctor->first_name . ' ' . $currentDoctor->last_name;
     foreach ($appointments as $value) {
         $currentUser = User::find($value->uid);
         Mail::send('mailtemplate/appointmentCancelled', ['name' => $currentUser->name, 'doctor' => $doctorName], function ($m) use($currentUser) {
             $m->from('*****@*****.**', 'Daemon');
             $m->to($currentUser->email, $currentUser->name)->subject('Wedaduru Appointment Notice');
         });
         doctorSchedule::where('id', $value->id)->update(['cancelDoctor' => '1']);
     }
     return View::make('doctor.createcancelslot')->with('user', $user);
 }