From 0c4134bd5913f43603e1887d13b259378d856551 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Thu, 15 Oct 2026 11:20:41 +0530 Subject: [PATCH] changed logic in houlry report in production --- app/Filament/Widgets/ItemOverview.php | 31 +++++++++++++++++++++------ 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/app/Filament/Widgets/ItemOverview.php b/app/Filament/Widgets/ItemOverview.php index 965b152c..482806e9 100644 --- a/app/Filament/Widgets/ItemOverview.php +++ b/app/Filament/Widgets/ItemOverview.php @@ -140,15 +140,32 @@ class ItemOverview extends ChartWidget }, $shiftedKeys); } - $totalQuantity = array_sum($orderedData); + // $totalQuantity = array_sum($orderedData); - $planQuantity = round($totalQuantity / 22.5, 2); + // $planQuantity = round($totalQuantity / 22.5, 2); - $planData = array_fill( - 0, - count($orderedData), - $planQuantity - ); + // $planData = array_fill( + // 0, + // count($orderedData), + // $planQuantity + // ); + + if (in_array($activeFilter, ['today', 'yesterday'])) { + $planQuantity = round(array_sum($orderedData) / 22.5, 2); + + $planData = array_fill( + 0, + count($orderedData), + $planQuantity + ); + } else { + // This Week: each day's production / 22.5 + // This Month: each week's production / 22.5 + $planData = array_map( + fn ($quantity) => round($quantity / 22.5, 2), + $orderedData + ); + } return [ 'datasets' => [