コード例 #1
0
ファイル: PersonaController.php プロジェクト: bmrpas/SHREDDER
 public function add_persona()
 {
     $inputs = Input::all();
     $rules = array('persona_cid' => 'required|integer|unique:persona,persona_cid', 'persona_primer_apellido' => 'required|max:50|alpha:persona,persona_primer_apellido', 'persona_segundo_apellido' => 'required|max:50|alpha:persona,persona_segundo_apellido', 'persona_primer_nombre' => 'required|max:50|alpha:persona,persona_primer_nombre', 'persona_segundo_nombre' => 'max:50|alpha:persona,persona_segundo_nombre', 'persona_sexo' => 'required|max:1|alpha:persona,persona_sexo', 'persona_fecha_nac' => 'required|date:persona,persona_fecha_nac', 'persona_grado_instruccion' => 'required|max:20|alpha:persona,persona_grado_instruccion', 'persona_mail' => 'required|max:50|email:persona,persona_mail', 'persona_departamento' => 'alpha|max:50:persona,persona_departamento');
     $validator = Validator::make($inputs, $rules);
     if ($validator->fails()) {
         return Redirect::back()->withInput()->withErrors($validator);
     } else {
         $persona = new Person();
         $persona->persona_cid = Input::get('persona_cid');
         $persona->persona_primer_apellido = Input::get('persona_primer_apellido');
         $persona->persona_segundo_apellido = Input::get('persona_segundo_apellido');
         $persona->persona_primer_nombre = Input::get('persona_primer_nombre');
         if (Input::get('persona_segundo_nombre') != 'NULL') {
             $persona->persona_segundo_nombre = Input::get('persona_segundo_nombre');
         } else {
             $persona->persona_segundo_nombre = null;
         }
         $persona->persona_sexo = Input::get('persona_sexo');
         $persona->persona_fecha_nac = Input::get('persona_fecha_nac');
         $persona->persona_grado_instruccion = Input::get('persona_grado_instruccion');
         $persona->persona_mail = Input::get('persona_mail');
         if (Input::get('persona_departamento') != 'NULL') {
             $persona->persona_departamento = Input::get('persona_departamento');
         } else {
             $persona->persona_departamento = NULL;
         }
         $persona->fk_profesion = Input::get('fk_profesion');
         $persona->fk_cargo = Input::get('fk_cargo');
         $persona->fk_lugar = Input::get('fk_lugar');
         if (Input::get('fk_persona_a_quien_autorizo') != 'NULL') {
             $persona->fk_persona_a_quien_autorizo = Input::get('fk_persona_a_quien_autorizo');
             $persona->fk_persona_quien_me_autorizo = NULL;
             $persona->persona_es_autorizado = FALSE;
             $persona->save();
             $persona_a_quien_autorizo = Person::find($persona->fk_persona_a_quien_autorizo);
             $persona_a_quien_autorizo->persona_es_autorizado = TRUE;
             $persona_a_quien_autorizo->fk_persona_quien_me_autorizo = $persona->id;
             $persona_a_quien_autorizo->save();
             return Redirect::to('persona');
         } else {
             $persona->fk_persona_a_quien_autorizo = NULL;
             $persona->fk_persona_quien_me_autorizo = NULL;
             $persona->persona_es_autorizado = FALSE;
             $persona->save();
             return Redirect::to('persona');
         }
         return Redirect::to('persona');
     }
 }
コード例 #2
0
ファイル: persons.php プロジェクト: andrejjursa/lstme-ledcoin
 public function create_person()
 {
     $form = $this->get_form();
     build_validator_from_form($form);
     if ($this->form_validation->run()) {
         $this->db->trans_begin();
         $person_data = $this->input->post('person');
         $person = new Person();
         $person->from_array($person_data, array('name', 'surname', 'login', 'organisation', 'admin'));
         $person->password = sha1($person_data['password']);
         $person->enabled = 1;
         $group = new Group();
         $group->get_by_id((int) $person_data['group_id']);
         if ($person->save($group) && $this->db->trans_status()) {
             $this->db->trans_commit();
             add_success_flash_message('Osoba menom <strong>' . $person_data['name'] . ' ' . $person_data['surname'] . '</strong> s loginom <strong>' . $person_data['login'] . '</strong> bola vytvorená s ID <strong>' . $person->id . '</strong>.');
             redirect(site_url('persons'));
         } else {
             $this->db->trans_rollback();
             add_error_flash_message('Osobu sa nepodarilo vytvoriť, skúste to znovu neskôr.');
             redirect(site_url('persons/new_person'));
         }
     } else {
         $this->new_person();
     }
 }
