echo json_encode($employerModel->getBillingContact($_GET['id'])); exit; } elseif ($_GET['page'] === "download-invoice" || $_GET['page'] === "preview-invoice") { $result = $model->getInvoice($_GET['id']); $row = $result[0]; if ($row['issued']) { // get latest invoice $issued_invoices = $model->getIssuedInvoices($row['id']); $latest_invoice = $issued_invoices[0]; $mpdf = new \mPDF(); $mpdf->WriteHTML($latest_invoice['file_contents']); $outputTag = $_GET['page'] === "preview-invoice" ? 'I' : 'D'; $mpdf->Output($latest_invoice['file_name'], $outputTag); exit; } $requestedINV = $model->calculateInvoice($row); $year = date('Y', strtotime($row['event_start_date'])); $month = date('n', strtotime($row['event_start_date'])); $month >= 1 && $month <= 4 ? $year-- : ''; $startyear = $year; $endyear = $year + 1; $fileName = "SCS{$startyear}/{$endyear}-{$row['employer_id']}{$row['event_id']}.pdf"; ob_start(); require "./includes/php/invoice_template.php"; $template = ob_get_contents(); ob_end_clean(); $mpdf = new \mPDF(); $mpdf->WriteHTML($template); $outputTag = $_GET['page'] === "preview-invoice" ? 'I' : 'D'; $mpdf->Output($fileName, $outputTag); } elseif ($_GET['page'] === "issue-invoice") {