/**
  * 
  * Show analytics of employees reporting to manager 
  */
 public function employeereportAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     if ($loginuserGroup == MANAGER_GROUP || $loginuserGroup == MANAGEMENT_GROUP || $loginuserRole == SUPERADMINROLE) {
         $norec_arr = array();
         $form = new Default_Form_Employeereport();
         $requi_model = new Default_Model_Requisition();
         $employmentstatusModel = new Default_Model_Employmentstatus();
         $role_model = new Default_Model_Roles();
         $departmentsmodel = new Default_Model_Departments();
         $bu_model = new Default_Model_Businessunits();
         $roles_arr = $role_model->getRolesList_EMP();
         $job_data = $requi_model->getJobTitleList();
         $employmentStatusData = $employmentstatusModel->getempstatuslist();
         if (count($job_data) == 0) {
             $norec_arr['jobtitle_id'] = "Job titles are not configured yet.";
             $norec_arr['position_id'] = "Positions are not configured yet.";
         }
         if (count($employmentStatusData) == 0) {
             $norec_arr['emp_status_id'] = "Employment status is not configured yet.";
         }
         $form->jobtitle_id->addMultiOptions(array('' => 'Select Job Title') + $job_data);
         if (count($employmentStatusData) > 0) {
             $form->emp_status_id->addMultiOption('', 'Select Employment Status');
             foreach ($employmentStatusData as $employmentStatusres) {
                 $form->emp_status_id->addMultiOption($employmentStatusres['workcodename'], $employmentStatusres['statusname']);
             }
         }
         if (sizeof($roles_arr) > 0) {
             $form->emprole->addMultiOptions(array('' => 'Select Role') + $roles_arr);
         } else {
             $norec_arr['emprole'] = 'Roles are not added yet.';
         }
         $bu_arr = $bu_model->getBU_report();
         if (!empty($bu_arr)) {
             foreach ($bu_arr as $bu) {
                 $form->businessunit_id->addMultiOption($bu['id'], utf8_encode($bu['bu_name']));
             }
         } else {
             $norec_arr['businessunit_id'] = 'Business Units are not added yet.';
         }
         // Show count of employees reporting to manager
         // Get employees data reporting to manager
         $myEmployees_model = new Default_Model_Myemployees();
         $employee_model = new Default_Model_Employee();
         //$this->_helper->layout->setLayout("analyticslayout");
         $this->view->count_emp_reporting = $employee_model->getCountEmpReporting($myEmployees_model->getLoginUserId());
         $this->view->form = $form;
         $this->view->messages = $norec_arr;
         $this->view->ermsg = '';
     } else {
         $this->render('error/error.phtml');
     }
 }
