74 lines
2.1 KiB
PHP
74 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Pages;
|
|
|
|
|
|
use App\Models\Plant;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Forms\Form;
|
|
use Filament\Pages\Page;
|
|
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class InvoiceDashboard extends Page
|
|
{
|
|
|
|
use HasFiltersForm;
|
|
|
|
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
|
|
|
protected static ?string $navigationGroup = 'Invoice DashBoard';
|
|
|
|
protected static string $view = 'filament.pages.invoice-dashboard';
|
|
|
|
|
|
public function mount(): void
|
|
{
|
|
$this->filtersForm->fill([
|
|
'plant' => Plant::first()?->id // Default to first plant
|
|
]);
|
|
}
|
|
|
|
public function filtersForm(Form $form): Form
|
|
{
|
|
return $form
|
|
->statePath('filters') // Explicitly set where to store form data
|
|
->schema([
|
|
Select::make('plant')
|
|
->options(Plant::pluck('name', 'id'))
|
|
->label('Select Plant')
|
|
->reactive()
|
|
->afterStateUpdated(function ($state) {
|
|
session(['selec_plant' => $state]);
|
|
$this->dispatch('invoiceChart');
|
|
}),
|
|
Select::make('invoice')
|
|
->options([
|
|
'serial_invoice' => 'Serial Invoice',
|
|
'individual_material' => 'Individual Material Invoice',
|
|
'bundle_material' => 'Bundle Material Invoice',
|
|
])
|
|
->label('Select Invoice')
|
|
->reactive()
|
|
->default(0)
|
|
->afterStateUpdated(function ($state) {
|
|
session(['select_invoice' => $state]);
|
|
$this->dispatch('invoiceChart');
|
|
})
|
|
])
|
|
->columns(2);
|
|
}
|
|
|
|
public static function getNavigationLabel(): string
|
|
{
|
|
return 'Invoice';
|
|
}
|
|
|
|
public static function canAccess(): bool
|
|
{
|
|
return Auth::check() && Auth::user()->can('view invoice dashboard');
|
|
}
|
|
|
|
}
|