diff --git a/Modules/Helpdesk/Resources/views/partials/ticket-controls.blade.php b/Modules/Helpdesk/Resources/views/partials/ticket-controls.blade.php index 0980ede6..14d38b7e 100644 --- a/Modules/Helpdesk/Resources/views/partials/ticket-controls.blade.php +++ b/Modules/Helpdesk/Resources/views/partials/ticket-controls.blade.php @@ -4,27 +4,36 @@ $ticketTimeLogTable = (new TicketTimeLog())->getTable(); + $hasEndedAtColumn = Schema::hasColumn($ticketTimeLogTable, 'ended_at'); + $hasStoppedAtColumn = Schema::hasColumn($ticketTimeLogTable, 'stopped_at'); + $hasFinishedAtColumn = Schema::hasColumn($ticketTimeLogTable, 'finished_at'); + $hasUserIdColumn = Schema::hasColumn($ticketTimeLogTable, 'user_id'); + $runningTimerQuery = TicketTimeLog::query() ->where('ticket_id', $ticket->getKey()) + ->whereNotNull('started_at') ->orderByDesc('started_at'); - if (Schema::hasColumn($ticketTimeLogTable, 'user_id')) { + if ($hasUserIdColumn) { $runningTimerQuery->where('user_id', auth()->id()); } - if (Schema::hasColumn($ticketTimeLogTable, 'ended_at')) { + if ($hasEndedAtColumn) { $runningTimerQuery->whereNull('ended_at'); } - if (Schema::hasColumn($ticketTimeLogTable, 'stopped_at')) { + if ($hasStoppedAtColumn) { $runningTimerQuery->whereNull('stopped_at'); } - if (Schema::hasColumn($ticketTimeLogTable, 'finished_at')) { + if ($hasFinishedAtColumn) { $runningTimerQuery->whereNull('finished_at'); } - $runningTimer = $runningTimerQuery->first(); + $runningTimer = ($hasEndedAtColumn || $hasStoppedAtColumn || $hasFinishedAtColumn) + ? $runningTimerQuery->first() + : null; + $runningTimerStartedAt = $runningTimer?->started_at; $runningTimerElapsedSeconds = $runningTimerStartedAt ? max(0, now()->diffInSeconds($runningTimerStartedAt)) @@ -55,6 +64,7 @@ @@ -92,6 +102,7 @@

Timer running

+

Started {{ $runningTimerStartedAt->format('d M Y H:i:s') }}

@@ -99,9 +110,11 @@

{{ $runningTimerElapsedDisplay }}

+

Elapsed

@@ -110,9 +123,11 @@
@endif - @include('helpdesk::partials.ticket-time-timer', [ - 'ticket' => $ticket, - ]) +
+ @include('helpdesk::partials.ticket-time-timer', [ + 'ticket' => $ticket, + ]) +
@@ -222,8 +237,9 @@ @error('priority_id') -

{{ $message }}

+

{{ $message }}

@enderror +