예제 #1
0
 public function tracer_report()
 {
     //seth
     //THIS REPORT IS CURRENTLY STATIC UNTIL AN INTERFACE IS MADE
     // $t_report = Facility_stocks::get_tracer_items_report_new($facility_code, $district_id, $county_id, $category_id, $commodity_id, $option, $from, $to, $report_type, $tracer);
     $county_name = counties::get_county_name(1);
     $t_report = Facility_stocks::get_tracer_items_report_new(NULL, NULL, 1, NULL, NULL, NULL, 1427839200, 1430344800, NULL, 1, "packs");
     //can add 'mos' for months of stock
     $stock_lvl = Facility_stocks::get_county_stock_level_tracer(1, NULL, NULL, "ksh");
     //county id only
     $excel_data = array('doc_creator' => 'HCMP Kenya', 'doc_title' => 'Tracer Commodity Report For $county_name[\'county_name\']', 'file_name' => 'Nairobi County Tracer Commodity Monthly Report');
     $row_data = array();
     $column_data = array("KEMSA Code", "Proprietary Drug Name", "Unit Of Issue", "Consumption (AMC) in Packs", "Current Stock Level in Packs");
     $excel_data['column_data'] = $column_data;
     // echo "<pre>";print_r($stock_lvl);echo "</pre>";exit;
     $chopped_down = array();
     foreach ($t_report as $chunk) {
         foreach ($stock_lvl as $chunket) {
             if ($chunk['commodity_id'] == $chunket['commodity_id']) {
                 $chopped_down[] = array('commodity_code' => $chunk['commodity_code'], 'commodity_name' => $chunket['commodity_name'], 'issue_unit' => $chunk['unit_size'], 'consumption' => $chunk['total'], 'stock_total' => $chunket['total']);
                 //end of chopped down array assignments
             }
             //end of if
         }
         //stock level foreach
     }
     //tracer report foreach
     foreach ($chopped_down as $spliced) {
         array_push($row_data, array($spliced["commodity_code"], $spliced["commodity_name"], $spliced["issue_unit"], $spliced["consumption"], $spliced["stock_total"]));
     }
     $excel_data['row_data'] = $row_data;
     // echo "<pre>";print_r($chopped_down);echo "</pre>";exit;
     $this->hcmp_functions->create_excel($excel_data);
 }