public function viewAction() { $id = $this->getRequest()->getParam('id'); $callval = $this->getRequest()->getParam('call'); if ($callval == 'ajaxcall') { $this->_helper->layout->disableLayout(); } $objName = 'employee'; $employeeform = new Default_Form_employee(); $employeeform->removeElement("submit"); $elements = $employeeform->getElements(); if (count($elements) > 0) { foreach ($elements as $key => $element) { if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") { $element->setAttrib("disabled", "disabled"); } } } if ($id) { $employeeModal = new Default_Model_Employee(); $usersModel = new Default_Model_Users(); $employmentstatusModel = new Default_Model_Employmentstatus(); $busineesUnitModel = new Default_Model_Businessunits(); $deptModel = new Default_Model_Departments(); $role_model = new Default_Model_Roles(); $user_model = new Default_Model_Usermanagement(); $candidate_model = new Default_Model_Candidatedetails(); $jobtitlesModel = new Default_Model_Jobtitles(); $positionsmodel = new Default_Model_Positions(); $prefixModel = new Default_Model_Prefix(); $data = $employeeModal->getsingleEmployeeData($id); if ($data == 'norows') { $this->view->rowexist = "norows"; } else { if (!empty($data)) { $this->view->rowexist = "rows"; $data = $data[0]; $employeeData = $employeeModal->getsingleEmployeeData($data['user_id']); $roles_arr = $role_model->getRolesDataByID($data['emprole']); if (sizeof($roles_arr) > 0) { $employeeform->emprole->addMultiOption($roles_arr[0]['id'] . '_' . $roles_arr[0]['group_id'], utf8_encode($roles_arr[0]['rolename'])); } $referedby_options = $user_model->getRefferedByForUsers(); $reportingManagerData = $usersModel->getReportingManagerList($data['department_id'], $data['id'], $roles_arr[0]['group_id']); if (!empty($reportingManagerData)) { $employeeform->reporting_manager->addMultiOption('', 'Select a Reporting Manager'); if ($roles_arr[0]['group_id'] == MANAGEMENT_GROUP) { $employeeform->reporting_manager->addMultiOption(SUPERADMIN, 'Super Admin'); } foreach ($reportingManagerData as $reportingManagerres) { $employeeform->reporting_manager->addMultiOption($reportingManagerres['id'], $reportingManagerres['name']); } } $employeeform->setDefault('reporting_manager', $data['reporting_manager']); $employmentStatusData = $employmentstatusModel->getempstatuslist(); if (sizeof($employmentStatusData) > 0) { $employeeform->emp_status_id->addMultiOption('', 'Select a Employment Status'); foreach ($employmentStatusData as $employmentStatusres) { $employeeform->emp_status_id->addMultiOption($employmentStatusres['workcodename'], $employmentStatusres['statusname']); } } $businessunitData = $busineesUnitModel->getDeparmentList(); if (sizeof($businessunitData) > 0) { $employeeform->businessunit_id->addMultiOption('0', 'No Business Unit'); foreach ($businessunitData as $businessunitres) { $employeeform->businessunit_id->addMultiOption($businessunitres['id'], $businessunitres['unitname']); } } $departmentsData = $deptModel->getDepartmentList($data['businessunit_id']); if (sizeof($departmentsData) > 0) { $employeeform->department_id->addMultiOption('', 'Select a Department'); foreach ($departmentsData as $departmentsres) { $employeeform->department_id->addMultiOption($departmentsres['id'], $departmentsres['deptname']); } } $jobtitleData = $jobtitlesModel->getJobTitleList(); if (sizeof($jobtitleData) > 0) { $employeeform->jobtitle_id->addMultiOption('', 'Select a Job Title'); foreach ($jobtitleData as $jobtitleres) { $employeeform->jobtitle_id->addMultiOption($jobtitleres['id'], $jobtitleres['jobtitlename']); } } $positionlistArr = $positionsmodel->getPositionList($data['jobtitle_id']); if (sizeof($positionlistArr) > 0) { $employeeform->position_id->addMultiOption('', 'Select a Position'); foreach ($positionlistArr as $positionlistres) { $employeeform->position_id->addMultiOption($positionlistres['id'], $positionlistres['positionname']); } } if (isset($data['prefix_id']) && $data['prefix_id'] != '') { $singlePrefixArr = $prefixModel->getsinglePrefixData($data['prefix_id']); if ($singlePrefixArr != 'norows') { $employeeform->prefix_id->addMultiOption($singlePrefixArr[0]['id'], $singlePrefixArr[0]['prefix']); } } $employeeform->populate($data); $employeeform->setDefault('user_id', $data['user_id']); $employeeform->setDefault('emp_status_id', $data['emp_status_id']); $employeeform->setDefault('businessunit_id', $data['businessunit_id']); $employeeform->setDefault('jobtitle_id', $data['jobtitle_id']); $employeeform->setDefault('department_id', $data['department_id']); $employeeform->setDefault('position_id', $data['position_id']); $date_of_joining = sapp_Global::change_date($data['date_of_joining'], 'view'); $employeeform->date_of_joining->setValue($date_of_joining); if ($data['date_of_leaving'] != '' && $data['date_of_leaving'] != '0000-00-00') { $date_of_leaving = sapp_Global::change_date($data['date_of_leaving'], 'view'); $employeeform->date_of_leaving->setValue($date_of_leaving); } if ($data['modeofentry'] != 'Direct') { $employeeform->rccandidatename->setValue($data['userfullname']); } if (sizeof($referedby_options) > 0 && $data['candidatereferredby'] != '' && $data['candidatereferredby'] != 0) { $employeeform->candidatereferredby->setValue($referedby_options[$data['candidatereferredby']]); } if ($data['rccandidatename'] != '' && $data['rccandidatename'] != 0) { $cand_data = $candidate_model->getCandidateById($data['rccandidatename']); $data['requisition_code'] = $cand_data['requisition_code']; } $employeeform->setAttrib('action', DOMAIN . 'employee/edit/id/' . $id); $this->view->id = $id; $this->view->form = $employeeform; $this->view->employeedata = !empty($employeeData) ? $employeeData[0] : ""; $this->view->messages = $this->_helper->flashMessenger->getMessages(); $this->view->data = $data; $this->view->controllername = $objName; $this->view->id = $id; } } } }
public function indexAction() { $editPrivilege = ""; $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $id = $loginUserId; $data = array(); $tabName = "employee"; $callval = $this->getRequest()->getParam('call'); if ($callval == 'ajaxcall') { $this->_helper->layout->disableLayout(); } $employeeform = new Default_Form_employee(); try { if ($id != '' && $id > 0) { $employeeModal = new Default_Model_Employee(); $usersModel = new Default_Model_Users(); $employmentstatusModel = new Default_Model_Employmentstatus(); $busineesUnitModel = new Default_Model_Businessunits(); $deptModel = new Default_Model_Departments(); $role_model = new Default_Model_Roles(); $user_model = new Default_Model_Usermanagement(); $candidate_model = new Default_Model_Candidatedetails(); $jobtitlesModel = new Default_Model_Jobtitles(); $positionsmodel = new Default_Model_Positions(); $prefix_model = new Default_Model_Prefix(); $data = $employeeModal->getsingleEmployeeData($id); if ($data == 'norows') { $this->view->rowexist = "norows"; $this->view->empdata = ""; } else { if (!empty($data)) { $this->view->rowexist = "rows"; $this->view->empdata = $data; $elements = $employeeform->getElements(); if (count($elements) > 0) { foreach ($elements as $key => $element) { if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") { $element->setAttrib("disabled", "disabled"); } } } $employeeform->removeElement("submit"); $data = $data[0]; if ($loginUserId == SUPERADMIN) { //If login user is superAdmin..... role is 'Super Admin'. $employeeform->emprole->addMultiOption('superAdmin', 'Super Admin'); } else { $roles_arr = $role_model->getRolesDataByID($data['emprole']); if (sizeof($roles_arr) > 0) { $employeeform->emprole->addMultiOption($roles_arr[0]['id'] . '_' . $roles_arr[0]['group_id'], utf8_encode($roles_arr[0]['rolename'])); } } $prefix_data = $prefix_model->getsinglePrefixData($data['prefix_id']); if ($prefix_data != 'norows') { $prefix_data = $prefix_data[0]; $employeeform->prefix_id->addMultiOption($prefix_data['id'], $prefix_data['prefix']); } $referedby_options = $user_model->getRefferedByForUsers(); /* Code for reporting manager dropdown */ $reportingManagerData = $usersModel->getUserDetailsByID($data['reporting_manager']); if (!empty($reportingManagerData)) { $employeeform->reporting_manager->addMultiOption($reportingManagerData[0]['id'], $reportingManagerData[0]['userfullname']); } $employmentStatusData = $employmentstatusModel->getempstatuslist(); if (sizeof($employmentStatusData) > 0) { $employeeform->emp_status_id->addMultiOption('', 'Select a Employment Status'); foreach ($employmentStatusData as $employmentStatusres) { $employeeform->emp_status_id->addMultiOption($employmentStatusres['workcodename'], $employmentStatusres['statusname']); } } $businessunitData = $busineesUnitModel->getDeparmentList(); if (sizeof($businessunitData) > 0) { $employeeform->businessunit_id->addMultiOption('0', 'No Business Unit'); foreach ($businessunitData as $businessunitres) { $employeeform->businessunit_id->addMultiOption($businessunitres['id'], $businessunitres['unitname']); } } $departmentsData = $deptModel->getDepartmentList($data['businessunit_id']); if (sizeof($departmentsData) > 0) { $employeeform->department_id->addMultiOption('', 'Select a Department'); foreach ($departmentsData as $departmentsres) { $employeeform->department_id->addMultiOption($departmentsres['id'], $departmentsres['deptname']); } } $jobtitleData = $jobtitlesModel->getJobTitleList(); if (sizeof($jobtitleData) > 0) { $employeeform->jobtitle_id->addMultiOption('', 'Select a Job Title'); foreach ($jobtitleData as $jobtitleres) { $employeeform->jobtitle_id->addMultiOption($jobtitleres['id'], $jobtitleres['jobtitlename']); } } $positionlistArr = $positionsmodel->getPositionList($data['jobtitle_id']); if (sizeof($positionlistArr) > 0) { $employeeform->position_id->addMultiOption('', 'Select a Position'); foreach ($positionlistArr as $positionlistres) { $employeeform->position_id->addMultiOption($positionlistres['id'], $positionlistres['positionname']); } } $employeeform->populate($data); $employeeform->setDefault('user_id', $data['user_id']); $employeeform->setDefault('emp_status_id', $data['emp_status_id']); $employeeform->setDefault('businessunit_id', $data['businessunit_id']); $employeeform->setDefault('jobtitle_id', $data['jobtitle_id']); $employeeform->setDefault('department_id', $data['department_id']); $employeeform->setDefault('position_id', $data['position_id']); if ($data['date_of_joining'] != '' && $data['date_of_joining'] != '0000-00-00') { $date_of_joining = sapp_Global::change_date($data['date_of_joining'], 'view'); $employeeform->date_of_joining->setValue($date_of_joining); } if ($data['date_of_leaving'] != '' && $data['date_of_leaving'] != '0000-00-00') { $date_of_leaving = sapp_Global::change_date($data['date_of_leaving'], 'view'); $employeeform->date_of_leaving->setValue($date_of_leaving); } if ($data['modeofentry'] != 'Direct') { $employeeform->rccandidatename->setValue($data['userfullname']); } if (sizeof($referedby_options) > 0 && $data['candidatereferredby'] != '' && $data['candidatereferredby'] != 0) { $employeeform->candidatereferredby->setValue($referedby_options[$data['candidatereferredby']]); } $employeeform->setAttrib('action', DOMAIN . 'mydetails/edit/'); $this->view->id = $id; $this->view->form = $employeeform; $this->view->employeedata = !empty($data) ? $data : ""; $this->view->messages = $this->_helper->flashMessenger->getMessages(); $this->view->empdata = $data; $this->view->editPrivilege = $this->mydetailsobjPrivileges; } } } else { $this->view->rowexist = "norows"; } } catch (Exception $e) { $this->view->rowexist = "norows"; } if ($this->getRequest()->getPost()) { $result = $this->save($employeeform, $tabName); $this->view->msgarray = $result; } }