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',