From 9f0ee1c29ba919b1fa10bd59d2e2f7c8a70781a2 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Thu, 29 Oct 2026 11:18:34 +0530 Subject: [PATCH] changed logic for today and yesterday in item overview --- app/Filament/Widgets/ItemOverview.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/app/Filament/Widgets/ItemOverview.php b/app/Filament/Widgets/ItemOverview.php index 9c8e9e37..357aa363 100644 --- a/app/Filament/Widgets/ItemOverview.php +++ b/app/Filament/Widgets/ItemOverview.php @@ -151,13 +151,31 @@ class ItemOverview extends ChartWidget // ); if (in_array($activeFilter, ['today', 'yesterday'])) { - $planQuantity = round(array_sum($orderedData) / 22.5, 2); + + // Get total monthly plan quantity + $monthlyPlanQuantity = \DB::table('YOUR_ACTUAL_PLAN_TABLE') + ->where('plant_id', $selectedPlant) + ->where('line_id', $selectedLine) + ->whereYear('created_at', $startDate->year) + ->whereMonth('created_at', $startDate->month) + ->sum('plan_quantity'); + + $weeksCount = (int) ceil($startDate->daysInMonth / 7); + + $weeklyPlan = $weeksCount > 0 + ? $monthlyPlanQuantity / $weeksCount + : 0; + + $dailyPlan = $weeklyPlan / 7; + + $hourlyPlan = round($dailyPlan / 22.5, 2); $planData = array_fill( 0, count($orderedData), - $planQuantity + $hourlyPlan ); + } elseif ($activeFilter === 'this_month') {