From 92beb31874fd36a7f0725780894d8e995f431245 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Thu, 29 Oct 2026 10:37:57 +0530 Subject: [PATCH] Added this week plan data filter logic in production dashboard --- app/Filament/Widgets/ItemOverview.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/Filament/Widgets/ItemOverview.php b/app/Filament/Widgets/ItemOverview.php index 7143f1f1..0c6330f6 100644 --- a/app/Filament/Widgets/ItemOverview.php +++ b/app/Filament/Widgets/ItemOverview.php @@ -181,6 +181,28 @@ class ItemOverview extends ChartWidget $weeksCount, $weeklyPlan ); + } + elseif ($activeFilter === 'this_week') { + $weeklyPlanQuantity = \DB::table('production_plans') + ->where('plant_id', $selectedPlant) + ->where('line_id', $selectedLine) + ->whereBetween('created_at', [ + $startDate, + $endDate + ]) + ->sum('plan_quantity'); + + $daysCount = count($orderedData); + + $dailyPlan = $daysCount > 0 + ? round($weeklyPlanQuantity / $daysCount, 2) + : 0; + + $planData = array_fill( + 0, + $daysCount, + $dailyPlan + ); } else {