- 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>
This commit is contained in:
2026-07-22 15:18:09 +02:00
parent 4e8f17189a
commit 90fae0a4de
49 changed files with 1649 additions and 79 deletions

View File

@@ -5,7 +5,7 @@ APP_DEBUG=true
APP_URL=http://localhost
AUTHOR_CONTACT=helpdesk@kzbikowski.pl
VERSION=1.0.2
VERSION=1.1.0
APP_LOCALE=en
APP_FALLBACK_LOCALE=en

View File

@@ -15,8 +15,10 @@ use App\Models\Subcategory;
use App\Models\Team;
use App\Models\User;
use App\Models\UserField;
use App\Services\BookStackClient;
use App\Services\LdapUserProvisioner;
use App\Support\Settings;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Mail;
@@ -137,6 +139,12 @@ class Panel extends Component
public ?string $mailTestResult = null;
public array $bookstackConfig = [];
public ?string $bookstackTestResult = null;
public ?string $bookstackTestMessage = null;
// ---- generic pending-delete confirm ----
public ?string $pendingDeleteType = null;
@@ -187,6 +195,18 @@ class Panel extends Component
'fromAddress' => Settings::get('mail_from_address'),
'fromName' => Settings::get('mail_from_name'),
];
$this->bookstackConfig = [
'enabled' => Settings::bool('bookstack_enabled'),
'baseUrl' => Settings::get('bookstack_base_url'),
'tokenId' => Settings::get('bookstack_token_id'),
'tokenSecret' => Settings::get('bookstack_token_secret'),
'verifySsl' => Settings::bool('bookstack_verify_ssl'),
'showToGuests' => Settings::bool('bookstack_show_to_guests'),
'searchTypes' => Settings::get('bookstack_search_types', 'both'),
'allowedShelfIdsCreation' => $this->parseShelfIds(Settings::get('bookstack_allowed_shelf_ids_creation', '')),
'allowedShelfIdsTicketView' => $this->parseShelfIds(Settings::get('bookstack_allowed_shelf_ids_ticket_view', '')),
];
}
public function setTab(string $tab): void
@@ -965,7 +985,7 @@ class Panel extends Component
* key-primary-keyed, sort_order-ordered lists edited the same way: swap
* this row's sort_order with its immediate neighbor in the given direction.
*
* @param \Illuminate\Support\Collection<int, Status|Priority> $ordered
* @param Collection<int, Status|Priority> $ordered
*/
protected function swapAdjacentSortOrder($ordered, string $key, int $direction): void
{
@@ -1288,6 +1308,90 @@ class Panel extends Component
}
}
// ===================== BOOKSTACK CONFIG =====================
public function saveBookstackConfig(): void
{
Settings::set('bookstack_enabled', $this->bookstackConfig['enabled'] ? '1' : '0');
Settings::set('bookstack_base_url', $this->bookstackConfig['baseUrl']);
Settings::set('bookstack_token_id', $this->bookstackConfig['tokenId']);
if ($this->bookstackConfig['tokenSecret']) {
Settings::set('bookstack_token_secret', $this->bookstackConfig['tokenSecret']);
}
Settings::set('bookstack_verify_ssl', $this->bookstackConfig['verifySsl'] ? '1' : '0');
Settings::set('bookstack_show_to_guests', $this->bookstackConfig['showToGuests'] ? '1' : '0');
if (in_array($this->bookstackConfig['searchTypes'], ['both', 'page', 'book'], true)) {
Settings::set('bookstack_search_types', $this->bookstackConfig['searchTypes']);
}
Settings::set('bookstack_allowed_shelf_ids_creation', implode(',', $this->bookstackConfig['allowedShelfIdsCreation']));
Settings::set('bookstack_allowed_shelf_ids_ticket_view', implode(',', $this->bookstackConfig['allowedShelfIdsTicketView']));
$this->bookstackTestResult = null;
$this->bookstackTestMessage = null;
}
#[Computed]
public function bookstackShelves(): array
{
return app(BookStackClient::class)->shelves();
}
/**
* Drops the cached shelf list (and its dependent shelf>book map) so a
* shelf added/renamed/removed in BookStack shows up in both checklists
* right away, then re-fetches shared by both "Dozwolone półki"
* checklists since they list the exact same shelves.
*/
public function refreshBookstackShelves(): void
{
app(BookStackClient::class)->clearShelfCache();
unset($this->bookstackShelves);
}
/**
* @return int[]
*/
protected function parseShelfIds(string $raw): array
{
return collect(explode(',', $raw))->map(fn ($v) => (int) trim($v))->filter()->values()->all();
}
/**
* $field is 'allowedShelfIdsCreation' or 'allowedShelfIdsTicketView'
* the two independent allow-lists (ticket-creation suggestions vs. the
* operator ticket-view sidebar) toggled by their own checklist.
*/
public function toggleBookstackAllowedShelf(string $field, int $id): void
{
$ids = $this->bookstackConfig[$field];
$this->bookstackConfig[$field] = in_array($id, $ids, true)
? array_values(array_diff($ids, [$id]))
: [...$ids, $id];
}
public function testBookstackConnection(): void
{
$cfg = $this->bookstackConfig;
if (empty($cfg['baseUrl']) || empty($cfg['tokenId'])) {
$this->bookstackTestResult = 'error';
$this->bookstackTestMessage = 'Uzupełnij adres instancji i Token ID.';
return;
}
$tokenSecret = $cfg['tokenSecret'] ?: Settings::get('bookstack_token_secret');
$result = app(BookStackClient::class)->testConnection($cfg['baseUrl'], $cfg['tokenId'], $tokenSecret ?? '', (bool) $cfg['verifySsl']);
$this->bookstackTestResult = $result['ok'] ? 'ok' : 'error';
$this->bookstackTestMessage = $result['message'];
}
// ===================== MAIL / SMTP CONFIG =====================
public function saveMailConfig(): void

View File

