Esempio n. 1
0
 public function save($id = null)
 {
     if ($_POST) {
         $data = new Organization($id);
         if ($_POST['id'] == '') {
             $_POST['created_by'] = $this->user->id;
         } else {
             $_POST['updated_by'] = $this->user->id;
         }
         $data->from_array($_POST);
         $data->show_rest = @$_POST['show_rest'] == '' ? 'n' : $_POST['show_rest'];
         $data->show_public = @$_POST['show_public'] == '' ? 'n' : $_POST['show_public'];
         $data->save();
         $this->db->query("DELETE FROM hotels_organizations WHERE org_id=" . $data->id);
         foreach ($_POST['org_hotel'] as $key => $item) {
             if ($item) {
                 $hotel_org = new Hotel_organization();
                 $hotel_org->hotel_id = $item;
                 $hotel_org->org_id = $data->id;
                 $hotel_org->save();
             }
         }
         $action = @$_POST['id'] > 0 ? 'UPDATE' : 'CREATE';
         save_logs($this->menu_id, $action, @$data->id, $action . ' ' . $data->org_name . ' Organizations ');
     }
     redirect("admin/settings/organizations");
 }
Esempio n. 2
0
 public function executeProcessNewOrgForm(sfWebRequest $request)
 {
     $f = $request->getParameter("organization");
     $p = Doctrine::getTable('Principal')->findOneByFedid($this->getUser()->getUsername());
     $o = new Organization();
     $o->setName($f["name"]);
     $o->setDescription($f["description"]);
     $o->setCreatedAt(date('Y-m-d H:i:s'));
     $o->save();
     $op = new OrganizationPrincipal();
     $op->setOrganization($o);
     $op->setPrincipal($p);
     $op->save();
     $i = new Invitation();
     $i->setEmail($p->getEmail());
     $i->setOrganization($o);
     $i->setUuid('1');
     $i->setCreatedAt(date('Y-m-d H:i:s'));
     $i->setAcceptAt(date('Y-m-d H:i:s'));
     $i->setCounter(1);
     $i->setInviter($p);
     $i->setPrincipal($p);
     $i->setStatus("accepted");
     $i->save();
     $r = new Role();
     $r->setName($f["role_name"]);
     $r->setOrganization($o);
     $r->setShoworder(0);
     $r->save();
     $o->setDefaultRoleId($r->getId());
     $o->save();
     $this->redirect("show/index?id=" . $o->getId());
 }
 function create()
 {
     $organization = new Organization();
     $organization->name = $_POST['name'];
     if ($organization->save()) {
         $this->redirect('/organizations', 'Criado com sucesso!');
     } else {
         $this->redirect('/organizations', 'Falha na criação!');
     }
 }
 public function run()
 {
     $organization = new Organization();
     $organization->name = 'Helpster';
     $organization->date_established = '2015-02-24';
     $organization->description = 'Helpster is a site dedicated to link volunteer organizations to prospecting volunteers';
     $organization->website = 'http://helpster.site';
     $organization->image = 'helpster.png';
     $organization->user_id = 4;
     $organization->save();
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Organization();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Organization'])) {
         $model->attributes = $_POST['Organization'];
         if ($model->save()) {
             $this->redirect(array('view', 'code' => $model->code));
         }
     }
     $this->render('create', array('model' => $model));
 }
 public function update(Organization $org)
 {
     $name = trim(Input::get('name'));
     $redirect = Redirect::route('settings', $org->slug);
     if ($name) {
         $org->name = $name;
         $org->css = Input::get('css', []);
         $org->save();
         return $redirect->withSuccess('Organization updated successfully');
     } else {
         return $redirect->withError('Name may not be blank');
     }
 }
