public function editAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $id = $this->getRequest()->getParam('id');
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $appraisalinitform = new Default_Form_Appraisalinit();
     $appraisalinitform->submit->setLabel('Update');
     try {
         if ($id) {
             if (is_numeric($id) && $id > 0) {
                 $appraisalinitmodel = new Default_Model_Appraisalinit();
                 $data = $appraisalinitmodel->getConfigData($id);
                 if (!empty($data)) {
                     $empSummaryModel = new Default_Model_Employee();
                     $empData = $empSummaryModel->getEmp_from_summary($loginUserId);
                     $appraisalinitform->businessunit_name->setValue($empData['businessunit_name']);
                     $appraisalinitform->department_name->setValue($empData['department_name']);
                     $employmentstatusModel = new Default_Model_Employmentstatus();
                     $employmentStatusData = $employmentstatusModel->getempstatusActivelist();
                     if (!empty($employmentStatusData)) {
                         foreach ($employmentStatusData as $employmentStatusres) {
                             $appraisalinitform->eligibility->addMultiOption($employmentStatusres['workcodename'], $employmentStatusres['statusname']);
                         }
                     }
                     $data = $data[0];
                     $appraisalinitform->populate($data);
                     $appraisalinitform->setAttrib('action', DOMAIN . 'appraisalinit/edit/id/' . $id);
                     $this->view->data = $data;
                 } else {
                     $this->view->ermsg = 'norecord';
                 }
             } else {
                 $this->view->ermsg = 'norecord';
             }
         } else {
             $this->view->ermsg = '';
         }
     } catch (Exception $e) {
         $this->view->ermsg = 'nodata';
     }
     $this->view->eligibility_value = $data['eligibility'];
     $this->view->form = $appraisalinitform;
     if ($this->getRequest()->getPost()) {
         $result = $this->save($appraisalinitform);
         $this->view->msgarray = $result;
     }
     $this->render('form');
 }