@@ -11,10 +11,13 @@ class Dashboard extends Component
{
public string $tab = 'current';
public string $search = '';
#[Computed]
public function tickets()
{
return Auth::user()->ticketsAsCustomer()
->search($this->search)
->with('subcategory.category')
->orderByDesc('updated_at')
->get();

View File

@@ -4,6 +4,7 @@ namespace App\Livewire\Client;
use App\Models\Category;
use App\Models\Subcategory;
use App\Services\BookStackClient;
use App\Services\TicketService;
use App\Support\Settings;
use Illuminate\Support\Facades\Auth;
@@ -60,6 +61,17 @@ class NewTicket extends Component
$this->step = 3;
}
/**
* @return array<int, array{name: string, url: ?string}>
*/
#[Computed]
public function suggestedArticles(): array
{
$query = trim(($this->selectedCategory?->name ?? '').' '.($this->selectedSubcategory?->name ?? ''));
return app(BookStackClient::class)->search($query);
}
public function backToCategory(): void
{
$this->step = 1;

View File

@@ -27,6 +27,10 @@ class TicketShow extends Component
public ?int $pendingDeleteMessageId = null;
public ?int $csatRating = null;
public string $csatComment = '';
public function mount(Ticket $ticket): void
{
abort_unless($ticket->customer_id === Auth::id(), 403);
@@ -86,6 +90,14 @@ class TicketShow extends Component
$this->ticket->refresh();
}
public function submitCsat(): void
{
$this->validate(['csatRating' => 'required|integer|between:1,5']);
app(TicketService::class)->submitCsat($this->ticket, $this->csatRating, $this->csatComment ?: null);
$this->ticket->refresh();
}
public function startEdit(int $messageId, string $body): void
{
$message = TicketMessage::query()->findOrFail($messageId);

View File

@@ -6,6 +6,7 @@ use App\Models\Category;
use App\Models\Subcategory;
use App\Models\Ticket;
use App\Models\User;
use App\Services\BookStackClient;
use App\Services\LdapUserProvisioner;
use App\Services\TicketService;
use App\Support\Settings;
@@ -72,6 +73,27 @@ class Landing extends Component
$this->step = 3;
}
/**
* Unlike the logged-in Client/Operator wizards, this guest-facing form
* only shows suggestions when the admin has explicitly opted into
* exposing them to anonymous visitors (bookstack_show_to_guests)
* suggested KB article titles/links could otherwise leak internal
* content to the public.
*
* @return array<int, array{name: string, url: ?string}>
*/
#[Computed]
public function suggestedArticles(): array
{
if (! Settings::bool('bookstack_show_to_guests')) {
return [];
}
$query = trim(($this->selectedCategory?->name ?? '').' '.($this->selectedSubcategory?->name ?? ''));
return app(BookStackClient::class)->search($query);
}
public function backToCategory(): void
{
$this->step = 1;

View File

@@ -0,0 +1,39 @@
<?php
namespace App\Livewire;
use Illuminate\Support\Facades\Auth;
use Livewire\Attributes\Computed;
use Livewire\Component;
class NotificationBell extends Component
{
#[Computed]
public function notifications()
{
return Auth::user()->notifications()->latest()->limit(20)->get();
}
#[Computed]
public function unreadCount(): int
{
return Auth::user()->unreadNotifications()->count();
}
public function markAsRead(string $id): void
{
Auth::user()->notifications()->where('id', $id)->first()?->markAsRead();
unset($this->notifications, $this->unreadCount);
}
public function markAllAsRead(): void
{
Auth::user()->unreadNotifications->each->markAsRead();
unset($this->notifications, $this->unreadCount);
}
public function render()
{
return view('livewire.notification-bell');
}
}

View File

@@ -5,6 +5,7 @@ namespace App\Livewire\Operator;
use App\Models\Category;
use App\Models\Subcategory;
use App\Models\User;
use App\Services\BookStackClient;
use App\Services\TicketService;
use App\Support\Settings;
use Illuminate\Support\Facades\Auth;
@@ -69,6 +70,17 @@ class NewTicket extends Component
$this->step = 3;
}
/**
* @return array<int, array{name: string, url: ?string}>
*/
#[Computed]
public function suggestedArticles(): array
{
$query = trim(($this->selectedCategory?->name ?? '').' '.($this->selectedSubcategory?->name ?? ''));
return app(BookStackClient::class)->search($query);
}
public function backToCategory(): void
{
$this->step = 1;

View File

@@ -41,6 +41,125 @@ class Queue extends Component
public bool $pendingDeleteSelected = false;
#[Url]
public ?int $savedViewId = null;
public string $newViewName = '';
/**
* A bare visit (no explicit ?savedViewId=... in the URL, i.e. Livewire
* never bound one) auto-applies the operator's default saved view, if
* they have one an explicit savedViewId in the URL always wins.
*/
public function mount(): void
{
if ($this->savedViewId !== null) {
return;
}
$default = Auth::user()->savedQueueViews()->where('is_default', true)->first();
if ($default) {
$this->applyViewFilters($default->filters);
$this->savedViewId = $default->id;
}
}
#[Computed]
public function savedViews()
{
return Auth::user()->savedQueueViews()->orderBy('name')->get();
}
/**
* @return array<string, mixed>
*/
protected function snapshotFilters(): array
{
return [
'queue' => $this->queue,
'filterStatus' => $this->filterStatus,
'filterPriority' => $this->filterPriority,
'filterCategory' => $this->filterCategory,
'search' => $this->search,
'sortBy' => $this->sortBy,
'sortDir' => $this->sortDir,
'visibleColumns' => $this->visibleColumns,
];
}
protected function applyViewFilters(array $filters): void
{
$this->queue = $filters['queue'] ?? $this->queue;
$this->filterStatus = $filters['filterStatus'] ?? $this->filterStatus;
$this->filterPriority = $filters['filterPriority'] ?? $this->filterPriority;
$this->filterCategory = $filters['filterCategory'] ?? $this->filterCategory;
$this->search = $filters['search'] ?? $this->search;
$this->sortBy = $filters['sortBy'] ?? $this->sortBy;
$this->sortDir = $filters['sortDir'] ?? $this->sortDir;
$this->visibleColumns = $filters['visibleColumns'] ?? $this->visibleColumns;
$this->selectedIds = [];
}
public function saveCurrentView(): void
{
$name = trim($this->newViewName);
if ($name === '') {
return;
}
$view = Auth::user()->savedQueueViews()->create([
'name' => $name,
'filters' => $this->snapshotFilters(),
]);
$this->savedViewId = $view->id;
$this->newViewName = '';
unset($this->savedViews);
}
/**
* Always scoped to the current user (never a bare SavedQueueView::find())
* savedViewId/id args here are client-controllable, same defensive
* pattern as selectedIdsInScope() for bulk ticket actions.
*/
public function applySavedView(int $id): void
{
$view = Auth::user()->savedQueueViews()->find($id);
if (! $view) {
return;
}
$this->applyViewFilters($view->filters);
$this->savedViewId = $view->id;
}
public function deleteSavedView(int $id): void
{
Auth::user()->savedQueueViews()->where('id', $id)->delete();
if ($this->savedViewId === $id) {
$this->savedViewId = null;
}
unset($this->savedViews);
}
public function setDefaultView(int $id): void
{
$view = Auth::user()->savedQueueViews()->find($id);
if (! $view) {
return;
}
Auth::user()->savedQueueViews()->where('id', '!=', $id)->update(['is_default' => false]);
$view->update(['is_default' => true]);
unset($this->savedViews);
}
#[Computed]
public function statuses()
{
@@ -55,9 +174,9 @@ class Queue extends Component
#[Computed]
public function filterableStatuses()
{
return $this->queue === 'all'
? $this->statuses->reject(fn (Status $s) => $s->stage === 'closed')
: $this->statuses;
return $this->queue === 'closed'
? $this->statuses
: $this->statuses->reject(fn (Status $s) => $s->stage === 'closed');
}
#[Computed]
@@ -101,15 +220,15 @@ class Queue extends Component
$defs = [
'all' => ['label' => 'Otwarte', 'icon' => 'inbox', 'group' => 'Przegląd', 'filter' => fn ($q) => $q->whereNotIn('status_key', $closedKeys)],
'mine' => ['label' => 'Moje zgłoszenia', 'icon' => 'assignment_ind', 'group' => 'Przegląd', 'filter' => fn ($q) => $q->where('assignee_id', Auth::id())],
'unassigned' => ['label' => 'Nieprzypisane', 'icon' => 'person_off', 'group' => 'Przegląd', 'filter' => fn ($q) => $q->whereNull('assignee_id')],
'mine' => ['label' => 'Moje zgłoszenia', 'icon' => 'assignment_ind', 'group' => 'Przegląd', 'filter' => fn ($q) => $q->where('assignee_id', Auth::id())->whereNotIn('status_key', $closedKeys)],
'unassigned' => ['label' => 'Nieprzypisane', 'icon' => 'person_off', 'group' => 'Przegląd', 'filter' => fn ($q) => $q->whereNull('assignee_id')->whereNotIn('status_key', $closedKeys)],
'closed' => ['label' => 'Zamknięte', 'icon' => 'archive', 'group' => 'Przegląd', 'filter' => fn ($q) => $q->whereIn('status_key', $closedKeys)],
];
foreach ($this->teams as $team) {
$defs['team:'.$team->id] = [
'label' => $team->name, 'icon' => 'groups', 'group' => 'Zespoły',
'filter' => fn ($q) => $q->where('team_id', $team->id),
'filter' => fn ($q) => $q->where('team_id', $team->id)->whereNotIn('status_key', $closedKeys),
];
}
@@ -155,11 +274,7 @@ class Queue extends Component
$query->where('customer_id', $this->filterCustomerId);
}
if (trim($this->search) !== '') {
$term = '%'.trim($this->search).'%';
$query->where(fn ($q) => $q->where('number', 'like', $term)
->orWhere('subject', 'like', $term)
->orWhere('name', 'like', $term)
->orWhere('email', 'like', $term));
$query->search($this->search);
}
$tickets = $query->with(['subcategory.category', 'assignee', 'priority', 'status'])->get();
@@ -251,7 +366,11 @@ class Queue extends Component
$this->queue = $key;
$this->selectedIds = [];
if ($key === 'all' && $this->filterStatus !== 'all' && Status::stageFor($this->filterStatus) === 'closed') {
// Every tab except "closed" now excludes closed-stage tickets (see
// queueDefs()), so a stale closed-stage status filter would silently
// zero out the list on any other tab — clear it on every tab switch
// away from "closed", not just when landing on "all".
if ($key !== 'closed' && $this->filterStatus !== 'all' && Status::stageFor($this->filterStatus) === 'closed') {
$this->filterStatus = 'all';
}
}

View File

@@ -15,6 +15,7 @@ use Illuminate\Support\Facades\DB;
use Livewire\Attributes\Computed;
use Livewire\Attributes\Url;
use Livewire\Component;
use Symfony\Component\HttpFoundation\StreamedResponse;
class Stats extends Component
{
@@ -152,6 +153,23 @@ class Stats extends Component
'avgFirstResponseHours' => $this->avgFirstResponseHours(),
'avgResolutionHours' => $this->avgResolutionHours($closedKeys),
'sla' => $this->slaBreachStats($closedKeys),
'csat' => $this->csatStats($closedKeys),
];
}
/**
* Response rate is against closed tickets (the only ones that can ever
* be rated see Ticket::csatSubmittable()), not the whole filtered set.
*/
protected function csatStats(array $closedKeys): array
{
$closedTotal = (clone $this->baseQuery)->whereIn('tickets.status_key', $closedKeys)->count();
$rated = (clone $this->baseQuery)->whereNotNull('csat_rating')->get(['csat_rating']);
return [
'avg' => $rated->isEmpty() ? null : round($rated->avg('csat_rating'), 2),
'count' => $rated->count(),
'responseRate' => $closedTotal > 0 ? round($rated->count() / $closedTotal * 100, 1) : null,
];
}
@@ -387,6 +405,40 @@ class Stats extends Component
$this->range = $range;
}
/**
* Row-per-ticket CSV of everything the active filters/date range
* currently show streamed directly, no temp file, no new dependency.
*/
public function export(): StreamedResponse
{
$tickets = (clone $this->baseQuery)
->with(['subcategory.category', 'assignee', 'team', 'status', 'priority'])
->orderBy('tickets.created_at')
->get();
return response()->streamDownload(function () use ($tickets) {
$out = fopen('php://output', 'w');
fputcsv($out, ['Numer', 'Temat', 'Status', 'Priorytet', 'Kategoria', 'Zespół', 'Operator', 'Utworzono', 'Zaktualizowano', 'Ocena CSAT'], escape: '\\');
foreach ($tickets as $ticket) {
fputcsv($out, [
$ticket->number,
$ticket->subject,
$ticket->statusLabel(),
$ticket->priorityLabel(),
$ticket->categoryLabel(),
$ticket->team?->name,
$ticket->assignee?->name,
$ticket->created_at,
$ticket->updated_at,
$ticket->csat_rating,
], escape: '\\');
}
fclose($out);
}, 'statystyki-'.now()->format('Y-m-d').'.csv');
}
public function render()
{
return view('livewire.operator.stats');

View File

@@ -12,6 +12,7 @@ use App\Models\Team;
use App\Models\Ticket;
use App\Models\TicketMessage;
use App\Models\User;
use App\Services\BookStackClient;
use App\Services\TicketService;
use App\Support\Settings;
use Illuminate\Support\Facades\Auth;
@@ -185,6 +186,18 @@ class TicketShow extends Component
return Category::query()->with('subcategories')->get();
}
/**
* @return array<int, array{name: string, url: ?string, type: string, book: ?string, shelf: ?string}>
*/
#[Computed]
public function suggestedArticles(): array
{
$subcategory = $this->ticket->subcategory;
$query = trim(($subcategory?->category?->name ?? '').' '.($subcategory?->name ?? ''));
return app(BookStackClient::class)->search($query, 5, BookStackClient::CONTEXT_TICKET_VIEW);
}
/**
* A non-admin operator can only reassign a ticket to one of their own
* teams (mirrors the visibility scoping in Operator\Queue).

View File

@@ -0,0 +1,24 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
#[Fillable(['user_id', 'name', 'filters', 'is_default'])]
class SavedQueueView extends Model
{
protected function casts(): array
{
return [
'filters' => 'array',
'is_default' => 'boolean',
];
}
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}

View File

@@ -8,11 +8,13 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
#[Fillable([
'number', 'customer_id', 'email', 'name', 'subcategory_id', 'subject', 'body',
'status_key', 'priority_key', 'team_id', 'assignee_id', 'custom_fields', 'api_client_id',
'sla_notified_at', 'time_spent_seconds', 'timer_started_at', 'created_at', 'updated_at',
'csat_rating', 'csat_comment', 'csat_rated_at',
])]
class Ticket extends Model
{
@@ -23,6 +25,8 @@ class Ticket extends Model
'sla_notified_at' => 'datetime',
'time_spent_seconds' => 'integer',
'timer_started_at' => 'datetime',
'csat_rating' => 'integer',
'csat_rated_at' => 'datetime',
];
}
@@ -129,6 +133,46 @@ class Ticket extends Model
|| $this->assignee_id === $user->id;
}
/**
* Matches ticket number/subject/name/email plus subject/body and reply
* body text. Uses MySQL FULLTEXT (natural-language mode) on MySQL/MariaDB
* matching the indexes added in the 2026_07_22_000141 migration and
* falls back to plain LIKE on sqlite (used by the test suite), which has
* no FULLTEXT equivalent.
*/
public function scopeSearch(Builder $query, string $term): Builder
{
$term = trim($term);
if ($term === '') {
return $query;
}
$mysql = DB::connection()->getDriverName() === 'mysql';
$like = '%'.$term.'%';
$messageTicketIds = DB::table('ticket_messages')
->when(
$mysql,
fn ($q) => $q->whereFullText('body', $term),
fn ($q) => $q->where('body', 'like', $like),
)
->pluck('ticket_id');
return $query->where(function (Builder $q) use ($term, $like, $mysql, $messageTicketIds) {
if ($mysql) {
$q->whereFullText(['subject', 'body'], $term);
} else {
$q->where('subject', 'like', $like)->orWhere('body', 'like', $like);
}
$q->orWhere('number', 'like', $like)
->orWhere('name', 'like', $like)
->orWhere('email', 'like', $like)
->orWhereIn('id', $messageTicketIds);
});
}
public function addHistory(string $text): TicketHistory
{
return $this->histories()->create(['text' => $text, 'created_at' => now()]);
@@ -166,6 +210,21 @@ class Ticket extends Model
return Status::stageFor($this->status_key) === 'closed';
}
public function hasCsatRating(): bool
{
return $this->csat_rating !== null;
}
/**
* A client can rate a ticket once it's closed, and only until they do
* there's no "change your rating" flow, mirroring how e.g. edit-message
* doesn't apply once the underlying thing is done.
*/
public function csatSubmittable(): bool
{
return $this->isClosed() && ! $this->hasCsatRating();
}
/**
* A resolution time of 0 minutes means "no SLA" for that priority, not
* "due instantly" such tickets never count down and never breach.

View File

@@ -189,6 +189,11 @@ class User extends Authenticatable implements LdapAuthenticatable
return $this->hasMany(Ticket::class, 'assignee_id');
}
public function savedQueueViews(): HasMany
{
return $this->hasMany(SavedQueueView::class);
}
/**
* The admin-defined "user field" values, stored one row per field in
* user_field_values see the custom_field_values virtual attribute

View File

@@ -6,6 +6,7 @@ use App\Models\EmailTemplate;
use App\Models\Ticket;
use App\Support\Settings;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\AnonymousNotifiable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
@@ -13,11 +14,39 @@ class TicketNotification extends Notification
{
use Queueable;
public function __construct(protected Ticket $ticket, protected int $emailTemplateId) {}
/**
* $recipientRole is which area the notified person is being addressed in
* ('client' or 'operator', mirrors NotificationSetting::$recipient) a
* user can hold both roles at once, so this can't be inferred from the
* notifiable itself; it decides which ticket URL (client vs operator
* area) both the e-mail link and the in-app notification point to.
*/
public function __construct(protected Ticket $ticket, protected int $emailTemplateId, protected string $recipientRole = 'client') {}
/**
* A guest customer with no account is routed anonymously (see
* TicketService::notify()) and can only ever receive mail the
* "database" channel needs a real notifiable model to attach the row to.
*/
public function via(object $notifiable): array
{
return ['mail'];
return $notifiable instanceof AnonymousNotifiable ? ['mail'] : ['mail', 'database'];
}
protected function ticketUrl(): string
{
return route($this->recipientRole === 'operator' ? 'operator.ticket' : 'client.ticket', $this->ticket);
}
public function toDatabase(object $notifiable): array
{
return [
'ticket_id' => $this->ticket->id,
'number' => $this->ticket->number,
'subject' => $this->ticket->subject,
'message' => 'Zgłoszenie #'.$this->ticket->number.' — '.$this->ticket->subject,
'url' => $this->ticketUrl(),
];
}
public function toMail(object $notifiable): MailMessage
@@ -35,7 +64,8 @@ class TicketNotification extends Notification
'priorytet' => $this->ticket->priorityLabel(),
'zespol' => $this->ticket->team?->name ?? 'Brak',
'operator' => $this->ticket->assignee?->name ?? 'Nieprzypisane',
'link' => route('client.ticket', $this->ticket),
'link' => $this->ticketUrl(),
'ocena' => route('client.ticket', $this->ticket).'#csat',
]) ?? [
'subject' => 'Zgłoszenie #'.$this->ticket->number,
'body' => $this->ticket->subject,

View File

@@ -3,6 +3,7 @@
namespace App\Providers;
use App\Models\ApiClient;
use App\Models\User;
use App\Support\Settings;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Database\Eloquent\Relations\Relation;
@@ -35,7 +36,9 @@ class AppServiceProvider extends ServiceProvider
$this->applyTimezoneSettingsOverride();
$this->configureApiRateLimiting();
Relation::enforceMorphMap(['api_client' => ApiClient::class]);
// 'user' backs the polymorphic notifiable_type column on the
// database-notifications table (in-app notification bell).
Relation::enforceMorphMap(['api_client' => ApiClient::class, 'user' => User::class]);
}
/**

View File

@@ -0,0 +1,279 @@
<?php
namespace App\Services;
use App\Support\Settings;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Http;
class BookStackClient
{
/**
* Two independent allow-lists, since which shelves make sense to
* surface differs by where suggestions show up: 'creation' gates the
* ticket-wizard suggestions (client/operator/guest), 'ticket_view'
* gates the separate sidebar shown to an operator on an existing ticket.
*/
public const CONTEXT_CREATION = 'creation';
public const CONTEXT_TICKET_VIEW = 'ticket_view';
protected const CONTEXT_SETTINGS_KEYS = [
self::CONTEXT_CREATION => 'bookstack_allowed_shelf_ids_creation',
self::CONTEXT_TICKET_VIEW => 'bookstack_allowed_shelf_ids_ticket_view',
];
public function enabled(): bool
{
return Settings::bool('bookstack_enabled')
&& Settings::get('bookstack_base_url')
&& Settings::get('bookstack_token_id');
}
/**
* Suggested-article lookup, shared by the ticket-creation wizard and the
* operator ticket-view sidebar returns [] whenever the integration is
* off/unconfigured, the query is empty, or no shelf has been allow-listed
* yet for the given $context (an empty allow-list means "search nothing",
* not "search everything" an admin has to opt specific shelves in
* before any content is ever suggested, independently per context).
* Cached briefly since the same category/subcategory query repeats
* across every ticket created/viewed with that combination. Respects the
* admin-configured bookstack_search_types setting ('both'|'page'|'book')
* via BookStack's own `{type:x}` query syntax. The cache key folds in the
* allowed-shelf list so changing it in Admin > Konfiguracja is reflected
* immediately, instead of possibly serving a pre-change result for up to
* 10 minutes.
*
* @return array<int, array{name: string, url: ?string, type: string, book: ?string, shelf: ?string}>
*/
public function search(string $query, int $limit = 5, string $context = self::CONTEXT_CREATION): array
{
$query = trim($query);
$allowedShelfIds = $this->allowedShelfIds($context);
if (! $this->enabled() || $query === '' || ! $allowedShelfIds) {
return [];
}
$typeFilter = Settings::get('bookstack_search_types', 'both');
if (in_array($typeFilter, ['page', 'book'], true)) {
$query .= " {type:{$typeFilter}}";
}
$cacheKey = 'bookstack:search:'.md5($query.'|'.$limit.'|'.implode(',', $allowedShelfIds));
return Cache::remember($cacheKey, now()->addMinutes(10), function () use ($query, $limit, $allowedShelfIds) {
try {
$response = $this->client()->get('/api/search', ['query' => $query, 'count' => $limit]);
if (! $response->successful()) {
return [];
}
$shelfMap = $this->shelfBookMap();
$allowedBookIds = $this->bookIdsForShelves($shelfMap, $allowedShelfIds);
$bookShelfNames = $this->bookShelfNames($shelfMap);
return collect($response->json('data', []))
->filter(function (array $item) use ($allowedShelfIds, $allowedBookIds) {
$type = $item['type'] ?? null;
if ($type === 'bookshelf') {
return in_array($item['id'] ?? null, $allowedShelfIds, true);
}
if ($type === 'book') {
return in_array($item['id'] ?? null, $allowedBookIds, true);
}
// pages/chapters carry the id of the book they live in
return isset($item['book_id']) && in_array($item['book_id'], $allowedBookIds, true);
})
->map(function (array $item) use ($bookShelfNames) {
$bookId = $item['book_id'] ?? (($item['type'] ?? null) === 'book' ? $item['id'] : null);
return [
'name' => $item['name'] ?? '',
'url' => $item['url'] ?? null,
'type' => $item['type'] ?? 'page',
'book' => $item['book']['name'] ?? null,
'shelf' => $bookId ? ($bookShelfNames[$bookId] ?? null) : null,
];
})
->filter(fn (array $item) => $item['name'] !== '')
->values()
->all();
} catch (\Throwable) {
return [];
}
});
}
/**
* Drops the cached shelf list and shelf>book membership map used by
* the admin's "Odśwież listę półek" button so a shelf renamed/added/
* removed in BookStack shows up immediately instead of after up to 30
* minutes. Doesn't touch the per-query search-result cache (10 min TTL,
* self-invalidates on the next config save via the allow-list in its key).
*/
public function clearShelfCache(): void
{
Cache::forget('bookstack:shelves');
Cache::forget('bookstack:shelf-book-map');
}
/**
* Bookshelves for the admin's two "dozwolone półki" checklists cached
* since shelf structure changes rarely and this is fetched on every
* Admin > Konfiguracja page load while the BookStack section is expanded.
*
* @return array<int, array{id: int, name: string}>
*/
public function shelves(): array
{
if (! $this->enabled()) {
return [];
}
return Cache::remember('bookstack:shelves', now()->addMinutes(30), function () {
try {
$response = $this->client()->get('/api/shelves', ['count' => 200]);
if (! $response->successful()) {
return [];
}
return collect($response->json('data', []))
->map(fn (array $s) => ['id' => $s['id'], 'name' => $s['name']])
->values()
->all();
} catch (\Throwable) {
return [];
}
});
}
/**
* @return int[]
*/
protected function allowedShelfIds(string $context): array
{
$key = self::CONTEXT_SETTINGS_KEYS[$context] ?? self::CONTEXT_SETTINGS_KEYS[self::CONTEXT_CREATION];
$raw = Settings::get($key, '');
return collect(explode(',', (string) $raw))
->map(fn ($v) => (int) trim($v))
->filter()
->values()
->all();
}
/**
* Every shelf's book membership, fetched once and cached the single
* source both shelf-exclusion and the "Shelf > Book" breadcrumb are
* derived from, so there's only one place that talks to /api/shelves/{id}.
*
* @return array<int, array{name: string, bookIds: int[]}>
*/
protected function shelfBookMap(): array
{
return Cache::remember('bookstack:shelf-book-map', now()->addMinutes(30), function () {
$map = [];
foreach ($this->shelves() as $shelf) {
$bookIds = [];
try {
$response = $this->client()->get("/api/shelves/{$shelf['id']}");
if ($response->successful()) {
$bookIds = collect($response->json('books', []))->pluck('id')->all();
}
} catch (\Throwable) {
// Skip an unreachable/deleted shelf rather than failing the whole search.
}
$map[$shelf['id']] = ['name' => $shelf['name'], 'bookIds' => $bookIds];
}
return $map;
});
}
/**
* @param array<int, array{name: string, bookIds: int[]}> $shelfMap
* @param int[] $shelfIds
* @return int[]
*/
protected function bookIdsForShelves(array $shelfMap, array $shelfIds): array
{
$ids = [];
foreach ($shelfIds as $shelfId) {
$ids = [...$ids, ...($shelfMap[$shelfId]['bookIds'] ?? [])];
}
return $ids;
}
/**
* Book id -> owning shelf name, for the suggestion list's breadcrumb. A
* book that sits on more than one shelf just shows whichever is last in
* the map there's no single "correct" shelf to prefer in that case.
*
* @param array<int, array{name: string, bookIds: int[]}> $shelfMap
* @return array<int, string>
*/
protected function bookShelfNames(array $shelfMap): array
{
$names = [];
foreach ($shelfMap as $shelf) {
foreach ($shelf['bookIds'] as $bookId) {
$names[$bookId] = $shelf['name'];
}
}
return $names;
}
/**
* Tests unsaved admin-form values directly, rather than whatever's
* currently stored mirrors testLdapConnection()/testMailConnection()
* in Admin\Panel. Returns a message alongside the ok/error flag (BookStack's
* API returns a specific, useful reason e.g. missing "Access System API"
* role permission that a plain boolean would hide from the admin.
*
* @return array{ok: bool, message: ?string}
*/
public function testConnection(string $baseUrl, string $tokenId, string $tokenSecret, bool $verifySsl = true): array
{
try {
$response = Http::withHeaders(['Authorization' => "Token {$tokenId}:{$tokenSecret}"])
->withOptions(['verify' => $verifySsl])
->timeout(6)
->get(rtrim($baseUrl, '/').'/api/search', ['query' => 'test', 'count' => 1]);
if ($response->successful()) {
return ['ok' => true, 'message' => null];
}
return ['ok' => false, 'message' => $response->json('error.message') ?? ('HTTP '.$response->status())];
} catch (\Throwable $e) {
return ['ok' => false, 'message' => $e->getMessage()];
}
}
protected function client()
{
$tokenId = Settings::get('bookstack_token_id');
$tokenSecret = Settings::get('bookstack_token_secret');
return Http::withHeaders(['Authorization' => "Token {$tokenId}:{$tokenSecret}"])
->withOptions(['verify' => Settings::bool('bookstack_verify_ssl')])
->timeout(4)
->baseUrl(rtrim(Settings::get('bookstack_base_url'), '/'));
}
}

