public function viewAction() { if (defined('EMPTABCONFIGS')) { $empOrganizationTabs = explode(",", EMPTABCONFIGS); if (in_array('workeligibilitydetails', $empOrganizationTabs)) { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $employeeData = array(); $id = $this->getRequest()->getParam('userid'); $callval = $this->getRequest()->getParam('call'); if ($callval == 'ajaxcall') { $this->_helper->layout->disableLayout(); } $objName = 'workeligibilitydetails'; $issuingauthority = ''; $employeeModal = new Default_Model_Employee(); $workeligibilityform = new Default_Form_Workeligibilitydetails(); $workeligibilityform->removeElement("submit"); $elements = $workeligibilityform->getElements(); if (count($elements) > 0) { foreach ($elements as $key => $element) { if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") { $element->setAttrib("disabled", "disabled"); } } } try { if ($id && is_numeric($id) && $id > 0 && $id != $loginUserId) { $usersModel = new Default_Model_Users(); $empdata = $employeeModal->getActiveEmployeeData($id); $employeeData = $usersModel->getUserDetailsByIDandFlag($id); if ($empdata == 'norows') { $this->view->rowexist = "norows"; $this->view->empdata = ""; } else { $this->view->rowexist = "rows"; if (!empty($empdata)) { $workeligibilityModel = new Default_Model_Workeligibilitydetails(); if ($id) { $usersModel = new Default_Model_Users(); $workeligibilityDoctypesModal = new Default_Model_Workeligibilitydoctypes(); $countriesModel = new Default_Model_Countries(); $statesmodel = new Default_Model_States(); $citiesmodel = new Default_Model_Cities(); $countrieslistArr = $countriesModel->getTotalCountriesList(); if (sizeof($countrieslistArr) > 0) { $workeligibilityform->issuingauth_country->addMultiOption('', 'Select Country'); foreach ($countrieslistArr as $countrieslistres) { $workeligibilityform->issuingauth_country->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name'])); } } else { $msgarray['issuingauth_country'] = 'Countries are not configured yet.'; } $data = $workeligibilityModel->getWorkEligibilityRecord($id); if (!empty($data) && isset($data)) { $countryId = $data[0]['issuingauth_country']; $stateId = $data[0]['issuingauth_state']; $cityId = $data[0]['issuingauth_city']; $documenttype_id = $data[0]['documenttype_id']; if ($countryId != '') { $statelistArr = $statesmodel->getStatesList($countryId); if (sizeof($statelistArr) > 0) { $workeligibilityform->issuingauth_state->addMultiOption('', 'Select State'); foreach ($statelistArr as $statelistres) { $workeligibilityform->issuingauth_state->addMultiOption($statelistres['id'] . '!@#' . $statelistres['state_name'], $statelistres['state_name']); } } } if ($stateId != '') { $citylistArr = $citiesmodel->getCitiesList($stateId); if (sizeof($citylistArr) > 0) { $workeligibilityform->issuingauth_city->addMultiOption('', 'Select City'); foreach ($citylistArr as $cityPermlistres) { $workeligibilityform->issuingauth_city->addMultiOption($cityPermlistres['id'] . '!@#' . $cityPermlistres['city_name'], $cityPermlistres['city_name']); } } $stateNameArr = $statesmodel->getStateName($stateId); } if ($cityId != '') { $cityNameArr = $citiesmodel->getCityName($cityId); } if ($documenttype_id != '') { $issuingauthorityArr = $workeligibilityDoctypesModal->getIssuingAuthority($documenttype_id); } if (!empty($issuingauthorityArr)) { $issuingauthority = $issuingauthorityArr[0]['issuingauthority']; $workeligibilityform->issuingauthflag->setValue($issuingauthority); $workeligibilityform->documenttype_id->addMultiOption($issuingauthorityArr[0]['id'], $issuingauthorityArr[0]['documenttype']); } $workeligibilityform->setDefault("id", $data[0]["id"]); $workeligibilityform->setDefault("user_id", $data[0]["user_id"]); $workeligibilityform->setDefault('issuingauth_country', $data[0]['issuingauth_country']); if (!empty($stateNameArr)) { $workeligibilityform->setDefault('issuingauth_state', $stateNameArr[0]['id'] . '!@#' . $stateNameArr[0]['statename']); } if (!empty($cityNameArr)) { $workeligibilityform->setDefault('issuingauth_city', $cityNameArr[0]['id'] . '!@#' . $cityNameArr[0]['cityname']); } $workeligibilityform->setDefault("documenttype_id", $data[0]["documenttype_id"]); $workeligibilityform->setDefault("issuingauth_name", $data[0]["issuingauth_name"]); $workeligibilityform->setDefault("issuingauth_postalcode", $data[0]["issuingauth_postalcode"]); $issue_date = date(DATEFORMAT_PHP, strtotime($data[0]["doc_issue_date"])); $workeligibilityform->setDefault('doc_issue_date', $issue_date); $expiry_date = date(DATEFORMAT_PHP, strtotime($data[0]["doc_expiry_date"])); $workeligibilityform->setDefault('doc_expiry_date', $expiry_date); } $this->view->controllername = $objName; $this->view->id = $id; $this->view->data = $data; $this->view->employeedata = $employeeData[0]; $this->view->form = $workeligibilityform; $this->view->issuingauthority = $issuingauthority; } } $this->view->empdata = $empdata; } } else { $this->view->rowexist = "norows"; } } catch (Exception $e) { $this->view->rowexist = "norows"; } } else { $this->_redirect('error'); } } else { $this->_redirect('error'); } }
public function workeligibilityAction() { if (defined('EMPTABCONFIGS')) { $empOrganizationTabs = explode(",", EMPTABCONFIGS); if (in_array('workeligibilitydetails', $empOrganizationTabs)) { $tabName = "workeligibility"; $employeeData = array(); $msgarray = array(); $emptyFlag = 0; $issuingauthority = ''; $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $userid = $loginUserId; $employeeModal = new Default_Model_Employee(); $empdata = $employeeModal->getsingleEmployeeData($userid); if ($empdata == 'norows') { $this->view->rowexist = "norows"; $this->view->empdata = ""; } else { $this->view->rowexist = "rows"; if (!empty($empdata)) { $workeligibilityform = new Default_Form_Workeligibilitydetails(); $workeligibilityModel = new Default_Model_Workeligibilitydetails(); $workeligibilityDoctypesModal = new Default_Model_Workeligibilitydoctypes(); //fetchAll($where = null, $order = null, $count = null, $offset = null) function syntax... $workeligibilityDoctypesData = $workeligibilityDoctypesModal->fetchAll('isactive=1', 'documenttype'); $workeligibilityDoctypesDataArr = $workeligibilityDoctypesData->toArray(); if (!empty($workeligibilityDoctypesDataArr)) { foreach ($workeligibilityDoctypesDataArr as $data) { $workeligibilityform->documenttype_id->addMultiOption($data['id'], $data['documenttype']); } } else { $msgarray['documenttype_id'] = 'Work eligibility document types are not configured yet.'; $emptyFlag++; } if ($userid) { $countriesModel = new Default_Model_Countries(); $statesmodel = new Default_Model_States(); $citiesmodel = new Default_Model_Cities(); $countrieslistArr = $countriesModel->getTotalCountriesList(); if (sizeof($countrieslistArr) > 0) { $workeligibilityform->issuingauth_country->addMultiOption('', 'Select Country'); foreach ($countrieslistArr as $countrieslistres) { $workeligibilityform->issuingauth_country->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name'])); } } else { $msgarray['issuingauth_country'] = 'Countries are not configured yet.'; $emptyFlag++; } $data = $workeligibilityModel->getWorkEligibilityRecord($userid); if (!empty($data) && isset($data)) { $countryId = $data[0]['issuingauth_country']; $stateId = $data[0]['issuingauth_state']; $cityId = $data[0]['issuingauth_city']; $documenttype_id = $data[0]['documenttype_id']; //Populating states & cities Drop down......... from tbl_states & tbl_cities if ($countryId != '') { $statelistArr = $statesmodel->getStatesList($countryId); if (sizeof($statelistArr) > 0) { $workeligibilityform->issuingauth_state->addMultiOption('', 'Select State'); foreach ($statelistArr as $statelistres) { $workeligibilityform->issuingauth_state->addMultiOption($statelistres['id'] . '!@#' . $statelistres['state_name'], $statelistres['state_name']); } } } if ($stateId != '') { $citylistArr = $citiesmodel->getCitiesList($stateId); if (sizeof($citylistArr) > 0) { $workeligibilityform->issuingauth_city->addMultiOption('', 'Select City'); foreach ($citylistArr as $cityPermlistres) { $workeligibilityform->issuingauth_city->addMultiOption($cityPermlistres['id'] . '!@#' . $cityPermlistres['city_name'], $cityPermlistres['city_name']); } } $stateNameArr = $statesmodel->getStateName($stateId); } if ($cityId != '') { $cityNameArr = $citiesmodel->getCityName($cityId); } if ($documenttype_id != '') { $issuingauthorityArr = $workeligibilityDoctypesModal->getIssuingAuthority($documenttype_id); } if (!empty($issuingauthorityArr)) { $issuingauthority = $issuingauthorityArr[0]['issuingauthority']; $workeligibilityform->issuingauthflag->setValue($issuingauthority); } $workeligibilityform->setDefault("id", $data[0]["id"]); $workeligibilityform->setDefault("user_id", $data[0]["user_id"]); $workeligibilityform->setDefault('issuingauth_country', $data[0]['issuingauth_country']); if (!empty($stateNameArr)) { $workeligibilityform->setDefault('issuingauth_state', $stateNameArr[0]['id'] . '!@#' . $stateNameArr[0]['statename']); } if (!empty($cityNameArr)) { $workeligibilityform->setDefault('issuingauth_city', $cityNameArr[0]['id'] . '!@#' . $cityNameArr[0]['cityname']); } $workeligibilityform->setDefault("documenttype_id", $data[0]["documenttype_id"]); $workeligibilityform->setDefault("issuingauth_name", $data[0]["issuingauth_name"]); $workeligibilityform->setDefault("issuingauth_postalcode", $data[0]["issuingauth_postalcode"]); $issue_date = sapp_Global::change_date($data[0]["doc_issue_date"], 'view'); $workeligibilityform->setDefault('doc_issue_date', $issue_date); $expiry_date = sapp_Global::change_date($data[0]["doc_expiry_date"], 'view'); $workeligibilityform->setDefault('doc_expiry_date', $expiry_date); } $workeligibilityform->setAttrib('action', DOMAIN . 'mydetails/workeligibility'); $this->view->id = $userid; $this->view->data = $data; $this->view->form = $workeligibilityform; $this->view->issuingauthority = $issuingauthority; $this->view->msgarray = $msgarray; } if ($this->getRequest()->getPost()) { $documenttype_id = $this->_request->getParam('documenttype_id'); if ($documenttype_id != '') { $issuingauthorityArr = $workeligibilityDoctypesModal->getIssuingAuthority($documenttype_id); } if (!empty($issuingauthorityArr)) { $issuingauthority = $issuingauthorityArr[0]['issuingauthority']; if ($issuingauthority == 2) { $workeligibilityform->issuingauth_state->setRequired(true)->addErrorMessage('Please select a state.'); $workeligibilityform->issuingauth_state->addValidator('NotEmpty', false, array('messages' => 'Please select a state.')); } else { if ($issuingauthority == 3) { $workeligibilityform->issuingauth_state->setRequired(true)->addErrorMessage('Please select a state.'); $workeligibilityform->issuingauth_state->addValidator('NotEmpty', false, array('messages' => 'Please select a state.')); $workeligibilityform->issuingauth_city->setRequired(true)->addErrorMessage('Please select a city.'); $workeligibilityform->issuingauth_city->addValidator('NotEmpty', false, array('messages' => 'Please select a city.')); } } } $result = $this->save($workeligibilityform, $tabName); $result['issuingauthorityflag'] = $_POST['issuingauthflag']; $this->view->msgarray = $result; } } $this->view->empdata = $empdata; $this->view->emptyFlag = $emptyFlag; $this->view->messages = $this->_helper->flashMessenger->getMessages(); } } else { $this->_redirect('error'); } } else { $this->_redirect('error'); } }