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}
+ '); + $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([ diff --git a/database/migrations/2020_09_11_221219_change_description_to_256_varchar.php b/database/migrations/2020_09_11_221219_change_description_to_256_varchar.php new file mode 100644 index 00000000..116830b2 --- /dev/null +++ b/database/migrations/2020_09_11_221219_change_description_to_256_varchar.php @@ -0,0 +1,32 @@ +string('description', 256)->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('invoice_details', function (Blueprint $table) { + // + }); + } +} diff --git a/database/migrations/2020_09_14_130855_add_ei_edo_epo_to_invoice.php b/database/migrations/2020_09_14_130855_add_ei_edo_epo_to_invoice.php new file mode 100644 index 00000000..5030f0d1 --- /dev/null +++ b/database/migrations/2020_09_14_130855_add_ei_edo_epo_to_invoice.php @@ -0,0 +1,33 @@ +string('edo')->unique(); + $table->string('ei')->unique(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('invoices', function (Blueprint $table) { + // + }); + } +} diff --git a/resources/assets/js/components/NewInvoice.vue b/resources/assets/js/components/NewInvoice.vue index e54d97a4..570ed4b7 100644 --- a/resources/assets/js/components/NewInvoice.vue +++ b/resources/assets/js/components/NewInvoice.vue @@ -155,7 +155,7 @@ name="description" cols="20" rows="2" @blur="$v.form.addLine.description.$touch()"/>
- Description Required + Maximum length for description is 256 characters
@@ -375,6 +375,9 @@ -
- -

- 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']}} +
+
+ +

- +
- - + + - - - + + + @foreach ($lines as $line) - - - - - - + + + + + + @endforeach @@ -165,5 +197,8 @@
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)}}
+ + + \ No newline at end of file diff --git a/resources/views/pdf/po.blade.php b/resources/views/pdf/po.blade.php index 4e3b42ad..11d3d5b2 100644 --- a/resources/views/pdf/po.blade.php +++ b/resources/views/pdf/po.blade.php @@ -5,8 +5,8 @@ document