diff --git a/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php index c4bd49cc..4954558f 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php @@ -17,11 +17,11 @@ use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject; use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\TransactionType; use App\Classes\ValueObjects\Constants\DocumentType; -use Barryvdh\DomPDF\PDF; use App\Models\Booking; use Illuminate\Database\Eloquent\Model; +use MPDF; class CreateInvoiceTransactionProcessor { /** @var ListsTransactions */ @@ -51,18 +51,6 @@ class CreateInvoiceTransactionProcessor /** @var UpdatesBookingStatus */ private $updatesBookingStatus; - /** @var PDF */ - private $purchase_pdf; - - /** @var PDF */ - private $deliver_pdf; - - /** @var PDF */ - private $payment_pdf; - - /** @var PDF */ - private $supplier_pdf; - /** * CreateInvoiceTransactionLogic constructor. * @param ListsTransactions $listsTransactions @@ -70,7 +58,7 @@ class CreateInvoiceTransactionProcessor * @param GeneratesTransactionBillNumber $generatesTransactionBillNumber * @param CalculatesBookingPaidAmount $calculatesBookingPaidAmount */ - public function __construct(ListsTransactions $listsTransactions, CreatesTransaction $createsTransaction, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CalculatesBookingPaidAmount $calculatesBookingPaidAmount, CalculatesBookingCurrencyAverageRate $calculatesBookingCurrencyAverageRate, FetchesCompany $fetchesCompany, CreatesDocument $createsDocument, CreatesFiles $createsFile, UpdatesBookingStatus $updatesBookingStatus, PDF $purchase_pdf, PDF $deliver_pdf, PDF $payment_pdf, PDF $supplier_pdf) + public function __construct(ListsTransactions $listsTransactions, CreatesTransaction $createsTransaction, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CalculatesBookingPaidAmount $calculatesBookingPaidAmount, CalculatesBookingCurrencyAverageRate $calculatesBookingCurrencyAverageRate, FetchesCompany $fetchesCompany, CreatesDocument $createsDocument, CreatesFiles $createsFile, UpdatesBookingStatus $updatesBookingStatus) { $this->listsTransactions = $listsTransactions; $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; @@ -81,10 +69,6 @@ class CreateInvoiceTransactionProcessor $this->createsDocument = $createsDocument; $this->createsFile = $createsFile; $this->updatesBookingStatus = $updatesBookingStatus; - $this->purchase_pdf = $purchase_pdf; - $this->deliver_pdf = $deliver_pdf; - $this->payment_pdf = $payment_pdf; - $this->supplier_pdf = $supplier_pdf; } /** @@ -134,7 +118,7 @@ class CreateInvoiceTransactionProcessor $supplier = $this->fetchesCompany->execute(['id' => $transaction->receiver]); - $purchase_order_pdf = $this->purchase_pdf->loadView('pages.pdfs.purchase_order', ['transaction' => $po_order_transaction, 'supplier' => $supplier]); + $purchase_order_pdf = MPDF::loadView('pages.pdfs.purchase_order', ['transaction' => $po_order_transaction, 'supplier' => $supplier]); $document_object = new DocumentObject( DocumentType::PURCHASE_ORDER, [chunk_split('data:application/pdf;base64,'.base64_encode($purchase_order_pdf->output()))], @@ -145,7 +129,7 @@ class CreateInvoiceTransactionProcessor $document = $this->createsDocument->execute($po_order_transaction->booking, $document_object); $this->createsFile->execute($document, $document_object); - $deliver_order_pdf = $this->deliver_pdf->loadView('pages.pdfs.deliver_order', ['transaction' => $po_order_transaction, 'supplier' => $supplier]); + $deliver_order_pdf = MPDF::loadView('pages.pdfs.deliver_order', ['transaction' => $po_order_transaction, 'supplier' => $supplier]); $document_object = new DocumentObject( DocumentType::DELIVER_ORDER, [chunk_split('data:application/pdf;base64,'.base64_encode($deliver_order_pdf->output()))], @@ -156,7 +140,7 @@ class CreateInvoiceTransactionProcessor $document = $this->createsDocument->execute($po_order_transaction->booking, $document_object); $this->createsFile->execute($document, $document_object); - $payment_order_pdf = $this->payment_pdf->loadView('pages.pdfs.payment_order', ['transaction' => $po_order_transaction, 'supplier' => $supplier]); + $payment_order_pdf = MPDF::loadView('pages.pdfs.payment_order', ['transaction' => $po_order_transaction, 'supplier' => $supplier]); $document_object = new DocumentObject( DocumentType::PAYMENT_ORDER, [chunk_split('data:application/pdf;base64,'.base64_encode($payment_order_pdf->output()))], @@ -167,7 +151,7 @@ class CreateInvoiceTransactionProcessor $document = $this->createsDocument->execute($po_order_transaction->booking, $document_object); $this->createsFile->execute($document, $document_object); - $supplier_order_pdf = $this->supplier_pdf->loadView('pages.pdfs.supplier_deliver_order', ['transaction' => $po_order_transaction, 'supplier' => $supplier]); + $supplier_order_pdf = MPDF::loadView('pages.pdfs.supplier_deliver_order', ['transaction' => $po_order_transaction, 'supplier' => $supplier]); $document_object = new DocumentObject( DocumentType::SUPPLIER_DELIVER_ORDER, [chunk_split('data:application/pdf;base64,'.base64_encode($supplier_order_pdf->output()))], @@ -183,4 +167,4 @@ class CreateInvoiceTransactionProcessor } } } -} \ No newline at end of file +} diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index d77eda88..267831c3 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -17,7 +17,7 @@ class Transaction extends AbstractModel implements Documentable */ public function booking(): BelongsTo { - return $this->BelongsTo( booking::class, 'booking_id', 'id'); + return $this->BelongsTo( Booking::class, 'booking_id', 'id'); } /** diff --git a/composer.json b/composer.json index ec061d4f..4d27cd7f 100644 --- a/composer.json +++ b/composer.json @@ -12,6 +12,7 @@ "ext-fileinfo": "*", "ext-json": "^1.6", "barryvdh/laravel-dompdf": "^0.9.0", + "carlos-meneses/laravel-mpdf": "^2.1", "fideloper/proxy": "^4.2", "fruitcake/laravel-cors": "^1.0", "guzzlehttp/guzzle": "^6.3", diff --git a/config/app.php b/config/app.php index a8881019..c080002d 100644 --- a/config/app.php +++ b/config/app.php @@ -178,6 +178,8 @@ return [ // Third Parties Spatie\Permission\PermissionServiceProvider::class, Barryvdh\DomPDF\ServiceProvider::class, + Meneses\LaravelMpdf\LaravelMpdfServiceProvider::class + ], /* @@ -230,6 +232,7 @@ return [ 'Validator' => Illuminate\Support\Facades\Validator::class, 'View' => Illuminate\Support\Facades\View::class, 'PDF' => Barryvdh\DomPDF\Facade::class, + 'MPDF' => Meneses\LaravelMpdf\Facades\LaravelMpdf::class, ], diff --git a/config/pdf.php b/config/pdf.php new file mode 100644 index 00000000..3459543c --- /dev/null +++ b/config/pdf.php @@ -0,0 +1,27 @@ + '', + 'format' => 'A4', + 'default_font_size' => '12', + 'default_font' => 'sans-serif', + 'margin_left' => 10, + 'margin_right' => 10, + 'margin_top' => 10, + 'margin_bottom' => 10, + 'margin_header' => 0, + 'margin_footer' => 0, + 'orientation' => 'P', + 'title' => 'Laravel mPDF', + 'author' => '', + 'watermark' => '', + 'show_watermark' => false, + 'watermark_font' => 'sans-serif', + 'display_mode' => 'fullpage', + 'watermark_text_alpha' => 0.1, + 'custom_font_dir' => '', + 'custom_font_data' => [], + 'auto_language_detection' => false, + 'temp_dir' => rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR), + 'pdfa' => false, + 'pdfaauto' => false, +]; \ No newline at end of file diff --git a/resources/assets/images/ri_1.png b/resources/assets/images/ri_1.png new file mode 100644 index 00000000..f4b2eef5 Binary files /dev/null and b/resources/assets/images/ri_1.png differ diff --git a/resources/views/layouts/base_pdf.blade.php b/resources/views/layouts/base_pdf.blade.php index 013c9871..99eb376a 100644 --- a/resources/views/layouts/base_pdf.blade.php +++ b/resources/views/layouts/base_pdf.blade.php @@ -1,36 +1,148 @@ - + + - - + body { + font-family: sun-extA; + } + + .header { + margin-top: 5em; + } + + .separator { + text-align: right; + border-bottom: 0.5px solid black; + font-size: 0.7em; + } + + img.logo { + top: 10px; + } + + img { + height: 6em; + width: 9em; + } + + .title { + font-size: 2em; + font-weight: 1200; + } + + .details { + display: inline-block; + position: relative; + + } + + .sub-title { + font-size: 1.3em; + font-weight: bold; + } + + .label { + font-size: 1.1em; + font-weight: bold; + } + + .bill-to { + margin-top: 30px; + } + + table { + width: 100%; + vertical-align: top; + } + + th { + border-bottom: 1px solid black; + } + + td { + padding: 0.4em; + /* text-align: center; */ + } + + td.title { + text-align: left; + } + td.description, + th.description { + text-align: justify; + max-width: 40em; + } + + td.stock-code, + th.stock-code { + text-align: center; + } + + th { + vertical-align: middle; + } + + td, + th { + /* margin-top: 0.6em; + margin-right: 0.6em; */ + } + + .subtotal td { + border-top: 1px solid black; + } + + .total { + border-top: 1px solid black; + border-bottom: 3px double black; + font-weight: bolder; + } + + .address {} + + */ td.header-logo { + /* text-align: left; */ + width: fit-content; + } + + td.header-cief-address { + text-align: left; + margin-left: -30px; + } + + td.header-details { + text-align: left; + vertical-align: top; + } + + td.bill-to { + text-align: left; + } + + td.document-detail { + text-align: left; + border: 1px solid black; + padding: 1em 1em 1em 1em; + width: 16em; + } + + td.address { + text-align: left; + } + + .right { + text-align: right; + } + + diff --git a/resources/views/pages/pdfs/deliver_order.blade.php b/resources/views/pages/pdfs/deliver_order.blade.php index 7e7f9e0f..fb00d869 100644 --- a/resources/views/pages/pdfs/deliver_order.blade.php +++ b/resources/views/pages/pdfs/deliver_order.blade.php @@ -1,73 +1,110 @@ @extends('layouts.base_pdf') @section('inner_content') - -

