277 lines
15 KiB
PHP
Executable File
277 lines
15 KiB
PHP
Executable File
@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 aria-label="Description" 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">
|
|
<label for="sonar-input-25ff0676dc" class="visually-hidden">closure internal</label>
|
|
<input type="checkbox" name="closure_internal" value="1"
|
|
class="mt-1 rounded border-emerald-400 text-purple-600 focus:ring-purple-500" id="sonar-input-25ff0676dc">
|
|
<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
|