From 579c795d0696094591be3511778557e6ce597760 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 16 Nov 2026 10:45:30 +0530 Subject: [PATCH] Added print panel 2 in production order controller --- .../Controllers/ProductionOrderController.php | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/app/Http/Controllers/ProductionOrderController.php b/app/Http/Controllers/ProductionOrderController.php index cb877867..ea22dc10 100644 --- a/app/Http/Controllers/ProductionOrderController.php +++ b/app/Http/Controllers/ProductionOrderController.php @@ -146,6 +146,65 @@ class ProductionOrderController extends Controller } } + public function printpanel2($production_order, $plantCode){ + + $order = ProductionOrder::where('production_order', $production_order)->first(); + + $wareHouseNo = Plant::where('code', $plantCode)->first(); + + $wareNo = $wareHouseNo->warehouse_number ?? null; + + if (!$order) { + abort(404, 'Production Order not found'); + } + else{ + $fromSerial = (int) $order->from_serial_number; + $toSerial = (int) $order->to_serial_number; + $itemCode = $order->item->code ?? ''; + $itemDes = $order->item->description ?? ''; + $now = Carbon::now(); + $year = $now->format('y'); + // $month = $now->format('m'); + // $month = $now->format('m'); + + $stickers = []; + + for ($i = $fromSerial; $i <= $toSerial; $i++) + { + + $currentSerial = (string) $i; + + $year = substr($currentSerial, -10, 2); + + $month = substr($currentSerial, -8, 2); + + $serial = str_pad($i, 6, '0', STR_PAD_LEFT); + $serialCount = substr(str_pad($i, 6, '0', STR_PAD_LEFT), -6); + + $qrData = $plantCode . $wareNo . '/' . $itemCode . '/' . $year.$month . '/' . $serialCount; + + $panel = $plantCode . $wareNo . '/' . $itemCode . '/' . $year.$month . '/' . $serialCount; + + $qrCode = new QrCode($qrData); + $output = new Output\Png; + $qrBinary = $output->output($qrCode, 100); + $qrBase64 = base64_encode($qrBinary); + + $stickers[] = [ + 'serial' => $panel, + 'qr' => 'data:image/png;base64,' . $qrBase64, + 'production_order' => $production_order, + 'description' => $itemDes ?? '' + ]; + } + + $pdf = Pdf::loadView('production-orders.printpanel2', compact('stickers')) + ->setPaper([0, 0, 113.39, 113.39]); + + return $pdf->stream('stickers.pdf'); + } + } + public function printitemserial($production_order, $plantCode) { $order = ProductionOrder::where('production_order', $production_order)->first();