hourly production chart updated
This commit is contained in:
@@ -31,13 +31,17 @@ class ItemOverview extends ChartWidget
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($activeFilter === 'yesterday') {
|
if ($activeFilter === 'yesterday') {
|
||||||
$startDate = now()->subDay()->startOfDay();
|
$startDate = now()->subDay()->setTime(8, 0, 0); // yesterday 8:00 AM
|
||||||
$endDate = now()->subDay()->endOfDay();
|
$endDate = now()->setTime(8, 0, 0); // today 8:00 AM
|
||||||
$groupBy = 'EXTRACT(HOUR FROM production_quantities.created_at)';
|
$groupBy = 'EXTRACT(HOUR FROM production_quantities.created_at)';
|
||||||
}
|
}
|
||||||
else if ($activeFilter === 'this_week') {
|
else if ($activeFilter === 'this_week') {
|
||||||
$startDate = now()->startOfWeek(); // Monday 12:00 AM
|
// Monday 8:00 AM of the current week
|
||||||
$endDate = now()->endOfWeek(); // Sunday 11:59 PM
|
$startDate = now()->startOfWeek()->setTime(8, 0, 0);
|
||||||
|
|
||||||
|
// Next Monday 8:00 AM (end of Sunday + 8 hrs)
|
||||||
|
$endDate = now()->endOfWeek()->addDay()->setTime(8, 0, 0);
|
||||||
|
|
||||||
$groupBy = 'EXTRACT(DOW FROM production_quantities.created_at)'; // Group by day of week
|
$groupBy = 'EXTRACT(DOW FROM production_quantities.created_at)'; // Group by day of week
|
||||||
}
|
}
|
||||||
else if ($activeFilter === 'this_month') {
|
else if ($activeFilter === 'this_month') {
|
||||||
@@ -47,8 +51,8 @@ class ItemOverview extends ChartWidget
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$startDate = now()->startOfDay();
|
$startDate = now()->setTime(8, 0, 0); // today at 8:00 AM
|
||||||
$endDate = now()->endOfDay();
|
$endDate = now()->copy()->addDay()->setTime(8, 0, 0); // tomorrow at 8:00 AM
|
||||||
$groupBy = 'EXTRACT(HOUR FROM production_quantities.created_at)';
|
$groupBy = 'EXTRACT(HOUR FROM production_quantities.created_at)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user