Updated default plant load logic and auto focus enabled for invoice number #311
@@ -70,7 +70,10 @@ class InvoiceValidationResource extends Resource
|
|||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(InvoiceValidation::latest()->first())->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
return ($userHas && strlen($userHas) > 0) ? $userHas : optional(InvoiceValidation::latest()->first())->plant_id;
|
||||||
|
// return optional(InvoiceValidation::latest()->first())->plant_id;
|
||||||
})
|
})
|
||||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
// ->afterStateUpdated(fn ($set) => $set('block_id', null) & $set('name', null) & $set('start_time', null) & $set('duration', null) & $set('end_time', null))
|
// ->afterStateUpdated(fn ($set) => $set('block_id', null) & $set('name', null) & $set('start_time', null) & $set('duration', null) & $set('end_time', null))
|
||||||
@@ -118,8 +121,19 @@ class InvoiceValidationResource extends Resource
|
|||||||
// ->afterStateHydrated(function (TextInput $component, string $state) {
|
// ->afterStateHydrated(function (TextInput $component, string $state) {
|
||||||
// $component->state(ucwords($state));
|
// $component->state(ucwords($state));
|
||||||
// })
|
// })
|
||||||
|
->autofocus(function ($state, callable $set, callable $get) {
|
||||||
|
$plantId = $get('plant_id');
|
||||||
|
$sNo = $get('serial_number');
|
||||||
|
if (! $plantId || $sNo) {
|
||||||
|
return false;
|
||||||
|
} elseif ($plantId && ! $sNo) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$invNo = $get('invoice_number');
|
// $invNo = $get('invoice_number');
|
||||||
$set('serial_number', null);
|
$set('serial_number', null);
|
||||||
$set('update_invoice', null);
|
$set('update_invoice', null);
|
||||||
// Session::put('invoice_number', $state);
|
// Session::put('invoice_number', $state);
|
||||||
|
|||||||
Reference in New Issue
Block a user