Deliver Order

-
-
-
-

Bill To

-
Marking: {{ $transaction->booking->marking }}
-
Company: {{ $supplier->name }}
-
Phone: {{ $supplier->contacts()->first()->phone }}
-
-
EDO: {{ $transaction->bill_no }}
-
REF: {{ $transaction->payment_reference ?? '-' }}
-
Date: {{ $transaction->created_at }}
-
-
-
- CIEF Worldwide Sdn Bhd (1134596-M)Malaysia Global Innovation & CreativityCentre, Level 1 CWS, Block 3730, PersiaranAPEC 63000 Cyberjaya +
+ +

+
{{ $transaction->bill_no }}
+
+ + + + + +
+ + + CIEF WORLDWIDE SDN BHD + + + (1134596-M)
+ Malaysian Global Innovation & Creativity Center
+ Level 1 CWS, Block 3730, Persiaran APEC,
+ 63000 Cyberjaya, Malaysian.
+ Tel: 018-2909252 +
+
+ + Delivery Order +
-
Phone: 0182909252
- - -
- - + +
EDO: {{ $transaction->bill_no }}
+ + +
REF: {{ $transaction->payment_reference ?? '-' }}
+
Date: {{ $transaction->created_at }}
+
 
+ + + + + + + + +
+ + Bill To + +
+
+ Company: {{ $supplier->name }} +
+
+ sdas sda sdsd dtaman asdksd 4.000 +
+
+ Phone: {{ $supplier->contacts()->first()->phone }} +
+
+ +
+
+ + + + + + + + + + + + + @foreach ($transaction->transactionDetails as $key => $transaction_detail) - - - - - + + + + + + - @foreach($transaction->transactionDetails as $transaction_detail) - - - - - - - - @endforeach - {{-- - - - - - - - + @endforeach + + + + + + + + + + + + - - - - --}} - - - - - -
NoStock CodeDescriptionQuantityUnit Price (RM)Total Amount
(RM)
Product CodeProduct NameQuantityPriceAmount{{ $key + 1 }}{{ $transaction_detail->product_code }}{{ $transaction_detail->product_name }}{{ $transaction_detail->quantity }}{{ $transaction_detail->convert_original_price() }}{{ $transaction_detail->convert_original_amount() }}
{{ $transaction_detail->product_code }}{{ $transaction_detail->product_name }}{{ $transaction_detail->quantity }}MYR {{ $transaction_detail->convert_original_price() }}MYR {{ $transaction_detail->convert_original_amount() }}
SubtotalMYR
AdjustmentMYR
Subtotal{{ $transaction->convert_original_amount() }}
Total{{ $transaction->convert_original_amount() }}
Biling ChargesMYR
TotalMYR {{ $transaction->convert_original_amount() }}
-
- - -@endsection \ No newline at end of file + +
+ + + + + + +
This is generated by computer. No signature required.Page {PAGENO} of {nbpg}
+
+@endsection diff --git a/resources/views/pages/pdfs/payment_order.blade.php b/resources/views/pages/pdfs/payment_order.blade.php index 34bcdfb8..e9e48299 100644 --- a/resources/views/pages/pdfs/payment_order.blade.php +++ b/resources/views/pages/pdfs/payment_order.blade.php @@ -1,73 +1,113 @@ @extends('layouts.base_pdf') @section('inner_content') - -

