Esempio n. 1
0
 public function filter_facility_orders($facility_code, $year, $month, $option)
 {
     $facility_code = isset($facility_code) ? $facility_code : $this->session->userdata('facility_id');
     $facility_name = Facilities::get_facility_name2($facility_code);
     //Build the line graph showing the expiries graph
     $graph_data = array();
     $graph_data = array_merge($graph_data, array("graph_id" => 'graph-section'));
     $graph_data = array_merge($graph_data, array("graph_title" => 'Total Orders for ' . $facility_name['facility_name'] . ' in ' . $m . ' ' . $year));
     $graph_data = array_merge($graph_data, array("graph_type" => 'column'));
     $graph_data = array_merge($graph_data, array("graph_yaxis_title" => 'Total Orders (values in ' . $option . ')'));
     $graph_data = array_merge($graph_data, array("graph_categories" => array()));
     $graph_data = array_merge($graph_data, array("series_data" => array("Total Orders" => array())));
     if ($year == 0 && $month == 0) {
         //Where the month and year have not been selected
         //$year = date("Y");
         $orders = facility_orders::get_facility_orders($facility_code, $year);
         $graph_data = array_merge($graph_data, array("graph_type" => 'line'));
         foreach ($orders as $facility_orders) {
             $graph_data['graph_categories'] = array_merge($graph_data['graph_categories'], array($facility_orders['month']));
             $graph_data['series_data']['Total Orders'] = array_merge($graph_data['series_data']['Total Orders'], array((int) $facility_orders['total']));
         }
     } elseif ($year == 0 && $month != 0) {
         //When only the month is selected
         //$year = date("Y");
         $m = date('F', strtotime('2000-' . $month . '-01'));
         $orders = facility_orders::get_filtered_facility_orders($facility_code, $year, $month, $option);
         foreach ($orders as $facility_orders) {
             $graph_data['graph_categories'] = array_merge($graph_data['graph_categories'], array($facility_orders['name']));
             $graph_data['series_data']['Total Orders'] = array_merge($graph_data['series_data']['Total Orders'], array((int) $facility_orders['total']));
         }
     } elseif ($year != 0 && $month == 0) {
         //When the $year is not set but the month is
         //$year = date("Y");
         $orders = facility_orders::get_filtered_facility_orders($facility_code, $year, $month, $option);
         foreach ($orders as $facility_orders) {
             $graph_data['graph_categories'] = array_merge($graph_data['graph_categories'], array($facility_orders['name']));
             $graph_data['series_data']['Total Orders'] = array_merge($graph_data['series_data']['Total Orders'], array((int) $facility_orders['total']));
         }
     } else {
         //Where both month and year are selected by the user
         //Get the name of the month selected
         $m = date('F', strtotime('2000-' . $month . '-01'));
         $orders = facility_orders::get_filtered_facility_orders($facility_code, $year, $month, $option);
         foreach ($orders as $facility_orders) {
             $graph_data['graph_categories'] = array_merge($graph_data['graph_categories'], array($facility_orders['name']));
             $graph_data['series_data']['Total Orders'] = array_merge($graph_data['series_data']['Total Orders'], array((int) $facility_orders['total']));
         }
     }
     $data['high_graph'] = $this->hcmp_functions->create_high_chart_graph($graph_data);
     return $this->load->view("shared_files/report_templates/high_charts_template_v", $data);
 }