Added chart for invoice quantity
This commit is contained in:
70
app/Filament/Pages/InvoiceQuantityDashboard.php
Normal file
70
app/Filament/Pages/InvoiceQuantityDashboard.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\Plant;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class InvoiceQuantityDashboard 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-quantity-dashboard';
|
||||
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
session()->forget(['selec_plant', 'select_invoice']);
|
||||
$this->filtersForm->fill([
|
||||
'plant' => null,
|
||||
'invoice' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
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 Quantity';
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view invoice serial quantity dashboard');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user