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') {
$weeklyProduction = [];
foreach ($orderedData as $index => $quantity) {
$day = (int) date('j', strtotime($labels[$index]));
$weekNumber = (int) ceil($day / 7);
$monthlyPlan = round(array_sum($orderedData) / 22.5, 2);
$weeklyProduction[$weekNumber] =
($weeklyProduction[$weekNumber] ?? 0) + $quantity;
}
$planData = [];
$weeksCount = count($orderedData);
foreach ($weeklyProduction as $weekNumber => $quantity) {
$planData[] = round($quantity / 22.5, 2);
}
$weeklyPlan = $weeksCount > 0
? round($monthlyPlan / $weeksCount, 2)
: 0;
$planData = array_fill(
0,
$weeksCount,
$weeklyPlan
);
}
else {