예제 #2
0
 public function editAction()
 {
     $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;
     }
     $this->view->loginuserRole = $loginuserRole;
     $this->view->loginuserGroup = $loginuserGroup;
     $id = $this->getRequest()->getParam('id');
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $appraisalinitform = new Default_Form_Appraisalinit();
     $app_rating_model = new Default_Model_Appraisalratings();
     $appraisalinitform->submit->setLabel('Update');
     $disable_arr = array();
     $ratings = '';
     $eligibilityvalue = '';
     $ratingsflag = 'false';
     $data = array();
     try {
         if ($id != '') {
             if (is_numeric($id) && $id > 0) {
                 $appraisalinitmodel = new Default_Model_Appraisalinit();
                 $checkRatingsExists = $app_rating_model->getAppraisalRatingsbyInitId($id);
                 if (!empty($checkRatingsExists)) {
                     $ratingsflag = 'true';
                 }
                 $this->view->ratingsflag = $ratingsflag;
                 $data = $appraisalinitmodel->getConfigData($id);
                 if (!empty($data)) {
                     $data = $data[0];
                     $performance_app_flag = isset($data['performance_app_flag']) ? $data['performance_app_flag'] : '';
                     $this->view->performance_app_flag = $performance_app_flag;
                     $app_rating_type = isset($data['appraisal_ratings']) ? $data['appraisal_ratings'] : 0;
                     $this->view->init_id = $id;
                     if ($data['initialize_status'] == 1) {
                         $this->appraisalinitialized($data);
                     } else {
                         if ($loginuserRole != SUPERADMINROLE && $loginuserGroup != MANAGEMENT_GROUP) {
                             // $appImpleData = sapp_PerformanceHelper::check_per_implmentation($businessunit_id, $department_id);
                             $empSummaryModel = new Default_Model_Employee();
                             $empData = $empSummaryModel->getEmp_from_summary($loginUserId);
                             $appraisalinitform->businessunit_name->setValue($empData['businessunit_name']);
                             if ($performance_app_flag == 0) {
                                 $appraisalinitform->department_name->setValue($empData['department_name']);
                             } else {
                                 $appraisalinitform->removeElement("department_name");
                             }
                         } else {
                             // $appImpleData = sapp_PerformanceHelper::check_per_implmentation($data['businessunit_id'], $data['department_id']);
                             $businessunits = $appraisalinitmodel->getbusinnessunits_admin($data['businessunit_id']);
                             $this->view->businessunits = $businessunits;
                             $dept_model = new Default_Model_Departments();
                             if ($performance_app_flag == 0) {
                                 $dept_data = $dept_model->getParicularDepartmentId($data['department_id']);
                                 if (count($dept_data) > 0) {
                                     $dept_data = $dept_data[0];
                                     $appraisalinitform->department_id->addMultiOption($dept_data['id'], $dept_data['deptname']);
                                 }
                             }
                         }
                         // $this->view->imple_data = $appImpleData;
                         $employmentstatusModel = new Default_Model_Employmentstatus();
                         $employmentStatusData = $employmentstatusModel->getempstatusActivelist();
                         if (!empty($employmentStatusData)) {
                             foreach ($employmentStatusData as $employmentStatusres) {
                                 $appraisalinitform->eligibility->addMultiOption($employmentStatusres['workcodename'], $employmentStatusres['statusname']);
                                 $appraisalinitform->eligibility_hidden->addMultiOption($employmentStatusres['workcodename'], $employmentStatusres['statusname']);
                                 $eligibilityvalue .= $employmentStatusres['workcodename'] . ',';
                             }
                             $eligibilityvalue = rtrim($eligibilityvalue, ',');
                         }
                         $category_model = new Default_Model_Appraisalcategory();
                         $category_data = $category_model->getAppraisalCategorysData();
                         foreach ($category_data as $cdata) {
                             $appraisalinitform->category_id->addMultiOption($cdata['id'], $cdata['category_name']);
                         }
                         // Set default values for 'To Year' field
                         $following_year = $data["from_year"] + 1;
                         $appraisalinitform->to_year->addMultiOptions(array($data["from_year"] => $data["from_year"], $following_year => $following_year));
                         $appraisalinitform->populate($data);
                         // if($appImpleData['appraisal_ratings'] == 1)
                         // if($app_rating_type == 1)
                         // $ratings = '1-5';
                         // else
                         // $ratings = '1-10';
                         $appraisalinitform->appraisal_ratings->setValue($app_rating_type);
                         if ($eligibilityvalue != '') {
                             $appraisalinitform->eligibility_value->setValue($eligibilityvalue);
                         }
                         $appraisalinitform->setAttrib('action', BASE_URL . 'appraisalinit/edit/id/' . $id);
                         $appraisalinitform->eligibilityflag->setValue('1');
                         $appraisalinitform->eligibility_hidden->setAttrib("disabled", "disabled");
                         /*$cnt = $appraisalinitmodel->check_delete($id);
                           if($cnt > 0)
                           {
                               $disable_arr[] = "management_appraisal"; 
                           }*/
                         if ($data['enable_step'] == 2) {
                             $appraisalinitform->enable_step->removeMultiOption(1);
                         }
                         $this->view->period_disp = $this->period_helper($data['appraisal_mode'], $data['appraisal_period']);
                         $this->view->data = $data;
                         $this->view->category_id_value = $data['category_id'];
                         $this->view->businessunit_id = $businessunit_id;
                         $this->view->employmentStatusData = $employmentStatusData;
                         $this->view->eligibilityvalue = $eligibilityvalue;
                     }
                 } else {
                     $this->view->ermsg = 'norecord';
                 }
             } else {
                 $this->view->ermsg = 'norecord';
             }
         } else {
             $this->view->ermsg = '';
         }
     } catch (Exception $e) {
         $this->view->ermsg = 'nodata';
     }
     $this->view->eligibility_value = isset($data['eligibility']) ? $data['eligibility'] : '';
     $this->view->form = $appraisalinitform;
     if ($this->getRequest()->getPost()) {
         $result = $this->save($appraisalinitform, $is_edit = 1);
         $this->view->msgarray = $result;
     }
     //$this->view->disable_arr = $disable_arr;
     if (!empty($data) && $data['initialize_status'] == 1) {
         $this->render('edit');
     } else {
         $this->render('form');
     }
 }