コード例 #3
0
ファイル: BasePersonalNote.php プロジェクト: yasirgit/afids
 /**
  * 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->aPerson !== null) {
             if ($this->aPerson->isModified() || $this->aPerson->isNew()) {
                 $affectedRows += $this->aPerson->save($con);
             }
             $this->setPerson($this->aPerson);
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = PersonalNotePeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setNew(false);
             } else {
                 $affectedRows += PersonalNotePeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
コード例 #4
0
ファイル: Employee.class.php プロジェクト: eebrah/schoolsys
    function save()
    {
        global $dbh;
        $returnValue = false;
        if (parent::save()) {
            $query = '
INSERT INTO `employeeDetails` (
	  `uniqueID`
	, `IDNumber`
	, `KRAPIN`
	, `dateOfEmployment`
)
VALUES (
	  "' . mysql_escape_string($this->getUniqueID()) . '"
	, "' . mysql_escape_string($this->getIDNumber()) . '"
	, "' . mysql_escape_string($this->getKRAPIN()) . '"
	, "' . mysql_escape_string($this->getDateOfEmployment()) . '"
)';
            try {
                $dbh->beginTransaction();
                $dbh->exec($query);
                $dbh->commit();
                $returnValue = true;
            } catch (PDOException $e) {
                print "Error!: " . $e->getMessage() . "<br/>";
                die;
            }
            $returnValue = true;
        }
        return $returnValue;
    }
コード例 #5
0
ファイル: actions.class.php プロジェクト: nathanlon/twical
 /**
  * Create the person or find it.
  */
 public function executeTwitterCallback(sfWebRequest $request)
 {
     $user = $this->getUser();
     $this->isAuthenticated = false;
     if ($user->isAuthenticated() == true) {
         $this->isAuthenticated = true;
         $guardUser = $user->getGuardUser();
         $guardUserId = $guardUser->getId();
         $token = $user->getAttribute('sfTwitterAuth_oauth_access_token');
         $secret = $user->getAttribute('sfTwitterAuth_oauth_access_token_secret');
         //look for a person with this guard user id already.
         $q = Doctrine_Query::create()->from('Person p')->where('p.sf_guard_user_id = ?', $guardUserId);
         $person = $q->fetchOne();
         $personTable = Doctrine_Core::getTable('Person');
         $person = $personTable->findOneBy('sf_guard_user_id', $guardUserId);
         $this->addedPerson = false;
         $this->personSQLQuery = "GuardUserID={$guardUserId} " . $q->getSqlQuery();
         // . "params = " . print_r($q->getParams(), true);
         if ($person === false) {
             $person = new Person();
             $person->setSfGuardUserId($guardUserId);
             $person->setTwitterToken($token);
             $person->setTwitterSecret($secret);
             $person->save();
             $this->addedPerson = true;
         }
         $personId = $person->getId();
         $user->setPersonId($personId);
         $this->personId = $personId;
         $this->redirect('@homepage');
     }
 }
コード例 #6
0
ファイル: Publish.php プロジェクト: uzerpllp/uzerp
 public function systemCompany(&$do, &$errors)
 {
     $user = getCurrentUser();
     $person = new Person();
     $person->load($user->person_id);
     $format = new xmlrpcmsg('elgg.user.newCommunity', array(new xmlrpcval($person->firstname . ' ' . $person->surname, "string"), new xmlrpcval($person->email, "string"), new xmlrpcval($do->company, "string")));
     $client = new xmlrpc_client("_rpc/RPC2.php", "tech2.severndelta.co.uk", 8091);
     $request = $client->send($format);
     if (!$request->faultCode()) {
         $response = $request->value();
         if ($response->structmemexists('owner') && $response->structmemexists('community')) {
             $person->published_username = $response->structmem('owner')->scalarval();
             $person->save();
             $do->published = true;
             $do->published_username = $response->structmem('community')->scalarval();
             $do->published_owner_id = $person->id;
             $do->save();
         } else {
             $errors[] = 'Failed to publish company';
         }
     } else {
         $errors[] = "Code: " . $request->faultCode() . " Reason '" . $request->faultString();
         return false;
     }
     return true;
 }
