/** * @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)); }