add new fields into pdf

This commit is contained in:
Edmond Teh
2020-09-26 01:27:59 +08:00
parent 56f288e05c
commit 8539110359
3 changed files with 79 additions and 21 deletions
+35 -9
View File
@@ -359,17 +359,16 @@ class InvoiceController extends Controller
}
}
// Ensure Invoice Status is Approve
// if ($this->invoiceStatus($id) !== 'approve') {
// return response()->json(['message' => 'Invoice must and exist and approve status.'], 403);
// }
// Generate PO
$booking = Booking::where('id', $id)->first();
$invoice = Invoice::where('booking_id', $booking['id'])->first();
$lines = InvoiceDetails::where('invoice_id', $invoice->id)->get();
$marking = User::find($booking->user_id)->marking;
$subtotal = InvoiceDetails::where('invoice_id', $invoice->id)->sum('total');
$adjustment = $invoice->adjustment;
$billing_charges = $booking->billing_charge;
$total = $subtotal + $adjustment + $billing_charges;
$data = [
'title' => 'Purchase Order',
@@ -395,7 +394,10 @@ class InvoiceController extends Controller
'phone' => '018 2909252',
],
'lines' => $lines,
'amount' => $invoice->amount
'subtotal' => $subtotal,
'adjustment' => $adjustment,
'billingcharges' => $billing_charges,
'total' => $total
];
$defaultConfig = (new \Mpdf\Config\ConfigVariables())->getDefaults();
@@ -456,6 +458,10 @@ class InvoiceController extends Controller
$lines = InvoiceDetails::where('invoice_id', $invoice->id)->get();
$supplierbooking = SupplierBooking::where('booking_id', $id)->first();
$supplier = SettingSupplier::where('id', $supplierbooking->supplier_id)->first();
$subtotal = InvoiceDetails::where('invoice_id', $invoice->id)->sum('total');
$adjustment = $invoice->adjustment;
$billing_charges = $booking->billing_charge;
$total = $subtotal + $adjustment + $billing_charges;
$data = [
'title' => 'Delivery Order',
@@ -481,7 +487,10 @@ class InvoiceController extends Controller
'phone' => '',
],
'lines' => $lines,
'amount' => $invoice->amount
'subtotal' => $subtotal,
'adjustment' => $adjustment,
'billingcharges' => $billing_charges,
'total' => $total
];
$defaultConfig = (new \Mpdf\Config\ConfigVariables())->getDefaults();
$fontDirs = $defaultConfig['fontDir'];
@@ -532,6 +541,11 @@ class InvoiceController extends Controller
$booking = Booking::where('id', $id)->first();
$invoice = Invoice::where('booking_id', $booking['id'])->first();
$lines = InvoiceDetails::where('invoice_id', $invoice->id)->get();
$subtotal = InvoiceDetails::where('invoice_id', $invoice->id)->sum('total');
$adjustment = $invoice->adjustment;
$billing_charges = $booking->billing_charge;
$total = $subtotal + $adjustment + $billing_charges;
$data = [
'title' => 'Invoice',
@@ -551,7 +565,10 @@ class InvoiceController extends Controller
],
'total_page' => (count($lines) / 10),
'lines' => $lines,
'amount' => $invoice->amount
'subtotal' => $subtotal,
'adjustment' => $adjustment,
'billingcharges' => $billing_charges,
'total' => $total
];
$defaultConfig = (new \Mpdf\Config\ConfigVariables())->getDefaults();
@@ -603,6 +620,11 @@ class InvoiceController extends Controller
$booking = Booking::where('id', $id)->first();
$invoice = Invoice::where('booking_id', $booking['id'])->first();
$lines = InvoiceDetails::where('invoice_id', $invoice->id)->get();
$subtotal = InvoiceDetails::where('invoice_id', $invoice->id)->sum('total');
$adjustment = $invoice->adjustment;
$billing_charges = $booking->billing_charge;
$total = $subtotal + $adjustment + $billing_charges;
$data = [
'title' => 'Delivery Order',
@@ -621,7 +643,10 @@ class InvoiceController extends Controller
'marking_no' => ''
],
'lines' => $lines,
'amount' => $invoice->amount
'subtotal' => $subtotal,
'adjustment' => $adjustment,
'billingcharges' => $billing_charges,
'total' => $total
];
$defaultConfig = (new \Mpdf\Config\ConfigVariables())->getDefaults();
@@ -629,6 +654,7 @@ class InvoiceController extends Controller
$defaultFontConfig = (new \Mpdf\Config\FontVariables())->getDefaults();
$fontData = $defaultFontConfig['fontdata'];
$mpdf = new \Mpdf\Mpdf([
'fontDir' => array_merge($fontDirs, [
__DIR__ . '/custom/font/directory',
+22 -7
View File
@@ -87,6 +87,9 @@
td.address {
text-align: left;
}
.right {
text-align: right;
}
</style>
</head>
@@ -169,26 +172,38 @@
<td class="description" >{{$line->description}}</td>
<td width="10%">{{$line->quantity}}</td>
<td width="12%">{{number_format($line->unit_price_rm, 2)}}</td>
<td width="20%">{{number_format($line->total, 2)}}</td>
<td width="20%" class="right">{{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="right">Subtotal</td>
<td class="right">{{ number_format($subtotal, 2) }}</td>
</tr>
@if($adjustment)
<tr class="adjustment">
<td colspan="3"></td>
<td colspan="2" class="right">Adjustment</td>
<td class="right">{{ number_format($adjustment, 2) }}</td>
</tr>
@endif
@if($billingcharges)
<tr class="billingcharges">
<td colspan="4"></td>
<td class="right">Billing Charges</td>
<td class="right">{{ number_format($billingcharges, 2) }}</td>
</tr>
@endif
<tr>
<td colspan="4"></td>
<td>Total</td>
<td class="total">{{ number_format($amount, 2) }}</td>
<td class="right">Total</td>
<td class="total right">{{ number_format($total, 2) }}</td>
</tr>
</tfoot>
</table>
</body>
</html>
+22 -5
View File
@@ -46,6 +46,9 @@
.center {
text-align: center;
}
.right {
text-align: right;
}
.middle {
vertical-align: middle;
}
@@ -147,20 +150,34 @@
<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>
<td width="20%" class="right top">{{number_format($line->total, 2)}}</td>
</tr>
@endforeach
</tbody>
<tfoot>
<tr class="subtotal">
<td colspan="4"></td>
<td class="center middle">Subtotal</td>
<td class="center middle">{{ number_format($amount, 2) }}</td>
<td class="right middle">Subtotal</td>
<td class="right middle">{{ number_format($subtotal, 2) }}</td>
</tr>
@if($adjustment)
<tr class="adjustment">
<td colspan="4"></td>
<td class="right middle">Adjustment</td>
<td class="right middle">{{ number_format($adjustment, 2) }}</td>
</tr>
@endif
@if($billingcharges)
<tr class="billingcharges">
<td colspan="4"></td>
<td class="right middle">Billing Charges</td>
<td class="right middle">{{ number_format($billingcharges, 2) }}</td>
</tr>
@endif
<tr>
<td colspan="4"></td>
<td class="center center middle">Total</td>
<td class="total center middle">{{ number_format($amount, 2) }}</td>
<td class="right middle">Total</td>
<td class="total right middle">{{ number_format($total, 2) }}</td>
</tr>
</tfoot>
</table>