예제 #1
0
 /** 
  ** performance appraisal reports
  ** by default displays all employee ratings for the current year
  ** parameterized by year, business unit, department, quarter, reporting manager 
  **/
 public function performancereportAction()
 {
     try {
         $form = new Default_Form_performancereport();
         $norec_arr = array();
         $dept_model = new Default_Model_Departments();
         $dept_data = $dept_model->getdepts_interview_report();
         $appraisalRatings_model = new Default_Model_Appraisalemployeeratings();
         $department = $this->_request->getParam('department_id');
         $businessunit = $this->_request->getParam('businessunit_id');
         $reportingmanager = $this->_request->getParam('reporting_manager');
         $fromyear = $this->_request->getParam('fromyear');
         $toyear = $this->_request->getParam('toyear');
         $employeeid = $this->_request->getParam('hiddenemployeename');
         $nofilters = 0;
         $appraisalData = array();
         $curdate = date('Y-m-d');
         //if all the filters are empty
         if ($department == '' && $reportingmanager == '' && ($businessunit == '' || $businessunit == 0) && $fromyear == '' && $toyear == '' && $employeeid == '') {
             $fromyear = date('Y');
             $toyear = date('Y', strtotime("{$curdate} +1 year"));
             $appraisalData = $appraisalRatings_model->getappraisalidsforperformance($fromyear, $toyear, $department, $reportingmanager, $businessunit, $employeeid);
             //when no filters are there and if there is no data for current year, checking for previous year
             if (empty($appraisalData)) {
                 $fromyear = $fromyear - 1;
                 $toyear = $toyear - 1;
                 $appraisalData = $appraisalRatings_model->getappraisalidsforperformance($fromyear, $toyear, $department, $reportingmanager, $businessunit, $employeeid);
             }
         } else {
             $appraisalData = $appraisalRatings_model->getappraisalidsforperformance($fromyear, $toyear, $department, $reportingmanager, $businessunit, $employeeid);
         }
         //getting the employees count with consolidated rating group by consolidated rating
         $emp_count_data = $appraisalRatings_model->getEmpCountWithConsolidatedRatings($fromyear, $toyear, $department, $reportingmanager, $businessunit, $appraisalData, $employeeid);
         $maxrating = 0;
         $noofboxes = 0;
         $ratingsarray = array();
         if (isset($emp_count_data) && !empty($emp_count_data)) {
             //making the array with rating as key
             foreach ($emp_count_data as $emp_count) {
                 $ratingsarray[$emp_count['consolidated_rating']] = $emp_count;
             }
         }
         //get the max rating to calculate the number of boxes
         if (isset($ratingsarray) && !empty($ratingsarray)) {
             $maxrating = max(array_keys($ratingsarray));
             if ($maxrating <= 5) {
                 $noofboxes = 5;
             } else {
                 $noofboxes = 10;
             }
         }
         //getting the employees data
         $emp_data = $appraisalRatings_model->getEmpRatings($fromyear, $toyear, $department, $reportingmanager, $businessunit, $appraisalData, $employeeid);
         $emp_grouped_data = array();
         if ($noofboxes > 0) {
             for ($i = 1; $i <= $noofboxes; $i++) {
                 $emp_inner_data = array();
                 foreach ($emp_data as $emp) {
                     if ($emp['consolidated_floor_rating'] == $i) {
                         array_push($emp_inner_data, $emp);
                     }
                 }
                 $emp_grouped_data[$i] = $emp_inner_data;
             }
         }
         //getting business units
         $bu_model = new Default_Model_Businessunits();
         $bu_arr = $bu_model->getBU_report();
         if (!empty($bu_arr)) {
             foreach ($bu_arr as $bu) {
                 $form->businessunit_id->addMultiOption($bu['id'], utf8_encode($bu['bu_name']));
             }
         } else {
             $norec_arr['businessunit_id'] = 'Business Units are not added yet.';
         }
         $this->view->emp_data = $emp_data;
         $this->view->emp_grouped_data = $emp_grouped_data;
         $this->view->ratingsarray = $ratingsarray;
         $this->view->noofboxes = $noofboxes;
         $this->view->messages = $norec_arr;
         $this->view->fromyear = $fromyear;
         $this->view->toyear = $toyear;
         $this->view->form = $form;
     } catch (Exception $e) {
         print_r($e);
     }
 }