コード例 #7
0
ファイル: Employee.php プロジェクト: mnapier/opensourcepos
 public function save_employee(&$person_data, &$employee_data, &$grants_data, $employee_id = FALSE)
 {
     $success = FALSE;
     //Run these queries as a transaction, we want to make sure we do all or nothing
     $this->db->trans_start();
     if (parent::save($person_data, $employee_id)) {
         if (!$employee_id || !$this->exists($employee_id)) {
             $employee_data['person_id'] = $employee_id = $person_data['person_id'];
             $success = $this->db->insert('employees', $employee_data);
         } else {
             $this->db->where('person_id', $employee_id);
             $success = $this->db->update('employees', $employee_data);
         }
         //We have either inserted or updated a new employee, now lets set permissions.
         if ($success) {
             //First lets clear out any grants the employee currently has.
             $success = $this->db->delete('grants', array('person_id' => $employee_id));
             //Now insert the new grants
             if ($success) {
                 foreach ($grants_data as $permission_id) {
                     $success = $this->db->insert('grants', array('permission_id' => $permission_id, 'person_id' => $employee_id));
                 }
             }
         }
     }
     $this->db->trans_complete();
     $success &= $this->db->trans_status();
     return $success;
 }
コード例 #8
0
 public function save($deep = true)
 {
     if (!$this->Username) {
         $this->Username = static::getUniqueUsername($this->FirstName, $this->LastName);
     }
     return parent::save($deep);
 }
コード例 #9
0
ファイル: Router.php プロジェクト: xama5/uver-erp
 public function add()
 {
     $person = new Person();
     $person->save();
     (new Customer())->setPerson($person)->save();
     $this->getRequest()->redirect("person", "edit", array("id" => $person->getId()));
 }
コード例 #10
0
ファイル: Router.php プロジェクト: xama5/uver-erp
 public function add_post()
 {
     $person = new Person();
     $person->save();
     (new Employee())->setPerson($person)->setHours($_POST["hours"])->setWage($_POST["wage"])->save();
     $this->getRequest()->redirect("person", "edit", array("id" => $person->getId()));
 }
コード例 #11
0
ファイル: PersonController.php プロジェクト: pdooley/genesis
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Person();
     $model->attributes = $_POST;
     $result = $model->save();
     $this->sendAjaxResponse($model);
 }
コード例 #12
0
ファイル: UserController.php プロジェクト: nurielmeni/nymedia
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $user = new User('passwordset');
     $person = new Person();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['User'], $_POST['Person'])) {
         $person->attributes = $_POST['Person'];
         if ($person->save()) {
             $user->attributes = $_POST['User'];
             $user->person_id = $person->id;
             if ($user->save()) {
                 // Assign a role to the user
                 $command = Yii::app()->db->createCommand();
                 $effectedRows = $command->insert('auth_assignment', array('itemname' => $user->user_role, 'userid' => $user->id, 'bizrule' => '', 'data' => 's:0:"";'));
                 if ($effectedRows == 1) {
                     Yii::app()->user->setFlash('success', Yii::t('user', 'User created and assigned to Role successfuly.'));
                 } else {
                     Yii::app()->user->setFlash('error', Yii::t('user', 'user assignment to Role failed.'));
                 }
                 $this->redirect(array('view', 'id' => $user->id));
             } else {
                 Yii::app()->user->setFlash('error', Yii::t('user', 'user creation failed.'));
             }
         } else {
             Yii::app()->user->setFlash('error', Yii::t('user', 'person creation failed.'));
         }
     }
     $this->render('create', array('user' => $user, 'person' => $person));
 }