View File

@@ -78,7 +78,9 @@ class TicketService
// A transition to "closed" fires its own dedicated notification
// instead of the generic status-changed one, so closing a ticket
// doesn't send the customer/operator two emails for one event.
if ($statusKey === 'closed') {
// Checked via the status's stage (not the literal key) since admins
// can rename/replace which key maps to the "closed" stage.
if (Status::stageFor($statusKey) === 'closed') {
$this->notify($ticket, 'ticket_closed');
// Time tracking only applies to open work — checkpoint and pause
@@ -90,6 +92,22 @@ class TicketService
}
}
public function submitCsat(Ticket $ticket, int $rating, ?string $comment = null): void
{
if (! $ticket->csatSubmittable()) {
return;
}
$rating = max(1, min(5, $rating));
$ticket->update([
'csat_rating' => $rating,
'csat_comment' => $comment,
'csat_rated_at' => now(),
]);
$ticket->addHistory('Klient ocenił obsługę: '.$rating.'/5');
}
public function setPriority(Ticket $ticket, string $priorityKey): void
{
$ticket->update(['priority_key' => $priorityKey]);
@@ -276,6 +294,12 @@ class TicketService
/**
* Public so the scheduled SLA-breach check (which isn't a ticket lifecycle
* event raised from within this service) can trigger the same way.
*
* Routes through the recipient's own User model (so it lands in the
* in-app notification bell in addition to e-mail) whenever one exists;
* falls back to an anonymous mail-only route for a guest customer with
* no account. One shared NotificationSetting.enabled flag gates both
* channels there's no separate in-app on/off switch.
*/
public function notify(Ticket $ticket, string $triggerKey): void
{
@@ -285,6 +309,14 @@ class TicketService
return;
}
$notifiable = $setting->recipient === 'operator' ? $ticket->assignee : $ticket->customer;
if ($notifiable) {
$notifiable->notify(new TicketNotification($ticket, $setting->email_template_id, $setting->recipient));
return;
}
$email = $setting->recipient === 'operator' ? $ticket->assignee?->email : $ticket->email;
if (! $email) {
@@ -292,6 +324,6 @@ class TicketService
}
Notification::route('mail', $email)
->notify(new TicketNotification($ticket, $setting->email_template_id));
->notify(new TicketNotification($ticket, $setting->email_template_id, $setting->recipient));
}
}

