changed logic in item overview
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Failing after 24s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 13s
Laravel Larastan / larastan (pull_request) Failing after 4m36s
Laravel Pint / pint (pull_request) Successful in 5m16s

This commit is contained in:
dhanabalan
2026-10-29 11:06:36 +05:30
parent 40a893fbe9
commit 17c0426dc4

View File

@@ -183,25 +183,27 @@ class ItemOverview extends ChartWidget
); );
} }
elseif ($activeFilter === 'this_week') { 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('plant_id', $selectedPlant)
->where('line_id', $selectedLine) ->where('line_id', $selectedLine)
->whereYear('created_at', $startDate->year) ->whereYear('created_at', $startDate->year)
->whereMonth('created_at', $startDate->month) ->whereMonth('created_at', $startDate->month)
->sum('plan_quantity'); ->sum('plan_quantity');
$daysCount = count($orderedData); // Number of calendar weeks in the current month
$weeksCount = (int) ceil($startDate->daysInMonth / 7);
$dailyPlan = $daysCount > 0 // Monthly plan -> weekly plan -> daily plan
? round($weeklyPlanQuantity / $daysCount, 2) $weeklyPlan = $weeksCount > 0
? $monthlyPlanQuantity / $weeksCount
: 0; : 0;
$planData = array_fill( $dailyPlan = round($weeklyPlan / 7, 2);
0,
$daysCount,
$dailyPlan
);
// Monday through Sunday
$planData = array_fill(0, 7, $dailyPlan);
} }
else { else {
// This Week: each day's production / 22.5 // This Week: each day's production / 22.5