From 3e04391342bfadbb26ec6c33a33b1c6c30ace9ac Mon Sep 17 00:00:00 2001 From: Edmond Teh Date: Mon, 7 Sep 2020 02:35:36 +0800 Subject: [PATCH] supplier do --- app/Http/Controllers/InvoiceController.php | 58 +- .../js/pages/admin/booking/completed.vue | 634 ++++++++++-------- .../assets/js/pages/booking/completed.vue | 2 +- routes/api.php | 2 +- 4 files changed, 395 insertions(+), 301 deletions(-) diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index 94356c43..fe7da199 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -14,6 +14,8 @@ use App\Booking; use App\Invoice; use App\InvoiceDetails; use App\InvoiceStatuses; +use App\SupplierBooking; +use App\SettingSupplier; use PDF; class InvoiceController extends Controller @@ -367,18 +369,18 @@ class InvoiceController extends Controller $data = [ 'title' => 'Delivery Order', 'buyer' => [ - 'buyer_company' => 'CIEF Worldwide Sdn Bhd', + 'buyer_company' => $invoice->buyer_company, 'reg_no' => '', + 'address' => $invoice->address, + 'gst' => '', + 'phone' => $invoice->contact_no + ], + 'seller' => [ + 'seller_company' => 'CIEF Worldwide Sdn Bhd', 'address' => 'Malaysia Global Innovation & Creativity Centre, Level 1 CWS, Block 3730, Persiaran APEC 63000 Cyberjaya.', - 'gst' => '', - 'phone' => '018 2909252' - ], - 'seller' => [ - 'seller_company' => $invoice->buyer_company, - 'address' => $invoice->address, - 'phone' => $invoice->contact_no, + 'phone' => '018 2909252', 'date' => $invoice->updated_at, 'po_number' => $invoice->po_number, 'order_number' => $booking->order_no @@ -396,13 +398,41 @@ class InvoiceController extends Controller public function getSupplierDO($id) { - // Only Admin Can get Supplier DO + // Generate PO - // Ensure Invoice Exist and Completed - - // Generate PO - - // Send + $booking = Booking::where('id', $id)->first(); + $invoice = Invoice::where('booking_id', $booking['id'])->first(); + $lines = InvoiceDetails::where('invoice_id', $invoice->id)->get(); + $supplierbooking = SupplierBooking::where('booking_id', $id)->first(); + $supplier = SettingSupplier::where('id', $supplierbooking->supplier_id)->first(); + + $data = [ + 'title' => 'Delivery Order', + 'buyer' => [ + 'buyer_company' => 'CIEF Worldwide Sdn Bhd', + 'reg_no' => '', + 'address' => 'Malaysia Global Innovation & Creativity Centre, Level + 1 CWS, Block 3730, Persiaran APEC 63000 + Cyberjaya.', + 'gst' => '', + 'phone' => '018 2909252' + ], + 'seller' => [ + 'seller_company' => $invoice->buyer_company, + 'address' => $supplier->company_name, + 'phone' => '', + 'date' => '', + 'po_number' => $invoice->po_number, + 'order_number' => $booking->order_no + ], + 'lines' => $lines, + 'amount' => $invoice->amount + ]; + $pdf = PDF::loadView('pdf/po', $data); + + + // Send + return $pdf->download('do.pdf'); } // private invoiceExist($id) diff --git a/resources/assets/js/pages/admin/booking/completed.vue b/resources/assets/js/pages/admin/booking/completed.vue index 6f3922b5..74af3821 100644 --- a/resources/assets/js/pages/admin/booking/completed.vue +++ b/resources/assets/js/pages/admin/booking/completed.vue @@ -21,11 +21,11 @@ -
- - +
+ +

Download

-
+
@@ -41,11 +41,11 @@
-
- - + @@ -54,21 +54,34 @@ -
- Invoice - +
+
+ Invoice + +
+ + + + + +
+
+ + +
- - - - - @@ -143,7 +156,7 @@
Beneficiary Account :
-
{{booking_details.account_name}}
+
{{ booking_details.account_name }}
@@ -151,7 +164,7 @@
Beneficiary Account Number :
-
{{booking_details.account_num}}
+
{{ booking_details.account_num }}
@@ -164,14 +177,14 @@ - +
-
-
+
+
@@ -207,7 +220,7 @@ -
+
MYR {{ booking_details.bia }}
@@ -223,7 +236,7 @@ --> -
+
@@ -233,10 +246,10 @@ -
+
-
+
@@ -249,7 +262,7 @@ - +
@@ -270,7 +283,7 @@
- +
Supplier Report @@ -278,9 +291,9 @@
- +
- Download Now + Download Now
@@ -292,8 +305,8 @@
- - + +

Download

@@ -309,8 +322,8 @@
- - + +

Download

@@ -336,257 +349,308 @@ .image:hover { box-shadow: 0 0 2px 1px rgba(0, 140, 186, 0.5); } + .btn-warning { + margin-top: 0.4em !important; + } \ No newline at end of file diff --git a/resources/assets/js/pages/booking/completed.vue b/resources/assets/js/pages/booking/completed.vue index b36c3c3d..db496a33 100644 --- a/resources/assets/js/pages/booking/completed.vue +++ b/resources/assets/js/pages/booking/completed.vue @@ -247,7 +247,7 @@ export default { const url = window.URL.createObjectURL(new Blob([resp.data])) const link = document.createElement('a') link.href = url - link.setAttribute('download', 'po.pdf') + link.setAttribute('download', 'do.pdf') document.body.appendChild(link) link.click() }) diff --git a/routes/api.php b/routes/api.php index 413aef28..8d8e3706 100644 --- a/routes/api.php +++ b/routes/api.php @@ -140,7 +140,7 @@ Route::group(['middleware' => ['role:admin']], function() { // New routes for invoice Route::patch('invoice/{id}/status', 'InvoiceController@updateStatus'); - Route::get('invoice/{id}/supplierdo', 'InvoiceController@supplierDO'); + Route::get('invoice/{id}/supplierdo', 'InvoiceController@getSupplierDO'); Route::post('invoice/{id}/comment', 'InvoiceController@postStatus'); Route::get('admin/complete-orders', 'BookingController@adminShowCompletedOrders');