/**
  * 
  * Edit function to prepopulate the data.
  * 
  */
 public function editAction($id = '')
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
         $businessUnit = $auth->getStorage()->read()->businessunit_id;
         $department = $auth->getStorage()->read()->department_id;
     }
     $appInitModel = new Default_Model_Appraisalinit();
     $msgarray = array();
     $buOptions = '';
     $deptOptions = '';
     if ($id == '') {
         $id = $this->getRequest()->getParam('id');
     }
     if ($loginuserRole != SUPERADMINROLE && $loginuserGroup != MANAGEMENT_GROUP) {
         $callval = $this->getRequest()->getParam('call');
         if ($callval == 'ajaxcall') {
             $this->_helper->layout->disableLayout();
         }
         $appraisalratingsform = new Default_Form_Appraisalratings();
         $appraisalratingsmodel = new Default_Model_Appraisalratings();
         $performanceappflag = '';
         $appraisalratingsform->submit->setLabel('Update');
         $res = $appraisalratingsmodel->checkAccessAddratings($businessUnit, $department);
         foreach ($res as $result) {
             $appraisal_rating = $result['appraisal_ratings'];
         }
         $appraisal_rating = $appraisal_rating == 1 ? 5 : 10;
         try {
             if ($id) {
                 if (is_numeric($id) && $id > 0) {
                     $data = $appraisalratingsmodel->getAppraisalRatingsbyInitId($id);
                     if (!empty($data)) {
                         //$data = $data[0];
                         //echo "<pre>"; print_r($data);echo "</pre>";
                         // $appraisal_rating = 1;
                         $appInitdata = $appInitModel->getConfigData($data[0]['pa_initialization_id']);
                         $appraisalratingsform->setAttrib('action', DOMAIN . 'appraisalratings/edit/id/' . $id);
                         /* Fetch business unit and department name*/
                         $appImpleData = sapp_PerformanceHelper::check_per_implmentation($businessUnit, $department);
                         $performanceappflag = $appImpleData['performance_app_flag'];
                         $optionsArray = $this->buildoptions($businessUnit, $department, $performanceappflag);
                         $buOptions = $optionsArray['buoptions'];
                         $deptOptions = isset($optionsArray['deptoptions']) ? $optionsArray['deptoptions'] : '';
                         /* End */
                         $this->view->performanceappflag = $performanceappflag;
                         $this->view->buOptions = $buOptions;
                         $this->view->deptOptions = $deptOptions;
                         $this->view->data = $data;
                         $this->view->checkActiveApp = $appInitdata[0];
                         $this->view->appraisal_rating = $appraisal_rating;
                     } else {
                         $this->view->ermsg = 'norecord';
                     }
                 } else {
                     $this->view->ermsg = 'norecord';
                 }
             } else {
                 $this->view->ermsg = 'nodata';
             }
         } catch (Exception $e) {
             $this->view->ermsg = 'nodata';
         }
         $this->view->form = $appraisalratingsform;
         if ($this->getRequest()->getPost()) {
             $result = $this->save($appraisalratingsform);
             $this->view->msgarray = $result;
         }
         $this->render('form');
     } else {
         $buOptions = '';
         $deptOptions = '';
         $businessUnitId = '';
         $department = '';
         $deptArr = array();
         $flag = 2;
         $appraisaldataArr = $appInitModel->getAppDataById($id);
         if (!empty($appraisaldataArr)) {
             $businessUnitId = $appraisaldataArr['businessunit_id'];
             $departmentId = $appraisaldataArr['department_id'] != 'null' ? $appraisaldataArr['department_id'] : '';
             $appImpleData = sapp_PerformanceHelper::check_per_implmentation($businessUnitId, $departmentId);
             $performanceappflag = $appImpleData['performance_app_flag'];
             $optionsArray = $this->buildoptions($businessUnitId, $departmentId, $performanceappflag);
             $buOptions = $optionsArray['buoptions'];
             $deptOptions = isset($optionsArray['deptoptions']) ? $optionsArray['deptoptions'] : '';
         }
         if ($this->getRequest()->getPost()) {
             $result = $this->save($appraisalratingsform);
             $this->view->msgarray = $result;
         }
         $this->view->appraislaid = $id;
         $this->view->performanceappflag = $performanceappflag;
         $this->view->businessUnitId = $businessUnitId;
         $this->view->departmentId = $departmentId;
         $this->view->buOptions = $buOptions;
         $this->view->deptOptions = $deptOptions;
         $this->view->flag = $flag;
         $this->render('managementform');
     }
 }
 public function editAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     try {
         $appEmpRatingsModel = new Default_Model_Appraisalemployeeratings();
         $app_rating_model = new Default_Model_Appraisalratings();
         $appEmpRatingsData = $appEmpRatingsModel->getSelfAppraisalDataByEmpID($loginUserId);
         if (sizeof($appEmpRatingsData) > 0 && $appEmpRatingsData[0]['employee_id'] == $loginUserId && $appEmpRatingsData[0]['status'] == 1 && $appEmpRatingsData[0]['appraisal_status'] == APP_PENDING_EMP) {
             // Check rating exist for appraisal.
             $checkRatingsExists = $app_rating_model->getAppraisalRatingsbyInitId($appEmpRatingsData[0]['pa_initialization_id']);
             // get all Categories Data based on category ids
             $categories_data = $appEmpRatingsModel->getAppCateDataByIDs($appEmpRatingsData[0]['category_id']);
             // get question previleges data of employee for that initialization
             $appEmpQuesPrivData = $appEmpRatingsModel->getAppEmpQuesPrivData($appEmpRatingsData[0]['pa_initialization_id'], $appEmpRatingsData[0]['employee_id']);
             // merging HR and Manager questions
             $ques_csv = '';
             if ($appEmpQuesPrivData[0]['hr_qs']) {
                 $ques_csv .= $appEmpQuesPrivData[0]['hr_qs'];
             }
             if ($appEmpQuesPrivData[0]['manager_qs']) {
                 if ($ques_csv) {
                     $ques_csv .= ',';
                 }
                 $ques_csv .= $appEmpQuesPrivData[0]['manager_qs'];
             }
             // get all questions data based on above question ids
             $questions_data = $appEmpRatingsModel->getAppQuesDataByIDs($ques_csv);
             // merging HR and Manager questions privileges
             $hr_ques_previs = array();
             $mgr_ques_previs = array();
             $ratingType = array();
             if ($appEmpQuesPrivData[0]['hr_group_qs_privileges']) {
                 $hr_ques_previs = json_decode($appEmpQuesPrivData[0]['hr_group_qs_privileges'], true);
             }
             if ($appEmpQuesPrivData[0]['manager_qs_privileges']) {
                 $mgr_ques_previs = json_decode($appEmpQuesPrivData[0]['manager_qs_privileges'], true);
             }
             $question_previs = $hr_ques_previs + $mgr_ques_previs;
             // Employee and Manager response
             $emp_response = array();
             $mgr_response = array();
             if ($appEmpRatingsData[0]['employee_response']) {
                 $emp_response = json_decode($appEmpRatingsData[0]['employee_response'], true);
             }
             if ($appEmpRatingsData[0]['manager_response']) {
                 $mgr_response = json_decode($appEmpRatingsData[0]['manager_response'], true);
             }
             // get rating details using configuration id
             $ratingsData = $appEmpRatingsModel->getAppRatingsDataByConfgId($appEmpRatingsData[0]['pa_configured_id'], $appEmpRatingsData[0]['pa_initialization_id']);
             if (count($ratingsData) > 0) {
                 $ratingType = $ratingsData[0]['rating_type'];
             }
             $ratingText = array();
             $ratingValues = array();
             foreach ($ratingsData as $rd) {
                 $ratingText[] = $rd['rating_text'];
                 $ratingValues[$rd['id']] = $rd['rating_value'];
             }
             // building managers names from Emp-Ques-Privileges data
             $managerIDs = array();
             $managerNames = array();
             $line_unique_arr = array_filter(array_unique(array(1 => $appEmpQuesPrivData[0]['line_manager_1'], 2 => $appEmpQuesPrivData[0]['line_manager_2'], 3 => $appEmpQuesPrivData[0]['line_manager_3'], 4 => $appEmpQuesPrivData[0]['line_manager_4'], 5 => $appEmpQuesPrivData[0]['line_manager_5'])), 'strlen');
             if (!empty($line_unique_arr)) {
                 for ($i = 1; $i <= count($line_unique_arr); $i++) {
                     $managerIDs[] = $line_unique_arr[$i];
                 }
                 $usersData = $appEmpRatingsModel->getUserNamesByIDs(implode($managerIDs, ','));
                 foreach ($managerIDs as $mi) {
                     foreach ($usersData as $ud) {
                         if ($ud['id'] == $mi) {
                             $managerNames[] = $ud['userfullname'];
                         }
                     }
                 }
             }
             $this->view->managerNames = $managerNames;
             $this->view->mgrLevels = $appEmpQuesPrivData[0]['manager_levels'];
             $this->view->appEmpRatingsData = $appEmpRatingsData;
             $this->view->categories_data = $categories_data;
             $this->view->questions_data = $questions_data;
             $this->view->question_previs = $question_previs;
             $this->view->ratingType = $ratingType;
             $this->view->ratingText = json_encode($ratingText);
             $this->view->ratingValues = $ratingValues;
             $this->view->emp_response = $emp_response;
             $this->view->mgr_response = $mgr_response;
             $this->view->check_ratings_exists = $checkRatingsExists;
         } else {
             $this->view->rowexist = "norows";
         }
     } catch (Exception $e) {
         $this->view->rowexist = "norows";
     }
 }
