public function getdepartmentsAction() { $ajaxContext = $this->_helper->getHelper('AjaxContext'); $ajaxContext->addActionContext('getdepartments', 'html')->initContext(); $businessunit_id = $this->_request->getParam('business_id'); $con = $this->_request->getParam('con'); $employeeform = new Default_Form_employee(); $leavemanagementform = new Default_Form_leavemanagement(); $flag = ''; $departmentsmodel = new Default_Model_Departments(); $appraisalconfigmodel = new Default_Model_Appraisalconfig(); if ($con == 'leavemanagement') { $leavemanagementmodel = new Default_Model_Leavemanagement(); $departmentidsArr = $leavemanagementmodel->getActiveDepartmentIds(); $depatrmentidstr = ''; $newarr = array(); if (!empty($departmentidsArr)) { $where = ''; for ($i = 0; $i < sizeof($departmentidsArr); $i++) { $newarr1[] = array_push($newarr, $departmentidsArr[$i]['deptid']); } $depatrmentidstr = implode(",", $newarr); foreach ($newarr as $deparr) { $where .= " id!= {$deparr} AND "; } $where = trim($where, " AND"); $querystring = "Select d.id,d.deptname from main_departments as d where d.unitid={$businessunit_id} and d.isactive=1 and {$where} "; $querystring .= " order by d.deptname"; $uniquedepartmentids = $departmentsmodel->getUniqueDepartments($querystring); if (empty($uniquedepartmentids)) { $flag = 'true'; } $this->view->uniquedepartmentids = $uniquedepartmentids; } else { $departmentlistArr = $departmentsmodel->getDepartmentList($businessunit_id); if (empty($departmentlistArr)) { $flag = 'true'; } $this->view->departmentlistArr = $departmentlistArr; } } else { if ($con == 'appraisal_config') { $departmentlistArr = $appraisalconfigmodel->getExistDepartments($businessunit_id); $dept_arr = array(); foreach ($departmentlistArr as $dept) { $deptid = $dept['department_id']; array_push($dept_arr, $deptid); } $dept_arr = array_filter($dept_arr); $dept_arr = array_unique($dept_arr); $dept_list = implode(',', $dept_arr); $departmentlistArr = $appraisalconfigmodel->getDepartments($businessunit_id, $dept_list); if (empty($departmentlistArr)) { $flag = 'true'; } $this->view->departmentlistArr = $departmentlistArr; } else { $departmentlistArr = $departmentsmodel->getDepartmentList($businessunit_id); if (empty($departmentlistArr)) { $flag = 'true'; } $this->view->departmentlistArr = $departmentlistArr; } } $this->view->employeeform = $employeeform; $this->view->leavemanagementform = $leavemanagementform; $this->view->flag = $flag; if ($con != '') { $this->view->con = $con; } }
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"; } }
public function getdepartmentsAction() { $ajaxContext = $this->_helper->getHelper('AjaxContext'); $ajaxContext->addActionContext('getdepartments', 'html')->initContext(); $businessunit_id = $this->_request->getParam('buss_id'); $positionsform = new Default_Form_positions(); $deptModel = new Default_Model_Departments(); $deptmodeldata = $deptModel->getDepartmentList($businessunit_id); $this->view->positionsform = $positionsform; $this->view->deptmodeldata = $deptmodeldata; }
public function getuniqueDepartment($businessunit_id) { $leavemanagementmodel = new Default_Model_Leavemanagement(); $departmentidsArr = $leavemanagementmodel->getActiveDepartmentIds(); $departmentsmodel = new Default_Model_Departments(); $depatrmentidstr = ''; $newarr = array(); if (!empty($departmentidsArr)) { $where = ''; for ($i = 0; $i < sizeof($departmentidsArr); $i++) { $newarr1[] = array_push($newarr, $departmentidsArr[$i]['deptid']); } $depatrmentidstr = implode(",", $newarr); foreach ($newarr as $deparr) { $where .= " id!= {$deparr} AND "; } $where = trim($where, " AND"); $querystring = "Select d.id,d.deptname from main_departments as d where d.unitid={$businessunit_id} and d.isactive=1 and {$where} "; $uniquedepartmentids = $departmentsmodel->getUniqueDepartments($querystring); return $uniquedepartmentids; } else { $departmentlistArr = $departmentsmodel->getDepartmentList($businessunit_id); return $departmentlistArr; } }
public function save($appraisalconfigform) { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $appraisalconfigmodel = new Default_Model_Appraisalconfig(); $departmentsmodel = new Default_Model_Departments(); $businessunitsmodel = new Default_Model_Businessunits(); $msgarray = array(); $resultArr = array(); $arrData = array(); $prevBusinessunit = ''; $errorflag = "true"; $id = $this->_request->getParam('id'); $businessunit_id = $this->_request->getParam('businessunit_id'); $performance_app_flag = $this->_request->getParam('performance_app_flag'); $department_id = $this->_request->getParam('department_id'); $appraisal_mode = $this->_request->getParam('appraisal_mode'); $approval_selection = $this->_request->getParam('approval_selection'); $appraisal_ratings = $this->_request->getParam('appraisal_ratings'); // Validation to check duplicate combinations $arrData = array("business_unit_id" => $businessunit_id, "department_id" => $department_id, "id" => $id); if ($appraisalconfigmodel->combinationExists($arrData)) { $msgarray['businessunit_id'] = 'Business unit or department configuration already exists.'; $errorflag = "false"; } /** Start * Validating selection of department if implementaion is department wise */ if ($performance_app_flag == 0) { if ($department_id == '') { $msgarray['department_id'] = 'Please select department.'; $errorflag = "false"; } } /** End validating selection of department */ /** Start Validating unique service desk department */ if ($businessunit_id != '' && $id == '') { $appraisalconigfArr = $appraisalconfigmodel->checkuniqueAppraisalConfigData($businessunit_id, $performance_app_flag, $department_id); if (!empty($appraisalconigfArr)) { if ($appraisalconigfArr[0]['count'] > 0) { $msgarray['department_id'] = 'Please select a different department.'; $errorflag = "false"; } } } /** End * Validating uniques department */ $db = Zend_Db_Table::getDefaultAdapter(); $db->beginTransaction(); if ($appraisalconfigform->isValid($this->_request->getPost()) && $errorflag == 'true') { try { $menumodel = new Default_Model_Menu(); $actionflag = ''; $tableid = ''; $data = array('businessunit_id' => $businessunit_id, 'department_id' => $department_id != '' ? $department_id : NULL, 'performance_app_flag' => $performance_app_flag, 'appraisal_mode' => $appraisal_mode, 'appraisal_ratings' => $appraisal_ratings, 'module_flag' => 1, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); if ($id != '') { /* for Update record */ $where = array('id=?' => $id); $actionflag = 2; } else { /* for Insert new record */ $data['createdby'] = $loginUserId; $data['createddate'] = gmdate("Y-m-d H:i:s"); $data['isactive'] = 1; $where = ''; $actionflag = 1; } $Id = $appraisalconfigmodel->SaveorUpdateAppraisalConfigData($data, $where); if ($Id == 'update') { $tableid = $id; $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Appraisal settings updated successfully")); } else { $tableid = $Id; $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Appraisal settings added successfully")); } $menuidArr = $menumodel->getMenuObjID('/appraisalconfig'); $menuID = $menuidArr[0]['id']; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid); /** Start * Sending Mails to employees */ /* if($performance_app_flag == 0) $employeeDetailsArr = $appraisalconfigmodel->getUserDetailsByID($businessunit_id,$department_id); else $employeeDetailsArr = $appraisalconfigmodel->getUserDetailsByID($businessunit_id,''); $msg_add_update = ($Id == 'update') ? "updated" : "added" ; //Sending mail to Super admin $options['subject'] = APPLICATION_NAME.': Performance Appraisal Settings '.ucfirst($msg_add_update); $options['header'] = 'Performance Appraisal Configuration'; $options['toEmail'] = SUPERADMIN_EMAIL; $options['toName'] = 'Super Admin'; $options['message'] = 'Dear Super Admin, performance appraisal configuration '.$msg_add_update; // $mail_id = sapp_Global::_sendEmail($options); //sending mail to others if(!empty($employeeDetailsArr)) { foreach($employeeDetailsArr as $emp) { $options['subject'] = APPLICATION_NAME.': Performance Appraisal Settings Added.'; $options['header'] = 'Performance Appraisal Configuration'; $options['toEmail'] = $emp['emailaddress']; $options['toName'] = $emp['userfullname']; $options['message'] = 'Dear '.$emp['userfullname'].', performance appraisal configuration '.$msg_add_update; // $mail_id = sapp_Global::_sendEmail($options); } } /** * End */ $db->commit(); $this->_redirect('appraisalconfig'); throw new Exception("Some error message"); } catch (Exception $e) { $db->rollBack(); echo $e->getMessage(); echo $e->getTraceAsString(); return $msgarray; } } else { $messages = $appraisalconfigform->getMessages(); foreach ($messages as $key => $val) { foreach ($val as $key2 => $val2) { $msgarray[$key] = $val2; break; } } if (isset($businessunit_id) && $businessunit_id != '') { if ($performance_app_flag == 0) { $departmentlistArr = $departmentsmodel->getDepartmentList($businessunit_id); if (!empty($departmentlistArr)) { foreach ($departmentlistArr as $departmentlist) { $appraisalconfigform->department_id->addMultiOption($departmentlist['id'], utf8_encode($departmentlist['deptname'])); } } } if (isset($department_id) && $department_id != 0 && $department_id != '') { $appraisalconfigform->setDefault('department_id', $department_id); } } return $msgarray; } }
public function updateempdetails($employeeform) { $emproleStr = ''; $roleArr = array(); $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $usersModel = new Default_Model_Usermanagement(); $employeeModal = new Default_Model_Employee(); $businessunit_id = $this->_request->getParam('businessunit_id', null); $department_id = $this->_request->getParam('department_id', null); $reporting_manager = $this->_request->getParam('reporting_manager', null); $jobtitle_id = $this->_request->getParam('jobtitle_id', null); $position_id = $this->_request->getParam('position_id', null); $user_id = $this->_getParam('user_id', null); $prefix_id = $this->_getParam('prefix_id', null); $extension_number = $this->_getParam('extension_number', null); if ($employeeform->isValid($this->_request->getPost())) { $id = $this->_request->getParam('id'); $emp_status_id = $this->_request->getParam('emp_status_id', null); $date_of_joining = $this->_request->getParam('date_of_joining', null); $date_of_joining = sapp_Global::change_date($date_of_joining, 'database'); $date_of_leaving = $this->_request->getParam('date_of_leaving', null); $date_of_leaving = sapp_Global::change_date($date_of_leaving, 'database'); $years_exp = $this->_request->getParam('years_exp'); //FOR USER table $employeeId = $this->_getParam('employeeId', null); $modeofentry = $this->_getParam('modeofentry', null); $hid_modeofentry = $this->_getParam('hid_modeofentry', null); $other_modeofentry = $this->_getParam('other_modeofentry', null); $userfullname = $this->_getParam('userfullname', null); $candidatereferredby = $this->_getParam('candidatereferredby', null); $rccandidatename = $this->_getParam('rccandidatename', null); $emprole = $this->_getParam('emprole', null); //roleid_group_id if ($emprole != "") { $roleArr = explode('_', $emprole); if (!empty($roleArr)) { $emproleStr = $roleArr[0]; } } $emailaddress = $this->_getParam('emailaddress', null); $tmp_name = $this->_request->getParam('tmp_emp_name', null); $act_inact = $this->_request->getParam("act_inact", null); //end of user table $date = new Zend_Date(); $menumodel = new Default_Model_Menu(); $empstatusarray = array(8, 9, 10); $actionflag = ''; $tableid = ''; if ($modeofentry == 'Direct' || $hid_modeofentry == 'Direct') { $candidate_key = 'userfullname'; $candidate_value = $userfullname; $emp_name = $userfullname; $candidate_flag = 'no'; } else { $candidate_key = 'rccandidatename'; $candidate_value = $rccandidatename; $emp_name = $tmp_name; $candidate_flag = 'yes'; } $trDb = Zend_Db_Table::getDefaultAdapter(); // starting transaction $trDb->beginTransaction(); try { $emppassword = sapp_Global::generatePassword(); $user_data = array('emprole' => $emproleStr, $candidate_key => $candidate_value, 'emailaddress' => $emailaddress, 'modifiedby' => $loginUserId, 'modifieddate' => Zend_Registry::get('currentdate'), 'emppassword' => md5($emppassword), 'employeeId' => $employeeId, 'modeofentry' => $id == '' ? $modeofentry : "", 'selecteddate' => $date_of_joining, 'candidatereferredby' => $candidatereferredby, 'userstatus' => 'old', 'other_modeofentry' => $other_modeofentry); if ($id != '') { $where = array('user_id=?' => $user_id); $actionflag = 2; $user_where = "id = " . $user_id; unset($user_data['candidatereferredby']); unset($user_data['userstatus']); unset($user_data['emppassword']); unset($user_data['employeeId']); unset($user_data['modeofentry']); unset($user_data['other_modeofentry']); } else { $data['createdby'] = $loginUserId; $data['createddate'] = gmdate("Y-m-d H:i:s"); $data['isactive'] = 1; $user_data['createdby'] = $loginUserId; $user_data['createddate'] = gmdate("Y-m-d H:i:s"); $user_data['isactive'] = 1; if ($modeofentry != 'Direct') { $user_data['userfullname'] = $emp_name; } $where = ''; $actionflag = 1; $user_where = ''; } $user_status = $usersModel->SaveorUpdateUserData($user_data, $user_where); if ($id == '') { $user_id = $user_status; } $data = array('user_id' => $user_id, 'reporting_manager' => $reporting_manager, 'emp_status_id' => $emp_status_id, 'businessunit_id' => $businessunit_id, 'department_id' => $department_id, 'jobtitle_id' => $jobtitle_id, 'position_id' => $position_id, 'prefix_id' => $prefix_id, 'extension_number' => $extension_number, 'date_of_joining' => $date_of_joining, 'date_of_leaving' => $date_of_leaving != '' ? $date_of_leaving : NULL, 'years_exp' => $years_exp == '' ? null : $years_exp, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); $Id = $employeeModal->SaveorUpdateEmployeeData($data, $where); $statuswhere = array('id=?' => $user_id); if (in_array($emp_status_id, $empstatusarray)) { $isactivestatus = ''; if ($emp_status_id == 8) { $isactivestatus = 2; } else { if ($emp_status_id == 9) { $isactivestatus = 3; } else { if ($emp_status_id == 10) { $isactivestatus = 4; } } } $statusdata = array('isactive' => $isactivestatus); $empstatusId = $usersModel->SaveorUpdateUserData($statusdata, $statuswhere); } else { $statusdata = array('isactive' => 1); $empstatusId = $usersModel->SaveorUpdateUserData($statusdata, $statuswhere); } if ($Id == 'update') { $tableid = $id; $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Employee details updated successfully.")); } else { //start of mailing $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); $view = $this->getHelper('ViewRenderer')->view; $this->view->emp_name = $emp_name; $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 of mailing $tableid = $Id; $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Employee details added successfully.")); } $menuidArr = $menumodel->getMenuObjID('/employee'); $menuID = $menuidArr[0]['id']; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid); $menuidArr = $menumodel->getMenuObjID('/usermanagement'); $menuID_user = $menuidArr[0]['id']; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $user_id); if ($act_inact == 1) { if ($user_data['isactive'] == 1) { $act_str = array("Activated" => Zend_Registry::get('currentdate')); } else { $act_str = array("Inactivated" => Zend_Registry::get('currentdate')); } $result = sapp_Global::logManager($menuID_user, 4, $loginUserId, $user_id, '', $act_str); } $trDb->commit(); $this->_redirect('employee/edit/id/' . $user_id); } catch (Exception $e) { $trDb->rollBack(); $msgarray['employeeId'] = "Something went wrong,please try again later."; return $msgarray; } } else { $messages = $employeeform->getMessages(); foreach ($messages as $key => $val) { foreach ($val as $key2 => $val2) { $msgarray[$key] = $val2; break; } } $usersModel = new Default_Model_Users(); if (isset($businessunit_id) && $businessunit_id != 0 && $businessunit_id != '') { $departmentsmodel = new Default_Model_Departments(); $departmentlistArr = $departmentsmodel->getDepartmentList($businessunit_id); $employeeform->department_id->clearMultiOptions(); $employeeform->reporting_manager->clearMultiOptions(); $employeeform->department_id->addMultiOption('', 'Select Department'); foreach ($departmentlistArr as $departmentlistresult) { $employeeform->department_id->addMultiOption($departmentlistresult['id'], utf8_encode($departmentlistresult['deptname'])); } if (isset($department_id) && $department_id != 0 && $department_id != '') { $employeeform->setDefault('department_id', $department_id); } } if (isset($department_id) && $department_id != 0 && $department_id != '') { $reportingManagerArr = $usersModel->getReportingManagerList($department_id, $user_id); $employeeform->reporting_manager->addMultiOption('', 'Select Reporting Manager'); foreach ($reportingManagerArr as $reportingManagerresult) { $employeeform->reporting_manager->addMultiOption($reportingManagerresult['id'], utf8_encode($reportingManagerresult['userfullname'])); } if (isset($reporting_manager) && $reporting_manager != 0 && $reporting_manager != '') { $employeeform->setDefault('reporting_manager', $reporting_manager); } } if (isset($jobtitle_id) && $jobtitle_id != 0 && $jobtitle_id != '') { $positionsmodel = new Default_Model_Positions(); $positionlistArr = $positionsmodel->getPositionList($jobtitle_id); $employeeform->position_id->clearMultiOptions(); $employeeform->position_id->addMultiOption('', 'Select Position'); foreach ($positionlistArr as $positionlistRes) { $employeeform->position_id->addMultiOption($positionlistRes['id'], utf8_encode($positionlistRes['positionname'])); } if (isset($position_id) && $position_id != 0 && $position_id != '') { $employeeform->setDefault('position_id', $position_id); } } return $msgarray; } }
public function save($appraisalconfigform) { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $appraisalconfigmodel = new Default_Model_Appraisalconfig(); $departmentsmodel = new Default_Model_Departments(); $businessunitsmodel = new Default_Model_Businessunits(); $msgarray = array(); $resultArr = array(); //$empstring = ''; //$prevBusinessunit = ''; $errorflag = "true"; $id = $this->_request->getParam('id'); $businessunit_id = $this->_request->getParam('businessunit_id'); $performance_app_flag = $this->_request->getParam('performance_app_flag'); $department_id = $this->_request->getParam('department_id'); $appraisal_mode = $this->_request->getParam('appraisal_mode'); $approval_selection = $this->_request->getParam('approval_selection'); $appraisal_ratings = $this->_request->getParam('appraisal_ratings'); /** Start * Validating selection of department if implementaion is department wise */ if ($performance_app_flag == 0) { if ($department_id == '') { $msgarray['department_id'] = 'Please select department.'; $errorflag = "false"; } } /** End validating selection of department */ /** * End Approver level selection */ /** Start Validating unique service desk department */ if ($businessunit_id != '' && $id == '') { $appraisalconigfArr = $appraisalconfigmodel->checkuniqueAppraisalConfigData($businessunit_id, $performance_app_flag, $department_id); if (!empty($appraisalconigfArr)) { if ($appraisalconigfArr[0]['count'] > 0) { $msgarray['department_id'] = 'Please select a different department.'; $errorflag = "false"; } } } /** End * Validating uniques service desk department */ /** * Validating if pending requests are there when changing the implementation */ if ($businessunit_id != '') { $implementationdata = $businessunitsmodel->getSingleUnitData($businessunit_id); //echo "<pre>"; print_r($implementationdata);echo "</pre>"; die; if (!empty($implementationdata)) { $prevBusinessunit = $implementationdata['service_desk_flag']; } if ($performance_app_flag != '') { if ($prevBusinessunit != $performance_app_flag) { $pendingRequestdata = $appraisalconfigmodel->getPendingAppraisalConfigData($businessunit_id); if (!empty($pendingRequestdata)) { if ($pendingRequestdata[0]['count'] > 0) { $msgarray['performance_app_flag'] = 'Applicability cannot be changed as requests are in pending state.'; $errorflag = "false"; } } } } } /** * End validating pending request checking */ $db = Zend_Db_Table::getDefaultAdapter(); $db->beginTransaction(); if ($appraisalconfigform->isValid($this->_request->getPost()) && $errorflag == 'true') { try { $menumodel = new Default_Model_Menu(); $actionflag = ''; $tableid = ''; $data = array('businessunit_id' => $businessunit_id, 'department_id' => $department_id != '' ? $department_id : NULL, 'performance_app_flag' => $performance_app_flag, 'appraisal_mode' => $appraisal_mode, 'approval_selection' => $approval_selection, 'appraisal_ratings' => $appraisal_ratings, 'module_flag' => 1, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); if ($id != '') { /* for Update record */ $where = array('id=?' => $id); $actionflag = 2; } else { /* for Insert new record */ $data['createdby'] = $loginUserId; $data['createddate'] = gmdate("Y-m-d H:i:s"); $data['isactive'] = 1; $where = ''; $actionflag = 1; } $Id = $appraisalconfigmodel->SaveorUpdateAppraisalConfigData($data, $where); if ($Id == 'update') { $tableid = $id; $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Configuration updated successfully.")); } else { $tableid = $Id; $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Configuration added successfully.")); } $menuidArr = $menumodel->getMenuObjID('/appraisalconfig'); $menuID = $menuidArr[0]['id']; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid); $db->commit(); $this->_redirect('appraisalconfig'); //throw new Exception("Some error message"); } catch (Exception $e) { $db->rollBack(); //echo $e->getMessage(); // echo $e->getTraceAsString(); //$msgarray['service_desk_id'] = "Something went wrong, please try again."; return $msgarray; } } else { $messages = $appraisalconfigform->getMessages(); foreach ($messages as $key => $val) { foreach ($val as $key2 => $val2) { $msgarray[$key] = $val2; break; } } if (isset($businessunit_id) && $businessunit_id != '') { if ($performance_app_flag == 0) { $departmentlistArr = $departmentsmodel->getDepartmentList($businessunit_id); if (!empty($departmentlistArr)) { //echo "<pre>";print_r($departmentlistArr); echo "</pre>"; foreach ($departmentlistArr as $departmentlist) { $appraisalconfigform->department_id->addMultiOption($departmentlist['id'], utf8_encode($departmentlist['deptname'])); } } } // $department_id = $departmentlist['deptname']; //echo "dept:".$department_id; die; //echo $performance_app_flag; die; if (isset($department_id) && $department_id != 0 && $department_id != '') { $appraisalconfigform->setDefault('department_id', $department_id); } } //echo "<pre>";print_r($msgarray);echo "</pre>"; die; return $msgarray; } }
public function save($appraisalconfigform) { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; $loginuserRole = $auth->getStorage()->read()->emprole; $loginUserEmpId = $auth->getStorage()->read()->employeeId; $loginUserEmail = $auth->getStorage()->read()->emailaddress; $loginUsername = $auth->getStorage()->read()->userfullname; } $appraisalconfigmodel = new Default_Model_Appraisalconfig(); $departmentsmodel = new Default_Model_Departments(); $businessunitsmodel = new Default_Model_Businessunits(); $msgarray = array(); $resultArr = array(); $arrData = array(); $prevBusinessunit = ''; $errorflag = "true"; $id = $this->_request->getParam('id'); $businessunit_id = $this->_request->getParam('businessunit_id'); $performance_app_flag = $this->_request->getParam('performance_app_flag'); $department_id = $this->_request->getParam('department_id'); $appraisal_mode = $this->_request->getParam('appraisal_mode'); $approval_selection = $this->_request->getParam('approval_selection'); $appraisal_ratings = $this->_request->getParam('appraisal_ratings'); // Validation to check duplicate combinations $arrData = array("business_unit_id" => $businessunit_id, "department_id" => $department_id, "id" => $id); if ($appraisalconfigmodel->combinationExists($arrData)) { $msgarray['businessunit_id'] = 'Business unit or department configuration already exists.'; $errorflag = "false"; } /** Start * Validating selection of department if implementaion is department wise */ if ($performance_app_flag == 0) { if ($department_id == '') { $msgarray['department_id'] = 'Please select department.'; $errorflag = "false"; } } /** End validating selection of department */ /** Start Validating unique service desk department */ if ($businessunit_id != '' && $id == '') { $appraisalconigfArr = $appraisalconfigmodel->checkuniqueAppraisalConfigData($businessunit_id, $performance_app_flag, $department_id); if (!empty($appraisalconigfArr)) { if ($appraisalconigfArr[0]['count'] > 0) { $msgarray['department_id'] = 'Please select a different department.'; $errorflag = "false"; } } } /** End * Validating uniques department */ $db = Zend_Db_Table::getDefaultAdapter(); $db->beginTransaction(); if ($appraisalconfigform->isValid($this->_request->getPost()) && $errorflag == 'true') { try { $actionflag = ''; $tableid = ''; $data = array('businessunit_id' => $businessunit_id, 'department_id' => $department_id != '' ? $department_id : NULL, 'performance_app_flag' => $performance_app_flag, 'appraisal_mode' => $appraisal_mode, 'appraisal_ratings' => $appraisal_ratings, 'module_flag' => 1, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); if ($id != '') { /* for Update record */ $where = array('id=?' => $id); $actionflag = 2; } else { /* for Insert new record */ $data['createdby'] = $loginUserId; $data['createddate'] = gmdate("Y-m-d H:i:s"); $data['isactive'] = 1; $where = ''; $actionflag = 1; } $Id = $appraisalconfigmodel->SaveorUpdateAppraisalConfigData($data, $where); if ($Id == 'update') { $tableid = $id; $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Appraisal settings updated successfully")); } else { $tableid = $Id; $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Appraisal settings added successfully")); } /* * Logs Storing */ $menuID = APPRAISAL_SETTINGS; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid); /* * Logs storing ends */ /** Start * Sending Mails to employees */ if ($performance_app_flag == 0) { $appraisal_details = $appraisalconfigmodel->getBunitDept($businessunit_id, $department_id); } else { $appraisal_details = $appraisalconfigmodel->getBunit($businessunit_id); } $employeeDetailsArr = $appraisalconfigmodel->getUserDetailsByID($businessunit_id, $department_id); if (!empty($appraisal_details)) { $bunit = $appraisal_details['unitname']; $dept = $appraisal_details['deptname']; } $msg_add_update = $Id == 'update' ? "Updated" : "Configured"; $dept_str = $dept == '' ? " " : "and <b>{$dept}</b> department"; $emp_id_str = $loginuserRole == SUPERADMINROLE ? " " : "({$loginUserEmpId})"; //Preparing Employee array for BCc $empArr = array(); if (!empty($employeeDetailsArr)) { $empArrList = ''; foreach ($employeeDetailsArr as $emp) { array_push($empArr, $emp['emailaddress']); } } //Sending mail to Super admin $options['subject'] = APPLICATION_NAME . ': Performance Appraisal Configuration ' . ucfirst($msg_add_update); $options['header'] = 'Performance Appraisal'; $options['toEmail'] = SUPERADMIN_EMAIL; $options['bcc'] = $empArr; $options['toName'] = 'Super Admin'; $options['message'] = "<div style='padding: 0; text-align: left; font-size:14px; font-family:Arial, Helvetica, sans-serif;'>\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span style='color:#3b3b3b;'>Hi,</span><br />\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div style='padding:20px 0 0 0;color:#3b3b3b;'>Performance appraisal settings are {$msg_add_update} for <b>{$bunit}</b> business unit {$dept_str} by " . $loginUsername . $emp_id_str . " </div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div style='padding:20px 0 10px 0;'>Please <a href=" . BASE_URL . " target='_blank' style='color:#b3512f;'>click here</a> to login to <b>" . APPLICATION_NAME . "</b> and check the details.</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div> "; $mail_id = sapp_Global::_sendEmail($options); /** * End */ $db->commit(); $this->_redirect('appraisalconfig'); throw new Exception("Some error message"); } catch (Exception $e) { $db->rollBack(); echo $e->getMessage(); echo $e->getTraceAsString(); return $msgarray; } } else { $messages = $appraisalconfigform->getMessages(); foreach ($messages as $key => $val) { foreach ($val as $key2 => $val2) { $msgarray[$key] = $val2; break; } } if (isset($businessunit_id) && $businessunit_id != '') { if ($performance_app_flag == 0) { $departmentlistArr = $departmentsmodel->getDepartmentList($businessunit_id); if (!empty($departmentlistArr)) { foreach ($departmentlistArr as $departmentlist) { $appraisalconfigform->department_id->addMultiOption($departmentlist['id'], utf8_encode($departmentlist['deptname'])); } } } if (isset($department_id) && $department_id != 0 && $department_id != '') { $appraisalconfigform->setDefault('department_id', $department_id); } } return $msgarray; } }
public function save($servicedeskconfform) { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $servicedeskconfmodel = new Default_Model_Servicedeskconf(); $employeemodel = new Default_Model_Employee(); $departmentsmodel = new Default_Model_Departments(); $businessunitsmodel = new Default_Model_Businessunits(); $msgarray = array(); $resultArr = array(); $empstring = ''; $prevBusinessunit = ''; $errorflag = "true"; $id = $this->_request->getParam('id'); $businessunit_id = $this->_request->getParam('businessunit_id'); $service_desk_flag = $this->_request->getParam('service_desk_flag'); $department_id = $this->_request->getParam('department_id'); $service_desk_id = $this->_request->getParam('service_desk_id'); $request_recievers = $this->_request->getParam('request_recievers'); $approvingauthority = $this->_request->getParam('approvingauthority'); $approver_1 = $this->_request->getParam('approver_1'); $approver_2 = $this->_request->getParam('approver_2'); $approver_3 = $this->_request->getParam('approver_3'); $cc_mail_recievers = $this->_request->getParam('cc_mail_recievers'); $attachment = $this->_request->getParam('attachment'); $description = trim($this->_request->getParam('description')); /** Start * Validating Request reciever and CC reciever * If both have same values then throwing an error */ if (!empty($request_recievers)) { if (!empty($cc_mail_recievers)) { $resultArr = array_intersect($request_recievers, $cc_mail_recievers); } } if (!empty($resultArr)) { $msgarray['cc_mail_recievers'] = 'Executors and request viewers cannot be same.'; $errorflag = "false"; } /** End validating Request reciever and CC reciever */ /** Start * Validating selection of department if implementaion is department wise */ if ($service_desk_flag == 0) { if ($department_id == '') { $msgarray['department_id'] = 'Please select department.'; $errorflag = "false"; } } /** End validating selection of department */ /** Start * Validating approver level selection. */ if ($approvingauthority != '') { if ($approvingauthority == 1) { if ($approver_1 == '') { $msgarray['approver_1'] = 'Please select approver 1.'; $errorflag = "false"; } } else { if ($approvingauthority == 2) { if ($approver_1 == '') { $msgarray['approver_1'] = 'Please select approver 1.'; $errorflag = "false"; } if ($approver_2 == '') { $msgarray['approver_2'] = 'Please select approver 2.'; $errorflag = "false"; } } else { if ($approver_1 == '') { $msgarray['approver_1'] = 'Please select approver 1.'; $errorflag = "false"; } if ($approver_2 == '') { $msgarray['approver_2'] = 'Please select approver 2.'; $errorflag = "false"; } if ($approver_3 == '') { $msgarray['approver_3'] = 'Please select approver 3.'; $errorflag = "false"; } } } } /** * End Approver level selection */ /** Start Validating unique service desk department */ if ($businessunit_id != '' && $service_desk_id != '' && $id == '') { $serviceconfArr = $servicedeskconfmodel->checkuniqueServiceConfData($businessunit_id, $service_desk_flag, $service_desk_id, $department_id); if (!empty($serviceconfArr)) { if ($serviceconfArr[0]['count'] > 0) { $msgarray['service_desk_id'] = 'Please select a different department.'; $errorflag = "false"; } } } /** End * Validating uniques service desk department */ /** * Validating if pending requests are there when changing the implementation */ if ($businessunit_id != '') { $implementationdata = $businessunitsmodel->getSingleUnitData($businessunit_id); if (!empty($implementationdata)) { $prevBusinessunit = $implementationdata['service_desk_flag']; } if ($service_desk_flag != '') { if ($prevBusinessunit != $service_desk_flag) { $pendingRequestdata = $servicedeskconfmodel->getPendingServiceReqData($businessunit_id); if (!empty($pendingRequestdata)) { if ($pendingRequestdata[0]['count'] > 0) { $msgarray['service_desk_flag'] = 'Applicability cannot be changed as requests are in pending state.'; $errorflag = "false"; } } } } } /** * End validating pending request checking */ $db = Zend_Db_Table::getDefaultAdapter(); $db->beginTransaction(); if ($servicedeskconfform->isValid($this->_request->getPost()) && $errorflag == 'true') { try { $menumodel = new Default_Model_Menu(); $actionflag = ''; $tableid = ''; $req_rec_string = ''; $cc_string = ''; $req_rec_string = implode(',', $request_recievers); if (!empty($cc_mail_recievers)) { $cc_string = implode(',', $cc_mail_recievers); } $data = array('businessunit_id' => $businessunit_id, 'department_id' => $department_id != '' ? $department_id : NULL, 'service_desk_flag' => $service_desk_flag, 'service_desk_id' => $service_desk_id, 'request_recievers' => $req_rec_string, 'cc_mail_recievers' => $cc_string != '' ? $cc_string : NULL, 'approver_1' => $approver_1 != '' ? $approver_1 : NULL, 'approver_2' => $approver_2 != '' ? $approver_2 : NULL, 'approver_3' => $approver_3 != '' ? $approver_3 : NULL, 'attachment' => $attachment != '' ? $attachment : NULL, 'description' => $description != '' ? $description : NULL, '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; } $budata = array('service_desk_flag' => $service_desk_flag, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); $buwhere = array('id=?' => $businessunit_id); /* If implementation wise is changed then all the previous records are inactivated and new record is inserted * Else normal update - insert will take place. */ if ($prevBusinessunit != $service_desk_flag) { $prevBUData = array('isactive' => 0, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); $prevBUwhere = array('businessunit_id=?' => $businessunit_id); /* Inactivating previous records */ $prevBUId = $servicedeskconfmodel->SaveorUpdateServiceConfData($prevBUData, $prevBUwhere); $data['createdby'] = $loginUserId; $data['createddate'] = gmdate("Y-m-d H:i:s"); $data['isactive'] = 1; $where = ''; $actionflag = 1; /* Inserting new record */ $Id = $servicedeskconfmodel->SaveorUpdateServiceConfData($data, $where); } else { /* Insert or update based on action */ $Id = $servicedeskconfmodel->SaveorUpdateServiceConfData($data, $where); } /* Updating service desk flag in business unit table */ $BId = $businessunitsmodel->SaveorUpdateBusinessUnits($budata, $buwhere); if ($Id == 'update') { $tableid = $id; $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Setting updated successfully.")); } else { $tableid = $Id; $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Setting added successfully.")); } $menuidArr = $menumodel->getMenuObjID('/servicedeskconf'); $menuID = $menuidArr[0]['id']; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid); $db->commit(); $this->_redirect('servicedeskconf'); } catch (Exception $e) { $db->rollBack(); $msgarray['service_desk_id'] = "Something went wrong, please try again."; return $msgarray; } } else { $messages = $servicedeskconfform->getMessages(); foreach ($messages as $key => $val) { foreach ($val as $key2 => $val2) { $msgarray[$key] = $val2; break; } } if (isset($businessunit_id) && $businessunit_id != '') { $employeeData = $employeemodel->getEmployeesForServiceDesk($businessunit_id, $department_id); $servicedeskData = $servicedeskconfmodel->getActiveServiceDepartments($businessunit_id, $department_id); if ($id == '') { $servicedeskconfform->service_desk_id->clearMultiOptions(); } $servicedeskconfform->request_recievers->clearMultiOptions(); $servicedeskconfform->cc_mail_recievers->clearMultiOptions(); if (!empty($employeeData)) { $servicedeskconfform->request_recievers->addMultiOption('', 'Select executor'); $servicedeskconfform->cc_mail_recievers->addMultiOption('', 'Select request viewer'); foreach ($employeeData as $empres) { $servicedeskconfform->request_recievers->addMultiOption($empres['user_id'], utf8_encode($empres['userfullname'])); $servicedeskconfform->cc_mail_recievers->addMultiOption($empres['user_id'], utf8_encode($empres['userfullname'])); } } if ($id == '') { if (!empty($servicedeskData)) { $servicedeskconfform->service_desk_id->addMultiOption('', 'Select category'); foreach ($servicedeskData as $servicedeskres) { $servicedeskconfform->service_desk_id->addMultiOption($servicedeskres['id'], utf8_encode($servicedeskres['service_desk_name'])); } } } if ($service_desk_flag == 0) { $departmentlistArr = $departmentsmodel->getDepartmentList($businessunit_id); if (!empty($departmentlistArr)) { foreach ($departmentlistArr as $departmentlist) { $servicedeskconfform->department_id->addMultiOption($departmentlist['id'], utf8_encode($departmentlist['deptname'])); } } } if (isset($service_desk_id) && $service_desk_id != 0 && $service_desk_id != '' && $id == '') { $servicedeskconfform->setDefault('service_desk_id', $service_desk_id); } if (isset($department_id) && $department_id != 0 && $department_id != '') { $servicedeskconfform->setDefault('department_id', $department_id); } } if (isset($approvingauthority) && $approvingauthority != '') { if ($approvingauthority == 1) { $approver1Data = $employeemodel->getApproverForServiceDesk($businessunit_id, $department_id, $empstring); if (!empty($approver1Data)) { foreach ($approver1Data as $app1res) { $servicedeskconfform->approver_1->addMultiOption($app1res['user_id'], utf8_encode($app1res['userfullname'])); } } } else { if ($approvingauthority == 2) { $approver1Data = $employeemodel->getApproverForServiceDesk($businessunit_id, $department_id, $empstring); if (!empty($approver1Data)) { foreach ($approver1Data as $app1res) { $servicedeskconfform->approver_1->addMultiOption($app1res['user_id'], utf8_encode($app1res['userfullname'])); } } if (isset($approver_1) && $approver_1 != '') { $empstring = $approver_1; $approver2Data = $employeemodel->getApproverForServiceDesk($businessunit_id, $department_id, $empstring); if (!empty($approver2Data)) { foreach ($approver2Data as $app2res) { $servicedeskconfform->approver_2->addMultiOption($app2res['user_id'], utf8_encode($app2res['userfullname'])); } } } } else { $approver1Data = $employeemodel->getApproverForServiceDesk($businessunit_id, $department_id, $empstring); if (!empty($approver1Data)) { foreach ($approver1Data as $app1res) { $servicedeskconfform->approver_1->addMultiOption($app1res['user_id'], utf8_encode($app1res['userfullname'])); } } if (isset($approver_1) && $approver_1 != '') { $empstring = $approver_1; $approver2Data = $employeemodel->getApproverForServiceDesk($businessunit_id, $department_id, $empstring); if (!empty($approver2Data)) { foreach ($approver2Data as $app2res) { $servicedeskconfform->approver_2->addMultiOption($app2res['user_id'], utf8_encode($app2res['userfullname'])); } } } if (isset($approver_2) && $approver_2 != '') { $empstring = $empstring . ',' . $approver_2; $approver3Data = $employeemodel->getApproverForServiceDesk($businessunit_id, $department_id, $empstring); if (!empty($approver3Data)) { foreach ($approver3Data as $app3res) { $servicedeskconfform->approver_3->addMultiOption($app3res['user_id'], utf8_encode($app3res['userfullname'])); } } } } } if (isset($approver_1) && $approver_1 != 0 && $approver_1 != '') { $servicedeskconfform->setDefault('approver_1', $approver_1); } if (isset($approver_2) && $approver_2 != 0 && $approver_2 != '') { $servicedeskconfform->setDefault('approver_2', $approver_2); } if (isset($approver_3) && $approver_3 != 0 && $approver_3 != '') { $servicedeskconfform->setDefault('approver_3', $approver_3); } } return $msgarray; } }
public function editpopupAction() { 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'); $userid = $this->getRequest()->getParam('unitId'); if ($id == '') { $id = $loginUserId; } // For open the form in popup... $empjobhistoryform = new Default_Form_empjobhistory(); $empjobhistoryModel = new Default_Model_Empjobhistory(); $employeeModel = new Default_Model_Employee(); $positionModel = new Default_Model_Positions(); $departmentModel = new Default_Model_Departments(); $jobtitleModel = new Default_Model_Jobtitles(); $clientsModel = new Timemanagement_Model_Clients(); if ($id) { $employeeArr = $employeeModel->getActiveEmployeeData($userid); if (!empty($employeeArr)) { if (isset($employeeArr[0]['businessunit_id']) && $employeeArr[0]['businessunit_id'] != '') { $departmentArr = $departmentModel->getDepartmentList($employeeArr[0]['businessunit_id']); if (!empty($departmentArr)) { $empjobhistoryform->department->addMultiOption('', 'Select Department'); foreach ($departmentArr as $departmentres) { $empjobhistoryform->department->addMultiOption($departmentres['id'], $departmentres['deptname']); } } } else { $departmentArr = $departmentModel->getTotalDepartmentList(); if (!empty($departmentArr)) { $empjobhistoryform->department->addMultiOption('', 'Select Department'); foreach ($departmentArr as $departmentres) { $empjobhistoryform->department->addMultiOption($departmentres['id'], $departmentres['deptname']); } } } } $positionArr = $positionModel->getTotalPositionList(); if (!empty($positionArr)) { $empjobhistoryform->positionheld->addMultiOption('', 'Select Position'); foreach ($positionArr as $positionres) { $empjobhistoryform->positionheld->addMultiOption($positionres['id'], $positionres['positionname']); } } $jobtitleArr = $jobtitleModel->getJobTitleList(); if (!empty($jobtitleArr)) { $empjobhistoryform->jobtitleid->addMultiOption('', 'Select Job Title'); foreach ($jobtitleArr as $jobtitleres) { $empjobhistoryform->jobtitleid->addMultiOption($jobtitleres['id'], $jobtitleres['jobtitlename']); } } $clientsArr = $clientsModel->getActiveClientsData(); if (!empty($clientsArr)) { $empjobhistoryform->client->addMultiOption('', 'Select a Client'); foreach ($clientsArr as $clientsres) { $empjobhistoryform->client->addMultiOption($clientsres['id'], $clientsres['client_name']); } } $data = $empjobhistoryModel->getsingleEmpJobHistoryData($id); if (!empty($data)) { $empjobhistoryform->populate($data[0]); $empjobhistoryform->setDefault('department', $data[0]['department']); $empjobhistoryform->setDefault('positionheld', $data[0]['positionheld']); $empjobhistoryform->setDefault('jobtitleid', $data[0]['jobtitleid']); $empjobhistoryform->setDefault('client', $data[0]['client_id']); if (isset($data[0]['start_date']) && $data[0]['start_date'] != '') { $start_date = sapp_Global::change_date($data[0]['start_date'], 'view'); $empjobhistoryform->start_date->setValue($start_date); } if (isset($data[0]['end_date']) && $data[0]['end_date'] != '') { $end_date = sapp_Global::change_date($data[0]['end_date'], 'view'); $empjobhistoryform->end_date->setValue($end_date); } } } $empjobhistoryform->setAttrib('action', BASE_URL . 'empjobhistory/editpopup/unitId/' . $userid); $this->view->form = $empjobhistoryform; $this->view->controllername = 'empjobhistory'; if ($this->getRequest()->getPost()) { $result = $this->save($empjobhistoryform, $userid); $this->view->msgarray = $result; } }
/** * This function acts as a service for onchange of business unit to get departments. * @param array $params_arr = array of parameters * @return array Array of department options. */ public function bunitOnchange($params_arr) { $result = array(); $status = 0; $message = "Invalid business unit."; if (isset($params_arr['role_id']) && $params_arr['role_id'] != '' && isset($params_arr['group_id']) && $params_arr['group_id'] != '' && isset($params_arr['businessunit_id']) && $params_arr['businessunit_id'] != '' && isset($params_arr['userid']) && $params_arr['userid'] != '') { $role_id = $params_arr['role_id']; $group_id = $params_arr['group_id']; $userid = $params_arr['userid']; $businessunit_id = $params_arr['businessunit_id']; if ($role_id == SUPERADMINROLE || $group_id == MANAGEMENT_GROUP || $group_id == HR_GROUP) { $privilege_flag = sapp_Global::_checkprivileges(EMPLOYEE, $group_id, $role_id, 'add'); if ($privilege_flag == 'Yes') { $status = 1; $message = "success"; $departmentsmodel = new Default_Model_Departments(); $departmentlistArr = $departmentsmodel->getDepartmentList($businessunit_id); $dept_str = sapp_Global::selectOptionBuilder("", "Select Department"); //echo "<pre>";print_r($departmentlistArr);echo "</pre>"; if (!empty($departmentlistArr)) { foreach ($departmentlistArr as $data) { $dept_str .= sapp_Global::selectOptionBuilder($data['id'], $data['deptname']); } $result['departments'] = $dept_str; } else { $status = 0; $message = "Departments are not configured yet."; } } } } return array('status' => $status, 'message' => $message, 'result' => $result); }