public function pdfreport($report_type, $facility_code) { $facility_information = $report_data = $heading = $report_title = $data = ''; $facility_name = Facilities::get_facility_name2($facility_code); $facility_obj = Facilities::get_facility_district_county_level($facility_code); $facility_information = '<table class = "data-table"><thead><tr><th>Facility Code</th><th>Facility Name</th><th>County</th><th>District</th><th>Type</th></tr></thead> <tbody><tr><td>' . $facility_code . '</td><td>' . $facility_name . '</td><td>' . $facility_obj['county'] . '</td><td>' . $facility_obj['district'] . '</td><td>' . $facility_obj['type'] . '</td></tr></tbody>'; $facility_information .= '</table>'; switch ($report_type) { case 'malaria': $heading = '<th>Drug Name</th>'; $report_title = 'Malaria Program Report For: ' . $facility_name; $file_name = $facility_name . ' Malaria Report'; $data = $this->createmalariareport($facility_code); break; case 'rh': $heading = '<th>Contraceptive</th>'; $report_title = 'Reproductive Health Program Report For: ' . $facility_name; $file_name = $facility_name . ' RH Report'; $data = $this->createrhreport($facility_code); break; default: break; } $report_table = '<table class = "data-table"> <thead> <tr>' . $heading . ' <th>Unit Size</th> <th>Unit Cost (Ksh)</th> <th>Opening Balance (Units)</th> <th>Total Receipts (Units)</th> <th>Total issues (Units)</th> <th>Adjustments(-ve) (Units)</th> <th>Adjustments(+ve) (Units)</th> <th>Losses (Units)</th> <th>No days out of stock</th> <th>Closing Stock(Units)</th> </tr> </thead>'; if (!$data) { $data = '<tr><td colspan = "11"><center>There is no report for this facility</center></td></tr>'; } $report_table .= $data; $report_table .= '</table>'; $pdf_data['pdf_title'] = $report_title; $pdf_data['file_name'] = $file_name; $pdf_data['pdf_html_body'] = $facility_information . $report_table; $this->hcmp_functions->create_pdf($pdf_data); }