Implement initial structure for code changes and prepare for future updates and Added view rights against plant on view report
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:
@@ -5,35 +5,33 @@ namespace App\Filament\Resources;
|
|||||||
use App\Filament\Exports\LocatorInvoiceValidationExporter;
|
use App\Filament\Exports\LocatorInvoiceValidationExporter;
|
||||||
use App\Filament\Imports\LocatorInvoiceValidationImporter;
|
use App\Filament\Imports\LocatorInvoiceValidationImporter;
|
||||||
use App\Filament\Resources\LocatorInvoiceValidationResource\Pages;
|
use App\Filament\Resources\LocatorInvoiceValidationResource\Pages;
|
||||||
use App\Filament\Resources\LocatorInvoiceValidationResource\RelationManagers;
|
|
||||||
use App\Models\Configuration;
|
use App\Models\Configuration;
|
||||||
use App\Models\InvoiceValidation;
|
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\StickerMaster;
|
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
|
use Filament\Forms\Components\DateTimePicker;
|
||||||
use Filament\Forms\Components\FileUpload;
|
use Filament\Forms\Components\FileUpload;
|
||||||
use Filament\Forms\Components\Section;
|
use Filament\Forms\Components\Section;
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Forms\Components\ToggleButtons;
|
use Filament\Forms\Components\ToggleButtons;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Forms\Get;
|
use Filament\Forms\Get;
|
||||||
use Filament\Notifications\Notification;
|
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 Maatwebsite\Excel\Facades\Excel;
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
use Filament\Tables\Actions\ExportAction;
|
|
||||||
use Filament\Tables\Actions\ImportAction;
|
|
||||||
use Storage;
|
use Storage;
|
||||||
use Str;
|
use Str;
|
||||||
use Filament\Forms\Components\DateTimePicker;
|
|
||||||
use Filament\Tables\Filters\Filter;
|
|
||||||
use Filament\Forms\Components\TextInput;
|
|
||||||
|
|
||||||
class LocatorInvoiceValidationResource extends Resource
|
class LocatorInvoiceValidationResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -57,14 +55,14 @@ class LocatorInvoiceValidationResource extends Resource
|
|||||||
->relationship('plant', 'name')
|
->relationship('plant', 'name')
|
||||||
->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();
|
||||||
})
|
})
|
||||||
->disabled(fn (Get $get) => $get('invoice_number'))
|
->disabled(fn (Get $get) => $get('invoice_number'))
|
||||||
->required()
|
->required()
|
||||||
->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('pallet_number', null);
|
$set('pallet_number', null);
|
||||||
@@ -72,9 +70,7 @@ class LocatorInvoiceValidationResource extends Resource
|
|||||||
$set('sno_quantity', 0);
|
$set('sno_quantity', 0);
|
||||||
$set('scan_quantity', 0);
|
$set('scan_quantity', 0);
|
||||||
$set('pend_quantity', 0);
|
$set('pend_quantity', 0);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('plant', null);
|
$set('plant', null);
|
||||||
$set('invoice_number', null);
|
$set('invoice_number', null);
|
||||||
$set('pallet_number', null);
|
$set('pallet_number', null);
|
||||||
@@ -97,19 +93,17 @@ class LocatorInvoiceValidationResource extends Resource
|
|||||||
'x-model' => 'value',
|
'x-model' => 'value',
|
||||||
'x-on:keydown.enter.prevent' => '$wire.processinvoiceSNo()',
|
'x-on:keydown.enter.prevent' => '$wire.processinvoiceSNo()',
|
||||||
])
|
])
|
||||||
->readOnly(fn (callable $get) => !$get('plant') || $get('pallet_number') || $get('serial_number'))
|
->readOnly(fn (callable $get) => ! $get('plant') || $get('pallet_number') || $get('serial_number'))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$plantId = $get('plant');
|
$plantId = $get('plant');
|
||||||
$invNo = $get('invoice_number');
|
$invNo = $get('invoice_number');
|
||||||
$snoCount = 0;
|
$snoCount = 0;
|
||||||
$pendingCount = 0;
|
$pendingCount = 0;
|
||||||
$scannedCount = 0;
|
$scannedCount = 0;
|
||||||
if (!$plantId) {
|
if (! $plantId) {
|
||||||
$set('invoice_number', null);
|
$set('invoice_number', null);
|
||||||
$set('pallet_number', null);
|
$set('pallet_number', null);
|
||||||
}
|
} elseif ($invNo) {
|
||||||
else if ($invNo)
|
|
||||||
{
|
|
||||||
$snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invNo)->count();
|
$snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invNo)->count();
|
||||||
|
|
||||||
$pendingCount = LocatorInvoiceValidation::where('invoice_number', $invNo)->where('plant_id', $plantId)->whereNull('scanned_status')->orWhere('scanned_status', '=', '')->count();
|
$pendingCount = LocatorInvoiceValidation::where('invoice_number', $invNo)->where('plant_id', $plantId)->whereNull('scanned_status')->orWhere('scanned_status', '=', '')->count();
|
||||||
@@ -133,33 +127,32 @@ class LocatorInvoiceValidationResource extends Resource
|
|||||||
$plantId = $get('plant');
|
$plantId = $get('plant');
|
||||||
$invoiceExist = false;
|
$invoiceExist = false;
|
||||||
|
|
||||||
if (!empty($invoiceNumber) && !empty($plantId)) {
|
if (! empty($invoiceNumber) && ! empty($plantId)) {
|
||||||
$records = LocatorInvoiceValidation::where('plant_id', $plantId)
|
$records = LocatorInvoiceValidation::where('plant_id', $plantId)
|
||||||
->where('invoice_number', $invoiceNumber)
|
->where('invoice_number', $invoiceNumber)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$allScanned = true;
|
$allScanned = true;
|
||||||
foreach ($records as $record)
|
foreach ($records as $record) {
|
||||||
{
|
|
||||||
if (($record->scanned_status == null) || trim($record->scanned_status) == '') {
|
if (($record->scanned_status == null) || trim($record->scanned_status) == '') {
|
||||||
$allScanned = false;
|
$allScanned = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($records) > 0 && !$allScanned) {
|
if (count($records) > 0 && ! $allScanned) {
|
||||||
$invoiceExist = true;
|
$invoiceExist = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $invoiceExist == false || !$get('plant') || !$get('invoice_number') || $get('serial_number');
|
return $invoiceExist == false || ! $get('plant') || ! $get('invoice_number') || $get('serial_number');
|
||||||
})
|
})
|
||||||
->extraAttributes([
|
->extraAttributes([
|
||||||
'wire:keydown.enter.prevent' => 'processPalletNo()',
|
'wire:keydown.enter.prevent' => 'processPalletNo()',
|
||||||
])
|
])
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$plantId = $get('plant');
|
$plantId = $get('plant');
|
||||||
if (!$plantId) {
|
if (! $plantId) {
|
||||||
$set('invoice_number', null);
|
$set('invoice_number', null);
|
||||||
$set('pallet_number', null);
|
$set('pallet_number', null);
|
||||||
}
|
}
|
||||||
@@ -175,26 +168,25 @@ class LocatorInvoiceValidationResource extends Resource
|
|||||||
$plantId = $get('plant');
|
$plantId = $get('plant');
|
||||||
$invoiceExist = false;
|
$invoiceExist = false;
|
||||||
|
|
||||||
if (!empty($invoiceNumber) && !empty($plantId)) {
|
if (! empty($invoiceNumber) && ! empty($plantId)) {
|
||||||
$records = LocatorInvoiceValidation::where('plant_id', $plantId)
|
$records = LocatorInvoiceValidation::where('plant_id', $plantId)
|
||||||
->where('invoice_number', $invoiceNumber)
|
->where('invoice_number', $invoiceNumber)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$allScanned = true;
|
$allScanned = true;
|
||||||
foreach ($records as $record)
|
foreach ($records as $record) {
|
||||||
{
|
|
||||||
if (($record->scanned_status == null) || trim($record->scanned_status) == '') {
|
if (($record->scanned_status == null) || trim($record->scanned_status) == '') {
|
||||||
$allScanned = false;
|
$allScanned = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($records) > 0 && !$allScanned) {
|
if (count($records) > 0 && ! $allScanned) {
|
||||||
$invoiceExist = true;
|
$invoiceExist = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $invoiceExist == false || !$get('plant') || !$get('invoice_number') || $get('pallet_number');
|
return $invoiceExist == false || ! $get('plant') || ! $get('invoice_number') || $get('pallet_number');
|
||||||
})
|
})
|
||||||
->extraAttributes([
|
->extraAttributes([
|
||||||
'x-data' => '{ value: "" }',
|
'x-data' => '{ value: "" }',
|
||||||
@@ -216,7 +208,7 @@ class LocatorInvoiceValidationResource extends Resource
|
|||||||
->default(0)
|
->default(0)
|
||||||
->readOnly(),
|
->readOnly(),
|
||||||
|
|
||||||
//Forms\Components\View::make('forms.components.update-invoice-button'),
|
// Forms\Components\View::make('forms.components.update-invoice-button'),
|
||||||
|
|
||||||
ToggleButtons::make('update_invoice')
|
ToggleButtons::make('update_invoice')
|
||||||
->label('Update Invoice?')
|
->label('Update Invoice?')
|
||||||
@@ -228,7 +220,7 @@ class LocatorInvoiceValidationResource extends Resource
|
|||||||
$plantId = $get('plant');
|
$plantId = $get('plant');
|
||||||
$invoiceExist = false;
|
$invoiceExist = false;
|
||||||
|
|
||||||
if (!empty($invoiceNumber) && !empty($plantId)) {
|
if (! empty($invoiceNumber) && ! empty($plantId)) {
|
||||||
|
|
||||||
$records = LocatorInvoiceValidation::where('plant_id', $plantId)
|
$records = LocatorInvoiceValidation::where('plant_id', $plantId)
|
||||||
->where('invoice_number', $invoiceNumber)
|
->where('invoice_number', $invoiceNumber)
|
||||||
@@ -236,20 +228,19 @@ class LocatorInvoiceValidationResource extends Resource
|
|||||||
|
|
||||||
$allScanned = true;
|
$allScanned = true;
|
||||||
|
|
||||||
foreach ($records as $record)
|
foreach ($records as $record) {
|
||||||
{
|
|
||||||
if (($record->scanned_status == null) || trim($record->scanned_status) == '') {
|
if (($record->scanned_status == null) || trim($record->scanned_status) == '') {
|
||||||
$allScanned = false;
|
$allScanned = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($records) > 0 && !$allScanned) {
|
if (count($records) > 0 && ! $allScanned) {
|
||||||
$invoiceExist = true;
|
$invoiceExist = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $get('update_invoice') == '0' || $invoiceExist == false || !empty($get('pallet_number')) || !empty($get('serial_number')); //$get('invoice_number') == null
|
return $get('update_invoice') == '0' || $invoiceExist == false || ! empty($get('pallet_number')) || ! empty($get('serial_number')); // $get('invoice_number') == null
|
||||||
}),
|
}),
|
||||||
|
|
||||||
Forms\Components\TextInput::make('id')
|
Forms\Components\TextInput::make('id')
|
||||||
@@ -266,14 +257,14 @@ class LocatorInvoiceValidationResource extends Resource
|
|||||||
$plantId = $get('plant');
|
$plantId = $get('plant');
|
||||||
$isPalletValid = false;
|
$isPalletValid = false;
|
||||||
|
|
||||||
if (!empty($palletNumber) && !empty($plantId)) {
|
if (! empty($palletNumber) && ! empty($plantId)) {
|
||||||
$pallet = PalletValidation::where('plant_id', $plantId)
|
$pallet = PalletValidation::where('plant_id', $plantId)
|
||||||
->where('pallet_number', $palletNumber)
|
->where('pallet_number', $palletNumber)
|
||||||
->first();
|
->first();
|
||||||
$isPalletValid = $pallet !== null;
|
$isPalletValid = $pallet !== null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return !$isPalletValid || $get('update_locator_invoice') == '0' || !empty($get('serial_number'));
|
return ! $isPalletValid || $get('update_locator_invoice') == '0' || ! empty($get('serial_number'));
|
||||||
})
|
})
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get, $livewire) {
|
->afterStateUpdated(function ($state, callable $set, callable $get, $livewire) {
|
||||||
$plantId = $get('plant');
|
$plantId = $get('plant');
|
||||||
@@ -289,6 +280,7 @@ class LocatorInvoiceValidationResource extends Resource
|
|||||||
if ($state !== '1') {
|
if ($state !== '1') {
|
||||||
$set('update_locator_invoice', '0');
|
$set('update_locator_invoice', '0');
|
||||||
$set('pallet_number', null);
|
$set('pallet_number', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,13 +288,13 @@ class LocatorInvoiceValidationResource extends Resource
|
|||||||
->where('pallet_number', $palletNumber)
|
->where('pallet_number', $palletNumber)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if (!$palletRecord)
|
if (! $palletRecord) {
|
||||||
{
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title("Pallet number '{$palletNumber}' does not exist.")
|
->title("Pallet number '{$palletNumber}' does not exist.")
|
||||||
->danger()
|
->danger()
|
||||||
->duration(5000)
|
->duration(5000)
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,13 +310,13 @@ class LocatorInvoiceValidationResource extends Resource
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$allCompleted)
|
if (! $allCompleted) {
|
||||||
{
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title("Pallet number '{$palletNumber}' is not completed in masters")
|
->title("Pallet number '{$palletNumber}' is not completed in masters")
|
||||||
->danger()
|
->danger()
|
||||||
->duration(5000)
|
->duration(5000)
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,7 +405,7 @@ class LocatorInvoiceValidationResource extends Resource
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
})
|
}),
|
||||||
])
|
])
|
||||||
->columns(5),
|
->columns(5),
|
||||||
|
|
||||||
@@ -431,6 +423,7 @@ class LocatorInvoiceValidationResource 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')
|
||||||
@@ -504,6 +497,7 @@ class LocatorInvoiceValidationResource extends Resource
|
|||||||
// ->options(Plant::pluck('name', 'id')->toArray())
|
// ->options(Plant::pluck('name', 'id')->toArray())
|
||||||
->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();
|
||||||
})
|
})
|
||||||
->label('Select Plant')
|
->label('Select Plant')
|
||||||
@@ -524,7 +518,7 @@ class LocatorInvoiceValidationResource extends Resource
|
|||||||
->reactive()
|
->reactive()
|
||||||
->required()
|
->required()
|
||||||
->disk('local')
|
->disk('local')
|
||||||
->visible(fn (Get $get) => !empty($get('plant_id')))
|
->visible(fn (Get $get) => ! empty($get('plant_id')))
|
||||||
->directory('uploads/temp'),
|
->directory('uploads/temp'),
|
||||||
])
|
])
|
||||||
->action(function (array $data) {
|
->action(function (array $data) {
|
||||||
@@ -546,8 +540,7 @@ class LocatorInvoiceValidationResource extends Resource
|
|||||||
$fullFolderPath = "uploads/$folderPath";
|
$fullFolderPath = "uploads/$folderPath";
|
||||||
|
|
||||||
// Check if the folder exists, if not, create it
|
// Check if the folder exists, if not, create it
|
||||||
if (!Storage::disk('local')->exists($fullFolderPath))
|
if (! Storage::disk('local')->exists($fullFolderPath)) {
|
||||||
{
|
|
||||||
Storage::disk('local')->makeDirectory($fullFolderPath);
|
Storage::disk('local')->makeDirectory($fullFolderPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -555,12 +548,10 @@ class LocatorInvoiceValidationResource extends Resource
|
|||||||
|
|
||||||
$fullPath = Storage::disk('local')->path($path);
|
$fullPath = Storage::disk('local')->path($path);
|
||||||
|
|
||||||
if ($fullPath && file_exists($fullPath))
|
if ($fullPath && file_exists($fullPath)) {
|
||||||
{
|
|
||||||
$rows = Excel::toArray(null, $fullPath)[0];
|
$rows = Excel::toArray(null, $fullPath)[0];
|
||||||
|
|
||||||
if((count($rows) - 1) <= 0)
|
if ((count($rows) - 1) <= 0) {
|
||||||
{
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Invalid Locator Invoice Found')
|
->title('Invalid Locator Invoice Found')
|
||||||
->body('Uploaded excel sheet is empty or<br>contains no valid data.')
|
->body('Uploaded excel sheet is empty or<br>contains no valid data.')
|
||||||
@@ -571,37 +562,31 @@ class LocatorInvoiceValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$invalidSerialCodes=[];
|
$invalidSerialCodes = [];
|
||||||
$duplicateSerials = [];
|
$duplicateSerials = [];
|
||||||
$seenSerialNumbers = [];
|
$seenSerialNumbers = [];
|
||||||
$validRowsFound = false;
|
$validRowsFound = false;
|
||||||
|
|
||||||
foreach ($rows as $index => $row)
|
foreach ($rows as $index => $row) {
|
||||||
{
|
if ($index === 0) {
|
||||||
if ($index === 0) continue; // Skip header
|
continue;
|
||||||
|
} // Skip header
|
||||||
|
|
||||||
$serialNumber = trim($row[0]);
|
$serialNumber = trim($row[0]);
|
||||||
|
|
||||||
if (empty($serialNumber))
|
if (empty($serialNumber)) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
} else {
|
||||||
else
|
if (Str::length($serialNumber) < 9 || Str::length($serialNumber) > 20 || ! ctype_alnum($serialNumber)) {
|
||||||
{
|
|
||||||
if(Str::length($serialNumber) < 9 || Str::length($serialNumber) > 20 || !ctype_alnum($serialNumber))
|
|
||||||
{
|
|
||||||
$invalidSerialCodes[] = $serialNumber;
|
$invalidSerialCodes[] = $serialNumber;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
if (in_array($serialNumber, $seenSerialNumbers)) {
|
if (in_array($serialNumber, $seenSerialNumbers)) {
|
||||||
$duplicateSerials[] = $serialNumber;
|
$duplicateSerials[] = $serialNumber;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$seenSerialNumbers[] = $serialNumber;
|
$seenSerialNumbers[] = $serialNumber;
|
||||||
$validRowsFound = true;
|
$validRowsFound = true;
|
||||||
}
|
}
|
||||||
@@ -611,10 +596,10 @@ class LocatorInvoiceValidationResource extends Resource
|
|||||||
|
|
||||||
$uniqueSerialCodes = array_unique($invalidSerialCodes);
|
$uniqueSerialCodes = array_unique($invalidSerialCodes);
|
||||||
|
|
||||||
if (!empty($uniqueSerialCodes)) {
|
if (! empty($uniqueSerialCodes)) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Invalid Serial Numbers Found')
|
->title('Invalid Serial Numbers Found')
|
||||||
->body('The following serial numbers should contain minimum 9 digit (and maximum 20 digit) alpha numeric values:<br>' . implode(', ', $uniqueSerialCodes))
|
->body('The following serial numbers should contain minimum 9 digit (and maximum 20 digit) alpha numeric values:<br>'.implode(', ', $uniqueSerialCodes))
|
||||||
->danger()
|
->danger()
|
||||||
->duration(5000)
|
->duration(5000)
|
||||||
->send();
|
->send();
|
||||||
@@ -622,15 +607,16 @@ class LocatorInvoiceValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$duplicateSerialCodes = array_unique($duplicateSerials);
|
$duplicateSerialCodes = array_unique($duplicateSerials);
|
||||||
|
|
||||||
if (!empty($duplicateSerialCodes)) {
|
if (! empty($duplicateSerialCodes)) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Duplicate Serial Numbers Found')
|
->title('Duplicate Serial Numbers Found')
|
||||||
->body('The following serial numbers are already exist in imported excel:<br>' . implode(', ', $duplicateSerialCodes))
|
->body('The following serial numbers are already exist in imported excel:<br>'.implode(', ', $duplicateSerialCodes))
|
||||||
->danger()
|
->danger()
|
||||||
->duration(5000)
|
->duration(5000)
|
||||||
->send();
|
->send();
|
||||||
@@ -638,10 +624,11 @@ class LocatorInvoiceValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$validRowsFound) {
|
if (! $validRowsFound) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Invalid Locator Invoice Found')
|
->title('Invalid Locator Invoice Found')
|
||||||
->body('Uploaded excel sheet is empty or<br>contains no valid data.')
|
->body('Uploaded excel sheet is empty or<br>contains no valid data.')
|
||||||
@@ -652,6 +639,7 @@ class LocatorInvoiceValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -663,10 +651,10 @@ class LocatorInvoiceValidationResource extends Resource
|
|||||||
->pluck('serial_number')
|
->pluck('serial_number')
|
||||||
->toArray();
|
->toArray();
|
||||||
|
|
||||||
if (!empty($existingSerials)) {
|
if (! empty($existingSerials)) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Duplicate Serial Numbers Found')
|
->title('Duplicate Serial Numbers Found')
|
||||||
->body('The following serial numbers already exist with a different invoice number:<br>' . implode(', ', $existingSerials))
|
->body('The following serial numbers already exist with a different invoice number:<br>'.implode(', ', $existingSerials))
|
||||||
->danger()
|
->danger()
|
||||||
->duration(5000)
|
->duration(5000)
|
||||||
->send();
|
->send();
|
||||||
@@ -674,10 +662,9 @@ class LocatorInvoiceValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// Save full file path to session
|
// Save full file path to session
|
||||||
session(['uploaded_invoice_path' => $fullPath]);
|
session(['uploaded_invoice_path' => $fullPath]);
|
||||||
Notification::make()
|
Notification::make()
|
||||||
@@ -688,7 +675,7 @@ class LocatorInvoiceValidationResource extends Resource
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view import dispatch serial invoice validation');
|
return Filament::auth()->user()->can('view import dispatch serial invoice validation');
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -696,22 +683,17 @@ class LocatorInvoiceValidationResource extends Resource
|
|||||||
->importer(LocatorInvoiceValidationImporter::class)
|
->importer(LocatorInvoiceValidationImporter::class)
|
||||||
->label('Import Locator Invoice')
|
->label('Import Locator Invoice')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view import locator invoice validation');
|
return Filament::auth()->user()->can('view import locator invoice validation');
|
||||||
}),
|
}),
|
||||||
ExportAction::make()
|
ExportAction::make()
|
||||||
->exporter(LocatorInvoiceValidationExporter::class)
|
->exporter(LocatorInvoiceValidationExporter::class)
|
||||||
->label('Export Locator Invoice')
|
->label('Export Locator Invoice')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view export locator invoice validation');
|
return Filament::auth()->user()->can('view export locator 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')
|
||||||
@@ -725,6 +707,7 @@ class LocatorInvoiceValidationResource 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()
|
||||||
@@ -745,12 +728,13 @@ class LocatorInvoiceValidationResource 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 LocatorInvoiceValidation::where('plant_id', $plantId)
|
return LocatorInvoiceValidation::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')
|
||||||
@@ -767,12 +751,13 @@ class LocatorInvoiceValidationResource 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 LocatorInvoiceValidation::where('plant_id', $plantId)
|
return LocatorInvoiceValidation::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')
|
||||||
@@ -785,12 +770,13 @@ class LocatorInvoiceValidationResource 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 LocatorInvoiceValidation::where('plant_id', $plantId)
|
return LocatorInvoiceValidation::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')
|
||||||
@@ -837,103 +823,115 @@ class LocatorInvoiceValidationResource 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['created_from'])) {
|
if (! empty($data['created_from'])) {
|
||||||
$query->where('created_at', '>=', $data['created_from']);
|
$query->where('created_at', '>=', $data['created_from']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['created_to'])) {
|
if (! empty($data['created_to'])) {
|
||||||
$query->where('created_at', '<=', $data['created_to']);
|
$query->where('created_at', '<=', $data['created_to']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['created_by'])) {
|
if (! empty($data['created_by'])) {
|
||||||
$query->where('created_by', $data['created_by']);
|
$query->where('created_by', $data['created_by']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['scanned_from'])) {
|
if (! empty($data['scanned_from'])) {
|
||||||
$query->where('scanned_at', '>=', $data['scanned_from']);
|
$query->where('scanned_at', '>=', $data['scanned_from']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['scanned_to'])) {
|
if (! empty($data['scanned_to'])) {
|
||||||
$query->where('scanned_at', '<=', $data['scanned_to']);
|
$query->where('scanned_at', '<=', $data['scanned_to']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['scanned_by'])) {
|
if (! empty($data['scanned_by'])) {
|
||||||
$query->where('scanned_by', $data['scanned_by']);
|
$query->where('scanned_by', $data['scanned_by']);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
->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['created_from'])) {
|
if (! empty($data['created_from'])) {
|
||||||
$indicators[] = 'From: ' . $data['created_from'];
|
$indicators[] = 'From: '.$data['created_from'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['created_to'])) {
|
if (! empty($data['created_to'])) {
|
||||||
$indicators[] = 'To: ' . $data['created_to'];
|
$indicators[] = 'To: '.$data['created_to'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['created_by'])) {
|
if (! empty($data['created_by'])) {
|
||||||
$indicators[] = 'Created By: ' . $data['created_by'];
|
$indicators[] = 'Created By: '.$data['created_by'];
|
||||||
}
|
}
|
||||||
if (!empty($data['scanned_from'])) {
|
if (! empty($data['scanned_from'])) {
|
||||||
$indicators[] = 'Scanned From: ' . $data['scanned_from'];
|
$indicators[] = 'Scanned From: '.$data['scanned_from'];
|
||||||
}
|
}
|
||||||
if (!empty($data['scanned_to'])) {
|
if (! empty($data['scanned_to'])) {
|
||||||
$indicators[] = 'Scanned To: ' . $data['scanned_to'];
|
$indicators[] = 'Scanned To: '.$data['scanned_to'];
|
||||||
}
|
}
|
||||||
if (!empty($data['scanned_by'])) {
|
if (! empty($data['scanned_by'])) {
|
||||||
$indicators[] = 'Scanned By: ' . $data['scanned_by'];
|
$indicators[] = 'Scanned By: '.$data['scanned_by'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $indicators;
|
return $indicators;
|
||||||
})
|
}),
|
||||||
])
|
])
|
||||||
->filtersFormMaxHeight('280px')
|
->filtersFormMaxHeight('280px')
|
||||||
->actions([
|
->actions([
|
||||||
|
|||||||
Reference in New Issue
Block a user