phase 6 added helpdesk

This commit is contained in:
Mark Gregory
2026-07-24 11:28:06 +01:00
parent 5ecf20fe97
commit 8c74abfbc6
212 changed files with 23064 additions and 0 deletions
@@ -0,0 +1,327 @@
@php
$helpdeskAttachmentAccept = collect(config('helpdesk.allowed_extensions', config('helpdesk.allowed_mimes', [])))
->filter(fn ($extension) => is_string($extension) && trim($extension) !== '')
->map(fn ($extension) => '.' . strtolower(ltrim(trim($extension), '.')))
->unique()
->implode(',');
@endphp
@props(['comments', 'level' => 0, 'ticket' => null, 'canSeeInternalNotes' => false])
<div class="space-y-3" data-helpdesk-thread-level="{{ (int) $level }}">
@foreach ($comments as $comment)
@php
$commentUser = $comment->relationLoaded('user') ? $comment->getRelation('user') : null;
$commentAttachments = $comment->relationLoaded('attachments')
? $comment->getRelation('attachments')
: collect();
$commentReplies = $comment->relationLoaded('replies') ? $comment->getRelation('replies') : collect();
$replyFormId = 'helpdesk-reply-form-' . $comment->id;
$currentTicket = $ticket ?? ($comment->ticket ?? null);
$replyCount = $commentReplies->count();
$isInternal = (bool) $comment->is_internal;
$borderClass = $isInternal
? 'border-purple-400/70 dark:border-purple-600/70'
: 'border-zinc-200 dark:border-zinc-700';
$railClass = $isInternal
? 'bg-purple-500'
: ((int) $level % 3 === 0
? 'bg-red-500'
: ((int) $level % 3 === 1
? 'bg-blue-500'
: 'bg-emerald-500'));
$commentSubject = trim((string) ($comment->subject ?? ''));
if ($commentSubject === '') {
$plainSubject = trim((string) ($comment->body_text ?? strip_tags((string) $comment->body)));
$commentSubject = Str::limit($plainSubject !== '' ? $plainSubject : 'Response', 72);
}
if ($isInternal && !Str::startsWith(Str::lower($commentSubject), 'internal')) {
$commentSubject = 'Internal note';
}
$renderedBody = html_entity_decode((string) $comment->body, ENT_QUOTES | ENT_HTML5, 'UTF-8');
while (
str_contains($renderedBody, '&lt;') ||
str_contains($renderedBody, '&gt;') ||
str_contains($renderedBody, '&amp;lt;')
) {
$decodedBody = html_entity_decode($renderedBody, ENT_QUOTES | ENT_HTML5, 'UTF-8');
if ($decodedBody === $renderedBody) {
break;
}
$renderedBody = $decodedBody;
}
if ($currentTicket !== null) {
$renderedBody = strtr($renderedBody, [
'{{ ticket . reference }}' => (string) e((string) ($currentTicket->reference ?? '')),
'{{ ticket . subject }}' => (string) e((string) ($currentTicket->subject ?? '')),
'{{ ticket . status }}' => (string) e((string) ($currentTicket->status?->name ?? '')),
'{{ ticket . priority }}' => (string) e((string) ($currentTicket->priority?->name ?? '')),
'{{ ticket . category }}' => (string) e((string) ($currentTicket->category?->name ?? '')),
'{{ ticket . project }}' => (string) e((string) ($currentTicket->project?->title ?? '')),
'{{ ticket . team }}' => (string) e((string) ($currentTicket->team?->name ?? '')),
'{{ requester . name }}' => (string) e(
(string) ($currentTicket->owner?->name ?? ($currentTicket->user?->name ?? '')),
),
'{{ agent . name }}' => (string) e((string) ($currentTicket->agent?->name ?? '')),
'{{ actor . name }}' => (string) e((string) ($commentUser?->name ?? '')),
'{{ ticket . url }}' => (string) e(
route('helpdesk.tickets.show', ['ticket' => $currentTicket->getKey()]),
),
]);
}
$containsHtml = $renderedBody !== strip_tags($renderedBody);
$renderedBody = preg_replace('/<\s*(script|style)[^>]*>.*?<\s*\/\s*\1\s*>/is', '', $renderedBody) ?: '';
$renderedBody = preg_replace('/\s+on[a-z]+\s*=\s*("[^"]*"|\'[^\']*\'|[^\s>]+)/i', '', $renderedBody) ?: '';
$renderedBody = preg_replace('/javascript\s*:/i', '', $renderedBody) ?: '';
$renderedBody = strip_tags(
$renderedBody,
'<p><br><strong><b><em><i><u><ul><ol><li><blockquote><pre><code><a>',
);
$renderedBody = $containsHtml ? $renderedBody : nl2br(e($renderedBody));
@endphp
@if (!$isInternal || $canSeeInternalNotes)
<details class="group rounded-2xl border {{ $borderClass }} bg-white shadow-sm transition dark:bg-zinc-900"
data-helpdesk-comment-card
data-helpdesk-comment-text="{{ e(Str::lower($commentSubject . ' ' . strip_tags((string) $comment->body) . ' ' . ($comment->body_text ?? '') . ' ' . ($commentUser?->name ?? '') . ' ' . ($comment->unid ?? '') . ' ' . ($comment->guid ?? ''))) }}"
style="margin-left: {{ min((int) $level, 4) * 1.25 }}rem">
<summary class="flex cursor-pointer list-none items-start gap-3 rounded-2xl p-4 marker:hidden">
<span class="mt-1 inline-flex h-12 w-2 shrink-0 rounded-full {{ $railClass }}"
aria-hidden="true"></span>
<div class="min-w-0 flex-1">
<div class="flex flex-wrap items-center gap-2">
<span
class="inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-zinc-100 text-zinc-700 ring-1 ring-zinc-200 dark:bg-zinc-800 dark:text-zinc-100 dark:ring-zinc-700">
<i class="fa-solid {{ $isInternal ? 'fa-note-sticky' : 'fa-envelope' }}"
aria-hidden="true"></i>
</span>
<div class="min-w-0 flex-1">
<div class="flex flex-wrap items-center gap-2">
<span
class="truncate text-base font-extrabold text-zinc-900 dark:text-zinc-100">{{ $commentSubject }}</span>
<span
class="rounded-full bg-zinc-100 px-2.5 py-1 text-[11px] font-extrabold text-zinc-700 dark:bg-zinc-800 dark:text-zinc-100">{{ $replyCount }}
{{ $replyCount === 1 ? 'reply' : 'replies' }}</span>
@if ($commentAttachments->isNotEmpty())
<span
class="rounded-full bg-emerald-100 px-2.5 py-1 text-[11px] font-extrabold text-emerald-800 dark:bg-emerald-950 dark:text-emerald-100">
<i class="fa-solid fa-paperclip mr-1"
aria-hidden="true"></i>{{ $commentAttachments->count() }}
</span>
@endif
@if ($isInternal)
<span
class="rounded-full bg-purple-600 px-2.5 py-1 text-[11px] font-extrabold uppercase tracking-wide text-white">Internal</span>
@else
<span
class="rounded-full bg-emerald-600 px-2.5 py-1 text-[11px] font-extrabold uppercase tracking-wide text-white">Public</span>
@endif
</div>
<div
class="mt-1 flex flex-wrap items-center gap-2 text-xs font-semibold text-zinc-500 dark:text-zinc-400">
<span>{{ $commentUser?->name ?? 'Unknown user' }}</span>
<span aria-hidden="true">•</span>
<span>{{ $comment->created_at?->format('d M Y H:i') }}</span>
</div>
</div>
</div>
</div>
<span
class="mt-1 inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-zinc-100 text-zinc-600 transition group-open:rotate-90 dark:bg-zinc-800 dark:text-zinc-200">
<i class="fa-solid fa-chevron-right text-xs" aria-hidden="true"></i>
</span>
</summary>
<div class="border-t border-zinc-100 px-4 pb-4 pt-3 dark:border-zinc-800">
<div class="prose prose-sm max-w-none dark:prose-invert">
{!! $renderedBody !!}
</div>
@if ($commentAttachments->isNotEmpty())
<div
class="mt-4 rounded-xl border border-zinc-200 bg-zinc-50 p-3 dark:border-zinc-700 dark:bg-zinc-950/60">
<div
class="mb-2 flex items-center gap-2 text-xs font-extrabold uppercase tracking-wide text-zinc-500">
<i class="fa-solid fa-paperclip text-blue-500" aria-hidden="true"></i>
Attachments
</div>
<div class="flex flex-wrap gap-2">
@foreach ($commentAttachments as $attachment)
<a href="{{ route('helpdesk.attachments.download', $attachment->id) }}"
target="_blank"
class="inline-flex items-center gap-2 rounded-lg border border-blue-200 bg-white px-3 py-2 text-xs font-bold text-blue-700 shadow-sm hover:bg-blue-50 dark:border-blue-900 dark:bg-zinc-900 dark:text-blue-200 dark:hover:bg-blue-950/50">
<i class="fa-solid fa-thumbtack" aria-hidden="true"></i>
{{ $attachment->original_name ?? ($attachment->original_filename ?? ($attachment->filename ?? ($attachment->file_name ?? basename($attachment->path ?? ($attachment->file_path ?? ''))))) }}
</a>
@endforeach
</div>
</div>
@endif
@if ($currentTicket !== null)
<div class="mt-4 flex flex-wrap justify-end gap-2">
<button type="button" dusk="reply-to-comment-{{ $comment->id }}"
data-helpdesk-reply-toggle="{{ $replyFormId }}"
class="inline-flex items-center justify-center rounded-lg bg-blue-600 px-3 py-2 text-xs font-bold text-white shadow-sm transition hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-400/70">
<i class="fa-solid fa-reply mr-2" aria-hidden="true"></i>
Respond
</button>
@if (auth()->user()?->isMpbaPlatformAdmin())
<form method="POST"
action="{{ route('helpdesk.tickets.comments.destroy', [$currentTicket, $comment]) }}"
onsubmit="return confirm('Delete this response? This will remove it from the visible conversation but keep the replication identity/audit trail.');">
@csrf
@method('DELETE')
<button type="submit" dusk="delete-comment-{{ $comment->id }}"
class="inline-flex items-center justify-center rounded-lg bg-red-600 px-3 py-2 text-xs font-bold text-white shadow-sm transition hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-400/70">
<i class="fa-solid fa-trash-can mr-2" aria-hidden="true"></i>
Delete
</button>
</form>
@endif
</div>
<form id="{{ $replyFormId }}" method="POST"
action="{{ route('helpdesk.tickets.comments.store', $currentTicket) }}"
enctype="multipart/form-data"
class="mt-4 hidden rounded-xl border border-red-200 bg-red-50/60 p-4 dark:border-red-900 dark:bg-red-950/20"
data-helpdesk-comment-form>
@csrf
<input type="hidden" name="parent_id" value="{{ $comment->id }}">
<div class="mb-3">
<label for="reply-subject-{{ $comment->id }}"
class="mb-2 block text-sm font-bold text-zinc-700 dark:text-zinc-200">Subject</label>
<input id="reply-subject-{{ $comment->id }}" name="subject"
value="{{ old('subject', 'RE: ' . $commentSubject) }}"
spellcheck="true" lang="en-GB" autocorrect="on" autocomplete="on" autocapitalize="sentences" inputmode="text"
class="block w-full rounded-xl border border-zinc-300 bg-white p-3 text-sm font-semibold text-zinc-900 shadow-sm focus:border-blue-500 focus:ring-blue-500 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100">
</div>
<label for="reply-body-{{ $comment->id }}"
class="mb-2 block text-sm font-bold text-zinc-700 dark:text-zinc-200">Response to
response</label>
<div class="mb-2 flex flex-wrap gap-2"
data-helpdesk-html-toolbar="reply-body-{{ $comment->id }}">
<button type="button" data-helpdesk-tag="strong"
class="rounded-lg border px-2 py-1 text-xs font-black">B</button>
<button type="button" data-helpdesk-tag="em"
class="rounded-lg border px-2 py-1 text-xs italic">I</button>
<button type="button" data-helpdesk-tag="ul"
class="rounded-lg border px-2 py-1 text-xs">List</button>
<button type="button" data-helpdesk-wrap="<blockquote>"
data-helpdesk-wrap-end="</blockquote>"
class="rounded-lg border px-2 py-1 text-xs">Quote</button>
<button type="button" data-helpdesk-wrap="<code>" data-helpdesk-wrap-end="</code>"
class="rounded-lg border px-2 py-1 text-xs">Code</button>
</div>
<textarea spellcheck="true" lang="en-GB" autocorrect="on" autocomplete="on" autocapitalize="sentences" inputmode="text" id="reply-body-{{ $comment->id }}" dusk="reply-body-{{ $comment->id }}" name="commentBody" rows="4"
required
class="block w-full rounded-xl border border-zinc-300 bg-white p-3 text-sm text-zinc-900 shadow-sm focus:border-blue-500 focus:ring-blue-500 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100"
placeholder="Write a threaded Lotus Notes-style response..."></textarea>
<div class="mt-4 rounded-xl border border-zinc-200 bg-white p-3 shadow-sm dark:border-zinc-700 dark:bg-zinc-950">
<p class="text-xs font-extrabold uppercase tracking-[0.16em] text-zinc-500 dark:text-zinc-400">Visibility</p>
@can('update', $currentTicket)
@if ($canSeeInternalNotes)
<div class="mt-3 grid gap-3 sm:grid-cols-2">
<label class="flex cursor-pointer items-start gap-3 rounded-xl border border-emerald-300 bg-emerald-50 p-3 text-emerald-950 shadow-sm transition hover:border-emerald-400 hover:bg-emerald-100/80 focus-within:border-emerald-500 focus-within:bg-emerald-100/80 focus-within:ring-2 focus-within:ring-emerald-400/30 active:bg-emerald-100/80 dark:border-emerald-900 dark:bg-emerald-950/60 dark:text-emerald-100 dark:hover:border-emerald-700 dark:hover:bg-emerald-900/50 dark:focus-within:bg-emerald-900/50">
<input type="radio" name="internal" value="0" checked class="mt-1 border-emerald-400 text-emerald-600 focus:ring-emerald-500">
<span>
<span class="block text-sm font-extrabold">Public reply</span>
<span class="mt-1 block text-xs font-semibold opacity-80">Visible to the requester and counts towards SLA.</span>
</span>
</label>
<label class="flex cursor-pointer items-start gap-3 rounded-xl border border-purple-300 bg-purple-50 p-3 text-purple-950 shadow-sm transition hover:border-purple-400 hover:bg-purple-100/80 focus-within:border-purple-500 focus-within:bg-purple-100/80 focus-within:ring-2 focus-within:ring-purple-400/30 active:bg-purple-100/80 dark:border-purple-900 dark:bg-purple-950/60 dark:text-purple-100 dark:hover:border-purple-700 dark:hover:bg-purple-900/50 dark:focus-within:bg-purple-900/50">
<input type="radio" name="internal" value="1" class="mt-1 border-purple-400 text-purple-600 focus:ring-purple-500">
<span>
<span class="block text-sm font-extrabold">Internal note</span>
<span class="mt-1 block text-xs font-semibold opacity-80">Support-only note. Does not count as public SLA response.</span>
</span>
</label>
</div>
@else
<input type="hidden" name="internal" value="0">
<div class="mt-3 rounded-xl border border-emerald-300 bg-emerald-50 p-3 text-sm font-semibold text-emerald-950 dark:border-emerald-900 dark:bg-emerald-950/60 dark:text-emerald-100">
<i class="fa-solid fa-envelope-circle-check mr-2" aria-hidden="true"></i>
This threaded response will be public.
</div>
@endif
@else
<input type="hidden" name="internal" value="0">
@endcan
</div>
<details
class="mt-4 overflow-hidden rounded-xl border border-zinc-200 bg-white/80 shadow-sm dark:border-zinc-800 dark:bg-zinc-950/50">
<summary
class="group flex cursor-pointer list-none items-center justify-between gap-3 bg-gradient-to-r from-slate-950 via-blue-950 to-slate-900 px-4 py-3 text-white [&::-webkit-details-marker]:hidden">
<span class="flex min-w-0 items-center gap-3">
<span
class="inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-xl border border-blue-400/30 bg-blue-500/15 text-blue-200">
<i class="fa-solid fa-paperclip text-xs" aria-hidden="true"></i>
</span>
<span class="min-w-0">
<span
class="block text-[10px] font-black uppercase tracking-[0.22em] text-blue-200">Attachments</span>
<span class="block truncate text-xs font-semibold text-zinc-300">Pin
response files.</span>
</span>
</span>
<span class="flex shrink-0 items-center gap-2">
<span
class="rounded-full border border-white/10 bg-white/10 px-2.5 py-1 text-[10px] font-black text-white"
data-helpdesk-file-count>0 files</span>
<i class="fa-solid fa-chevron-down text-[10px] text-blue-200 transition group-open:rotate-180"
aria-hidden="true"></i>
</span>
</summary>
<div class="p-4">
<div
class="flex min-h-[4.5rem] flex-col gap-3 rounded-xl border border-zinc-200 bg-zinc-50/80 p-4 dark:border-zinc-800 dark:bg-zinc-950/70 sm:flex-row sm:items-center sm:justify-between">
<span class="text-xs font-semibold text-zinc-500 dark:text-zinc-400"
data-helpdesk-file-label>No files attached</span>
<label data-helpdesk-file-button>
<i class="fa-solid fa-paperclip" aria-hidden="true"></i>
<span>Attach files</span>
<input name="attachments[]" type="file" multiple accept="{{ $helpdeskAttachmentAccept }}" class="sr-only"
data-helpdesk-file-input>
</label>
</div>
</div>
</details>
<div class="mt-4 flex justify-end gap-2">
<button type="button" data-helpdesk-reply-toggle="{{ $replyFormId }}"
class="inline-flex items-center justify-center rounded-lg bg-slate-600 px-3 py-2 text-xs font-bold text-white shadow-sm transition hover:bg-slate-700 focus:outline-none focus:ring-2 focus:ring-slate-400/70">Cancel</button>
<button type="submit" dusk="post-reply-{{ $comment->id }}"
class="inline-flex items-center justify-center rounded-lg bg-emerald-600 px-3 py-2 text-xs font-bold text-white shadow-sm transition hover:bg-emerald-700 focus:outline-none focus:ring-2 focus:ring-emerald-400/70">Post
response</button>
</div>
</form>
@endif
@if ($commentReplies->isNotEmpty())
<div class="mt-4 border-l-4 border-red-500 pl-4">
@include('helpdesk::partials.comment-thread', [
'comments' => $commentReplies,
'level' => ((int) $level) + 1,
'ticket' => $currentTicket,
'canSeeInternalNotes' => $canSeeInternalNotes,
])
</div>
@endif
</div>
</details>
@endif
@endforeach
</div>
@@ -0,0 +1,27 @@
<div class="overflow-hidden rounded-3xl border border-zinc-200 bg-white shadow-sm dark:border-zinc-700 dark:bg-zinc-900">
<div class="bg-gradient-to-br from-slate-950 via-slate-900 to-blue-950 px-6 py-7 text-white">
<div class="flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between">
<div>
<p class="text-xs font-semibold uppercase tracking-[0.28em] text-blue-200">
{{ $eyebrow ?? 'Helpdesk' }}
</p>
<h1 class="mt-2 text-3xl font-semibold tracking-tight">
{{ $title ?? 'Helpdesk' }}
</h1>
@if (!empty($subtitle))
<p class="mt-2 max-w-3xl text-sm text-blue-100/90">
{{ $subtitle }}
</p>
@endif
</div>
@isset($actions)
<div class="flex flex-wrap gap-2">
{{ $actions }}
</div>
@endisset
</div>
</div>
</div>
@@ -0,0 +1,275 @@
@can('update', $ticket)
<details
class="group rounded-xl border border-zinc-200 bg-white p-4 shadow-sm dark:border-zinc-700 dark:bg-zinc-900"
data-helpdesk-ticket-controls>
<summary
class="-mx-4 -mt-4 mb-4 flex cursor-pointer list-none items-center justify-between gap-3 rounded-t-xl bg-indigo-700 px-4 py-4 text-white marker:hidden">
<div class="flex min-w-0 items-center gap-3">
<span
class="inline-flex h-12 w-12 shrink-0 items-center justify-center rounded-xl bg-indigo-950 text-white ring-1 ring-indigo-300/60 shadow-lg">
<i class="fa-solid fa-sliders text-lg" aria-hidden="true"></i>
</span>
<div class="min-w-0">
<h2 class="text-lg font-black uppercase tracking-wide">Ticket controls</h2>
<p class="text-xs font-semibold text-indigo-100">
Log time, assignment, status and priority
</p>
</div>
</div>
<span
class="inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-white/15 text-white ring-1 ring-white/20">
<i class="fa-solid fa-chevron-right text-xs transition group-open:rotate-90" aria-hidden="true"></i>
</span>
</summary>
@if (session('ticket-action-updated'))
<div
class="mb-4 rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-2 text-xs font-bold text-emerald-800 dark:border-emerald-800 dark:bg-emerald-950 dark:text-emerald-100">
{{ session('ticket-action-updated') }}
</div>
@endif
@include('helpdesk::partials.ticket-time-timer', [
'ticket' => $ticket,
])
<form method="POST" action="{{ route('helpdesk.tickets.time-logs.store', $ticket) }}"
class="mb-4 space-y-2">
@csrf
<label class="block text-xs font-bold text-zinc-700 dark:text-zinc-200"
for="ticket_time_minutes">Log time</label>
<div class="grid grid-cols-[1fr_auto] gap-2">
<input id="ticket_time_minutes" name="minutes" type="number" min="1" max="1440"
placeholder="Minutes"
class="block w-full rounded-lg border border-zinc-300 bg-white p-2 text-xs font-semibold text-zinc-900 shadow-sm focus:border-emerald-500 focus:ring-emerald-500 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100"
data-dusk="ticket-time-minutes">
<button type="submit" dusk="log-ticket-time" data-dusk="log-ticket-time"
class="inline-flex items-center justify-center rounded-lg bg-emerald-600 px-3 py-2 text-xs font-black text-white shadow-sm transition hover:bg-emerald-700 focus:outline-none focus:ring-2 focus:ring-emerald-400/70">
<i class="fa-solid fa-clock mr-2" aria-hidden="true"></i>
<span>Log</span>
</button>
</div>
<textarea spellcheck="true" lang="en-GB" name="description" rows="2" placeholder="Optional work note"
class="block w-full rounded-lg border border-zinc-300 bg-white p-2 text-xs font-semibold text-zinc-900 shadow-sm focus:border-emerald-500 focus:ring-emerald-500 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100"
data-dusk="ticket-time-description"></textarea>
@error('minutes')
<p class="text-xs font-bold text-red-600 dark:text-red-400">{{ $message }}</p>
@enderror
@error('description')
<p class="text-xs font-bold text-red-600 dark:text-red-400">{{ $message }}</p>
@enderror
</form>
<form method="POST" action="{{ route('helpdesk.tickets.agent.update', $ticket) }}"
class="mb-4 space-y-2">
@csrf
<label class="block text-xs font-bold text-zinc-700 dark:text-zinc-200"
for="show_agent_id">Assigned agent</label>
<select id="show_agent_id" name="agent_id"
class="hd-select block w-full rounded-lg border border-zinc-300 bg-white p-2 text-xs font-semibold text-zinc-900 shadow-sm focus:border-emerald-500 focus:ring-emerald-500 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100"
data-dusk="ticket-show-agent">
<option value="" @selected($agent_id === null)>Unassigned</option>
@forelse ($agents as $agent)
<option
value="{{ $agent->id }}" @selected((int) $agent_id === (int) $agent->id)>{{ $agent->name }}
·
{{ $agent->email }}</option>
@empty
<option value="" disabled>No users available for assignment</option>
@endforelse
</select>
@error('agent_id')
<p class="text-xs font-bold text-red-600 dark:text-red-400">{{ $message }}</p>
@enderror
<button type="submit" dusk="update-agent" data-dusk="update-agent"
class="inline-flex items-center justify-center rounded-lg bg-emerald-600 px-3 py-2 text-xs font-black text-white shadow-sm transition hover:bg-emerald-700 focus:outline-none focus:ring-2 focus:ring-emerald-400/70">
<i class="fa-solid fa-user-check mr-2" aria-hidden="true"></i>
<span>Assign agent</span>
</button>
</form>
<form method="POST" action="{{ route('helpdesk.tickets.status.update', $ticket) }}"
class="mb-4 space-y-2"
data-helpdesk-status-form>
@csrf
<label class="block text-xs font-bold text-zinc-700 dark:text-zinc-200"
for="show_status_id">Status</label>
<select id="show_status_id" name="status_id"
class="hd-select block min-h-10 w-full rounded-lg border border-zinc-300 bg-white px-3 py-2 text-xs font-semibold text-zinc-900 shadow-sm focus:border-blue-500 focus:ring-blue-500 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100"
data-dusk="ticket-show-status">
@foreach ($statuses as $status)
<option
value="{{ $status->id }}"
data-is-closed="{{ $status->is_closed ? '1' : '0' }}"
@selected((int) $status_id === (int) $status->id)>{{ $status->name }}
</option>
@endforeach
</select>
@error('status_id')
<p class="text-xs font-bold text-red-600 dark:text-red-400">{{ $message }}</p>
@enderror
@error('closure_comment')
<p class="text-xs font-bold text-red-600 dark:text-red-400">{{ $message }}</p>
@enderror
<dialog data-helpdesk-close-ticket-dialog
class="w-full max-w-lg rounded-2xl border border-zinc-200 bg-white p-0 shadow-2xl backdrop:bg-slate-950/70 dark:border-zinc-700 dark:bg-zinc-900">
<div class="bg-gradient-to-r from-red-800 via-red-700 to-slate-900 px-5 py-4 text-white">
<div class="flex items-center gap-3">
<span class="inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-white/15 text-white ring-1 ring-white/20">
<i class="fa-solid fa-lock" aria-hidden="true"></i>
</span>
<div class="min-w-0">
<h3 class="text-base font-black tracking-tight">Close ticket</h3>
<p class="text-xs font-semibold text-red-100">A closure comment is required for the audit trail.</p>
</div>
</div>
</div>
<div class="space-y-4 p-5">
<label class="block text-xs font-bold text-zinc-700 dark:text-zinc-200" for="closure_comment">
Closure comment <span class="text-red-600">*</span>
</label>
<textarea id="closure_comment" spellcheck="true" lang="en-GB" name="closure_comment" rows="5" minlength="10" maxlength="5000"
placeholder="Explain what was completed, verified, or agreed before closing this ticket."
class="block w-full rounded-xl border border-zinc-300 bg-white p-3 text-sm font-semibold text-zinc-900 shadow-sm focus:border-red-500 focus:ring-red-500 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100"
data-helpdesk-closure-comment>{{ old('closure_comment') }}</textarea>
<label class="flex items-start gap-3 rounded-xl border border-emerald-200 bg-emerald-50 p-3 text-sm text-emerald-950 dark:border-emerald-900 dark:bg-emerald-950 dark:text-emerald-100">
<input type="hidden" name="closure_internal" value="0">
<input type="checkbox" name="closure_internal" value="1"
class="mt-1 rounded border-emerald-400 text-purple-600 focus:ring-purple-500">
<span>
<span class="block font-extrabold">Internal closure note</span>
<span class="mt-1 block text-xs font-semibold opacity-80">Leave unticked to save the closure as a public customer-visible response.</span>
</span>
</label>
<div class="flex flex-col-reverse gap-2 sm:flex-row sm:justify-end">
<button type="button" data-helpdesk-close-dialog-cancel
class="inline-flex items-center justify-center rounded-lg border border-zinc-300 bg-white px-4 py-2 text-xs font-black text-zinc-700 shadow-sm hover:bg-zinc-50 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100 dark:hover:bg-zinc-800">
Cancel
</button>
<button type="submit" data-helpdesk-confirm-close
class="inline-flex items-center justify-center rounded-lg bg-red-600 px-4 py-2 text-xs font-black text-white shadow-sm hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-400/70">
<i class="fa-solid fa-lock mr-2" aria-hidden="true"></i>
Close ticket
</button>
</div>
</div>
</dialog>
<button type="submit" dusk="update-status"
class="inline-flex items-center justify-center rounded-lg bg-blue-600 px-3 py-2 text-xs font-black text-white shadow-sm transition hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-400/70">
<i class="fa-solid fa-circle-check mr-2" aria-hidden="true"></i>
<span>Update status</span>
</button>
</form>
<form method="POST" action="{{ route('helpdesk.tickets.priority.update', $ticket) }}"
class="space-y-2">
@csrf
<label class="block text-xs font-bold text-zinc-700 dark:text-zinc-200"
for="show_priority_id">Priority</label>
<select id="show_priority_id" name="priority_id"
class="hd-select block w-full rounded-lg border border-zinc-300 bg-white p-2 text-xs font-semibold text-zinc-900 shadow-sm focus:border-amber-500 focus:ring-amber-500 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100"
data-dusk="ticket-show-priority">
@foreach ($priorities as $priority)
<option
value="{{ $priority->id }}" @selected((int) $priority_id === (int) $priority->id)>{{ $priority->name }}
</option>
@endforeach
</select>
@error('priority_id')
<p class="text-xs font-bold text-red-600 dark:text-red-400">{{ $message }}</p>
@enderror
<button type="submit" dusk="update-priority"
class="inline-flex items-center justify-center rounded-lg bg-amber-500 px-3 py-2 text-xs font-black text-white shadow-sm transition hover:bg-amber-600 focus:outline-none focus:ring-2 focus:ring-amber-300/70">
<i class="fa-solid fa-flag mr-2" aria-hidden="true"></i>
<span>Update priority</span>
</button>
</form>
</details>
<script>
(() => {
const initialiseCloseTicketDialogs = () => {
document.querySelectorAll('[data-helpdesk-status-form]').forEach((form) => {
if (form.dataset.helpdeskCloseDialogInitialised === '1') {
return;
}
form.dataset.helpdeskCloseDialogInitialised = '1';
const statusSelect = form.querySelector('[data-dusk="ticket-show-status"]');
const dialog = form.querySelector('[data-helpdesk-close-ticket-dialog]');
const comment = form.querySelector('[data-helpdesk-closure-comment]');
const cancel = form.querySelector('[data-helpdesk-close-dialog-cancel]');
const originalStatus = statusSelect?.value || '';
if (!statusSelect || !dialog || !comment) {
return;
}
const selectedStatusIsClosed = () => {
const selectedOption = statusSelect.options[statusSelect.selectedIndex];
return selectedOption?.dataset?.isClosed === '1';
};
const openDialog = () => {
if (!dialog.open) {
dialog.showModal();
}
window.setTimeout(() => comment.focus(), 50);
};
statusSelect.addEventListener('change', () => {
if (selectedStatusIsClosed()) {
openDialog();
}
});
form.addEventListener('submit', (event) => {
if (!selectedStatusIsClosed() || comment.value.trim().length >= 10) {
return;
}
event.preventDefault();
openDialog();
});
cancel?.addEventListener('click', () => {
dialog.close();
statusSelect.value = originalStatus;
statusSelect.dispatchEvent(new Event('change', { bubbles: true }));
});
});
};
document.addEventListener('DOMContentLoaded', initialiseCloseTicketDialogs);
document.addEventListener('livewire:navigated', initialiseCloseTicketDialogs);
initialiseCloseTicketDialogs();
})();
</script>
@endcan
@@ -0,0 +1,16 @@
@php
$ticketTimeLogs = \Modules\Helpdesk\Models\TicketTimeLog::query()
->with('user')
->where('ticket_id', $ticket->getKey())
->whereNotNull('ended_at')
->latest('logged_at')
->get();
$ticketLoggedSeconds = (int) $ticketTimeLogs->sum(function ($timeLog) {
return (int) ($timeLog->seconds ?? ((int) $timeLog->minutes * 60));
});
$ticketLoggedHours = intdiv($ticketLoggedSeconds, 3600);
$ticketLoggedMinutes = intdiv($ticketLoggedSeconds % 3600, 60);
$ticketLoggedRemainingSeconds = $ticketLoggedSeconds % 60;
@endphp
@@ -0,0 +1,3 @@
@can('update', $ticket)
@livewire('helpdesk.ticket-timer', ['ticket' => $ticket], key('helpdesk-ticket-timer-'.$ticket->getKey()))
@endcan
@@ -0,0 +1,32 @@
<form method="POST" action="{{ route('helpdesk.tickets.time-logs.store', $ticket) }}" class="mb-4 space-y-2">
@csrf
<label class="block text-xs font-bold text-zinc-700 dark:text-zinc-200" for="time_minutes">
Log time
</label>
<div class="grid grid-cols-[1fr_auto] gap-2">
<input id="time_minutes" name="minutes" type="number" min="1" max="1440" value="{{ old('minutes') }}"
placeholder="Minutes"
class="block w-full rounded-lg border border-zinc-300 bg-white p-2 text-xs font-semibold text-zinc-900 shadow-sm focus:border-emerald-500 focus:ring-emerald-500 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100"
data-dusk="ticket-time-minutes">
<button type="submit" dusk="log-ticket-time" data-dusk="log-ticket-time"
class="inline-flex items-center justify-center rounded-lg bg-emerald-600 px-3 py-2 text-xs font-black text-white shadow-sm transition hover:bg-emerald-700 focus:outline-none focus:ring-2 focus:ring-emerald-400/70">
<i class="fa-solid fa-clock mr-2" aria-hidden="true"></i>
<span>Log</span>
</button>
</div>
<textarea spellcheck="true" lang="en-GB" name="description" rows="2" placeholder="Optional work note"
class="block w-full rounded-lg border border-zinc-300 bg-white p-2 text-xs font-semibold text-zinc-900 shadow-sm focus:border-emerald-500 focus:ring-emerald-500 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100"
data-dusk="ticket-time-description">{{ old('description') }}</textarea>
@error('minutes')
<p class="text-xs font-bold text-red-600 dark:text-red-400">{{ $message }}</p>
@enderror
@error('description')
<p class="text-xs font-bold text-red-600 dark:text-red-400">{{ $message }}</p>
@enderror
</form>