Исправил индиктор заполнения отчета в статистике
Добавил вывод прошедшего отчета в статистике Исправил выбор дат в календаре статистики
This commit is contained in:
@@ -138,9 +138,9 @@ class DateRangeService
|
||||
$endAlreadyResolved = $endDate->format('H:i:s') === '09:00:00';
|
||||
|
||||
if ($startDate->isSameDay($endDate)) {
|
||||
$startDate = $startDate->subDay()->setTime(9, 0);
|
||||
$endDate = $endDate->setTime(9, 0);
|
||||
} else {
|
||||
$startDate = $startDate->setTime(9, 0);
|
||||
$endDate = $endDate->addDay()->setTime(9, 0);
|
||||
} else {
|
||||
$startDate = $startDate->setTime(9, 0);
|
||||
// Смена длится сутки и "принадлежит" дню, в который начинается (см. currentShiftBoundaries).
|
||||
// Поэтому смена последнего выбранного дня захватывает следующие календарные сутки —
|
||||
@@ -159,7 +159,10 @@ class DateRangeService
|
||||
|
||||
private function getDefaultDateRange($user): array
|
||||
{
|
||||
[$startDate, $endDate] = $this->currentShiftBoundaries();
|
||||
$requestPath = request()->path();
|
||||
$switchToday = $requestPath === 'report';
|
||||
|
||||
[$startDate, $endDate] = $this->currentShiftBoundaries($switchToday);
|
||||
|
||||
return [
|
||||
$startDate->format('Y-m-d H:i:s'),
|
||||
@@ -167,12 +170,12 @@ class DateRangeService
|
||||
];
|
||||
}
|
||||
|
||||
private function currentShiftBoundaries(): array
|
||||
private function currentShiftBoundaries(bool $switchToday = false): array
|
||||
{
|
||||
$now = Carbon::now('Asia/Yakutsk');
|
||||
$todayAt9 = $now->copy()->setTime(9, 0, 0);
|
||||
|
||||
if ($now->gte($todayAt9)) {
|
||||
if ($switchToday && $now->gte($todayAt9)) {
|
||||
return [$todayAt9, $todayAt9->copy()->addDay()];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user