Esempio n. 7
0
 /**
  * Registers new principal and school for platform access
  * @return [type] [description]
  */
 public function register()
 {
     $this->setSEO(array("title" => "Register School"));
     $view = $this->getActionView();
     if (RequestMethods::post("action") == "register") {
         $user = new \User(array("name" => RequestMethods::post("name"), "email" => RequestMethods::post("email"), "phone" => RequestMethods::post("phone"), "username" => strtolower(implode("", explode(" ", RequestMethods::post("name")))), "password" => Markup::encrypt("password"), "admin" => 0));
         $user->save();
         $location = new Location(array("user_id" => $user->id, "address" => RequestMethods::post("address"), "city" => RequestMethods::post("city"), "latitude" => "", "longitude" => ""));
         $location->save();
         $organization = new Organization(array("user_id" => $user->id, "name" => RequestMethods::post("sname"), "location_id" => $location->id, "phone" => RequestMethods::post("sphone"), "logo" => ""));
         $organization->save();
         $view->set("success", true);
     }
 }
 public function save($id = null)
 {
     if ($_POST) {
         $data = new Organization($id);
         if ($_POST['id'] == '') {
             $_POST['created_by'] = $this->user->id;
         } else {
             $_POST['updated_by'] = $this->user->id;
         }
         $data->from_array($_POST);
         $data->save();
         $action = @$_POST['id'] > 0 ? 'UPDATE' : 'CREATE';
         save_logs($this->menu_id, $action, @$data->id, $action . ' ' . $data->org_name . ' Organizations ');
     }
     redirect("admin/settings/organizations");
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     if ($this->menu_use[6]) {
         $model = new Organization();
         // Uncomment the following line if AJAX validation is needed
         // $this->performAjaxValidation($model);
         if (isset($_POST['Organization'])) {
             $_POST['Organization']['user_id'] = Yii::app()->user->id;
             $model->attributes = $_POST['Organization'];
             if ($model->save()) {
                 $this->redirect(array('index'));
             }
         }
         $this->render('create', array('model' => $model));
     } else {
         $this->redirect(array('site/index'));
     }
 }
 public function postCreate()
 {
     $validator = Validator::make(Input::all(), Organization::$rules);
     if ($validator->passes()) {
         //Upload the logo
         $file = Input::file('image');
         $upload_success = Input::file('image')->move('public/uploads', $file->getClientOriginalName());
         //save the register
         $organization = new Organization();
         $organization->name = Input::get('name');
         $organization->test = Input::get('test');
         $organization->logo = $file->getClientOriginalName();
         $organization->address = Input::get('address');
         $organization->save();
         return Redirect::to('organization/new')->with('message', 'Registro creado con exito');
     } else {
         return Redirect::to('organization/new')->with('error', 'Ocurrieron los siguientes errores')->withErrors($validator)->withInput();
     }
 }
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param PropelPDO $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aUser !== null) {
             if ($this->aUser->isModified() || $this->aUser->isNew()) {
                 $affectedRows += $this->aUser->save($con);
             }
             $this->setUser($this->aUser);
         }
         if ($this->aOrganization !== null) {
             if ($this->aOrganization->isModified() || $this->aOrganization->isNew()) {
                 $affectedRows += $this->aOrganization->save($con);
             }
             $this->setOrganization($this->aOrganization);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Esempio n. 12
0
 }
 // check if orga shortname exists
 $organization = new Organization($gDb, $_POST['orgaShortName']);
 if ($organization->getValue('org_id') > 0) {
     $gMessage->show($gL10n->get('INS_ORGA_SHORTNAME_EXISTS', $_POST['orgaShortName']));
 }
 // set execution time to 2 minutes because we have a lot to do :)
 // there should be no error output because of safe mode
 @set_time_limit(120);
 $gDb->startTransaction();
 // create new organization
 $newOrganization = new Organization($gDb, $_POST['orgaShortName']);
 $newOrganization->setValue('org_longname', $_POST['orgaLongName']);
 $newOrganization->setValue('org_shortname', $_POST['orgaShortName']);
 $newOrganization->setValue('org_homepage', $_SERVER['HTTP_HOST']);
 $newOrganization->save();
 // write all preferences from preferences.php in table adm_preferences
 require_once '../../installation/db_scripts/preferences.php';
 // set some specific preferences whose values came from user input of the installation wizard
 $orga_preferences['email_administrator'] = $_POST['orgaEmail'];
 $orga_preferences['system_language'] = $gPreferences['system_language'];
 // create all necessary data for this organization
 $newOrganization->setPreferences($orga_preferences, false);
 $newOrganization->createBasicData($gCurrentUser->getValue('usr_id'));
 // if installation of second organization than show organization select at login
 if ($gCurrentOrganization->countAllRecords() === 2) {
     $sql = 'UPDATE ' . TBL_PREFERENCES . ' SET prf_value = 1
          WHERE prf_name = \'system_organization_select\' ';
     $gDb->query($sql);
 }
 $gDb->endTransaction();
