From a1457a1e76f7ed3fb1c5ca76d3c1ce1541add681 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Thu, 29 Oct 2026 09:39:57 +0530 Subject: [PATCH] changed logic in production dashboard --- app/Filament/Widgets/ItemOverview.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app/Filament/Widgets/ItemOverview.php b/app/Filament/Widgets/ItemOverview.php index 1edc5f5e..0a30cf7d 100644 --- a/app/Filament/Widgets/ItemOverview.php +++ b/app/Filament/Widgets/ItemOverview.php @@ -160,20 +160,20 @@ class ItemOverview extends ChartWidget ); } elseif ($activeFilter === 'this_month') { - $weeklyProduction = []; - foreach ($orderedData as $index => $quantity) { - $day = (int) date('j', strtotime($labels[$index])); - $weekNumber = (int) ceil($day / 7); + $monthlyPlan = round(array_sum($orderedData) / 22.5, 2); - $weeklyProduction[$weekNumber] = - ($weeklyProduction[$weekNumber] ?? 0) + $quantity; - } - $planData = []; + $weeksCount = count($orderedData); - foreach ($weeklyProduction as $weekNumber => $quantity) { - $planData[] = round($quantity / 22.5, 2); - } + $weeklyPlan = $weeksCount > 0 + ? round($monthlyPlan / $weeksCount, 2) + : 0; + + $planData = array_fill( + 0, + $weeksCount, + $weeklyPlan + ); } else {