/** * @before _session */ public function preregister() { $this->seo(array("title" => "Register", "view" => $this->getLayoutView())); $view = $this->getActionView(); if (RequestMethods::post("department")) { $exist = User::first(array("email = ?" => RequestMethods::post("email")), array("id")); if (!$exist) { $user = new User(array("name" => RequestMethods::post("name"), "email" => RequestMethods::post("email"), "phone" => RequestMethods::post("phone"), "password" => rand(100000, 9999999), "gender" => RequestMethods::post("gender"), "birthday" => "")); $user->save(); $organization = \Organization::saveRecord(); $location = \Location::saveRecord($user); $centre = new Centre(array("user_id" => $user->id, "organization_id" => $organization->id, "type" => "lab", "department" => json_encode(RequestMethods::post("department")), "phone" => RequestMethods::post("org_phone"), "location_id" => $location->id)); $centre->save(); $member = new Member(array("user_id" => $user->id, "centre_id" => $centre->id, "organization_id" => $organization->id, "designation" => "admin", "image" => "", "live" => "1")); $member->save(); Shared\Services\Mail::notify(array("template" => "vendorRegister", "subject" => "Welcome to HealthLitmus.com", "user" => $user)); $this->redirect("/auth/success"); } else { $view->set("message", "User Already Exists"); } } }
/** * @before _secure, _vendor */ public function reports() { $this->seo(array("title" => "Test Report", "view" => $this->getLayoutView())); $view = $this->getActionView(); $centre_id = RequestMethods::get("centre_id", $this->member->centre_id); $appointments = Appointment::all(array("centre_id = ?" => $centre_id), array("id", "patient_id", "user_id", "service_id", "start")); $view->set("appointments", $appointments); if (RequestMethods::post("action") == "report") { $appt_id = RequestMethods::post("appointment_id"); if (!array_key_exists($appt_id, $appointments)) { $view->set("message", "Invalid request!!"); return; } $appt = $appointments[$appt_id]; $job = Job::first(array("appointment_id = ?" => $appt->id)); if (!$job) { $view->set("message", "Invalid Request!!"); return; } // find emails $user = User::first(array("id = ?" => $appt->user_id), array("email")); $patient = User::first(array("id = ?" => $appt->patient_id), array("email")); if (!$user->email && !$patient->email) { $view->set("message", "No email to send message to"); return; } elseif (!$patient->email) { $emails = $user->email; } else { $emails = array($user->email, $patient->email); $emails = array_unique($emails); } // upload file $file = $this->_upload('file', "files", array("extensions" => "pdf")); if (!$file) { $view->set("message", "File upload failed!!"); return; } $file_path = APP_PATH . '/public/assets/uploads/files/' . $file; $name = $this->organization->name; Shared\Services\Mail::notify(array("emails" => $emails, "delivery" => "sendgrid", "template" => "sendReport", "lab" => $name, "apptime" => \Framework\StringMethods::datetime_to_text($appt->start), "subject" => RequestMethods::post("report_detail"), "attachment" => $file_path)); unlink($file_path); $job->live = 1; $job->save(); $view->set("message", "Sent Successfully"); } }
public function success() { $this->seo(array("title" => "Thank You", "view" => $this->getLayoutView())); $view = $this->getActionView(); $configuration = Registry::get("configuration"); $payment_request_id = RequestMethods::get("payment_request_id"); if ($payment_request_id) { $instamojo = Instamojo::first(array("payment_request_id = ?" => $payment_request_id)); if ($instamojo) { $imojo = $configuration->parse("configuration/payment"); $curl = new Curl(); $curl->setHeader('X-Api-Key', $imojo->payment->instamojo->key); $curl->setHeader('X-Auth-Token', $imojo->payment->instamojo->auth); $curl->get('https://www.instamojo.com/api/1.1/payment-requests/' . $payment_request_id . '/'); $payment = $curl->response; $instamojo->status = $payment->payment_request->status; $instamojo->save(); $order = Order::first(array("id = ?" => $instamojo->purpose_id)); $order->ref_id = $instamojo->id; $order->save(); $appointments = Appointment::all(array("order_id = ?" => $order->id), array("id")); foreach ($appointments as $appointment) { $appointment = Appointment::first(array("id = ?" => $appointment->id)); $appointment->live = 1; $appointment->save(); } $user = User::first(array("id = ?" => $instamojo->user_id)); $point = new Point(array("user_id" => $instamojo->user_id, "property" => "appointment", "property_id" => $instamojo->purpose_id, "unit" => 0.01 * ($order->amount / 1.12))); $point->save(); $this->generateinvoice($order->id, $instamojo->id); Shared\Services\Mail::notify(array("template" => "confirmAppointment", "subject" => "Appointment Confirmed", "appointment" => $appointment, "instamojo" => $instamojo, "point" => $point, "user" => $user, "attachment" => APP_PATH . "/public/assets/uploads/files/orders/{$order->id}.pdf")); } } }
/** * Register the doctor * @before _session */ public function preregister() { $this->seo(array("title" => "Doctor | Pre-Register", "view" => $this->getLayoutView())); $view = $this->getActionView(); $days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]; $view->set("specialities", self::$_specialities)->set("medicine", array("Allopathy", "Homeopathy", "Naturopathy"))->set("days", $days); if (RequestMethods::post("action") == "doctor") { $user = \User::saveRecord(null, false); if (is_array($user)) { $view->set("errors", $user); return; } $doc = \Doc::saveRecord($user, null, false); if (is_array($doc)) { $view->set("errors", $doc); return; } $location = \Location::saveRecord($user, null, true); if (is_array($location)) { unset($location["user_id"]); if (count($location) >= 1) { $view->set("errors", $location); return; } } try { $user->save(); $doc->user_id = $user->id; $doc->save(); $location->user_id = $user->id; $location->save(); $organization = Shared\Services\Doctor::createOrg(array("user" => $user, "location" => $location)); \Slot::saveRecord($user, $organization); } catch (\Exception $e) { $view->set("message", "Email or phone number exists"); return; } $meta = new Meta(array("user_id" => $user->id, "property" => "forgotPass", "value" => uniqid())); $meta->save(); Shared\Services\Mail::notify(array("template" => "doctorRegister", "subject" => "Welcome to HealthLitmus.com", "user" => $user, "meta" => $meta, "verify" => true)); $this->redirect("/auth/success"); } }