From 3c909e51e66cf4c9c73a8ae3fa725ff452cee7ae Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 1 Dec 2026 08:39:13 +0530 Subject: [PATCH] Added panel box pallet count page and livewire pages --- app/Filament/Pages/PanelBoxPalletCount.php | 68 +++++++++++++++++++ app/Livewire/PanelPalletCountDataTable.php | 53 +++++++++++++++ .../pages/panel-box-pallet-count.blade.php | 15 ++++ .../panel-pallet-count-data-table.blade.php | 37 ++++++++++ 4 files changed, 173 insertions(+) create mode 100644 app/Filament/Pages/PanelBoxPalletCount.php create mode 100644 app/Livewire/PanelPalletCountDataTable.php create mode 100644 resources/views/filament/pages/panel-box-pallet-count.blade.php create mode 100644 resources/views/livewire/panel-pallet-count-data-table.blade.php diff --git a/app/Filament/Pages/PanelBoxPalletCount.php b/app/Filament/Pages/PanelBoxPalletCount.php new file mode 100644 index 00000000..d04dca42 --- /dev/null +++ b/app/Filament/Pages/PanelBoxPalletCount.php @@ -0,0 +1,68 @@ +statePath('filters') + ->schema([ + Section::make('') + ->schema([ + + Select::make('plant_id') + ->label('Plant') + ->relationship('plant', 'name') + ->reactive() + // ->searchable() + ->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(); + }) + ->required() + ->afterStateUpdated(function ($state, callable $get, $set) { + $set('pallet_count', null); + }), + Select::make('pallet_count') + ->label('Select Pallet') + ->required() + ->columnSpan(1) + ->options(function (callable $get) { + + if (!$get('plant_id')) { + return []; + } + + return \App\Models\PanelPalletValidation::where('plant_id', $get('plant_id')) + ->pluck('pallet_number', 'pallet_number') + ->toArray(); + }) + ->reactive() + ->afterStateUpdated(function ($state, callable $get, $set) { + $plantId = $get('plant_id'); + $this->dispatch('loadData',$state, $plantId); + }), + + ]) + ->columns(2) + ]); + } +} diff --git a/app/Livewire/PanelPalletCountDataTable.php b/app/Livewire/PanelPalletCountDataTable.php new file mode 100644 index 00000000..50b08986 --- /dev/null +++ b/app/Livewire/PanelPalletCountDataTable.php @@ -0,0 +1,53 @@ + 'requestRemoveSerialNumber', + 'loadData' => 'loadPalletData', + ]; + + + public function loadPalletData($palletNumber, $plantId) + { + $this->plantId = $plantId; + $this->palletNumber = $palletNumber; + $this->records = []; + + $this->records = PanelPalletValidation::query() + ->where('plant_id', $plantId) + ->where('pallet_number', $palletNumber) + ->get() + ->groupBy(fn ($record) => trim($record->panel_box_code ?? '')) + ->map(function ($items, $code) { + return [ + 'panel_box_code' => $code, + 'count' => $items->pluck('panel_box_serial_number') + ->filter() + ->unique() + ->count(), + ]; + }) + ->values() + ->toArray(); + } + + public function render() + { + return view('livewire.panel-pallet-count-data-table'); + } +} diff --git a/resources/views/filament/pages/panel-box-pallet-count.blade.php b/resources/views/filament/pages/panel-box-pallet-count.blade.php new file mode 100644 index 00000000..c1862ed5 --- /dev/null +++ b/resources/views/filament/pages/panel-box-pallet-count.blade.php @@ -0,0 +1,15 @@ + + +
+ {{-- Render the Select form fields --}} +
+ {{ $this->form }} +
+ +
+ +
+
+ +
+ diff --git a/resources/views/livewire/panel-pallet-count-data-table.blade.php b/resources/views/livewire/panel-pallet-count-data-table.blade.php new file mode 100644 index 00000000..77e4fe18 --- /dev/null +++ b/resources/views/livewire/panel-pallet-count-data-table.blade.php @@ -0,0 +1,37 @@ +
+

+ PALLET COUNT DATA TABLE: +

+ +
+ + + + + + + + + + + @forelse ($records as $index => $record) + + + + + + @empty + + + + @endforelse + +
NoPanel Box CodeCount
{{ $index + 1 }} + {{ $record['panel_box_code'] }} + + {{ $record['count'] }} +
+ No pallet records found. +
+
+