diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index 91b5be5c..9dc75cbb 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -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(' +
| This is generated by computer. No signature required. | +Page {PAGENO} of {nbpg} | +
- - CIEF WORLDWIDE SDN BHD +
+
+ |
+
+
+
+ CIEF WORLDWIDE SDN BHD
+
+
(1134596-M) Malaysian Global Innovation & Creativity Center Level 1 CWS, Block 3730, Persiaran APEC, 63000 Cyberjaya, Malaysian. Tel: 018-2909252 - -
-
-
-
- {{$title}}
- @if($detail['ei'])
- EI#: {{$detail['ei']}}
- @endif
- @if($detail['edo'])
- EDO#: {{$detail['edo']}}
- @endif
- Ref#: {{$detail['ref']}}
- Date: {{$detail['date']}}
- Page: 1 of 1
-
- Bill To
-
-
-
-
+
- {{$billto['buyer_company']}}
-
-
- {{$billto['address']}}
-
-
- Phone: {{$billto['phone']}}
-
- |
+
+
+
+ {{$title}}
+
+
+ @if($detail['ei'])
+ EI#: {{$detail['ei']}}
+ @endif
+ @if($detail['edo'])
+ EDO#: {{$detail['edo']}}
+ @endif
+ Ref#: {{$detail['ref']}}
+ Date: {{$detail['date']}}
+ |
+
| + + Bill To + + | +||
|
+
+ {{$billto['buyer_company']}}
+
+
+ {{$billto['address']}}
+
+
+ Phone: {{$billto['phone']}}
+
+ |
+ ||
| No | -Stock Code | +No | +Stock Code | Description | -Quantity | -Unit Price (RM) | -Total Amount (RM) | +Quantity | +Unit Price (RM) | +Total Amount (RM) |
|
|---|---|---|---|---|---|---|---|---|---|---|---|
| {{$line->order}} | -{{$line->stock_code}} | -{{$line->description}} | -{{$line->quantity}} | -{{number_format($line->unit_price_rm, 2)}} | -{{number_format($line->total, 2)}} | +{{$line->order}} | +{{$line->stock_code}} | +{{$line->description}} | +{{$line->quantity}} | +{{number_format($line->unit_price_rm, 2)}} | +{{number_format($line->total, 2)}} |