View File

@@ -39,6 +39,15 @@ class Settings
'mail_smtp_encryption' => 'tls',
'mail_from_address' => '',
'mail_from_name' => '',
'bookstack_enabled' => '0',
'bookstack_base_url' => '',
'bookstack_token_id' => '',
'bookstack_token_secret' => '',
'bookstack_verify_ssl' => '1',
'bookstack_show_to_guests' => '0',
'bookstack_search_types' => 'both',
'bookstack_allowed_shelf_ids_creation' => '',
'bookstack_allowed_shelf_ids_ticket_view' => '',
'email_footer' => '<p>Ta wiadomość została wygenerowana automatycznie przez system {firma} — prosimy na nią nie odpowiadać.</p>',
'accent_color' => '#7c6fd6',
'login_notice_type' => 'info',
@@ -51,7 +60,7 @@ class Settings
.'</div>',
];
protected static array $encrypted = ['ldap_bind_password', 'mail_smtp_password'];
protected static array $encrypted = ['ldap_bind_password', 'mail_smtp_password', 'bookstack_token_secret'];
public static function get(string $key, ?string $default = null): ?string
{

View File

@@ -27,6 +27,18 @@ return [
'author_contact' => env('AUTHOR_CONTACT'),
/*
|--------------------------------------------------------------------------
| Version
|--------------------------------------------------------------------------
|
| Shown on the Admin > About tab. Not a framework setting set VERSION in
| .env, bump it alongside the CHANGELOG.md entry/git tag on each release.
|
*/
'version' => env('VERSION'),
/*
|--------------------------------------------------------------------------
| Application Environment

View File

@@ -0,0 +1,25 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('notifications', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('type');
$table->morphs('notifiable');
$table->text('data');
$table->timestamp('read_at')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('notifications');
}
};

View File

@@ -0,0 +1,45 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('tickets', function (Blueprint $table) {
$table->unsignedTinyInteger('csat_rating')->nullable()->after('time_spent_seconds');
$table->text('csat_comment')->nullable()->after('csat_rating');
$table->timestamp('csat_rated_at')->nullable()->after('csat_comment');
});
// FULLTEXT indexes power full-text ticket search — MariaDB/MySQL only,
// the sqlite driver used by tests has no equivalent (search falls back
// to LIKE there, see Ticket::scopeSearch()).
if (Schema::getConnection()->getDriverName() === 'mysql') {
Schema::table('tickets', function (Blueprint $table) {
$table->fullText(['subject', 'body']);
});
Schema::table('ticket_messages', function (Blueprint $table) {
$table->fullText('body');
});
}
}
public function down(): void
{
if (Schema::getConnection()->getDriverName() === 'mysql') {
Schema::table('tickets', function (Blueprint $table) {
$table->dropFullText(['subject', 'body']);
});
Schema::table('ticket_messages', function (Blueprint $table) {
$table->dropFullText(['body']);
});
}
Schema::table('tickets', function (Blueprint $table) {
$table->dropColumn(['csat_rating', 'csat_comment', 'csat_rated_at']);
});
}
};

View File

@@ -0,0 +1,25 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('saved_queue_views', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained('users')->cascadeOnDelete();
$table->string('name');
$table->json('filters');
$table->boolean('is_default')->default(false);
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('saved_queue_views');
}
};

View File

@@ -0,0 +1,52 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Appends a "rate our support" CTA to the existing seeded ticket_closed
* e-mail template, matching what a fresh install's seeder now produces
* (see DatabaseSeeder::seedEmailTemplatesAndNotifications()). Guarded by
* a "does it already contain {ocena}" check so re-running (or a fresh
* seed that already has it) is a no-op, and skipped entirely if the
* admin has since customized the template away from the seeded wording.
*/
public function up(): void
{
$template = DB::table('email_templates')->where('key', 'tpl-closed')->first();
if (! $template || str_contains($template->body, '{ocena}')) {
return;
}
$seededBody = '<p>Cześć {imie},</p><p>Twoje zgłoszenie „{temat}” zostało zamknięte. Jeśli temat nie został rozwiązany, odpowiedz na tego maila lub zgłoś sprawę ponownie.</p><p>Podgląd zgłoszenia: <a href="{link}" rel="noopener noreferrer" target="_blank">Kliknij tu</a></p>';
if (! str_starts_with($template->body, $seededBody)) {
return;
}
$csatLink = '<p><a href="{ocena}" rel="noopener noreferrer" target="_blank">Oceń naszą obsługę</a></p>';
$rest = substr($template->body, strlen($seededBody));
DB::table('email_templates')->where('id', $template->id)->update([
'body' => $seededBody.$csatLink.$rest,
'updated_at' => now(),
]);
}
public function down(): void
{
$template = DB::table('email_templates')->where('key', 'tpl-closed')->first();
if (! $template) {
return;
}
DB::table('email_templates')->where('id', $template->id)->update([
'body' => str_replace('<p><a href="{ocena}" rel="noopener noreferrer" target="_blank">Oceń naszą obsługę</a></p>', '', $template->body),
'updated_at' => now(),
]);
}
};

View File

@@ -287,6 +287,7 @@ class DatabaseSeeder extends Seeder
{
$footer = '<p>Pozdrawiamy,<br>Zespół Wsparcia</p>';
$link = '<p>Podgląd zgłoszenia: <a href="{link}" rel="noopener noreferrer" target="_blank">Kliknij tu</a></p>';
$csatLink = '<p><a href="{ocena}" rel="noopener noreferrer" target="_blank">Oceń naszą obsługę</a></p>';
$templates = [
'tpl-new' => [
@@ -322,7 +323,7 @@ class DatabaseSeeder extends Seeder
'tpl-closed' => [
'name' => 'Zgłoszenie zamknięte', 'trigger_label' => 'Status = Zamknięte',
'subject' => 'Zgłoszenie #{numer} zostało zamknięte',
'body' => '<p>Cześć {imie},</p><p>Twoje zgłoszenie „{temat}” zostało zamknięte. Jeśli temat nie został rozwiązany, odpowiedz na tego maila lub zgłoś sprawę ponownie.</p>'.$link.$footer,
'body' => '<p>Cześć {imie},</p><p>Twoje zgłoszenie „{temat}” zostało zamknięte. Jeśli temat nie został rozwiązany, odpowiedz na tego maila lub zgłoś sprawę ponownie.</p>'.$link.$csatLink.$footer,
],
'tpl-reply' => [
'name' => 'Nowa odpowiedź operatora', 'trigger_label' => 'Operator odpowiedział',

View File

@@ -313,9 +313,16 @@ body {
.queue-filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.queue-filters-search { width: 220px; }
.queue-filters-columns { position: relative; margin-left: auto; }
.queue-filters-saved { position: relative; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.spin { display: inline-block; animation: spin 0.8s linear infinite; }
.main-col { flex: 1; min-width: 320px; }
.aside-col { width: 300px; flex: none; }
/* Opt-in wider sidebar (operator ticket view, which also shows BookStack
suggestions) at least 50% wider than the default .aside-col. */
.aside-col-wide { width: 460px; }
.wizard-step { width: 80px; flex: none; }
.wizard-connector { width: 56px; flex: none; }
@@ -339,6 +346,7 @@ body {
.profile-menu-name { display: none; }
.main-col { min-width: 0; }
.aside-col { width: 100%; }
.aside-col-wide { width: 100%; }
.wizard-step { width: 58px; }
.wizard-connector { width: 22px; }
.dialog { padding: 18px; }

View File

@@ -0,0 +1,55 @@
@props(['articles', 'variant' => 'banner', 'title' => 'Może pomogą te artykuły z bazy wiedzy', 'showCopy' => false])
@php
$icons = ['book' => 'menu_book', 'chapter' => 'bookmark', 'bookshelf' => 'library_books', 'page' => 'article'];
$isSidebar = $variant === 'sidebar';
@endphp
@if (count($articles))
<div class="card" style="{{ $isSidebar ? 'padding:16px;gap:8px' : 'padding:14px;gap:10px;background:color-mix(in srgb, var(--color-accent) 6%, transparent);border-color:color-mix(in srgb, var(--color-accent) 25%, var(--color-divider))' }}">
@if ($isSidebar)
<div class="card-kicker">{{ $title }}</div>
@else
<div style="display:flex;align-items:center;gap:6px;font-size:12.5px;font-weight:600">
<span class="material-symbols-outlined" style="font-size:16px">auto_awesome</span>
{{ $title }}
</div>
@endif
<div style="display:flex;flex-direction:column;gap:2px">
@foreach ($articles as $article)
<div
@if ($showCopy) x-data="{ copied: false }" @endif
style="display:flex;gap:6px;align-items:flex-start;padding:8px;border-radius:6px"
onmouseover="this.style.background='color-mix(in srgb, var(--color-accent) 8%, transparent)'"
onmouseout="this.style.background='transparent'"
>
<a
href="{{ $article['url'] }}"
target="_blank"
rel="noopener noreferrer"
style="display:flex;gap:10px;align-items:flex-start;flex:1;min-width:0;text-decoration:none;color:inherit"
>
<span class="material-symbols-outlined" style="font-size:18px;flex:none;margin-top:1px;color:var(--color-accent)">{{ $icons[$article['type']] ?? 'article' }}</span>
<span style="min-width:0;flex:1">
<span style="display:block;font-size:13px;font-weight:500;color:var(--color-accent)">{{ $article['name'] }}</span>
@if (! empty($article['book']) && $article['book'] !== $article['name'])
<span style="display:block;font-size:11px;color:color-mix(in srgb, var(--color-text) 55%, transparent);margin-top:1px">
{{ ! empty($article['shelf']) ? $article['shelf'].' > '.$article['book'] : $article['book'] }}
</span>
@endif
</span>
</a>
@if ($showCopy)
<button
type="button"
class="btn btn-secondary"
style="flex:none;font-size:11px;padding:4px 8px;white-space:nowrap"
x-on:click="navigator.clipboard.writeText(@js($article['url'])); copied = true; setTimeout(() => copied = false, 1500)"
x-text="copied ? 'Skopiowano!' : 'Kopiuj link'"
></button>
@endif
</div>
@endforeach
</div>
</div>
@endif

View File

@@ -1,9 +1,25 @@
@props(['attachment'])
<a
href="{{ \Illuminate\Support\Facades\Storage::disk('public')->url($attachment->path) }}"
target="_blank"
style="display:inline-flex;align-items:center;gap:6px;margin-top:8px;padding:5px 10px;border:1px solid var(--color-divider);border-radius:6px;font-size:12.5px;color:inherit;text-decoration:none;background:color-mix(in srgb, var(--color-text) 5%, transparent)"
>
<span class="material-symbols-outlined" style="font-size:15px">attach_file</span>{{ $attachment->original_name }}
</a>
@php
$url = \Illuminate\Support\Facades\Storage::disk('public')->url($attachment->path);
$isImage = \Illuminate\Support\Str::startsWith($attachment->mime ?? '', 'image/');
@endphp
@if ($isImage)
<a href="{{ $url }}" target="_blank" style="display:block;margin-top:8px">
<img
src="{{ $url }}"
alt="{{ $attachment->original_name }}"
loading="lazy"
style="max-width:220px;max-height:160px;border-radius:8px;border:1px solid var(--color-divider);object-fit:cover;cursor:zoom-in;display:block"
>
</a>
@else
<a
href="{{ $url }}"
target="_blank"
style="display:inline-flex;align-items:center;gap:6px;margin-top:8px;padding:5px 10px;border:1px solid var(--color-divider);border-radius:6px;font-size:12.5px;color:inherit;text-decoration:none;background:color-mix(in srgb, var(--color-text) 5%, transparent)"
>
<span class="material-symbols-outlined" style="font-size:15px">attach_file</span>{{ $attachment->original_name }}
</a>
@endif

View File

@@ -18,5 +18,9 @@
{{ $slot }}
@auth
<livewire:notification-bell />
@endauth
<x-profile-menu />
</div>

View File

@@ -654,6 +654,86 @@ $tabGroups = [
@endif
</form>
<form wire:submit="saveBookstackConfig" class="card" style="padding:20px;gap:14px">
<h4 style="margin:0">Baza wiedzy BookStack</h4>
<span class="text-muted" style="font-size:11.5px;margin-top:-8px">Po włączeniu, podczas tworzenia zgłoszenia klientom i operatorom podpowiadane będą pasujące artykuły z BookStack na podstawie wybranej kategorii/podkategorii.</span>
<label class="radio"><input type="checkbox" wire:model="bookstackConfig.enabled" style="position:static;opacity:1;width:auto;height:auto"><strong>Włącz integrację z BookStack</strong></label>
@if ($bookstackConfig['enabled'])
<div class="field"><label>Adres instancji BookStack</label><input class="input" placeholder="https://wiki.firma.pl" wire:model="bookstackConfig.baseUrl"></div>
<div class="field"><label>Token ID</label><input class="input" wire:model="bookstackConfig.tokenId"></div>
<div class="field"><label>Token Secret</label><input class="input" type="password" placeholder="(bez zmian jeśli puste)" wire:model="bookstackConfig.tokenSecret"></div>
<p class="text-muted" style="font-size:11.5px;margin:-4px 0 0">Token API generuje się w BookStack: Profil &rarr; Ustawienia API. Użytkownik/rola właściciela tokenu musi mieć uprawnienie „Access System API”.</p>
<div class="field"><label>Przeszukuj</label>
<select class="input" style="width:auto" wire:model="bookstackConfig.searchTypes">
<option value="both">Strony i książki</option>
<option value="page">Tylko strony</option>
<option value="book">Tylko książki</option>
</select>
</div>
<div style="display:flex;justify-content:flex-end">
<button type="button" class="btn btn-secondary" style="display:flex;align-items:center;gap:6px;font-size:12.5px" wire:click="refreshBookstackShelves" wire:loading.attr="disabled" wire:target="refreshBookstackShelves">
<span class="material-symbols-outlined" style="font-size:16px" wire:loading.class="spin" wire:target="refreshBookstackShelves">refresh</span>
Odśwież listę półek
</button>
</div>
<div class="field">
<label>Dozwolone półki podpowiedzi przy tworzeniu zgłoszenia</label>
@if (count($this->bookstackShelves))
<div style="display:flex;flex-direction:column;gap:2px;border:1px solid var(--color-divider);border-radius:8px;padding:8px">
@foreach ($this->bookstackShelves as $shelf)
<label style="display:flex;align-items:center;gap:8px;font-size:13px;font-weight:400;padding:4px 6px;border-radius:5px;cursor:pointer">
<input type="checkbox" @checked(in_array($shelf['id'], $bookstackConfig['allowedShelfIdsCreation'])) wire:click="toggleBookstackAllowedShelf('allowedShelfIdsCreation', {{ $shelf['id'] }})">
{{ $shelf['name'] }}
</label>
@endforeach
</div>
@else
<p class="text-muted" style="font-size:11.5px;margin:2px 0 0">Brak półek do wyświetlenia sprawdź, czy połączenie działa (przycisk „Testuj połączenie” niżej), albo zapisz konfigurację, żeby odświeżyć listę.</p>
@endif
<p class="text-muted" style="font-size:11.5px;margin:2px 0 0">Tylko książki/strony z zaznaczonych półek mogą pojawić się jako podpowiedzi podczas tworzenia zgłoszenia (klient, operator, formularz gościa). Jeśli żadna półka nie jest zaznaczona, podpowiedzi się nie pojawią.</p>
</div>
<div class="field">
<label>Dozwolone półki panel operatora przy zgłoszeniu</label>
@if (count($this->bookstackShelves))
<div style="display:flex;flex-direction:column;gap:2px;border:1px solid var(--color-divider);border-radius:8px;padding:8px">
@foreach ($this->bookstackShelves as $shelf)
<label style="display:flex;align-items:center;gap:8px;font-size:13px;font-weight:400;padding:4px 6px;border-radius:5px;cursor:pointer">
<input type="checkbox" @checked(in_array($shelf['id'], $bookstackConfig['allowedShelfIdsTicketView'])) wire:click="toggleBookstackAllowedShelf('allowedShelfIdsTicketView', {{ $shelf['id'] }})">
{{ $shelf['name'] }}
</label>
@endforeach
</div>
@else
<p class="text-muted" style="font-size:11.5px;margin:2px 0 0">Brak półek do wyświetlenia sprawdź, czy połączenie działa (przycisk „Testuj połączenie” niżej), albo zapisz konfigurację, żeby odświeżyć listę.</p>
@endif
<p class="text-muted" style="font-size:11.5px;margin:2px 0 0">Niezależna lista kontroluje, co widzi operator w bocznym panelu po otwarciu istniejącego zgłoszenia (link do artykułu lub przycisk kopiowania linku). Jeśli żadna półka nie jest zaznaczona, panel się nie pokaże.</p>
</div>
<label class="radio"><input type="checkbox" wire:model="bookstackConfig.showToGuests" style="position:static;opacity:1;width:auto;height:auto">Pokazuj podpowiedzi także niezalogowanym (formularz zgłoszenia na stronie głównej)</label>
<span class="text-muted" style="font-size:11.5px;margin-top:-8px">Bez zaznaczenia podpowiedzi widoczne tylko przy tworzeniu zgłoszenia przez zalogowanego klienta lub operatora.</span>
<label class="radio"><input type="checkbox" wire:model="bookstackConfig.verifySsl" style="position:static;opacity:1;width:auto;height:auto">Weryfikuj certyfikat SSL instancji BookStack</label>
<span class="text-muted" style="font-size:11.5px;margin-top:-8px">Wyłącz tylko jeśli instancja BookStack korzysta z certyfikatu self-signed / z prywatnego CA.</span>
<div style="display:flex;gap:10px;margin-top:8px;align-items:center;flex-wrap:wrap">
<button type="button" class="btn btn-secondary" wire:click="testBookstackConnection">Testuj połączenie</button>
<button type="submit" class="btn btn-primary">Zapisz</button>
@if ($bookstackTestResult === 'ok')
<div style="display:flex;align-items:center;gap:6px;color:var(--color-success)"><span class="material-symbols-outlined" style="font-size:18px">check_circle</span>Połączenie OK</div>
@elseif ($bookstackTestResult === 'error')
<div style="display:flex;align-items:center;gap:6px;color:var(--color-danger)"><span class="material-symbols-outlined" style="font-size:18px">error</span>Błąd połączenia{{ $bookstackTestMessage ? ': '.$bookstackTestMessage : '' }}</div>
@endif
</div>
@else
<button type="submit" class="btn btn-primary" style="align-self:flex-start">Zapisz</button>
@endif
</form>
</div>
@endif
@@ -667,7 +747,7 @@ $tabGroups = [
<h3 style="margin:0 0 14px">O aplikacji</h3>
<div class="card" style="padding:18px;gap:10px;max-width:420px">
<div style="display:flex;justify-content:space-between"><span class="text-muted">Aplikacja</span><span>{{ \App\Support\Settings::get('company_name') }}</span></div>
<div style="display:flex;justify-content:space-between"><span class="text-muted">Wersja</span><span>1.0.0</span></div>
<div style="display:flex;justify-content:space-between"><span class="text-muted">Wersja</span><span>{{ config('app.version') ?: '—' }}</span></div>
<div style="display:flex;justify-content:space-between"><span class="text-muted">Kontakt wsparcia</span><span>{{ config('app.author_contact') ?: '—' }}</span></div>
</div>
@endif

View File

@@ -7,9 +7,12 @@
<a href="{{ route('client.new') }}" wire:navigate class="btn btn-primary">+ Nowe zgłoszenie</a>
</div>
<div class="seg" style="align-self:flex-start">
<label class="seg-opt"><input type="radio" name="ctab" @checked($tab === 'current') wire:click="setTab('current')">Aktualne ({{ $this->currentTickets->count() }})</label>
<label class="seg-opt"><input type="radio" name="ctab" @checked($tab === 'archive') wire:click="setTab('archive')">Archiwalne ({{ $this->archiveTickets->count() }})</label>
<div style="display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap">
<div class="seg">
<label class="seg-opt"><input type="radio" name="ctab" @checked($tab === 'current') wire:click="setTab('current')">Aktualne ({{ $this->currentTickets->count() }})</label>
<label class="seg-opt"><input type="radio" name="ctab" @checked($tab === 'archive') wire:click="setTab('archive')">Archiwalne ({{ $this->archiveTickets->count() }})</label>
</div>
<input class="input" type="search" placeholder="Szukaj po numerze, temacie, treści…" wire:model.live.debounce.400ms="search" style="max-width:280px">
</div>
<div style="display:flex;flex-direction:column;gap:10px">

View File

@@ -59,6 +59,9 @@
<span class="tag tag-outline">{{ $this->selectedCategory?->name }} / {{ $this->selectedSubcategory?->name }}</span>
<button type="button" class="btn btn-ghost" style="padding:0" wire:click="backToSubcategory">Zmień</button>
</div>
<x-bookstack-suggestions :articles="$this->suggestedArticles" />
<div class="field">
<label>Temat</label>
<input class="input" wire:model="subject">
@@ -76,8 +79,16 @@
<div class="field">
<label>Załączniki</label>
<div style="border:1px dashed var(--color-divider);border-radius:8px;padding:14px;display:flex;flex-wrap:wrap;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="border:1px dashed var(--color-divider);border-radius:8px;padding:14px;display:flex;flex-wrap:wrap;align-items:center;gap:10px"
>
<label class="btn btn-secondary" style="cursor:pointer">Wybierz pliki<input type="file" multiple style="display:none" wire:model="attachments"></label>
<span class="text-muted" style="font-size:12px">lub przeciągnij pliki tutaj</span>
@forelse ($attachments as $i => $file)
<span class="text-muted" style="font-size:13px;display:flex;align-items:center;gap:6px">
{{ $file->getClientOriginalName() }}

View File

@@ -63,7 +63,14 @@
<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 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">
<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">
@@ -99,6 +106,34 @@
<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)

View File

@@ -89,6 +89,9 @@
<span class="tag tag-outline">{{ $this->selectedCategory?->name }} / {{ $this->selectedSubcategory?->name }}</span>
<button type="button" class="btn btn-ghost" style="padding:0" wire:click="backToSubcategory">Zmień</button>
</div>
<x-bookstack-suggestions :articles="$this->suggestedArticles" />
<div class="field">
<label>Temat</label>
<input class="input" placeholder="Krótki opis problemu" wire:model="subject">

View File

@@ -0,0 +1,36 @@
<div x-data="{ open: false }" @click.outside="open = false" style="position:relative;display:inline-block" wire:poll.30s="$refresh">
<button type="button" class="btn btn-secondary" @click="open = !open" style="position:relative;display:flex;align-items:center;gap:0;padding:8px">
<span class="material-symbols-outlined" style="font-size:18px">notifications</span>
@if ($this->unreadCount)
<span style="position:absolute;top:2px;right:2px;min-width:16px;height:16px;padding:0 3px;border-radius:8px;background:var(--color-accent);color:#fff;font-size:10px;line-height:16px;text-align:center">{{ $this->unreadCount > 9 ? '9+' : $this->unreadCount }}</span>
@endif
</button>
<div
x-show="open"
x-cloak
style="position:absolute;top:100%;right:0;margin-top:6px;background:var(--color-surface);border:1px solid var(--color-divider);border-radius:8px;box-shadow:var(--shadow-md);width:320px;max-height:420px;overflow-y:auto;z-index:30"
>
<div style="display:flex;align-items:center;justify-content:space-between;padding:10px 14px;border-bottom:1px solid var(--color-divider)">
<span style="font-size:12.5px;font-weight:600">Powiadomienia</span>
@if ($this->unreadCount)
<button type="button" wire:click="markAllAsRead" style="font-size:11.5px;background:none;border:none;color:var(--color-accent);cursor:pointer;padding:0">Oznacz wszystkie jako przeczytane</button>
@endif
</div>
@forelse ($this->notifications as $notification)
<a
href="{{ $notification->data['url'] ?? '#' }}"
wire:navigate
wire:click="markAsRead('{{ $notification->id }}')"
@click="open = false"
style="display:block;padding:10px 14px;text-decoration:none;color:var(--color-text);border-bottom:1px solid var(--color-divider);font-size:12.5px;{{ $notification->read_at ? 'opacity:0.6' : 'background:color-mix(in srgb, var(--color-accent) 6%, transparent)' }}"
>
<div>{{ $notification->data['message'] ?? '' }}</div>
<div style="font-size:11px;color:color-mix(in srgb, var(--color-text) 55%, transparent);margin-top:2px">{{ $notification->created_at->diffForHumans() }}</div>
</a>
@empty
<div style="padding:20px 14px;text-align:center;font-size:12.5px;color:color-mix(in srgb, var(--color-text) 55%, transparent)">Brak powiadomień</div>
@endforelse
</div>
</div>

View File

@@ -65,6 +65,9 @@
<span class="tag tag-outline">{{ $this->selectedCategory?->name }} / {{ $this->selectedSubcategory?->name }}</span>
<button type="button" class="btn btn-ghost" style="padding:0" wire:click="backToSubcategory">Zmień</button>
</div>
<x-bookstack-suggestions :articles="$this->suggestedArticles" />
<div class="field">
<label>Temat</label>
<input class="input" wire:model="subject">
@@ -82,8 +85,16 @@
<div class="field">
<label>Załączniki</label>
<div style="border:1px dashed var(--color-divider);border-radius:8px;padding:14px;display:flex;flex-wrap:wrap;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="border:1px dashed var(--color-divider);border-radius:8px;padding:14px;display:flex;flex-wrap:wrap;align-items:center;gap:10px"
>
<label class="btn btn-secondary" style="cursor:pointer">Wybierz pliki<input type="file" multiple style="display:none" wire:model="attachments"></label>
<span class="text-muted" style="font-size:12px">lub przeciągnij pliki tutaj</span>
@forelse ($attachments as $i => $file)
<span class="text-muted" style="font-size:13px;display:flex;align-items:center;gap:6px">
{{ $file->getClientOriginalName() }}

View File

@@ -74,6 +74,34 @@
@endforeach
</select>
<div class="queue-filters-saved" x-data="{ open: false, adding: false }">
<button type="button" class="btn btn-secondary" @click="open = ! open" style="display:flex;align-items:center;justify-content:center;gap:6px">
<span class="material-symbols-outlined" style="font-size:18px">bookmark</span>
Zapisane widoki
</button>
<div x-show="open" x-cloak @click.outside="open = false; adding = false" style="position:absolute;top:100%;left:0;margin-top:4px;background:var(--color-surface);border:1px solid var(--color-divider);border-radius:8px;box-shadow:var(--shadow-md);z-index:30;padding:6px;min-width:220px">
@forelse ($this->savedViews as $view)
<div style="display:flex;align-items:center;gap:4px;padding:2px 2px 2px 8px;border-radius:5px;{{ $savedViewId === $view->id ? 'background:color-mix(in srgb, var(--color-accent) 12%, transparent)' : '' }}">
<button type="button" wire:click="applySavedView({{ $view->id }})" style="flex:1;min-width:0;text-align:left;background:none;border:none;cursor:pointer;padding:6px 0;font-size:13px;color:{{ $savedViewId === $view->id ? 'var(--color-accent)' : 'inherit' }};overflow:hidden;text-overflow:ellipsis;white-space:nowrap">{{ $view->name }}</button>
<span class="material-symbols-outlined" style="font-size:16px;cursor:pointer;flex:none;opacity:{{ $view->is_default ? '1' : '0.4' }};color:{{ $view->is_default ? 'var(--color-accent)' : 'inherit' }}" title="Ustaw jako domyślny" wire:click="setDefaultView({{ $view->id }})">star</span>
<span class="material-symbols-outlined" style="font-size:16px;cursor:pointer;flex:none;opacity:0.6" title="Usuń" wire:click="deleteSavedView({{ $view->id }})">delete</span>
</div>
@empty
<p class="text-muted" style="font-size:12px;margin:2px 8px">Brak zapisanych widoków.</p>
@endforelse
<div style="border-top:1px solid var(--color-divider);margin:4px 0"></div>
<template x-if="! adding">
<button type="button" class="btn btn-secondary btn-block" @click="adding = true" style="font-size:12.5px">+ Zapisz bieżące filtry…</button>
</template>
<div x-show="adding" style="display:flex;gap:6px;padding:4px 2px">
<input class="input" style="flex:1;font-size:12.5px" placeholder="Nazwa widoku" wire:model="newViewName" @keydown.enter="$wire.saveCurrentView(); adding = false">
<button type="button" class="btn btn-primary" style="flex:none;padding:6px 10px" @click="$wire.saveCurrentView(); adding = false">Zapisz</button>
</div>
</div>
</div>
<div class="queue-filters-columns" x-data="{ open: false }">
<button type="button" class="btn btn-secondary" @click="open = ! open" style="display:flex;align-items:center;justify-content:center;gap:6px">
<span class="material-symbols-outlined" style="font-size:18px">view_column</span>

View File

@@ -52,6 +52,11 @@
<option value="{{ $u->id }}">{{ $u->name }}</option>
@endforeach
</select>
<button type="button" class="btn btn-secondary" style="margin-left:auto;display:flex;align-items:center;gap:6px" wire:click="export">
<span class="material-symbols-outlined" style="font-size:18px">download</span>
Eksportuj CSV
</button>
</div>
{{-- KPI tiles --}}
@@ -85,6 +90,11 @@
</div>
<div class="stat-tile-meta">{{ $kpis['sla']['breached'] }} / {{ $kpis['sla']['total'] }} zgłoszeń</div>
</div>
<div class="stat-tile">
<div class="stat-tile-label">Ocena obsługi (CSAT)</div>
<div class="stat-tile-value">{{ $kpis['csat']['avg'] !== null ? $kpis['csat']['avg'].' / 5' : '—' }}</div>
<div class="stat-tile-meta">{{ $kpis['csat']['count'] }} ocen{{ $kpis['csat']['responseRate'] !== null ? ' · '.$kpis['csat']['responseRate'].'% odpowiedzi' : '' }}</div>
</div>
</div>
<div style="display:grid;grid-template-columns:repeat(auto-fit, minmax(340px, 1fr));gap:16px;align-items:start">

View File

@@ -2,7 +2,7 @@
<x-topbar />
<div class="page-pad" style="flex:1;padding:20px 24px;overflow:auto">
<div style="display:flex;flex-direction:column;gap:16px;max-width:1020px;margin:0 auto">
<div style="display:flex;flex-direction:column;gap:16px;max-width:1180px;margin:0 auto">
<a href="{{ route('operator.queue') }}" 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">
@@ -96,7 +96,14 @@
@if ($addingNote)
<textarea class="input" placeholder="Dodaj notatkę widoczną tylko dla zespołu…" wire:model="noteDraft"></textarea>
<div style="display:flex;align-items:center;gap:10px">
<div 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">
<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="noteAttachments"></label>
@forelse ($noteAttachments as $i => $file)
<span class="text-muted" style="font-size:13px;display:flex;align-items:center;gap:6px;min-width:0">
@@ -160,7 +167,14 @@
</select>
<textarea class="input" placeholder="Napisz odpowiedź do klienta…" wire:model="reply"></textarea>
<div style="display:flex;align-items:center;gap:10px">
<div 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">
<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="replyAttachments"></label>
@forelse ($replyAttachments as $i => $file)
<span class="text-muted" style="font-size:13px;display:flex;align-items:center;gap:6px;min-width:0">
@@ -190,7 +204,7 @@
</form>
</div>
<div class="aside-col" style="display:flex;flex-direction:column;gap:14px">
<div class="aside-col aside-col-wide" style="display:flex;flex-direction:column;gap:14px">
<div class="card" style="padding:16px;gap:6px">
<div style="display:flex;justify-content:space-between;align-items:flex-start;gap:8px">
<div class="card-kicker">Zgłaszający</div>
@@ -272,11 +286,27 @@
</div>
</div>
<x-bookstack-suggestions :articles="$this->suggestedArticles" variant="sidebar" title="Baza wiedzy" :show-copy="true" />
<div class="card" style="padding:16px;gap:8px">
<div class="card-kicker">SLA</div>
<div style="font-size:12.5px">{{ $ticket->slaInfo()['text'] }}</div>
</div>
@if ($ticket->hasCsatRating())
<div class="card" style="padding:16px;gap:8px">
<div class="card-kicker">Ocena obsługi</div>
<div style="display:flex;gap:2px">
@for ($i = 1; $i <= 5; $i++)
<span class="material-symbols-outlined" style="font-size:18px;color:{{ $i <= $ticket->csat_rating ? 'var(--color-accent)' : 'var(--color-divider)' }}">star</span>
@endfor
</div>
@if ($ticket->csat_comment)
<p style="font-size:12.5px;margin:0;white-space:pre-wrap">{{ $ticket->csat_comment }}</p>
@endif
</div>
@endif
<div class="card" style="padding:16px;gap:8px">
<div class="card-kicker">MONITOR CZASU PRACY</div>
<div
@@ -344,16 +374,21 @@
<span>Czas w zgłoszeniu: <strong x-text="format()"></strong></span>
<span class="material-symbols-outlined" style="font-size:16px;cursor:pointer;opacity:0.7" wire:click="startEditTimer">edit</span>
</div>
<div style="display:flex;gap:6px">
@if ($ticket->isClosed())
@if ($ticket->isClosed())
<div style="display:flex;flex-direction:column;gap:6px;align-items:flex-start">
<span style="font-size:12px;opacity:0.7">Zgłoszenie zamknięte zliczanie wstrzymane</span>
@elseif ($ticket->timer_started_at)
<button type="button" class="btn btn-secondary" wire:click="stopTimer" @click="running = false; clearInterval(tick)">Zatrzymaj</button>
@else
<button type="button" class="btn btn-secondary" wire:click="resumeTimer" @click="running = true; start()">Wznów</button>
@endif
<button type="button" class="btn btn-secondary" wire:click="resetTimer" @click="seconds = 0; running = false; clearInterval(tick)">Resetuj</button>
</div>
<button type="button" class="btn btn-secondary" wire:click="resetTimer" @click="seconds = 0; running = false; clearInterval(tick)">Resetuj</button>
</div>
@else
<div style="display:flex;gap:6px">
@if ($ticket->timer_started_at)
<button type="button" class="btn btn-secondary" wire:click="stopTimer" @click="running = false; clearInterval(tick)">Zatrzymaj</button>
@else
<button type="button" class="btn btn-secondary" wire:click="resumeTimer" @click="running = true; start()">Wznów</button>
@endif
<button type="button" class="btn btn-secondary" wire:click="resetTimer" @click="seconds = 0; running = false; clearInterval(tick)">Resetuj</button>
</div>
@endif
@endif
</div>
</div>

View File

@@ -1,6 +1,7 @@
<?php
use App\Livewire\Operator\Queue;
use App\Models\Team;
use Livewire\Livewire;
test('the operator queue has a dedicated tab listing only closed tickets', function () {
@@ -31,34 +32,62 @@ test('the "Otwarte" tab never shows closed tickets', function () {
->assertDontSee($closed->number);
});
test('the "Otwarte" tab does not offer "Zamknięte" as a status filter option', function () {
test('no tab other than "Zamknięte" offers "Zamknięte" as a status filter option', function () {
seedStatusesAndPriorities();
$operator = operatorUser('all-no-closed-filter@example.com');
$operator = operatorUser('no-closed-filter-elsewhere@example.com');
$keys = Livewire::actingAs($operator)->test(Queue::class)
->instance()->filterableStatuses->pluck('key')->all();
foreach (['all', 'mine', 'unassigned'] as $queue) {
$keys = Livewire::actingAs($operator)->test(Queue::class)
->call('setQueue', $queue)
->instance()->filterableStatuses->pluck('key')->all();
expect($keys)->not->toContain('closed');
expect($keys)->not->toContain('closed');
}
});
test('other tabs still offer "Zamknięte" as a status filter option', function () {
test('the "Zamknięte" tab offers "Zamknięte" as a status filter option', function () {
seedStatusesAndPriorities();
$operator = operatorUser('mine-has-closed-filter@example.com');
$operator = operatorUser('closed-tab-has-closed-filter@example.com');
$keys = Livewire::actingAs($operator)->test(Queue::class)
->call('setQueue', 'mine')
->call('setQueue', 'closed')
->instance()->filterableStatuses->pluck('key')->all();
expect($keys)->toContain('closed');
});
test('switching to "Otwarte" resets an active "Zamknięte" status filter, since it would always be empty there', function () {
test('"Moje zgłoszenia", "Nieprzypisane" and team tabs never show closed tickets, only "Zamknięte" does', function () {
seedStatusesAndPriorities();
$team = Team::query()->create(['name' => 'Support']);
$operator = operatorUser('closed-excluded-everywhere@example.com');
$operator->teams()->attach($team->id);
$mine = makeTicket(['number' => '3001', 'status_key' => 'closed', 'assignee_id' => $operator->id]);
$unassigned = makeTicket(['number' => '3002', 'status_key' => 'closed', 'assignee_id' => null]);
$teamTicket = makeTicket(['number' => '3003', 'status_key' => 'closed', 'team_id' => $team->id]);
foreach (['mine', 'unassigned', 'team:'.$team->id] as $queue) {
Livewire::actingAs($operator)->test(Queue::class)
->call('setQueue', $queue)
->assertDontSee($mine->number)
->assertDontSee($unassigned->number)
->assertDontSee($teamTicket->number);
}
Livewire::actingAs($operator)->test(Queue::class)
->call('setQueue', 'closed')
->assertSee($mine->number)
->assertSee($unassigned->number)
->assertSee($teamTicket->number);
});
test('switching away from "Zamknięte" resets an active "Zamknięte" status filter, since it would always be empty elsewhere', function () {
seedStatusesAndPriorities();
$operator = operatorUser('reset-filter@example.com');
Livewire::actingAs($operator)->test(Queue::class)
->call('setQueue', 'closed')
->set('filterStatus', 'closed')
->call('setQueue', 'all')
->call('setQueue', 'mine')
->assertSet('filterStatus', 'all');
});