Payment Order

-
-
-
-

Bill To

-
Marking: {{ $transaction->booking->marking }}
-
Company: {{ $supplier->name }}
-
Phone: {{ $supplier->contacts()->first()->phone }}
-
-
EDO: {{ $transaction->bill_no }}
-
REF: {{ $transaction->payment_reference ?? '-' }}
-
Date: {{ $transaction->created_at }}
-
-
-
- CIEF Worldwide Sdn Bhd (1134596-M)Malaysia Global Innovation & CreativityCentre, Level 1 CWS, Block 3730, PersiaranAPEC 63000 Cyberjaya +
+ +

+
{{ $transaction->bill_no }}
+
+ + + + + + + + + + + + {{-- + + + + --}} + + + + + + +
+ + + CIEF WORLDWIDE SDN BHD + + + (1134596-M)
+ Malaysian Global Innovation & Creativity Center
+ Level 1 CWS, Block 3730, Persiaran APEC,
+ 63000 Cyberjaya, Malaysian.
+ Tel: 018-2909252 +
+
+ + Invoice +
-
Phone: 0182909252
- - -
- - + +
EI#: {{ $transaction->bill_no }}
+ + +
Ref# {{ $transaction->payment_reference ?? '-' }}
+
Date: {{ $transaction->created_at }}
+
 
