From d8a66e7678b5560036793ecb51a943686b7e5ced Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Sat, 8 Nov 2025 01:46:30 +0530 Subject: [PATCH] removed challan in invoice data dashboard --- app/Filament/Pages/InvoiceDataDashboard.php | 49 +++++++++++++-------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/app/Filament/Pages/InvoiceDataDashboard.php b/app/Filament/Pages/InvoiceDataDashboard.php index 2fc648a..40badac 100644 --- a/app/Filament/Pages/InvoiceDataDashboard.php +++ b/app/Filament/Pages/InvoiceDataDashboard.php @@ -53,33 +53,48 @@ class InvoiceDataDashboard extends Page }), Select::make('distribution_channel') ->label('Distribution Channel') - ->options(function (callable $get) { + // ->options(function (callable $get) { + // $plant = $get('plant'); + + // if (!$plant) { + // return []; + // } + + // $options = InvoiceDataValidation::where('plant_id', $plant) + // ->whereNotNull('distribution_channel_desc') + // ->where('distribution_channel_desc', '!=', '') + // ->select('distribution_channel_desc') + // ->distinct() + // ->pluck('distribution_channel_desc', 'distribution_channel_desc') + // ->toArray(); + + // $hasEmpty = InvoiceDataValidation::where('plant_id', $plant) + // ->where(function ($q) { + // $q->whereNull('distribution_channel_desc') + // ->orWhere('distribution_channel_desc', ''); + // }) + // ->exists(); + + // if ($hasEmpty) { + // $options['Challan'] = 'Challan'; + // } + + // return $options; + // }) + ->options(function (callable $get) { $plant = $get('plant'); if (!$plant) { return []; } - $options = InvoiceDataValidation::where('plant_id', $plant) + // Fetch unique, non-empty distribution_channel_desc values + return InvoiceDataValidation::where('plant_id', $plant) ->whereNotNull('distribution_channel_desc') ->where('distribution_channel_desc', '!=', '') - ->select('distribution_channel_desc') ->distinct() ->pluck('distribution_channel_desc', 'distribution_channel_desc') ->toArray(); - - $hasEmpty = InvoiceDataValidation::where('plant_id', $plant) - ->where(function ($q) { - $q->whereNull('distribution_channel_desc') - ->orWhere('distribution_channel_desc', ''); - }) - ->exists(); - - if ($hasEmpty) { - $options['Challan'] = 'Challan'; - } - - return $options; }) ->afterStateUpdated(callback: function ($state,callable $set) { session(['dist_channel' => $state]); @@ -106,6 +121,4 @@ class InvoiceDataDashboard extends Page return Auth::check() && Auth::user()->can('view invoice data dashboard'); } - - }