コード例 #1
0
 public function getperiodAction($from_year = 0, $to_year = 0, $bunit = 0, $dept_id = 0, $dept_flag = 0, $mode = 0, $call_flag = 0, $is_edit = 0, $appraisal_id = 0, $existing_period = '')
 {
     // if ajax call(to year on change)
     if ($call_flag == 0) {
         $from_year = $this->_getParam('from_year', null);
         $to_year = $this->_getParam('to_year', null);
         $bunit = $this->_getParam('bunit', null);
         $dept_id = $this->_getParam('dept_id', null);
         $dept_flag = $this->_getParam('flag', null);
         $mode = $this->_getParam('mode', null);
         $is_edit = $this->_getParam('is_edit', null);
         $appraisal_id = $this->_getParam('appraisal_id', null);
         $existing_period = $this->_getParam('existing_period', null);
     }
     $dept = isset($dept_flag) && $dept_flag == 0 ? $dept_id : 0;
     $app_init_model = new Default_Model_Appraisalinit();
     //code for edit appraisal
     if ($is_edit == 1) {
         //get the data for the appraisal based on id to compare from year, to year and period
         $appraisal_data = $app_init_model->getConfigData($appraisal_id);
         $appr_from_year = isset($appraisal_data[0]['from_year']) ? $appraisal_data[0]['from_year'] : 0;
         $appr_to_year = isset($appraisal_data[0]['to_year']) ? $appraisal_data[0]['to_year'] : 0;
         $appr_mode = isset($appraisal_data[0]['appraisal_mode']) ? $appraisal_data[0]['appraisal_mode'] : '';
         $appr_period = isset($appraisal_data[0]['appraisal_period']) ? $appraisal_data[0]['appraisal_period'] : 0;
         $actual_appr_period = $this->period_helper($appr_mode, $appr_period);
         if ($from_year == $appr_from_year && $to_year == $appr_to_year && $existing_period == $actual_appr_period) {
             if ($call_flag == 0) {
                 $this->_helper->json(array('status' => 'success', 'val' => $appr_period, 'disp_val' => $actual_appr_period));
                 return;
             } else {
                 return 'success';
             }
         }
     }
     $exist_appraisal = $app_init_model->checkappadmin($bunit, $dept_id);
     $period = 0;
     if (!$exist_appraisal) {
         //code for edit appraisal
         $year_diff = 0;
         $exist_flag = 0;
         //calculate the difference between toyear and from year
         if (is_numeric($from_year) && is_numeric($to_year)) {
             $year_diff = $to_year - $from_year;
         }
         $period = $app_init_model->getperiod($bunit, $from_year, $to_year, $mode, $dept);
         //if year difference is 0
         if ($year_diff == 0) {
             //check with from year and to year
             if ($app_init_model->isAppraisalExist($bunit, $dept_id, $from_year, $to_year, ' AND ')) {
                 $exist_flag++;
             }
             //check with from year or to year
             if ($app_init_model->isAppraisalExist($bunit, $dept_id, $from_year, $to_year, ' OR ')) {
                 $exist_flag++;
             }
         } else {
             if ($year_diff == 1) {
                 //check with from year and to year
                 if ($app_init_model->isAppraisalExist($bunit, $dept_id, $from_year, $to_year, ' AND ')) {
                     $exist_flag++;
                 }
                 //check with from year or (to year - 1)
                 $to_year = $to_year - 1;
                 if ($app_init_model->isAppraisalExist($bunit, $dept_id, $from_year, $to_year, ' AND ')) {
                     $exist_flag++;
                 }
             }
         }
         $status = 'success';
         if ($exist_flag == 0 && $period == 1 || $exist_flag > 0 && ($period > 1 && $period < 5) && strcmp($mode, 'Yearly') != 0) {
             // die('ef '.$exist_flag.' md '.$mode.' pd '.$period);
             if (strcmp($mode, 'Quarterly') == 0 && $period > 4 || strcmp($mode, 'Half-yearly') == 0 && $period > 2 || strcmp($mode, 'Yearly') == 0 && $period > 1 && $period != 0) {
                 $status = 'fail';
             } else {
                 $status = 'success';
             }
         } else {
             $status = 'fail';
         }
     } else {
         $status = 'fail';
     }
     if ($call_flag == 0) {
         $disp_val = '';
         if (!empty($period)) {
             $disp_val = $this->period_helper($mode, $period);
         }
         $this->_helper->json(array('status' => $status, 'val' => $period, 'disp_val' => $disp_val));
     } else {
         return $status;
     }
 }
コード例 #2
0
 public function getperiodAction()
 {
     $from_year = $this->_getParam('from_year', null);
     $to_year = $this->_getParam('to_year', null);
     $bunit = $this->_getParam('bunit', null);
     $dept_id = $this->_getParam('dept_id', null);
     $dept_flag = $this->_getParam('flag', null);
     $dept = isset($dept_flag) && $dept_flag == 0 ? $dept_id : 0;
     $mode = $this->_getParam('mode', null);
     $app_init_model = new Default_Model_Appraisalinit();
     $year_diff = 0;
     $exist_flag = 0;
     //calculate the difference between toyear and from year
     if (is_numeric($from_year) && is_numeric($to_year)) {
         $year_diff = $to_year - $from_year;
     }
     // echo ' year diff '.$year_diff;
     $period = $app_init_model->getperiod($bunit, $from_year, $to_year, $mode, $dept);
     //if year difference is 0
     if ($year_diff == 0) {
         //check with from year and to year
         if ($app_init_model->isAppraisalExist($bunit, $dept_id, $from_year, $to_year, ' AND ')) {
             $exist_flag++;
         }
         //check with from year or to year
         if ($app_init_model->isAppraisalExist($bunit, $dept_id, $from_year, $to_year, ' OR ')) {
             $exist_flag++;
         }
     } else {
         if ($year_diff == 1) {
             //check with from year and to year
             if ($app_init_model->isAppraisalExist($bunit, $dept_id, $from_year, $to_year, ' AND ')) {
                 $exist_flag++;
             }
             //check with from year or (to year - 1)
             $to_year = $to_year - 1;
             if ($app_init_model->isAppraisalExist($bunit, $dept_id, $from_year, $to_year, ' AND ')) {
                 $exist_flag++;
             }
         }
     }
     $status = 'success';
     if ($exist_flag == 0 && $period == 1 || $exist_flag > 0 && ($period > 1 && $period < 5) && strcmp($mode, 'Yearly') != 0) {
         if (strcmp($mode, 'Quarterly') == 0 && $period > 4 || strcmp($mode, 'Half-yearly') == 0 && $period > 2 || strcmp($mode, 'Yearly') == 0 && $period > 1 && $period != 0) {
             $status = 'fail';
         } else {
             $status = 'success';
         }
     } else {
         $status = 'fail';
     }
     $disp_val = $this->period_helper($mode, $period);
     $this->_helper->json(array('status' => $status, 'val' => $period, 'disp_val' => $disp_val));
 }