public function drill_down($type, $id) { $to = $this -> input -> post('to'); $from = $this -> input -> post('from'); if ($to == false) { $to = date("U", mktime(0, 0, 0, 1, 1, date("Y") + 1)); } else if ($to == true) { $to = strtotime($to); } if ($from == false) { $from = date("U", mktime(0, 0, 0, 1, 1, date('Y'))); } else if ($from == true) { $from = strtotime($from); } $data['type'] = $type; $data['id'] = $id; $data['title'] = "Disbursement Management::Receipts Log For The Period Between " . date('d/m/Y', $from) . " to " . date('d/m/Y', $to); $data['content_view'] = "view_receipts_view"; $data['vaccines'] = Vaccines::getAll_Minified(); $return_array = array(); $current_stock = array(); $population = 0; $year = date('Y'); $balances = array(); $archive_date = date('U'); //Type 0 means we are drilling down to a region if ($type == 0) { $data['recipient'] = Regions::getRegionName($id); $data['type'] = 0; $data['store_id'] = $id; foreach ($data['vaccines'] as $vaccine) { $return_array[$vaccine -> id] = Disbursements::getRegionalReceipts($id, $vaccine -> id, $from, $to); $current_stock[$vaccine -> id] = Disbursements::getRegionalPeriodBalance($id, $vaccine -> id, $archive_date); } $population = Regional_Populations::getRegionalPopulation($id, $year); } //Type 1 means we are drilling down to a district else if ($type == 1) { $data['recipient'] = Districts::getDistrictName($id); $data['type'] = 1; $data['store_id'] = $id; foreach ($data['vaccines'] as $vaccine) { $return_array[$vaccine -> id] = Disbursements::getDistrictReceipts($id, $vaccine -> id, $from, $to); //$current_stock[$vaccine->id] = Disbursements::getDistrictStockAtHand($id,$vaccine->id); $current_stock[$vaccine -> id] = Disbursements::getDistrictPeriodBalance($id, $vaccine -> id, $archive_date); } $population = District_Populations::getDistrictPopulation($id, $year); } //Type 2 means we are drilling down to the whole country if ($type == 2) { $data['recipient'] = "National Store"; $data['type'] = 2; $data['store_id'] = "0"; foreach ($data['vaccines'] as $vaccine) { $return_array[$vaccine -> id] = Disbursements::getNationalReceived($vaccine -> id, $from, $to); $current_stock[$vaccine -> id] = Disbursements::getNationalPeriodBalance($vaccine -> id, $archive_date); } $population = Regional_Populations::getNationalPopulation($year); } $data['population'] = $population; $data['disbursements'] = $return_array; $data['current_stocks'] = $current_stock; $this -> base_params_min_graph($data); }