+ + + + + + + + +
+ + Bill To + +
+
+ Company: {{ $supplier->name }} +
+
+ sdas sda sdsd dtaman asdksd 4.000 +
+
+ Phone: {{ $supplier->contacts()->first()->phone }} +
+
+ +
+
+ + + + + + + + + + + + + @foreach ($transaction->transactionDetails as $key => $transaction_detail) - - - - - + + + + + + - @foreach($transaction->transactionDetails as $transaction_detail) - - - - - - - - @endforeach - {{-- - - - - - - - - - - - - --}} - - - - - -
NoStock CodeDescriptionQuantityUnit Price (RM)Total Amount
(RM)
Product CodeProduct NameQuantityPriceAmount{{ $key + 1 }}{{ $transaction_detail->product_code }}{{ $transaction_detail->product_name }}{{ $transaction_detail->quantity }}{{ $transaction_detail->convert_original_price() }}{{ $transaction_detail->convert_original_amount() }}
{{ $transaction_detail->product_code }}{{ $transaction_detail->product_name }}{{ $transaction_detail->quantity }}MYR {{ $transaction_detail->convert_original_price() }}MYR {{ $transaction_detail->convert_original_amount() }}
SubtotalMYR
AdjustmentMYR
Biling ChargesMYR
TotalMYR {{ $transaction->convert_original_amount() }}
-
- - -@endsection \ No newline at end of file + @endforeach +
Subtotal{{ $transaction->convert_original_amount() }}
Billing Charges{{ $transaction->service_charge }}
Total{{ $transaction->convert_original_amount() }}
+ + + + + + +
This is generated by computer. No signature required.Page {PAGENO} of {nbpg}
+
+@endsection diff --git a/resources/views/pages/pdfs/purchase_order.blade.php b/resources/views/pages/pdfs/purchase_order.blade.php index 2423d239..5f196a4b 100644 --- a/resources/views/pages/pdfs/purchase_order.blade.php +++ b/resources/views/pages/pdfs/purchase_order.blade.php @@ -1,74 +1,120 @@ @extends('layouts.base_pdf') @section('inner_content') - -