示例#2
0
 public function savesitepreference($wizardpreferenceform, $wizardData)
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     if ($wizardpreferenceform->isValid($this->_request->getPost())) {
         $trDb = Zend_Db_Table::getDefaultAdapter();
         // starting transaction
         $trDb->beginTransaction();
         try {
             $systempreferencemodel = new Default_Model_Sitepreference();
             $currencymodel = new Default_Model_Currency();
             $orgInfoModel = new Default_Model_Organisationinfo();
             $wizard_model = new Default_Model_Wizard();
             $IdentityCodesModel = new Default_Model_Identitycodes();
             $employmentstatusmodel = new Default_Model_Employmentstatus();
             $countriesmodel = new Default_Model_Countries();
             $statesmodel = new Default_Model_States();
             $citiesmodel = new Default_Model_Cities();
             $id = (int) $this->_request->getParam('id');
             $currencyid = (int) $this->_request->getParam('currencyid');
             $organisationid = (int) $this->_request->getParam('organisationid');
             $empcodeid = (int) $this->_request->getParam('empcodeid');
             $dateformatid = $this->_request->getParam('dateformatid');
             $timeformatid = $this->_request->getParam('timeformatid');
             $timezoneid = $this->_request->getParam('timezoneid');
             $currencyname = $this->_request->getParam('currencyname');
             $currencycode = $this->_request->getParam('currencycode');
             $passwordid = $this->_request->getParam('passwordid');
             $perm_country = $this->_request->getParam('perm_country');
             $perm_stateparam = $this->_request->getParam('perm_state');
             $perm_stateArr = explode("!@#", $this->_request->getParam('perm_state'));
             $perm_state = $perm_stateArr[0];
             $perm_cityparam = $this->_request->getParam('perm_city');
             $perm_cityArr = explode("!@#", $this->_request->getParam('perm_city'));
             $perm_city = $perm_cityArr[0];
             $employee_code = $this->_request->getParam('employee_code');
             $workcodename = $this->_request->getParam('workcodename');
             $date = new Zend_Date();
             $menumodel = new Default_Model_Menu();
             /*
              * Save or Update - Currency name in currency table based on currency ID
              */
             $currency_data = array('currencyname' => trim($currencyname), 'currencycode' => trim($currencycode), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             if ($currencyid != '') {
                 $currencywhere = array('id=?' => $currencyid);
             } else {
                 $currency_data['createdby'] = $loginUserId;
                 $currency_data['createddate'] = gmdate("Y-m-d H:i:s");
                 $currency_data['isactive'] = 1;
                 $currencywhere = '';
             }
             $CurrencyId = $currencymodel->SaveorUpdateCurrencyData($currency_data, $currencywhere);
             /*
              * End 
              */
             /*
              * Start -  Updating and Inserting Site Preference Data after fetching currency id
              */
             $siteprference_data = array('dateformatid' => $dateformatid, 'timeformatid' => $timeformatid, 'timezoneid' => $timezoneid, 'currencyid' => $currencyid != '' ? $currencyid : $CurrencyId, 'passwordid' => $passwordid, 'createdby' => $loginUserId, 'createddate' => $date->get('yyyy-MM-dd HH:mm:ss'), 'modifiedby' => $loginUserId, 'modifieddate' => $date->get('yyyy-MM-dd HH:mm:ss'), 'isactive' => 1);
             $site_update_arr = array('isactive' => 0, 'modifieddate' => $date->get('yyyy-MM-dd HH:mm:ss'), 'modifiedby' => $loginUserId);
             $systempreferencemodel->SaveorUpdateSystemPreferanceData($site_update_arr, 'isactive = 1');
             $Id = $systempreferencemodel->SaveorUpdateSystemPreferanceData($siteprference_data, '');
             /*
              *  End
              */
             /*
              * Updating Country,state and city based on organisation id
              */
             // Inserting into main_countries if not added
             $countryExistsArr = $countriesmodel->getActiveCountryName($perm_country);
             if (empty($countryExistsArr)) {
                 $countrynamearr = $countriesmodel->getCountryCode($perm_country);
                 if (!empty($countrynamearr)) {
                     $country_data = array('country' => trim($countrynamearr[0]['country_name']), 'countrycode' => trim($countrynamearr[0]['country_code']), 'citizenship' => NULL, 'createdby' => $loginUserId, 'createddate' => $date->get('yyyy-MM-dd HH:mm:ss'), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'country_id_org' => $perm_country, 'isactive' => 1);
                     $Country_Id = $countriesmodel->SaveorUpdateCountryData($country_data, '');
                 }
             }
             // Inserting into main_state if not added
             $State_Id = $statesmodel->SaveorUpdateStatesData($perm_country, $perm_stateArr[1], $perm_state, $loginUserId);
             // Inserting into main_cities if not added
             $City_Id = $citiesmodel->SaveorUpdateCitiesData($perm_country, $perm_state, $perm_cityArr[1], $perm_city, $loginUserId);
             $location_data = array('country' => $perm_country, 'state' => $perm_state, 'city' => $perm_city, 'createdby' => $loginUserId, 'createddate' => $date->get('yyyy-MM-dd HH:mm:ss'), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'isactive' => 1);
             if ($organisationid != '') {
                 $locwhere = array('id=?' => $organisationid);
                 $LocationId = $orgInfoModel->SaveorUpdateData($location_data, $orgwhere);
             }
             $LocationId = $wizard_model->SaveorUpdateWizardData($location_data, '');
             /*
              * End
              */
             /*
              * Start - Updating Employee Code
              */
             $empcode_data = array('employee_code' => trim($employee_code), 'modifiedBy' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             if ($empcodeid != '') {
                 $empcodewhere = array('id=?' => $empcodeid);
             } else {
                 $empcode_data['createdby'] = $loginUserId;
                 $empcode_data['createddate'] = gmdate("Y-m-d H:i:s");
                 $empcodewhere = '';
             }
             $EmpCodeId = $IdentityCodesModel->SaveorUpdateIdentitycodesData($empcode_data, $empcodewhere);
             /*
              * End
              */
             /*
              * Start - Update employment status data
              */
             if (!empty($workcodename)) {
                 $empstat_update_arr = array('isactive' => 0, 'modifieddate' => $date->get('yyyy-MM-dd HH:mm:ss'), 'modifiedby' => $loginUserId);
                 $Empstat_update_Id = $employmentstatusmodel->SaveorUpdateEmploymentStatusData($empstat_update_arr, 'isactive=1');
                 for ($j = 0; $j < sizeof($workcodename); $j++) {
                     switch ($workcodename[$j]) {
                         case 1:
                             $workcode = 'FT';
                             break;
                         case 2:
                             $workcode = 'PT';
                             break;
                         case 3:
                             $workcode = 'PERM';
                             break;
                         case 4:
                             $workcode = 'TEMP';
                             break;
                         case 5:
                             $workcode = 'PROB';
                             break;
                         case 6:
                             $workcode = 'CONT';
                             break;
                         case 7:
                             $workcode = 'DEP';
                             break;
                         case 8:
                             $workcode = 'RES';
                             break;
                         case 9:
                             $workcode = 'LEFT';
                             break;
                         case 10:
                             $workcode = 'SUSP';
                             break;
                         default:
                             $workcode = 'FT';
                     }
                     $empstatus_data = array('workcode' => trim($workcode), 'workcodename' => trim($workcodename[$j]), 'createdby' => $loginUserId, 'createddate' => gmdate("Y-m-d H:i:s"), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'isactive' => 1);
                     $Empstat_Id = $employmentstatusmodel->SaveorUpdateEmploymentStatusData($empstatus_data, '');
                 }
             }
             /*
              * End
              */
             /*
              * Update Wizard Table
              */
             $wizardarray = array('site_config' => 2, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             if ($wizardData['org_details'] == 2) {
                 $wizardarray['iscomplete'] = 2;
             }
             $wizard_model->SaveorUpdateWizardData($wizardarray, '');
             $trDb->commit();
             $this->_helper->getHelper("FlashMessenger")->addMessage("Site Preference updated successfully.");
             $this->_redirect('wizard/configuresite');
         } catch (Exception $e) {
             $trDb->rollBack();
             $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Something went wrong,please try again later."));
             $this->_redirect('wizard/configuresite');
         }
     } else {
         $messages = $wizardpreferenceform->getMessages();
         foreach ($messages as $key => $val) {
             foreach ($val as $key2 => $val2) {
                 $msgarray[$key] = $val2;
                 break;
             }
         }
         return $msgarray;
     }
 }
 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;
     }
 }
 public function editAction()
 {
     $auth = Zend_Auth::getInstance();
     $role_datap = array();
     $empGroup = "";
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
         $loginuserUnitID = $auth->getStorage()->read()->businessunit_id;
         $loginuserDeptID = $auth->getStorage()->read()->department_id;
     }
     $id = (int) $this->getRequest()->getParam('id');
     $id = abs($id);
     if ($id == '') {
         $id = $loginUserId;
     }
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $employeeform = new Default_Form_Myteamemployee();
     try {
         if ($id != '' && is_numeric($id) && $id > 0 && $id != $loginUserId) {
             $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 = array();
             $empDeptId = "";
             $empRoleId = "";
             $data = $employeeModal->getsingleEmployeeData($id);
             if ($data == 'norows') {
                 $this->view->rowexist = "norows";
             } else {
                 if (!empty($data)) {
                     $this->view->rowexist = "rows";
                     $employeeform->submit->setLabel('Update');
                     $data = $data[0];
                     /* Earlier code to fetch employee details */
                     $employeeData = $employeeModal->getsingleEmployeeData($id);
                     $roles_arr = $role_model->getRolesListByGroupID(EMPLOYEE_GROUP);
                     if (sizeof($roles_arr) > 0) {
                         $employeeform->emprole->addMultiOptions(array('' => 'Select Role') + $roles_arr);
                     }
                     $employmentStatusData = $employmentstatusModel->getempstatuslist();
                     if (sizeof($employmentStatusData) > 0) {
                         $employeeform->emp_status_id->addMultiOption('', 'Select Employment Status');
                         foreach ($employmentStatusData as $employmentStatusres) {
                             $employeeform->emp_status_id->addMultiOption($employmentStatusres['workcodename'], $employmentStatusres['statusname']);
                         }
                     }
                     $businessunitData = $busineesUnitModel->getDeparmentList();
                     if (sizeof($businessunitData) > 0) {
                         foreach ($businessunitData as $businessunitres) {
                             if ($businessunitres['id'] == $loginuserUnitID) {
                                 $employeeform->businessunit_id->addMultiOption($businessunitres['id'], $businessunitres['unitname']);
                             }
                         }
                     }
                     $departmentsData = $deptModel->getDepartmentList($data['businessunit_id']);
                     if (sizeof($departmentsData) > 0) {
                         foreach ($departmentsData as $departmentsres) {
                             if ($departmentsres['id'] == $loginuserDeptID) {
                                 $employeeform->department_id->addMultiOption($departmentsres['id'], $departmentsres['deptname']);
                             }
                         }
                     }
                     $jobtitleData = $jobtitlesModel->getJobTitleList();
                     if (sizeof($jobtitleData) > 0) {
                         $employeeform->jobtitle_id->addMultiOption('', 'Select 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 Position');
                         foreach ($positionlistArr as $positionlistres) {
                             $employeeform->position_id->addMultiOption($positionlistres['id'], $positionlistres['positionname']);
                         }
                     }
                     $prefixData = $prefixModel->getPrefixList();
                     if (!empty($prefixData)) {
                         foreach ($prefixData as $prefixres) {
                             $employeeform->prefix_id->addMultiOption($prefixres['id'], $prefixres['prefix']);
                         }
                     }
                     $userData = $usersModel->getUserDetails($loginUserId);
                     if (count($userData) > 0) {
                         $employeeform->reporting_manager->addMultiOption($userData[0]['id'], $userData[0]['userfullname']);
                     }
                     $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']);
                     $employeeform->setDefault('prefix_id', $data['prefix_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);
                     }
                     $role_data = $role_model->getRoleDataById($data['emprole']);
                     $employeeform->emprole->setValue($data['emprole'] . "_" . $role_data['group_id']);
                     $employeeform->setAttrib('action', DOMAIN . 'myemployees/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;
                 }
             }
         } else {
             $this->view->rowexist = "norows";
         }
         if ($this->getRequest()->getPost()) {
             $result = $this->save($employeeform);
             $this->view->msgarray = $result;
             $employeeform->modeofentry->setValue($data['modeofentry']);
         }
     } catch (Exception $e) {
         $this->view->rowexist = "norows";
     }
 }
示例#5
0
 public function getGrid($sort, $by, $perPage, $pageNo, $searchData, $call, $dashboardcall, $exParam1 = '', $exParam2 = '', $exParam3 = '', $exParam4 = '')
 {
     $searchQuery = '';
     $tablecontent = '';
     $emptyroles = 0;
     $empstatus_opt = array();
     $searchArray = array();
     $data = array();
     $id = '';
     $dataTmp = array();
     if ($searchData != '' && $searchData != 'undefined') {
         $searchValues = json_decode($searchData);
         foreach ($searchValues as $key => $val) {
             if ($key == 'astatus') {
                 $searchQuery .= " e.isactive like '%" . $val . "%' AND ";
             } else {
                 if ($key == 'extn') {
                     $searchQuery .= " concat(e.office_number,' (ext ',e.extension_number,')') like '%" . $val . "%' AND ";
                 } else {
                     $searchQuery .= $key . " like '%" . $val . "%' AND ";
                 }
             }
             $searchArray[$key] = $val;
         }
         $searchQuery = rtrim($searchQuery, " AND");
     }
     $objName = 'employee';
     $tableFields = array('action' => 'Action', 'firstname' => 'First Name', 'lastname' => 'Last Name', 'emailaddress' => 'E-mail', 'employeeId' => 'Employee ID', 'astatus' => 'User Status', 'extn' => 'Work Phone', 'jobtitle_name' => 'Job Title', 'reporting_manager_name' => 'Reporting Manager', 'contactnumber' => 'Contact Number', 'emp_status_name' => 'Employment Status', 'emprole_name' => "Role");
     $tablecontent = $this->getEmployeesData($sort, $by, $pageNo, $perPage, $searchQuery, '', $exParam1);
     if ($tablecontent == "emptyroles") {
         $emptyroles = 1;
     } else {
         $employmentstatusModel = new Default_Model_Employmentstatus();
         $employmentStatusData = $employmentstatusModel->getempstatuslist();
         if (count($employmentStatusData) > 0) {
             foreach ($employmentStatusData as $empsdata) {
                 $empstatus_opt[$empsdata['workcodename']] = $empsdata['statusname'];
             }
         }
     }
     $dataTmp = array('userid' => $id, 'sort' => $sort, 'by' => $by, 'pageNo' => $pageNo, 'perPage' => $perPage, 'tablecontent' => $tablecontent, 'objectname' => $objName, 'extra' => array(), 'tableheader' => $tableFields, 'jsGridFnName' => 'getAjaxgridData', 'jsFillFnName' => '', 'searchArray' => $searchArray, 'menuName' => 'Employees', 'dashboardcall' => $dashboardcall, 'add' => 'add', 'call' => $call, 'search_filters' => array('astatus' => array('type' => 'select', 'filter_data' => array('' => 'All', 1 => 'Active', 0 => 'Inactive')), 'emp_status_id' => array('type' => 'select', 'filter_data' => array('' => 'All') + $empstatus_opt)), 'emptyroles' => $emptyroles);
     return $dataTmp;
 }
 public function editAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $id = $this->getRequest()->getParam('id');
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $appraisalinitform = new Default_Form_Appraisalinit();
     $appraisalinitform->submit->setLabel('Update');
     try {
         if ($id) {
             if (is_numeric($id) && $id > 0) {
                 $appraisalinitmodel = new Default_Model_Appraisalinit();
                 $data = $appraisalinitmodel->getConfigData($id);
                 if (!empty($data)) {
                     $empSummaryModel = new Default_Model_Employee();
                     $empData = $empSummaryModel->getEmp_from_summary($loginUserId);
                     $appraisalinitform->businessunit_name->setValue($empData['businessunit_name']);
                     $appraisalinitform->department_name->setValue($empData['department_name']);
                     $employmentstatusModel = new Default_Model_Employmentstatus();
                     $employmentStatusData = $employmentstatusModel->getempstatusActivelist();
                     if (!empty($employmentStatusData)) {
                         foreach ($employmentStatusData as $employmentStatusres) {
                             $appraisalinitform->eligibility->addMultiOption($employmentStatusres['workcodename'], $employmentStatusres['statusname']);
                         }
                     }
                     $data = $data[0];
                     $appraisalinitform->populate($data);
                     $appraisalinitform->setAttrib('action', DOMAIN . 'appraisalinit/edit/id/' . $id);
                     $this->view->data = $data;
                 } else {
                     $this->view->ermsg = 'norecord';
                 }
             } else {
                 $this->view->ermsg = 'norecord';
             }
         } else {
             $this->view->ermsg = '';
         }
     } catch (Exception $e) {
         $this->view->ermsg = 'nodata';
     }
     $this->view->eligibility_value = $data['eligibility'];
     $this->view->form = $appraisalinitform;
     if ($this->getRequest()->getPost()) {
         $result = $this->save($appraisalinitform);
         $this->view->msgarray = $result;
     }
     $this->render('form');
 }
