5, // Set your desired top margin in millimeters 'margin_bottom' => 1, 'margin_left' => 1, 'margin_right' => 1, ]); $mpdf->Addpage('P'); $stylesheet = file_get_contents('Styles/pdf.css'); $mpdf->WriteHTML($stylesheet, \Mpdf\HTMLParserMode::HEADER_CSS); $invoice_res = $db->exec_query('invoices', ['*'], '', '', '', '', "record_id = {$_GET['record_id']}"); $invoice = $invoice_res->fetch_assoc(); $invoice_number = $invoice['invoice_no']; $date_created = $invoice['date_created']; $date_due = $invoice['date_due']; $description = $invoice['description']; $total = $invoice['total']; $content_array = explode(';', $invoice['invoice_content']); $content_table = ''; foreach ($content_array as $content) { if (strlen($content) > 2) { $info = explode(',', $content); $content_table = $content_table . " $info[0] $info[1] R " . number_format($info[2], 2, '.', ',') . " $info[3] R " . number_format($info[4], 2, '.', ',') . " "; } } $company_details = $db->exec_query('company', ['*']); $company_info = $company_details->fetch_assoc(); $company_name = $company_info['company_name']; $company_email = $company_info['email']; $company_address = $company_info['address']; $company_phone = $company_info['phone']; $bank = $company_info['bank']; $acc = $company_info['acc']; $branch = $company_info['branch']; $client_res = $db->exec_query('clients', ['*'], '', '', '', '', "record_id = {$invoice['clients_id']}"); $client = $client_res->fetch_assoc(); $client_name = $client['clients_name']; $client_email = $client['email']; $client_address = $client['address']; $client_phone = $client['cell']; $payments_table = ""; $payments_res = $db->exec_query('income', ['*'], '', '', '', '', "invoices_id = {$_GET['record_id']}"); if ($payments_res->num_rows > 0) { $payments_table = "

Payments

"; while ($payment = $payments_res->fetch_assoc()) { $payments_table = $payments_table . " "; } $payments_table = $payments_table . "
$payment[date] R " . number_format($payment['amount'], 2, '.', ',') . "

"; } $htmlContent = "

INVOICE

#$invoice_number

DATE: $date_created

DUE : $date_due

FROM

TO

$company_name

$client_name

$company_email

$client_email

$company_phone

$client_phone

$company_address

$client_address

$company_vat

$client_vat


$description

$content_table
DESCRIPTION QUANTITY AMOUNT DISCOUNT SUB TOTAL
$payments_table "; $mpdf->WriteHTML($htmlContent); $mpdf->Output(); }