public function manageAction($id = false)
 {
     $this->permission('manage');
     $this->language->load("clinic_schedule_exceptions");
     $model = new \modules\clinic\models\Clinic_schedule_exceptions();
     $model->attributes = $this->Input->input['post'];
     $schedules = Form_helper::queryToDropdown('clinic_schedules', 'clinic_schedule_id', 'clinic_schedule_id');
     if ($id) {
         $model->clinic_schedule_exception_id = $id;
     }
     $model->language_id = $this->language->getDefaultLanguage();
     if ($model->save()) {
         Uri_helper::redirect("management/clinic_schedule_exceptions");
     }
     return $this->render('clinic_schedule_exceptions/manage', ['item' => $id ? $model->get() : null, 'schedule' => $schedules]);
 }
 public function exceptionsAction($id = false)
 {
     $this->language->load("clinic_doctors");
     if ($_POST) {
         $date = $this->input->post('exc_date');
         $from_time = $this->input->post('exc_from');
         $to_time = $this->input->post('exc_to');
         $clinic_schedule_exception_id = $this->input->post('clinic_schedule_exception_id');
         foreach ($date as $key => $value) {
             $exceptions = new \modules\clinic\models\Clinic_schedule_exceptions();
             $exceptions->clinic_doctor_id = $id;
             $exceptions->from_time = $from_time[$key];
             $exceptions->to_time = $to_time[$key];
             $exceptions->date = $value;
             if ($clinic_schedule_exception_id[$key]) {
                 $exceptions->clinic_schedule_exception_id = $clinic_schedule_exception_id[$key];
             }
             $exceptions->save();
         }
         if ($exceptions->save()) {
             Uri_helper::redirect("management/clinic_doctors/doctor_schedule/" . $id);
         }
     }
     if (!$_POST) {
         $exception = new \modules\clinic\models\Clinic_schedule_exceptions();
         $exception->select;
         $exception->clinic_doctor_id = $id;
         $result = $exception->get();
         return $this->render('clinic_doctors/exceptions', ['items' => $result, 'doctor' => $id]);
     }
 }
Пример #3
0
 public function get_searchResult($date, $time, $doctor_id)
 {
     $i = 0;
     $x = 0;
     //        $final_result = [];
     //        $newtime[]->time = (object) array('time', 'user_id', 'date');
     foreach ($time as $key => $value) {
         $newtime[$key]->time = $value;
     }
     foreach ($newtime as $key => $value) {
         $model_rev = new \modules\clinic\models\Clinic_reservations();
         $model_rev->_select = 'user_id , date , time';
         $model_rev->time = $value->time;
         $model_rev->date = $date;
         $model_rev->clinic_doctor_id = $doctor_id;
         $model_rev->where = 'clinic_reservation_status = "confirmed" of clinic_reservation_status = "pending"';
         $result_f = $model_rev->get();
         $user_id = $result_f[0]->user_id;
         if ($result_f) {
             foreach ($result_f as $key => $value) {
                 $tim = $result_f[$key]->time;
                 foreach ($newtime as $k => $val) {
                     if ($newtime[$k]->time == $tim) {
                         $user_id = $result_f[$key]->user_id;
                         $newtime[$k]->user_id = $user_id;
                         $newtime[$k]->date = $date;
                         $newtime[$k]->time = $tim;
                         $newtime[$k]->status = 'reserved';
                     }
                 }
             }
         }
     }
     $model_ex = new \modules\clinic\models\Clinic_schedule_exceptions();
     $model_ex->select = '';
     $model_ex->clinic_doctor_id = $doctor_id;
     $model_ex->date = $date;
     $exception = $model_ex->get();
     foreach ($exception as $key => $v) {
         $ffff = strtotime("1970-01-01 {$v->from_time} UTC");
         $tttt = strtotime("1970-01-01 {$v->to_time} UTC");
         foreach ($newtime as $k => $value) {
             $newwww = $newtime[$k]->time;
             $convert = strtotime("1970-01-01 {$newwww} UTC");
             if ($convert == $ffff) {
                 $newtime[$k]->status = 'except';
                 $newtime[$k]->time = $newwww;
             } elseif ($convert == $tttt) {
                 $newtime[$k]->status = 'except';
             } elseif ($convert > $ffff && $convert < $tttt) {
                 $newtime[$k]->status = 'except';
             }
         }
     }
     return $newtime;
 }
 public function schedule_exceptionsAction($id = false)
 {
     $this->layout = 'ajax';
     $this->permission('schedule_exceptions');
     $exceptions = new \modules\clinic\models\Clinic_schedule_exceptions();
     $exceptions->clinic_doctor_id = $id;
     $exceptions->date = $this->input->post('exc_date');
     $exceptions->from_time = $this->input->post('exc_from');
     $exceptions->to_time = $this->input->post('exc_to');
     $exp_schedule = [];
     foreach ($exceptions->get() as $item) {
         $exp_schedule[$item->clinic_doctor_id] = $item;
     }
     $exceptions->save();
     return $this->render('clinic_doctors/exceptions', ['exp_schedule' => $exp_schedule, 'doctor' => $id]);
 }