removed challan in invoice data dashboard

This commit is contained in:
dhanabalan
2025-11-08 01:46:30 +05:30
parent 3da1616a9f
commit d8a66e7678

View File

@@ -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');
}
}