From 6fd005acf924823d7f7b0b595e6d8a30d0ddc415 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 25 May 2026 15:00:45 +0530 Subject: [PATCH 1/6] Added asrs item validation migration file --- ...025_create_asrs_item_validations_table.php | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 database/migrations/2026_05_25_141025_create_asrs_item_validations_table.php diff --git a/database/migrations/2026_05_25_141025_create_asrs_item_validations_table.php b/database/migrations/2026_05_25_141025_create_asrs_item_validations_table.php new file mode 100644 index 0000000..e8de26d --- /dev/null +++ b/database/migrations/2026_05_25_141025_create_asrs_item_validations_table.php @@ -0,0 +1,47 @@ + Date: Mon, 25 May 2026 15:01:17 +0530 Subject: [PATCH 2/6] Added asrs item validation model file --- app/Models/AsrsItemValidation.php | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 app/Models/AsrsItemValidation.php diff --git a/app/Models/AsrsItemValidation.php b/app/Models/AsrsItemValidation.php new file mode 100644 index 0000000..d8b0ddb --- /dev/null +++ b/app/Models/AsrsItemValidation.php @@ -0,0 +1,33 @@ +belongsTo(Plant::class); + } +} From 0f6276fd763d81f1cfde78dc9e2fa32012f1475a Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 25 May 2026 15:02:19 +0530 Subject: [PATCH 3/6] Added asrs item validation resource page --- .../Resources/AsrsItemValidationResource.php | 231 ++++++++++++++++++ .../Pages/CreateAsrsItemValidation.php | 12 + .../Pages/EditAsrsItemValidation.php | 22 ++ .../Pages/ListAsrsItemValidations.php | 19 ++ .../Pages/ViewAsrsItemValidation.php | 19 ++ 5 files changed, 303 insertions(+) create mode 100644 app/Filament/Resources/AsrsItemValidationResource.php create mode 100644 app/Filament/Resources/AsrsItemValidationResource/Pages/CreateAsrsItemValidation.php create mode 100644 app/Filament/Resources/AsrsItemValidationResource/Pages/EditAsrsItemValidation.php create mode 100644 app/Filament/Resources/AsrsItemValidationResource/Pages/ListAsrsItemValidations.php create mode 100644 app/Filament/Resources/AsrsItemValidationResource/Pages/ViewAsrsItemValidation.php diff --git a/app/Filament/Resources/AsrsItemValidationResource.php b/app/Filament/Resources/AsrsItemValidationResource.php new file mode 100644 index 0000000..c826e81 --- /dev/null +++ b/app/Filament/Resources/AsrsItemValidationResource.php @@ -0,0 +1,231 @@ +schema([ + Forms\Components\Select::make('plant_id') + ->label('Plant') + ->relationship('plant', 'name') + ->required() + ->disabledOn('edit'), + Forms\Components\Select::make('item_code') + ->label('Item Code') + ->reactive() + ->options(function (Get $get) { + $plantId = $get('plant_id'); + + if (!$plantId) { + return []; + } + + return AsrsItemValidation::where('plant_id', $plantId) + ->pluck('item_code', 'item_code'); + }) + ->searchable() + ->afterStateUpdated(function (callable $set, $state) { + $item = AsrsItemValidation::where('item_code', $state)->first(); + + if ($item) { + $set('item_description', $item->item_description); + $set('uom', $item->uom); + } else { + $set('item_description', null); + $set('uom', null); + } + }) + ->disabledOn('edit'), + Forms\Components\TextInput::make('item_description') + ->label('Item Description') + ->readOnly() + ->reactive() + ->disabledOn('edit'), + Forms\Components\TextInput::make('uom') + ->label('UOM') + ->readOnly() + ->reactive() + ->disabledOn('edit'), + Forms\Components\Select::make('mhe') + ->label('MHE') + ->options([ + 'Bin1000*800*750' => 'Bin 1000*800*750', + 'Bin1000*800*1000' => 'Bin 1000*800*1000', + 'Pallet' => 'Pallet', + 'ChinaBin' => 'China Bin', + 'PalletWithPlasticCrate' => 'Pallet With Plastic Crate', + 'PlasticCrateBig' => 'Plastic Crate Big', + 'PlasticCrateSmall' => 'Plastic Crate Small', + 'OutsideStorage' => 'Outside Storage', + ]), + Forms\Components\TextInput::make('bin_quantity') + ->label('Bin Quantity'), + Forms\Components\Select::make('asrs') + ->label('ASRS') + ->options([ + 'ASRS1' => 'ASRS1', + 'ASRS2' => 'ASRS2', + ]), + Forms\Components\Select::make('asrs_category') + ->label('ASRS Category') + ->options([ + 'In' => 'In', + 'Out' => 'Out', + ]), + Forms\Components\Select::make('status') + ->label('Status') + ->options([ + 'Updated' => 'Updated', + 'NotUpdated' => 'Not Updated', + ]), + Forms\Components\Hidden::make('created_by') + ->label('Created By') + ->default(Filament::auth()->user()?->name ?? ''), + Forms\Components\Hidden::make('updated_by') + ->label('Updated By') + ->default(Filament::auth()->user()?->name ?? ''), + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + Tables\Columns\TextColumn::make('No.') + ->label('No.') + ->getStateUsing(function ($record, $livewire, $column, $rowLoop) { + $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; + }) + ->alignCenter(), + Tables\Columns\TextColumn::make('plant.name') + ->label('Plant') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('item_code') + ->label('Item Code') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('item_description') + ->label('Item Description') + ->alignCenter() + ->searchable(), + Tables\Columns\TextColumn::make('uom') + ->label('UOM') + ->alignCenter() + ->searchable(), + Tables\Columns\TextColumn::make('mhe') + ->label('MHE') + ->alignCenter() + ->searchable(), + Tables\Columns\TextColumn::make('bin_quantity') + ->label('Bin Quantity') + ->alignCenter() + ->searchable(), + Tables\Columns\TextColumn::make('asrs') + ->label('ASRS') + ->alignCenter() + ->searchable(), + Tables\Columns\TextColumn::make('asrs_category') + ->label('ASRS Category') + ->alignCenter() + ->searchable(), + Tables\Columns\TextColumn::make('status') + ->label('Status') + ->alignCenter() + ->searchable(), + Tables\Columns\TextColumn::make('created_at') + ->dateTime() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + Tables\Columns\TextColumn::make('updated_at') + ->dateTime() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + Tables\Columns\TextColumn::make('deleted_at') + ->dateTime() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + ]) + ->filters([ + Tables\Filters\TrashedFilter::make(), + ]) + ->actions([ + Tables\Actions\ViewAction::make(), + Tables\Actions\EditAction::make(), + ]) + ->bulkActions([ + Tables\Actions\BulkActionGroup::make([ + Tables\Actions\DeleteBulkAction::make(), + Tables\Actions\ForceDeleteBulkAction::make(), + Tables\Actions\RestoreBulkAction::make(), + ]), + ]) + ->headerActions([ + ImportAction::make() + ->importer(AsrsItemValidationImporter::class) + ->visible(function() { + return Filament::auth()->user()->can('view import asrs item validation'); + }), + ExportAction::make() + ->exporter(AsrsItemValidationExporter::class) + ->visible(function() { + return Filament::auth()->user()->can('view export asrs item validation'); + }), + ]); + } + + public static function getRelations(): array + { + return [ + // + ]; + } + + public static function getPages(): array + { + return [ + 'index' => Pages\ListAsrsItemValidations::route('/'), + 'create' => Pages\CreateAsrsItemValidation::route('/create'), + 'view' => Pages\ViewAsrsItemValidation::route('/{record}'), + 'edit' => Pages\EditAsrsItemValidation::route('/{record}/edit'), + ]; + } + + public static function getEloquentQuery(): Builder + { + return parent::getEloquentQuery() + ->withoutGlobalScopes([ + SoftDeletingScope::class, + ]); + } +} diff --git a/app/Filament/Resources/AsrsItemValidationResource/Pages/CreateAsrsItemValidation.php b/app/Filament/Resources/AsrsItemValidationResource/Pages/CreateAsrsItemValidation.php new file mode 100644 index 0000000..7245839 --- /dev/null +++ b/app/Filament/Resources/AsrsItemValidationResource/Pages/CreateAsrsItemValidation.php @@ -0,0 +1,12 @@ + Date: Mon, 25 May 2026 15:02:55 +0530 Subject: [PATCH 4/6] Added asrs item validation importer and exporter --- .../Exports/AsrsItemValidationExporter.php | 66 +++++++++++ .../Imports/AsrsItemValidationImporter.php | 106 ++++++++++++++++++ 2 files changed, 172 insertions(+) create mode 100644 app/Filament/Exports/AsrsItemValidationExporter.php create mode 100644 app/Filament/Imports/AsrsItemValidationImporter.php diff --git a/app/Filament/Exports/AsrsItemValidationExporter.php b/app/Filament/Exports/AsrsItemValidationExporter.php new file mode 100644 index 0000000..7d9968f --- /dev/null +++ b/app/Filament/Exports/AsrsItemValidationExporter.php @@ -0,0 +1,66 @@ +label('NO') + ->state(function ($record) use (&$rowNumber) { + // Increment and return the row number + return ++$rowNumber; + }), + ExportColumn::make('plant.code') + ->label('PLANT'), + ExportColumn::make('item_code') + ->label('ITEM CODE'), + ExportColumn::make('item_description') + ->label('ITEM DESCRIPTION'), + ExportColumn::make('uom') + ->label('UOM'), + ExportColumn::make('mhe') + ->label('MHE'), + ExportColumn::make('bin_quantity') + ->label('BIN QUANTITY'), + ExportColumn::make('asrs') + ->label('ASRS'), + ExportColumn::make('asrs_category') + ->label('ASRS CATEGORY'), + ExportColumn::make('status') + ->label('STATUS'), + ExportColumn::make('created_at') + ->label('CREATED AT'), + ExportColumn::make('updated_at') + ->label('UPDATED AT'), + ExportColumn::make('created_by') + ->label('CREATED BY'), + ExportColumn::make('updated_by') + ->label('UPDATED BY'), + ExportColumn::make('deleted_at') + ->label('DELETED AT') + ->enabledByDefault(false), + ]; + } + + public static function getCompletedNotificationBody(Export $export): string + { + $body = 'Your asrs item validation export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.'; + + if ($failedRowsCount = $export->getFailedRowsCount()) { + $body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.'; + } + + return $body; + } +} diff --git a/app/Filament/Imports/AsrsItemValidationImporter.php b/app/Filament/Imports/AsrsItemValidationImporter.php new file mode 100644 index 0000000..b2032d5 --- /dev/null +++ b/app/Filament/Imports/AsrsItemValidationImporter.php @@ -0,0 +1,106 @@ +requiredMapping() + ->exampleHeader('PLANT CODE') + ->example('1000') + ->label('PLANT CODE') + ->relationship(resolveUsing: 'code') + ->rules(['required']), + ImportColumn::make('item_code') + ->exampleHeader('ITEM CODE') + ->example('ITEM001') + ->label('ITEM CODE') + ->rules(['required']), + ImportColumn::make('item_description') + ->exampleHeader('ITEM DESCRIPTION') + ->example('Item Description') + ->label('ITEM DESCRIPTION'), + ImportColumn::make('uom') + ->exampleHeader('UOM') + ->example('EA') + ->label('UOM'), + ]; + } + + public function resolveRecord(): ?AsrsItemValidation + { + $warnMsg = []; + $plantCod = trim($this->data['plant']) ?? ''; + $iCode = trim($this->data['item_code']) ?? ''; + $itemDes = trim($this->data['item_description']) ?? ''; + $uom = trim($this->data['uom']) ?? ''; + $createdBy = Filament::auth()->user()?->name ?? ''; + $updatedBy = $createdBy; + + $plantId = null; + + if ($plantCod == null || $plantCod == '' || ! $plantCod) { + $warnMsg[] = "Plant code can't be empty!"; + } elseif (! is_numeric($plantCod)) { + $warnMsg[] = "Plant code '{$plantCod}' should contain only numeric values!"; + } elseif (Str::length($plantCod) < 4 || Str::length($plantCod) > 7) { + $warnMsg[] = "Plant code '{$plantCod}' must be between 4 and 7 digits only!"; + } elseif (! preg_match('/^[1-9]\d{3,6}$/', $plantCod)) { + $warnMsg[] = "Invalid plant code '{$plantCod}' found!"; + } else { + $plant = Plant::where('code', $plantCod)->first(); + if (! $plant) { + $warnMsg[] = 'Plant not found!'; + } else { + $plantId = $plant->id; + } + } + if (Str::length($iCode) < 6 || ! ctype_alnum($iCode)) { + $warnMsg[] = 'Invalid item code found'; + } + if (Str::length($itemDes) < 5) { + $warnMsg[] = 'Invalid description found'; + } + + if (! empty($warnMsg)) { + throw new RowImportFailedException(implode(', ', $warnMsg)); + } + + return AsrsItemValidation::updateOrCreate([ + 'item_code' => $iCode, + 'plant_id' => $plant->id, + ], + [ + 'item_description' => $itemDes, + 'uom' => trim($this->data['uom']), + 'created_by' => $createdBy, + 'updated_by' => $updatedBy, + ] + ); + } + + public static function getCompletedNotificationBody(Import $import): string + { + $body = 'Your asrs item validation import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.'; + + if ($failedRowsCount = $import->getFailedRowsCount()) { + $body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.'; + } + + return $body; + } +} From dd037e7f8a79c38e5fe5305839a4de307f6eef98 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 25 May 2026 15:03:36 +0530 Subject: [PATCH 5/6] Added asrs item validation policy file --- app/Policies/AsrsItemValidationPolicy.php | 106 ++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 app/Policies/AsrsItemValidationPolicy.php diff --git a/app/Policies/AsrsItemValidationPolicy.php b/app/Policies/AsrsItemValidationPolicy.php new file mode 100644 index 0000000..e076d13 --- /dev/null +++ b/app/Policies/AsrsItemValidationPolicy.php @@ -0,0 +1,106 @@ +checkPermissionTo('view-any AsrsItemValidation'); + } + + /** + * Determine whether the user can view the model. + */ + public function view(User $user, AsrsItemValidation $asrsitemvalidation): bool + { + return $user->checkPermissionTo('view AsrsItemValidation'); + } + + /** + * Determine whether the user can create models. + */ + public function create(User $user): bool + { + return $user->checkPermissionTo('create AsrsItemValidation'); + } + + /** + * Determine whether the user can update the model. + */ + public function update(User $user, AsrsItemValidation $asrsitemvalidation): bool + { + return $user->checkPermissionTo('update AsrsItemValidation'); + } + + /** + * Determine whether the user can delete the model. + */ + public function delete(User $user, AsrsItemValidation $asrsitemvalidation): bool + { + return $user->checkPermissionTo('delete AsrsItemValidation'); + } + + /** + * Determine whether the user can delete any models. + */ + public function deleteAny(User $user): bool + { + return $user->checkPermissionTo('delete-any AsrsItemValidation'); + } + + /** + * Determine whether the user can restore the model. + */ + public function restore(User $user, AsrsItemValidation $asrsitemvalidation): bool + { + return $user->checkPermissionTo('restore AsrsItemValidation'); + } + + /** + * Determine whether the user can restore any models. + */ + public function restoreAny(User $user): bool + { + return $user->checkPermissionTo('restore-any AsrsItemValidation'); + } + + /** + * Determine whether the user can replicate the model. + */ + public function replicate(User $user, AsrsItemValidation $asrsitemvalidation): bool + { + return $user->checkPermissionTo('replicate AsrsItemValidation'); + } + + /** + * Determine whether the user can reorder the models. + */ + public function reorder(User $user): bool + { + return $user->checkPermissionTo('reorder AsrsItemValidation'); + } + + /** + * Determine whether the user can permanently delete the model. + */ + public function forceDelete(User $user, AsrsItemValidation $asrsitemvalidation): bool + { + return $user->checkPermissionTo('force-delete AsrsItemValidation'); + } + + /** + * Determine whether the user can permanently delete any models. + */ + public function forceDeleteAny(User $user): bool + { + return $user->checkPermissionTo('force-delete-any AsrsItemValidation'); + } +} From 9d02be360e3e99c23102c4bb6818bbc5867da4bc Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 25 May 2026 15:04:24 +0530 Subject: [PATCH 6/6] Added asrs permissions in seeder page --- database/seeders/PermissionSeeder.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/database/seeders/PermissionSeeder.php b/database/seeders/PermissionSeeder.php index 152df60..407b74d 100644 --- a/database/seeders/PermissionSeeder.php +++ b/database/seeders/PermissionSeeder.php @@ -225,5 +225,9 @@ class PermissionSeeder extends Seeder Permission::updateOrCreate(['name' => 'view print production order button']); Permission::updateOrCreate(['name' => 'view save production order button']); Permission::updateOrCreate(['name' => 'view print panel production order button']); + + Permission::updateOrCreate(['name' => 'view import asrs item validation']); + Permission::updateOrCreate(['name' => 'view export asrs item validation']); + } }