This commit is contained in:
Edmond Teh
2020-09-14 17:12:19 +08:00
parent 75bb7d0d9c
commit f7f62fb677
3 changed files with 202 additions and 248 deletions
+82 -71
View File
@@ -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('
<table width="100%">
<tr>
<td style="text-align: right; ">This is generated by computer. No signature required.</td>
<td style="text-align: right; ">Page {PAGENO} of {nbpg}</td>
</tr>
</table>
');
$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('
<table width="100%">
<tr>
<td style="text-align: right; ">This is generated by computer. No signature required.</td>
<td style="text-align: right; ">Page {PAGENO} of {nbpg}</td>
</tr>
</table>
');
$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
</tr>
</table>
');
$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('
<table width="100%">
<tr>
<td style="text-align: right; ">This is generated by computer. No signature required.</td>
<td style="text-align: right; ">Page {PAGENO} of {nbpg}</td>
</tr>
</table>
');
$mpdf->setHeader($invoice->edo);
$mpdf->WriteHTML($html);
$mpdf->Output();
+4 -14
View File
@@ -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;
}
</style>
</head>
@@ -125,10 +115,10 @@
</strong>
</div>
@if($detail['ei'])
<div class="number">EI#: {{$detail['ei']}}</div>
<div class="number">EI#: {{$detail['ei']}}</div>
@endif
@if($detail['edo'])
<div class="number">EDO#: {{$detail['edo']}}</div>
<div class="number">EDO#: {{$detail['edo']}}</div>
@endif
<div class="ref">Ref#: {{$detail['ref']}}</div>
<div class="date">Date: {{$detail['date']}}</div>
+116 -163
View File
@@ -4,214 +4,167 @@
<meta charset="UTF-8">
<title>document</title>
<style>
body {
font-family: noto sans-serif;
font-size: normal;
}
.details {
float: right;
max-width: 30%;
padding: 2em;
border: 1px solid black;
}
.buyer, .header {
max-width: 45%;
}
.seller, .doc-details {
max-width: 45%;
}
.doc-details {
padding: 1em;
border: 1px solid black;
}
.buyer-seller-container {
}
.buyer-company {
display: block;
font-size: 16px;
font-weight: bolder;
}
.reg {
display: block;
font-size: 14px;
}
.address {
display: block;
font-size: 14px;
word-wrap: break-word;
}
.gst {
display: block;
font-size: 14px;
}
.contact-no {
display: block;
font-size: 14px;
}
.seller {
width: 45%;
font-family: sun-extA;
overflow: wrap;
}
table {
width: 100%;
}
td.title {
text-align: left;
}
td.document-detail {
text-align: left;
border: 1px solid black;
padding: 1em 1em 1em 1em;
width: 16em;
}
.buyer-seller-title {
font-size: 1.2em;
font-weight: bolder;
}
td.description, th.description {
text-align: justify;
max-width: 40em;
}
td.stock-code, th.stock-code {
text-align: center;
}
th {
border-bottom: 1px solid black;
}
.clear-fix::after {
content: "";
clear: both;
display: table;
td.description, th.description {
text-align: justify;
}
td {
padding: 0.4em;
.total {
border-top: 1px solid black;
border-bottom: 3px double black;
font-weight: bolder;
}
.center {
text-align: center;
}
td.description, th.description {
text-align: left;
.middle {
vertical-align: middle;
}
td, th {
margin-top: 0.6em;
margin-right: 0.6em;
.top {
vertical-align: top;
}
.buyer-seller-title {
font-size: 1.2em;
margin-bottom: 0.2em;
td {
padding-bottom: 1em;
}
.subtotal td {
border-top: 1px solid black;
}
.total {
border-top: 1px solid black;
border-bottom: 1px double black;
font-weight: bolder;
}
</style>
</head>
<body>
<div class="clear-fix">
<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">
<table class="header">
<tr>
<td class="title">
<h1>
{{ $title }}
</h1>
</td>
<td class="document-detail">
PO#: {{$detail['po']}} <br>
Ref#: {{ $detail['ref'] }} <br>
Date: {{ $detail['date'] }}
</div>
<div class="contact-no">
Page: 1 of 1
</div>
</div>
</div>
</td>
</tr>
</table>
<br>
<div class="buyer-seller-container clear-fix">
<div class="buyer">
<div class="buyer-seller-title">
Buyer
</div>
@if($buyer['marking_no'])
<div class="buyer-company">
Marking#: {{$buyer['marking_no']}}
</div>
@endif
<span class="buyer-company">
{{ $buyer['buyer_company'] }}
</span>
<span class="reg">
{{ $buyer['reg_no'] }}
</span>
<span class="address">
{{ $buyer['address'] }}
</span>
<!-- <span class="gst">
GST: 12345678
</span> -->
<span class="contact-no">
Phone: {{ $buyer['phone'] }}
</span>
</div>
<div class="seller">
<div class="buyer-seller-title">
Seller
</div>
<span class="buyer-company">
{{ $seller['seller_company'] }}
</span>
<div class="address">
{{ $seller['address'] }}
</div>
@if($seller['phone'])
<div class="contact-no">
Phone: {{ $seller['phone'] }}
</div>
@endif
</div>
</div>
<br>
<br>
<br>
<table>
<caption>
<h3>Billing Detail</h3>
</caption>
<table class="buyer-seller">
<tr>
<td width="50%" class="top">
<span class="buyer-seller-title">
Buyer
</span>
<br>
@if($buyer['marking_no'])
<div class="buyer-company">
Marking#: {{$buyer['marking_no']}}
</div>
@endif
<span class="buyer-company">
{{ $buyer['buyer_company'] }}
</span>
<span class="reg">
({{ $buyer['reg_no'] }})
</span>
<br>
<span class="address">
{{ $buyer['address'] }}
</span>
<br>
<span class="contact-no">
Phone: {{ $buyer['phone'] }}
</span>
</td>
<td width="50%" class="top">
<span class="buyer-seller-title">
Seller
</span>
<br>
<span class="buyer-company">
{{ $seller['seller_company'] }}
</span>
<div class="address">
{{ $seller['address'] }}
</div>
@if($seller['phone'])
<div class="contact-no">
Phone: {{ $seller['phone'] }}
</div>
@endif
</td>
</tr>
</table>
<br>
<table class="line-table" style="overflow: wrap" autosize="1">
<thead>
<tr>
<th>No</th>
<th class="description">Stock Code</th>
<th width="5%" >No</th>
<th class="stock-code" width="10%">Stock Code</th>
<th class="description">Description</th>
<th>Quantity</th>
<th>Unit Price (RM)</th>
<th>Total Amount (RM)</th>
<th width="10%">Quantity</th>
<th width="12%">Unit Price (RM)</th>
<th width="10%">Total Amount<br>(RM)</th>
</tr>
</thead>
<tbody>
@foreach ($lines as $line)
<tr>
<td>{{$line->order}}</td>
<td class="description">{{$line->stock_code}}</td>
<td class="description">{{$line->description}}</td>
<td>{{$line->quantity}}</td>
<td>{{number_format($line->unit_price_rm, 2)}}</td>
<td>{{number_format($line->total, 2)}}</td>
<td width="5%" class="center top">{{$line->order}}</td>
<td class="stock-code top" width="10%">{{$line->stock_code}}</td>
<td class="description" >{{$line->description}}</td>
<td width="10%" class="center top">{{$line->quantity}}</td>
<td width="12%" class="center top">{{number_format($line->unit_price_rm, 2)}}</td>
<td width="20%" class="center top">{{number_format($line->total, 2)}}</td>
</tr>
@endforeach
</tbody>
<tfoot>
<tr class="subtotal">
<td colspan="4"></td>
<td>Subtotal</td>
<td>{{ number_format($amount, 2) }}</td>
<td class="center middle">Subtotal</td>
<td class="center middle">{{ number_format($amount, 2) }}</td>
</tr>
<tr>
<td colspan="4"></td>
<td>Total</td>
<td class="total">{{ number_format($amount, 2) }}</td>
<td class="center center middle">Total</td>
<td class="total center middle">{{ number_format($amount, 2) }}</td>
</tr>
</tfoot>
</table>
<br>
<div class="footer">
This is computer generated. No Company Chop &amp; Signature required.
</div>
</body>
</html>