From f7f62fb677c7ce7e7f5f674ffbfdb26360b2854f Mon Sep 17 00:00:00 2001 From: Edmond Teh Date: Mon, 14 Sep 2020 17:12:19 +0800 Subject: [PATCH] po --- app/Http/Controllers/InvoiceController.php | 153 +++++------ resources/views/pdf/invoice.blade.php | 18 +- resources/views/pdf/po.blade.php | 279 +++++++++------------ 3 files changed, 202 insertions(+), 248 deletions(-) diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index 51925929..5999eaeb 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -359,11 +359,36 @@ class InvoiceController extends Controller 'lines' => $lines, 'amount' => $invoice->amount ]; - $pdf = PDF::loadView('pdf/po', $data); + + $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('Invoice'); - // Send - return $pdf->download('po.pdf'); + $html = view('pdf/po', $data); + + $mpdf->Bookmark('Start of the document'); + $mpdf->SetHTMLFooter(' + + + + + +
This is generated by computer. No signature required.Page {PAGENO} of {nbpg}
+ '); + $mpdf->setHeader($invoice->po_number); + $mpdf->WriteHTML($html); + + $mpdf->Output(); } @@ -398,8 +423,8 @@ class InvoiceController extends Controller 'ref' => $booking->id ], 'buyer' => [ - 'buyer_company' => 'CIEF Worldwide Sdn Bhd (1134596-M)', - 'reg_no' => '', + 'buyer_company' => 'CIEF Worldwide Sdn Bhd', + 'reg_no' => '1134596-M', 'address' => 'Malaysia Global Innovation & Creativity Centre, Level 1 CWS, Block 3730, Persiaran APEC 63000 Cyberjaya.', @@ -415,16 +440,6 @@ class InvoiceController extends Controller 'lines' => $lines, 'amount' => $invoice->amount ]; - $pdf = PDF::loadView('pdf/po', $data); - - - // Send - return $pdf->download('do.pdf'); - - } - - public function CIEFToCustomerInvoice($id) - { $defaultConfig = (new \Mpdf\Config\ConfigVariables())->getDefaults(); $fontDirs = $defaultConfig['fontDir']; $defaultFontConfig = (new \Mpdf\Config\FontVariables())->getDefaults(); @@ -437,8 +452,29 @@ class InvoiceController extends Controller ]); $mpdf->shrink_tables_to_fit=1; $mpdf->keep_table_proportions = true; - $mpdf->SetTitle('Purchase Order'); + $mpdf->SetTitle('Invoice'); + $html = view('pdf/po', $data); + + $mpdf->Bookmark('Start of the document'); + $mpdf->SetHTMLFooter(' + + + + + +
This is generated by computer. No signature required.Page {PAGENO} of {nbpg}
+ '); + $mpdf->setHeader($invoice->po_number); + $mpdf->WriteHTML($html); + + $mpdf->Output(); + + } + + public function CIEFToCustomerInvoice($id) + { + $booking = Booking::where('id', $id)->first(); $invoice = Invoice::where('booking_id', $booking['id'])->first(); $lines = InvoiceDetails::where('invoice_id', $invoice->id)->get(); @@ -447,8 +483,8 @@ class InvoiceController extends Controller 'title' => 'Invoice', 'detail' => [ 'date' => Carbon::createFromFormat('Y-m-d H:i:s', $booking->created_at)->format('d-m-Y'), - 'ei' => '', - 'edo' => 'EDO-202009-000001', + 'ei' => $invoice->ei, + 'edo' => null, 'ref' => $booking->id ], 'billto' => [ @@ -464,18 +500,21 @@ class InvoiceController extends Controller 'amount' => $invoice->amount ]; - + $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('Invoice'); $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(' @@ -486,7 +525,7 @@ class InvoiceController extends Controller '); - $mpdf->setHeader("EDO-202009-000001"); + $mpdf->setHeader($invoice->ei); $mpdf->WriteHTML($html); $mpdf->Output(); @@ -501,11 +540,11 @@ class InvoiceController extends Controller $lines = InvoiceDetails::where('invoice_id', $invoice->id)->get(); $data = [ - 'title' => 'DO', + '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', + 'edo' => $invoice->edo, 'ref' => $booking->id ], 'billto' => [ @@ -520,16 +559,6 @@ class InvoiceController extends Controller 'amount' => $invoice->amount ]; - $pdf = PDF::loadView('pdf/invoice', $data); - - // Send - return $pdf->download('do.pdf'); - } - - - public function showpo() { - - $defaultConfig = (new \Mpdf\Config\ConfigVariables())->getDefaults(); $fontDirs = $defaultConfig['fontDir']; $defaultFontConfig = (new \Mpdf\Config\FontVariables())->getDefaults(); @@ -540,40 +569,22 @@ class InvoiceController extends Controller __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 - ]; - + $mpdf->shrink_tables_to_fit=1; + $mpdf->keep_table_proportions = true; + $mpdf->SetTitle('do'); - $html = view('pdf/invoice', $data); $mpdf->Bookmark('Start of the document'); + $mpdf->SetHTMLFooter(' + + + + + +
This is generated by computer. No signature required.Page {PAGENO} of {nbpg}
+ '); + $mpdf->setHeader($invoice->edo); $mpdf->WriteHTML($html); $mpdf->Output(); diff --git a/resources/views/pdf/invoice.blade.php b/resources/views/pdf/invoice.blade.php index 74a04ce9..a8c8eb16 100644 --- a/resources/views/pdf/invoice.blade.php +++ b/resources/views/pdf/invoice.blade.php @@ -41,15 +41,11 @@ th { border-bottom: 1px solid black; } - .clear-fix::after { - content: ""; - clear: both; - display: table; - } td { padding: 0.4em; text-align: center; - }td.description, th.description { + } + td.description, th.description { text-align: justify; max-width: 40em; } @@ -91,12 +87,6 @@ td.address { text-align: left; } - td.computer-generated { - padding-top: 2em; - text-align: center; - font-size: 1.2em; - font-weight: bold; - } @@ -125,10 +115,10 @@ @if($detail['ei']) -
EI#: {{$detail['ei']}}
+
EI#: {{$detail['ei']}}
@endif @if($detail['edo']) -
EDO#: {{$detail['edo']}}
+
EDO#: {{$detail['edo']}}
@endif
Ref#: {{$detail['ref']}}
Date: {{$detail['date']}}
diff --git a/resources/views/pdf/po.blade.php b/resources/views/pdf/po.blade.php index 11d3d5b2..885c3c43 100644 --- a/resources/views/pdf/po.blade.php +++ b/resources/views/pdf/po.blade.php @@ -4,214 +4,167 @@ document -
-
-

