Updated session forget func. and recent_qr func. and added sap_msg_status, sap_msg_description columns

This commit is contained in:
dhanabalan
2025-05-12 19:56:09 +05:30
parent 25f13a6d49
commit 79be8aec91

View File

@@ -37,7 +37,7 @@ class ProductionQuantityPage extends Page implements HasForms
public $qrData, $pId, $bId, $sId, $lId, $iId, $succId, $sNoId, $succStat, $recQr, $prodOrder;
public $recent_qr, $clear_qr;
// public $recent_qr, $clear_qr;
use HasFiltersForm;
@@ -45,6 +45,7 @@ class ProductionQuantityPage extends Page implements HasForms
public function mount(): void
{
session()->forget(['select_plant', 'select_line']);
session()->forget(['selected_plant', 'selected_line']);
$this->filtersForm->fill([
'plant' => null,
'line' => null,
@@ -71,7 +72,7 @@ class ProductionQuantityPage extends Page implements HasForms
padding: 0 !important;
max-width: 100% !important;
/* overflow-y: auto; Allow vertical scrolling */
height: 100vh; /* Ensure full height of the viewport */
height: 100vh;
}
/* Expand page area fully */
@@ -80,6 +81,22 @@ class ProductionQuantityPage extends Page implements HasForms
max-width: 100% !important;
}
/* Expand main container to full screen but add margin */
/* .fi-main {
margin: 0.5rem -0.5rem !important; Top/Bottom: 0.5rem, Left/Right: 0.2rem
padding: 0rem !important;
max-width: calc(100% - 0.1rem) !important; /* Matches horizontal margin
height: calc(100vh - 1rem); Matches vertical margin
box-sizing: border-box;
}*/
/* Expand page area fully within the main container */
/* .fi-main > .fi-page {
padding: 0.2rem !important;
max-width: calc(100% - 0.1rem) !important;
box-sizing: border-box;
} */
/* Allow scroll on body again */
body {
overflow: auto;
@@ -125,8 +142,6 @@ class ProductionQuantityPage extends Page implements HasForms
session(['select_plant' => $state]);
session()->forget(['selected_plant', 'selected_line']);
if (!$plantId)
{
$set('pqPlantError', 'Please select a plant first.');
@@ -339,11 +354,14 @@ class ProductionQuantityPage extends Page implements HasForms
->required(),
Hidden::make('success_msg')
->required(),
Hidden::make('item_id')
->required(),
Hidden::make('sap_msg_status'),
Hidden::make('sap_msg_description'),
TextInput::make('recent_qr')
->label('Last scanned QR')
->reactive()
->live()
->columnSpan(1)
// ->default(function () {
// // Get the latest 'item_id' foreign key from 'production_quantities' table
@@ -358,12 +376,14 @@ class ProductionQuantityPage extends Page implements HasForms
// // Get the latest 'serial_number' from 'production_quantities' table
// $serialNumber = $latestProductionQuantity->serial_number;
// dd($itemCode, $serialNumber);
// // Combine 'code' and 'serial_number' into the desired format
// return $itemCode && $serialNumber ? "{$itemCode} | {$serialNumber}" : null;
// // return $itemCode && $serialNumber ? "{$itemCode} | {$serialNumber}" : null;
// $this->recQr = $itemCode && $serialNumber ? "{$itemCode} | {$serialNumber}" : null;
// })
// ->default(fn () => $this->recent_qr)
->default(fn () => $this->recQr)
->readOnly(true),
TextInput::make('id')
@@ -383,7 +403,7 @@ class ProductionQuantityPage extends Page implements HasForms
//dd($formQRData);
//$formValues = [];
// This will get all form data from the request
$this->clear_qr = null;
//$this->clear_qr = null;
$this->qrData = null;
$this->iId = null;
$this->succId = null;
@@ -428,6 +448,15 @@ class ProductionQuantityPage extends Page implements HasForms
// return;
// }
$latestProductionQuantity = ProductionQuantity::latest()->first();
if ($latestProductionQuantity) {
$itemCode = optional(Item::find($latestProductionQuantity->item_id))->code;
$serialNumber = $latestProductionQuantity->serial_number;
$this->recQr = $itemCode && $serialNumber ? "{$itemCode} | {$serialNumber}" : null;
}
if (empty($formQRData)) {
$this->form->fill([
'plant_id'=> $this->pId,
@@ -438,9 +467,12 @@ class ProductionQuantityPage extends Page implements HasForms
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
Notification::make()
->title('Invalid QR')
->body("Scan the valid QR code.<br>(Ex: Item_Code|Serial_Number )")
@@ -460,6 +492,8 @@ class ProductionQuantityPage extends Page implements HasForms
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> null,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
@@ -480,6 +514,8 @@ class ProductionQuantityPage extends Page implements HasForms
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> null,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
@@ -500,6 +536,8 @@ class ProductionQuantityPage extends Page implements HasForms
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> null,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
@@ -520,6 +558,8 @@ class ProductionQuantityPage extends Page implements HasForms
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> null,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
@@ -540,6 +580,8 @@ class ProductionQuantityPage extends Page implements HasForms
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> null,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
@@ -561,6 +603,8 @@ class ProductionQuantityPage extends Page implements HasForms
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> null,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
@@ -583,6 +627,8 @@ class ProductionQuantityPage extends Page implements HasForms
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> null,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
@@ -637,6 +683,8 @@ class ProductionQuantityPage extends Page implements HasForms
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
@@ -659,6 +707,8 @@ class ProductionQuantityPage extends Page implements HasForms
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
@@ -704,6 +754,8 @@ class ProductionQuantityPage extends Page implements HasForms
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
@@ -741,6 +793,8 @@ class ProductionQuantityPage extends Page implements HasForms
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
@@ -766,6 +820,8 @@ class ProductionQuantityPage extends Page implements HasForms
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
@@ -814,6 +870,8 @@ class ProductionQuantityPage extends Page implements HasForms
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
@@ -858,6 +916,8 @@ class ProductionQuantityPage extends Page implements HasForms
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
@@ -883,6 +943,8 @@ class ProductionQuantityPage extends Page implements HasForms
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
@@ -909,6 +971,8 @@ class ProductionQuantityPage extends Page implements HasForms
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
@@ -925,6 +989,8 @@ class ProductionQuantityPage extends Page implements HasForms
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
@@ -952,6 +1018,8 @@ class ProductionQuantityPage extends Page implements HasForms
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
@@ -973,6 +1041,8 @@ class ProductionQuantityPage extends Page implements HasForms
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
@@ -994,6 +1064,8 @@ class ProductionQuantityPage extends Page implements HasForms
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
@@ -1016,6 +1088,8 @@ class ProductionQuantityPage extends Page implements HasForms
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
@@ -1039,6 +1113,8 @@ class ProductionQuantityPage extends Page implements HasForms
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
@@ -1061,6 +1137,8 @@ class ProductionQuantityPage extends Page implements HasForms
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
@@ -1084,6 +1162,8 @@ class ProductionQuantityPage extends Page implements HasForms
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
@@ -1113,6 +1193,8 @@ class ProductionQuantityPage extends Page implements HasForms
'serial_number'=> null,
'success_msg'=> 'Y',
'production_order'=> $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
@@ -1130,6 +1212,8 @@ class ProductionQuantityPage extends Page implements HasForms
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
@@ -1152,6 +1236,8 @@ class ProductionQuantityPage extends Page implements HasForms
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
@@ -1174,6 +1260,8 @@ class ProductionQuantityPage extends Page implements HasForms
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
@@ -1219,6 +1307,8 @@ class ProductionQuantityPage extends Page implements HasForms
'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,
]);