Esempio n. 13
0
 function voluntary_work($employee_id = '')
 {
     $data['page_name'] = '<b>Personal Data Sheet</b>';
     $data['section_name'] = '<b>Personal Information</b>';
     $data['focus_field'] = 'org_name';
     $data['msg'] = '';
     $e = new Employee_m();
     $data['employee'] = $e->get_by_id($employee_id);
     if (Input::get('op')) {
         // VOLUNTARY WORK OR INVOLVEMENT=========================
         $org_name = Input::get('org_name');
         $org_inclusive_date_from = Input::get('org_inclusive_date_from');
         $org_inclusive_date_to = Input::get('org_inclusive_date_to');
         $org_number_of_hours = Input::get('org_number_of_hours');
         $org_position = Input::get('org_position');
         $org = new Organization();
         $org->get_by_employee_id($employee_id);
         $org->delete_all();
         $i = 0;
         foreach ($org_name as $org) {
             if ($org != "") {
                 $organization = new Organization();
                 $organization->employee_id = $employee_id;
                 $organization->name = $org_name[$i];
                 $organization->inclusive_date_from = $org_inclusive_date_from[$i];
                 $organization->inclusive_date_to = $org_inclusive_date_to[$i];
                 $organization->number_of_hours = $org_number_of_hours[$i];
                 $organization->position = $org_position[$i];
                 $organization->save();
             }
             $i++;
         }
         $data['msg'] = 'Voluntary Work has been saved!';
     }
     // Voluntary work or involvement ======================================
     $org = new Organization();
     $org->order_by('inclusive_date_from', 'DESC');
     $data['orgs'] = $org->get_by_employee_id($employee_id);
     $data['selected'] = $e->office_id;
     //Use for office listbox
     $data['options'] = $this->options->office_options();
     $data['employee_id'] = $employee_id;
     $data['main_content'] = 'voluntary_work';
     return View::make('includes/template', $data);
 }
