Upload via GUI (258 Dateien)
This commit is contained in:
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../includes/bootstrap.php';
|
||||
$staff = require_staff_login();
|
||||
$pdo = get_db();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
verify_csrf();
|
||||
$action = $_POST['action'] ?? '';
|
||||
|
||||
if ($action === 'rename') {
|
||||
$id = (int)($_POST['id'] ?? 0);
|
||||
$name = trim($_POST['name'] ?? '');
|
||||
if ($id && $name) {
|
||||
$pdo->prepare('UPDATE saved_queues SET name=?, updated_at=? WHERE id=? AND (staff_id=? OR ?=1)')
|
||||
->execute([$name, db_now(), $id, $staff['id'], $staff['role'] === 'admin' ? 1 : 0]);
|
||||
flash('success', 'Queue umbenannt.');
|
||||
}
|
||||
redirect('/staff/queues.php');
|
||||
}
|
||||
|
||||
if ($action === 'delete') {
|
||||
$id = (int)($_POST['id'] ?? 0);
|
||||
if ($id) {
|
||||
$pdo->prepare('DELETE FROM saved_queues WHERE id=? AND (staff_id=? OR ?=1)')
|
||||
->execute([$id, $staff['id'], $staff['role'] === 'admin' ? 1 : 0]);
|
||||
flash('success', 'Queue gelöscht.');
|
||||
}
|
||||
redirect('/staff/queues.php');
|
||||
}
|
||||
|
||||
if ($action === 'reorder') {
|
||||
$ids = array_map('intval', $_POST['ids'] ?? []);
|
||||
foreach ($ids as $i => $id) {
|
||||
$pdo->prepare('UPDATE saved_queues SET sort_order=? WHERE id=? AND staff_id=?')
|
||||
->execute([$i, $id, $staff['id']]);
|
||||
}
|
||||
echo json_encode(['ok' => true]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$queues = queues_for($pdo, (int) $staff['id']);
|
||||
|
||||
$pageTitle = 'Gespeicherte Ansichten';
|
||||
$activePage = 'tickets';
|
||||
require __DIR__ . '/_header.php';
|
||||
?>
|
||||
|
||||
<div class="topbar">
|
||||
<h1>Gespeicherte Ansichten</h1>
|
||||
<a href="/staff/tickets.php" class="btn secondary">← Zur Ticket-Liste</a>
|
||||
</div>
|
||||
|
||||
<?php if (!$queues): ?>
|
||||
<div class="card">
|
||||
<div class="empty-state">
|
||||
<p>Noch keine gespeicherten Ansichten vorhanden.</p>
|
||||
<p class="muted" style="font-size:.85rem">Filter in der <a href="/staff/tickets.php">Ticket-Liste</a> setzen und auf „Ansicht speichern" klicken.</p>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="card">
|
||||
<h3>Meine Ansichten</h3>
|
||||
<p class="muted" style="font-size:.85rem; margin-bottom:16px">Reihenfolge per Drag & Drop ändern. Klick auf den Namen öffnet die Ansicht.</p>
|
||||
<ul id="queue-list" style="list-style:none; padding:0; margin:0; display:flex; flex-direction:column; gap:8px">
|
||||
<?php foreach ($queues as $q):
|
||||
$filters = $q['filters'];
|
||||
$href = '/staff/tickets.php?' . http_build_query(queue_filters_to_web($filters));
|
||||
$summary = [];
|
||||
if (!empty($filters['status'])) $summary[] = 'Status: ' . $filters['status'];
|
||||
if (!empty($filters['assigned'])) $summary[] = 'Zugewiesen: ' . ($filters['assigned'] === 'me' ? 'mir' : ($filters['assigned'] === 'unassigned' ? 'niemand' : 'ID ' . $filters['assigned']));
|
||||
if (!empty($filters['departmentId'])) $summary[] = 'Abteilung: ' . $filters['departmentId'];
|
||||
if (!empty($filters['priorityId'])) $summary[] = 'Priorität: ' . $filters['priorityId'];
|
||||
if (!empty($filters['sla'])) $summary[] = 'SLA: ' . $filters['sla'];
|
||||
if (!empty($filters['q'])) $summary[] = 'Suche: "' . $filters['q'] . '"';
|
||||
?>
|
||||
<li data-id="<?= $q['id'] ?>"
|
||||
style="background:var(--surface); border:1px solid var(--border); border-radius:8px; padding:14px 16px; display:flex; align-items:center; gap:12px; cursor:grab">
|
||||
<span style="color:var(--muted); font-size:1rem; cursor:grab">⠿</span>
|
||||
<div style="flex:1; min-width:0">
|
||||
<div style="display:flex; align-items:center; gap:10px; margin-bottom:4px">
|
||||
<a href="<?= e($href) ?>" style="font-weight:600; font-size:.92rem; color:var(--ink)"><?= e($q['name']) ?></a>
|
||||
<?php if ($q['is_shared']): ?><span class="muted" style="font-size:.75rem">⇄ geteilt<?= $q['mine'] ? '' : ' von ' . e($q['owner_name'] ?? '') ?></span><?php endif; ?>
|
||||
</div>
|
||||
<?php if ($summary): ?>
|
||||
<div class="muted" style="font-size:.78rem"><?= e(implode(' · ', $summary)) ?></div>
|
||||
<?php else: ?>
|
||||
<div class="muted" style="font-size:.78rem">Alle Tickets</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php if (queue_can_edit($q, $staff)): ?>
|
||||
<div style="display:flex; gap:6px; flex-shrink:0">
|
||||
<!-- Umbenennen -->
|
||||
<button onclick="renameQueue(<?= $q['id'] ?>, '<?= e(addslashes($q['name'])) ?>')"
|
||||
class="btn secondary" style="padding:5px 10px; font-size:.78rem">✏️ Umbenennen</button>
|
||||
<!-- Löschen -->
|
||||
<form method="post" onsubmit="return confirm('Ansicht löschen?')" style="margin:0">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="delete">
|
||||
<input type="hidden" name="id" value="<?= $q['id'] ?>">
|
||||
<button type="submit" class="btn secondary"
|
||||
style="padding:5px 10px; font-size:.78rem; border-color:var(--danger); color:var(--danger)">🗑️</button>
|
||||
</form>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Umbenennen Modal -->
|
||||
<div id="rename-modal" style="display:none; position:fixed; inset:0; background:rgba(0,0,0,.5); z-index:9999; align-items:center; justify-content:center">
|
||||
<div style="background:#fff; border-radius:12px; padding:24px; width:100%; max-width:400px; box-shadow:0 8px 32px rgba(0,0,0,.2)">
|
||||
<h3 style="margin:0 0 16px">Ansicht umbenennen</h3>
|
||||
<form method="post" id="rename-form">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="rename">
|
||||
<input type="hidden" name="id" id="rename-id">
|
||||
<label>Name</label>
|
||||
<input type="text" name="name" id="rename-name" required style="margin-bottom:16px">
|
||||
<div class="btn-row">
|
||||
<button type="submit" class="btn">Speichern</button>
|
||||
<button type="button" class="btn secondary" onclick="document.getElementById('rename-modal').style.display='none'">Abbrechen</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function renameQueue(id, currentName) {
|
||||
document.getElementById('rename-id').value = id;
|
||||
document.getElementById('rename-name').value = currentName;
|
||||
document.getElementById('rename-modal').style.display = 'flex';
|
||||
setTimeout(() => document.getElementById('rename-name').focus(), 50);
|
||||
}
|
||||
|
||||
// Drag & Drop Reihenfolge
|
||||
(function() {
|
||||
var list = document.getElementById('queue-list');
|
||||
if (!list) return;
|
||||
var dragging = null;
|
||||
|
||||
list.querySelectorAll('li').forEach(function(li) {
|
||||
li.addEventListener('dragstart', function(e) {
|
||||
dragging = li;
|
||||
li.style.opacity = '.4';
|
||||
e.dataTransfer.effectAllowed = 'move';
|
||||
});
|
||||
li.addEventListener('dragend', function() {
|
||||
li.style.opacity = '1';
|
||||
dragging = null;
|
||||
saveOrder();
|
||||
});
|
||||
li.addEventListener('dragover', function(e) {
|
||||
e.preventDefault();
|
||||
if (dragging && dragging !== li) {
|
||||
var rect = li.getBoundingClientRect();
|
||||
var mid = rect.top + rect.height / 2;
|
||||
if (e.clientY < mid) {
|
||||
list.insertBefore(dragging, li);
|
||||
} else {
|
||||
list.insertBefore(dragging, li.nextSibling);
|
||||
}
|
||||
}
|
||||
});
|
||||
li.setAttribute('draggable', 'true');
|
||||
});
|
||||
|
||||
function saveOrder() {
|
||||
var ids = Array.from(list.querySelectorAll('li')).map(li => li.dataset.id);
|
||||
var fd = new FormData();
|
||||
fd.append('action', 'reorder');
|
||||
fd.append('csrf_token', document.querySelector('[name=csrf_token]').value);
|
||||
ids.forEach(id => fd.append('ids[]', id));
|
||||
fetch('/staff/queues.php', { method: 'POST', body: fd });
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php require __DIR__ . '/_footer.php'; ?>
|
||||
Reference in New Issue
Block a user