示例#7
0
 public function getGrid($sort, $by, $perPage, $pageNo, $searchData, $call, $dashboardcall, $exParam1 = '', $exParam2 = '', $exParam3 = '', $exParam4 = '')
 {
     $searchQuery = '';
     $tablecontent = '';
     $emptyroles = 0;
     $empstatus_opt = array();
     $searchArray = array();
     $data = array();
     $id = '';
     $dataTmp = array();
     $auth = Zend_Auth::getInstance();
     $request = Zend_Controller_Front::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserGroup = $auth->getStorage()->read()->group_id;
         $loginUserRole = $auth->getStorage()->read()->emprole;
     }
     $controllerName = $request->getRequest()->getControllerName();
     if ($controllerName == 'employee' && ($loginUserRole == SUPERADMINROLE || $loginUserGroup == HR_GROUP || $loginUserGroup == MANAGEMENT_GROUP)) {
         $filterArray = array('' => 'All', 1 => 'Active', 0 => 'Inactive', 2 => 'Resigned', 3 => 'Left', 4 => 'Suspended');
     } else {
         $filterArray = array('' => 'All', 1 => 'Active');
     }
     if ($searchData != '' && $searchData != 'undefined') {
         $searchValues = json_decode($searchData);
         foreach ($searchValues as $key => $val) {
             if ($key == 'astatus') {
                 $searchQuery .= " e.isactive like '%" . $val . "%' AND ";
             } else {
                 if ($key == 'extn') {
                     $searchQuery .= " concat(e.office_number,' (ext ',e.extension_number,')') like '%" . $val . "%' AND ";
                 } else {
                     $searchQuery .= $key . " like '%" . $val . "%' AND ";
                 }
             }
             $searchArray[$key] = $val;
         }
         $searchQuery = rtrim($searchQuery, " AND");
     }
     $objName = 'employee';
     $tableFields = array('action' => 'Action', 'firstname' => 'First Name', 'lastname' => 'Last Name', 'emailaddress' => 'Email', 'employeeId' => 'Employee ID', 'businessunit_name' => 'Business Unit', 'department_name' => 'Department', 'astatus' => 'User Status', 'extn' => 'Work Phone', 'jobtitle_name' => 'Job Title', 'reporting_manager_name' => 'Reporting Manager', 'contactnumber' => 'Contact Number', 'emp_status_name' => 'Employment Status', 'emprole_name' => "Role");
     $tablecontent = $this->getEmployeesData($sort, $by, $pageNo, $perPage, $searchQuery, '', $exParam1);
     if ($tablecontent == "emptyroles") {
         $emptyroles = 1;
     } else {
         $employmentstatusModel = new Default_Model_Employmentstatus();
         $employmentStatusData = $employmentstatusModel->getempstatuslist();
         if (count($employmentStatusData) > 0) {
             foreach ($employmentStatusData as $empsdata) {
                 $empstatus_opt[$empsdata['workcodename']] = $empsdata['statusname'];
             }
         }
     }
     $dataTmp = array('userid' => $id, 'sort' => $sort, 'by' => $by, 'pageNo' => $pageNo, 'perPage' => $perPage, 'tablecontent' => $tablecontent, 'objectname' => $objName, 'extra' => array(), 'tableheader' => $tableFields, 'jsGridFnName' => 'getAjaxgridData', 'jsFillFnName' => '', 'searchArray' => $searchArray, 'menuName' => 'Employees', 'dashboardcall' => $dashboardcall, 'add' => 'add', 'call' => $call, 'search_filters' => array('astatus' => array('type' => 'select', 'filter_data' => $filterArray), 'emp_status_id' => array('type' => 'select', 'filter_data' => array('' => 'All') + $empstatus_opt)), 'emptyroles' => $emptyroles);
     return $dataTmp;
 }
