changed logic for today and yesterday in item overview #1340
@@ -151,13 +151,31 @@ class ItemOverview extends ChartWidget
|
||||
// );
|
||||
|
||||
if (in_array($activeFilter, ['today', 'yesterday'])) {
|
||||
$planQuantity = round(array_sum($orderedData) / 22.5, 2);
|
||||
|
||||
// Get total monthly plan quantity
|
||||
$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');
|
||||
|
||||
$weeksCount = (int) ceil($startDate->daysInMonth / 7);
|
||||
|
||||
$weeklyPlan = $weeksCount > 0
|
||||
? $monthlyPlanQuantity / $weeksCount
|
||||
: 0;
|
||||
|
||||
$dailyPlan = $weeklyPlan / 7;
|
||||
|
||||
$hourlyPlan = round($dailyPlan / 22.5, 2);
|
||||
|
||||
$planData = array_fill(
|
||||
0,
|
||||
count($orderedData),
|
||||
$planQuantity
|
||||
$hourlyPlan
|
||||
);
|
||||
|
||||
}
|
||||
elseif ($activeFilter === 'this_month') {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user