diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index abe9c607..b33e6fbd 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -20,6 +20,7 @@ use App\SettingSupplier; use App\Marking; use App\User; use PDF; +use ZipArchive; class InvoiceController extends Controller { @@ -349,8 +350,8 @@ class InvoiceController extends Controller $booking->admin_status = 7; $booking->save(); - $do = $this->generateSupplierDo($request, $booking->id); - Mail::raw( 'DO for booking no'.$booking->id.' '.$do->Output('do.pdf', 'S'), function($message) use ($do, $booking){ + + 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); @@ -373,17 +374,7 @@ class InvoiceController extends Controller } - public function generateSupplierDo(Request $request, $id){ - if (!is_numeric($id)) { - return response()->json(["message" => "Invalid id. Id needs to be a number"], 400); - } - - // Booking Exist and Belongs to User or is Admin - if ($request->user()->role === 'member') { - if (!$this->isUser($id, $request->user()->id)) { - return response()->json(['message' => 'The PO Does not belongs to you.'], 403); - } - } + public function generateSupplierDo($id){ // Generate PO @@ -459,7 +450,18 @@ class InvoiceController extends Controller public function customerToCIEFPO(Request $request, $id) { - $mpdf = $this->generateSupplierDo($request, $id); + if (!is_numeric($id)) { + return response()->json(["message" => "Invalid id. Id needs to be a number"], 400); + } + + // Booking Exist and Belongs to User or is Admin + if ($request->user()->role === 'member') { + if (!$this->isUser($id, $request->user()->id)) { + return response()->json(['message' => 'The PO Does not belongs to you.'], 403); + } + } + + $mpdf = $this->generateSupplierDo($id); $mpdf->Output(); }