public function deleteAction($id = false)
 {
     $this->permission('delete');
     if (!$id) {
         return Brightery::error404();
     }
     $model = new \modules\clinic\models\Clinic_schedule_exceptions();
     $model->clinic_schedule_exception_id = $id;
     if ($model->delete()) {
         Uri_helper::redirect("management/clinic_schedule_exceptions");
     }
 }
 public function deleteAction($id = false)
 {
     $this->permission('delete');
     if (!$id) {
         return Brightery::error404();
     }
     $model_schedules = new \modules\clinic\models\Clinic_schedules();
     $model_schedules->clinic_doctor_id = $id;
     $model_exceptions = new modules\clinic\models\Clinic_schedule_exceptions();
     $model_exceptions->clinic_doctor_id = $id;
     $model = new \modules\clinic\models\Clinic_doctors();
     $model->clinic_doctor_id = $id;
     $model_resevration_type = new \modules\clinic\models\Clinic_doctor_reservation_types();
     $model_resevration_type->clinic_doctor_id = $id;
     $model_reservation = new \modules\clinic\models\Clinic_reservations();
     $model_reservation->clinic_doctor_id = $id;
     if ($model->delete() && $model_exceptions->delete() && $model_schedules->delete() && $model_resevration_type->delete() && $model_reservation->delete()) {
         Uri_helper::redirect("management/clinic_doctors");
     }
 }
 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;
 }