Added process order rejection page and its blade file
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 20s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 20s
This commit is contained in:
78
app/Filament/Pages/ProcessOrderRejection.php
Normal file
78
app/Filament/Pages/ProcessOrderRejection.php
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Pages;
|
||||||
|
|
||||||
|
use Filament\Pages\Page;
|
||||||
|
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||||
|
use App\Models\Plant;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Forms\Form;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class ProcessOrderRejection extends Page
|
||||||
|
{
|
||||||
|
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||||
|
|
||||||
|
protected static string $view = 'filament.pages.process-order-rejection';
|
||||||
|
|
||||||
|
protected static ?string $navigationGroup = 'Process Order DashBoard';
|
||||||
|
|
||||||
|
use HasFiltersForm;
|
||||||
|
|
||||||
|
public function mount(): void
|
||||||
|
{
|
||||||
|
session()->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');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<x-filament-panels::page>
|
||||||
|
<div class="space-y-4">
|
||||||
|
{{-- Render the Select form fields --}}
|
||||||
|
<div class="space-y-4">
|
||||||
|
{{ $this->filtersForm($this->form) }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Render the chart widget below the form --}}
|
||||||
|
<div class="mt-6">
|
||||||
|
@livewire(\App\Filament\Widgets\ProcessOrderChart::class)
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</x-filament-panels::page>
|
||||||
Reference in New Issue
Block a user