From 4a87dea26ffdc232932beb5ccc6d82639134b208 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Thu, 29 Oct 2026 11:59:37 +0530 Subject: [PATCH] Added logic in item overview for today filter seperated --- app/Filament/Widgets/ItemOverview.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/app/Filament/Widgets/ItemOverview.php b/app/Filament/Widgets/ItemOverview.php index 1de2fb7c..629af503 100644 --- a/app/Filament/Widgets/ItemOverview.php +++ b/app/Filament/Widgets/ItemOverview.php @@ -150,7 +150,29 @@ class ItemOverview extends ChartWidget // $planQuantity // ); - if (in_array($activeFilter, ['today', 'yesterday'])) { + if ($activeFilter === 'today') { + + $monthlyPlanQuantity = \DB::table('production_plans') + ->where('plant_id', $selectedPlant) + ->where('line_id', $selectedLine) + ->whereYear('created_at', $startDate->year) + ->whereMonth('created_at', $startDate->month) + ->sum('plan_quantity'); + + // Calculate daily target directly + $weeksCount = (int) ceil($startDate->daysInMonth / 7); + + $dailyPlan = $weeksCount > 0 + ? round($monthlyPlanQuantity / ($weeksCount * 7), 2) + : 0; + + // Calculate hourly target + $hourlyPlan = round($dailyPlan / 22.5, 2); + + // Same hourly plan value for every hour + $planData = array_fill(0, 24, $hourlyPlan); + } + if ($activeFilter === 'yesterday') { $monthlyPlanQuantity = \DB::table('production_plans') ->where('plant_id', $selectedPlant)