Beispiel #1
0
 public function get_service_point_graph_data()
 {
     // $graph_id = "container";
     $facility_code = $this->session->userdata('facility_id');
     $service_point = 2;
     //hard coded for pharmacy,until requested for :]
     $service_point_stock = facility_stocks::get_service_point_stocks($facility_code, $service_point);
     $service_point_name = $service_point_stock[0]['service_point_name'];
     // echo "<pre> Here";print_r($service_point_stock);exit;
     $service_point_stock_count = count($service_point_stock);
     $graph_id = "sp_graph";
     $graph_data = array();
     $graph_data = array_merge($graph_data, array("graph_id" => $graph_id));
     $graph_data = array_merge($graph_data, array("graph_title" => "{$service_point_name} Stock Level"));
     $graph_data = array_merge($graph_data, array("graph_type" => "bar"));
     $graph_data = array_merge($graph_data, array("graph_yaxis_title" => "Total Stock Level"));
     $graph_data = array_merge($graph_data, array("graph_categories" => array()));
     $graph_data = array_merge($graph_data, array("series_data" => array("Current Pack Balance" => array(), "Current Unit Balance" => array())));
     $graph_data['stacking'] = 'normal';
     foreach ($service_point_stock as $service_point_stock) {
         $pack_balance = $service_point_stock['current_balance'] / $service_point_stock['total_commodity_units'];
         $graph_data['graph_categories'] = array_merge($graph_data['graph_categories'], array($service_point_stock['commodity_name']));
         $graph_data['series_data']['Current Pack Balance'] = array_merge($graph_data['series_data']['Current Pack Balance'], array((double) $pack_balance));
         $graph_data['series_data']['Current Unit Balance'] = array_merge($graph_data['series_data']['Current Unit Balance'], array((double) $service_point_stock['total_commodity_units']));
     }
     $service_point_stock_data = $this->hcmp_functions->create_high_chart_graph($graph_data);
     // echo "<pre>"; print_r($service_point_stock_data); echo "</pre>"; exit;
     $loading_icon = base_url('assets/img/no-record-found.png');
     $service_point_stock_data = $service_point_stock_count > 0 ? $service_point_stock_data : "\$('#container').html('<img src={$loading_icon}>');";
     $actual_expiries = count(facility_stocks::get_service_point_stocks($facility_code, $service_point, NULL, 1));
     $potential_expiries = count(facility_stocks::get_service_point_stocks($facility_code, $service_point, 1, NULL));
     // echo "<pre>";print_r($potential_expiries);exit;
     return array("service_point_stock_count" => $service_point_stock_count, "service_point_stock_graph" => $service_point_stock_data, "service_point_name" => $service_point_name, "potential_expiries" => $potential_expiries, "actual_expiries" => $actual_expiries);
 }