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\SupplierBooking;
use App\SettingSupplier;
use App\Marking;
use App\User;
use PDF;
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
if ($request->user()->role === 'member') {
@@ -320,30 +322,34 @@ 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();
$marking = User::find($booking->user_id)->marking;
$data = [
'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_company' => $invoice->buyer_company,
'reg_no' => $invoice->reg_no,
'address' => $invoice->address,
'gst' => '',
'phone' => $invoice->contact_no
'phone' => $invoice->contact_no,
'marking_no' => $marking
],
'seller' => [
'seller_company' => 'CIEF Worldwide Sdn Bhd',
'seller_company' => 'CIEF Worldwide Sdn Bhd (1134596-M)',
'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
];
PDF::setOptions(['dpi' => 150, 'defaultFont' => 'courier']);
$pdf = PDF::loadView('pdf/po', $data);
@@ -352,74 +358,7 @@ class InvoiceController extends Controller
}
public function showpo() {
$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)
public function CIEFToSupplierDO(Request $request, $id)
{
// Booking Exist and Belongs to User or is Admin
if ($request->user()->role === 'member') {
@@ -438,25 +377,31 @@ 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();
$supplierbooking = SupplierBooking::where('booking_id', $id)->first();
$supplier = SettingSupplier::where('id', $supplierbooking->supplier_id)->first();
$data = [
'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_company' => $invoice->buyer_company,
'reg_no' => $invoice->reg_no,
'address' => $invoice->address,
'buyer_company' => 'CIEF Worldwide Sdn Bhd (1134596-M)',
'reg_no' => '',
'address' => 'Malaysia Global Innovation & Creativity Centre, Level
1 CWS, Block 3730, Persiaran APEC 63000
Cyberjaya.',
'gst' => '',
'phone' => $invoice->contact_no
'phone' => '018 2909252',
'marking_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
'seller_company' => $supplier->company_name,
'address' => '',
'phone' => '',
],
'lines' => $lines,
'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
@@ -508,15 +485,6 @@ class InvoiceController extends Controller
return $pdf->download('do.pdf');
}
// private invoiceExist($id)
// {
// }
// private invoiceStatus($id) {
// }
private function isUser($booking_id, $user_id) {
$booking = Booking::where([