From f5173d986147ed85ae96fcd1871b2d955adcc121 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 16 Feb 2026 13:00:55 +0530 Subject: [PATCH] Changed logic in production quantity page for last scanned qr --- app/Filament/Pages/ProductionQuantityPage.php | 36 ++++++++++++++++--- .../pages/production-quantity.blade.php | 6 ++-- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/app/Filament/Pages/ProductionQuantityPage.php b/app/Filament/Pages/ProductionQuantityPage.php index a4899f6..af6e40e 100644 --- a/app/Filament/Pages/ProductionQuantityPage.php +++ b/app/Filament/Pages/ProductionQuantityPage.php @@ -42,6 +42,8 @@ class ProductionQuantityPage extends Page implements HasForms public $qrData, $pId, $bId, $sId, $lId, $iId, $succId, $sNoId, $succStat, $recQr, $prodOrder, $workCenter, $mId; + public $recent_qr; + // public $recent_qr, $clear_qr; @@ -336,6 +338,33 @@ class ProductionQuantityPage extends Page implements HasForms Hidden::make('sap_msg_status'), Hidden::make('sap_msg_description'), + TextInput::make('recent_qr') + ->label('Last scanned QR') + ->reactive() + ->columnSpan(['default' => 1, 'sm' => 2]) + //->columnSpan(2) + // ->default(function () { + // // Get the latest 'item_id' foreign key from 'production_quantities' table + // $latestProductionQuantity = ProductionQuantity::latest()->first(); + // if (!$latestProductionQuantity) { + // return null; // Return null if no production quantities exist + // } + + // // Get the corresponding 'code' from 'items' table where 'id' matches 'item_id' + // $itemCode = optional(Item::find($latestProductionQuantity->item_id))->code; + + // // Get the latest 'serial_number' from 'production_quantities' table + // $serialNumber = $latestProductionQuantity->serial_number; + + // // Combine 'code' and 'serial_number' into the desired format + // // return $itemCode && $serialNumber ? "{$itemCode} | {$serialNumber}" : null; + + // $this->recQr = $itemCode && $serialNumber ? "{$itemCode} | {$serialNumber}" : null; + + // }) + ->default(fn () => $this->recQr) + ->readOnly(true), + TextInput::make('id') ->hidden() @@ -344,7 +373,7 @@ class ProductionQuantityPage extends Page implements HasForms ->default(Filament::auth()->user()->name), ]) // ->columns(6); - ->columns(['default' => 1, 'sm' => 7]); + ->columns(['default' => 1, 'sm' => 8]); } public function processMachine($value){ @@ -1353,13 +1382,13 @@ class ProductionQuantityPage extends Page implements HasForms $this->iId = null; - // Get line + block in one shot $line = Line::with('block')->find($lineId); $lineName = $line?->name; $blockName = $line?->block?->name; $shiftName = $shift?->name; + $this->recent_qr = $itemCode.' | '.$this->sNoId; // after success insertion $this->form->fill([ @@ -1369,14 +1398,13 @@ class ProductionQuantityPage extends Page implements HasForms 'shift_id'=> $shiftName, 'line_id'=> $lineName, 'item_id'=> null, - //'item_code'=> null, 'serial_number'=> null, 'success_msg'=> null, 'production_order'=> $this->prodOrder, 'sap_msg_status' => null, 'sap_msg_description' => null, 'operator_id'=> $operatorName, - 'recent_qr' => $itemCode.' | '.$this->sNoId, + 'recent_qr' => $this->recent_qr, ]); Notification::make() diff --git a/resources/views/filament/pages/production-quantity.blade.php b/resources/views/filament/pages/production-quantity.blade.php index cccbaac..7055dc7 100644 --- a/resources/views/filament/pages/production-quantity.blade.php +++ b/resources/views/filament/pages/production-quantity.blade.php @@ -45,7 +45,7 @@ --}}
-
+
@@ -60,7 +60,7 @@
-
+ {{--
@@ -71,7 +71,7 @@ readonly wire:model="recent_qr" /> -
+
--}}