{{ $title }}

-
-
- @if ($detail['po']) -
- PO#: {{ $detail['po'] }} -
- @endif - @if ($detail['do']) -
- DO#: {{ $detail['do'] }} -
- @endif -
- Ref#: {{ $detail['ref'] }} -
-
+ + + + + +
+

+ {{ $title }} +

+
+ PO#: {{$detail['po']}}
+ Ref#: {{ $detail['ref'] }}
Date: {{ $detail['date'] }} - -
- Page: 1 of 1 -
- - - +

-
-
-
- Buyer -
- @if($buyer['marking_no']) -
- Marking#: {{$buyer['marking_no']}} -
- @endif - - {{ $buyer['buyer_company'] }} - - - {{ $buyer['reg_no'] }} - - - {{ $buyer['address'] }} - - - - Phone: {{ $buyer['phone'] }} - -
-
-
- Seller -
- - {{ $seller['seller_company'] }} - -
- {{ $seller['address'] }} -
- @if($seller['phone']) -
- Phone: {{ $seller['phone'] }} -
- @endif - -
-
-
-
-
- - +
-

Billing Detail

-
+ + + + +
+ + Buyer + +
+ @if($buyer['marking_no']) +
+ Marking#: {{$buyer['marking_no']}} +
+ @endif + + {{ $buyer['buyer_company'] }} + + + ({{ $buyer['reg_no'] }}) + +
+ + {{ $buyer['address'] }} + +
+ + Phone: {{ $buyer['phone'] }} + +
+ + Seller + +
+ + {{ $seller['seller_company'] }} + +
+ {{ $seller['address'] }} +
+ @if($seller['phone']) +
+ Phone: {{ $seller['phone'] }} +
+ @endif +
+ +
+ + - - + + - - - + + + @foreach ($lines as $line) - - - - - - + + + + + + @endforeach - - + + - - + +
NoStock CodeNoStock Code DescriptionQuantityUnit Price (RM)Total Amount (RM)QuantityUnit 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)}}
Subtotal{{ number_format($amount, 2) }}Subtotal{{ number_format($amount, 2) }}
Total{{ number_format($amount, 2) }}Total{{ number_format($amount, 2) }}
-
- - - \ No newline at end of file