public function pereditAction()
 {
     $identityDocumentArr = array();
     $documentsArr = array();
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('emppersonaldetails', $empOrganizationTabs)) {
             $loginUserId = '';
             $loginUserGroup = '';
             $loginUserRole = '';
             $auth = Zend_Auth::getInstance();
             $emptyFlag = 0;
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
                 $loginUserGroup = $auth->getStorage()->read()->group_id;
                 $loginUserRole = $auth->getStorage()->read()->emprole;
             }
             $id = $this->getRequest()->getParam('userid');
             if ($id == '') {
                 $id = $loginUserId;
             }
             $callval = $this->getRequest()->getParam('call');
             if ($callval == 'ajaxcall') {
                 $this->_helper->layout->disableLayout();
             }
             try {
                 if ($id && is_numeric($id) && $id > 0 && $id != $loginUserId) {
                     $employeeModal = new Default_Model_Employee();
                     $empdata = $employeeModal->getsingleEmployeeData($id);
                     if ($empdata == 'norows') {
                         $this->view->rowexist = "norows";
                         $this->view->empdata = "";
                     } else {
                         $this->view->rowexist = "rows";
                         if (!empty($empdata)) {
                             $empperdetailsModal = new Default_Model_Emppersonaldetails();
                             $usersModel = new Default_Model_Users();
                             $emppersonaldetailsform = new Default_Form_emppersonaldetails();
                             if ($loginUserGroup == MANAGER_GROUP || $loginUserRole == SUPERADMINROLE) {
                                 $identitydocumentsModel = new Default_Model_Identitydocuments();
                                 $identityDocumentArr = $identitydocumentsModel->getIdentitydocumnetsrecord();
                             }
                             $genderModel = new Default_Model_Gender();
                             $maritalstatusmodel = new Default_Model_Maritalstatus();
                             $nationalitymodel = new Default_Model_Nationality();
                             $ethniccodemodel = new Default_Model_Ethniccode();
                             $racecodemodel = new Default_Model_Racecode();
                             $languagemodel = new Default_Model_Language();
                             $msgarray = array();
                             $genderlistArr = $genderModel->getGenderList();
                             if (!empty($genderlistArr)) {
                                 foreach ($genderlistArr as $genderlistres) {
                                     $emppersonaldetailsform->genderid->addMultiOption($genderlistres['id'], $genderlistres['gendername']);
                                 }
                             } else {
                                 $msgarray['genderid'] = 'Gender is not configured yet.';
                                 $emptyFlag++;
                             }
                             $maritalstatuslistArr = $maritalstatusmodel->getMaritalStatusList();
                             if (!empty($maritalstatuslistArr)) {
                                 foreach ($maritalstatuslistArr as $maritalstatuslistres) {
                                     $emppersonaldetailsform->maritalstatusid->addMultiOption($maritalstatuslistres['id'], $maritalstatuslistres['maritalstatusname']);
                                 }
                             } else {
                                 $msgarray['maritalstatusid'] = 'Marital status is not configured yet.';
                                 $emptyFlag++;
                             }
                             $nationalitylistArr = $nationalitymodel->getNationalityList();
                             if (!empty($nationalitylistArr)) {
                                 foreach ($nationalitylistArr as $nationalitylistres) {
                                     $emppersonaldetailsform->nationalityid->addMultiOption($nationalitylistres['id'], $nationalitylistres['nationalitycode']);
                                 }
                             } else {
                                 $msgarray['nationalityid'] = 'Nationality is not configured yet.';
                                 $emptyFlag++;
                             }
                             $ethniccodeArr = $ethniccodemodel->gettotalEthnicCodeData();
                             if (!empty($ethniccodeArr)) {
                                 foreach ($ethniccodeArr as $ethniccoderes) {
                                     $emppersonaldetailsform->ethniccodeid->addMultiOption($ethniccoderes['id'], $ethniccoderes['ethnicname']);
                                 }
                             } else {
                                 $msgarray['ethniccodeid'] = 'Ethnic codes are not configured yet.';
                                 $emptyFlag++;
                             }
                             $racecodeArr = $racecodemodel->gettotalRaceCodeData();
                             if (!empty($racecodeArr)) {
                                 foreach ($racecodeArr as $racecoderes) {
                                     $emppersonaldetailsform->racecodeid->addMultiOption($racecoderes['id'], $racecoderes['racename']);
                                 }
                             } else {
                                 $msgarray['racecodeid'] = 'Race codes are not configured yet.';
                                 $emptyFlag++;
                             }
                             $languageArr = $languagemodel->gettotalLanguageData();
                             if (!empty($languageArr)) {
                                 foreach ($languageArr as $languageres) {
                                     $emppersonaldetailsform->languageid->addMultiOption($languageres['id'], $languageres['languagename']);
                                 }
                             } else {
                                 $msgarray['languageid'] = 'Languages are not configured yet.';
                                 $emptyFlag++;
                             }
                             if (!empty($identityDocumentArr)) {
                                 $this->view->identitydocument = $identityDocumentArr;
                             }
                             $data = $empperdetailsModal->getsingleEmpPerDetailsData($id);
                             if (!empty($data)) {
                                 $emppersonaldetailsform->populate($data[0]);
                                 $dob = sapp_Global::change_date($data[0]["dob"], 'view');
                                 $emppersonaldetailsform->dob->setValue($dob);
                                 /*
                                 if($data[0]['celebrated_dob'] !='')
                                 {
                                 
                                 	$celebrated_dob = sapp_Global::change_date($data[0]["celebrated_dob"], 'view');
                                 	$emppersonaldetailsform->celebrated_dob->setValue($celebrated_dob);
                                 }
                                 */
                                 if ($data[0]['identity_documents'] != '') {
                                     $documentsArr = get_object_vars(json_decode($data[0]['identity_documents']));
                                 }
                                 $emppersonaldetailsform->setDefault('genderid', $data[0]['genderid']);
                                 $emppersonaldetailsform->setDefault('maritalstatusid', $data[0]['maritalstatusid']);
                                 $emppersonaldetailsform->setDefault('nationalityid', $data[0]['nationalityid']);
                                 $emppersonaldetailsform->setDefault('ethniccodeid', $data[0]['ethniccodeid']);
                                 $emppersonaldetailsform->setDefault('racecodeid', $data[0]['racecodeid']);
                                 $emppersonaldetailsform->setDefault('languageid', $data[0]['languageid']);
                             }
                             $emppersonaldetailsform->user_id->setValue($id);
                             $emppersonaldetailsform->setAttrib('action', DOMAIN . 'myemployees/peredit/userid/' . $id);
                             $this->view->form = $emppersonaldetailsform;
                             $this->view->data = $data;
                             $this->view->documentsArr = $documentsArr;
                             $this->view->id = $id;
                             $this->view->msgarray = $msgarray;
                             $this->view->employeedata = $empdata[0];
                             $this->view->emptyFlag = $emptyFlag;
                             $this->view->messages = $this->_helper->flashMessenger->getMessages();
                         }
                         $this->view->empdata = $empdata;
                     }
                 } else {
                     $this->view->rowexist = "norows";
                 }
             } catch (Exception $e) {
                 $this->view->rowexist = "norows";
             }
             if ($this->getRequest()->getPost()) {
                 $result = $this->persave($emppersonaldetailsform, $id, $identityDocumentArr);
                 $this->view->msgarray = $result;
             }
         } else {
             $this->_redirect('error');
         }
     } else {
         $this->_redirect('error');
     }
 }