Purchase Order

-
-
-
-

Buyer

-
Marking: {{ $transaction->booking->marking }}
-
Company: {{ $supplier->name }}
-
Phone: {{ $supplier->contacts()->first()->phone }}
+
+ +

+
{{ $transaction->bill_no }}
+
+
+ + + + + +
+ Purchase Order + + PO#: {{ $transaction->bill_no }}
+ Ref#: {{ $transaction->payment_reference ?? '-' }}
+ Date: {{ $transaction->created_at }} +
+ +
+ + + + + + + + + + + {{-- + + + + --}} + + + + + + +
+ + Buyer +
-
PO: {{ $transaction->bill_no }}
-
REF: {{ $transaction->payment_reference ?? '-' }}
-
Date: {{ $transaction->created_at }}
- -
-

Seller

-
- CIEF Worldwide Sdn Bhd (1134596-M)Malaysia Global Innovation & CreativityCentre, Level 1 CWS, Block 3730, PersiaranAPEC 63000 Cyberjaya + +
+ Marking#: {{ $transaction->booking->marking }}
-
Phone: 0182909252
-
-
-
- - + + + {{ $supplier->name }} + + + {{-- {{ $supplier }} --}} + +
+ + {{-- {{ $buyer['address'] }} --}} + +
+ + Phone: {{ $supplier->contacts()->first()->phone }} + + + + +
+ + Seller + +
+ + CIEF Worldwide Sdn Bhd (1134596-M) + +
+ Malaysia Global Innovation & CreativityCentre, Level 1 CWS, Block 3730, PersiaranAPEC 63000 Cyberjaya +
+
+ Phone: 0182909252 +
+
+ +
+ + + + + + + + + + + + + + @foreach ($transaction->transactionDetails as $key => $transaction_detail) - - - - - + + + + + + - @foreach($transaction->transactionDetails as $transaction_detail) - - - - - - - - @endforeach - {{-- - - - - - - - - - - - - --}} - - - - - -
NoStock CodeDescriptionQuantityUnit Price (RM)Total Amount
(RM)
Product CodeProduct NameQuantityPriceAmount{{ $key + 1 }}{{ $transaction_detail->product_code }}{{ $transaction_detail->product_name }}{{ $transaction_detail->quantity }}{{ $transaction_detail->convert_original_price() }}{{ $transaction_detail->convert_original_amount() }}
{{ $transaction_detail->product_code }}{{ $transaction_detail->product_name }}{{ $transaction_detail->quantity }}MYR {{ $transaction_detail->convert_original_price() }}MYR {{ $transaction_detail->convert_original_amount() }}
SubtotalMYR
AdjustmentMYR
Biling ChargesMYR
TotalMYR {{ $transaction->convert_original_amount() }}
-
- - -@endsection \ No newline at end of file + @endforeach +
Subtotal{{ $transaction->convert_original_amount() }}
Billing Charges{{ number_format($billingcharges, 2) }}
Total{{ $transaction->convert_original_amount() }}
+ + + + + + +
This is generated by computer. No signature required.Page {PAGENO} of {nbpg}
+
+@endsection diff --git a/resources/views/pages/pdfs/supplier_deliver_order.blade.php b/resources/views/pages/pdfs/supplier_deliver_order.blade.php index a3ff56cc..c7f6b183 100644 --- a/resources/views/pages/pdfs/supplier_deliver_order.blade.php +++ b/resources/views/pages/pdfs/supplier_deliver_order.blade.php @@ -1,73 +1,107 @@ @extends('layouts.base_pdf') @section('inner_content') - -