コード例 #13
0
 public function save()
 {
     try {
         $model = new Person($this->data->id);
         $model->setData($this->data->person);
         $model->save();
         $this->renderPrompt('information', 'OK');
     } catch (\Exception $e) {
         $this->renderPrompt('error', $e->getMessage());
     }
 }
コード例 #14
0
ファイル: BaseCompanion.php プロジェクト: yasirgit/afids
 /**
  * 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->aPassenger !== null) {
             if ($this->aPassenger->isModified() || $this->aPassenger->isNew()) {
                 $affectedRows += $this->aPassenger->save($con);
             }
             $this->setPassenger($this->aPassenger);
         }
         if ($this->aPerson !== null) {
             if ($this->aPerson->isModified() || $this->aPerson->isNew()) {
                 $affectedRows += $this->aPerson->save($con);
             }
             $this->setPerson($this->aPerson);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = CompanionPeer::ID;
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = CompanionPeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setId($pk);
                 //[IMV] update autoincrement primary key
                 $this->setNew(false);
             } else {
                 $affectedRows += CompanionPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         if ($this->collMissionCompanions !== null) {
             foreach ($this->collMissionCompanions as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
コード例 #15
0
ファイル: personTest.php プロジェクト: JakeDawkins/NiceCatch
 public function testDelete()
 {
     $person = new Person();
     $person->setPersonKindID(1);
     $person->setUsername("timmy");
     $person->setName("Timothy");
     $person->setPhone("000-101-1010");
     $person->save();
     $this->assertTrue(Person::personExists($person->getUsername()) != false);
     $person->delete();
     $this->assertTrue(!Person::personExists($person->getUsername()));
 }
コード例 #16
0
ファイル: ZonePerson.php プロジェクト: laiello/zoop
 function postEdit($p, $z)
 {
     $personId = $p[1];
     $person = new Person($personId);
     $person->firstname = $_POST['firstname'];
     $person->lastname = $_POST['lastname'];
     $person->save();
     if ($z['personId'] == 0) {
         $this->setParam('personId', $person->id);
     }
     $this->redirect('view');
 }
コード例 #17
0
 function create()
 {
     $person = new Person();
     $person->setAttributes($this->params);
     $res = $person->save();
     if ($res) {
         //$this->renderText('User '.$person->first_name.' '.$person->last_name.' created', 201);
         $this->redirectTo($this->urlFor(array('controller' => 'cache_sweeper', 'action' => 'show', 'id' => $person->id)));
     } else {
         $this->renderText('Error', 502);
     }
 }
コード例 #18
0
 public function newPerson($name)
 {
     // Creating sfGuardUser
     $guardUser = new sfGuardUser();
     $guardUser->set('name', $name);
     $guardUser->save();
     // Creating the Person
     $person = new Person();
     $person->set('name', $name);
     $person->set('sf_guard_user_id', $guardUser['id']);
     $person->save();
     return $person;
 }
コード例 #19
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Person();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Person'])) {
         $model->attributes = $_POST['Person'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
コード例 #20
0
ファイル: supplier.php プロジェクト: ekchanthorn/demo_loan
 function save(&$person_data, &$supplier_data, $supplier_id = false)
 {
     $success = false;
     if (parent::save($person_data, $supplier_id)) {
         if (!$supplier_id or !$this->exists($supplier_id)) {
             $supplier_data['person_id'] = $person_data['person_id'];
             $success = $this->db->insert('suppliers', $supplier_data);
         } else {
             $this->db->where('person_id', $supplier_id);
             $success = $this->db->update('suppliers', $supplier_data);
         }
     }
     return $success;
 }
コード例 #21
0
 /**
  * @param string $name
  * @param string $name_normalized
  * @return Person
  * @throws Exception
  */
 public static function getOrCreate($name, $name_normalized)
 {
     /** @var Person|null $pers */
     $pers = Person::model()->findByAttributes(["name_normalized" => $name_normalized]);
     if (is_null($pers)) {
         $pers = new Person();
         $pers->name = $name;
         $pers->name_normalized = $name_normalized;
         $pers->typ = static::$TYP_SONSTIGES;
         if (!$pers->save()) {
             RISTools::send_email(Yii::app()->params['adminEmail'], "Person:getOrCreate Error", print_r($pers->getErrors(), true), null, "system");
             throw new Exception("Fehler beim Speichern: Person");
         }
     }
     return $pers;
 }
