changed logic in item overview #1338

Merged
jothi merged 1 commits from ranjith-dev into master 2026-10-29 05:36:53 +00:00

View File

@@ -183,25 +183,27 @@ class ItemOverview extends ChartWidget
);
}
elseif ($activeFilter === 'this_week') {
$weeklyPlanQuantity = \DB::table('production_plans')
// Get the total plan quantity for the current month
$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');
$daysCount = count($orderedData);
// Number of calendar weeks in the current month
$weeksCount = (int) ceil($startDate->daysInMonth / 7);
$dailyPlan = $daysCount > 0
? round($weeklyPlanQuantity / $daysCount, 2)
// Monthly plan -> weekly plan -> daily plan
$weeklyPlan = $weeksCount > 0
? $monthlyPlanQuantity / $weeksCount
: 0;
$planData = array_fill(
0,
$daysCount,
$dailyPlan
);
$dailyPlan = round($weeklyPlan / 7, 2);
// Monday through Sunday
$planData = array_fill(0, 7, $dailyPlan);
}
else {
// This Week: each day's production / 22.5