92 lines
5.1 KiB
PHP
92 lines
5.1 KiB
PHP
<?php
|
||
/**
|
||
* staff/_tickets_list_partial.php
|
||
*
|
||
* Rendert NUR die Ticket-Tabelle (inkl. "X Treffer"-Banner und Pagination), ohne
|
||
* Kopf/Filterleiste/Fußzeile. Wird von staff/tickets.php an zwei Stellen genutzt:
|
||
* 1) normal eingebunden beim vollständigen Seitenaufbau
|
||
* 2) bei ?partial=1 als einziger Output für den Live-Refresh per JS (siehe
|
||
* dortiges <script> weiter unten in tickets.php) – damit die Tabelle alle paar
|
||
* Sekunden ohne Seiten-Reload aktuell bleibt, auch während ein Mitarbeiter
|
||
* gerade auf der Liste ist.
|
||
* Erwartet dieselben Variablen, die tickets.php vor dem Einbinden bereits berechnet
|
||
* hat ($tickets, $ticketTags, $totalPages, $page, $totalCount, $departments, $search,
|
||
* $filterDept/$filterStatus/... sowie $_GET für die Pagination-Links).
|
||
*/
|
||
?>
|
||
<div id="tickets-live-region">
|
||
<form method="post" id="bulk-form-tickets">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="bulk_action" id="bulk_action_tickets" value="">
|
||
|
||
<div class="card">
|
||
<?php if ($search || $filterDept || ($filterStatus && $filterStatus !== '') || $filterPrio || $filterAssign || $filterTag || $filterSpam): ?>
|
||
<div style="padding:8px 12px; margin-bottom:12px; background:var(--primary-lt); border-radius:6px; font-size:.84rem; color:var(--primary-dk); font-weight:500">
|
||
<?= count($tickets) ?> Treffer
|
||
<?php if ($search): ?> für „<?= e($search) ?>"<?php endif; ?>
|
||
<?php if ($filterDept): ?> · Abteilung: <?= e(array_column($departments, 'name', 'id')[$filterDept] ?? '') ?><?php endif; ?>
|
||
· <a href="/staff/tickets.php" style="color:var(--primary-dk)">Filter zurücksetzen</a>
|
||
</div>
|
||
<?php endif; ?>
|
||
<?php if (!$tickets): ?>
|
||
<div class="empty-state">Keine Tickets gefunden.</div>
|
||
<?php else: ?>
|
||
<table>
|
||
<thead><tr>
|
||
<th style="width:24px"><input type="checkbox" onclick="document.querySelectorAll('.ticket-check').forEach(c=>c.checked=this.checked)"></th>
|
||
<th>Ticket</th><th>Betreff</th><th>Abteilung</th><th>Priorität</th><th>Status</th><th>Zugewiesen</th><th>Eingang</th><th>Fällig</th>
|
||
</tr></thead>
|
||
<tbody>
|
||
<?php foreach ($tickets as $t):
|
||
[$label, $color] = status_label($t['status']);
|
||
$isOverdue = $t['resolution_due_at'] && strtotime($t['resolution_due_at']) < time() && !in_array($t['status'], ['resolved','closed']);
|
||
?>
|
||
<tr class="<?= $isOverdue ? 'is-overdue' : '' ?>">
|
||
<td><input type="checkbox" class="ticket-check" name="ticket_ids[]" value="<?= $t['id'] ?>"></td>
|
||
<td><a href="/staff/ticket_view.php?n=<?= urlencode($t['ticket_number']) ?>" class="ticket-no">#<?= e($t['ticket_number']) ?></a></td>
|
||
<td><a href="/staff/ticket_view.php?n=<?= urlencode($t['ticket_number']) ?>"><?= e($t['subject']) ?></a><br>
|
||
<span class="muted" style="font-size:.78rem"><?= e($t['requester_name']) ?></span>
|
||
<span class="muted" style="font-size:.75rem; color:var(--muted-lt)"> · <?= e($t['requester_email']) ?></span>
|
||
<?php if (!empty($ticketTags[$t['id']])): ?>
|
||
<div style="margin-top:4px">
|
||
<?php foreach ($ticketTags[$t['id']] as $tg): ?>
|
||
<span class="badge" style="background:<?= e($tg['color']) ?>; font-size:.7rem"><?= e($tg['name']) ?></span>
|
||
<?php endforeach; ?>
|
||
</div>
|
||
<?php endif; ?>
|
||
</td>
|
||
<td><?= e($t['department_name']) ?></td>
|
||
<td><span class="badge" style="background:<?= e($t['priority_color']) ?>"><?= e($t['priority_name']) ?></span></td>
|
||
<td><span class="badge" style="background:<?= $color ?>"><?= e($label) ?></span></td>
|
||
<td><?= $t['staff_name'] ? e($t['staff_name']) : '<span class="muted">–</span>' ?></td>
|
||
<td class="muted" style="white-space:nowrap" title="Ticket eingegangen"><?= e(format_dt($t['created_at'] ?? null)) ?></td>
|
||
<td class="muted"><?= time_until($t['resolution_due_at']) ?></td>
|
||
</tr>
|
||
<?php endforeach; ?>
|
||
</tbody>
|
||
</table>
|
||
<?php endif; ?>
|
||
</div>
|
||
</form>
|
||
|
||
<?php if ($totalPages > 1): ?>
|
||
<div style="display:flex;justify-content:center;align-items:center;gap:6px;margin-top:20px;flex-wrap:wrap">
|
||
<?php
|
||
$baseUrl = '/staff/tickets.php?' . http_build_query(array_diff_key($_GET, ['page'=>'','partial'=>''])) . '&page=';
|
||
$start = max(1, $page-2);
|
||
$end = min($totalPages, $page+2);
|
||
?>
|
||
<?php if ($page > 1): ?>
|
||
<a href="<?= $baseUrl.($page-1) ?>" class="btn secondary" style="padding:6px 12px">← Zurück</a>
|
||
<?php endif; ?>
|
||
<?php for ($p = $start; $p <= $end; $p++): ?>
|
||
<a href="<?= $baseUrl.$p ?>" class="btn <?= $p===$page?'':'secondary' ?>" style="padding:6px 12px;<?= $p===$page?'font-weight:700':'' ?>"><?= $p ?></a>
|
||
<?php endfor; ?>
|
||
<?php if ($page < $totalPages): ?>
|
||
<a href="<?= $baseUrl.($page+1) ?>" class="btn secondary" style="padding:6px 12px">Weiter →</a>
|
||
<?php endif; ?>
|
||
<span class="muted" style="font-size:.82rem"><?= number_format($totalCount) ?> Tickets gesamt</span>
|
||
</div>
|
||
<?php endif; ?>
|
||
</div>
|