コード例 #1
0
ファイル: api.php プロジェクト: vNative/vnative
 /**
  * @protected
  * Check API Key
  */
 public function _secure()
 {
     $headers = getallheaders();
     $key = $headers['X-Api-Key'];
     if (!$key) {
         $this->redirect('/api/failure/12');
     }
     $apiKey = ApiKey::first(['key' => $key]);
     if (!$apiKey) {
         $this->redirect('/api/failure/13');
     }
     $ip = Utils::getClientIp();
     if (!in_array($ip, $apiKey->ips)) {
         // $this->redirect('/api/failure/41');
     }
     $this->_org = Organization::first(['_id' => $apiKey->org_id]);
     if ($this->_org->live !== true) {
         $this->redirect('/api/failure/42');
     }
 }
コード例 #2
0
ファイル: patient.php プロジェクト: HLitmus/WebApp
 /**
  * @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);
 }
コード例 #3
0
ファイル: auth.php プロジェクト: SwiftSchool/School
 protected function _checkLogin()
 {
     if (RequestMethods::post("action") == "logmein") {
         $username = RequestMethods::post("username");
         $password = RequestMethods::post("password");
         $user = User::first(array("username = ?" => $username, "live = ?" => true));
         if (!$user) {
             return array("error" => "Invalid username/password");
         }
         if (!Markup::checkHash($password, $user->password)) {
             return array("error" => "Invalid username/password");
         }
         $session = Registry::get("session");
         $this->setUser($user);
         if ($user->admin) {
             self::redirect("/admin");
         }
         $headers = getallheaders();
         $scholar = Scholar::first(array("user_id = ?" => $user->id));
         if ($scholar) {
             $session->set('scholar', $scholar);
             $organization = Organization::first(array("id = ?" => $scholar->organization_id));
             $session->set('organization', $organization);
             if (isset($headers["X-Student-App"])) {
                 $meta = $this->_meta($user, "student");
                 return array("success" => true, "meta" => $meta, "scholar" => $scholar);
             } else {
                 self::redirect("/student");
             }
         }
         $organization = Organization::first(array("user_id = ?" => $user->id));
         if ($organization) {
             $session->set('organization', $organization);
             self::redirect("/school");
         }
         $educator = Educator::first(array("user_id = ?" => $user->id));
         if ($educator) {
             $session->set('educator', $educator);
             $organization = Organization::first(array("id = ?" => $educator->organization_id));
             $session->set('organization', $organization);
             if (isset($headers["X-Teacher-App"])) {
                 $meta = $this->_meta($user, "teacher");
                 return array("success" => true, "meta" => $meta, "educator" => $educator);
             } else {
                 self::redirect("/teacher");
             }
         }
         return array("error" => "Something went wrong please try again later");
     } else {
         return array("error" => "Invalid Request");
     }
 }
コード例 #4
0
ファイル: lab.php プロジェクト: HLitmus/WebApp
 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);
 }
コード例 #5
0
ファイル: doctor.php プロジェクト: HLitmus/WebApp
 /**
  * @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));
 }
コード例 #6
0
ファイル: auth.php プロジェクト: vNative/vnative
 public function logout()
 {
     $session = Registry::get("session");
     $this->setUser(false);
     $admin = $session->get("admin_user_id");
     if (!$admin) {
         session_destroy();
         $this->redirect("/");
     } else {
         $user = User::first(["id = ?" => $admin]);
         $org = Organization::first(["_id = ?" => $user->org_id]);
         $session->erase("admin_user_id");
         $this->_loginRedirect($user, $org);
     }
 }
コード例 #7
0
ファイル: medicaltest.php プロジェクト: HLitmus/WebApp
 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);
 }
コード例 #8
0
ファイル: auth.php プロジェクト: HLitmus/WebApp
 protected function session()
 {
     $session = Registry::get("session");
     $managers = Manager::all(array("user_id = ?" => $this->user->id));
     if ($managers) {
         $session->set("managing", $managers);
         $this->redirect("/admin");
     }
     $member = Member::first(array("user_id = ?" => $this->user->id));
     $doc = Doc::first(array("user_id = ?" => $this->user->id));
     if ($member && !$doc) {
         $organization = Organization::first(array("id = ?" => $member->organization_id));
         $session->set("member", $member);
         $session->set("organization", $organization);
         $this->redirect("/vendor");
     }
     if ($doc && $member) {
         $organization = Organization::first(array("id = ?" => $member->organization_id));
         $session->set("member", $member);
         $session->set("organization", $organization);
         $session->set("doctor", $doc);
         $this->redirect("/doctor");
     }
     $checkout = isset($_COOKIE["__hlCheckout"]) ? true : false;
     if ($checkout) {
         setcookie("__hlCheckout", "", time() - 3600);
         $this->redirect("/cart/checkout");
     }
     $this->redirect("/patient.html");
 }