diff --git a/app/Filament/Widgets/ItemOverview.php b/app/Filament/Widgets/ItemOverview.php index 482806e9..1edc5f5e 100644 --- a/app/Filament/Widgets/ItemOverview.php +++ b/app/Filament/Widgets/ItemOverview.php @@ -158,7 +158,25 @@ class ItemOverview extends ChartWidget count($orderedData), $planQuantity ); - } else { + } + elseif ($activeFilter === 'this_month') { + $weeklyProduction = []; + + foreach ($orderedData as $index => $quantity) { + $day = (int) date('j', strtotime($labels[$index])); + $weekNumber = (int) ceil($day / 7); + + $weeklyProduction[$weekNumber] = + ($weeklyProduction[$weekNumber] ?? 0) + $quantity; + } + $planData = []; + + foreach ($weeklyProduction as $weekNumber => $quantity) { + $planData[] = round($quantity / 22.5, 2); + } + + } + else { // This Week: each day's production / 22.5 // This Month: each week's production / 22.5 $planData = array_map(