before cief to customer do

This commit is contained in:
Edmond Teh
2020-09-09 18:31:22 +08:00
parent 3c204baee9
commit 4f313b9e72
6 changed files with 333 additions and 181 deletions
+65 -97
View File
@@ -16,6 +16,8 @@ use App\InvoiceDetails;
use App\InvoiceStatuses; use App\InvoiceStatuses;
use App\SupplierBooking; use App\SupplierBooking;
use App\SettingSupplier; use App\SettingSupplier;
use App\Marking;
use App\User;
use PDF; use PDF;
class InvoiceController extends Controller class InvoiceController extends Controller
@@ -301,7 +303,7 @@ class InvoiceController extends Controller
} }
public function getPO(Request $request, $id) public function customerToCIEFPO(Request $request, $id)
{ {
// Booking Exist and Belongs to User or is Admin // Booking Exist and Belongs to User or is Admin
if ($request->user()->role === 'member') { if ($request->user()->role === 'member') {
@@ -320,30 +322,34 @@ class InvoiceController extends Controller
$booking = Booking::where('id', $id)->first(); $booking = Booking::where('id', $id)->first();
$invoice = Invoice::where('booking_id', $booking['id'])->first(); $invoice = Invoice::where('booking_id', $booking['id'])->first();
$lines = InvoiceDetails::where('invoice_id', $invoice->id)->get(); $lines = InvoiceDetails::where('invoice_id', $invoice->id)->get();
$marking = User::find($booking->user_id)->marking;
$data = [ $data = [
'title' => 'Purchase Order', 'title' => 'Purchase Order',
'detail' => [
'date' => Carbon::createFromFormat('Y-m-d H:i:s', $booking->created_at)->format('d-m-Y'),
'po' => $invoice->po_number,
'do' => '',
'ref' => $booking->id
],
'buyer' => [ 'buyer' => [
'buyer_company' => $invoice->buyer_company, 'buyer_company' => $invoice->buyer_company,
'reg_no' => $invoice->reg_no, 'reg_no' => $invoice->reg_no,
'address' => $invoice->address, 'address' => $invoice->address,
'gst' => '', 'gst' => '',
'phone' => $invoice->contact_no 'phone' => $invoice->contact_no,
'marking_no' => $marking
], ],
'seller' => [ 'seller' => [
'seller_company' => 'CIEF Worldwide Sdn Bhd', 'seller_company' => 'CIEF Worldwide Sdn Bhd (1134596-M)',
'address' => 'Malaysia Global Innovation & Creativity Centre, Level 'address' => 'Malaysia Global Innovation & Creativity Centre, Level
1 CWS, Block 3730, Persiaran APEC 63000 1 CWS, Block 3730, Persiaran APEC 63000
Cyberjaya.', Cyberjaya.',
'phone' => '018 2909252', 'phone' => '018 2909252',
'date' => $invoice->updated_at,
'po_number' => $invoice->po_number,
'order_number' => $booking->order_no
], ],
'lines' => $lines, 'lines' => $lines,
'amount' => $invoice->amount 'amount' => $invoice->amount
]; ];
PDF::setOptions(['dpi' => 150, 'defaultFont' => 'courier']);
$pdf = PDF::loadView('pdf/po', $data); $pdf = PDF::loadView('pdf/po', $data);
@@ -352,74 +358,7 @@ class InvoiceController extends Controller
} }
public function showpo() { public function CIEFToSupplierDO(Request $request, $id)
$booking = Booking::where('id', 2018)->first();
$invoice = Invoice::where('booking_id', $booking['id'])->first();
$lines = InvoiceDetails::where('invoice_id', $invoice->id)->get();
$data = [
'title' => 'Delivery Order',
'buyer' => [
'buyer_company' => $invoice->buyer_company,
'reg_no' => $invoice->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.',
'phone' => '018 2909252',
'date' => $invoice->updated_at,
'po_number' => $invoice->po_number,
'order_number' => $booking->order_no
],
'lines' => $lines,
'amount' => $invoice->amount
];
// Send
return view('pdf/po', $data);
}
public function showdo() {
$booking = Booking::where('id', 2018)->first();
$invoice = Invoice::where('booking_id', $booking['id'])->first();
$lines = InvoiceDetails::where('invoice_id', $invoice->id)->get();
$data = [
'title' => 'Delivery Order',
'buyer' => [
'buyer_company' => $invoice->buyer_company,
'reg_no' => $invoice->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.',
'phone' => '018 2909252',
'date' => $invoice->updated_at,
'po_number' => $invoice->po_number,
'order_number' => $booking->order_no
],
'lines' => $lines,
'amount' => $invoice->amount
];
// Send
return view('pdf/do', $data);
}
public function getDO(Request $request, $id)
{ {
// Booking Exist and Belongs to User or is Admin // Booking Exist and Belongs to User or is Admin
if ($request->user()->role === 'member') { if ($request->user()->role === 'member') {
@@ -438,25 +377,31 @@ class InvoiceController extends Controller
$booking = Booking::where('id', $id)->first(); $booking = Booking::where('id', $id)->first();
$invoice = Invoice::where('booking_id', $booking['id'])->first(); $invoice = Invoice::where('booking_id', $booking['id'])->first();
$lines = InvoiceDetails::where('invoice_id', $invoice->id)->get(); $lines = InvoiceDetails::where('invoice_id', $invoice->id)->get();
$supplierbooking = SupplierBooking::where('booking_id', $id)->first();
$supplier = SettingSupplier::where('id', $supplierbooking->supplier_id)->first();
$data = [ $data = [
'title' => 'Delivery Order', 'title' => 'Delivery Order',
'detail' => [
'date' => Carbon::createFromFormat('Y-m-d H:i:s', $booking->created_at)->format('d-m-Y'),
'po' => $invoice->po_number,
'do' => '',
'ref' => $booking->id
],
'buyer' => [ 'buyer' => [
'buyer_company' => $invoice->buyer_company, 'buyer_company' => 'CIEF Worldwide Sdn Bhd (1134596-M)',
'reg_no' => $invoice->reg_no, 'reg_no' => '',
'address' => $invoice->address, 'address' => 'Malaysia Global Innovation & Creativity Centre, Level
1 CWS, Block 3730, Persiaran APEC 63000
Cyberjaya.',
'gst' => '', 'gst' => '',
'phone' => $invoice->contact_no 'phone' => '018 2909252',
'marking_no' => ''
], ],
'seller' => [ 'seller' => [
'seller_company' => 'CIEF Worldwide Sdn Bhd', 'seller_company' => $supplier->company_name,
'address' => 'Malaysia Global Innovation & Creativity Centre, Level 'address' => '',
1 CWS, Block 3730, Persiaran APEC 63000 'phone' => '',
Cyberjaya.',
'phone' => '018 2909252',
'date' => $invoice->updated_at,
'po_number' => $invoice->po_number,
'order_number' => $booking->order_no
], ],
'lines' => $lines, 'lines' => $lines,
'amount' => $invoice->amount 'amount' => $invoice->amount
@@ -469,7 +414,39 @@ class InvoiceController extends Controller
} }
public function getSupplierDO($id) 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();
$data = [
'title' => 'INVOICE',
'detail' => [
'date' => Carbon::createFromFormat('Y-m-d H:i:s', $booking->created_at)->format('d-m-Y'),
'ei' => 'EI-202009-000001',
'edo' => '',
'ref' => $booking->id
],
'billto' => [
'buyer_company' => $invoice->buyer_company,
'reg_no' => $invoice->reg_no,
'address' => $invoice->address,
'gst' => '',
'phone' => $invoice->contact_no,
'marking_no' => ''
],
'lines' => $lines,
'amount' => $invoice->amount
];
$pdf = PDF::loadView('pdf/invoice', $data);
// Send
return $pdf->download('invoice.pdf');
}
public function CIEFToCustomerDO($id)
{ {
// Generate PO // Generate PO
@@ -508,15 +485,6 @@ class InvoiceController extends Controller
return $pdf->download('do.pdf'); return $pdf->download('do.pdf');
} }
// private invoiceExist($id)
// {
// }
// private invoiceStatus($id) {
// }
private function isUser($booking_id, $user_id) { private function isUser($booking_id, $user_id) {
$booking = Booking::where([ $booking = Booking::where([
@@ -78,6 +78,9 @@
<button class="btn btn-primary" type="button" @click="onDownloadDO"> <button class="btn btn-primary" type="button" @click="onDownloadDO">
Download DO Download DO
</button> </button>
<button class="btn btn-info" type="button" @click="onDownloadInvoice">
Download Invoice
</button>
<button class="btn btn-warning" type="button" @click="onDownloadSupplier"> <button class="btn btn-warning" type="button" @click="onDownloadSupplier">
Download Supplier PO Download Supplier PO
</button> </button>
@@ -473,6 +476,22 @@ export default {
link.click() link.click()
}) })
.catch(err => console.error(JSON.stringify(err))) .catch(err => console.error(JSON.stringify(err)))
},
onDownloadInvoice () {
const url = '/api/invoice/' + this.booking_details.id + '/invoice'
axios({
url: url,
method: 'GET',
responseType: 'blob' // important
}).then(resp => {
const url = window.URL.createObjectURL(new Blob([resp.data]))
const link = document.createElement('a')
link.href = url
link.setAttribute('download', 'invoice.pdf')
document.body.appendChild(link)
link.click()
})
.catch(err => console.error(JSON.stringify(err)))
} }
}, },
directives: { directives: {
@@ -58,6 +58,9 @@
<button class="btn btn-primary" type="button" @click="onDownloadDO"> <button class="btn btn-primary" type="button" @click="onDownloadDO">
Download DO Download DO
</button> </button>
<button class="btn btn-info" type="button" @click="onDownloadInvoice">
Download Invoice
</button>
</div> </div>
</div> </div>
</div> </div>
@@ -252,6 +255,22 @@ export default {
link.click() link.click()
}) })
.catch(err => console.error(JSON.stringify(err))) .catch(err => console.error(JSON.stringify(err)))
},
onDownloadInvoice () {
const url = '/api/invoice/' + this.booking_details.id + '/invoice'
axios({
url: url,
method: 'GET',
responseType: 'blob' // important
}).then(resp => {
const url = window.URL.createObjectURL(new Blob([resp.data]))
const link = document.createElement('a')
link.href = url
link.setAttribute('download', 'invoice.pdf')
document.body.appendChild(link)
link.click()
})
.catch(err => console.error(JSON.stringify(err)))
} }
} }
} }
+159 -61
View File
@@ -1,71 +1,169 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html lang="en">
<head> <head>
<title></title> <title>Document</title>
<style> <style>
body {
font-family: simhei;
}
.clear-fix::after {
content: "";
clear: both;
display: table;
}
.letter-head {
float: left;
display: inline-block;
position: relative;
}
img.logo {
display: inline;
position: absolute;
top: 10px;
right: 0;
}
img {
height: 7em;
width: 18%;
}
.cief-address {
position: absolute;
left: 18%;
top: -30px;
}
.details {
position: absolute;
left: 78%;
top: -20px;
}
.title {
font-size: 2em;
font-weight: bolder;
}
.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%;
}
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 {
text-align: left;
}
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: 1px double black;
font-weight: bolder;
}
.address {
}
</style> </style>
</head> </head>
<body> <body>
<div class="header clear-fix">
<img src="https://firebasestorage.googleapis.com/v0/b/edmondtm-1d8ed.appspot.com/o/logo.png?alt=media&token=e8458dc5-b9cd-4db4-b2c9-b953c0b9d09e" alt="logo" id="logo">
<p class="cief-address">
<span class="company-name">CIEF WORLDWIDE SDN BHD</span>
<span class="company-reg">(1134596-M)</span><br>
Malaysian Global Innovation &amp; Creativity Center <br>
Level 1 CWS, Block 3730, Persiaran APEC, <br>
63000 Cyberjaya, Malaysian. <br>
Tel: 018-2909252
</p>
<div class="details">
<div class="title">{{$title}}</div>
@if($detail['ei'])
<div class="number">EI#: {{$detail['ei']}}</div>
@endif
@if($detail['edo'])
<div class="number">EDO#: {{$detail['edo']}}</div>
@endif
<div class="ref">Ref#: {{$detail['ref']}}</div>
<div class="date">Date: {{$detail['date']}}</div>
<div class="page">Page: 1 of 1</div>
</div>
</div>
<div class="bill-to sub-title">
Bill To
</div>
<div class="address">
<div class="label">
{{$billto['buyer_company']}}
</div>
<div class="address">
{{$billto['address']}}
</div>
<div>
Phone: {{$billto['phone']}}
</div>
</div>
<br>
<br>
<table> <table>
<tr> <thead>
<td> <tr>
<div class="letter-head" > <th>No</th>
<img src="https://firebasestorage.googleapis.com/v0/b/edmondtm-1d8ed.appspot.com/o/logo.png?alt=media&token=e8458dc5-b9cd-4db4-b2c9-b953c0b9d09e" alt="logo" id="logo"> <th class="description">Stock Code</th>
<p class="cief-address"> <th class="description">Description</th>
<span class="company-name">CIEF WORLDWIDE SDN BHD</span> <th>Quantity</th>
<span class="company-reg">1134596-M</span><br> <th>Unit Price (RM)</th>
Malaysian Global Innovation & Creativity Center <br> <th>Total Amount (RM)</th>
Level 1 CWS, Block 3730, Persiaran APEC, <br> </tr>
63000 Cyberjaya, Malaysian. <br> </thead>
Tel: 018-2909252 <tbody>
</p> @foreach ($lines as $line)
</div> <tr>
</td> <td>{{$line->order}}</td>
<td> <td class="description">{{$line->stock_code}}</td>
<div class="details"> <td class="description">{{$line->description}}</td>
<div class="document-name"> <td>{{$line->quantity}}</td>
INVOICE <td>{{number_format($line->unit_price_rm, 2)}}</td>
</div> <td>{{number_format($line->total, 2)}}</td>
<span class="document-number-title"> </tr>
EI No: @endforeach
</span> </tbody>
<span class="document-number"> <tfoot>
EI-1234566777 <tr class="subtotal">
</span> <td colspan="4"></td>
</div> <td>Subtotal</td>
</td> <td>{{ number_format($amount, 2) }}</td>
</tr> </tr>
<tr>
<td colspan="4"></td>
<td>Total</td>
<td class="total">{{ number_format($amount, 2) }}</td>
</tr>
</tfoot>
</table> </table>
<div class="header">
</div>
<div class="buyer-seller-container">
<div class="buyer">
<p class="marking-no">
<span class="label">Marking No:</span>
1234567
</p>
<p class="address">
Bill To:
<div class="company-name">AMK Store</div>
19, Jalan Cheras Indah 21,
Taman Cheras Indah,
56100 Kuala Lumpur
</p>
</div>
<div class="seller">
<p class="address">
Sell To:
<div class="company-name">AMK Store</div>
19, Jalan Cheras Indah 21,
Taman Cheras Indah,
56100 Kuala Lumpur
</p>
</div>
</div>
</body> </body>
</html> </html>
+67 -20
View File
@@ -13,14 +13,18 @@
padding: 2em; padding: 2em;
border: 1px solid black; border: 1px solid black;
} }
.buyer { .buyer, .header {
max-width: 45%; max-width: 45%;
float: left; float: left;
} }
.seller { .seller, .doc-details {
max-width: 45%; max-width: 45%;
float: right; float: right;
} }
.doc-details {
padding: 1em;
border: 1px solid black;
}
.buyer-seller-container { .buyer-seller-container {
} }
.buyer-company { .buyer-company {
@@ -52,6 +56,9 @@
width: 100%; width: 100%;
} }
th {
border-bottom: 1px solid black;
}
.clear-fix::after { .clear-fix::after {
content: ""; content: "";
clear: both; clear: both;
@@ -70,21 +77,59 @@
} }
.buyer-seller-title { .buyer-seller-title {
font-size: 1.2em; font-size: 1.2em;
/* text-decoration-line: underline; */
/* text-decoration-style: double; */
margin-bottom: 0.2em; margin-bottom: 0.2em;
} }
.subtotal td {
border-top: 1px solid black;
}
.total {
border-top: 1px solid black;
border-bottom: 1px double black;
font-weight: bolder;
}
</style> </style>
</head> </head>
<body> <body>
<div class="header"> <div class="clear-fix">
<h1>{{ $title }}</h1> <div class="header">
<h1>{{ $title }}</h1>
</div>
<div class="doc-details">
@if ($detail['po'])
<div class="contact-no">
PO#: {{ $detail['po'] }}
</div>
@endif
@if ($detail['do'])
<div class="contact-no">
DO#: {{ $detail['do'] }}
</div>
@endif
<div class="contact-no">
Ref#: {{ $detail['ref'] }}
</div>
<div class="contact-no">
Date: {{ $detail['date'] }}
</div>
<div class="contact-no">
Page: 1 of 1
</div>
</div>
</div> </div>
<br>
<div class="buyer-seller-container clear-fix"> <div class="buyer-seller-container clear-fix">
<div class="buyer"> <div class="buyer">
<div class="buyer-seller-title"> <div class="buyer-seller-title">
Buyer Buyer
</div> </div>
@if($buyer['marking_no'])
<div class="buyer-company">
Marking#: {{$buyer['marking_no']}}
</div>
@endif
<span class="buyer-company"> <span class="buyer-company">
{{ $buyer['buyer_company'] }} {{ $buyer['buyer_company'] }}
</span> </span>
@@ -111,24 +156,17 @@
<div class="address"> <div class="address">
{{ $seller['address'] }} {{ $seller['address'] }}
</div> </div>
@if($seller['phone'])
<div class="contact-no"> <div class="contact-no">
Phone: {{ $seller['phone'] }} Phone: {{ $seller['phone'] }}
</div> </div>
<div class="contact-no"> @endif
Date: {{ $seller['date'] }}
</div>
<div class="contact-no">
PO#: {{ $seller['po_number'] }}
</div>
<div class="contact-no">
Order#: {{ $seller['order_number'] }}
</div>
</div> </div>
</div> </div>
<br> <br>
<br> <br>
<br> <br>
{{$lines[0]->description}}
<table> <table>
<caption> <caption>
<h3>Billing Detail</h3> <h3>Billing Detail</h3>
@@ -136,6 +174,7 @@
<thead> <thead>
<tr> <tr>
<th>No</th> <th>No</th>
<th class="description">Stock Code</th>
<th class="description">Description</th> <th class="description">Description</th>
<th>Quantity</th> <th>Quantity</th>
<th>Unit Price (RM)</th> <th>Unit Price (RM)</th>
@@ -146,6 +185,7 @@
@foreach ($lines as $line) @foreach ($lines as $line)
<tr> <tr>
<td>{{$line->order}}</td> <td>{{$line->order}}</td>
<td class="description">{{$line->stock_code}}</td>
<td class="description">{{$line->description}}</td> <td class="description">{{$line->description}}</td>
<td>{{$line->quantity}}</td> <td>{{$line->quantity}}</td>
<td>{{number_format($line->unit_price_rm, 2)}}</td> <td>{{number_format($line->unit_price_rm, 2)}}</td>
@@ -154,18 +194,25 @@
@endforeach @endforeach
</tbody> </tbody>
<tfoot> <tfoot>
<tr> <tr class="subtotal">
<td colspan="3"></td> <td colspan="4"></td>
<td>Subtotal</td> <td>Subtotal</td>
<td>{{ number_format($amount, 2) }}</td> <td>{{ number_format($amount, 2) }}</td>
</tr> </tr>
<tr> <tr>
<td colspan="3"></td> <td colspan="4"></td>
<td>Total</td> <td>Total</td>
<td>{{ number_format($amount, 2) }}</td> <td class="total">{{ number_format($amount, 2) }}</td>
</tr> </tr>
</tfoot> </tfoot>
</table> </table>
<br>
<div class="footer">
This is computer generated. No Company Chop &amp; Signature required.
</div>
</body> </body>
</html> </html>
+4 -3
View File
@@ -53,8 +53,9 @@ Route::group(['middleware' => 'auth:api'], function () {
Route::get('invoice/{id}', 'InvoiceController@show'); Route::get('invoice/{id}', 'InvoiceController@show');
Route::post('invoice/{id}', 'InvoiceController@create'); Route::post('invoice/{id}', 'InvoiceController@create');
Route::put('invoice/{id}', 'InvoiceController@edit'); Route::put('invoice/{id}', 'InvoiceController@edit');
Route::get('invoice/{id}/po', 'InvoiceController@getPO'); Route::get('invoice/{id}/po', 'InvoiceController@customerToCIEFPO');
Route::get('invoice/{id}/do', 'InvoiceController@getDO'); Route::get('invoice/{id}/do', 'InvoiceController@CIEFToCustomerDO');
Route::get('invoice/{id}/invoice', 'InvoiceController@CIEFToCustomerInvoice');
//Route::get('notification/user', 'NotificationController@getUserMessage'); //Route::get('notification/user', 'NotificationController@getUserMessage');
//Route::post('notification/read-notification/{notification_id}', 'NotificationController@readNotification'); //Route::post('notification/read-notification/{notification_id}', 'NotificationController@readNotification');
@@ -142,7 +143,7 @@ Route::group(['middleware' => ['role:admin']], function() {
// New routes for invoice // New routes for invoice
Route::patch('invoice/{id}/status', 'InvoiceController@updateStatus'); Route::patch('invoice/{id}/status', 'InvoiceController@updateStatus');
Route::get('invoice/{id}/supplierdo', 'InvoiceController@getSupplierDO'); Route::get('invoice/{id}/supplierdo', 'InvoiceController@CIEFToSupplierDO');
Route::post('invoice/{id}/comment', 'InvoiceController@postStatus'); Route::post('invoice/{id}/comment', 'InvoiceController@postStatus');
Route::get('admin/complete-orders', 'BookingController@adminShowCompletedOrders'); Route::get('admin/complete-orders', 'BookingController@adminShowCompletedOrders');