/**
  * 
  * 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');
     }
 }
Esempio n. 2
0
 public function requisitionstatusreportAction()
 {
     try {
         $norec_arr = array();
         $form = new Default_Form_Requisitionsstatusreport();
         $requi_model = new Default_Model_Requisition();
         $employmentstatusModel = new Default_Model_Employmentstatus();
         $job_data = $requi_model->getJobTitleList();
         if (count($job_data) == 0) {
             $norec_arr['jobtitle'] = "Job titles are not configured yet.";
         }
         $form->jobtitle->addMultiOptions(array('' => 'Select Job Title') + $job_data);
         // Requisiton's Raised in limit from  past 10 years to next two years
         $raised_in_years1 = range(date('Y', strtotime('-10 years')), date('Y', strtotime('+2 years')));
         $raised_in_years2 = array_combine($raised_in_years1, $raised_in_years1);
         $form->createdon->addMultiOptions(array('' => 'Select Requisition Year'));
         $form->createdon->addMultiOptions($raised_in_years2);
         $columns_array = array('requisition_code' => 'Requisition Code', 'job_title' => 'Job title', 'req_status' => 'Requisition Status', 'created_by' => 'Raised By', 'reporting_manager_name' => 'Reporting Manager', 'approver1' => 'Approver -1', 'appstatus1' => 'Status', 'req_no_positions' => 'No.of positions', 'selected_members' => 'Filled positions', 'created_on' => 'Raised On', 'onboard_date' => 'Due Date');
         $mandatory_array = array('requisition_code' => 'Requisition Code', 'job_title' => 'Job title', 'req_status' => 'Requisition Status', 'created_by' => 'Raised By', 'reporting_manager_name' => 'Reporting Manager', 'approver1' => 'Approver -1', 'appstatus1' => 'Status', 'req_no_positions' => 'No.of positions', 'selected_members' => 'Filled positions', 'created_on' => 'Raised On', 'onboard_date' => 'Due Date');
         $this->view->columns_array = $columns_array;
         $this->view->form = $form;
         $this->view->messages = $norec_arr;
     } catch (Exception $e) {
         exit($e->getMessage());
     }
 }
 public function editAction()
 {
     $id = $this->getRequest()->getParam('id');
     $data = array();
     $jobtitle = '';
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $form = new Default_Form_Requisition();
     $requi_model = new Default_Model_Requisition();
     $user_model = new Default_Model_Usermanagement();
     $jobtitleModel = new Default_Model_Jobtitles();
     $form->setAttrib('action', BASE_URL . 'approvedrequisitions/edit/id/' . $id);
     $form->submit->setLabel('Update');
     $elements = $form->getElements();
     if (count($elements) > 0) {
         foreach ($elements as $key => $element) {
             if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments" && $key != "submit" && $key != 'req_status' && $key != 'onboard_date') {
                 $form->removeElement($key);
             }
         }
     }
     try {
         if ($id > 0 && is_numeric($id)) {
             $data = $requi_model->getRequisitionDataById($id);
             if (count($data) > 0 && $data['req_status'] != 'Initiated' && $data['req_status'] != 'Rejected') {
                 $data['jobtitlename'] = '';
                 $business_units_list = $requi_model->getBusinessUnitsList($data['businessunit_id']);
                 $data['businessunit_name'] = $business_units_list['unitname'];
                 $departments_list = $requi_model->getDepartmentList($data['businessunit_id'], $data['department_id']);
                 $data['dept_name'] = $departments_list['deptname'];
                 $job_data = $requi_model->getJobTitleList($data['jobtitle']);
                 $data['titlename'] = $job_data['jobtitlename'];
                 $pos_data = $requi_model->getPositionOptions($data['jobtitle'], $data['position_id']);
                 $data['posname'] = $pos_data['positionname'];
                 $emptype_options = $requi_model->getEmpStatusOptions($data['emp_type']);
                 $data['empttype'] = $emptype_options['employemnt_status'];
                 $report_manager_options = $user_model->getUserDataById($data['reporting_id']);
                 $data['mngrname'] = $report_manager_options['userfullname'];
                 $raisedby = $requi_model->getrequisitioncreatername($data['createdby']);
                 $data['raisedby'] = $raisedby['userfullname'];
                 $app1_data = $user_model->getUserDataById($data['approver1']);
                 $data['app1_name'] = $app1_data['userfullname'];
                 if ($data['approver2'] != '') {
                     $app2_data = $user_model->getUserDataById($data['approver2']);
                     $data['app2_name'] = $app2_data['userfullname'];
                 } else {
                     $data['app2_name'] = 'No Approver';
                 }
                 if ($data['approver3'] != '') {
                     $app3_data = $user_model->getUserDataById($data['approver3']);
                     $data['app3_name'] = $app3_data['userfullname'];
                 } else {
                     $data['app3_name'] = 'No Approver';
                 }
                 $jobttlArr = $jobtitleModel->getsingleJobTitleData($data['jobtitle']);
                 if (!empty($jobttlArr) && $jobttlArr != 'norows') {
                     $jobtitle = $jobttlArr[0]['jobtitlename'];
                     $data['jobtitlename'] = $jobttlArr[0]['jobtitlename'];
                 }
                 foreach ($data as $key => $val) {
                     $data[$key] = htmlentities($val, ENT_QUOTES, "UTF-8");
                 }
                 $onboard_date_org = $data['onboard_date'];
                 $data['onboard_date'] = sapp_Global::change_date($data['onboard_date'], 'view');
                 if ($data['req_status'] == 'Approved') {
                     $form->req_status->addMultiOptions(array('Approved' => 'Approved', 'Closed' => 'Closed', 'On hold' => 'On hold', 'Complete' => 'Complete'));
                 } else {
                     if ($data['req_status'] == 'Complete') {
                         $form->req_status->addMultiOptions(array('Complete' => 'Complete'));
                         $form->req_status->setAttrib('disabled', 'disabled');
                         $form->removeElement('submit');
                     } else {
                         $form->req_status->addMultiOptions(array('' => 'Select status', 'Closed' => 'Closed', 'On hold' => 'On hold', 'Complete' => 'Complete', 'In process' => 'In process'));
                     }
                 }
                 $form->req_status->setRequired(true);
                 $form->req_status->addValidator('NotEmpty', false, array('messages' => 'Please select option.'));
                 $form->populate($data);
                 $form->setDefault('req_status', $data['req_status']);
                 $this->view->data = $data;
                 $this->view->loginuserGroup = $loginuserGroup;
                 $this->view->form = $form;
                 $this->view->id = $id;
                 $this->view->edit_duedate = 'no';
                 if ($onboard_date_org < date('Y-m-d') && ($loginuserGroup == HR_GROUP || $loginuserGroup == MANAGEMENT_GROUP || $loginuserGroup == '')) {
                     $this->view->edit_duedate = 'yes';
                 } else {
                     $form->removeElement('onboard_date');
                 }
                 $sort = $this->_getParam('sort') != '' ? $this->_getParam('sort') : 'DESC';
                 $by = $this->_getParam('by') != '' ? $this->_getParam('by') : 'c.createddate';
                 $perPage = $this->_getParam('per_page', 10);
                 $pageNo = $this->_getParam('page', 1);
                 $searchQuery = '';
                 $searchArray = array();
                 $tablecontent = '';
                 /** search from grid - START **/
                 $searchData = $this->_getParam('searchData');
                 if ($searchData != '' && $searchData != 'undefined') {
                     $searchValues = json_decode($searchData);
                     if (count($searchValues) > 0) {
                         foreach ($searchValues as $key => $val) {
                             $searchQuery .= " " . $key . " like '%" . $val . "%' AND ";
                             $searchArray[$key] = $val;
                         }
                         $searchQuery = rtrim($searchQuery, " AND");
                     }
                 }
                 /** search from grid - END **/
                 $objName = 'apprreqcandidates';
                 $tableFields = array('action' => 'Action', 'candidate_name' => 'Candidate Name', 'cand_status' => 'Candidate Status');
                 $candidate_model = new Default_Model_Candidatedetails();
                 $tablecontent = $candidate_model->getCandidatesData_requisition($sort, $by, $pageNo, $perPage, $searchQuery, $id);
                 $cand_status_opt = array('' => 'All', 'Shortlisted' => 'Shortlisted', 'Selected' => 'Selected', 'Rejected' => 'Rejected', 'On hold' => 'On hold', 'Disqualified' => 'Disqualified', 'Scheduled' => 'Scheduled', 'Not Scheduled' => 'Not Scheduled', 'Recruited' => 'Recruited', 'Requisition Closed/Completed' => 'Requisition Closed/Completed');
                 $dataTmp = array('sort' => $sort, 'by' => $by, 'pageNo' => $pageNo, 'perPage' => $perPage, 'tablecontent' => $tablecontent, 'objectname' => $objName, 'extra' => array(), 'tableheader' => $tableFields, 'jsGridFnName' => 'getAjaxgridData', 'jsFillFnName' => '', 'formgrid' => 'true', 'searchArray' => $searchArray, 'menuName' => 'Candidate details', 'call' => '', 'search_filters' => array('cand_status' => array('type' => 'select', 'filter_data' => $cand_status_opt)));
                 array_push($data, $dataTmp);
                 $this->view->dataArray = $dataTmp;
                 if ($this->getRequest()->getPost()) {
                     $result = $this->save($form, $data);
                     $this->view->msgarray = $result;
                     $this->view->messages = $result;
                 }
                 $this->view->nodata = '';
             } else {
                 $this->view->nodata = 'nodata';
             }
         } else {
             $this->view->nodata = 'nodata';
         }
     } 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();
     $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';
     }
 }