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') { 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