Added transaction chart

This commit is contained in:
dhanabalan
2025-04-19 12:11:01 +05:30
parent d1cffac58b
commit 0f5ab9e5ea

View File

@@ -22,7 +22,7 @@ use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\Section; use Filament\Forms\Components\Section;
use Filament\Notifications\Notification; use Filament\Notifications\Notification;
use Filament\Tables\Actions\ExportAction; use Filament\Tables\Actions\ExportAction;
//use Livewire\Livewire; use Livewire\Livewire;
class ProductionQuantityResource extends Resource class ProductionQuantityResource extends Resource
{ {
@@ -33,6 +33,7 @@ class ProductionQuantityResource extends Resource
// protected static ?string $navigationParentItem = 'Display Transactions'; // protected static ?string $navigationParentItem = 'Display Transactions';
protected static ?string $navigationGroup = 'Production'; protected static ?string $navigationGroup = 'Production';
public $plant_id;
public static function form(Form $form): Form public static function form(Form $form): Form
@@ -54,8 +55,19 @@ class ProductionQuantityResource extends Resource
// ->afterStateUpdated(fn ($set) => $set('block_name', null)) // ->afterStateUpdated(fn ($set) => $set('block_name', null))
->afterStateUpdated(function ($state, callable $set, callable $get) { ->afterStateUpdated(function ($state, callable $set, callable $get) {
$plantId = $get('plant_id'); $plantId = $get('plant_id');
//...
// $set('plantId', $state);
session(['select_plant' => $state]);
session()->forget('select_line'); // Reset line filter
//...
$set('block_name', null); $set('block_name', null);
if (!$plantId) { if (!$plantId)
{
$set('pqPlantError', 'Please select a plant first.'); $set('pqPlantError', 'Please select a plant first.');
return; return;
} }
@@ -64,7 +76,24 @@ class ProductionQuantityResource extends Resource
$set('validationError', null); $set('validationError', null);
$set('pqPlantError', null); $set('pqPlantError', null);
} }
}) })
->extraAttributes([
'x-on:change' => "
if (\$event.target.value) {
\$wire.dispatch('filtersUpdated', { plantId: \$event.target.value });
}
",
])
// ->extraAttributes([
// 'x-on:change' => "\$wire.dispatch('filtersUpdated', { plantId: \$event.target.value })"
// ])
// ->extraAttributes([
// 'x-on:change' => "\$wire.set('plantId', \$event.target.value)"
// ])
->extraAttributes(fn ($get) => [ ->extraAttributes(fn ($get) => [
'class' => $get('pqPlantError') ? 'border-red-500' : '', 'class' => $get('pqPlantError') ? 'border-red-500' : '',
]) ])
@@ -230,7 +259,16 @@ class ProductionQuantityResource extends Resource
// $set('recent_qr', null); // $set('recent_qr', null);
// } // }
} }
//..
session(['select_line' => $state]);
}) })
// ->extraAttributes([
// 'x-on:change' => "\$wire.dispatch('filtersUpdated')", // Dispatch Livewire event from Alpine.js
// ])
->extraAttributes([
'x-on:change' => "\$wire.dispatch('filtersUpdated', { lineId: \$event.target.value })"
])
->extraAttributes(fn ($get) => [ ->extraAttributes(fn ($get) => [
'class' => $get('pqLineError') ? 'border-red-500' : '', 'class' => $get('pqLineError') ? 'border-red-500' : '',
]) ])
@@ -793,6 +831,7 @@ class ProductionQuantityResource extends Resource
]); ]);
} }
public static function table(Table $table): Table public static function table(Table $table): Table
{ {
return $table return $table