Example #1
0
 public function get_district_dashboard_notifications_graph_data()
 {
     //format the graph here
     //$facility_code=$this -> session -> userdata('facility_id');
     $district_id = $this->session->userdata('district_id');
     $district_stock_ = facility_stocks::get_district_stock_amc($district_id);
     $district_stock_count = count($district_stock_);
     $graph_data = array();
     $graph_data = array_merge($graph_data, array("graph_id" => 'container'));
     $graph_data = array_merge($graph_data, array("graph_title" => 'District Store 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  (values in packs)'));
     $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 ($district_stock_ as $district_stock_) {
         $graph_data['graph_categories'] = array_merge($graph_data['graph_categories'], array($district_stock_['commodity_name']));
         $graph_data['series_data']['Current Pack Balance'] = array_merge($graph_data['series_data']['Current Pack Balance'], array((double) $district_stock_['pack_balance']));
         $graph_data['series_data']['Current Unit Balance'] = array_merge($graph_data['series_data']['Current Unit Balance'], array((double) $district_stock_['commodity_balance']));
         // $graph_data['series_data'] = array_merge($graph_data['series_data'], array("Potential Expiries" => $series_data2, "Actual Expiries" => $series_data));
     }
     //create the graph here
     //echo "I WORK";exit;
     $district_stock_data = $this->hcmp_functions->create_high_chart_graph($graph_data);
     $loading_icon = base_url('assets/img/no-record-found.png');
     $district_stock_data = $district_stock_count > 0 ? $district_stock_data : "\$('#container').html('<img src={$loading_icon}>');";
     //get potential expiries info here
     $potential_expiries_ = count(Facility_stocks::drug_store_commodity_expiries($district_id));
     //get actual Expiries info here
     $actual_expiries = count(Facility_stocks::drug_store_commodity_expiries($district_id));
     //get items they have been donated for
     $facility_donations = redistribution_data::get_all_active_drug_store($district_id, "to-me")->count();
     // echo "<pre>";print_r($facility_donations);echo "</pre>";exit;
     //seth
     //get stocks from v1
     $stocks_from_v1 = 0;
     return array('district_stock_count' => $district_stock_count, 'district_stock_graph' => $district_stock_data, 'potential_expiries' => $potential_expiries_, 'actual_expiries' => $actual_expiries, 'facility_donations' => $facility_donations, 'stocks_from_v1' => $stocks_from_v1);
 }