$requestedINV = $model->calculateInvoice($row); $requestedINV['discount'] = $row['discount']; $requestedINV['received'] = $row['received']; $requestedINV['comment'] = $row['comment']; $model->updateInvoiceDetail($requestedINV, $row['invoice_detail_id']); $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(); $model->issueInvoice($row['id'], $fileName, $template); $loggers['audit']->info("Invoice {$row['id']} issued"); header('Content-Type: text/plain; charset=utf-8'); echo $row['id']; exit; } elseif ($_GET['page'] === "save-invoice") { $result = $model->getInvoice($_POST['id']); $row = $result[0]; $row['employer_id'] = $_POST['employer_id']; $row['event_id'] = $_POST['event_id']; $event = $eventModel->getEvent($row['event_id']); $row['event_price'] = $event[0]['price']; $requestedINV = $model->calculateInvoice($row); $requestedINV["discount"] = $_POST['discount']; $requestedINV["comment"] = $_POST['comment']; $requestedINV["amount_remaining"] = $requestedINV['total_after_tax'];