Files
servicedesk/src/resources/views/livewire/client/ticket-show.blade.php
Kacper 90fae0a4de v1.1.0
- In-app notifications: a bell in the top bar backed by Laravel's database
  notification channel, alongside existing e-mail notifications (same
  per-trigger toggle drives both; ticket links now correctly point into the
  recipient's own area instead of always linking to the client view).
- Drag-and-drop attachments on every upload form, plus inline image
  thumbnails in the message thread instead of a plain download link.
- Customer satisfaction (CSAT) rating: clients rate a closed ticket 1-5 stars
  with an optional comment; shown read-only to operators, surfaced as a KPI
  on the stats dashboard, and linked from the "ticket closed" e-mail.
- Saved queue views: operators can save/apply/delete named filter+sort+
  column presets in the ticket queue and mark one as their default.
- Full-text search (MySQL FULLTEXT, portable LIKE fallback) across ticket
  subject/body and reply message bodies, now also on the client's own ticket
  list.
- Stats CSV export for the currently filtered ticket set.
- Optional BookStack knowledge-base integration (off by default): suggests
  articles by category/subcategory while creating a ticket and in a separate
  sidebar for operators on an existing ticket (with a copy-link button).
  Configurable connection/SSL bypass/search-type filter, plus two
  independent per-shelf allow-lists so nothing is ever searched until an
  admin opts specific shelves in.
- Closed tickets no longer show in "Moje zgłoszenia"/"Nieprzypisane"/team
  queue tabs, only under "Zamknięte" (matching how "Otwarte" already worked).
- Wired up the Admin > About "Wersja" field to config('app.version')/VERSION
  in .env instead of a stale hardcoded string.
- Fixed: TicketService::setStatus() now checks a status's stage rather than
  the literal key 'closed' to decide whether to fire the "ticket closed"
  notification/stop the timer.
- Updated README/ARCHITECTURE/CHANGELOG/install/SECURITY docs and all three
  wiki/ role guides for the above; documented a root-vs-www-data file
  ownership gotcha in CLAUDE.md (running artisan commands via a plain
  `docker exec` can leave root-owned Blade cache files that later break
  recompilation for the www-data Apache process).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-22 15:18:09 +02:00

173 lines
12 KiB
PHP

<div style="flex:1;display:flex;flex-direction:column">
<x-topbar />
<div class="page-pad" style="flex:1;padding:28px;display:flex;flex-direction:column;gap:20px;max-width:920px;width:100%;margin:0 auto;box-sizing:border-box">
<a href="{{ route('client.dashboard') }}" wire:navigate class="btn btn-ghost" style="align-self:flex-start;padding:0">&larr; Wróć do listy</a>
<div style="display:flex;gap:20px;align-items:flex-start;flex-wrap:wrap">
<div class="main-col" style="display:flex;flex-direction:column;gap:16px">
@php
$firstMessage = $this->ticketMessages->first();
$threadMessages = $this->ticketMessages->skip(1);
@endphp
<div class="card" style="padding:22px;gap:10px">
<div class="card-kicker">Zgłoszenie #{{ $ticket->number }}</div>
<h2 style="margin:2px 0 0">{{ $ticket->subject }}</h2>
<div class="card-meta">{{ $ticket->categoryLabel() }} &middot; utworzono {{ \App\Support\Rel::format($ticket->created_at) }}</div>
<div style="white-space:pre-wrap;font-size:14px;margin-top:4px">{{ $ticket->body }}</div>
@foreach ($firstMessage?->attachments ?? [] as $a)
<x-message-attachment :attachment="$a" />
@endforeach
@if (count($ticket->customFieldEntries()))
<div style="display:flex;flex-direction:column;gap:2px;margin-top:2px">
@foreach ($ticket->customFieldEntries() as $cf)
<div style="font-size:14px"><strong>{{ $cf['label'] }}:</strong> {{ $cf['value'] }}</div>
@endforeach
</div>
@endif
</div>
<div style="display:flex;flex-direction:column;gap:10px">
@foreach ($threadMessages as $m)
@php $mine = $m->role === 'client' && $m->author_id === auth()->id(); @endphp
<div style="display:flex;justify-content:{{ $mine ? 'flex-end' : 'flex-start' }}">
<div style="max-width:75%;padding:10px 14px;border-radius:12px;font-size:14px;background:{{ $mine ? 'var(--color-accent-800)' : 'var(--color-surface)' }};color:{{ $mine ? 'var(--color-accent-100)' : 'var(--color-text)' }};border:1px solid var(--color-divider)">
<div style="display:flex;justify-content:space-between;align-items:flex-start;gap:10px">
<div style="font-size:11px;opacity:0.65;margin-bottom:4px">{{ $m->author_name }} &middot; {{ \App\Support\Rel::format($m->created_at) }}{{ $m->edited ? ' · edytowano' : '' }}</div>
@if ($m->role === 'client' && $m->author_id === auth()->id())
<div style="display:flex;gap:6px;flex:none">
<span class="material-symbols-outlined" style="font-size:15px;cursor:pointer;opacity:0.7" wire:click="startEdit({{ $m->id }}, @js($m->body))">edit</span>
<span class="material-symbols-outlined" style="font-size:15px;cursor:pointer;opacity:0.7" wire:click="requestDelete({{ $m->id }})">delete</span>
</div>
@endif
</div>
@if ($editingMessageId === $m->id)
<textarea class="input" wire:model="editingDraft"></textarea>
<div style="display:flex;gap:8px;margin-top:6px">
<button type="button" class="btn btn-secondary" wire:click="cancelEdit">Anuluj</button>
<button type="button" class="btn btn-primary" wire:click="saveEdit">Zapisz</button>
</div>
@else
<div style="white-space:pre-wrap">{{ $m->body }}</div>
@endif
@foreach ($m->attachments as $a)
<x-message-attachment :attachment="$a" />
@endforeach
</div>
</div>
@endforeach
</div>
<form wire:submit="sendReply" class="card" style="padding:16px;gap:10px">
<textarea class="input" placeholder="Napisz odpowiedź…" wire:model="reply"></textarea>
@error('reply') <span style="color:var(--color-danger);font-size:12px">{{ $message }}</span> @enderror
<div style="display:flex;align-items:center;gap:10px">
<div
x-data="{ dragging: false }"
@dragover.prevent="dragging = true"
@dragleave.prevent="dragging = false"
@drop.prevent="dragging = false; const input = $el.querySelector('input[type=file]'); input.files = $event.dataTransfer.files; input.dispatchEvent(new Event('change'))"
:style="{ borderColor: dragging ? 'var(--color-accent)' : undefined, background: dragging ? 'color-mix(in srgb, var(--color-accent) 8%, transparent)' : undefined }"
style="flex:1;min-width:0;border:1px dashed var(--color-divider);border-radius:8px;padding:10px 14px;display:flex;flex-wrap:wrap;align-items:center;gap:10px"
>
<label class="btn btn-secondary" style="cursor:pointer;flex:none">Załącz pliki<input type="file" multiple style="display:none" wire:model="attachments"></label>
@forelse ($attachments as $i => $file)
<span class="text-muted" style="font-size:13px;display:flex;align-items:center;gap:6px;min-width:0">
<span class="material-symbols-outlined" style="font-size:16px;flex:none">attach_file</span>
<span style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap">{{ $file->getClientOriginalName() }}</span>
<span class="material-symbols-outlined" style="font-size:16px;cursor:pointer;opacity:0.7;flex:none" wire:click="removeAttachment({{ $i }})">close</span>
</span>
@empty
<span class="text-muted" style="font-size:13px">Brak załączników</span>
@endforelse
</div>
<button class="btn btn-primary" style="flex:none" type="submit">Wyślij odpowiedź</button>
</div>
@error('attachments') <span style="color:var(--color-danger);font-size:12px">{{ $message }}</span> @enderror
</form>
</div>
<div class="aside-col" style="display:flex;flex-direction:column;gap:14px">
<div class="card" style="padding:16px;gap:8px">
<div class="card-kicker">Twoje dane</div>
<div style="font-size:14px;font-weight:500">{{ auth()->user()->name }}</div>
<div class="text-muted" style="font-size:13px">{{ auth()->user()->email }}</div>
</div>
<div class="card" style="padding:16px;gap:10px">
<div class="card-kicker">Status i priorytet</div>
<div style="display:flex;gap:6px">
<span style="{{ $ticket->priorityStyle() }}">{{ $ticket->priorityLabel() }}</span>
<span style="{{ $ticket->statusStyle() }}">{{ $ticket->statusLabel() }}</span>
</div>
@if (! $ticket->isClosed())
<button type="button" class="btn btn-secondary btn-block" wire:click="close">Zamknij zgłoszenie</button>
@elseif ($ticket->isClosed())
<button type="button" class="btn btn-secondary btn-block" wire:click="reopen">Otwórz ponownie</button>
@endif
</div>
<div id="csat" class="card" style="padding:16px;gap:10px">
<div class="card-kicker">Ocena obsługi</div>
@if ($ticket->hasCsatRating())
<div style="display:flex;gap:2px">
@for ($i = 1; $i <= 5; $i++)
<span class="material-symbols-outlined" style="font-size:20px;color:{{ $i <= $ticket->csat_rating ? 'var(--color-accent)' : 'var(--color-divider)' }}">star</span>
@endfor
</div>
@if ($ticket->csat_comment)
<p style="font-size:13px;margin:0;white-space:pre-wrap">{{ $ticket->csat_comment }}</p>
@endif
@elseif ($ticket->csatSubmittable())
<div style="display:flex;gap:4px" wire:key="csat-stars-{{ $csatRating }}">
@for ($i = 1; $i <= 5; $i++)
<span
class="material-symbols-outlined"
style="font-size:24px;cursor:pointer;color:{{ $csatRating && $i <= $csatRating ? 'var(--color-accent)' : 'var(--color-divider)' }}"
wire:click="$set('csatRating', {{ $i }})"
>star</span>
@endfor
</div>
@error('csatRating') <span style="color:var(--color-danger);font-size:12px">{{ $message }}</span> @enderror
<textarea class="input" placeholder="Komentarz (opcjonalnie)" wire:model="csatComment" style="min-height:60px"></textarea>
<button type="button" class="btn btn-primary btn-block" wire:click="submitCsat">Wyślij ocenę</button>
@else
<p class="text-muted" style="font-size:12px;margin:0">Ocena będzie dostępna po zamknięciu zgłoszenia.</p>
@endif
</div>
<div class="card" style="padding:16px;gap:8px">
<div class="card-kicker">Historia zmian</div>
@forelse ($ticket->histories as $h)
<div style="font-size:12.5px"><span>{{ $h->text }}</span><div class="text-muted" style="font-size:11px">{{ \App\Support\Rel::format($h->created_at) }}</div></div>
@empty
<p class="text-muted" style="font-size:12px;margin:0">Brak historii zmian.</p>
@endforelse
</div>
<div class="card" style="padding:16px;gap:8px">
<div class="card-kicker">Inne Twoje zgłoszenia</div>
@forelse ($this->otherTickets as $ot)
<a href="{{ route('client.ticket', $ot) }}" wire:navigate style="display:flex;justify-content:space-between;align-items:center;gap:8px;cursor:pointer;text-decoration:none;color:inherit">
<span style="font-size:13px">#{{ $ot->number }} — {{ $ot->subject }}</span>
<span style="{{ $ot->statusStyle() }};flex:none">{{ $ot->statusLabel() }}</span>
</a>
@empty
<p class="text-muted" style="font-size:12px;margin:0">Brak innych zgłoszeń.</p>
@endforelse
</div>
</div>
</div>
</div>
@if ($pendingDeleteMessageId)
<div class="dialog-backdrop">
<div class="dialog" style="max-width:400px">
<div class="dialog-title">Potwierdź usunięcie</div>
<div class="dialog-body">Czy na pewno usunąć wiadomość?</div>
<div class="dialog-actions">
<button type="button" class="btn btn-secondary" wire:click="cancelDelete">Anuluj</button>
<button type="button" class="btn btn-primary" wire:click="confirmDelete">Usuń</button>
</div>
</div>
</div>
@endif
</div>