/** * @before _secure, _vendor */ public function settings() { $this->seo(array("title" => "Settings", "view" => $this->getLayoutView())); $view = $this->getActionView(); $centre = Centre::first(array("id = ?" => $this->member->centre_id)); $location = Location::first(array("id = ?" => $centre->location_id)); $area = Area::first(array("id = ?" => $location->area_id)); if (RequestMethods::post("action") == "settings") { $phone = RequestMethods::post("phone"); $user = $this->user; $message = null; if ($phone != $user->phone) { $exist = User::first(array("phone = ?" => $phone)); if ($exist) { $message = "Phone number already exists"; } else { $user->phone = $phone; } } $user->name = RequestMethods::post("name"); $user->save(); $this->setUser($user); $location = \Location::saveRecord($user, $location); $phone = RequestMethods::post("cphone"); if ($centre->phone != $phone) { $exist = Centre::first(array("phone = ?" => $phone)); if ($exist) { $message = "Landline already exists!!"; } else { $centre->phone = $phone; $centre->save(); } } if (!$message) { $message = "Info updated!!"; } $view->set("message", $message); } if (RequestMethods::post("action") == "operations") { $operations = RequestMethods::post("operations"); foreach ($operations as $key => $value) { $operation = Operation::first(array("centre_id = ?" => $id, "area_id = ?" => $value)); if (!$operation) { $operation = new Operation(array("user_id" => $this->user->id, "centre_id" => $id, "organization_id" => $this->organization->id, "area_id" => $value, "live" => 1)); $operation->save(); } } } $ops = Operation::all(array("centre_id = ?" => $id), array("area_id")); $opa = array(); foreach ($ops as $o) { $opa[] = $o->area_id; } $view->set("centre", $centre); $view->set("area", $area); $view->set("location", $location); $view->set("opa", $opa); }
public function details($title, $id = '') { $organization = Organization::first(array("id = ?" => $id)); $this->seo(array("title" => $organization->name, "keywords" => $organization->name, "description" => substr(strip_tags($organization->details), 0, 150), "view" => $this->getLayoutView())); $view = $this->getActionView(); $centre = Centre::first(array("organization_id = ?" => $id), array("*"), "created", "desc"); $services = Service::all(array("centre_id = ?" => $centre->id), array("property", "property_id", "charge")); $location = Location::first(array("id = ?" => $centre->location_id), array("street", "area_id", "city_id")); $area = Area::first(array("id = ?" => $location->area_id), array("name")); $city = City::first(array("id = ?" => $location->city_id), array("name")); $view->set("centre", $centre); $view->set("area", $area); $view->set("city", $city); $view->set("location", $location); $view->set("services", $services); $view->set("organization", $organization); }
/** * @before _secure */ public function book() { $this->noview(); $session = Registry::get("session"); $configuration = Registry::get("configuration"); $imojo = $configuration->parse("configuration/payment"); $intoSeconds = function ($value) { $pieces = explode(":", $value); return 3600 * $pieces[0] + 60 * $pieces[1]; }; if (RequestMethods::get("action") == "pickupLocation") { $session->set('Appt\\Book:$location', RequestMethods::get("location_id")); echo "Success"; return; } if (RequestMethods::post("action") != "checkout" || !$session->get('Appt\\Book:$location')) { $this->redirect("/404"); } $charge = base64_decode(RequestMethods::post("tp")); $services = RequestMethods::post("service"); $centre = RequestMethods::post("centre"); $carts = RequestMethods::post("cart"); $order = new Order(array("user_id" => $this->user->id, "type" => "appointment", "amount" => $charge, "mode" => "instamojo", "ref_id" => "")); $order->save(); foreach ($services as $service) { $i = 0; $c = Centre::first(array("id = ?" => $centre[$i]), array("organization_id")); $appointment = new Appointment(array("patient_id" => RequestMethods::post("user_id", $this->user->id), "user_id" => $this->user->id, "order_id" => $order->id, "centre_id" => $centre[$i], "service_id" => $service, "location_id" => $session->get('Appt\\Book:$location'), "organization_id" => $c->organization_id, "start" => strftime("%Y-%m-%d %H:%M:%S", strtotime(RequestMethods::post("start")) + $intoSeconds(RequestMethods::post("startTime"))), "end" => strftime("%Y-%m-%d %H:%M:%S", strtotime(RequestMethods::post("start")) + $intoSeconds(RequestMethods::post("endTime"))), "allDay" => 0)); $appointment->save(); $i++; } $session->erase('Appt\\Book:$location'); $curl = new Curl(); $curl->setHeader('X-Api-Key', $imojo->payment->instamojo->key); $curl->setHeader('X-Auth-Token', $imojo->payment->instamojo->auth); $curl->post('https://www.instamojo.com/api/1.1/payment-requests/', array("purpose" => "Appointment", "amount" => $charge, "buyer_name" => $this->user->name, "email" => $this->user->email, "phone" => $this->user->phone, "redirect_url" => "http://healthlitmus.com/appointments/success", "allow_repeated_payments" => false)); if (!isset($_COOKIE["fixedappointments"])) { setcookie("fixedappointments", 1, time() + 3600 * 24); } else { setcookie("fixedappointments", $_COOKIE["fixedappointments"] + 1, time() + 3600 * 24); } $payment = $curl->response; if ($payment->success == "true") { foreach ($carts as $cart) { $cart = Cart::first(array("id = ?" => $cart)); $cart->delete(); } $session->erase('User\\Cart:$cart')->erase('User\\Cart:$total'); $instamojo = new Instamojo(array("user_id" => $this->user->id, "payment_request_id" => $payment->payment_request->id, "amount" => $payment->payment_request->amount, "purpose" => "order", "purpose_id" => $order->id, "status" => $payment->payment_request->status, "longurl" => $payment->payment_request->longurl, "live" => 1)); $instamojo->save(); $this->redirect($instamojo->longurl); } }
public function appsearch() { $this->JSONview(); $view = $this->getActionView(); $test_ids = RequestMethods::get("test", ""); $city = RequestMethods::get("city", ""); $area = RequestMethods::get("area", ""); $in = implode(",", $test_ids); $size = sizeof($test_ids); $database = Registry::get("database"); $result = $database->execute("SELECT centre_id FROM services WHERE city_id={$city} AND area_id={$area} AND property='test' AND property_id IN ({$in}) GROUP BY centre_id HAVING count(distinct property_id) = {$size}"); $results = array(); for ($i = 0; $i < $result->num_rows; $i++) { $data = $result->fetch_array(MYSQLI_ASSOC); $c = $data["centre_id"]; $centre = Centre::first(array("id = ?" => $c), array("organization_id", "location_id")); $location = Location::first(array("id = ?" => $centre->location_id)); $organization = Organization::first(array("id = ?" => $centre->organization_id), array("name", "id")); $infos = Service::infos($c, $test_ids, $city, $area); array_push($results, array("centre_id" => $c, "street" => $location->street, "org_name" => $organization->name, "org_id" => $organization->id, "charge" => $infos["charge"])); } $alltests = Test::all(array("live = ?" => true), array("id", "title")); $view->set("area", $area); $view->set("city", $city); $view->set("results", $results); $view->set("alltests", $alltests); $view->set("test_ids", $test_ids); }