Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 /**
  * @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");
         }
     }
 }