예제 #1
0
 /**
  * This function generates report for
  * "Requirement", "Issuance" and "Remaining Balance" at Provincial Stores
  *
  */
 public function targetIssuanceAction()
 {
     $form = new Form_TargetIssuanceSearch();
     $stock_master = new Model_StockMaster();
     if ($this->_request->isPost()) {
         $res = $this->_request->getPost();
         $form->month->setValue($res['month']);
         $form->year->setValue($res['year']);
         $form->province_region->setValue($res['province_region']);
         $stock_master->form_values = $res;
         // Getting "Warehouse" from "Location"
         $warehouses = new Model_Warehouses();
         $warehouses->form_values['stakeholder_id'] = 1;
         $warehouses->form_values['province_id'] = $res['province_region'];
         $warehouse = $warehouses->getAmcWarehouses();
         $stock_master->form_values['warehouse_id'] = $warehouse[0]['key'];
         $this->view->w_name = $warehouse[0]['value'];
         $this->view->w_id = $warehouse[0]['key'];
         $month = $res['month'];
         $year = $res['year'];
         $dataset = $stock_master->targetIssuanceSearch();
         $monthName = date("F", mktime(0, 0, 0, $month, 10));
         // Generating XML for chart
         $title = "EPI - Provincial Requirement Vs Issuance ";
         $sub_title = $warehouse[0]['value'] . " (January, {$year} to {$monthName},  {$year})";
         $xmlstore = "<chart exportEnabled='1' labelDisplay='rotate' slantLabels='1' yAxisMaxValue='100' exportAction='Download' caption= '{$title} ' subcaption= ' {$sub_title}' exportFileName='" . $title . " - " . date('Y-m-d H:i:s') . "' yAxisName='Doses' showValues='0' formatNumberScale='0' theme='fint'>";
         $xmlstore .= "<categories>";
         foreach ($dataset as $row) {
             $xmlstore .= "<category label='" . $row['product'] . "' />";
         }
         $xmlstore .= "</categories>";
         $xmlstore .= "<dataset seriesName='Requirement' color='5B9BD5'>";
         foreach ($dataset as $row) {
             $xmlstore .= "<set value='" . round($row['n_month_requirement']) . "' />";
         }
         $xmlstore .= "</dataset>";
         $xmlstore .= "<dataset seriesName='Issued' color='A5C838'>";
         foreach ($dataset as $row) {
             $xmlstore .= "<set value='" . round($row['issuance']) . "' />";
         }
         $xmlstore .= "</dataset>";
         $xmlstore .= "<dataset seriesName='Balance' color='ED7D31'>";
         foreach ($dataset as $row) {
             $xmlstore .= "<set value='" . round($row['n_month_balance']) . "' />";
         }
         $xmlstore .= "</dataset>";
         $xmlstore .= "</chart>";
     }
     $this->view->form = $form;
     $this->view->m = $month;
     $this->view->y = $year;
     $this->view->result = $dataset;
     $this->view->xmlstore = $xmlstore;
 }