From e09a362c964379b822c9560286bf0cf2987ba4d2 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 20 May 2026 12:50:45 +0530 Subject: [PATCH] Added ware house number logic for item code print logic --- .../Controllers/ProductionOrderController.php | 26 ++++++++++++++++--- routes/web.php | 2 +- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/ProductionOrderController.php b/app/Http/Controllers/ProductionOrderController.php index 12349af..d0d95b7 100644 --- a/app/Http/Controllers/ProductionOrderController.php +++ b/app/Http/Controllers/ProductionOrderController.php @@ -80,7 +80,8 @@ class ProductionOrderController extends Controller $wareHouseNo = Plant::where('code', $plantCode)->first(); - $wareNo = $wareHouseNo->warehouse_number; + $wareNo = $wareHouseNo->warehouse_number ?? null; + \Log::info('Plant Data', [ 'plant' => $wareHouseNo ? $wareHouseNo->toArray() : null, @@ -135,7 +136,7 @@ class ProductionOrderController extends Controller } } - public function printitemserial($production_order) + public function printitemserial($production_order, $plantCode) { $order = ProductionOrder::where('production_order', $production_order)->first(); @@ -148,6 +149,14 @@ class ProductionOrderController extends Controller $itemCode = $order->item->code ?? ''; $itemDes = $order->item->description ?? ''; + $wareHouseNo = Plant::where('code', $plantCode)->first(); + + $wareNo = $wareHouseNo->warehouse_number ?? null; + + $now = Carbon::now(); + $year = $now->format('y'); + $month = $now->format('m'); + $stickers = []; for ($i = $fromSerial; $i <= $toSerial; $i++) @@ -155,7 +164,16 @@ class ProductionOrderController extends Controller $serial = str_pad($i, 6, '0', STR_PAD_LEFT); - $qrData = $itemCode . '|' . $serial; + // $qrData = $itemCode . '|' . $serial; + + $serial = str_pad($i, 6, '0', STR_PAD_LEFT); + $serialCount = substr(str_pad($i, 6, '0', STR_PAD_LEFT), -6); + + $serialWithWarehouse = substr($serial, 0, 4) . $wareNo . substr($serial, 4); + + $qrData = $itemCode . '|' . $serialWithWarehouse; + + // $panel = $plantCode . $wareNo . '/' . $itemCode . '/' . $year.$month . '/' . $serialCount; // $qrBase64 = base64_encode( // QrCode::format('png')->size(100)->generate($qrData) @@ -168,7 +186,7 @@ class ProductionOrderController extends Controller $qrBase64 = base64_encode($qrBinary); $stickers[] = [ - 'serial' => $serial, + 'serial' => $serialWithWarehouse, 'qr' => 'data:image/png;base64,' . $qrBase64, 'production_order' => $itemCode, 'description' => $itemDes ?? '' diff --git a/routes/web.php b/routes/web.php index 71ddd38..32ecd52 100644 --- a/routes/web.php +++ b/routes/web.php @@ -61,7 +61,7 @@ Route::get('production-orders/{production_order}/{plant_code}/printpanel', [ProductionOrderController::class, 'printpanel'] )->name('production-orders.printpanel'); -Route::get('production-orders/{production_order}/printItemSerial', +Route::get('production-orders/{production_order}/{plant_code}/printItemSerial', [ProductionOrderController::class, 'printItemSerial'] )->name('production-orders.printItemSerial');