コード例 #22
0
 public function actionIndex()
 {
     $this->pageTitle = Lang::t('Register');
     $user_model = new Users(Users::SCENARIO_SIGNUP);
     $user_model->activation_code = Common::generateHash(microtime());
     $user_model->user_level = UserLevels::LEVEL_MEMBER;
     $user_model->timezone = SettingsTimezone::DEFAULT_TIME_ZONE;
     $user_model_class_name = $user_model->getClassName();
     $person_model = new Person();
     $person_model_class_name = $person_model->getClassName();
     $person_address = new PersonAddress();
     $person_address_class_name = $person_address->getClassName();
     if (Yii::app()->request->isPostRequest) {
         $verifyPhoneCode = isset($_POST['verifyPhoneCode']) ? $_POST['verifyPhoneCode'] : null;
         $verifyMailCode = isset($_POST['verifyMailCode']) ? $_POST['verifyMailCode'] : null;
         if (isset($_POST[$user_model_class_name])) {
             $user_model->validatorList->add(CValidator::createValidator('CaptchaExtendedValidator', $user_model, 'verifyCode', array('allowEmpty' => !CCaptcha::checkRequirements())));
             $user_model->attributes = $_POST[$user_model_class_name];
             $user_model->status = 'Active';
             $user_model->answer = strtoupper($user_model->answer);
             $user_model->validate();
         }
         if (isset($_POST[$person_model_class_name])) {
             $person_model->attributes = $_POST[$person_model_class_name];
             $person_model->married = 'n';
             $person_model->havechildren = 'n';
             $person_model->validate();
         }
         if (isset($_POST['PersonAddress'])) {
             $person_address->attributes = $_POST[$person_address_class_name];
             $person_address->validate(array('phone1'));
         }
         if (!$user_model->hasErrors() && !$person_model->hasErrors() && !$person_address->hasErrors()) {
             if ($user_model->save(FALSE)) {
                 $person_model->id = $user_model->id;
                 $person_model->save(FALSE);
                 $person_address->person_id = $person_model->id;
                 $person_address->save(FALSE);
                 Yii::app()->user->setFlash('success', Lang::t('Account created successfullly. Please enter your login details.'));
                 $this->redirect($this->createUrl('/users/default/view', array('id' => $user_model->id)));
                 //$this->redirect('../default/login');
             }
         }
     }
     $this->render('index', array('user_model' => $user_model, 'person_model' => $person_model, 'person_address' => $person_address, 'verifyPhoneCode' => isset($verifyPhoneCode) ? $verifyPhoneCode : null, 'verifyMailCode' => isset($verifyMailCode) ? $verifyMailCode : null));
 }
コード例 #23
0
ファイル: employee.php プロジェクト: ekchanthorn/demo_loan
 function save(&$person_data, &$employee_data, &$permission_data, &$permission_action_data, &$location_data, $employee_id = false)
 {
     $success = false;
     //Run these queries as a transaction, we want to make sure we do all or nothing
     $this->db->trans_start();
     if (parent::save($person_data, $employee_id)) {
         if (!$employee_id or !$this->exists($employee_id)) {
             $employee_data['person_id'] = $employee_id = $person_data['person_id'];
             $success = $this->db->insert('employees', $employee_data);
         } else {
             $this->db->where('person_id', $employee_id);
             $success = $this->db->update('employees', $employee_data);
         }
         //We have either inserted or updated a new employee, now lets set permissions.
         if ($success) {
             //First lets clear out any permissions the employee currently has.
             $success = $this->db->delete('permissions', array('person_id' => $employee_id));
             //Now insert the new permissions
             if ($success) {
                 foreach ($permission_data as $allowed_module) {
                     $success = $this->db->insert('permissions', array('module_id' => $allowed_module, 'person_id' => $employee_id));
                 }
             }
             //First lets clear out any permissions actions the employee currently has.
             $success = $this->db->delete('permissions_actions', array('person_id' => $employee_id));
             //Now insert the new permissions actions
             if ($success) {
                 foreach ($permission_action_data as $permission_action) {
                     list($module, $action) = explode('|', $permission_action);
                     $success = $this->db->insert('permissions_actions', array('module_id' => $module, 'action_id' => $action, 'person_id' => $employee_id));
                 }
             }
             $success = $this->db->delete('employees_locations', array('employee_id' => $employee_id));
             //Now insert the new employee locations
             if ($success) {
                 if ($location_data !== FALSE) {
                     foreach ($location_data as $location_id) {
                         $success = $this->db->insert('employees_locations', array('employee_id' => $employee_id, 'location_id' => $location_id));
                     }
                 }
             }
         }
     }
     $this->db->trans_complete();
     return $success;
 }