Supplier Deliver Order

-
-
-
-

Bill To

-
Marking: {{ $transaction->booking->marking }}
-
Company: {{ $supplier->name }}
-
Phone: {{ $supplier->contacts()->first()->phone }}
+
+ +
+ + + + +
+ Atvantic Import & Export Snd. Bhd (1309816-P)
+
+
+ + + + + +
+ Delivery Order + + PO#: {{ $transaction->bill_no }}
+ Ref#: {{ $transaction->payment_reference ?? '-' }}
+ Date: {{ $transaction->created_at }} +
+ +
+ + + +
+ + Buyer +
-
EDO: {{ $transaction->bill_no }}
-
REF: {{ $transaction->payment_reference ?? '-' }}
-
Date: {{ $transaction->created_at }}
- -
-
- CIEF Worldwide Sdn Bhd (1134596-M)Malaysia Global Innovation & CreativityCentre, Level 1 CWS, Block 3730, PersiaranAPEC 63000 Cyberjaya + +
+ CIEF Worldwide Sdn Bhd (1134596-M)
-
Phone: 0182909252
-
-
-
- - + + + Malaysia Global Innovation & CreativityCentre, Level 1 CWS, Block 3730, PersiaranAPEC 63000 Cyberjaya + + + {{-- {{ $supplier }} --}} + +
+ + {{-- {{ $buyer['address'] }} --}} + +
+ + Phone: 0182909252 + + + +
+ +
+ + + + + + + + + + + + + + @foreach ($transaction->transactionDetails as $key => $transaction_detail) - - - - - + + + + + + - @foreach($transaction->transactionDetails as $transaction_detail) - - - - - - - - @endforeach - {{-- - - - - - - - + @endforeach + + + + + + + + + + + + - - - - --}} - - - - - -
NoStock CodeDescriptionQuantityUnit Price (RM)Total Amount
(RM)
Product CodeProduct NameQuantityPriceAmount{{ $key + 1 }}{{ $transaction_detail->product_code }}{{ $transaction_detail->product_name }}{{ $transaction_detail->quantity }}{{ $transaction_detail->convert_original_price() }}{{ $transaction_detail->convert_original_amount() }}
{{ $transaction_detail->product_code }}{{ $transaction_detail->product_name }}{{ $transaction_detail->quantity }}MYR {{ $transaction_detail->convert_original_price() }}MYR {{ $transaction_detail->convert_original_amount() }}
SubtotalMYR
AdjustmentMYR
Subtotal{{ $transaction->convert_original_amount() }}
Total{{ $transaction->convert_original_amount() }}
Biling ChargesMYR
TotalMYR {{ $transaction->convert_original_amount() }}
-
- - -@endsection \ No newline at end of file + +
+ + + + + + +
This is generated by computer. No signature required.Page {PAGENO} of {nbpg}
+
+@endsection