/**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Addressbook::model()->findByPk((int) $id);
     //if($model===null)
     //	throw new CHttpException(404,'The requested page does not exist.');
     return $model;
 }
Exemplo n.º 2
0
 /**
  * Get the addressbook for the user profiles. If it doesn't exist it will be
  * created.
  * 
  * @return Addressbook 
  */
 public function getUsersAddressbook()
 {
     $ab = Addressbook::model()->findSingleByAttribute('users', '1');
     //\GO::t('users','base'));
     if (!$ab) {
         $ab = new Addressbook();
         $ab->name = \GO::t('users');
         $ab->users = true;
         $ab->save();
         $ab->acl->addGroup(\GO::config()->group_internal);
     }
     return $ab;
 }
 public function actionWrite()
 {
     if (isset($_POST['Employee'])) {
         $messages = $this->ValidateData(array(array($_POST['Employee']['fullname'], 'emptyfullname', 'emptystring'), array($_POST['Employee']['orgstructureid'], 'emptyorgstructure', 'emptystring'), array($_POST['Employee']['positionid'], 'emptyposition', 'emptystring'), array($_POST['Employee']['employeetypeid'], 'emptyemployeetype', 'emptystring'), array($_POST['Employee']['sexid'], 'emptysex', 'emptystring'), array($_POST['Employee']['birthcityid'], 'emptybirthcity', 'emptystring'), array($_POST['Employee']['birthdate'], 'emptybirthdate', 'emptystring'), array($_POST['Employee']['maritalstatusid'], 'emptymaritalstatus', 'emptystring'), array($_POST['Employee']['joindate'], 'emptyjoindate', 'emptystring'), array($_POST['Employee']['employeestatusid'], 'emptyemployeestatus', 'emptystring'), array($_POST['Employee']['levelorgid'], 'emptylevelorg', 'emptystring')));
         if ($messages == '') {
             if ((int) $_POST['Employee']['employeeid'] > 0) {
                 $model = $this->loadModel($_POST['Employee']['employeeid']);
                 $ab = Addressbook::model()->findbypk($model->addressbookid);
                 $ab->fullname = $_POST['Employee']['fullname'];
                 $ab->save();
                 $model->fullname = $_POST['Employee']['fullname'];
                 $model->oldnik = $_POST['Employee']['oldnik'];
                 $model->orgstructureid = $_POST['Employee']['orgstructureid'];
                 $model->positionid = $_POST['Employee']['positionid'];
                 $model->levelorgid = $_POST['Employee']['levelorgid'];
                 $model->employeetypeid = $_POST['Employee']['employeetypeid'];
                 $model->sexid = $_POST['Employee']['sexid'];
                 $model->birthcityid = $_POST['Employee']['birthcityid'];
                 $model->birthdate = $_POST['Employee']['birthdate'];
                 $model->religionid = $_POST['Employee']['religionid'];
                 $model->maritalstatusid = $_POST['Employee']['maritalstatusid'];
                 $model->referenceby = $_POST['Employee']['referenceby'];
                 $model->joindate = $_POST['Employee']['joindate'];
                 $model->employeestatusid = $_POST['Employee']['employeestatusid'];
                 $model->istrial = $_POST['Employee']['istrial'];
                 $model->accountno = $_POST['Employee']['accountno'];
                 $model->taxno = $_POST['Employee']['taxno'];
             } else {
                 $model = new Employee();
                 $model->attributes = $_POST['Employee'];
             }
             try {
                 if ($model->save()) {
                     $this->DeleteLock($this->menuname, $_POST['Employee']['fullname']);
                     $this->GetSMessage('insertsuccess');
                 } else {
                     $this->GetMessage($model->getErrors());
                 }
             } catch (Exception $e) {
                 $this->GetMessage($e->getMessage());
             }
         }
     }
 }