Added hourly data in production quantity in modules
This commit is contained in:
@@ -227,10 +227,43 @@ class ModuleFilterDataController extends Controller
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->count();
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => $rowCount
|
||||
], 200);
|
||||
// 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([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => $rowCount
|
||||
], 200);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user