From d8420ce5972e01ab0fc5d04305738150250c1700 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 18 Nov 2026 11:25:15 +0530 Subject: [PATCH] Added process order rejection page and its blade file --- app/Filament/Pages/ProcessOrderRejection.php | 78 +++++++++++++++++++ .../pages/process-order-rejection.blade.php | 14 ++++ 2 files changed, 92 insertions(+) create mode 100644 app/Filament/Pages/ProcessOrderRejection.php create mode 100644 resources/views/filament/pages/process-order-rejection.blade.php diff --git a/app/Filament/Pages/ProcessOrderRejection.php b/app/Filament/Pages/ProcessOrderRejection.php new file mode 100644 index 00000000..86391092 --- /dev/null +++ b/app/Filament/Pages/ProcessOrderRejection.php @@ -0,0 +1,78 @@ +forget(['selected_plant', 'selected_line']); + $this->filtersForm->fill([ + 'plant' => null, + 'line' => null, + ]); + } + + public function filtersForm(Form $form): Form + { + return $form + ->statePath('filters') // Explicitly set where to store form data + ->schema([ + Select::make('plant') + ->label('Select Plant') + ->reactive() + ->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(); + }) + ->afterStateUpdated(function ($state) { + session(['selected_plant' => $state]); + $this->triggerChartUpdate(); + }), + // Line Filter + Select::make('line') + ->options(function ($get) { + $plantId = $get('plant'); + return $plantId ? Plant::find($plantId)->getLineNames()->pluck('name', 'id') : []; + }) + ->label('Select Line') + ->reactive() + ->afterStateUpdated(function ($state) { + session(['selected_line' => $state]); // Store in session + $this->triggerChartUpdate(); + }), + ]) + ->columns(2); + } + + public function triggerChartUpdate(): void + { + $filters = $this->filtersForm->getState(); + + if (!empty($filters['plant']) && !empty($filters['line'])) { + $this->dispatch('processOrderChart', filters: $filters); + } + } + + public static function canAccess(): bool + { + return Auth::check() && Auth::user()->can('view process order rejection dashboard'); + } +} diff --git a/resources/views/filament/pages/process-order-rejection.blade.php b/resources/views/filament/pages/process-order-rejection.blade.php new file mode 100644 index 00000000..a486f830 --- /dev/null +++ b/resources/views/filament/pages/process-order-rejection.blade.php @@ -0,0 +1,14 @@ + +
+ {{-- Render the Select form fields --}} +
+ {{ $this->filtersForm($this->form) }} +
+ + {{-- Render the chart widget below the form --}} +
+ @livewire(\App\Filament\Widgets\ProcessOrderChart::class) +
+
+ +