示例#1
0
文件: doctor.php 项目: HLitmus/WebApp
 public static function createOrg($opts)
 {
     $organization = \Organization::saveRecord(null, array("name" => $opts['user']->name));
     $centre = new \Centre(array("user_id" => $opts['user']->id, "organization_id" => $organization->id, "type" => "clinic", "department" => json_encode(RequestMethods::post("department", array("Clinic"))), "phone" => RequestMethods::post("org_phone", ""), "location_id" => $opts['location']->id));
     $centre->save();
     $member = new \Member(array("user_id" => $opts['user']->id, "centre_id" => $centre->id, "organization_id" => $organization->id, "designation" => "admin", "image" => "", "live" => 1));
     $member->save();
     return $organization;
 }
示例#2
0
文件: lab.php 项目: HLitmus/WebApp
 protected function _saveCenters($centres, $dept)
 {
     $i = 0;
     $errors = array();
     $message = null;
     foreach ($centres as $c) {
         if ($i == 0 && empty($c['phone'])) {
             $errors["phone"][$i] = "Atleast 1 phone number is required";
             break;
         } elseif ($i == 0) {
             if (empty($c['city'])) {
                 $errors["city"][$i] = "1 city is required to save";
                 break;
             } elseif (empty($c['area'])) {
                 $errors["area"][$i] = "1 area is required to save";
                 break;
             }
         }
         $cpe = Centre::first(array("phone = ?" => $c['phone']));
         if ($cpe) {
             $errors["phone"][$i] = "Phone number already exists";
             ++$i;
             continue;
         }
         if (!empty($c['city']) && !empty($c['area'])) {
             $location = Location::first(array("city_id = ?" => $c['city'], "area_id = ?" => $c['area'], "user_id = ?" => $this->user->id, "street = ?" => $c['address']));
             if (!$location) {
                 $location = new Location(array("user_id" => $this->user->id, "area_id" => $c['area'], "city_id" => $c['city'], "street" => $c['address'], "latitude" => "", "longitude" => ""));
                 $location->save();
             }
             $center = new Centre(array("user_id" => $this->user->id, "organization_id" => $this->organization->id, "type" => "lab", "department" => json_encode($dept), "phone" => $c['phone'], "location_id" => $location->id));
             $center->save();
             $message = "Center saved <strong>Successfully!!</strong>";
         } elseif (!empty($c['city']) && empty($c['area'])) {
             $errors["area"][$i] = "Area is required with the city";
         } elseif (empty($c['city']) && !empty($c['area'])) {
             $errors["city"][$i] = "City is required with area";
         }
         ++$i;
     }
     return array("errors" => $errors, "message" => $message);
 }
示例#3
0
文件: vendor.php 项目: HLitmus/WebApp
 /**
  * @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");
         }
     }
 }
 public function postcentres()
 {
     if (Input::has('add')) {
         $rules = array('name' => 'required|string|max:250', 'address' => 'required|string|max:250', 'strength' => 'required|numeric|min:0', 'pincode' => 'required|numeric|digits:6', 'online' => 'required|in:YES,NO');
         $messages = array('name.required' => 'Name field is required', 'address.required' => 'Address field is required', 'strength.required' => 'Strength field is required', 'pincode.required' => 'Pincode field is required', 'name.max' => 'Name(max length):250', 'address.max' => 'Address(max length):250', 'strength.min' => 'Strength (min value):0', 'strength.numeric' => 'Strength can have only digits', 'pincode.numeric' => 'Pincode can have only digits', 'pincode.digits' => 'Pincode length has to be 6 digits', 'online.required' => 'Online option need to be selected', 'online.in' => 'Online value can be either YES or NO');
         $v = Validator::make(Input::all(), $rules, $messages);
         if ($v->fails()) {
             return Redirect::route('crepcentres')->withErrors($v);
         }
         $num = Centre::where('city_id', Auth::crep()->get()->city_id)->count();
         $centre = new Centre();
         $centre->name = Input::get('name');
         $centre->address = Input::get('address');
         $centre->pincode = Input::get('pincode');
         $centre->strength = Input::get('strength');
         $centre->left = Input::get('strength');
         $centre->city_id = Auth::crep()->get()->city_id;
         $centre->code = strval(Auth::crep()->get()->city_id) . chr($num + 65);
         $centre->online = Input::get('online');
         $centre->comments = 'Added by ' . Auth::crep()->get()->name . ' on ' . date('H:i:s d-m-Y', time());
         $centre->save();
         if (Input::get('online') == 'YES' && User::where('paid', 0)->where('centre_city', Auth::crep()->get()->city_id * 10)->where('centre_id', null)->count() > 0) {
             $usernum = User::where('paid', 0)->where('centre_city', Auth::crep()->get()->city_id * 10)->where('centre_id', null)->count();
             if ($usernum > intval($centre->strength)) {
                 $usernum = $centre->strength;
             }
             foreach (User::where('paid', 0)->where('centre_city', Auth::crep()->get()->city_id * 10)->take($usernum)->get() as $user) {
                 $pass = str_random(6);
                 $user->centre_id = $centre->id;
                 $user->result_pass = Crypt::encrypt($pass);
                 $user->save();
             }
             $centre->left = intval($centre->left) - $usernum;
             $centre->save();
         }
         return Redirect::route('crepcentres')->with('success', 'Centre Successfully Added');
     }
     return Redirect::route('crepcentres');
 }