コード例 #24
0
 function save(&$person_data, &$supplier_data, $supplier_id = false)
 {
     $success = false;
     //Run these queries as a transaction, we want to make sure we do all or nothing
     $this->db->trans_start();
     if (parent::save($person_data, $supplier_id)) {
         if (!$supplier_id or !$this->exists($supplier_id)) {
             $supplier_data['person_id'] = $person_data['person_id'];
             $success = $this->db->insert('suppliers', $supplier_data);
         } else {
             $this->db->where('person_id', $supplier_id);
             $success = $this->db->update('suppliers', $supplier_data);
         }
     }
     $this->db->trans_complete();
     return $success;
 }
コード例 #25
0
 function testCreate_OneToOne()
 {
     $this->_createModelAndIncludeThem('social_security', 'SocialSecurity');
     $this->_createModelAndIncludeThem('person', 'Person');
     $ss = new SocialSecurity();
     $ss->setCode($ss_code = 42);
     $ss->save();
     $person = new Person();
     $person->setName($person_name = 'Vasya');
     $person->setSocialSecurity($ss);
     $person->save();
     $loaded_ss = lmbActiveRecord::findById('SocialSecurity', $ss->getId());
     $this->assertEqual($loaded_ss->getCode(), $ss_code);
     $this->assertEqual($loaded_ss->getPerson()->getId(), $person->getId());
     $loaded_person = lmbActiveRecord::findById('Person', $person->getId());
     $this->assertEqual($loaded_person->getSocialSecurity()->getId(), $ss->getId());
 }
コード例 #26
0
ファイル: UserController.php プロジェクト: stpncpe/cbdbx
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $user = new User('passwordset');
     $person = new Person();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['User'], $_POST['Person'])) {
         $person->attributes = $_POST['Person'];
         if ($person->save()) {
             $user->attributes = $_POST['User'];
             $user->person_id = $person->id;
             if ($user->save()) {
                 $this->redirect(array('view', 'id' => $user->id));
             }
         }
     }
     $this->render('create', array('user' => $user, 'person' => $person));
 }
コード例 #27
0
 public function handleCreate()
 {
     DB::transaction(function () {
         $input = Input::all();
         $person = new Person();
         $localizationController = new LocalizationController();
         $person->names = $input['names'];
         $person->last_name = $input['last_name'];
         $person->doc_number = $input['doc_number'];
         $person->doc_type = $input['doc_type'];
         $person->email = $input['email'];
         $person->career = $input['career'];
         $person->state = 1;
         //para transformar a fecha
         $borndate = date("Y-m-d", strtotime($input['born_date']));
         $person->born_date = $borndate;
         $person->nationality = $input['nationality'];
         $person->academicdegree_id = $input['academicdegree_id'];
         $person->localization_id = $localizationController->getLocalizationId($input['localization_dept'], $input['localization_prov'], $input['localization_dist']);
         $person->save();
         $i = 0;
         foreach ($input['mobile_number'] as $mobil) {
             $phone = new Phone();
             $phone->person()->associate($person);
             $phone->mobile_number = $mobil;
             $phone->type = $input['phone_type'][$i];
             $phone->save();
             $i = $i + 1;
         }
         if (isset($input['notif1'])) {
             //asociar la persona a las notificaciones de tipo 1
             //$person->notifications()->save(Notification::find(1));
             $person->notifications()->attach(1);
             $person->notifications()->where('person_id', '=', $person->id)->update(array('state' => 1));
         }
         if (isset($input['notif2'])) {
             //asociar la persona a las notificaciones de tipo 1
             $person->notifications()->attach(2);
             $person->notifications()->where('person_id', '=', $person->id)->update(array('state' => 1));
         }
     });
     return Redirect::to('registro');
 }
