From 3b890374e0a7d27c8c8b0f040256dde3f7aa1401 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Thu, 20 Aug 2026 09:18:05 +0530 Subject: [PATCH 1/2] Added inspection lot number in panel box validation resource page --- .../Resources/PanelBoxValidationResource.php | 99 +++++++++++++++++-- .../Pages/CreatePanelBoxValidation.php | 8 ++ 2 files changed, 97 insertions(+), 10 deletions(-) diff --git a/app/Filament/Resources/PanelBoxValidationResource.php b/app/Filament/Resources/PanelBoxValidationResource.php index b0b5518..83d7289 100644 --- a/app/Filament/Resources/PanelBoxValidationResource.php +++ b/app/Filament/Resources/PanelBoxValidationResource.php @@ -24,6 +24,10 @@ use Filament\Forms\Components\Select; use Filament\Forms\Components\TextInput; use Filament\Tables\Filters\Filter; use Str; +use Filament\Tables\Actions\ExportAction; +use Filament\Tables\Actions\ImportAction; +use App\Filament\Exports\PanelBoxValidationExporter; +use App\Filament\Imports\PanelBoxValidationImporter; class PanelBoxValidationResource extends Resource { @@ -172,6 +176,40 @@ class PanelBoxValidationResource extends Resource $set('production_order', request()->get('production_order')); } }), + Forms\Components\TextInput::make('inspection_lot_number') + ->label('Inspec Lot No') + ->placeholder('Scan the valid Inspec Lot No') + ->minLength(7) + ->maxLength(14) + ->reactive() + ->readOnly(fn (callable $get) => $get('item_id')) + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + if (! is_numeric($get('inspection_lot_number'))) { + $set('inspecOrdError', 'Must be a numeric value.'); + $set('item_id', null); + $set('sticker_master_id', null); + $set('uom', null); + $set('serial_number', null); + } else { + $set('inspecOrdError', null); + $set('inspection_lot_number', $state); + $set('inspection', $state); + } + }) + ->default(fn ($get) => $get('inspection') ?? session('last_selected_inspection')) + ->extraAttributes(fn ($get) => [ + 'class' => $get('inspecOrdError') ? 'border-red-500' : '', + ]) + ->hint(fn ($get) => $get('inspecOrdError') ? $get('inspecOrdError') : null) + ->hintColor('danger') + ->required(), + Forms\Components\Hidden::make('inspection') + ->default(fn () => session('last_selected_inspection')) + ->afterStateHydrated(function ($state, $set) { + if (! $state && request()->has('inspection_lot_number')) { + $set('inspection_lot_number', request()->get('inspection_lot_number')); + } + }), Forms\Components\TextInput::make('item_id') ->label('Item Code') // ->id('item_id') @@ -186,6 +224,7 @@ class PanelBoxValidationResource extends Resource $pId = $get('line_id'); $plantId = $get('plant_id'); $plaCode = Plant::find($plantId)?->code; + $inspecLotNo = $get('inspection_lot_number'); $set('part_validation_type', null); $set('show_validation_image', false); $set('validation1_image_url', null); @@ -584,6 +623,15 @@ class PanelBoxValidationResource extends Resource $set('item_id', null); return; } + else if($existInMaster->inspection_lot_number != $inspecLotNo){ + Notification::make() + ->title('Panel GR Found') + ->body("Inspection Lot Number code not match for Production Order (Or) Doc No'{$pOrder}' and Item '{$itemCode}'.") + ->danger() + ->send(); + $set('item_id', null); + return; + } else if($existInMaster->quantity == '' || $existInMaster->quantity == null){ Notification::make() ->title('Panel GR Found') @@ -1619,6 +1667,11 @@ class PanelBoxValidationResource extends Resource ->alignCenter() ->searchable() ->sortable(), + Tables\Columns\TextColumn::make('inspection_lot_number') + ->label('Inspection Lot No') + ->alignCenter() + ->searchable() + ->sortable(), Tables\Columns\TextColumn::make('serial_number') ->label('Serial Number') ->alignCenter() @@ -1628,52 +1681,62 @@ class PanelBoxValidationResource extends Resource ->label('Serial Number Panel') ->alignCenter() ->searchable() - ->sortable(), + ->sortable() + ->visible(fn ($record) => $record?->stickerMaster?->serial_number_panel == 1), Tables\Columns\TextColumn::make('pack_slip_panel') ->label('Pack Slip Panel') ->alignCenter() ->searchable() - ->sortable(), + ->sortable() + ->visible(fn ($record) => $record?->stickerMaster?->pack_slip_panel == 1), Tables\Columns\TextColumn::make('name_plate_panel') ->label('Name Plate Panel') ->alignCenter() ->searchable() - ->sortable(), + ->sortable() + ->visible(fn ($record) => $record?->stickerMaster?->name_plate_panel == 1), Tables\Columns\TextColumn::make('tube_sticker_panel') ->label('Tube Sticker Panel') ->alignCenter() ->searchable() - ->sortable(), + ->sortable() + ->visible(fn ($record) => $record?->stickerMaster?->tube_sticker_panel == 1), Tables\Columns\TextColumn::make('warranty_card_panel') ->label('Warranty Card Panel') ->alignCenter() ->searchable() - ->sortable(), + ->sortable() + ->visible(fn ($record) => $record?->stickerMaster?->warranty_card_panel == 1), Tables\Columns\TextColumn::make('part_validation1') ->label('Part Validation 1') ->alignCenter() ->searchable() - ->sortable(), + ->sortable() + ->visible(fn ($record) => $record?->stickerMaster?->part_validation1 != null), Tables\Columns\TextColumn::make('part_validation2') ->label('Part Validation 2') ->alignCenter() ->searchable() - ->sortable(), + ->sortable() + ->visible(fn ($record) => $record?->stickerMaster?->part_validation2 != null), Tables\Columns\TextColumn::make('part_validation3') ->label('Part Validation 3') ->alignCenter() ->searchable() - ->sortable(), + ->sortable() + ->visible(fn ($record) => $record?->stickerMaster?->part_validation3 != null), Tables\Columns\TextColumn::make('part_validation4') ->label('Part Validation 4') ->alignCenter() ->searchable() - ->sortable(), + ->sortable() + ->visible(fn ($record) => $record?->stickerMaster?->part_validation4 != null), Tables\Columns\TextColumn::make('part_validation5') ->label('Part Validation 5') ->alignCenter() ->searchable() - ->sortable(), + ->sortable() + ->visible(fn ($record) => $record?->stickerMaster?->part_validation5 != null), Tables\Columns\TextColumn::make('panel_box_supplier') ->label('Panel Box Supplier') ->alignCenter() @@ -1909,6 +1972,22 @@ class PanelBoxValidationResource extends Resource Tables\Actions\ForceDeleteBulkAction::make(), Tables\Actions\RestoreBulkAction::make(), ]), + ]) + ->headerActions([ + ImportAction::make() + ->label('Import Panel Box Validation') + ->color('warning') + ->importer(PanelBoxValidationImporter::class) + ->visible(function () { + return Filament::auth()->user()->can('view import panel box validation'); + }), + ExportAction::make() + ->label('Export Panel Box Validation') + ->color('warning') + ->exporter(PanelBoxValidationExporter::class) + ->visible(function () { + return Filament::auth()->user()->can('view export panel box validation'); + }), ]); } diff --git a/app/Filament/Resources/PanelBoxValidationResource/Pages/CreatePanelBoxValidation.php b/app/Filament/Resources/PanelBoxValidationResource/Pages/CreatePanelBoxValidation.php index 02de7c7..b8e97bf 100644 --- a/app/Filament/Resources/PanelBoxValidationResource/Pages/CreatePanelBoxValidation.php +++ b/app/Filament/Resources/PanelBoxValidationResource/Pages/CreatePanelBoxValidation.php @@ -46,6 +46,7 @@ class CreatePanelBoxValidation extends CreateRecord { 'last_selected_plant_id', 'last_selected_line', 'last_selected_production', + 'last_selected_inspection', ]); } @@ -117,6 +118,7 @@ class CreatePanelBoxValidation extends CreateRecord { 'plant_id' => $this->data['plant_id'] ?? null, 'line_id' => $this->data['line_id'] ?? null, 'production_order' => $this->data['production_order'] ?? null, + 'inspection_lot_number' => $this->data['inspection_lot_number'] ?? null, ]) ); } @@ -220,6 +222,7 @@ class CreatePanelBoxValidation extends CreateRecord { $plant = $this->form->getState()['plant'] ?? null; $line = $this->form->getState()['line'] ?? null; $production = $this->form->getState()['production'] ?? null; + $inspection = $this->form->getState()['inspection'] ?? null; // $this->skipChecklistValidation = false; // $this->showChecklist = false; @@ -244,6 +247,7 @@ class CreatePanelBoxValidation extends CreateRecord { 'plant_id' => null, 'line_id' => null, 'production_order' => null, + 'inspection_lot_number' => null, ]); @@ -260,6 +264,9 @@ class CreatePanelBoxValidation extends CreateRecord { if ($production) { session(['last_selected_production' => $production]); } + if ($inspection) { + session(['last_selected_inspection' => $inspection]); + } } protected function getRedirectUrl(): string @@ -270,6 +277,7 @@ class CreatePanelBoxValidation extends CreateRecord { 'plant_id' => $this->data['plant_id'] ?? null, 'line_id' => $this->data['line_id'] ?? null, 'production_order' => $this->data['production_order'] ?? null, + 'inspection_lot_number' => $this->data['inspection_lot_number'] ?? null, ]); } } From 38dc55ac7c34b5ea728f9c3b9e25e44ba5b736d4 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Thu, 20 Aug 2026 09:19:05 +0530 Subject: [PATCH 2/2] Added panel box validation importer and exporter --- .../Exports/PanelBoxValidationExporter.php | 87 +++++++++++++++++++ .../Imports/PanelBoxValidationImporter.php | 70 +++++++++++++++ 2 files changed, 157 insertions(+) create mode 100644 app/Filament/Exports/PanelBoxValidationExporter.php create mode 100644 app/Filament/Imports/PanelBoxValidationImporter.php diff --git a/app/Filament/Exports/PanelBoxValidationExporter.php b/app/Filament/Exports/PanelBoxValidationExporter.php new file mode 100644 index 0000000..1fb4bd3 --- /dev/null +++ b/app/Filament/Exports/PanelBoxValidationExporter.php @@ -0,0 +1,87 @@ +label('NO') + ->state(function ($record) use (&$rowNumber) { + // Increment and return the row number + return ++$rowNumber; + }), + ExportColumn::make('plant.name') + ->label('PLANT NAME'), + ExportColumn::make('line.name') + ->label('LINE NAME'), + ExportColumn::make('stickerMaster.item.code') + ->label('ITEM CODE'), + ExportColumn::make('production_order') + ->label('PRODUCTION ORDER'), + ExportColumn::make('inspection_lot_number') + ->label('INSPECTION LOT NUMBER'), + ExportColumn::make('serial_number') + ->label('SERIAL NUMBER'), + ExportColumn::make('panel_box_supplier') + ->label('PANEL BOX SUPPLIER'), + ExportColumn::make('panel_box_serial_number') + ->label('PANEL BOX SERIAL NUMBER'), + ExportColumn::make('panel_box_code') + ->label('PANEL BOX CODE'), + ExportColumn::make('serial_number_panel') + ->label('SERIAL NUMBER PANEL'), + ExportColumn::make('pack_slip_panel') + ->label('PACK SLIP PANEL'), + ExportColumn::make('name_plate_panel') + ->label('NAME PLATE PANEL'), + ExportColumn::make('tube_sticker_panel') + ->label('TUBE STICKER PANEL'), + ExportColumn::make('warranty_card_panel') + ->label('WARRANTY CARD PANEL'), + ExportColumn::make('part_validation1') + ->label('PART VALIDATION 1'), + ExportColumn::make('part_validation2') + ->label('PART VALIDATION 2'), + ExportColumn::make('part_validation3') + ->label('PART VALIDATION 3'), + ExportColumn::make('part_validation4') + ->label('PART VALIDATION 4'), + ExportColumn::make('part_validation5') + ->label('PART VALIDATION 5'), + 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 panel box 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/PanelBoxValidationImporter.php b/app/Filament/Imports/PanelBoxValidationImporter.php new file mode 100644 index 0000000..dfc91c5 --- /dev/null +++ b/app/Filament/Imports/PanelBoxValidationImporter.php @@ -0,0 +1,70 @@ +requiredMapping() + ->relationship() + ->rules(['required']), + ImportColumn::make('line') + ->requiredMapping() + ->relationship() + ->rules(['required']), + ImportColumn::make('stickerMaster') + ->requiredMapping() + ->relationship() + ->rules(['required']), + ImportColumn::make('production_order'), + ImportColumn::make('serial_number'), + ImportColumn::make('serial_number_panel'), + ImportColumn::make('pack_slip_panel'), + ImportColumn::make('name_plate_panel'), + ImportColumn::make('tube_sticker_panel'), + ImportColumn::make('warranty_card_panel'), + ImportColumn::make('part_validation1'), + ImportColumn::make('part_validation2'), + ImportColumn::make('part_validation3'), + ImportColumn::make('part_validation4'), + ImportColumn::make('part_validation5'), + ImportColumn::make('created_by'), + ImportColumn::make('updated_by'), + ImportColumn::make('panel_box_supplier'), + ImportColumn::make('panel_box_serial_number'), + ImportColumn::make('panel_box_code'), + ImportColumn::make('inspection_lot_number'), + ]; + } + + public function resolveRecord(): ?PanelBoxValidation + { + // return PanelBoxValidation::firstOrNew([ + // // Update existing records, matching them by `$this->data['column_name']` + // 'email' => $this->data['email'], + // ]); + + return new PanelBoxValidation(); + } + + public static function getCompletedNotificationBody(Import $import): string + { + $body = 'Your panel box 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; + } +}