Esempio n. 14
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param PropelPDO $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aUser !== null) {
             if ($this->aUser->isModified() || $this->aUser->isNew()) {
                 $affectedRows += $this->aUser->save($con);
             }
             $this->setUser($this->aUser);
         }
         if ($this->aOrganization !== null) {
             if ($this->aOrganization->isModified() || $this->aOrganization->isNew()) {
                 $affectedRows += $this->aOrganization->save($con);
             }
             $this->setOrganization($this->aOrganization);
         }
         if ($this->aChartRelatedByForkedFrom !== null) {
             if ($this->aChartRelatedByForkedFrom->isModified() || $this->aChartRelatedByForkedFrom->isNew()) {
                 $affectedRows += $this->aChartRelatedByForkedFrom->save($con);
             }
             $this->setChartRelatedByForkedFrom($this->aChartRelatedByForkedFrom);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         if ($this->chartsRelatedByIdScheduledForDeletion !== null) {
             if (!$this->chartsRelatedByIdScheduledForDeletion->isEmpty()) {
                 foreach ($this->chartsRelatedByIdScheduledForDeletion as $chartRelatedById) {
                     // need to save related object because we set the relation to null
                     $chartRelatedById->save($con);
                 }
                 $this->chartsRelatedByIdScheduledForDeletion = null;
             }
         }
         if ($this->collChartsRelatedById !== null) {
             foreach ($this->collChartsRelatedById as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->jobsScheduledForDeletion !== null) {
             if (!$this->jobsScheduledForDeletion->isEmpty()) {
                 JobQuery::create()->filterByPrimaryKeys($this->jobsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->jobsScheduledForDeletion = null;
             }
         }
         if ($this->collJobs !== null) {
             foreach ($this->collJobs as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Esempio n. 15
0
 public function setOrganization($orgID, $orgName)
 {
     $config = new Configuration();
     //if the org module is installed get the org name from org database
     if ($config->settings->organizationsModule == 'Y') {
         //if no org ID was passed in then we need to create a new organization shell
         if (!$orgID) {
             $dbName = $config->settings->organizationsDatabaseName;
             $orgName = str_replace("'", "''", $orgName);
             $query = "INSERT INTO " . $dbName . ".Organization (name, createDate, createLoginID) VALUES ('" . $orgName . "', NOW(), '" . $_SESSION['loginID'] . "')";
             $this->organizationID = $this->db->processQuery($query);
         } else {
             $this->organizationID = $orgID;
         }
         //otherwise if the org module is not installed get the org name from this database
     } else {
         //if no org ID was passed in then we need to create a new provider
         if (!$orgID) {
             $organization = new Organization();
             $organization->organizationID = '';
             $organization->shortName = $orgName;
             $organization->save();
             $this->organizationID = $organization->primaryKey;
         } else {
             $this->organizationID = $orgID;
         }
     }
 }
Esempio n. 16
0
    if_is_admin(function () use($app) {
        try {
            $params = json_decode($app->request()->getBody(), true);
            // check if organization id already exists
            if (OrganizationQuery::create()->findPk($params['id'])) {
                error('id-already-exists', 'Sorry, there is already an organization with that id.');
                return;
            }
            $org = new Organization();
            $org->setId(strtolower($params['id']));
            $org->setName($params['name']);
            if (isset($params['default_theme'])) {
                $org->setDefaultTheme($params['default_theme']);
            }
            $org->setCreatedAt(time());
            $org->save();
            ok();
        } catch (Exception $e) {
            error('io-error', $e->getMessage());
        }
    });
});
/*
 * change organization
 */
$app->put('/organizations/:id', function ($org_id) use($app) {
    if_is_admin(function () use($app, $org_id) {
        $org = OrganizationQuery::create()->findPk($org_id);
        if ($org) {
            $params = json_decode($app->request()->getBody(), true);
            if (isset($params['name'])) {
 public function postAdd()
 {
     $organization = new Organization();
     $organization->full_name = Input::get('full_name');
     $organization->short_name = Input::get('short_name');
     $organization->inn = Input::get('inn');
     $organization->kpp = Input::get('kpp');
     $organization->legal_address = Input::get('legal_address');
     $organization->fact_address = Input::get('fact_address');
     $organization->boss_position = Input::get('boss_position');
     $organization->fio = Input::get('fio');
     $organization->date = Input::get('date');
     $organization->contract_number = Input::get('contract_number');
     $organization->operate_foundation = Input::get('operate_foundation');
     $organization->rs = Input::get('rs');
     $organization->ks = Input::get('ks');
     $organization->ls = Input::get('ls');
     $organization->bank = Input::get('bank');
     $organization->bik = Input::get('bik');
     $organization->phone = Input::get('phone');
     $organization->email = Input::get('email');
     $organization->last_document_number = 1;
     $organization->save();
     $user = new User();
     $user->first_name = Input::get('first_name');
     $user->last_name = Input::get('last_name');
     $user->surname = Input::get('surname');
     $user->username = Input::get('username');
     $user->password = Input::get('password');
     $organization->user()->save($user);
     return Redirect::action('AdminController@index');
 }
 private function createOrganizationRecursive($item, &$result)
 {
     $org = new Organization();
     $org->name = $item->org_name;
     $org->save();
     $parentId = $org->id;
     $result[] = $org->cast();
     $org->reset();
     if (isset($item->daughters)) {
         foreach ($item->daughters as $daughter) {
             $id = $this->createOrganizationRecursive($daughter, $result);
             if ($id) {
                 $this->create($parentId, $id, 'parent');
             }
         }
     }
     if (isset($item->related)) {
         foreach ($item->related as $related) {
             $id = $this->createOrganizationRecursive($related, $result);
             if ($id) {
                 $this->create($parentId, $id, 'related');
             }
         }
     }
     return $parentId;
 }
Esempio n. 19
0
                     array_push($arrayOrganizationsCreated, $organizationName);
                 }
             } catch (Exception $e) {
                 print "<p>Unable to associate organization {$organizationName} with its role.</p>";
             }
         }
     }
     // If we do not use the Organizations module
 } else {
     // Search if such organization already exists
     $organizationExists = $organization->alreadyExists($organizationName);
     $parentID = null;
     if (!$organizationExists) {
         // If not, create it
         $organization->shortName = $organizationName;
         $organization->save();
         $organizationID = $organization->organizationID();
         $organizationsInserted++;
         array_push($arrayOrganizationsCreated, $organizationName);
     } elseif ($organizationExists == 1) {
         // Else,
         $organizationID = $organization->getOrganizationIDByName($organizationName);
         $organizationsAttached++;
     } else {
         print "<p>Error: more than one organization is called {$organizationName}. Please consider deduping.</p>";
     }
     // Find role
     $organizationRoles = $organizationRole->getArray();
     if (($roleID = array_search($data[$_POST['role']], $organizationRoles)) == 0) {
         // If role is not found, fallback to the first one.
         $roleID = '1';
Esempio n. 20
0
 public function run()
 {
     $branch = new Branch();
     $branch->name = 'Head Office';
     $branch->save();
     $currency = new Currency();
     $currency->name = 'Kenyan Shillings';
     $currency->shortname = 'KES';
     $currency->save();
     $organization = new Organization();
     $organization->name = 'Lixnet Technologies';
     $organization->save();
     $share = new Share();
     $share->value = 0;
     $share->transfer_charge = 0;
     $share->charged_on = 'donor';
     $share->save();
     $perm = new Permission();
     $perm->name = 'create_employee';
     $perm->display_name = 'Create employee';
     $perm->category = 'Employee';
     $perm->save();
     $perm = new Permission();
     $perm->name = 'update_employee';
     $perm->display_name = 'Update employee';
     $perm->category = 'Employee';
     $perm->save();
     $perm = new Permission();
     $perm->name = 'delete_employee';
     $perm->display_name = 'Deactivate employee';
     $perm->category = 'Employee';
     $perm->save();
     $perm = new Permission();
     $perm->name = 'view_employee';
     $perm->display_name = 'View employee';
     $perm->category = 'Employee';
     $perm->save();
     $perm = new Permission();
     $perm->name = 'manage_earning';
     $perm->display_name = 'Manage earnings';
     $perm->category = 'Payroll';
     $perm->save();
     $perm = new Permission();
     $perm->name = 'manage_deduction';
     $perm->display_name = 'Manage deductions';
     $perm->category = 'Payroll';
     $perm->save();
     $perm = new Permission();
     $perm->name = 'manage_allowance';
     $perm->display_name = 'Manage allowance';
     $perm->category = 'Payroll';
     $perm->save();
     $perm = new Permission();
     $perm->name = 'manage_relief';
     $perm->display_name = 'Manage releif';
     $perm->category = 'Payroll';
     $perm->save();
     $perm = new Permission();
     $perm->name = 'manage_benefit';
     $perm->display_name = 'Manage benefits';
     $perm->category = 'Payroll';
     $perm->save();
     $perm = new Permission();
     $perm->name = 'process_payroll';
     $perm->display_name = 'Process payroll';
     $perm->category = 'Payroll';
     $perm->save();
     $perm = new Permission();
     $perm->name = 'view_payroll_report';
     $perm->display_name = 'View reports';
     $perm->category = 'Payroll';
     $perm->save();
     $perm = new Permission();
     $perm->name = 'manage_settings';
     $perm->display_name = 'Manage settings';
     $perm->category = 'Payroll';
     $perm->save();
     $perm = new Permission();
     $perm->name = 'view_application';
     $perm->display_name = 'View applications';
     $perm->category = 'Leave';
     $perm->save();
     $perm = new Permission();
     $perm->name = 'amend_application';
     $perm->display_name = 'Amend applications';
     $perm->category = 'Leave';
     $perm->save();
     $perm = new Permission();
     $perm->name = 'approve_application';
     $perm->display_name = 'Approve applications';
     $perm->category = 'Leave';
     $perm->save();
     $perm = new Permission();
     $perm->name = 'reject_application';
     $perm->display_name = 'Reject applications';
     $perm->category = 'Leave';
     $perm->save();
     $perm = new Permission();
     $perm->name = 'cancel_application';
     $perm->display_name = 'Cancel applications';
     $perm->category = 'Leave';
     $perm->save();
     $perm = new Permission();
     $perm->name = 'manage_type';
     $perm->display_name = 'Manage leave types';
     $perm->category = 'Leave';
     $perm->save();
     $perm = new Permission();
     $perm->name = 'manage_holiday';
     $perm->display_name = 'Manage holidays';
     $perm->category = 'Leave';
     $perm->save();
     $perm = new Permission();
     $perm->name = 'view_leave_report';
     $perm->display_name = 'View reports';
     $perm->category = 'Leave';
     $perm->save();
     $perm = new Permission();
     $perm->name = 'manage_organization';
     $perm->display_name = 'manage organization';
     $perm->category = 'Organization';
     $perm->save();
     $perm = new Permission();
     $perm->name = 'manage_branch';
     $perm->display_name = 'manage branches';
     $perm->category = 'Organization';
     $perm->save();
     $perm = new Permission();
     $perm->name = 'manage_group';
     $perm->display_name = 'manage groups';
     $perm->category = 'Organization';
     $perm->save();
     $perm = new Permission();
     $perm->name = 'manage_organization_settings';
     $perm->display_name = 'manage settings';
     $perm->category = 'Organization';
     $perm->save();
     $perm = new Permission();
     $perm->name = 'manage_user';
     $perm->display_name = 'manage users';
     $perm->category = 'System';
     $perm->save();
     $perm = new Permission();
     $perm->name = 'manage_role';
     $perm->display_name = 'manage roles';
     $perm->category = 'System';
     $perm->save();
     $perm = new Permission();
     $perm->name = 'manage_audit';
     $perm->display_name = 'manage audits';
     $perm->category = 'System';
     $perm->save();
     $perms = Permission::all();
     $pers = array();
     foreach ($perms as $p) {
         $pers[] = $p->id;
     }
     $role = new Role();
     $role->name = 'superadmin';
     $role->save();
     $role->perms()->sync($pers);
     $data = array('username' => 'superadmin', 'email' => '*****@*****.**', 'password' => 'superadmin', 'password_confirmation' => 'superadmin', 'user_type' => 'admin', 'organization_id' => 1);
     $repo = App::make('UserRepository');
     $user = $repo->register($data);
     $user->attachRole($role);
     /*
         $perm = new Permission;
         $perm->name = 'view_loan_product';
         $perm->display_name = 'view loan products';
         $perm->category = 'Loanproduct';
         $perm->save();
         $perm = new Permission;
         $perm->name = 'delete_loan_product';
         $perm->display_name = 'delete loan products';
         $perm->category = 'Loanproduct';
         $perm->save();
         $perm = new Permission;
         $perm->name = 'create_loan_account';
         $perm->display_name = 'create loan account';
         $perm->category = 'Loanaccount';
         $perm->save();
         $perm = new Permission;
         $perm->name = 'view_loan_account';
         $perm->display_name = 'view loan account';
         $perm->category = 'Loanaccount';
         $perm->save();
         $perm = new Permission;
         $perm->name = 'approve_loan_account';
         $perm->display_name = 'approve loan';
         $perm->category = 'Loanaccount';
         $perm->save();
         $perm = new Permission;
         $perm->name = 'disburse_loan';
         $perm->display_name = 'disburse loan';
         $perm->category = 'Loanaccount';
         $perm->save();
         $perm = new Permission;
         $perm->name = 'view_savings_account';
         $perm->display_name = 'view savings account';
         $perm->category = 'Savingaccount';
         $perm->save();
         $perm = new Permission;
         $perm->name = 'open_saving_account';
         $perm->display_name = 'Open savings account';
         $perm->category = 'Savingaccount';
         $perm->save();
     */
 }
Esempio n. 21
0
         VALUES (' . $cat_id_master_inf . ', \'TEXT\', \'ITEM_NAME\', \'SYS_ITEMNAME\', NULL, 1, 1, 1, 1, ' . $gCurrentUser->getValue('usr_id') . ',\'' . DATETIME_NOW . '\')
              , (' . $cat_id_master_inf . ', \'NUMBER\', \'ROOM_ID\', \'SYS_ROOM\', NULL, 1, 1, 1, 2, ' . $gCurrentUser->getValue('usr_id') . ',\'' . DATETIME_NOW . '\')
              , (' . $cat_id_master_inf . ', \'NUMBER\', \'PRICE\',   \'SYS_QUANTITY\', NULL, 0, 0, 0, 3, ' . $gCurrentUser->getValue('usr_id') . ',\'' . DATETIME_NOW . '\') ';
 $db->query($sql);
 if ($gDbType === 'postgresql') {
     // soundex is not a default function in PostgreSQL
     $sql = 'UPDATE ' . TBL_PREFERENCES . ' SET prf_value = \'0\'
              WHERE prf_name LIKE \'system_search_similar\'';
     $db->query($sql);
 }
 // create new organization
 $gCurrentOrganization = new Organization($db, $_SESSION['orga_shortname']);
 $gCurrentOrganization->setValue('org_longname', $_SESSION['orga_longname']);
 $gCurrentOrganization->setValue('org_shortname', $_SESSION['orga_shortname']);
 $gCurrentOrganization->setValue('org_homepage', $_SERVER['HTTP_HOST']);
 $gCurrentOrganization->save();
 // create user webmaster and assign roles
 $webmaster = new TableUsers($db);
 $webmaster->setValue('usr_login_name', $_SESSION['user_login']);
 $webmaster->setPassword($_SESSION['user_password']);
 $webmaster->setValue('usr_usr_id_create', $gCurrentUser->getValue('usr_id'));
 $webmaster->setValue('usr_timestamp_create', DATETIME_NOW);
 $webmaster->save(false);
 // no registered user -> UserIdCreate couldn't be filled
 // write all preferences from preferences.php in table adm_preferences
 require_once 'db_scripts/preferences.php';
 // set some specific preferences whose values came from user input of the installation wizard
 $orga_preferences['email_administrator'] = $_SESSION['orga_email'];
 $orga_preferences['system_language'] = $language;
 // calculate the best cost value for your server performance
 $benchmarkResults = PasswordHashing::costBenchmark();