changed logic in production dashboard #1333

Merged
jothi merged 1 commits from ranjith-dev into master 2026-10-29 04:10:15 +00:00

View File

@@ -160,20 +160,20 @@ class ItemOverview extends ChartWidget
); );
} }
elseif ($activeFilter === 'this_month') { elseif ($activeFilter === 'this_month') {
$weeklyProduction = [];
foreach ($orderedData as $index => $quantity) { $monthlyPlan = round(array_sum($orderedData) / 22.5, 2);
$day = (int) date('j', strtotime($labels[$index]));
$weekNumber = (int) ceil($day / 7);
$weeklyProduction[$weekNumber] = $weeksCount = count($orderedData);
($weeklyProduction[$weekNumber] ?? 0) + $quantity;
}
$planData = [];
foreach ($weeklyProduction as $weekNumber => $quantity) { $weeklyPlan = $weeksCount > 0
$planData[] = round($quantity / 22.5, 2); ? round($monthlyPlan / $weeksCount, 2)
} : 0;
$planData = array_fill(
0,
$weeksCount,
$weeklyPlan
);
} }
else { else {