public function export_store_tallies($vaccine, $vaccine_name) { $from = $this->session->userdata("store_tallies_from"); $to = $this->session->userdata("store_tallies_to"); $district_or_region_id = $this->session->userdata('district_province_id'); $login_level = $this->session->userdata('user_group'); $items = 20; $order_by = "Quantity"; $order = "DESC"; $offset = 0; $headers = "Period Tally For " . $vaccine_name . "\t\nFirst Issued\t Issued To \t Total Amount(Doses)\t\n"; $data = ""; if ($login_level == 1) { //National Level $tallies = Disbursements::getNationalRecipientTally($vaccine, $from, $to, $offset, $items, $order_by, $order); } if ($login_level == 2) { //Regional Level $tallies = Disbursements::getRegionalRecipientTally($district_or_region_id, $vaccine, $from, $to, $offset, $items, $order_by, $order); } foreach ($tallies as $tally) { $data .= $tally->Date_Issued . "\t"; $issued_to = ""; if ($tally->Issued_To_Region != null) { $issued_to = $tally->Region_Issued_To->name; } else { if ($tally->Issued_To_District != null) { $issued_to = $tally->District_Issued_To->name; } } $data .= $issued_to . "\t" . $tally->Quantity . "\n"; } header("Content-type: application/vnd.ms-excel; name='excel'"); header("Content-Disposition: filename=store_tallies_export.xls"); // Fix for crappy IE bug in download. header("Pragma: "); header("Cache-Control: "); echo $headers . $data; }