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
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 10s
This commit is contained in:
@@ -4,40 +4,41 @@ namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\SerialValidationExporter;
|
||||
use App\Filament\Resources\SerialValidationResource\Pages;
|
||||
use App\Filament\Resources\SerialValidationResource\RelationManagers;
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\SerialValidation;
|
||||
use App\Models\StickerMaster;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\ToggleButtons;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Str;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
|
||||
class SerialValidationResource extends Resource
|
||||
{
|
||||
protected static ?string $model = SerialValidation::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Serial Validation';
|
||||
|
||||
public $invoiceNumber;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
@@ -53,6 +54,7 @@ class SerialValidationResource extends Resource
|
||||
->columnSpan(1)
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
})
|
||||
->default(function () {
|
||||
@@ -70,10 +72,9 @@ class SerialValidationResource extends Resource
|
||||
$set('total_quantity', null);
|
||||
$set('scanned_quantity', null);
|
||||
$set('ivPlantError', 'Please select a plant first.');
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$set('ivPlantError', null);
|
||||
}
|
||||
})
|
||||
@@ -115,12 +116,58 @@ class SerialValidationResource extends Resource
|
||||
'id' => 'serial_number_input',
|
||||
'x-data' => '{ value: "" }',
|
||||
'x-model' => 'value',
|
||||
'wire:keydown.enter.prevent' => 'processSerialNumber(value)', // Using wire:keydown
|
||||
// 'x-data' => '{}',
|
||||
// 'x-on:keydown.enter.prevent' => "
|
||||
// let v = (\$event.target.value || '').replace(/[\\r\\n\\s]+$/g, '').trim().toLowerCase();
|
||||
|
||||
// if (!v.endsWith('/c')) {
|
||||
// \$wire.processSerialNumber(v);
|
||||
// }
|
||||
// ",
|
||||
// 'wire:keydown.enter.prevent' => 'processSerialNumber(value)', // Using wire:keydown
|
||||
'x-on:keydown.enter.prevent' => "
|
||||
let serial = \$event.target.value;
|
||||
if (serial.trim() != '') {
|
||||
\$wire.dispatch('process-scan', serial);
|
||||
}
|
||||
",
|
||||
])
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get, $livewire) {
|
||||
$set('update_invoice', 0);
|
||||
// if (str_ends_with(strtolower($state), '/c')) {
|
||||
// $livewire->dispatch('focus-capacitor');
|
||||
// }
|
||||
})
|
||||
->columnSpan(1),
|
||||
|
||||
Forms\Components\TextInput::make('capacitor')
|
||||
->label('Capacitor')
|
||||
->reactive()
|
||||
// ->hidden(fn (callable $get) => !str_ends_with(strtolower($get('serial_number')), '/c'))
|
||||
->visible(fn (callable $get) => str_ends_with(strtolower($get('serial_number')), '/c')
|
||||
)
|
||||
->extraAttributes([
|
||||
'id' => 'focus-capacitor-input',
|
||||
'x-data' => "{
|
||||
getItemCode() {
|
||||
return this.\$el.dataset.itemCode || '';
|
||||
}
|
||||
}",
|
||||
'x-init' => '
|
||||
// Nothing needed here now, listener runs globally
|
||||
',
|
||||
// Trigger processing with Enter key
|
||||
'x-on:keydown.enter.prevent' => "
|
||||
\$wire.processCapacitor(
|
||||
\$el.querySelector('input').value,
|
||||
getItemCode()
|
||||
)
|
||||
",
|
||||
// 'x-on:keydown.enter.prevent' => 'processCapacitor(value)',
|
||||
])
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('update_invoice', 0);
|
||||
// $this->dispatch('focus-serial-number');
|
||||
// if (!$invNo) { return; } else { }
|
||||
$get('serial_number');
|
||||
|
||||
})
|
||||
->columnSpan(1),
|
||||
Forms\Components\TextInput::make('total_quantity')
|
||||
@@ -138,18 +185,17 @@ class SerialValidationResource extends Resource
|
||||
->reactive()
|
||||
->hidden(fn (callable $get) => ($get('invoice_number') == null || $get('update_invoice') == '0') || ! empty($get('serial_number')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if (!$get('plant_id'))
|
||||
{
|
||||
if (! $get('plant_id')) {
|
||||
$set('update_invoice', null);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($get('update_invoice') == "1")
|
||||
{
|
||||
if ($get('update_invoice') == '1') {
|
||||
$totQuan = SerialValidation::where('invoice_number', $get('invoice_number'))->where('plant_id', $get('plant_id'))->count();
|
||||
if ($totQuan <= 0)
|
||||
{
|
||||
if ($totQuan <= 0) {
|
||||
$set('update_invoice', null);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -157,19 +203,16 @@ class SerialValidationResource extends Resource
|
||||
$scanMQuan = SerialValidation::where('invoice_number', $get('invoice_number'))->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $get('plant_id'))->count();
|
||||
$scanSQuan = SerialValidation::where('invoice_number', $get('invoice_number'))->where('scanned_status', 'Scanned')->where('plant_id', $get('plant_id'))->count();
|
||||
|
||||
if ($totMQuan > 0)
|
||||
{
|
||||
if ($totQuan == $scanMQuan)
|
||||
{
|
||||
if ($totMQuan > 0) {
|
||||
if ($totQuan == $scanMQuan) {
|
||||
$set('update_invoice', null);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($totQuan == $scanSQuan)
|
||||
{
|
||||
} else {
|
||||
if ($totQuan == $scanSQuan) {
|
||||
$set('update_invoice', null);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -194,6 +237,7 @@ class SerialValidationResource extends Resource
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('invoice_number')
|
||||
@@ -287,6 +331,7 @@ class SerialValidationResource extends Resource
|
||||
// ->options(Plant::pluck('name', 'id')->toArray()) // Fetch plant names and IDs
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
})
|
||||
->label('Select Plant')
|
||||
@@ -330,42 +375,37 @@ class SerialValidationResource extends Resource
|
||||
// /home/iot-dev/projects/pds/storage/app/private/uploads/temp/3RA0018735.xlsx
|
||||
|
||||
$totQuan = SerialValidation::where('invoice_number', $originalNameOnly)->count();
|
||||
if ($totQuan > 0)
|
||||
{
|
||||
if ($totQuan > 0) {
|
||||
$scanSQuan = SerialValidation::where('invoice_number', $originalNameOnly)->where('scanned_status', 'Scanned')->count();
|
||||
if ($totQuan == $scanSQuan)
|
||||
{
|
||||
if ($totQuan == $scanSQuan) {
|
||||
$invoiceFirst = SerialValidation::with('plant')->where('invoice_number', $originalNameOnly)->first();
|
||||
$plantName = $invoiceFirst ? (String)$invoiceFirst->plant->name : null;
|
||||
$plantName = $invoiceFirst ? (string) $invoiceFirst->plant->name : null;
|
||||
|
||||
Notification::make()
|
||||
->title("Serial invoice number : '$originalNameOnly' already completed the scanning process for plant : '$plantName'.")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path))
|
||||
{
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$invoiceFirst = SerialValidation::with('plant')->where('invoice_number', $originalNameOnly)->first();
|
||||
// $plantCode = $invoiceFirst ? (String)$invoiceFirst->plant->code : null;
|
||||
$plantName = $invoiceFirst ? (String)$invoiceFirst->plant->name : null;
|
||||
$plantName = $invoiceFirst ? (string) $invoiceFirst->plant->name : null;
|
||||
$invoicePlantId = $invoiceFirst->plant_id;
|
||||
if ($plantId != $invoicePlantId)
|
||||
{
|
||||
if ($plantId != $invoicePlantId) {
|
||||
Notification::make()
|
||||
->title("Serial invoice number : '$originalNameOnly' already exists for plant : '$plantName'.<br>Choose the valid 'Plant' to proceed!")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path))
|
||||
{
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -374,26 +414,23 @@ class SerialValidationResource extends Resource
|
||||
$totQuan = SerialValidation::where('invoice_number', $originalNameOnly)->where('plant_id', $plantId)->count();
|
||||
$scanSQuan = SerialValidation::where('invoice_number', $originalNameOnly)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
|
||||
|
||||
if ($totQuan > 0 && $totQuan == $scanSQuan)
|
||||
{
|
||||
if ($totQuan > 0 && $totQuan == $scanSQuan) {
|
||||
Notification::make()
|
||||
->title('Serial invoice already completed the scanning process for selected plant.')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path))
|
||||
{
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($fullPath && file_exists($fullPath))
|
||||
{
|
||||
if ($fullPath && file_exists($fullPath)) {
|
||||
$rows = Excel::toArray(null, $fullPath)[0];
|
||||
|
||||
if ((count($rows) - 1) <= 0)
|
||||
{
|
||||
if ((count($rows) - 1) <= 0) {
|
||||
Notification::make()
|
||||
->title('Records Not Found')
|
||||
->body("Import the valid 'Serial Invoice' file to proceed..!")
|
||||
@@ -403,6 +440,7 @@ class SerialValidationResource extends Resource
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -414,9 +452,10 @@ class SerialValidationResource extends Resource
|
||||
$seenSerialNumbers = [];
|
||||
$validRowsFound = false;
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index == 0) continue; // Skip header
|
||||
foreach ($rows as $index => $row) {
|
||||
if ($index == 0) {
|
||||
continue;
|
||||
} // Skip header
|
||||
|
||||
$materialCode = trim($row[0]);
|
||||
$serialNumber = trim($row[1]);
|
||||
@@ -425,24 +464,16 @@ class SerialValidationResource extends Resource
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!empty($materialCode))
|
||||
{
|
||||
if (Str::length($materialCode) < 6 || !ctype_alnum($materialCode))
|
||||
{
|
||||
if (! empty($materialCode)) {
|
||||
if (Str::length($materialCode) < 6 || ! ctype_alnum($materialCode)) {
|
||||
$invalidMatCodes[] = $materialCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
if (empty($serialNumber)) {
|
||||
$missingSerials[] = $materialCode;
|
||||
|
||||
}
|
||||
else if (Str::length($serialNumber) < 9 || !ctype_alnum($serialNumber))
|
||||
{
|
||||
} elseif (Str::length($serialNumber) < 9 || ! ctype_alnum($serialNumber)) {
|
||||
$invalidSerialCodes[] = $serialNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
if (in_array($serialNumber, $seenSerialNumbers)) {
|
||||
$duplicateSerials[] = $serialNumber;
|
||||
} else {
|
||||
@@ -452,9 +483,7 @@ class SerialValidationResource extends Resource
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -476,9 +505,9 @@ class SerialValidationResource extends Resource
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else if (!empty($uniqueMissingSerials)) {
|
||||
} elseif (! empty($uniqueMissingSerials)) {
|
||||
Notification::make()
|
||||
->title('Missing Serial Numbers')
|
||||
->body("The following item codes doesn't have valid serial number:<br>".implode(', ', $uniqueMissingSerials))
|
||||
@@ -487,9 +516,9 @@ class SerialValidationResource extends Resource
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else if (!empty($uniqueSerialCodes)) {
|
||||
} elseif (! empty($uniqueSerialCodes)) {
|
||||
Notification::make()
|
||||
->title('Invalid Serial Number')
|
||||
->body('The following serial numbers should contain minimum 9 digit alpha numeric values:<br>'.implode(', ', $uniqueSerialCodes))
|
||||
@@ -498,9 +527,9 @@ class SerialValidationResource extends Resource
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else if (!empty($duplicateSerialCodes)) {
|
||||
} elseif (! empty($duplicateSerialCodes)) {
|
||||
Notification::make()
|
||||
->title('Duplicate Serial Numbers')
|
||||
->body('The following serial numbers are already exist in imported excel:<br>'.implode(', ', $duplicateSerialCodes))
|
||||
@@ -509,6 +538,7 @@ class SerialValidationResource extends Resource
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -521,6 +551,7 @@ class SerialValidationResource extends Resource
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -536,8 +567,7 @@ class SerialValidationResource extends Resource
|
||||
|
||||
$missingCodes = array_diff($uniqueCodes, $matchedCodes);
|
||||
|
||||
if (!empty($missingCodes))
|
||||
{
|
||||
if (! empty($missingCodes)) {
|
||||
$missingCount = count($missingCodes);
|
||||
|
||||
$message = $missingCount > 10 ? "'$missingCount' item codes are not found in database." : 'The following item codes are not found in database:<br>'.implode(', ', $missingCodes);
|
||||
@@ -551,6 +581,7 @@ class SerialValidationResource extends Resource
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -560,8 +591,7 @@ class SerialValidationResource extends Resource
|
||||
->pluck('item.code')
|
||||
->toArray();
|
||||
|
||||
if (count($invalidCodes) > 10)
|
||||
{
|
||||
if (count($invalidCodes) > 10) {
|
||||
Notification::make()
|
||||
->title('Invalid item codes found')
|
||||
->body(''.count($invalidCodes).'item codes found have material type.')
|
||||
@@ -571,10 +601,9 @@ class SerialValidationResource extends Resource
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else if (count($invalidCodes) > 0)
|
||||
{
|
||||
} elseif (count($invalidCodes) > 0) {
|
||||
Notification::make()
|
||||
->title('Invalid item codes found')
|
||||
->body('Material invoice Item Codes found : '.implode(', ', $invalidCodes))
|
||||
@@ -584,10 +613,9 @@ class SerialValidationResource extends Resource
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Save full file path to session
|
||||
session(['uploaded_invoice_path' => $fullPath]);
|
||||
Notification::make()
|
||||
@@ -921,7 +949,6 @@ class SerialValidationResource extends Resource
|
||||
// $excelCode = trim($row[0]);
|
||||
// $excelMatQty = trim($row[1]);
|
||||
|
||||
|
||||
// if ($excelCode == $code && is_numeric($excelMatQty)) {
|
||||
// $totalExcelQty += $excelMatQty; // Sum up the quantities
|
||||
// }
|
||||
@@ -988,9 +1015,6 @@ class SerialValidationResource extends Resource
|
||||
return Filament::auth()->user()->can('view export serial validation invoice');
|
||||
}),
|
||||
])
|
||||
// ->filters([
|
||||
// Tables\Filters\TrashedFilter::make(),
|
||||
// ])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
@@ -1000,7 +1024,7 @@ class SerialValidationResource extends Resource
|
||||
->label('Type ?')
|
||||
->boolean()
|
||||
->options([
|
||||
'Serial' => 'Serial'
|
||||
'Serial' => 'Serial',
|
||||
])
|
||||
->default('Serial')
|
||||
->inlineLabel(false)
|
||||
@@ -1013,6 +1037,7 @@ class SerialValidationResource extends Resource
|
||||
// })
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
})
|
||||
->reactive()
|
||||
@@ -1032,6 +1057,7 @@ class SerialValidationResource extends Resource
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$pId = $get('Plant');
|
||||
|
||||
// if (empty($pId)) {
|
||||
// return [];
|
||||
// }
|
||||
@@ -1058,12 +1084,9 @@ class SerialValidationResource extends Resource
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if (!$plantId)
|
||||
{
|
||||
if (! $plantId) {
|
||||
return SerialValidation::whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return SerialValidation::where('plant_id', $plantId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||
}
|
||||
})
|
||||
@@ -1083,13 +1106,13 @@ class SerialValidationResource extends Resource
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['invoice_type']) || (empty($data['Plant']) && empty($data['invoice_number']) && empty($data['serial_number']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['operator_id']) && empty($data['scanned_status']) && empty($data['sticker_master_id']))) {
|
||||
if (empty($data['invoice_type']))
|
||||
{
|
||||
if (empty($data['invoice_type'])) {
|
||||
Notification::make()
|
||||
->title('Please, choose invoice type to filter.')
|
||||
->danger()
|
||||
->send();
|
||||
}
|
||||
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
@@ -1101,7 +1124,7 @@ class SerialValidationResource extends Resource
|
||||
$query->whereNotNull('scanned_status')->where('scanned_status', '!=', '');
|
||||
} elseif ($data['scanned_status'] == 'Pending') {
|
||||
// $query->whereNull('scanned_status')->orWhere('scanned_status', '');
|
||||
$query->where(function ($query) use ($data) {
|
||||
$query->where(function ($query) {
|
||||
// if (empty($data['scanned_status']) || $data['scanned_status'] == 'Pending') {
|
||||
$query->whereNull('scanned_status')->orWhere('scanned_status', '!=', 'Scanned');
|
||||
// }
|
||||
@@ -1115,7 +1138,7 @@ class SerialValidationResource extends Resource
|
||||
if ($data['scanned_status'] == 'Scanned') {
|
||||
$query->whereNotNull('serial_number')->where('serial_number', '!=', '');
|
||||
} elseif ($data['scanned_status'] == 'Pending') {
|
||||
$query->where(function ($query) use ($data) {
|
||||
$query->where(function ($query) {
|
||||
$query->whereNull('serial_number')->orWhere('serial_number', '=', '');
|
||||
});
|
||||
}
|
||||
@@ -1124,6 +1147,12 @@ class SerialValidationResource extends Resource
|
||||
|
||||
if (! empty($data['Plant'])) { // $plant = $data['Plant'] ?? null
|
||||
$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'])) {
|
||||
@@ -1161,6 +1190,12 @@ class SerialValidationResource extends Resource
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$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'])) {
|
||||
@@ -1193,7 +1228,7 @@ class SerialValidationResource extends Resource
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
})
|
||||
}),
|
||||
])
|
||||
->filtersFormMaxHeight('280px')
|
||||
->actions([
|
||||
|
||||
Reference in New Issue
Block a user