public function checkappraisalimplementationAction()
 {
     $ajaxContext = $this->_helper->getHelper('AjaxContext');
     $ajaxContext->addActionContext('savegroupedemployeesajax', 'json')->initContext();
     $this->_helper->layout->disableLayout();
     $result = array();
     $model = new Default_Model_Appraisalinit();
     $departmentsmodel = new Default_Model_Departments();
     $businessunit_id = $this->_request->getParam('buid');
     $enable_step = $this->_request->getParam("enable_step");
     $output = $model->check_performance_implmentation($businessunit_id);
     if (!empty($output)) {
         $departmentlistArr = $model->getdeparmentsadmin($businessunit_id, $enable_step);
         $options_data = "";
         $options_data .= sapp_Global::selectOptionBuilder('', 'Select Department');
         if (!empty($departmentlistArr)) {
             foreach ($departmentlistArr as $dept) {
                 $options_data .= sapp_Global::selectOptionBuilder($dept['id'], utf8_encode($dept['deptname']));
             }
             $result['msg'] = 'true';
         } else {
             $result['msg'] = 'false';
         }
         if ($output['performance_app_flag'] == 1) {
             $result['flag'] = 'buwise';
         } else {
             $result['flag'] = 'deptwise';
         }
         $result['result'] = $options_data;
     } else {
         $result['flag'] = 'notinitialized';
         $result['msg'] = 'false';
         $result['result'] = '';
     }
     $this->_helper->_json($result);
 }
