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"; } }
/** * This action is used for adding/updating data. * @parameters * @param id = id of role (optional) * * @return Zend_Form. */ public function editAction() { $groups_model = new Default_Model_Groups(); $role_model = new Default_Model_Roles(); $group_arr = $groups_model->getGroupsListForRoles(); $id = $this->getRequest()->getParam('id', null); $display_grp = "1"; $total_role_cnt = 0; $callval = $this->getRequest()->getParam('call'); if ($callval == 'ajaxcall') { $this->_helper->layout->disableLayout(); } $form = new Default_Form_Roles(); $data = array(); if ($id && is_numeric($id) && $id > 1) { try { $id = (int) $id; $id = abs($id); $form->submit->setLabel('Update'); $data = $role_model->getRoleDataById($id); if (count($data) > 0) { foreach ($data as $key => $val) { $data[$key] = htmlentities(addslashes($val), ENT_QUOTES, "UTF-8"); } $form->populate($data); } } catch (Exception $e) { $this->view->nodata = "nodata"; } } else { if ($id == '') { $total_role_cnt = $role_model->getTotalRolecnt(); foreach ($group_arr as $gid => $gdata) { if ($gdata['cnt'] < 5) { $display_grp = $gid; break; } } } else { $this->view->nodata = "nodata"; } } $this->view->form = $form; $this->view->group_arr = $group_arr; $this->view->data = $data; $this->view->display_grp = $display_grp; $this->view->total_role_cnt = $total_role_cnt; }
/** * This function is used to active/inactive employees. */ public function makeactiveinactiveAction() { Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/"); $emp_id = $this->_getParam('emp_id', null); $status = trim($this->_getParam('status', null)); $hasteam = trim($this->_getParam('hasteam', null)); $employeeModal = new Default_Model_Employee(); $user_model = new Default_Model_Usermanagement(); $usermodel = new Default_Model_Users(); $role_model = new Default_Model_Roles(); $logmanagermodel = new Default_Model_Logmanager(); $menumodel = new Default_Model_Menu(); $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $empData = $employeeModal->getsingleEmployeeData($emp_id); if ($hasteam == 'true') { $employessunderEmpId = array(); $reportingmanagersList = array(); $employessunderEmpId = $employeeModal->getEmployeesUnderRM($emp_id); if ($empData[0]['is_orghead'] == 1) { $reportingmanagersList = $usermodel->getReportingManagerList_employees('', '', MANAGEMENT_GROUP); } else { $role_data = $role_model->getRoleDataById($empData[0]['emprole']); $reportingmanagersList = $usermodel->getReportingManagerList_employees($empData[0]['department_id'], $emp_id, $role_data['group_id']); } $reportingmanagersList = sapp_Global::removeElementWithValue($reportingmanagersList, 'id', $emp_id); $this->view->emp_id = $emp_id; $this->view->status = $status; $this->view->ishead = $empData[0]['is_orghead']; $this->view->empName = $empData[0]['userfullname']; $this->view->employessunderEmpId = $employessunderEmpId; $this->view->reportingmanagersList = $reportingmanagersList; } else { $db = Zend_Db_Table::getDefaultAdapter(); $db->beginTransaction(); try { if ($status == 'active') { $data = array('isactive' => 1, 'emptemplock' => 0); $empdata = array('isactive' => 1); $logarr = array('userid' => $loginUserId, 'recordid' => $emp_id, 'date' => gmdate("Y-m-d H:i:s"), 'isactive' => 1); $jsonlogarr = json_encode($logarr); } else { if ($status == 'inactive') { $data = array('isactive' => 0, 'emptemplock' => 1); $empdata = array('isactive' => 0); $logarr = array('userid' => $loginUserId, 'recordid' => $emp_id, 'date' => gmdate("Y-m-d H:i:s"), 'isactive' => 0); $jsonlogarr = json_encode($logarr); } } $where = "id = " . $emp_id; $user_model->SaveorUpdateUserData($data, $where); $employeeModal->SaveorUpdateEmployeeData($empdata, "user_id =" . $emp_id); if ($empData[0]['is_orghead'] == '1') { $headData = array('is_orghead' => 0); $headWhere = "user_id = " . $emp_id; $employeeModal->SaveorUpdateEmployeeData($headData, $headWhere); } $menuidArr = $menumodel->getMenuObjID('/employee'); $menuID = $menuidArr[0]['id']; $id = $logmanagermodel->addOrUpdateLogManager($menuID, 4, $jsonlogarr, $loginUserId, $emp_id); $db->commit(); $result = 'update'; } catch (Exception $e) { $db->rollBack(); $result = 'failed'; } $this->_helper->json(array('result' => $result == 'update' ? "yes" : "no")); } }
/** * This action is used for adding/updating data. * @parameters * @param $id = id of users (optional) * * @return Zend_Form. */ public function editAction() { $popConfigPermission = array(); $user_model = new Default_Model_Usermanagement(); $role_model = new Default_Model_Roles(); $identity_code_model = new Default_Model_Identitycodes(); $identity_codes = $identity_code_model->getIdentitycodesRecord(); $identity_codes = isset($identity_codes[0]) ? $identity_codes[0] : array(); $id = $this->getRequest()->getParam('id', null); $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; $login_group_id = $auth->getStorage()->read()->group_id; $login_role_id = $auth->getStorage()->read()->emprole; } if (sapp_Global::_checkprivileges(IDENTITYCODES, $login_group_id, $login_role_id, 'edit') == 'Yes') { array_push($popConfigPermission, 'identitycodes'); } $this->view->popConfigPermission = $popConfigPermission; $callval = $this->getRequest()->getParam('call'); if ($callval == 'ajaxcall') { $this->_helper->layout->disableLayout(); } $form = new Default_Form_Usermanagement(); $err_messages = array(); $roles_arr = $role_model->getRolesListForUsers(''); $form->emprole->addMultiOptions(array('' => 'Select Role') + $roles_arr); $emp_identity_code = isset($identity_codes['backgroundagency_code']) ? $identity_codes['backgroundagency_code'] : ""; $identity_arr = array(); if ($emp_identity_code != '') { $identity_arr = array($identity_codes['users_code'] => "Users (" . $identity_codes['users_code'] . ")"); } else { $emp_id = ''; } $form->employeeId->addMultiOptions($identity_arr); if ($id != '' && $id > 0) { try { $id = (int) $id; $id = abs($id); $form->submit->setLabel('Update'); $data = $user_model->getUserDataById($id); if (count($data) > 0) { if ($data['jobtitle_id'] != '') { $this->_redirect('/employee/edit/id/' . $id); } $role_data = $role_model->getRoleDataById($data['emprole']); $data['emplockeddate'] = sapp_Global::change_date($data['emplockeddate'], 'view'); $form->populate($data); $this->view->data = $data; //$id_arr = preg_split('/-/', $data['employeeId']); $id_arr = preg_split('/(?=\\d)/', $data['employeeId'], 2); $identity_arr[$identity_codes['backgroundagency_code']] = "Background Agency (" . $identity_codes['backgroundagency_code'] . ")"; if (isset($identity_arr[$id_arr[0]]) && !empty($identity_arr[$id_arr[0]])) { $empIDSetVal = $identity_arr[$id_arr[0]]; } else { $empIDSetVal = ''; } $form->employeeId->setValue($empIDSetVal); if ($role_data['group_id'] == USERS_GROUP) { $form->emprole->clearMultiOptions(); $roles_arr = $role_model->getRolesListForUsers($id, $empIDSetVal); $form->emprole->addMultiOptions(array('' => 'Select Role') + $roles_arr); } } else { $this->view->nodata = "nodata"; } } catch (Exception $e) { $this->view->nodata = "nodata"; } } else { if ($id == '') { } else { echo $this->view->nodata = "nodata"; } } if ($id == '') { if ($emp_identity_code == '') { $err_messages['employeeId'] = "Identity codes are not configured yet."; } if (count($roles_arr) == 0) { $err_messages['emprole'] = "Roles are not added yet."; } } $this->view->messages = $err_messages; $this->view->form = $form; }