Пример #3
0
 public function savemngrorghierarchyAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $app_init_model = new Default_Model_Appraisalinit();
     $ques_temp_model = new Default_Model_Appraisalqstemp();
     $ques_org_model = new Default_Model_Appraisalqsmain();
     $app_rating_model = new Default_Model_Appraisalratings();
     // $init_id = $this->_getParam('init_id',null);
     $init_param = $this->_getParam('i', null);
     $init_id = sapp_Global::_decrypt($init_param);
     $init_data = $app_init_model->getConfigData($init_id);
     if (count($init_data) > 0) {
         $init_data = $init_data[0];
     }
     $this->view->init_id = $init_id;
     $this->view->init_data = $init_data;
     $this->view->msg_arr = array();
     $ratingsflag = 'false';
     $checkRatingsExists = $app_rating_model->getAppraisalRatingsbyInitId($init_id);
     if (!empty($checkRatingsExists)) {
         $ratingsflag = 'true';
     }
     $red_result = "";
     $type_arr = array('line' => 1, 'report' => 2);
     $trDb = Zend_Db_Table::getDefaultAdapter();
     //get manager ids as comma seperated string
     $manager_ids = $this->_getParam('mid', null);
     //break the manager ids into array
     $mngr_ids_array = explode(',', $manager_ids);
     $get_managers_data = array();
     $get_managers_data = $app_init_model->getManagers_report($init_id);
     $final_managers_data = array();
     //get the managers data and build an array with manager id as key
     if (isset($get_managers_data) && count($get_managers_data) > 0) {
         foreach ($get_managers_data as $data) {
             $mngr_id = isset($data['user_id']) ? $data['user_id'] : 0;
             $final_managers_data[$mngr_id] = $data;
         }
     }
     if (isset($mngr_ids_array) && count($mngr_ids_array) > 0) {
         $choose_option = 'report';
         foreach ($mngr_ids_array as $mngr) {
             $tot_ids = array();
             $context = 'add';
             $content = array();
             $content = $app_init_model->getdisplayacontentreportacc($init_id, $mngr);
             if ($context == 'add') {
                 $init_sdata = array('manager_level_type' => $type_arr[$choose_option]);
                 $app_result = array();
                 $app_result = $app_init_model->SaveorUpdateAppraisalInitData($init_sdata, " id = " . $init_id);
                 $qresult = '';
                 if ($app_result === 'update') {
                     if (count($content) > 0) {
                         foreach ($content as $cont) {
                             if (is_numeric($cont['user_id'])) {
                                 array_push($tot_ids, $cont['user_id']);
                             }
                         }
                     }
                     $line_str_arr = array();
                     $line_str_arr['line_manager_1'] = $mngr;
                     if (count($tot_ids) > 0) {
                         foreach ($tot_ids as $emp_id) {
                             $qdata = array('pa_initialization_id' => $init_id, 'manager_levels' => 1, 'employee_id' => $emp_id, 'module_flag' => 1, 'createdby' => $loginUserId, 'createdby_role' => $loginuserRole, 'createdby_group' => $loginuserGroup, 'modifiedby' => $loginUserId, 'modifiedby_role' => $loginuserRole, 'modifiedby_group' => $loginuserGroup, 'createddate' => gmdate("Y-m-d H:i:s"), 'modifieddate' => gmdate("Y-m-d H:i:s"), 'isactive' => 1);
                             $qdata = array_merge($qdata, $line_str_arr);
                             if ($init_data['initialize_status'] == 1) {
                                 $qresult = $ques_org_model->SaveorUpdatePrivilegeData($qdata, '');
                             } else {
                                 $qresult = $ques_temp_model->SaveorUpdateData($qdata, '');
                             }
                         }
                     }
                 }
                 if ($qresult !== '' && $app_result !== '') {
                     $red_result = 'saved';
                 }
                 $message = "Appraisal process updated successfully";
             }
         }
         if ($red_result === 'saved') {
             $message = "Appraisal process updated successfully";
             $this->_helper->FlashMessenger()->setNamespace('conf_success')->addMessage($message);
             $this->_redirect('appraisalinit/confmanagers/i/' . sapp_Global::_encrypt($init_id));
         }
     }
     $this->view->ratingsflag = $ratingsflag;
     $this->render('configuremanagers');
 }
 public function indexAction()
 {
     $errorMsg = "";
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $businessunit_id = $auth->getStorage()->read()->businessunit_id;
         $department_id = $auth->getStorage()->read()->department_id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $view = $this->view;
     $model = new Default_Model_Appraisalmanager();
     $app_rating_model = new Default_Model_Appraisalratings();
     $ratingflag = 'false';
     $linemangerids = '';
     $managerprofileimgArr = array();
     $businessUnits = array();
     $business_unit_model = new Default_Model_Businessunits();
     $businessUnits = $business_unit_model->getBusinessUnitsList();
     $emp_data = $model->getEmpdata_managerapp($loginUserId);
     if (!empty($emp_data)) {
         $checkRatingsExists = $app_rating_model->getAppraisalRatingsbyInitId($emp_data[0]['init_id']);
         if (!empty($checkRatingsExists)) {
             $ratingflag = 'true';
         }
     }
     if (!empty($emp_data)) {
         foreach ($emp_data as $key => $empval) {
             for ($i = 1; $i <= 5; $i++) {
                 if (isset($empval['line_rating_' . $i])) {
                     $linemangerids .= $empval['line_manager_' . $i] . ',';
                 }
             }
             if ($linemangerids) {
                 $linemangerids = rtrim($linemangerids, ',');
                 $managerprofileimgArr = $app_rating_model->getManagerProfileImg($linemangerids);
             }
             $emp_data[$key] = $emp_data[$key] + $managerprofileimgArr;
             $linemangerids = '';
             $managerprofileimgArr = array();
         }
     }
     $view->emp_data = $emp_data;
     $view->manager_id = $loginUserId;
     $view->error_msg = $errorMsg;
     $view->ratingflag = $ratingflag;
     $view->business_units = $businessUnits;
     $view->loginuserRole = $loginuserRole;
     $view->loginuserGroup = $loginuserGroup;
 }
 public function assigngroupsAction()
 {
     $appraisalinitmodel = new Default_Model_Appraisalinit();
     $appraisalGroupsModel = new Default_Model_Appraisalgroups();
     $appraisalQsModel = new Default_Model_Appraisalquestions();
     $app_rating_model = new Default_Model_Appraisalratings();
     $init_param = $this->_getParam('i', null);
     $init_id = sapp_Global::_decrypt($init_param);
     $id = $init_id;
     $employeeIds = '';
     $groupIds = '';
     $options = '';
     $appraisalgroupName = '';
     $data['empcount'] = '';
     $groupflag = 'notassigned';
     $msgarray = array();
     $check_array = array();
     $questionsArr = array();
     $ratingsflag = 'false';
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     try {
         if ($id) {
             if (is_numeric($id) && $id > 0) {
                 $checkRatingsExists = $app_rating_model->getAppraisalRatingsbyInitId($id);
                 if (!empty($checkRatingsExists)) {
                     $ratingsflag = 'true';
                 }
                 $data = $appraisalinitmodel->getConfigData($id);
                 //echo '<pre>';print_r($data);exit;
                 if (!empty($data) && $data[0]['status'] == 1) {
                     $data = $data[0];
                     if ($data['initialize_status'] == 1) {
                         $tablename = 'main_pa_questions_privileges';
                     } else {
                         $tablename = 'main_pa_questions_privileges_temp';
                     }
                     if ($data['group_settings'] != 0) {
                         if ($data['group_settings'] == 1) {
                             $questionPrivileges = $appraisalQsModel->gethrquestionprivileges($id, $tablename, '');
                             if ($data['category_id'] != '' && $data['category_id'] != 'null') {
                                 /*if($data['initialize_status'] == 1)
                                 			$questionsArr = $appraisalQsModel->getQuestionsByCategory($data['category_id'],$questionPrivileges['hr_qs']);
                                 		else*/
                                 $questionsArr = $appraisalQsModel->getQuestionsByCategory($data['category_id'], '');
                             }
                             //echo '<pre>';print_r($questionPrivileges);exit;
                             if (!empty($questionPrivileges)) {
                                 if (isset($questionPrivileges['hr_qs']) && isset($questionPrivileges['hr_group_qs_privileges'])) {
                                     if ($questionPrivileges['hr_qs'] != '' && $questionPrivileges['hr_group_qs_privileges'] != '') {
                                         $hr_qs_Arr = explode(',', $questionPrivileges['hr_qs']);
                                         $hr_qs_privileges = json_decode($questionPrivileges['hr_group_qs_privileges'], true);
                                         foreach ($hr_qs_privileges as $key => $val) {
                                             //$val = explode(',',substr($val, 1, -1));
                                             $check_array[$key] = $val;
                                         }
                                     }
                                 }
                             }
                             $this->view->questionsArr = $questionsArr;
                             $this->view->checkArr = $check_array;
                         } else {
                             $groupEmployeeCountArr = $appraisalQsModel->getGroupEmployeeCount($id, $tablename);
                             $EmpCountArr = $appraisalQsModel->getGroupCountDetails($id, $tablename);
                             if (!empty($EmpCountArr)) {
                                 $data['empcount'] = $EmpCountArr[0]['empcount'];
                             }
                             //echo '<pre>';print_r($groupEmployeeCountArr);exit;
                             $this->view->groupEmployeeCountArr = $groupEmployeeCountArr;
                         }
                         $this->view->msgarray = $msgarray;
                     }
                     if (sapp_Global::_checkprivileges(APPRAISALQUESTIONS, $loginuserGroup, $loginuserRole, 'edit') == 'Yes') {
                         $data['poppermission'] = 'yes';
                     }
                     $this->view->appraisalid = $id;
                     $this->view->encryptapprslid = $init_param;
                     $this->view->initializationdata = $data;
                     $this->view->ratingsflag = $ratingsflag;
                     if ($this->getRequest()->getPost()) {
                         $result = $this->savequestionPrivilegs($data);
                         $this->view->msgarray = $result;
                     }
                     $this->view->messages = $this->_helper->flashMessenger->getMessages();
                 } else {
                     $this->view->ermsg = 'norecord';
                 }
             } else {
                 $this->view->ermsg = 'norecord';
             }
         } else {
             $this->view->ermsg = 'norecord';
         }
     } catch (Exception $e) {
         $this->view->ermsg = 'nodata';
     }
 }