Ejemplo n.º 2
0
 public function save($appraisalInitForm, $is_edit = 0)
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $appraisalInitModel = new Default_Model_Appraisalinit();
     $dept_model = new Default_Model_Departments();
     $msgarray = array();
     $errorflag = 'true';
     $eligibilityflag = $this->_request->getParam('eligibilityflag');
     $eligibility = $this->_request->getParam('eligibility');
     $eligibility_hidden = $this->_request->getParam('eligibility_hidden');
     $eligibility_value = $this->_request->getParam('eligibility_value');
     if ($eligibilityflag == 1) {
         if (empty($eligibility)) {
             $msgarray['eligibility'] = "Please select eligibility";
             $errorflag = 'false';
         }
     }
     $enable_step = $this->_request->getParam('enable_step');
     $businessunit_id = $this->_request->getParam('businessunit_id');
     $department_id = $this->_request->getParam('department_id', null);
     $performance_app_flag = $this->_request->getParam('performance_app_flag');
     $id = $this->_request->getParam('id');
     if ($appraisalInitForm->isValid($this->_request->getPost()) && $errorflag == 'true') {
         try {
             $post_values = $this->_request->getPost();
             $pa_configured_id = $this->_request->getParam('configuration_id');
             $appraisal_mode = $this->_request->getParam('appraisal_mode');
             $appraisal_period = $this->_request->getParam('appraisal_period');
             $from_year = $this->_request->getParam('from_year');
             $to_year = $this->_request->getParam('to_year');
             $category_id = $this->_request->getParam('category_id', null);
             $status = $this->_request->getParam('status');
             $disable_arr = $this->_request->getParam('disable_arr', array());
             $management_appraisal = $this->_request->getParam('management_appraisal', null);
             $appraisal_ratings = $this->_request->getParam('appraisal_ratings', null);
             $managers_due_date = $this->_request->getParam('managers_due_date');
             $employee_due_date = $this->_request->getParam('employee_due_date');
             $hid_performance_app_flag = $this->_request->getParam('hid_performance_app_flag');
             $hid_appraisal_period = $this->_request->getParam('hid_appraisal_period', null);
             //checking whether the appraisal exists for the given peroid
             if (is_numeric($hid_appraisal_period) && !empty($hid_appraisal_period) && $this->getperiodAction($from_year, $to_year, $businessunit_id, $department_id, $hid_performance_app_flag, $appraisal_mode, 1, $is_edit, $id, $appraisal_period) == 'success' && $this->validateconfigAction($from_year, $to_year, $businessunit_id, $department_id, $hid_performance_app_flag, $appraisal_mode, 1, $is_edit, $id, $appraisal_period) == 'success') {
                 if (count($eligibility) > 0) {
                     $eligibility = implode(',', $eligibility);
                 } else {
                     $eligibility = null;
                 }
                 if (count($eligibility_hidden) > 0) {
                     $eligibility_hidden = implode(',', $eligibility_hidden);
                 } else {
                     $eligibility_hidden = null;
                 }
                 if (count($category_id) > 0) {
                     $category_id = implode(',', $category_id);
                 } else {
                     $category_id = null;
                 }
                 $actionflag = '';
                 $tableid = '';
                 $data = array('businessunit_id' => $businessunit_id, 'department_id' => $hid_performance_app_flag == 0 ? $department_id : null, 'enable_step' => $enable_step, 'appraisal_mode' => $appraisal_mode, 'appraisal_period' => $hid_appraisal_period, 'from_year' => $from_year, 'to_year' => $to_year, 'managers_due_date' => sapp_Global::change_date($managers_due_date, 'database'), 'employees_due_date' => sapp_Global::change_date($employee_due_date, 'database'), 'eligibility' => $eligibilityflag == 1 ? $eligibility : $eligibility_value, 'category_id' => $category_id, 'status' => $status, 'performance_app_flag' => !empty($performance_app_flag) ? $performance_app_flag : $hid_performance_app_flag, 'modifiedby' => $loginUserId, 'modifiedby_role' => $loginuserRole, 'modifiedby_group' => $loginuserGroup, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'appraisal_ratings' => $appraisal_ratings);
                 if ($id != '') {
                     $where = array('id=?' => $id);
                     $actionflag = 2;
                 } else {
                     // $app_data = $appraisalInitModel->check_per_implmentation($businessunit_id, $department_id);
                     // $data['pa_configured_id'] = !empty($app_data)?$app_data['id']:'0';
                     $data['pa_configured_id'] = 0;
                     $data['createdby_role'] = $loginuserRole;
                     $data['createdby_group'] = $loginuserGroup;
                     $data['createdby'] = $loginUserId;
                     $data['createddate'] = gmdate("Y-m-d H:i:s");
                     $data['isactive'] = 1;
                     $where = '';
                     $actionflag = 1;
                 }
                 $Id = $appraisalInitModel->SaveorUpdateAppraisalInitData($data, $where);
                 if ($Id == 'update') {
                     $tableid = $id;
                     $this->_helper->FlashMessenger()->setNamespace('appinit_success')->addMessage('Appraisal process updated successfully');
                 } else {
                     $this->_helper->FlashMessenger()->setNamespace('appinit_success')->addMessage('Appraisal process added successfully');
                     $tableid = $Id;
                 }
                 $menuID = INITIALIZE_APPRAISAL;
                 $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
                 $this->_redirect('appraisalinit/confmanagers/i/' . sapp_Global::_encrypt($tableid));
             } else {
                 if ($loginuserRole == SUPERADMINROLE || $loginuserGroup == MANAGEMENT_GROUP) {
                     if ($performance_app_flag == 0) {
                         if (isset($businessunit_id) && $businessunit_id != '') {
                             $appraisalInitForm->setDefault('businessunit_id', $businessunit_id);
                             $app_init_model = new Default_Model_Appraisalinit();
                             $appraisalInitForm->department_id->clearMultiOptions();
                             $appraisalInitForm->department_id->addMultiOption('', 'Select Department');
                             if ($id == '') {
                                 $dept_data = $app_init_model->getdeparmentsadmin($businessunit_id);
                                 if (count($dept_data) > 0) {
                                     foreach ($dept_data as $dept) {
                                         $appraisalInitForm->department_id->addMultiOption($dept['id'], utf8_encode($dept['deptname']));
                                     }
                                 }
                             }
                         }
                         if (isset($department_id) && $department_id != 0 && $department_id != '') {
                             if ($id != '') {
                                 $dept_data = $dept_model->getParicularDepartmentId($department_id);
                                 if (count($dept_data) > 0) {
                                     $dept_data = $dept_data[0];
                                     $appraisalInitForm->department_id->addMultiOption($dept_data['id'], $dept_data['deptname']);
                                     $appraisalInitForm->department_id->setValue($department_id);
                                 }
                             }
                             $appraisalInitForm->setDefault('department_id', $department_id);
                             $app_cnt = $app_init_model->checkappadmin($businessunit_id, $department_id);
                             if ($app_cnt > 0) {
                                 $msgarray['department_id'] = 'Appraisal already exists for this department.';
                             }
                         }
                     }
                 }
                 $msgarray['to_year'] = "Please select a valid year range.";
                 return $msgarray;
             }
         } catch (Exception $e) {
             $msgarray['businessunit_name'] = "Something went wrong, please try again.";
             return $msgarray;
         }
     } else {
         $messages = $appraisalInitForm->getMessages();
         foreach ($messages as $key => $val) {
             foreach ($val as $key2 => $val2) {
                 $msgarray[$key] = $val2;
                 break;
             }
         }
         if ($loginuserRole == SUPERADMINROLE || $loginuserGroup == MANAGEMENT_GROUP) {
             if ($performance_app_flag == 0) {
                 if (isset($businessunit_id) && $businessunit_id != '') {
                     $appraisalInitForm->setDefault('businessunit_id', $businessunit_id);
                     $app_init_model = new Default_Model_Appraisalinit();
                     $appraisalInitForm->department_id->clearMultiOptions();
                     $appraisalInitForm->department_id->addMultiOption('', 'Select Department');
                     if ($id == '') {
                         $dept_data = $app_init_model->getdeparmentsadmin($businessunit_id);
                         if (count($dept_data) > 0) {
                             foreach ($dept_data as $dept) {
                                 $appraisalInitForm->department_id->addMultiOption($dept['id'], utf8_encode($dept['deptname']));
                             }
                         }
                     }
                 }
                 if (isset($department_id) && $department_id != 0 && $department_id != '') {
                     if ($id != '') {
                         $dept_data = $dept_model->getParicularDepartmentId($department_id);
                         if (count($dept_data) > 0) {
                             $dept_data = $dept_data[0];
                             $appraisalInitForm->department_id->addMultiOption($dept_data['id'], $dept_data['deptname']);
                             $appraisalInitForm->department_id->setValue($department_id);
                         }
                     }
                     $appraisalInitForm->setDefault('department_id', $department_id);
                     $app_cnt = $app_init_model->checkappadmin($businessunit_id, $department_id);
                     if ($app_cnt > 0) {
                         $msgarray['department_id'] = 'Appraisal already exists for this department.';
                     }
                 }
             }
         }
         return $msgarray;
     }
 }