diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index 8366b760..26c7d722 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -349,13 +349,13 @@ class InvoiceController extends Controller $booking->admin_status = 7; $booking->save(); - $do = $this->CIEFToSupplierDO($request, $booking->id); + $do = $this->generateSupplierDo($request, $booking->id); Mail::raw( 'DO for booking no'.$booking->id, function($message) use ($do, $booking){ $message->from('info@cief-malaysia.com'); $message->to('uldvstar@gmail.com'); $message->subject('DO for booking no'.$booking->id); //Attach PDF doc - $message->attachData($do,'do_booking_no_'.$booking->id.'.pdf'); + $message->attachData($do->Output(),'do_booking_no_'.$booking->id.'.pdf'); }); if(!$booking) { @@ -371,8 +371,7 @@ class InvoiceController extends Controller } - public function customerToCIEFPO(Request $request, $id) - { + public function generateSupplierDo(Request $request, $id){ if (!is_numeric($id)) { return response()->json(["message" => "Invalid id. Id needs to be a number"], 400); } @@ -424,7 +423,7 @@ class InvoiceController extends Controller 'billingcharges' => $billing_charges, 'total' => $total ]; - + $defaultConfig = (new \Mpdf\Config\ConfigVariables())->getDefaults(); $fontDirs = $defaultConfig['fontDir']; $defaultFontConfig = (new \Mpdf\Config\FontVariables())->getDefaults(); @@ -440,7 +439,7 @@ class InvoiceController extends Controller $mpdf->SetTitle('Invoice'); $html = view('pdf/po', $data); - + $mpdf->Bookmark('Start of the document'); $mpdf->SetHTMLFooter(' @@ -453,6 +452,12 @@ class InvoiceController extends Controller $mpdf->setHeader($invoice->po_number); $mpdf->WriteHTML($html); + return $mpdf; + } + + public function customerToCIEFPO(Request $request, $id) + { + $mpdf = $this->generateSupplierDo($request, $id); $mpdf->Output(); }