diff --git a/app/Filament/Resources/PalletValidationResource.php b/app/Filament/Resources/PalletValidationResource.php index 6e09c4059..240b9edfd 100644 --- a/app/Filament/Resources/PalletValidationResource.php +++ b/app/Filament/Resources/PalletValidationResource.php @@ -476,7 +476,48 @@ class PalletValidationResource extends Resource Tables\Actions\RestoreBulkAction::make(), ]), ]) + // ->headerActions([ ->headerActions([ + Tables\Actions\Action::make('reprint_pallet') + ->label('Re-Print Pallet QR') + ->form([ + Select::make('plant') + ->options(Plant::pluck('name', 'id')->toArray()) + ->label('Select Plant') + ->required() + ->reactive(), + Select::make('pallet_list') + ->label('Select Pallet') + ->searchable() + ->required() + ->reactive() + ->options(function (callable $get) { + $plantId = $get('plant'); + + if (!$plantId) { + return []; + } + + return PalletValidation::query() + ->where('plant_id', $plantId) + ->whereNotNull('pallet_number') + ->where('pallet_number','!=', '') + ->select('pallet_number') + ->distinct() + ->orderBy('pallet_number') + ->pluck('pallet_number', 'pallet_number') + ->toArray(); + }), + + ]) + ->action(function (array $data) { + $selectedPalletNumber = $data['pallet_list']; + return redirect()->route('download-qr-pdf', ['palletNo' => $selectedPalletNumber]); + + }) + ->visible(function() { + return Filament::auth()->user()->can('view reprint pallet number'); + }), ImportAction::make() ->importer(PalletValidationImporter::class) ->visible(function() {