loaded plants against user rights in production quantity page #436
@@ -163,11 +163,15 @@ class ProductionQuantityPage extends Page implements HasForms
|
|||||||
return $form
|
return $form
|
||||||
->statePath('filters')
|
->statePath('filters')
|
||||||
->schema([
|
->schema([
|
||||||
|
|
||||||
Select::make('plant_id')
|
Select::make('plant_id')
|
||||||
->options(Plant::pluck('name', 'id'))
|
// ->options(Plant::pluck('name', 'id'))
|
||||||
->label('Plant')
|
->label('Plant')
|
||||||
->reactive()
|
->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()
|
->required()
|
||||||
->columnSpan(1)
|
->columnSpan(1)
|
||||||
->default(function () {
|
->default(function () {
|
||||||
@@ -419,13 +423,13 @@ class ProductionQuantityPage extends Page implements HasForms
|
|||||||
|
|
||||||
$machineAgaPlant = Machine::where('plant_id', $plantId)->where('work_center', $this->mNam)->first();
|
$machineAgaPlant = Machine::where('plant_id', $plantId)->where('work_center', $this->mNam)->first();
|
||||||
|
|
||||||
if (!$machinenotAgaPlant) {
|
if (! $machinenotAgaPlant) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Unknown WorkCenter')
|
->title('Unknown WorkCenter')
|
||||||
->body("Work Center not found")
|
->body('Work Center not found')
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $this->pId,
|
'plant_id' => $this->pId,
|
||||||
'machine_id' => $this->mNam,
|
'machine_id' => $this->mNam,
|
||||||
'block_name' => $this->bNam,
|
'block_name' => $this->bNam,
|
||||||
@@ -440,9 +444,9 @@ class ProductionQuantityPage extends Page implements HasForms
|
|||||||
// 'operator_id'=> $operatorName,
|
// 'operator_id'=> $operatorName,
|
||||||
'recent_qr' => $this->recQr,
|
'recent_qr' => $this->recQr,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} elseif (! $machineAgaPlant) {
|
||||||
else if (!$machineAgaPlant) {
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Unknown WorkCenter')
|
->title('Unknown WorkCenter')
|
||||||
->body("Work Center not found against plant code $PlaCo")
|
->body("Work Center not found against plant code $PlaCo")
|
||||||
@@ -464,20 +468,20 @@ class ProductionQuantityPage extends Page implements HasForms
|
|||||||
// 'operator_id'=> $operatorName,
|
// 'operator_id'=> $operatorName,
|
||||||
'recent_qr' => $this->recQr,
|
'recent_qr' => $this->recQr,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$rec = ProductionQuantity::where('plant_id', $plantId)->where('machine_id', $machineAgaPlant->id)->latest()->first();
|
$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();
|
$item = Item::where('id', $rec->item_id)->where('plant_id', $plantId)->first();
|
||||||
|
|
||||||
$itemCode = $item?->code ?? '';
|
$itemCode = $item?->code ?? '';
|
||||||
$serialNo = $rec->serial_number ?? '';
|
$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]);
|
$iCode = trim($splits[0]);
|
||||||
$sNumber = isset($splits[1]) ? trim($splits[1]) : null;
|
$sNumber = isset($splits[1]) ? trim($splits[1]) : null;
|
||||||
|
|
||||||
|
|
||||||
if (! ctype_alnum($iCode)) {
|
if (! ctype_alnum($iCode)) {
|
||||||
|
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
|
|||||||
Reference in New Issue
Block a user