loaded plants against user rights in production quantity page #436

Merged
jothi merged 1 commits from ranjith-dev into master 2026-03-04 10:25:17 +00:00
Showing only changes of commit 0e1accaaec - Show all commits

View File

@@ -163,11 +163,15 @@ class ProductionQuantityPage extends Page implements HasForms
return $form
->statePath('filters')
->schema([
Select::make('plant_id')
->options(Plant::pluck('name', 'id'))
// ->options(Plant::pluck('name', 'id'))
->label('Plant')
->reactive()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->required()
->columnSpan(1)
->default(function () {
@@ -419,13 +423,13 @@ class ProductionQuantityPage extends Page implements HasForms
$machineAgaPlant = Machine::where('plant_id', $plantId)->where('work_center', $this->mNam)->first();
if (!$machinenotAgaPlant) {
if (! $machinenotAgaPlant) {
Notification::make()
->title('Unknown WorkCenter')
->body("Work Center not found")
->body('Work Center not found')
->danger()
->send();
$this->form->fill([
$this->form->fill([
'plant_id' => $this->pId,
'machine_id' => $this->mNam,
'block_name' => $this->bNam,
@@ -440,9 +444,9 @@ class ProductionQuantityPage extends Page implements HasForms
// 'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
return;
}
else if (!$machineAgaPlant) {
} elseif (! $machineAgaPlant) {
Notification::make()
->title('Unknown WorkCenter')
->body("Work Center not found against plant code $PlaCo")
@@ -464,20 +468,20 @@ class ProductionQuantityPage extends Page implements HasForms
// 'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
return;
}
$rec = ProductionQuantity::where('plant_id', $plantId)->where('machine_id', $machineAgaPlant->id)->latest()->first();
if($rec)
{
if ($rec) {
$item = Item::where('id', $rec->item_id)->where('plant_id', $plantId)->first();
$itemCode = $item?->code ?? '';
$serialNo = $rec->serial_number ?? '';
$this->recQr = $itemCode . ' | ' . $serialNo;
$this->recQr = $itemCode.' | '.$serialNo;
}
@@ -1125,7 +1129,6 @@ class ProductionQuantityPage extends Page implements HasForms
$iCode = trim($splits[0]);
$sNumber = isset($splits[1]) ? trim($splits[1]) : null;
if (! ctype_alnum($iCode)) {
$this->form->fill([