Пример #2
0
 public function addpopupAction()
 {
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $id = $this->getRequest()->getParam('id');
     $controllername = 'ethniccode';
     $ethniccodeform = new Default_Form_ethniccode();
     $ethniccodemodel = new Default_Model_Ethniccode();
     $ethniccodeform->setAction(DOMAIN . 'ethniccode/addpopup');
     if ($this->getRequest()->getPost()) {
         if ($ethniccodeform->isValid($this->_request->getPost())) {
             $id = $this->_request->getParam('id');
             $ethniccode = $this->_request->getParam('ethniccode');
             $ethnicname = $this->_request->getParam('ethnicname');
             $description = $this->_request->getParam('description');
             $date = new Zend_Date();
             $menumodel = new Default_Model_Menu();
             $actionflag = '';
             $tableid = '';
             $data = array('ethniccode' => trim($ethniccode), 'ethnicname' => trim($ethnicname), 'description' => trim($description), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             if ($id != '') {
                 $where = array('id=?' => $id);
                 $actionflag = 2;
             } else {
                 $data['createdby'] = $loginUserId;
                 $data['createddate'] = gmdate("Y-m-d H:i:s");
                 $data['isactive'] = 1;
                 $where = '';
                 $actionflag = 1;
             }
             $Id = $ethniccodemodel->SaveorUpdateEthnicCodeData($data, $where);
             $tableid = $Id;
             $menuidArr = $menumodel->getMenuObjID('/ethniccode');
             $menuID = $menuidArr[0]['id'];
             $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
             $ethniccodesData = $ethniccodemodel->fetchAll('isactive = 1', 'ethnicname')->toArray();
             $opt = '';
             foreach ($ethniccodesData as $record) {
                 $opt .= sapp_Global::selectOptionBuilder($record['id'], $record['ethnicname']);
             }
             $this->view->ethniccodesData = $opt;
             $this->view->eventact = 'added';
             $close = 'close';
             $this->view->popup = $close;
         } else {
             $messages = $ethniccodeform->getMessages();
             foreach ($messages as $key => $val) {
                 foreach ($val as $key2 => $val2) {
                     $msgarray[$key] = $val2;
                     break;
                 }
             }
             $this->view->msgarray = $msgarray;
         }
     }
     $this->view->controllername = $controllername;
     $this->view->form = $ethniccodeform;
 }