示例#8
0
 public function addemppopupAction()
 {
     $flag = 'true';
     $controllername = 'employee';
     $msgarray = array();
     $emptyFlag = 0;
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $deptidforhead = $this->_getParam('deptidforhead', null);
     $report_opt = array();
     $emp_form = new Default_Form_employee();
     $user_model = new Default_Model_Usermanagement();
     $role_model = new Default_Model_Roles();
     $prefixModel = new Default_Model_Prefix();
     $identity_code_model = new Default_Model_Identitycodes();
     $jobtitlesModel = new Default_Model_Jobtitles();
     $deptModel = new Default_Model_Departments();
     $positionsmodel = new Default_Model_Positions();
     $employeeModal = new Default_Model_Employee();
     $usersModel2 = new Default_Model_Users();
     $employmentstatusModel = new Default_Model_Employmentstatus();
     $emp_form->setAction(BASE_URL . 'employee/addemppopup/deptidforhead/' . $deptidforhead);
     $emp_form->removeElement('department_id');
     $emp_form->removeElement('modeofentry');
     $identity_codes = $identity_code_model->getIdentitycodesRecord();
     $emp_identity_code = isset($identity_codes[0]) ? $identity_codes[0]['employee_code'] : "";
     if ($emp_identity_code != '') {
         $emp_id = $emp_identity_code . str_pad($user_model->getMaxEmpId($emp_identity_code), 4, '0', STR_PAD_LEFT);
     } else {
         $emp_id = '';
         $msgarray['employeeId'] = 'Identity codes are not configured yet.';
         $flag = 'false';
     }
     $emp_form->employeeId->setValue($emp_id);
     $role_data = $role_model->getRolesList_Dept();
     $emp_form->emprole->addMultiOptions(array('' => 'Select Role') + $role_data);
     if (empty($role_data)) {
         $msgarray['emprole'] = 'Roles are not configured yet.';
         $flag = 'false';
     }
     $prefixData = $prefixModel->getPrefixList();
     $emp_form->prefix_id->addMultiOption('', 'Select Prefix');
     if (!empty($prefixData)) {
         foreach ($prefixData as $prefixres) {
             $emp_form->prefix_id->addMultiOption($prefixres['id'], $prefixres['prefix']);
         }
     } else {
         $msgarray['prefix_id'] = 'Prefixes are not configured yet.';
         //$flag = 'false';
     }
     $jobtitleData = $jobtitlesModel->getJobTitleList();
     if (!empty($jobtitleData)) {
         foreach ($jobtitleData as $jobtitleres) {
             $emp_form->jobtitle_id->addMultiOption($jobtitleres['id'], $jobtitleres['jobtitlename']);
         }
     } else {
         $msgarray['jobtitle_id'] = 'Job titles are not configured yet.';
         $msgarray['position_id'] = 'Positions are not configured yet.';
         //$flag = 'false';
     }
     if (isset($_POST['jobtitle_id']) && $_POST['jobtitle_id'] != '') {
         $positionlistArr = $positionsmodel->getPositionList($_POST['jobtitle_id']);
         if (sizeof($positionlistArr) > 0) {
             $emp_form->position_id->addMultiOption('', 'Select Position');
             foreach ($positionlistArr as $positionlistres) {
                 $emp_form->position_id->addMultiOption($positionlistres['id'], $positionlistres['positionname']);
             }
         }
     }
     $employmentStatusData = $employmentstatusModel->getempstatusActivelist();
     $emp_form->emp_status_id->addMultiOption('', 'Select Employment Status');
     if (!empty($employmentStatusData)) {
         foreach ($employmentStatusData as $employmentStatusres) {
             $emp_form->emp_status_id->addMultiOption($employmentStatusres['workcodename'], $employmentStatusres['statusname']);
         }
     } else {
         $msgarray['emp_status_id'] = 'Employment status is not configured yet.';
         $emptyFlag++;
     }
     $reportingManagerData = $usersModel2->getReportingManagerList_employees('', '', MANAGEMENT_GROUP);
     if (!empty($reportingManagerData)) {
         $report_opt = $reportingManagerData;
         if (isset($_POST['reporting_manager']) && $_POST['reporting_manager'] != '') {
             $emp_form->setDefault('reporting_manager', $_POST['reporting_manager']);
         }
     } else {
         $msgarray['reporting_manager'] = 'Reporting managers are not added yet.';
         $flag = 'false';
     }
     if ($this->getRequest()->getPost()) {
         if ($emp_form->isValid($this->_request->getPost()) && $flag == 'true') {
             $jobtitle_id = $this->_request->getParam('jobtitle_id', null);
             $position_id = $this->_request->getParam('position_id', null);
             $date_of_joining = sapp_Global::change_date($this->_request->getParam('date_of_joining', null), 'database');
             $date_of_leaving = $this->_request->getParam('date_of_leaving', null);
             $date_of_leaving = sapp_Global::change_date($date_of_leaving, 'database');
             $employeeId = $this->_getParam('employeeId', null);
             $emprole = $this->_getParam('emprole', null);
             $reporting_manager = $this->_getParam('reporting_manager', null);
             $emailaddress = $this->_getParam('emailaddress', null);
             $emppassword = sapp_Global::generatePassword();
             $firstname = trim($this->_getParam('firstname', null));
             $lastname = trim($this->_getParam('lastname', null));
             $userfullname = $firstname . ' ' . $lastname;
             //$userfullname = trim($this->_request->getParam('userfullname',null));
             $prefix_id = $this->_getParam('prefix_id', null);
             $user_id = $this->_getParam('user_id', null);
             $emp_status_id = $this->_getParam('emp_status_id', null);
             $user_data = array('emprole' => $emprole, 'firstname' => $firstname != '' ? $firstname : NULL, 'lastname' => $lastname != '' ? $lastname : NULL, 'userfullname' => $userfullname, 'emailaddress' => $emailaddress, 'jobtitle_id' => $jobtitle_id, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'emppassword' => md5($emppassword), 'employeeId' => $employeeId, 'modeofentry' => 'Direct', 'selecteddate' => $date_of_joining, 'userstatus' => 'old');
             $emp_data = array('user_id' => $user_id, 'jobtitle_id' => $jobtitle_id, 'position_id' => $position_id, 'prefix_id' => $prefix_id, 'department_id' => $deptidforhead, 'reporting_manager' => $reporting_manager, 'date_of_joining' => $date_of_joining, 'date_of_leaving' => $date_of_leaving != '' ? $date_of_leaving : NULL, 'emp_status_id' => $emp_status_id, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             $user_data['createdby'] = $loginUserId;
             $user_data['createddate'] = gmdate("Y-m-d H:i:s");
             $user_data['isactive'] = 1;
             if ($emp_identity_code != '') {
                 $emp_id = $emp_identity_code . str_pad($user_model->getMaxEmpId($emp_identity_code), 4, '0', STR_PAD_LEFT);
             } else {
                 $emp_id = '';
             }
             $user_data['employeeId'] = $emp_id;
             $user_id = $user_model->SaveorUpdateUserData($user_data, '');
             $emp_data['user_id'] = $user_id;
             $emp_data['createdby'] = $loginUserId;
             $emp_data['createddate'] = gmdate("Y-m-d H:i:s");
             $emp_data['isactive'] = 1;
             $employeeModal->SaveorUpdateEmployeeData($emp_data, '');
             //end of saving into employee table.
             $tableid = $user_id;
             $actionflag = 1;
             $menuID = ORGANISATIONINFO;
             try {
                 $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
             } catch (Exception $e) {
             }
             $managementUsersData = $deptModel->getDeptHeads();
             $opt = '';
             foreach ($managementUsersData as $record) {
                 $opt .= sapp_Global::selectOptionBuilder($record['id'], $record['userfullname']);
             }
             $this->view->managementUsersData = $opt;
             /* Send Mail to the user */
             $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
             $view = $this->getHelper('ViewRenderer')->view;
             $this->view->emp_name = $userfullname;
             $this->view->password = $emppassword;
             $this->view->emp_id = $employeeId;
             $this->view->base_url = $base_url;
             $text = $view->render('mailtemplates/newpassword.phtml');
             $options['subject'] = APPLICATION_NAME . ' login Credentials';
             $options['header'] = 'Greetings from Sentrifugo';
             $options['toEmail'] = $emailaddress;
             $options['toName'] = $this->view->emp_name;
             $options['message'] = $text;
             $result = sapp_Global::_sendEmail($options);
             /* END */
             $this->view->eventact = 'added';
             $close = 'close';
             $this->view->popup = $close;
         } else {
             $messages = $emp_form->getMessages();
             foreach ($messages as $key => $val) {
                 foreach ($val as $key2 => $val2) {
                     $msgarray[$key] = $val2;
                     break;
                 }
             }
             $this->view->msgarray = $msgarray;
         }
     }
     $this->view->msgarray = $msgarray;
     $this->view->report_opt = $report_opt;
     $this->view->controllername = $controllername;
     $this->view->emp_form = $emp_form;
 }
示例#9
0
 public function employeereportAction()
 {
     $norec_arr = array();
     $form = new Default_Form_Employeereport();
     $requi_model = new Default_Model_Requisition();
     $employmentstatusModel = new Default_Model_Employmentstatus();
     $role_model = new Default_Model_Roles();
     $departmentsmodel = new Default_Model_Departments();
     $bu_model = new Default_Model_Businessunits();
     $roles_arr = $role_model->getRolesList_EMP();
     $job_data = $requi_model->getJobTitleList();
     $employmentStatusData = $employmentstatusModel->getempstatuslist();
     if (count($job_data) == 0) {
         $norec_arr['jobtitle_id'] = "Job titles are not configured yet.";
         $norec_arr['position_id'] = "Positions are not configured yet.";
     }
     if (count($employmentStatusData) == 0) {
         $norec_arr['emp_status_id'] = "Employment status is not configured yet.";
     }
     $form->jobtitle_id->addMultiOptions(array('' => 'Select Job Title') + $job_data);
     if (count($employmentStatusData) > 0) {
         $form->emp_status_id->addMultiOption('', 'Select Employment Status');
         foreach ($employmentStatusData as $employmentStatusres) {
             $form->emp_status_id->addMultiOption($employmentStatusres['workcodename'], $employmentStatusres['statusname']);
         }
     }
     if (sizeof($roles_arr) > 0) {
         $form->emprole->addMultiOptions(array('' => 'Select Role') + $roles_arr);
     } else {
         $norec_arr['emprole'] = 'Roles are not added yet.';
     }
     $bu_arr = $bu_model->getBU_report();
     if (!empty($bu_arr)) {
         foreach ($bu_arr as $bu) {
             $form->businessunit_id->addMultiOption($bu['id'], utf8_encode($bu['bu_name']));
         }
     } else {
         $norec_arr['businessunit_id'] = 'Business Units are not added yet.';
     }
     $this->view->form = $form;
     $this->view->messages = $norec_arr;
 }
 /**
  * This action is used for adding/updating data.
  * @parameters
  * @param $id  =  id of requisition.
  *
  * @return Zend_Form.
  */
 public function editAction()
 {
     $id = $this->getRequest()->getParam('id', null);
     $auth = Zend_Auth::getInstance();
     $data = array();
     $data_m = array();
     $job_title_permission = NULL;
     if ($auth->hasIdentity()) {
         $sess_vals = $auth->getStorage()->read();
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $job_title_permission = sapp_Global::_checkprivileges(JOBTITLES, $loginuserGroup, $loginuserRole, 'add');
     $positions_permission = sapp_Global::_checkprivileges(POSITIONS, $loginuserGroup, $loginuserRole, 'add');
     $emp_status_permission = sapp_Global::_checkprivileges(EMPLOYMENTSTATUS, $loginuserGroup, $loginuserRole, 'add');
     $form = new Default_Form_Requisition();
     $requi_model = new Default_Model_Requisition();
     $usersModel = new Default_Model_Users();
     $user_model = new Default_Model_Usermanagement();
     $form->setAttrib('action', DOMAIN . 'requisition/edit/id/' . $id);
     $form->submit->setLabel('Update');
     $edit_flag = '';
     $edit_order = '';
     $approver1_opt = array();
     $approver2_opt = array();
     $approver3_opt = array();
     $reportingManagerData = array();
     try {
         if ($id > 0 && is_numeric($id)) {
             $id = abs($id);
             $data = $requi_model->getRequisitionForEdit($id, $loginUserId);
             $aflag = $data['aflag'];
             $aorder = $data['aorder'];
             if (!empty($data) && $data['req_status'] == 'Initiated') {
                 if ($loginuserGroup != MANAGEMENT_GROUP || $loginuserGroup == MANAGEMENT_GROUP || $loginuserGroup == '') {
                     if ($aflag == 'approver' && $data['appstatus' . $aorder] == 'Initiated') {
                         $data['onboard_date'] = sapp_Global::change_date($data['onboard_date'], 'view');
                         $business_units_list = $requi_model->getBusinessUnitsList();
                         $data['bunit_name'] = $business_units_list[$data['businessunit_id']];
                         $departments_list = $requi_model->getDepartmentList($data['businessunit_id']);
                         $data['dept_name'] = $departments_list[$data['department_id']];
                         $job_data = $requi_model->getJobTitleList();
                         if (isset($job_data[$data['jobtitle']])) {
                             $data['jtitle_name'] = $job_data[$data['jobtitle']];
                         } else {
                             $data['jtitle_name'] = 'Select Job Title';
                         }
                         $pos_data = $requi_model->getPositionOptions($data['jobtitle']);
                         $data['position_name'] = $pos_data[$data['position_id']];
                         $emptype_options = $requi_model->getStatusOptionsForRequi();
                         if (isset($emptype_options[$data['emp_type']])) {
                             $data['emptype_name'] = $emptype_options[$data['emp_type']];
                         } else {
                             $data['emptype_name'] = 'Select Employment Status';
                         }
                         $report_manager_data = $user_model->getUserDataById($data['reporting_id']);
                         $data['mngrname'] = $report_manager_data['userfullname'];
                         $form->req_status->addMultiOptions(array('0' => 'Select status', '2' => 'Approved', '3' => 'Rejected'));
                         $form->req_status->setRequired(true)->addErrorMessage('Please select the status.');
                         $form->req_status->addFilter('Int')->addValidator('NotEmpty', true, array('integer', 'zero'));
                         $elements = $form->getElements();
                         if (count($elements) > 0) {
                             foreach ($elements as $key => $element) {
                                 if ($key != 'req_status') {
                                     $element->setRequired(false);
                                 }
                             }
                         }
                         if ($data['approver1'] != '') {
                             $app1_opt = $user_model->getUserDataById($data['approver1']);
                             $data_m['approver1'] = $app1_opt['userfullname'];
                         }
                         if ($data['approver2'] != '') {
                             $app2_opt = $user_model->getUserDataById($data['approver2']);
                             $data_m['approver2'] = $app2_opt['userfullname'];
                         }
                         if ($data['approver3'] != '') {
                             $app3_opt = $user_model->getUserDataById($data['approver3']);
                             $data_m['approver3'] = $app3_opt['userfullname'];
                         }
                     } else {
                         $edit_flag = 'no';
                         if (in_array('Approved', array($data['appstatus1'], $data['appstatus2'], $data['appstatus3']))) {
                             $edit_flag = 'yes';
                         }
                         if ($edit_flag == 'yes') {
                             $data['onboard_date'] = sapp_Global::change_date($data['onboard_date'], 'view');
                             $business_units_list = $requi_model->getBusinessUnitsList();
                             $data['bunit_name'] = $business_units_list[$data['businessunit_id']];
                             $departments_list = $requi_model->getDepartmentList($data['businessunit_id']);
                             $data['dept_name'] = $departments_list[$data['department_id']];
                             $job_data = $requi_model->getJobTitleList();
                             if (isset($job_data[$data['jobtitle']])) {
                                 $data['jtitle_name'] = $job_data[$data['jobtitle']];
                             } else {
                                 $data['jtitle_name'] = 'Select Job Title';
                             }
                             $pos_data = $requi_model->getPositionOptions($data['jobtitle']);
                             $data['position_name'] = $pos_data[$data['position_id']];
                             $emptype_options = $requi_model->getStatusOptionsForRequi();
                             if (isset($emptype_options[$data['emp_type']])) {
                                 $data['emptype_name'] = $emptype_options[$data['emp_type']];
                             } else {
                                 $data['emptype_name'] = 'Select Employment Status';
                             }
                             $report_manager_data = $user_model->getUserDataById($data['reporting_id']);
                             $data['mngrname'] = $report_manager_data['userfullname'];
                             $elements = $form->getElements();
                             if (count($elements) > 0) {
                                 foreach ($elements as $key => $element) {
                                     $element->setRequired(false);
                                 }
                             }
                             if ($data['appstatus1'] == 'Approved') {
                                 $edit_order = 1;
                                 $app1_opt = $user_model->getUserDataById($data['approver1']);
                                 $data_m['approver1'] = $app1_opt['userfullname'];
                                 $report_manager_options = $requi_model->getapprovers($data['reporting_id'], $data['department_id']);
                                 $app2_options = array();
                                 foreach ($report_manager_options as $app1) {
                                     if ($app1['id'] != $loginUserId && $app1['id'] != $data['approver1']) {
                                         $approver2_opt[] = array('id' => $app1['id'], 'name' => ucwords($app1['name']), 'profileimg' => $app1['profileimg']);
                                     }
                                 }
                                 $form->setDefault('approver1', $data['approver1']);
                                 $form->approver2->clearMultiOptions();
                                 $form->setDefault('approver2', $data['approver2']);
                                 if ($data['approver2'] != '') {
                                     $app3_options = array();
                                     foreach ($report_manager_options as $app1) {
                                         if ($app1['id'] != $loginUserId && $app1['id'] != $data['approver1'] && $app1['id'] != $data['approver2']) {
                                             $approver3_opt[] = array('id' => $app1['id'], 'name' => ucwords($app1['name']), 'profileimg' => $app1['profileimg']);
                                         }
                                     }
                                     $form->approver3->clearMultiOptions();
                                     $form->setDefault('approver3', $data['approver3']);
                                 }
                             }
                             if ($data['appstatus2'] == 'Approved') {
                                 $edit_order = 2;
                                 $app2_opt = $user_model->getUserDataById($data['approver2']);
                                 $data_m['approver2'] = $app2_opt['userfullname'];
                                 $report_manager_options = $requi_model->getapprovers($data['reporting_id'], $data['department_id']);
                                 $app3_options = array();
                                 foreach ($report_manager_options as $app1) {
                                     if ($app1['id'] != $loginUserId && $app1['id'] != $data['approver1'] && $app1['id'] != $data['approver2']) {
                                         $app3_options[$app1['id']] = ucwords($app1['name']);
                                     }
                                 }
                                 $form->approver3->clearMultiOptions();
                                 $form->approver3->addMultiOptions(array('' => 'Select Approver -3') + $app3_options);
                                 $form->setDefault('approver3', $data['approver3']);
                             }
                             if ($data['appstatus3'] == 'Approved') {
                                 $edit_order = 3;
                                 $app3_opt = $user_model->getUserDataById($data['approver3']);
                                 $data_m['approver3'] = $app3_opt['userfullname'];
                             }
                         } else {
                             $business_units_list = $requi_model->getBusinessUnitsList();
                             $form->business_unit->addMultiOptions(array('' => 'Select Business Unit') + $business_units_list);
                             $form->setDefault('business_unit', $data['businessunit_id']);
                             $departments_list = $requi_model->getDepartmentList($data['businessunit_id']);
                             $form->department->addMultiOptions(array('' => 'Select Department') + $departments_list);
                             $form->setDefault('department', $data['department_id']);
                             $job_data = $requi_model->getJobTitleList();
                             $form->jobtitle->addMultiOptions(array('' => 'Select Job Title') + $job_data);
                             $form->setDefault('jobtitle', $data['jobtitle']);
                             $pos_data = $requi_model->getPositionOptions($data['jobtitle']);
                             $form->position_id->addMultiOptions(array('' => 'Select Position') + $pos_data);
                             $form->setDefault('position_id', $data['position_id']);
                             $emptype_options = $requi_model->getStatusOptionsForRequi();
                             $form->emp_type->addMultiOptions(array('' => 'Select Employment Status') + $emptype_options);
                             $form->requisition_code->setValue($data['requisition_code']);
                             $form->req_status->addMultiOptions(array('1' => 'Initiated'));
                             if ($loginuserGroup == HR_GROUP || $loginuserGroup == '' || $loginuserGroup == MANAGEMENT_GROUP) {
                                 if ($loginuserGroup == '') {
                                     $reportingManagerData = $requi_model->getReportingmanagers('', $loginUserId, '', $data['department_id'], 'requisition');
                                 } else {
                                     $reportingManagerData = $requi_model->getReportingmanagers('', '', '', $data['department_id'], 'requisition');
                                 }
                                 if (isset($_POST['business_unit']) && $_POST['business_unit'] != '') {
                                     $departments_list = $requi_model->getDepartmentList($_POST['business_unit']);
                                     $form->department->addMultiOptions(array('' => 'Select Department') + $departments_list);
                                 }
                                 if (isset($_POST['department']) && $_POST['department'] != '') {
                                     $reportingManagerData = $requi_model->getReportingmanagers('', $loginUserId, '', $_POST['department'], 'requisition');
                                 }
                                 $form->setDefault('reporting_id', $data['reporting_id']);
                                 $form->setDefault('req_status', $data['req_status']);
                                 $form->req_status->setAttrib("disabled", "disabled");
                                 if ($loginuserGroup == HR_GROUP) {
                                     $departments_list = $requi_model->getDepartmentList($sess_vals->businessunit_id);
                                     $data_m['bunit_data']['id'] = $sess_vals->businessunit_id;
                                     $data_m['bunit_data']['name'] = $business_units_list[$sess_vals->businessunit_id];
                                     $form->department->addMultiOptions(array('' => 'Select Department') + $departments_list);
                                 }
                             } else {
                                 $report_manager_options = $user_model->getUserDataById($data['reporting_id']);
                                 $departments_list = $requi_model->getDepartmentList($data['businessunit_id']);
                                 $data_m['manager_data']['id'] = $data['reporting_id'];
                                 $data_m['manager_data']['name'] = $report_manager_options['userfullname'];
                                 $data_m['bunit_data']['id'] = $data['businessunit_id'];
                                 $data_m['bunit_data']['name'] = $business_units_list[$data['businessunit_id']];
                                 $data_m['dept_data']['id'] = $data['department_id'];
                                 $data_m['dept_data']['name'] = $departments_list[$data['department_id']];
                                 $form->setDefault('req_status', $data['req_status']);
                                 $form->req_status->setAttrib("disabled", "disabled");
                             }
                             //start of approvers options
                             $approver_opt = $requi_model->getapprovers($data['reporting_id'], $data['department_id']);
                             $app1_opt = array();
                             $app2_opt = array();
                             $app3_opt = array();
                             if (count($approver_opt) > 0 && count($_POST) == 0) {
                                 foreach ($approver_opt as $app1) {
                                     $approver1_opt[] = array('id' => $app1['id'], 'name' => ucwords($app1['name']), 'profileimg' => $app1['profileimg']);
                                 }
                                 foreach ($approver_opt as $app1) {
                                     if ($app1['id'] != $data['approver1']) {
                                         $approver2_opt[] = array('id' => $app1['id'], 'name' => ucwords($app1['name']), 'profileimg' => $app1['profileimg']);
                                     }
                                 }
                                 foreach ($approver_opt as $app1) {
                                     if ($app1['id'] != $data['approver1'] && $app1['id'] != $data['approver2']) {
                                         $approver3_opt[] = array('id' => $app1['id'], 'name' => ucwords($app1['name']), 'profileimg' => $app1['profileimg']);
                                     }
                                 }
                                 if ($data['approver2'] == '') {
                                     $approver3_opt = array();
                                 }
                             }
                             //end of approvers options
                             foreach ($data as $key => $val) {
                                 $data[$key] = htmlentities(addslashes($val), ENT_QUOTES, "UTF-8");
                             }
                             $data['onboard_date'] = sapp_Global::change_date($data['onboard_date'], 'view');
                             $form->populate($data);
                             if (isset($_POST['business_unit']) && $_POST['business_unit'] != '') {
                                 $departments_list = $requi_model->getDepartmentList($_POST['business_unit']);
                                 $form->department->clearMultiOptions();
                                 $form->department->addMultiOptions(array('' => 'Select Department') + $departments_list);
                             }
                             if (isset($_POST['jobtitle']) && $_POST['jobtitle'] != '') {
                                 $pos_data = $requi_model->getPositionOptions($_POST['jobtitle']);
                                 $form->position_id->clearMultiOptions();
                                 $form->position_id->addMultiOptions(array('' => 'Select Position') + $pos_data);
                             }
                             if (isset($_POST['reporting_id']) && $_POST['reporting_id'] != '') {
                                 $app1_data = $requi_model->getapprovers($_POST['reporting_id'], $_POST['department']);
                                 $app1_opt = array();
                                 if (count($app1_data) > 0) {
                                     foreach ($app1_data as $app1) {
                                         $app1_opt[$app1['id']] = ucwords($app1['name']);
                                         $approver1_opt[] = array('id' => $app1['id'], 'name' => ucwords($app1['name']), 'profileimg' => $app1['profileimg']);
                                     }
                                     $form->reporting_id->setValue($_POST['reporting_id']);
                                 }
                             }
                             if (isset($_POST['approver1']) && $_POST['approver1'] != '') {
                                 $app1_data = $requi_model->getapprovers($_POST['reporting_id'], $_POST['department']);
                                 $app1_opt = array();
                                 if (count($app1_data) > 0) {
                                     foreach ($app1_data as $app1) {
                                         if ($app1['id'] != $_POST['approver1']) {
                                             $approver2_opt[] = array('id' => $app1['id'], 'name' => ucwords($app1['name']), 'profileimg' => $app1['profileimg']);
                                         }
                                     }
                                     $form->approver1->setValue($_POST['approver1']);
                                 }
                             }
                             if (isset($_POST['approver2']) && $_POST['approver2'] != '') {
                                 $app1_data = $requi_model->getapprovers($_POST['reporting_id'], $_POST['department']);
                                 $app1_opt = array();
                                 if (count($app1_data) > 0) {
                                     foreach ($app1_data as $app1) {
                                         if ($app1['id'] != $_POST['approver1'] && $app1['id'] != $_POST['approver2']) {
                                             $approver3_opt[] = array('id' => $app1['id'], 'name' => ucwords($app1['name']), 'profileimg' => $app1['profileimg']);
                                         }
                                     }
                                     $form->approver2->setValue($_POST['approver2']);
                                 }
                             }
                             if (isset($_POST['approver3']) && $_POST['approver3'] != '') {
                                 $form->approver3->setValue($_POST['approver3']);
                             }
                         }
                     }
                     //end of else of aflag.
                     $this->view->loginuserGroup = $loginuserGroup;
                     $this->view->form = $form;
                     $this->view->data = $data;
                     $this->view->data_m = $data_m;
                     $this->view->aflag = $aflag;
                     $this->view->aorder = $aorder;
                     $this->view->edit_flag = $edit_flag;
                     $this->view->edit_order = $edit_order;
                     $this->view->reportingManagerData = $reportingManagerData;
                     $this->view->approver1_opt = $approver1_opt;
                     $this->view->approver2_opt = $approver2_opt;
                     $this->view->approver3_opt = $approver3_opt;
                     if ($this->getRequest()->getPost()) {
                         $result = $this->save($form, $data);
                         $this->view->msgarray = $result;
                         $this->view->messages = $result;
                     }
                     $this->view->ermsg = '';
                 } else {
                     $this->view->nodata = 'nodata';
                 }
             } else {
                 $this->view->nodata = 'nodata';
             }
         } else {
             $this->view->nodata = 'nodata';
         }
         // To check whether to display Employment Status configuration link or not
         $employmentstatusmodel = new Default_Model_Employmentstatus();
         $activeEmploymentStatusArr = $employmentstatusmodel->getEmploymentStatuslist();
         $this->view->job_title_permission = $job_title_permission;
         $this->view->positions_permission = $positions_permission;
         $this->view->emp_status_permission = $emp_status_permission;
     } catch (Exception $e) {
         $this->view->nodata = 'nodata';
     }
 }
 /**
  * This action is used for adding/updating data.
  * @parameters
  * @param $id  =  id of requisition.
  *
  * @return Zend_Form.
  */
 public function editAction()
 {
     $id = $this->getRequest()->getParam('id', null);
     $auth = Zend_Auth::getInstance();
     $data = array();
     $data_m = array();
     $ipreporting_idData = array();
     $ipreporting_ids = array();
     $technicalskills_all = array();
     $technicalskills_selected = array();
     $nontechnicalskills_all = array();
     $nontechnicalskills_selected = array();
     $job_title_permission = NULL;
     if ($auth->hasIdentity()) {
         $sess_vals = $auth->getStorage()->read();
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $job_title_permission = sapp_Global::_checkprivileges(JOBTITLES, $loginuserGroup, $loginuserRole, 'add');
     //$positions_permission = sapp_Global::_checkprivileges(POSITIONS, $loginuserGroup, $loginuserRole, 'add');
     $emp_status_permission = sapp_Global::_checkprivileges(EMPLOYMENTSTATUS, $loginuserGroup, $loginuserRole, 'add');
     $form = new Default_Form_Requisition();
     $requi_model = new Default_Model_Requisition();
     $usersModel = new Default_Model_Users();
     $user_model = new Default_Model_Usermanagement();
     $ipreporting_idData = $requi_model->getAllEmployees();
     $ipreporting_ids = $requi_model->getRequisitionInterviewPanelIDs($id);
     $technicalskills_all = $requi_model->getAllActiveTechnicalSkills();
     $technicalskills_selected = $requi_model->getRequisitionSkillIDs($id, "Technical");
     $nontechnicalskills_all = $requi_model->getAllActiveNonTechnicalSkills();
     $nontechnicalskills_selected = $requi_model->getRequisitionSkillIDs($id, "Non-Technical");
     $form->setAttrib('action', DOMAIN . 'requisition/edit/id/' . $id);
     $form->submit->setLabel('Update');
     $edit_flag = '';
     $edit_order = '';
     $approver1_opt = array();
     $approver2_opt = array();
     $reportingManagerData = array();
     $hrexecutivesData = array();
     try {
         if ($id > 0 && is_numeric($id)) {
             $id = abs($id);
             //$data['id'] = $id;
             $data = $requi_model->getRequisitionForEdit($id, $loginUserId);
             //$data['requ_jd'] = "<span title='" . htmlentities(trim($data['requ_jd']), ENT_QUOTES, "UTF-8") . "'><a href='" . DOMAIN . 'requisition/download/id/' . $id . "'>" . $data['requ_jd'] . "</a></span>";
             $getempId = $requi_model->getrequisitionDataonid($id);
             if (!empty($getempId['billable_empname'])) {
                 $getdatampname = $requi_model->getEmployeeNameonId($getempId['billable_empname']);
             }
             $aflag = $data['aflag'];
             if ($aflag == "approver") {
                 $aorder = 1;
             }
             //$aorder = $data['aorder'];
             if (!empty($data) && $data['req_status'] == 'Initiated') {
                 if ($loginuserGroup != MANAGEMENT_GROUP || $loginuserGroup == MANAGEMENT_GROUP || $loginuserGroup == '') {
                     if ($aflag == 'approver' && $data['appstatus' . $aorder] == 'Initiated') {
                         $data['onboard_date'] = sapp_Global::change_date($data['onboard_date'], 'view');
                         $business_units_list = $requi_model->getBusinessUnitsList();
                         $data['bunit_name'] = $business_units_list[$data['businessunit_id']];
                         $departments_list = $requi_model->getDepartmentList($data['businessunit_id']);
                         $data['dept_name'] = $departments_list[$data['department_id']];
                         $job_data = $requi_model->getJobTitleList();
                         if (isset($job_data[$data['jobtitle']])) {
                             $data['jtitle_name'] = $job_data[$data['jobtitle']];
                         } else {
                             $data['jtitle_name'] = 'Select Job Title';
                         }
                         //                            $pos_data = $requi_model->getPositionOptions($data['jobtitle']);
                         //                            $data['position_name'] = $pos_data[$data['position_id']];
                         $emptype_options = $requi_model->getStatusOptionsForRequi();
                         if (isset($emptype_options[$data['emp_type']])) {
                             $data['emptype_name'] = $emptype_options[$data['emp_type']];
                         } else {
                             $data['emptype_name'] = 'Select Employment Status';
                         }
                         $report_manager_data = $user_model->getUserDataById($data['reporting_id']);
                         $data['mngrname'] = $report_manager_data['userfullname'];
                         $form->req_status->addMultiOptions(array('0' => 'Select status', '2' => 'Approved', '3' => 'Rejected'));
                         $form->req_status->setRequired(true)->addErrorMessage('Please select the status.');
                         $form->req_status->addFilter('Int')->addValidator('NotEmpty', true, array('integer', 'zero'));
                         $elements = $form->getElements();
                         if (count($elements) > 0) {
                             foreach ($elements as $key => $element) {
                                 if ($key != 'req_status') {
                                     $element->setRequired(false);
                                 }
                             }
                         }
                         if ($data['approver1'] != '') {
                             $app1_opt = $user_model->getUserDataById($data['approver1']);
                             $data_m['approver1'] = $app1_opt['userfullname'];
                         }
                         if ($data['approver2'] != '') {
                             $app2_opt = $user_model->getUserDataById($data['approver2']);
                             $data_m['approver2'] = $app2_opt['userfullname'];
                         }
                     } else {
                         $edit_flag = 'no';
                         if (in_array('Approved', array($data['appstatus1'], $data['appstatus2'], $data['appstatus3']))) {
                             $edit_flag = 'yes';
                         }
                         if ($edit_flag == 'yes') {
                             $data['onboard_date'] = sapp_Global::change_date($data['onboard_date'], 'view');
                             $business_units_list = $requi_model->getBusinessUnitsList();
                             $data['bunit_name'] = $business_units_list[$data['businessunit_id']];
                             $departments_list = $requi_model->getDepartmentList($data['businessunit_id']);
                             $data['dept_name'] = $departments_list[$data['department_id']];
                             $job_data = $requi_model->getJobTitleList();
                             if (isset($job_data[$data['jobtitle']])) {
                                 $data['jtitle_name'] = $job_data[$data['jobtitle']];
                             } else {
                                 $data['jtitle_name'] = 'Select Job Title';
                             }
                             //                                $pos_data = $requi_model->getPositionOptions($data['jobtitle']);
                             //                                $data['position_name'] = $pos_data[$data['position_id']];
                             $emptype_options = $requi_model->getStatusOptionsForRequi();
                             if (isset($emptype_options[$data['emp_type']])) {
                                 $data['emptype_name'] = $emptype_options[$data['emp_type']];
                             } else {
                                 $data['emptype_name'] = 'Select Employment Status';
                             }
                             $report_manager_data = $user_model->getUserDataById($data['reporting_id']);
                             $data['mngrname'] = $report_manager_data['userfullname'];
                             $elements = $form->getElements();
                             if (count($elements) > 0) {
                                 foreach ($elements as $key => $element) {
                                     $element->setRequired(false);
                                 }
                             }
                             if ($data['appstatus1'] == 'Approved') {
                                 $edit_order = 1;
                                 $app1_opt = $user_model->getUserDataById($data['approver1']);
                                 $data_m['approver1'] = $app1_opt['userfullname'];
                                 $report_manager_options = $requi_model->getapprovers($data['reporting_id'], $data['department_id']);
                                 $form->setDefault('approver1', $data['approver1']);
                             }
                         } else {
                             #$form->setDefault('requ_jd', $data['requ_jd']);
                             $business_units_list = $requi_model->getBusinessUnitsList();
                             $form->business_unit->addMultiOptions(array('' => 'Select Business Unit') + $business_units_list);
                             $form->setDefault('business_unit', $data['businessunit_id']);
                             $departments_list = $requi_model->getDepartmentList($data['businessunit_id']);
                             $form->department->addMultiOptions(array('' => 'Select Department') + $departments_list);
                             $form->setDefault('department', $data['department_id']);
                             $job_data = $requi_model->getJobTitleList();
                             $form->jobtitle->addMultiOptions(array('' => 'Select Job Title') + $job_data);
                             $form->setDefault('jobtitle', $data['jobtitle']);
                             //                                $pos_data = $requi_model->getPositionOptions($data['jobtitle']);
                             //                                $form->position_id->addMultiOptions(array('' => 'Select Position') + $pos_data);
                             //                                $form->setDefault('position_id', $data['position_id']);
                             $emptype_options = $requi_model->getStatusOptionsForRequi();
                             $form->emp_type->addMultiOptions(array('' => 'Select Employment Status') + $emptype_options);
                             $form->technology->addMultiOptions(array('' => 'Select Technology') + $requi_model->getTechnologySkillIDName());
                             $form->setDefault('technology', $data['technology']);
                             $form->setDefault('reporting_id', $data['reporting_id']);
                             $form->billablefor->addMultiOptions(array('' => 'Select Billable Type', 'New' => 'New', 'Replacement' => 'Replacement', 'Backup' => 'Backup'));
                             $form->setDefault('billablefor', $getempId['billable_for']);
                             $form->setDefault('requ_jd', $getempId['upload_jd']);
                             $form->requ_jd->setRequired(false);
                             //$form->requisition_code->setValue($ipreporting_ids);
                             //$form->ipreporting_id->addMultiOptions(array('' => 'Select Technical Panel') + $ipreporting_idData);
                             //$form->ipreporting_id->setValue($data['requisition_code']);
                             //$form->ipreporting_id->setMultiOptions($ipreporting_ids);
                             $form->req_status->addMultiOptions(array('1' => 'Initiated'));
                             if ($loginuserGroup == HR_GROUP || $loginuserGroup == '' || $loginuserGroup == MANAGEMENT_GROUP) {
                                 if ($loginuserGroup == '') {
                                     $reportingManagerData = $requi_model->getReportingmanagers('', $loginUserId, '', $data['department_id'], 'requisition');
                                 } else {
                                     $reportingManagerData = $requi_model->getReportingmanagers('', '', '', $data['department_id'], 'requisition');
                                 }
                                 if ($loginuserGroup == HR_GROUP || $loginuserGroup == '' || $loginuserGroup == MANAGEMENT_GROUP) {
                                     if ($loginuserGroup == '') {
                                         $getEmployeelistonBunit = $requi_model->getEmployeelistonBunit('', $data['business_unit'], 'requisition');
                                     } else {
                                         $getEmployeelistonBunit = $requi_model->getEmployeelistonBunit('', $data['business_unit'], 'requisition');
                                     }
                                     //for hr,management
                                     $re_arr = array();
                                 }
                                 if (isset($_POST['business_unit']) && $_POST['business_unit'] != '') {
                                     $departments_list = $requi_model->getDepartmentList($_POST['business_unit']);
                                     $form->department->addMultiOptions(array('' => 'Select Department') + $departments_list);
                                 }
                                 if (isset($_POST['department']) && $_POST['department'] != '') {
                                     $reportingManagerData = $requi_model->getReportingmanagers('', $loginUserId, '', $_POST['department'], 'requisition');
                                 }
                                 $form->reporting_id->addMultiOptions(array('' => 'Select Reporting Manager') + $reportingManagerData);
                                 $form->setDefault('reporting_id', $data['reporting_id']);
                                 $form->setDefault('req_status', $data['req_status']);
                                 $form->req_status->setAttrib("disabled", "disabled");
                                 if ($loginuserGroup == HR_GROUP) {
                                     $departments_list = $requi_model->getDepartmentList($sess_vals->businessunit_id);
                                     $data_m['bunit_data']['id'] = $sess_vals->businessunit_id;
                                     $data_m['bunit_data']['name'] = $business_units_list[$sess_vals->businessunit_id];
                                     $form->department->addMultiOptions(array('' => 'Select Department') + $departments_list);
                                 }
                             } else {
                                 //for managers login
                                 $report_manager_options = $user_model->getUserDataById($data['reporting_id']);
                                 $departments_list = $requi_model->getDepartmentList($data['businessunit_id']);
                                 $data_m['manager_data']['id'] = $data['reporting_id'];
                                 $data_m['manager_data']['name'] = $report_manager_options['userfullname'];
                                 $data_m['bunit_data']['id'] = $data['businessunit_id'];
                                 $data_m['bunit_data']['name'] = $business_units_list[$data['businessunit_id']];
                                 $data_m['dept_data']['id'] = $data['department_id'];
                                 $data_m['dept_data']['name'] = $departments_list[$data['department_id']];
                                 $form->setDefault('reporting_id', $data['reporting_id']);
                                 $form->setDefault('req_status', $data['req_status']);
                                 $form->req_status->setAttrib("disabled", "disabled");
                             }
                             $hrexecutivesData = $requi_model->getHRExecutives();
                             //start of approvers options
                             $approver_opt = $requi_model->getapprovers($data['reporting_id'], $data['department_id']);
                             $app1_opt = array();
                             if (count($approver_opt) > 0 && count($_POST) == 0) {
                                 foreach ($approver_opt as $app1) {
                                     $approver1_opt[] = array('id' => $app1['id'], 'name' => ucwords($app1['name']), 'profileimg' => $app1['profileimg']);
                                 }
                             }
                             //end of approvers options
                             foreach ($data as $key => $val) {
                                 $data[$key] = htmlentities(addslashes($val), ENT_QUOTES, "UTF-8");
                             }
                             $data['onboard_date'] = sapp_Global::change_date($data['onboard_date'], 'view');
                             $form->populate($data);
                             if (isset($_POST['business_unit']) && $_POST['business_unit'] != '') {
                                 $departments_list = $requi_model->getDepartmentList($_POST['business_unit']);
                                 $form->department->clearMultiOptions();
                                 $form->department->addMultiOptions(array('' => 'Select Department') + $departments_list);
                             }
                             //                                if (isset($_POST['jobtitle']) && $_POST['jobtitle'] != '') {
                             //                                    $pos_data = $requi_model->getPositionOptions($_POST['jobtitle']);
                             //                                    $form->position_id->clearMultiOptions();
                             //                                    $form->position_id->addMultiOptions(array('' => 'Select Position') + $pos_data);
                             //                                }
                             if (isset($_POST['reporting_id']) && $_POST['reporting_id'] != '') {
                                 $app1_data = $requi_model->getapprovers($_POST['reporting_id'], $_POST['department']);
                                 $app1_opt = array();
                                 if (count($app1_data) > 0) {
                                     foreach ($app1_data as $app1) {
                                         $app1_opt[$app1['id']] = ucwords($app1['name']);
                                         $approver1_opt[] = array('id' => $app1['id'], 'name' => ucwords($app1['name']), 'profileimg' => $app1['profileimg']);
                                     }
                                     $form->reporting_id->setValue($_POST['reporting_id']);
                                 }
                             }
                         }
                     }
                     //end of else of aflag.
                     $this->view->loginuserGroup = $loginuserGroup;
                     $this->view->form = $form;
                     $this->view->data = $data;
                     $this->view->data_m = $data_m;
                     $this->view->aflag = $aflag;
                     $this->view->aorder = $aorder;
                     $this->view->edit_flag = $edit_flag;
                     $this->view->edit_order = $edit_order;
                     $this->view->reportingManagerData = $reportingManagerData;
                     $this->view->hrexecutivesData = $hrexecutivesData;
                     $this->view->approver1_opt = $approver1_opt;
                     $this->view->approver2_opt = $approver2_opt;
                     $this->view->ipreporting_idData = $ipreporting_idData;
                     $this->view->ipreporting_ids = $ipreporting_ids;
                     $this->view->technicalskills_all = $technicalskills_all;
                     $this->view->technicalskills_selected = $technicalskills_selected;
                     $this->view->nontechnicalskills_all = $nontechnicalskills_all;
                     $this->view->nontechnicalskills_selected = $nontechnicalskills_selected;
                     $this->view->getEmployeelistonBunit = $getEmployeelistonBunit;
                     $this->view->getempId = $getempId;
                     $this->view->getdatampname = $getdatampname;
                     if ($this->getRequest()->getPost()) {
                         $result = $this->save($form, $data);
                         $this->view->msgarray = $result;
                         $this->view->messages = $result;
                     }
                     $this->view->ermsg = '';
                 } else {
                     $this->view->nodata = 'nodata';
                 }
             } else {
                 $this->view->nodata = 'nodata';
             }
         } else {
             $this->view->nodata = 'nodata';
         }
         // To check whether to display Employment Status configuration link or not
         $employmentstatusmodel = new Default_Model_Employmentstatus();
         $activeEmploymentStatusArr = $employmentstatusmodel->getEmploymentStatuslist();
         $this->view->job_title_permission = $job_title_permission;
         $this->view->positions_permission = $positions_permission;
         $this->view->emp_status_permission = $emp_status_permission;
     } catch (Exception $e) {
         $this->view->nodata = 'nodata';
     }
 }
 public function addpopupAction()
 {
     $screenFlag = "";
     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');
     if ($this->getRequest()->getParam('screenflag')) {
         $screenFlag = $this->getRequest()->getParam('screenflag');
     }
     $boxid = $this->_getParam('boxid', null);
     $fromcontroller = $this->_getParam('fromcontroller', null);
     $msgarray = array();
     $controllername = 'employmentstatus';
     $employmentstatusform = new Default_Form_employmentstatus();
     $employmentstatusmodel = new Default_Model_Employmentstatus();
     $employmentstatusform->setAction(BASE_URL . 'employmentstatus/addpopup');
     $activeEmploymentStatusArr = $employmentstatusmodel->getEmploymentStatuslist();
     $newarr = array();
     $empstatusstr = '';
     if (!empty($activeEmploymentStatusArr)) {
         for ($i = 0; $i < sizeof($activeEmploymentStatusArr); $i++) {
             $newarr1[] = $activeEmploymentStatusArr[$i]['workcodename'];
         }
         if ($screenFlag == 'add') {
             array_push($newarr1, 8, 9, 10);
         }
         $empstatusstr = implode(",", $newarr1);
     }
     if ($empstatusstr != '') {
         $statusArr = $employmentstatusmodel->getStatuslist($empstatusstr);
     } else {
         $statusArr = $employmentstatusmodel->getCompleteStatuslist();
     }
     if (!empty($statusArr)) {
         $employmentstatusform->workcodename->addMultiOption('', 'Select Work Code');
         for ($i = 0; $i < sizeof($statusArr); $i++) {
             if ($fromcontroller == 'requisition') {
                 if (!in_array($statusArr[$i]['id'], array(5, 7, 8, 9, 10))) {
                     $employmentstatusform->workcodename->addMultiOption($statusArr[$i]['id'], utf8_encode($statusArr[$i]['employemnt_status']));
                 }
             } else {
                 $employmentstatusform->workcodename->addMultiOption($statusArr[$i]['id'], utf8_encode($statusArr[$i]['employemnt_status']));
             }
         }
     }
     $this->view->statusArr = $statusArr;
     $this->view->ermsg = '';
     if ($this->getRequest()->getPost()) {
         if ($employmentstatusform->isValid($this->_request->getPost())) {
             $id = $this->_request->getParam('id');
             $workcode = $this->_request->getParam('workcode');
             $workcodename = $this->_request->getParam('workcodename');
             $default_leaves = $this->_request->getParam('default_leaves');
             $description = $this->_request->getParam('description');
             $screenFlag = $this->getRequest()->getParam('screenflag');
             $date = new Zend_Date();
             $actionflag = '';
             $tableid = '';
             $data = array('workcode' => trim($workcode), 'workcodename' => trim($workcodename), '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 = $employmentstatusmodel->SaveorUpdateEmploymentStatusData($data, $where);
             $tableid = $Id;
             $menuID = EMPLOYMENTSTATUS;
             $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
             $this->view->eventact = 'added';
             $close = 'close';
             $this->view->popup = $close;
             if (isset($_POST['fromcontroller']) && $_POST['fromcontroller'] != '') {
                 $fromcontroller = $_POST['fromcontroller'];
             }
             if (isset($_POST['boxid']) && $_POST['boxid'] != '') {
                 $boxid = $_POST['boxid'];
             }
         } else {
             $messages = $employmentstatusform->getMessages();
             foreach ($messages as $key => $val) {
                 foreach ($val as $key2 => $val2) {
                     $msgarray[$key] = $val2;
                     break;
                 }
             }
             $this->view->msgarray = $msgarray;
         }
     }
     $opt = '';
     if ($fromcontroller == '') {
         if ($screenFlag == 'edit') {
             $empstatusData = $employmentstatusmodel->getempstatuslist();
         }
         if ($screenFlag == 'add') {
             $empstatusData = $employmentstatusmodel->getempstatusActivelist();
         }
         if (!empty($empstatusData)) {
             foreach ($empstatusData as $record) {
                 $opt .= sapp_Global::selectOptionBuilder($record['workcodename'], $record['statusname']);
             }
         }
     } else {
         if ($fromcontroller == 'requisition') {
             $requi_model = new Default_Model_Requisition();
             $empstatusData = $requi_model->getStatusOptionsForRequi();
             foreach ($empstatusData as $stat_id => $stat_name) {
                 $opt .= sapp_Global::selectOptionBuilder($stat_id, $stat_name);
             }
         }
     }
     $this->view->empstatusData = $opt;
     $this->view->screenFlag = $screenFlag;
     $this->view->controllername = $controllername;
     $this->view->form = $employmentstatusform;
     $this->view->ermsg = '';
     $this->view->boxid = $boxid;
     $this->view->fromcontroller = $fromcontroller;
 }
 public function appraisalinitialized($data)
 {
     $employmentstatusModel = new Default_Model_Employmentstatus();
     $category_model = new Default_Model_Appraisalcategory();
     $eligibility = '';
     $category = '';
     $budeptArr = sapp_Global::getbudeptname($data['id']);
     $empstatusArr = $employmentstatusModel->getEmploymentStatusName($data['eligibility']);
     if (!empty($empstatusArr)) {
         foreach ($empstatusArr as $status) {
             $eligibility .= $status['statusname'] . ',';
         }
         $eligibility = rtrim($eligibility, ',');
     }
     $categoryArr = $category_model->getCategoryNameByIds($data['category_id']);
     if (!empty($categoryArr)) {
         foreach ($categoryArr as $catid) {
             $category .= $catid['category_name'] . ',';
         }
         $category = rtrim($category, ',');
     }
     $data['process_status'] = '';
     if ($data['initialize_status'] == 1) {
         if ($data['enable_step'] == 1) {
             $data['process_status'] = 'Enabled to Managers';
         }
         if ($data['enable_step'] == 2) {
             $data['process_status'] = 'Enabled to Employees';
         }
     } else {
         if ($data['initialize_status'] == 2) {
             $data['process_status'] = 'Initialize Later';
         } else {
             $data['process_status'] = 'In progress';
         }
     }
     $this->view->ermsg = '';
     $this->view->eligibility = $eligibility;
     $this->view->category = $category;
     $this->view->budeptArr = $budeptArr;
     $this->view->data = $data;
 }