Example #1
0
 public static function infos($centre_id, $test_ids, $city, $area)
 {
     $charge = 0;
     $url = "";
     $arr = array();
     $count = count($test_ids);
     foreach ($test_ids as $test_id) {
         $where = array("city_id = ?" => $city, "area_id = ?" => $area, "property = ?" => "test", "property_id = ?" => $test_id, "centre_id = ?" => $centre_id);
         $service = Service::first($where, array("id", "charge"));
         $charge += $service->charge;
         array_push($arr, $service->id);
         if ($count == 1) {
             $url .= "service[]=" . $service->id;
         } else {
             $url .= "service[]=" . $service->id . "&";
         }
         --$count;
     }
     return array("url" => $url, "charge" => $charge, "services" => implode(",", $arr));
 }
Example #2
0
 /**
  * @before _secure
  */
 public function index()
 {
     $this->seo(array("title" => "Appointments Scheduled", "view" => $this->getLayoutView()));
     $view = $this->getActionView();
     $appointments = array();
     $page = RequestMethods::get("page", 1);
     $limit = RequestMethods::get("limit", 10);
     $count = Appointment::count(array("user_id" => $this->user->id));
     $as = Appointment::all(array("user_id =?" => $this->user->id, "live = ?" => 1), array("id", "service_id", "start", "end", "patient_id"), "start", "asc", $limit, $page);
     foreach ($as as $a) {
         $service = Service::first(array("id = ?" => $a->service_id), array("property", "property_id", "organization_id", "charge"));
         $organization = Organization::first(array("id = ?" => $service->organization_id), array("id", "name"));
         $model = ucfirst($service->property);
         $item = $model::first(array("id = ?" => $service->property_id), array("title"));
         $patient = User::first(array("id = ?" => $a->patient_id), array("name"));
         array_push($appointments, array("item" => $item->title, "organization_id" => $organization->id, "organization_name" => $organization->name, "patient" => $patient->name, "start" => $a->start, "end" => $a->end, "id" => $a->id, "charge" => $service->charge));
     }
     $view->set("appointments", $appointments);
     $view->set("page", $page);
     $view->set("limit", $limit);
     $view->set("count", $count);
 }
Example #3
0
 /**
  * @before _secure
  */
 public function orders()
 {
     $this->seo(array("title" => "Orders", "view" => $this->getLayoutView()));
     $view = $this->getActionView();
     $orders = array();
     $os = Order::all(array("user_id = ?" => $this->user->id), array("id", "amount", "ref_id"), "created", "desc");
     foreach ($os as $o) {
         $title = array();
         $appointments = Appointment::all(array("order_id = ?" => $o->id), array("service_id", "start", "end", "patient_id"));
         foreach ($appointments as $a) {
             $service = Service::first(array("id = ?" => $a->service_id), array("property", "property_id"));
             $model = ucfirst($service->property);
             $item = $model::first(array("id = ?" => $service->property_id), array("title"));
             $title[] = $item->title;
             $start = $a->start;
             $end = $a->end;
             $patient_id = $a->patient_id;
         }
         $patient = User::first(array("id = ?" => $patient_id), array("name"));
         array_push($orders, array("item" => implode(", ", $title), "amount" => $o->amount, "id" => $o->id, "ref_id" => $o->ref_id, "patient" => $patient->name, "start" => $start, "end" => $end));
     }
     $view->set("orders", $orders);
 }
Example #4
0
 /**
  * @before _secure, _vendor
  */
 public function all()
 {
     $this->noview();
     $events = array();
     $now = strftime("%Y-%m-%d", strtotime('now'));
     if ($this->member->designation == "admin") {
         $where = array("organization_id = ?" => $this->member->organization_id);
     } else {
         $where = array("centre_id = ?" => $this->member->centre_id);
     }
     $appointments = Appointment::all($where, array("service_id", "start", "end", "allDay", "id"));
     $returnTime = function ($date) {
         $d = explode(" ", $date);
         $d = implode("T", $d);
         return $d;
     };
     foreach ($appointments as $appointment) {
         $diff = 0;
         $color = '#3a87ad';
         //blue
         $service = Service::first(array("id = ?" => $appointment->service_id), array("property", "property_id"));
         $class = ucfirst($service->property);
         $item = $class::first(array("id = ?" => $service->property_id), array("title"));
         $job = Job::first(array("appointment_id = ?" => $appointment->id), array("id"));
         $diff = round((strtotime($appointment->start) - strtotime('now')) / 3600);
         if ($diff < 13) {
             $color = '#FF0000';
             //red
         }
         if (isset($job)) {
             $color = '#00FF00';
             //green
         }
         $events[] = array("title" => $item->title, "start" => $returnTime($appointment->start), "end" => $returnTime($appointment->end), "allDay" => $appointment->allDay ? true : false, "id" => $appointment->id, "color" => $color);
     }
     echo json_encode($events);
 }
Example #5
0
 /**
  * @before _secure, _doctor
  */
 public function appointments()
 {
     $this->seo(array("title" => "My Appointments", "view" => $this->getLayoutView()));
     $this->getLayoutView()->set("cal", true);
     $view = $this->getActionView();
     $appointments = array();
     $page = RequestMethods::get("page", 1);
     $limit = RequestMethods::get("limit", 10);
     $count = Appointment::count(array("user_id" => $this->user->id));
     $as = Appointment::all(array("user_id =?" => $this->user->id, "live = ?" => 1), array("id", "service_id", "start", "end", "patient_id"), "start", "asc", $limit, $page);
     foreach ($as as $a) {
         $service = Service::first(array("id = ?" => $a->service_id), array("property", "property_id", "organization_id", "charge"));
         $organization = Organization::first(array("id = ?" => $service->organization_id), array("id", "name"));
         $model = ucfirst($service->property);
         $item = $model::first(array("id = ?" => $service->property_id), array("title"));
         $patient = User::first(array("id = ?" => $a->patient_id), array("name"));
         array_push($appointments, array("item" => $item->title, "organization_id" => $organization->id, "organization_name" => $organization->name, "patient" => $patient->name, "start" => $a->start, "end" => $a->end, "id" => $a->id, "charge" => $service->charge));
     }
     $organization = Registry::get("session")->get("organization");
     if (RequestMethods::post("action") == "capacity") {
         \Slot::saveRecord($this->user, $organization);
         $view->set("message", "Slots Saved Successfully");
     }
     $view->set("appointments", $appointments);
     $days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
     $view->set("days", $days);
     $view->set("slots", Shared\Services\Doctor::slots($this->user));
 }
Example #6
0
 protected function _saveCharge($centres, $locations, $opts)
 {
     foreach ($centres as $centre) {
         $location = $locations[$centre->location_id];
         if (isset($opts['service_id']) && (int) $opts['service_id'] != 0) {
             $service = Service::first(array("id = ?" => $opts['service_id']));
         } else {
             $service = Service::first(array("property = ?" => "test", "property_id = ?" => $opts['test_id'], "centre_id = ?" => $centre->id, "organization_id = ?" => $this->organization->id));
         }
         if (!$service) {
             $service = new Service(array("property" => "test", "property_id" => $opts['test_id'], "centre_id" => $centre->id, "city_id" => $location->city_id, "area_id" => $location->area_id, "organization_id" => $this->organization->id));
         }
         $service->charge = $opts['charge'];
         $service->save();
     }
 }