コード例 #28
0
 public function actionIndex()
 {
     MemberNetwork::model()->updateNetwork(11, 10);
     $this->pageTitle = Lang::t('Register');
     //member model
     $member_model = new Member();
     $member_model_class_name = $member_model->getClassName();
     //user model
     $user_model = new Users(Users::SCENARIO_SIGNUP);
     $user_model->activation_code = Common::generateHash(microtime());
     $user_model->user_level = UserLevels::LEVEL_MEMBER;
     $user_model->timezone = SettingsTimezone::DEFAULT_TIME_ZONE;
     $user_model_class_name = $user_model->getClassName();
     //person model
     $person_model = new Person();
     $person_model_class_name = $person_model->getClassName();
     if (Yii::app()->request->isPostRequest) {
         if (isset($_POST[$member_model_class_name])) {
             $member_model->attributes = $_POST[$member_model_class_name];
             $member_model->validate();
         }
         if (isset($_POST[$user_model_class_name])) {
             $user_model->validatorList->add(CValidator::createValidator('CaptchaExtendedValidator', $user_model, 'verifyCode', array('allowEmpty' => !CCaptcha::checkRequirements())));
             $user_model->attributes = $_POST[$user_model_class_name];
             $user_model->validate();
         }
         if (isset($_POST[$person_model_class_name])) {
             $person_model->attributes = $_POST[$person_model_class_name];
             $person_model->validate();
         }
         if (!$member_model->hasErrors() && !$user_model->hasErrors() && !$person_model->hasErrors()) {
             if ($user_model->save(FALSE)) {
                 $person_model->id = $user_model->id;
                 $person_model->save(FALSE);
                 $member_model->id = $user_model->id;
                 $member_model->save(FALSE);
                 Yii::app()->user->setFlash('success', Lang::t('Check your email for account activation email.'));
                 $this->refresh();
             }
         }
     }
     $this->render('index', array('member_model' => $member_model, 'user_model' => $user_model, 'person_model' => $person_model));
 }
コード例 #29
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = array_except(Input::all(), array('_token'));
     $validator = Validator::make($input, Person::$validation_rules);
     if ($validator->passes() && $input['password'] === $input['password_confirmation']) {
         $person = new Person($input);
         //new Customer(array_except($input, array('password_confirmation')));
         $person->password = Hash::make(Input::get('password'));
         if ($person->save()) {
             return Redirect::route('persons.show', $person->id)->with('message', 'Person created.');
         } else {
             return Redirect::route('persons.create')->withInput()->withErrors($person->errors())->with(array('message' => 'Error with saving.'));
         }
         //return Redirect::route('customers.show', $customer->id);
     } else {
         //return Redirect::route('customers.create')->withInput()->withErrors( $customer->errors() );
         return Redirect::route('persons.create')->withInput()->withErrors($validator->errors())->with(array('message' => 'Error with validation.'));
     }
 }
コード例 #30
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->aMovie !== null) {
             if ($this->aMovie->isModified() || $this->aMovie->isNew()) {
                 $affectedRows += $this->aMovie->save($con);
             }
             $this->setMovie($this->aMovie);
         }
         if ($this->aPerson !== null) {
             if ($this->aPerson->isModified() || $this->aPerson->isNew()) {
                 $affectedRows += $this->aPerson->save($con);
             }
             $this->setPerson($this->aPerson);
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $criteria = $this->buildCriteria();
                 $pk = BasePeer::doInsert($criteria, $con);
                 $affectedRows += 1;
                 $this->setNew(false);
             } else {
                 $affectedRows += MoviespersonsPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }