Added hourly data in production quantity in modules
This commit is contained in:
@@ -227,11 +227,44 @@ class ModuleFilterDataController extends Controller
|
|||||||
->whereBetween('created_at', [$startDate, $endDate])
|
->whereBetween('created_at', [$startDate, $endDate])
|
||||||
->count();
|
->count();
|
||||||
|
|
||||||
|
// return response()->json([
|
||||||
|
// 'status_code' => 'SUCCESS',
|
||||||
|
// 'status_description' => $rowCount
|
||||||
|
// ], 200);
|
||||||
|
$chartName = $request->header('chart-name');
|
||||||
|
|
||||||
|
if ($chartName == 'Production Hourly Count') {
|
||||||
|
$hourlyCounts = [];
|
||||||
|
|
||||||
|
$hourStart = $startDate->copy();
|
||||||
|
while ($hourStart < $endDate) {
|
||||||
|
$hourEnd = $hourStart->copy()->addHour();
|
||||||
|
|
||||||
|
$label = $hourStart->format('g:i A') . ' to ' . $hourEnd->format('g:i A');
|
||||||
|
|
||||||
|
$count = ProductionQuantity::where('plant_id', $plant->id)
|
||||||
|
->where('line_id', $line->id)
|
||||||
|
->whereBetween('created_at', [$hourStart, $hourEnd])
|
||||||
|
->count();
|
||||||
|
|
||||||
|
$hourlyCounts[$label] = $count;
|
||||||
|
|
||||||
|
$hourStart = $hourEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'SUCCESS',
|
||||||
|
'status_description' => $hourlyCounts
|
||||||
|
], 200);
|
||||||
|
}
|
||||||
|
if ($chartName == 'Production Line Count')
|
||||||
|
{
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'SUCCESS',
|
'status_code' => 'SUCCESS',
|
||||||
'status_description' => $rowCount
|
'status_description' => $rowCount
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user