Compare commits
5 Commits
a4471c3c3b
...
757d9db536
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
757d9db536 | ||
|
|
72d56af9eb | ||
|
|
3ca93bff1a | ||
|
|
5c3c374f80 | ||
|
|
b4ac08292f |
@@ -54,6 +54,9 @@ class Dashboard extends \Filament\Pages\Dashboard
|
||||
return 'Production Line Count';
|
||||
}
|
||||
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view production line count dashboard');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
69
app/Filament/Pages/ProductionLineStopCount.php
Normal file
69
app/Filament/Pages/ProductionLineStopCount.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?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\Dashboard\Concerns\HasFiltersForm;
|
||||
use Filament\Pages\Page;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ProductionLineStopCount extends Page
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.production-line-stop-count';
|
||||
|
||||
protected static ?string $navigationGroup = 'Production DashBoard';
|
||||
|
||||
use HasFiltersForm;
|
||||
|
||||
|
||||
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')
|
||||
->schema([
|
||||
|
||||
Select::make('plant')
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
->label('Select Plant')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['selected_plant' => $state]);
|
||||
}),
|
||||
|
||||
// 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]);
|
||||
|
||||
}),
|
||||
|
||||
|
||||
])
|
||||
->columns(2);
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view production line stop count dashboard');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -9,6 +9,7 @@ use Filament\Forms\Form;
|
||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Tables\Concerns\HasFilters;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ProductionOrderCount extends Page
|
||||
{
|
||||
@@ -84,4 +85,9 @@ class ProductionOrderCount extends Page
|
||||
$this->dispatch('productionOrderChart', filters: $filters);
|
||||
}
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view production order count dashboard');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -886,7 +886,10 @@ class InvoiceValidationResource extends Resource
|
||||
ExportAction::make()
|
||||
->label('Export Invoices')
|
||||
->color('warning')
|
||||
->exporter(InvoiceValidationExporter::class),
|
||||
->exporter(InvoiceValidationExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export invoice');
|
||||
}),
|
||||
])
|
||||
|
||||
->filters([
|
||||
|
||||
@@ -918,11 +918,17 @@ class ProductionQuantityResource extends Resource
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->importer(ProductionQuantityImporter::class),
|
||||
->importer(ProductionQuantityImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import production quantities');
|
||||
}),
|
||||
// ->chunkSize(250),
|
||||
// ->maxRows(100000),
|
||||
ExportAction::make()
|
||||
->exporter(ProductionQuantityExporter::class),
|
||||
->exporter(ProductionQuantityExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export production quantities');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
42
app/Filament/Widgets/ProductionLineStopChart.php
Normal file
42
app/Filament/Widgets/ProductionLineStopChart.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use Filament\Widgets\ChartWidget;
|
||||
|
||||
class ProductionLineStopChart extends ChartWidget
|
||||
{
|
||||
protected static ?string $heading = 'Production Line Stop Chart';
|
||||
|
||||
protected static ?string $maxHeight = '250px';
|
||||
|
||||
protected function getData(): array
|
||||
{
|
||||
return [
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => 'Production by Category',
|
||||
'data' => [25, 40, 20, 15],
|
||||
'backgroundColor' => [
|
||||
'#f87171', // Red
|
||||
'#60a5fa', // Blue
|
||||
'#34d399', // Green
|
||||
'#fbbf24', // Yellow
|
||||
],
|
||||
],
|
||||
],
|
||||
'labels' => ['Line A', 'Line B', 'Line C', 'Line D'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function getType(): string
|
||||
{
|
||||
return 'doughnut';
|
||||
}
|
||||
|
||||
public static function canView(): bool
|
||||
{
|
||||
// Only show on HourlyProduction page
|
||||
return request()->routeIs('filament.pages.production-line-stop-count');
|
||||
}
|
||||
}
|
||||
@@ -35,8 +35,15 @@ class PermissionSeeder extends Seeder
|
||||
|
||||
Permission::updateOrCreate(['name' => 'view import serial invoice']);
|
||||
Permission::updateOrCreate(['name' => 'view import material invoice']);
|
||||
Permission::updateOrCreate(['name' => 'view production dashboard']);
|
||||
Permission::updateOrCreate(['name' => 'view invoice dashboard']);
|
||||
Permission::updateOrCreate(['name' => 'view export invoice']);
|
||||
Permission::updateOrCreate(['name' => 'view invoice dashboard']); //invoice dashboard
|
||||
|
||||
Permission::updateOrCreate(['name' => 'view import production quantities']);
|
||||
Permission::updateOrCreate(['name' => 'view export production quantities']);
|
||||
Permission::updateOrCreate(['name' => 'view production dashboard']); //hourly production
|
||||
Permission::updateOrCreate(['name' => 'view production line count dashboard']);
|
||||
Permission::updateOrCreate(['name' => 'view production order count dashboard']);
|
||||
Permission::updateOrCreate(['name' => 'view production line stop count dashboard']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<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\ProductionLineStopChart::class)
|
||||
</div>
|
||||
</div>
|
||||
</x-filament-panels::page>
|
||||
Reference in New Issue
Block a user