Example #1
0
 public function saveupdateAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $id = $this->_request->getParam('id');
     $gendercode = $this->_request->getParam('gendercode');
     $gendername = $this->_request->getParam('gendername');
     $description = $this->_request->getParam('description');
     $genderform = new Default_Form_gender();
     $gendermodel = new Default_Model_Gender();
     $messages = $genderform->getMessages();
     $actionflag = '';
     $tableid = '';
     if ($this->getRequest()->getPost()) {
         if ($genderform->isValid($this->_request->getPost())) {
             $data = array('gendercode' => trim($gendercode), 'gendername' => trim($gendername), 'description' => trim($description), 'modifiedby' => $loginUserId, 'modifieddate' => Zend_Registry::get('currentdate'));
             if ($id != '') {
                 $where = array('id=?' => $id);
                 $messages['message'] = 'Gender updated successfully.';
                 $actionflag = 2;
             } else {
                 $data['createdby'] = $loginUserId;
                 $data['createddate'] = Zend_Registry::get('currentdate');
                 $data['isactive'] = 1;
                 $where = '';
                 $messages['message'] = 'Gender added successfully.';
                 $actionflag = 1;
             }
             $Id = $gendermodel->SaveorUpdateGenderData($data, $where);
             if ($Id == 'update') {
                 $tableid = $id;
             } else {
                 $tableid = $Id;
             }
             $menuID = GENDER;
             $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
             $messages['result'] = 'saved';
             $this->_helper->json($messages);
         } else {
             $messages = $genderform->getMessages();
             $messages['result'] = 'error';
             $this->_helper->json($messages);
         }
     }
 }
 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');
     }
 }
Example #3
0
 public function addpopupAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $id = $this->getRequest()->getParam('id');
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $genderform = new Default_Form_gender();
     $gendermodel = new Default_Model_Gender();
     $genderform->setAction(DOMAIN . 'gender/addpopup');
     $controllername = 'gender';
     if ($this->getRequest()->getPost()) {
         if ($genderform->isValid($this->_request->getPost())) {
             $id = $this->_request->getParam('id');
             $gendercode = $this->_request->getParam('gendercode');
             $gendername = $this->_request->getParam('gendername');
             $description = $this->_request->getParam('description');
             $date = new Zend_Date();
             $menumodel = new Default_Model_Menu();
             $actionflag = '';
             $tableid = '';
             $data = array('gendercode' => trim($gendercode), 'gendername' => trim($gendername), '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 = $gendermodel->SaveorUpdateGenderData($data, $where);
             $tableid = $Id;
             $menuidArr = $menumodel->getMenuObjID('/gender');
             $menuID = $menuidArr[0]['id'];
             $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
             $genderData = $gendermodel->fetchAll('isactive = 1', 'gendername')->toArray();
             $opt = '';
             foreach ($genderData as $record) {
                 $opt .= sapp_Global::selectOptionBuilder($record['id'], $record['gendername']);
             }
             $this->view->genderData = $opt;
             $this->view->eventact = 'added';
             $close = 'close';
             $this->view->popup = $close;
         } else {
             $messages = $genderform->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 = $genderform;
 }