mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-19 12:24:09 +00:00
format documents with letterhead
This commit is contained in:
@@ -416,16 +416,30 @@ class InvoiceController extends Controller
|
||||
|
||||
public function CIEFToCustomerInvoice($id)
|
||||
{
|
||||
$defaultConfig = (new \Mpdf\Config\ConfigVariables())->getDefaults();
|
||||
$fontDirs = $defaultConfig['fontDir'];
|
||||
$defaultFontConfig = (new \Mpdf\Config\FontVariables())->getDefaults();
|
||||
$fontData = $defaultFontConfig['fontdata'];
|
||||
|
||||
$mpdf = new \Mpdf\Mpdf([
|
||||
'fontDir' => array_merge($fontDirs, [
|
||||
__DIR__ . '/custom/font/directory',
|
||||
]),
|
||||
]);
|
||||
$mpdf->shrink_tables_to_fit=1;
|
||||
$mpdf->keep_table_proportions = true;
|
||||
$mpdf->SetTitle('Purchase Order');
|
||||
|
||||
$booking = Booking::where('id', $id)->first();
|
||||
$invoice = Invoice::where('booking_id', $booking['id'])->first();
|
||||
$lines = InvoiceDetails::where('invoice_id', $invoice->id)->get();
|
||||
|
||||
$data = [
|
||||
'title' => 'INVOICE',
|
||||
'title' => 'Invoice',
|
||||
'detail' => [
|
||||
'date' => Carbon::createFromFormat('Y-m-d H:i:s', $booking->created_at)->format('d-m-Y'),
|
||||
'ei' => 'EI-202009-000001',
|
||||
'edo' => '',
|
||||
'ei' => '',
|
||||
'edo' => 'EDO-202009-000001',
|
||||
'ref' => $booking->id
|
||||
],
|
||||
'billto' => [
|
||||
@@ -436,14 +450,37 @@ class InvoiceController extends Controller
|
||||
'phone' => $invoice->contact_no,
|
||||
'marking_no' => ''
|
||||
],
|
||||
'total_page' => (count($lines) / 10),
|
||||
'lines' => $lines,
|
||||
'amount' => $invoice->amount
|
||||
];
|
||||
|
||||
$pdf = PDF::loadView('pdf/invoice', $data);
|
||||
|
||||
// Send
|
||||
return $pdf->download('invoice.pdf');
|
||||
|
||||
|
||||
$html = view('pdf/invoice', $data);
|
||||
$footer = array(
|
||||
"C" => array(
|
||||
"content" => "This is generated by computer , no signature required."
|
||||
),
|
||||
"R" => array(
|
||||
"content" => "Page {PAGENO} of {nb}"
|
||||
),
|
||||
"line" => 1
|
||||
);
|
||||
|
||||
$mpdf->Bookmark('Start of the document');
|
||||
$mpdf->SetHTMLFooter('
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td style="text-align: right; ">This is generated by computer. No signature required.</td>
|
||||
<td style="text-align: right; ">Page {PAGENO} of {nbpg}</td>
|
||||
</tr>
|
||||
</table>
|
||||
');
|
||||
$mpdf->setHeader("EDO-202009-000001");
|
||||
$mpdf->WriteHTML($html);
|
||||
|
||||
$mpdf->Output();
|
||||
}
|
||||
|
||||
public function CIEFToCustomerDO($id)
|
||||
@@ -480,6 +517,60 @@ class InvoiceController extends Controller
|
||||
return $pdf->download('do.pdf');
|
||||
}
|
||||
|
||||
|
||||
public function showpo() {
|
||||
|
||||
|
||||
$defaultConfig = (new \Mpdf\Config\ConfigVariables())->getDefaults();
|
||||
$fontDirs = $defaultConfig['fontDir'];
|
||||
$defaultFontConfig = (new \Mpdf\Config\FontVariables())->getDefaults();
|
||||
$fontData = $defaultFontConfig['fontdata'];
|
||||
|
||||
$mpdf = new \Mpdf\Mpdf([
|
||||
'fontDir' => array_merge($fontDirs, [
|
||||
__DIR__ . '/custom/font/directory',
|
||||
]),
|
||||
]);
|
||||
|
||||
$mpdf->SetTitle('Purchase Order');
|
||||
|
||||
$id = '2020';
|
||||
$booking = Booking::where('id', $id)->first();
|
||||
$invoice = Invoice::where('booking_id', $booking['id'])->first();
|
||||
$lines = InvoiceDetails::where('invoice_id', $invoice->id)->get();
|
||||
|
||||
$data = [
|
||||
'title' => 'Delivery Order',
|
||||
'detail' => [
|
||||
'date' => Carbon::createFromFormat('Y-m-d H:i:s', $booking->created_at)->format('d-m-Y'),
|
||||
'ei' => '',
|
||||
'edo' => 'EDO-202009-000001',
|
||||
'ref' => $booking->id
|
||||
],
|
||||
'billto' => [
|
||||
'buyer_company' => $invoice->buyer_company,
|
||||
'reg_no' => $invoice->reg_no,
|
||||
'address' => $invoice->address,
|
||||
'gst' => '',
|
||||
'phone' => $invoice->contact_no,
|
||||
'marking_no' => ''
|
||||
],
|
||||
'total_page' => (count($lines) / 10),
|
||||
'lines' => $lines,
|
||||
'amount' => $invoice->amount
|
||||
];
|
||||
|
||||
|
||||
|
||||
$html = view('pdf/invoice', $data);
|
||||
|
||||
$mpdf->Bookmark('Start of the document');
|
||||
$mpdf->WriteHTML($html);
|
||||
|
||||
$mpdf->Output();
|
||||
}
|
||||
|
||||
|
||||
private function isUser($booking_id, $user_id) {
|
||||
|
||||
$booking = Booking::where([
|
||||
|
||||
Reference in New Issue
Block a user