Added view rights against plant on view report and Updated alignments on resource
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 10s

This commit is contained in:
dhanabalan
2026-01-14 11:02:25 +05:30
parent 75d87cda29
commit 0a69d515a4

View File

@@ -5,30 +5,28 @@ namespace App\Filament\Resources;
use App\Filament\Exports\ReworkLocatorInvoiceValidationExporter; use App\Filament\Exports\ReworkLocatorInvoiceValidationExporter;
use App\Filament\Imports\ReworkLocatorInvoiceValidationImporter; use App\Filament\Imports\ReworkLocatorInvoiceValidationImporter;
use App\Filament\Resources\ReworkLocatorInvoiceValidationResource\Pages; use App\Filament\Resources\ReworkLocatorInvoiceValidationResource\Pages;
use App\Filament\Resources\ReworkLocatorInvoiceValidationResource\RelationManagers;
use App\Models\InvoiceValidation;
use App\Models\LocatorInvoiceValidation; use App\Models\LocatorInvoiceValidation;
use App\Models\PalletValidation; use App\Models\PalletValidation;
use App\Models\Plant; use App\Models\Plant;
use App\Models\ReworkLocatorInvoiceValidation; use App\Models\ReworkLocatorInvoiceValidation;
use Filament\Facades\Filament; use Filament\Facades\Filament;
use Filament\Forms; use Filament\Forms;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\ToggleButtons;
use Filament\Forms\Form; use Filament\Forms\Form;
use Filament\Forms\Get;
use Filament\Notifications\Notification;
use Filament\Resources\Resource; use Filament\Resources\Resource;
use Filament\Tables; use Filament\Tables;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Filters\Filter;
use Filament\Tables\Table; use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope; use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\ToggleButtons;
use Filament\Forms\Get;
use Filament\Notifications\Notification;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction;
use Filament\Forms\Components\DateTimePicker;
use Filament\Tables\Filters\Filter;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Select;
class ReworkLocatorInvoiceValidationResource extends Resource class ReworkLocatorInvoiceValidationResource extends Resource
{ {
@@ -54,20 +52,18 @@ class ReworkLocatorInvoiceValidationResource extends Resource
->required() ->required()
->options(function (callable $get) { ->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id; $userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray(); return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
}) })
->afterStateUpdated(function ($state, callable $set, callable $get) { ->afterStateUpdated(function ($state, callable $set, callable $get) {
$plantId = $get('plant_id'); $plantId = $get('plant_id');
if ($plantId) if ($plantId) {
{
$set('plant', $plantId); $set('plant', $plantId);
$set('invoice_number', null); $set('invoice_number', null);
$set('scan_pallet_no', null); $set('scan_pallet_no', null);
$set('scan_serial_no', null); $set('scan_serial_no', null);
$set('rework_type', null); $set('rework_type', null);
} } else {
else
{
$set('plant', null); $set('plant', null);
$set('invoice_number', null); $set('invoice_number', null);
$set('scan_pallet_no', null); $set('scan_pallet_no', null);
@@ -79,8 +75,8 @@ class ReworkLocatorInvoiceValidationResource extends Resource
->reactive(), ->reactive(),
Forms\Components\TextInput::make('invoice_number') Forms\Components\TextInput::make('invoice_number')
->label('Scan Invoice No') ->label('Scan Invoice No')
->required( fn ($get) => $get('rework_type') == 'invoice') ->required(fn ($get) => $get('rework_type') == 'invoice')
->readOnly(fn (callable $get) => (!$get('plant') || $get('rework_type') != 'invoice' || $get('scan_pallet_no') || $get('scan_serial_no'))) ->readOnly(fn (callable $get) => (! $get('plant') || $get('rework_type') != 'invoice' || $get('scan_pallet_no') || $get('scan_serial_no')))
// ->readOnly(fn ($get) => $get('rework_type') == 'pallet') // ->readOnly(fn ($get) => $get('rework_type') == 'pallet')
->reactive() ->reactive()
->extraAttributes([ ->extraAttributes([
@@ -88,17 +84,17 @@ class ReworkLocatorInvoiceValidationResource extends Resource
]), ]),
Forms\Components\TextInput::make('scan_pallet_no') Forms\Components\TextInput::make('scan_pallet_no')
->label('Scan Pallet No') ->label('Scan Pallet No')
->required( fn ($get) => $get('rework_type') == 'pallet') ->required(fn ($get) => $get('rework_type') == 'pallet')
->readOnly(fn ($get) => $get('rework_type') == 'invoice') ->readOnly(fn ($get) => $get('rework_type') == 'invoice')
->minLength(10) ->minLength(10)
->reactive() ->reactive()
->readOnly(fn (callable $get) => (!$get('plant') || !$get('rework_type') || ($get('rework_type') == 'invoice' && !$get('invoice_number')) || $get('scan_serial_no'))) ->readOnly(fn (callable $get) => (! $get('plant') || ! $get('rework_type') || ($get('rework_type') == 'invoice' && ! $get('invoice_number')) || $get('scan_serial_no')))
->extraAttributes([ ->extraAttributes([
'wire:keydown.enter' => 'processPalletno($event.target.value)', 'wire:keydown.enter' => 'processPalletno($event.target.value)',
]), ]),
Forms\Components\TextInput::make('scan_serial_no') Forms\Components\TextInput::make('scan_serial_no')
->label('Scan Serial No') ->label('Scan Serial No')
->readOnly(fn (callable $get) => (!$get('plant') || !$get('rework_type') || ($get('rework_type') == 'invoice' && !$get('invoice_number')) || ($get('rework_type') == 'invoice' && $get('scan_pallet_no')) || ($get('rework_type') == 'pallet' && !$get('scan_pallet_no')))) ->readOnly(fn (callable $get) => (! $get('plant') || ! $get('rework_type') || ($get('rework_type') == 'invoice' && ! $get('invoice_number')) || ($get('rework_type') == 'invoice' && $get('scan_pallet_no')) || ($get('rework_type') == 'pallet' && ! $get('scan_pallet_no'))))
->minLength(9) ->minLength(9)
->reactive() ->reactive()
->extraAttributes([ ->extraAttributes([
@@ -113,7 +109,7 @@ class ReworkLocatorInvoiceValidationResource extends Resource
->reactive() ->reactive()
->required() ->required()
->disabled(fn (Get $get) => ($get('invoice_number') || $get('scan_pallet_no') || $get('scan_serial_no'))) ->disabled(fn (Get $get) => ($get('invoice_number') || $get('scan_pallet_no') || $get('scan_serial_no')))
->hidden(fn (callable $get) => !$get('plant')) ->hidden(fn (callable $get) => ! $get('plant'))
->inline() ->inline()
->inlineLabel(false) ->inlineLabel(false)
// ->default('invoice') // ->default('invoice')
@@ -128,8 +124,7 @@ class ReworkLocatorInvoiceValidationResource extends Resource
$set('invoice_number', null); $set('invoice_number', null);
$set('scan_pallet_no', null); $set('scan_pallet_no', null);
$set('scan_serial_no', null); $set('scan_serial_no', null);
} } else {
else {
$set('reworkType', null); $set('reworkType', null);
$set('invoice_number', null); $set('invoice_number', null);
$set('scan_pallet_no', null); $set('scan_pallet_no', null);
@@ -144,7 +139,7 @@ class ReworkLocatorInvoiceValidationResource extends Resource
->boolean() ->boolean()
->grouped() ->grouped()
->reactive() ->reactive()
->hidden(fn (callable $get) => (!$get('plant') || $get('rework_type') != 'invoice' || !$get('invoice_number') || $get('update_invoice') == '0' || $get('scan_pallet_no') || $get('scan_serial_no'))) ->hidden(fn (callable $get) => (! $get('plant') || $get('rework_type') != 'invoice' || ! $get('invoice_number') || $get('update_invoice') == '0' || $get('scan_pallet_no') || $get('scan_serial_no')))
->afterStateUpdated(function ($state, callable $set, callable $get, $livewire) { ->afterStateUpdated(function ($state, callable $set, callable $get, $livewire) {
$plantId = $get('plant'); $plantId = $get('plant');
@@ -156,23 +151,21 @@ class ReworkLocatorInvoiceValidationResource extends Resource
$notCompletedCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber) $notCompletedCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)
->where('plant_id', $plantId) ->where('plant_id', $plantId)
->where(function($query) { ->where(function ($query) {
$query->whereNull('scanned_status') $query->whereNull('scanned_status')
->orWhere('scanned_status', ''); ->orWhere('scanned_status', '');
}) })
->count(); ->count();
$isScanningComplete = true; $isScanningComplete = true;
foreach ($rows as $row) foreach ($rows as $row) {
{
if ($row->scanned_status != 'Scanned') { if ($row->scanned_status != 'Scanned') {
$isScanningComplete = false; $isScanningComplete = false;
break; break;
} }
} }
if (!$isScanningComplete) if (! $isScanningComplete) {
{
Notification::make() Notification::make()
->title("Scanned invoice number: '$invoiceNumber' does not completed the scanning process!<br>Has '$notCompletedCount' pending serial number to scan!<br>Please, scan the valid completed invoice number to proceed...") ->title("Scanned invoice number: '$invoiceNumber' does not completed the scanning process!<br>Has '$notCompletedCount' pending serial number to scan!<br>Please, scan the valid completed invoice number to proceed...")
->danger() ->danger()
@@ -181,6 +174,7 @@ class ReworkLocatorInvoiceValidationResource extends Resource
$set('invoice_number', null); $set('invoice_number', null);
$set('update_invoice', null); $set('update_invoice', null);
return; return;
} }
}), }),
@@ -190,7 +184,7 @@ class ReworkLocatorInvoiceValidationResource extends Resource
->boolean() ->boolean()
->grouped() ->grouped()
->reactive() ->reactive()
->hidden(fn (callable $get) => (!$get('plant') || $get('rework_type') != 'pallet' || $get('update_pallet') == '0' || !$get('scan_pallet_no') || $get('scan_serial_no'))) ->hidden(fn (callable $get) => (! $get('plant') || $get('rework_type') != 'pallet' || $get('update_pallet') == '0' || ! $get('scan_pallet_no') || $get('scan_serial_no')))
->afterStateUpdated(function ($state, callable $set, callable $get, $livewire) { ->afterStateUpdated(function ($state, callable $set, callable $get, $livewire) {
$plantId = $get('plant'); $plantId = $get('plant');
@@ -198,15 +192,13 @@ class ReworkLocatorInvoiceValidationResource extends Resource
$serialNo = trim($get('scan_serial_no')); $serialNo = trim($get('scan_serial_no'));
$updatePalletStatus = $get('update_pallet') ?? null; $updatePalletStatus = $get('update_pallet') ?? null;
if ($updatePalletStatus == 0) if ($updatePalletStatus == 0) {
{
return; return;
} }
if (strlen($palletNumber) < 10) if (strlen($palletNumber) < 10) {
{
Notification::make() Notification::make()
->title("Invalid: Pallet Number") ->title('Invalid: Pallet Number')
->body("Pallet number '$palletNumber' must be at least 10 digits.") ->body("Pallet number '$palletNumber' must be at least 10 digits.")
->danger() ->danger()
->duration(5000) ->duration(5000)
@@ -216,13 +208,13 @@ class ReworkLocatorInvoiceValidationResource extends Resource
$set('scan_serial_no', null); $set('scan_serial_no', null);
$set('scan_pallet_no', null); $set('scan_pallet_no', null);
$set('update_pallet', null); $set('update_pallet', null);
return; return;
} }
$PalletSerialNumbers = PalletValidation::where('plant_id', $plantId)->where('pallet_number', $palletNumber)->first(); $PalletSerialNumbers = PalletValidation::where('plant_id', $plantId)->where('pallet_number', $palletNumber)->first();
if (!$PalletSerialNumbers) if (! $PalletSerialNumbers) {
{
Notification::make() Notification::make()
->title('Pallet Not Found') ->title('Pallet Not Found')
->body("Pallet number '$palletNumber' doesn't exist in pallet table!<br><br>Scan the valid exist 'Pallet Number' to proceed..!") ->body("Pallet number '$palletNumber' doesn't exist in pallet table!<br><br>Scan the valid exist 'Pallet Number' to proceed..!")
@@ -234,6 +226,7 @@ class ReworkLocatorInvoiceValidationResource extends Resource
$set('scan_serial_no', null); $set('scan_serial_no', null);
$set('scan_pallet_no', null); $set('scan_pallet_no', null);
$set('update_pallet', null); $set('update_pallet', null);
return; return;
} }
@@ -242,20 +235,18 @@ class ReworkLocatorInvoiceValidationResource extends Resource
->get(); ->get();
$isScanningComplete = true; $isScanningComplete = true;
foreach ($rows as $row) foreach ($rows as $row) {
{
if ($row->pallet_status != 'Completed') { if ($row->pallet_status != 'Completed') {
$isScanningComplete = false; $isScanningComplete = false;
break; break;
} }
} }
if(count($rows) <= 0) { if (count($rows) <= 0) {
$isScanningComplete = false; $isScanningComplete = false;
} }
if (!$isScanningComplete) if (! $isScanningComplete) {
{
Notification::make() Notification::make()
->title('Pallet Not Completed') ->title('Pallet Not Completed')
->body("Scanned pallet number '$palletNumber' doesn't completed the master packing!<br><br>Please, scan the valid completed pallet number to proceed..!") ->body("Scanned pallet number '$palletNumber' doesn't completed the master packing!<br><br>Please, scan the valid completed pallet number to proceed..!")
@@ -267,13 +258,11 @@ class ReworkLocatorInvoiceValidationResource extends Resource
$set('scan_serial_no', null); $set('scan_serial_no', null);
$set('scan_pallet_no', null); $set('scan_pallet_no', null);
$set('update_pallet', null); $set('update_pallet', null);
return; return;
} } else {
else
{
$locatExist = ($PalletSerialNumbers->locator_number != null && $PalletSerialNumbers->locator_number != '') ? $PalletSerialNumbers->locator_number : ''; $locatExist = ($PalletSerialNumbers->locator_number != null && $PalletSerialNumbers->locator_number != '') ? $PalletSerialNumbers->locator_number : '';
if ($locatExist) if ($locatExist) {
{
Notification::make() Notification::make()
->title('Locator Pallet Found') ->title('Locator Pallet Found')
->body("Scanned pallet number '$palletNumber' exist in locator number '$locatExist'.<br><br>Remove scanned 'Pallet' from 'Locator' to proceed re-master packing..!") ->body("Scanned pallet number '$palletNumber' exist in locator number '$locatExist'.<br><br>Remove scanned 'Pallet' from 'Locator' to proceed re-master packing..!")
@@ -285,14 +274,12 @@ class ReworkLocatorInvoiceValidationResource extends Resource
$set('scan_serial_no', null); $set('scan_serial_no', null);
$set('scan_pallet_no', null); $set('scan_pallet_no', null);
$set('update_pallet', null); $set('update_pallet', null);
return; return;
} } else {
else if (strlen($serialNo) > 0 && (strlen($serialNo) < 9 || strlen($serialNo) > 20)) {
{
if (strlen($serialNo) > 0 && (strlen($serialNo) < 9 || strlen($serialNo) > 20))
{
Notification::make() Notification::make()
->title("Invalid: Serial Number") ->title('Invalid: Serial Number')
->body("Serial number '$serialNo' should contain minimum 9 digits and maximum 20 digits.") ->body("Serial number '$serialNo' should contain minimum 9 digits and maximum 20 digits.")
->danger() ->danger()
->duration(5000) ->duration(5000)
@@ -301,12 +288,11 @@ class ReworkLocatorInvoiceValidationResource extends Resource
$livewire->dispatch('loadData', '', $palletNumber, $plantId, 'pallet'); $livewire->dispatch('loadData', '', $palletNumber, $plantId, 'pallet');
$set('scan_serial_no', null); $set('scan_serial_no', null);
$set('update_pallet', null); $set('update_pallet', null);
return; return;
} } elseif (strlen($serialNo) > 0 && ! ctype_alnum($serialNo)) {
else if (strlen($serialNo) > 0 && !ctype_alnum($serialNo))
{
Notification::make() Notification::make()
->title("Invalid: Serial Number") ->title('Invalid: Serial Number')
->body("Serial number '$serialNo' must contain alpha-numeric values only.") ->body("Serial number '$serialNo' must contain alpha-numeric values only.")
->danger() ->danger()
->duration(5000) ->duration(5000)
@@ -315,13 +301,12 @@ class ReworkLocatorInvoiceValidationResource extends Resource
$livewire->dispatch('loadData', '', $palletNumber, $plantId, 'pallet'); $livewire->dispatch('loadData', '', $palletNumber, $plantId, 'pallet');
$set('scan_serial_no', null); $set('scan_serial_no', null);
$set('update_pallet', null); $set('update_pallet', null);
return; return;
} }
if ($updatePalletStatus == 1) if ($updatePalletStatus == 1) {
{ foreach ($rows as $row) {
foreach ($rows as $row)
{
$row->forceDelete(); // Delete the row from the original table $row->forceDelete(); // Delete the row from the original table
} }
@@ -336,6 +321,7 @@ class ReworkLocatorInvoiceValidationResource extends Resource
$set('scan_serial_no', null); $set('scan_serial_no', null);
$set('scan_pallet_no', null); $set('scan_pallet_no', null);
$set('update_pallet', null); $set('update_pallet', null);
return; return;
} }
} }
@@ -349,7 +335,7 @@ class ReworkLocatorInvoiceValidationResource extends Resource
->hidden() ->hidden()
->readOnly(), ->readOnly(),
]) ])
->columns(5) ->columns(5),
]); ]);
} }
@@ -364,6 +350,7 @@ class ReworkLocatorInvoiceValidationResource extends Resource
$paginator = $livewire->getTableRecords(); $paginator = $livewire->getTableRecords();
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10; $perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1; $currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
return ($currentPage - 1) * $perPage + $rowLoop->iteration; return ($currentPage - 1) * $perPage + $rowLoop->iteration;
}), }),
Tables\Columns\TextColumn::make('plant.name') Tables\Columns\TextColumn::make('plant.name')
@@ -444,20 +431,17 @@ class ReworkLocatorInvoiceValidationResource extends Resource
->importer(ReworkLocatorInvoiceValidationImporter::class) ->importer(ReworkLocatorInvoiceValidationImporter::class)
->label('Import Rework Invoice') ->label('Import Rework Invoice')
->color('warning') ->color('warning')
->visible(function() { ->visible(function () {
return Filament::auth()->user()->can('view import rework invoice validation'); return Filament::auth()->user()->can('view import rework invoice validation');
}), }),
ExportAction::make() ExportAction::make()
->exporter(ReworkLocatorInvoiceValidationExporter::class) ->exporter(ReworkLocatorInvoiceValidationExporter::class)
->label('Export Rework Invoice') ->label('Export Rework Invoice')
->color('warning') ->color('warning')
->visible(function() { ->visible(function () {
return Filament::auth()->user()->can('view export rework invoice validation'); return Filament::auth()->user()->can('view export rework invoice validation');
}), }),
]) ])
// ->filters([
// Tables\Filters\TrashedFilter::make(),
// ])
->filters([ ->filters([
Tables\Filters\TrashedFilter::make(), Tables\Filters\TrashedFilter::make(),
Filter::make('advanced_filters') Filter::make('advanced_filters')
@@ -471,6 +455,7 @@ class ReworkLocatorInvoiceValidationResource extends Resource
// }) // })
->options(function (callable $get) { ->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id; $userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray(); return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
}) })
->reactive() ->reactive()
@@ -491,12 +476,13 @@ class ReworkLocatorInvoiceValidationResource extends Resource
->label('Invoice Number') ->label('Invoice Number')
->options(function (callable $get) { ->options(function (callable $get) {
$plantId = $get('Plant'); $plantId = $get('Plant');
if (!$plantId) { if (! $plantId) {
return []; return [];
} }
return ReworkLocatorInvoiceValidation::where('plant_id', $plantId) return ReworkLocatorInvoiceValidation::where('plant_id', $plantId)
->whereNotNull('invoice_number') ->whereNotNull('invoice_number')
->where('invoice_number','!=', '') ->where('invoice_number', '!=', '')
->orderBy('invoice_number', 'asc') ->orderBy('invoice_number', 'asc')
->get() ->get()
->unique('invoice_number') ->unique('invoice_number')
@@ -512,12 +498,13 @@ class ReworkLocatorInvoiceValidationResource extends Resource
->label('Pallet Number') ->label('Pallet Number')
->options(function (callable $get) { ->options(function (callable $get) {
$plantId = $get('Plant'); $plantId = $get('Plant');
if (!$plantId) { if (! $plantId) {
return []; return [];
} }
return ReworkLocatorInvoiceValidation::where('plant_id', $plantId) return ReworkLocatorInvoiceValidation::where('plant_id', $plantId)
->whereNotNull('pallet_number') ->whereNotNull('pallet_number')
->where('pallet_number','!=', '') ->where('pallet_number', '!=', '')
->orderBy('pallet_number', 'asc') ->orderBy('pallet_number', 'asc')
->get() ->get()
->unique('pallet_number') ->unique('pallet_number')
@@ -530,12 +517,13 @@ class ReworkLocatorInvoiceValidationResource extends Resource
->label('Locator Number') ->label('Locator Number')
->options(function (callable $get) { ->options(function (callable $get) {
$plantId = $get('Plant'); $plantId = $get('Plant');
if (!$plantId) { if (! $plantId) {
return []; return [];
} }
return ReworkLocatorInvoiceValidation::where('plant_id', $plantId) return ReworkLocatorInvoiceValidation::where('plant_id', $plantId)
->whereNotNull('locator_number') ->whereNotNull('locator_number')
->where('locator_number','!=', '') ->where('locator_number', '!=', '')
->orderBy('locator_number', 'asc') ->orderBy('locator_number', 'asc')
->get() ->get()
->unique('locator_number') ->unique('locator_number')
@@ -569,38 +557,44 @@ class ReworkLocatorInvoiceValidationResource extends Resource
return $query->whereRaw('1 = 0'); return $query->whereRaw('1 = 0');
} }
if (!empty($data['Plant'])) { //$plant = $data['Plant'] ?? null if (! empty($data['Plant'])) { // $plant = $data['Plant'] ?? null
$query->where('plant_id', $data['Plant']); $query->where('plant_id', $data['Plant']);
} else {
$userHas = Filament::auth()->user()->plant_id;
if ($userHas && strlen($userHas) > 0) {
return $query->whereRaw('1 = 0');
}
} }
if (!empty($data['invoice_number'])) { if (! empty($data['invoice_number'])) {
$query->where('invoice_number', $data['invoice_number']); $query->where('invoice_number', $data['invoice_number']);
} }
if (!empty($data['serial_number'])) { if (! empty($data['serial_number'])) {
$query->where('serial_number', $data['serial_number']); $query->where('serial_number', $data['serial_number']);
} }
if (!empty($data['pallet_number'])) { if (! empty($data['pallet_number'])) {
$query->where('pallet_number', $data['pallet_number']); $query->where('pallet_number', $data['pallet_number']);
} }
if (!empty($data['locator_number'])) { if (! empty($data['locator_number'])) {
$query->where('locator_number', $data['locator_number']); $query->where('locator_number', $data['locator_number']);
} }
if (!empty($data['scanned_status'])) { if (! empty($data['scanned_status'])) {
$query->where('scanned_status', $data['scanned_status']); $query->where('scanned_status', $data['scanned_status']);
} }
if (!empty($data['rework_from'])) { if (! empty($data['rework_from'])) {
$query->where('reworked_at', '>=', $data['rework_from']); $query->where('reworked_at', '>=', $data['rework_from']);
} }
if (!empty($data['rework_to'])) { if (! empty($data['rework_to'])) {
$query->where('reworked_at', '<=', $data['rework_to']); $query->where('reworked_at', '<=', $data['rework_to']);
} }
if (!empty($data['rework_by'])) { if (! empty($data['rework_by'])) {
$query->where('reworked_by', $data['rework_by']); $query->where('reworked_by', $data['rework_by']);
} }
@@ -608,43 +602,50 @@ class ReworkLocatorInvoiceValidationResource extends Resource
->indicateUsing(function (array $data) { ->indicateUsing(function (array $data) {
$indicators = []; $indicators = [];
if (!empty($data['Plant'])) { if (! empty($data['Plant'])) {
$indicators[] = 'Plant: ' . Plant::where('id', $data['Plant'])->value('name'); $indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name');
} else {
$userHas = Filament::auth()->user()->plant_id;
if ($userHas && strlen($userHas) > 0) {
return 'Plant: Choose plant to filter records.';
}
} }
if (!empty($data['invoice_number'])) { if (! empty($data['invoice_number'])) {
$indicators[] = 'Invoice Number: ' . $data['invoice_number']; $indicators[] = 'Invoice Number: '.$data['invoice_number'];
} }
if (!empty($data['serial_number'])) { if (! empty($data['serial_number'])) {
$indicators[] = 'Serial Number: ' . $data['serial_number']; $indicators[] = 'Serial Number: '.$data['serial_number'];
} }
if (!empty($data['pallet_number'])) { if (! empty($data['pallet_number'])) {
$indicators[] = 'Pallet Number: ' . $data['pallet_number']; $indicators[] = 'Pallet Number: '.$data['pallet_number'];
} }
if (!empty($data['locator_number'])) { if (! empty($data['locator_number'])) {
$indicators[] = 'Locator Number: ' . $data['locator_number']; $indicators[] = 'Locator Number: '.$data['locator_number'];
} }
if (!empty($data['scanned_status'])) { if (! empty($data['scanned_status'])) {
$indicators[] = 'Scanned Status: ' . $data['scanned_status']; $indicators[] = 'Scanned Status: '.$data['scanned_status'];
} }
if (!empty($data['rework_from'])) { if (! empty($data['rework_from'])) {
$indicators[] = 'From: ' . $data['rework_from']; $indicators[] = 'From: '.$data['rework_from'];
} }
if (!empty($data['rework_to'])) { if (! empty($data['rework_to'])) {
$indicators[] = 'To: ' . $data['rework_to']; $indicators[] = 'To: '.$data['rework_to'];
} }
if (!empty($data['rework_by'])) { if (! empty($data['rework_by'])) {
$indicators[] = 'Reworked By: ' . $data['rework_by']; $indicators[] = 'Reworked By: '.$data['rework_by'];
} }
return $indicators; return $indicators;
}) }),
]) ])
->filtersFormMaxHeight('280px') ->filtersFormMaxHeight('280px')
->actions([ ->actions([