From d311597baa17b7158ca431dd9efd68726733b432 Mon Sep 17 00:00:00 2001 From: Mark Gregory Date: Mon, 22 Jun 2026 16:09:40 +0100 Subject: [PATCH] proper naming --- .../views/partials/ticket-controls.blade.php | 88 +++++++++++++++++-- 1 file changed, 81 insertions(+), 7 deletions(-) diff --git a/Modules/Helpdesk/Resources/views/partials/ticket-controls.blade.php b/Modules/Helpdesk/Resources/views/partials/ticket-controls.blade.php index ed321634..f9a24b36 100644 --- a/Modules/Helpdesk/Resources/views/partials/ticket-controls.blade.php +++ b/Modules/Helpdesk/Resources/views/partials/ticket-controls.blade.php @@ -1,10 +1,41 @@ @php - $hasRunningTimer = method_exists($this, 'hasRunningTimer') && (bool)$this->hasRunningTimer(); + use Illuminate\Support\Facades\Schema; + use Modules\Helpdesk\Models\TicketTimeLog; + + $ticketTimeLogTable = (new TicketTimeLog())->getTable(); + + $runningTimerQuery = TicketTimeLog::query() + ->where('ticket_id', $ticket->getKey()) + ->orderByDesc('started_at'); + + if (Schema::hasColumn($ticketTimeLogTable, 'user_id')) { + $runningTimerQuery->where('user_id', auth()->id()); + } + + if (Schema::hasColumn($ticketTimeLogTable, 'ended_at')) { + $runningTimerQuery->whereNull('ended_at'); + } + + if (Schema::hasColumn($ticketTimeLogTable, 'stopped_at')) { + $runningTimerQuery->whereNull('stopped_at'); + } + + if (Schema::hasColumn($ticketTimeLogTable, 'finished_at')) { + $runningTimerQuery->whereNull('finished_at'); + } + + $runningTimer = $runningTimerQuery->first(); + $runningTimerStartedAt = $runningTimer?->started_at; + $runningTimerElapsedSeconds = $runningTimerStartedAt + ? max(0, now()->diffInSeconds($runningTimerStartedAt)) + : 0; + $runningTimerElapsedDisplay = gmdate('H:i:s', $runningTimerElapsedSeconds); + $hasRunningTimer = $runningTimerStartedAt !== null; @endphp @can('update', $ticket)
+

Ticket controls

-

Log time, assignment, status and - priority +

+ Log time, assignment, status and priority

- - + + @if ($hasRunningTimer) + + + + + + Running + {{ $runningTimerElapsedDisplay }} + + @endif + + + +
@@ -35,6 +82,33 @@ @endif + @if ($hasRunningTimer) +
+
+
+

+ Timer running +

+

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

+
+ +
+

+ {{ $runningTimerElapsedDisplay }} +

+

+ Elapsed +

+
+
+
+ @endif + @include('helpdesk::partials.ticket-time-timer', [ 'ticket' => $ticket, ])