Upload via GUI (258 Dateien)

This commit is contained in:
2026-10-16 19:12:18 +00:00
parent 56deade877
commit 6cced3beda
50 changed files with 11148 additions and 0 deletions
@@ -0,0 +1,67 @@
<?php
require_once __DIR__ . '/../includes/bootstrap.php';
$staff = require_staff_login();
$pdo = get_db();
$agents = $pdo->query(
"SELECT s.*, d.name AS dept_name,
(SELECT COUNT(*) FROM tickets t WHERE t.assigned_staff_id=s.id AND t.status NOT IN ('closed','resolved')) AS open_tickets,
r.name AS role_name
FROM staff s
LEFT JOIN departments d ON d.id = s.department_id
LEFT JOIN roles r ON r.id = s.role_id
WHERE s.is_active = 1
ORDER BY s.name"
)->fetchAll();
$pageTitle = 'Mitarbeiter-Verzeichnis'; $activePage = 'agent_directory';
require __DIR__ . '/_header.php';
?>
<h1>Mitarbeiter-Verzeichnis</h1>
<div style="display:grid; grid-template-columns:repeat(auto-fill,minmax(240px,1fr)); gap:16px; margin-top:8px">
<?php foreach ($agents as $a): ?>
<div class="card" style="padding:18px 20px; position:relative; <?= $a['is_on_vacation'] ? 'opacity:.75' : '' ?>">
<?php if ($a['is_on_vacation']): ?>
<span class="badge" style="position:absolute;top:14px;right:14px;background:var(--accent);font-size:.68rem">🌴 Urlaub</span>
<?php endif; ?>
<div style="display:flex; align-items:center; gap:12px; margin-bottom:12px">
<?php if ($a['avatar_path']): ?>
<img src="<?= e($a['avatar_path']) ?>" alt="" style="width:48px;height:48px;border-radius:50%;object-fit:cover;flex-shrink:0;border:2px solid var(--border)">
<?php else: ?>
<div style="width:48px;height:48px;border-radius:50%;background:var(--primary-lt);display:flex;align-items:center;justify-content:center;font-size:1.2rem;font-weight:700;color:var(--primary);flex-shrink:0">
<?= mb_strtoupper(mb_substr($a['name'], 0, 1)) ?>
</div>
<?php endif; ?>
<div>
<div style="font-weight:700;color:var(--ink)"><?= e($a['name']) ?></div>
<div style="font-size:.76rem;color:var(--muted)"><?= $a['role'] === 'admin' ? 'Administrator' : ($a['role_name'] ?? 'Mitarbeiter') ?></div>
</div>
</div>
<div style="display:flex;flex-direction:column;gap:5px;font-size:.82rem">
<div style="display:flex;gap:8px">
<span style="color:var(--muted);width:70px;flex-shrink:0">E-Mail</span>
<a href="mailto:<?= e($a['email']) ?>" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap"><?= e($a['email']) ?></a>
</div>
<?php if ($a['phone']): ?>
<div style="display:flex;gap:8px">
<span style="color:var(--muted);width:70px;flex-shrink:0">Telefon</span>
<span><?= e($a['phone']) ?></span>
</div>
<?php endif; ?>
<div style="display:flex;gap:8px">
<span style="color:var(--muted);width:70px;flex-shrink:0">Abteilung</span>
<span><?= $a['dept_name'] ? e($a['dept_name']) : '<span class="muted">–</span>' ?></span>
</div>
<div style="display:flex;gap:8px">
<span style="color:var(--muted);width:70px;flex-shrink:0">Offen</span>
<span>
<a href="/staff/tickets.php?assigned=<?= $a['id'] ?>" style="font-weight:600"><?= (int)$a['open_tickets'] ?></a>
<span class="muted"> Tickets</span>
</span>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php require __DIR__ . '/_footer.php'; ?>
+110
View File
@@ -0,0 +1,110 @@
<?php
require_once __DIR__ . '/../includes/bootstrap.php';
require_once __DIR__ . '/_ui.php';
$staff = require_admin();
$pdo = get_db();
$errors = [];
$newKey = $_SESSION['new_api_key'] ?? null; // wird nur einmal angezeigt
unset($_SESSION['new_api_key']);
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
verify_csrf();
$action = $_POST['action'] ?? '';
if ($action === 'create') {
try {
$created = api_key_create($pdo, (string) ($_POST['name'] ?? ''), !empty($_POST['can_create']), !empty($_POST['can_read']), (string) ($_POST['ip_whitelist'] ?? ''), (int) $staff['id']);
$_SESSION['new_api_key'] = ['name' => trim($_POST['name']), 'key' => $created['key']];
audit_log($staff['id'], 'API-Schlüssel erstellt: ' . trim($_POST['name']));
redirect('/staff/api_keys.php');
} catch (AdminModelException $e) {
$errors[] = $e->getMessage();
}
}
if ($action === 'toggle') {
$pdo->prepare('UPDATE api_keys SET is_active = 1 - is_active WHERE id = ?')->execute([(int) $_POST['id']]);
audit_log($staff['id'], 'API-Schlüssel umgeschaltet: #' . (int) $_POST['id']);
redirect('/staff/api_keys.php');
}
if ($action === 'delete') {
$pdo->prepare('DELETE FROM api_keys WHERE id = ?')->execute([(int) $_POST['id']]);
audit_log($staff['id'], 'API-Schlüssel gelöscht: #' . (int) $_POST['id']);
flash('success', 'Schlüssel gelöscht. Systeme, die ihn nutzen, werden ab sofort abgewiesen.');
redirect('/staff/api_keys.php');
}
}
$keys = $pdo->query('SELECT k.*, s.name AS creator FROM api_keys k LEFT JOIN staff s ON s.id = k.created_by ORDER BY k.created_at DESC')->fetchAll();
$base = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https://' : 'http://') . ($_SERVER['HTTP_HOST'] ?? 'ihre-domain.de');
$pageTitle = 'API-Schlüssel';
$activePage = 'api_keys';
require __DIR__ . '/_header.php';
?>
<?php foreach ($errors as $err): ?><div class="flash error"><?= e($err) ?></div><?php endforeach; ?>
<?php if ($newKey): ?>
<div class="flash success">
<strong>Schlüssel „<?= e($newKey['name']) ?>“ wurde erstellt.</strong> Kopiere ihn jetzt – aus Sicherheitsgründen wird er nie wieder angezeigt:
<div style="margin-top:8px"><code style="font-size:1rem;user-select:all;padding:6px 10px;background:rgba(0,0,0,.08);border-radius:6px;display:inline-block"><?= e($newKey['key']) ?></code></div>
</div>
<?php endif; ?>
<div style="display:flex;justify-content:space-between;align-items:center;gap:12px">
<h1 style="margin:0">API-Schlüssel</h1>
</div>
<p class="muted">Mit einem Schlüssel können Fremdsysteme (Website-Formular, Shop, Monitoring …) Tickets über die öffentliche API anlegen oder deren Status abfragen. Ereignisse an andere Systeme meldest du über <a href="/staff/webhooks.php">Webhooks</a>.</p>
<div class="card">
<table>
<thead><tr><th>Name</th><th>Schlüssel</th><th>Rechte</th><th>Erlaubte IPs</th><th>Status</th><th>Zuletzt genutzt</th><th>Erstellt</th><th></th></tr></thead>
<tbody>
<?php foreach ($keys as $k): ?>
<tr>
<td><strong><?= e($k['name']) ?></strong><div class="muted" style="font-size:.76rem"><?= e($k['creator'] ?? '') ?></div></td>
<td><code><?= e($k['key_prefix']) ?>…</code></td>
<td style="font-size:.85rem"><?= $k['can_create_tickets'] ? 'Tickets anlegen' : '' ?><?= $k['can_create_tickets'] && $k['can_read_tickets'] ? '<br>' : '' ?><?= $k['can_read_tickets'] ? 'Tickets lesen' : '' ?></td>
<td class="muted" style="font-size:.82rem"><?= e($k['ip_whitelist'] ?: 'alle') ?></td>
<td><strong><?= $k['is_active'] ? 'Aktiv' : 'Deaktiviert' ?></strong></td>
<td class="muted" style="font-size:.82rem"><?= e(cron_last_run_label($k['last_used_at'] ?? null)) ?></td>
<td class="muted" style="font-size:.82rem"><?= e(ui_date($k['created_at'] ?? null)) ?></td>
<td style="white-space:nowrap">
<form method="post" style="display:inline"><?= csrf_field() ?><input type="hidden" name="action" value="toggle"><input type="hidden" name="id" value="<?= (int) $k['id'] ?>">
<button type="submit" style="background:none;border:none;color:var(--primary);cursor:pointer;padding:0;font-size:.9rem"><?= $k['is_active'] ? 'Deaktivieren' : 'Aktivieren' ?></button></form> ·
<form method="post" style="display:inline" onsubmit="return confirm('Schlüssel endgültig löschen?')"><?= csrf_field() ?><input type="hidden" name="action" value="delete"><input type="hidden" name="id" value="<?= (int) $k['id'] ?>">
<button type="submit" style="background:none;border:none;color:#dc2626;cursor:pointer;padding:0;font-size:.9rem">Löschen</button></form>
</td>
</tr>
<?php endforeach; ?>
<?php if (!$keys): ?><tr><td colspan="8" class="muted">Noch keine API-Schlüssel angelegt.</td></tr><?php endif; ?>
</tbody>
</table>
</div>
<div class="card">
<h3 style="margin-top:0">Neuen Schlüssel erstellen</h3>
<form method="post" autocomplete="off">
<?= csrf_field() ?>
<input type="hidden" name="action" value="create">
<div style="display:grid;grid-template-columns:1fr 1fr;gap:16px;max-width:760px">
<div><label for="name">Name *</label><input type="text" id="name" name="name" placeholder="z. B. Website-Kontaktformular" required></div>
<div><label for="ip_whitelist">Erlaubte IP-Adressen (optional)</label><input type="text" id="ip_whitelist" name="ip_whitelist" placeholder="leer = von überall; sonst kommagetrennt"></div>
</div>
<label style="display:flex;align-items:center;gap:8px;font-weight:400;margin-top:12px"><input type="checkbox" name="can_create" value="1" checked style="width:auto"> Darf Tickets anlegen</label>
<label style="display:flex;align-items:center;gap:8px;font-weight:400"><input type="checkbox" name="can_read" value="1" style="width:auto"> Darf Ticketstatus lesen (mit Ticketnummer + E-Mail des Anfragenden)</label>
<div class="btn-row"><button type="submit" class="btn">Schlüssel erstellen</button></div>
</form>
</div>
<div class="card">
<h3 style="margin-top:0">So nutzt du die API</h3>
<p class="muted" style="margin-top:0">Ticket anlegen (JSON). Antwort: <code>201</code> mit der Ticketnummer. Höchstens 60 Tickets pro Minute.</p>
<pre style="background:var(--panel2,#f1f4f7);padding:12px;border-radius:8px;overflow:auto;font-size:.82rem"><?= e("curl -X POST {$base}/api/public/v1/tickets.php \\\n -H \"X-API-Key: dh_…\" -H \"Content-Type: application/json\" \\\n -d '{\"name\":\"Max Muster\",\"email\":\"max@example.de\",\"subject\":\"Frage zur Rechnung\",\"message\":\"Hallo …\",\"helpTopicId\":1}'") ?></pre>
<p class="muted">Status abfragen:</p>
<pre style="background:var(--panel2,#f1f4f7);padding:12px;border-radius:8px;overflow:auto;font-size:.82rem"><?= e("curl \"{$base}/api/public/v1/tickets.php?number=240915-0012&email=max@example.de\" -H \"X-API-Key: dh_…\"") ?></pre>
<p class="muted" style="font-size:.82rem;margin-bottom:0">Optionale Felder beim Anlegen: <code>departmentId</code>, <code>priorityId</code>, <code>helpTopicId</code>. Ticket-Regeln und SLA-Pläne gelten wie bei jedem anderen Ticket.</p>
</div>
<?php require __DIR__ . '/_footer.php'; ?>
+73
View File
@@ -0,0 +1,73 @@
<?php
require_once __DIR__ . '/../includes/bootstrap.php';
require_once __DIR__ . '/_ui.php';
$staff = require_staff_login();
$isAdmin = ($staff['role'] ?? '') === 'admin';
if ($isAdmin) app_downloads_prepare_dir(); // Ordner anlegen und Direktzugriff sperren
$apps = [];
foreach (array_keys(app_platforms()) as $key) $apps[$key] = app_download_info($key);
$serverUrl = base_url();
$pageTitle = 'Apps';
$activePage = 'apps';
require __DIR__ . '/_header.php';
?>
<h1 style="margin-top:0">Apps für Mitarbeiter</h1>
<p class="muted">Mit den Apps bearbeitet ihr Tickets am PC oder unterwegs. Beide haben ein helles und dunkles Design.</p>
<div class="card" style="margin-bottom:20px">
<strong>Serveradresse für die Anmeldung</strong>
<div style="display:flex;gap:8px;align-items:center;margin-top:6px;flex-wrap:wrap">
<input type="text" id="server-url" value="<?= e($serverUrl) ?>" readonly style="max-width:420px;margin:0">
<button type="button" class="btn secondary" onclick="navigator.clipboard.writeText(document.getElementById('server-url').value); this.textContent='Kopiert'">Kopieren</button>
</div>
<div class="muted" style="font-size:.82rem;margin-top:6px">Diese Adresse gebt ihr beim ersten Start der App ein, danach meldet ihr euch mit eurem Mitarbeiter-Konto an.</div>
</div>
<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(300px,1fr));gap:20px">
<?php foreach (app_platforms() as $key => $p): $a = $apps[$key]; ?>
<div class="card" style="margin:0">
<div style="font-size:.72rem;font-weight:700;text-transform:uppercase;letter-spacing:.06em;color:var(--muted);margin-bottom:8px"><?= e($p['label']) ?></div>
<?php if ($a): ?>
<div style="font-size:1.3rem;font-weight:800"><?= e($p['label']) ?>-App</div>
<div class="muted" style="font-size:.82rem;margin:4px 0 12px">
<?= e(app_format_size($a['size'])) ?> · Stand <?= e(ui_date($a['modified_at'])) ?>
</div>
<a class="btn" href="/staff/app_download.php?platform=<?= e($key) ?>">⬇ <?= e($p['label']) ?>-App herunterladen</a>
<div class="muted" style="font-size:.72rem;margin-top:10px;word-break:break-all">SHA-256: <?= e($a['sha256']) ?></div>
<?php else: ?>
<div class="muted">Hier ist noch keine <?= e($p['label']) ?>-App hinterlegt.<?= $isAdmin ? '' : ' Bitte einen Administrator fragen.' ?></div>
<?php if ($isAdmin): ?>
<div style="font-size:.85rem;margin-top:8px">Datei per FTP in den Ordner <code>app_downloads/</code> legen und genau so benennen: <code><?= e($p['stored']) ?></code></div>
<?php endif; ?>
<?php endif; ?>
<div style="margin-top:14px;font-size:.85rem;border-top:1px solid var(--border);padding-top:12px">
<strong>Installation</strong>
<?php if ($key === 'windows'): ?>
<ol style="padding-left:18px;margin:6px 0 0;line-height:1.7">
<li>Datei herunterladen und starten.</li>
<li>Falls Windows warnt („Der Computer wurde geschützt“): <em>Weitere Informationen → Trotzdem ausführen</em>.</li>
<li>App öffnen, Serveradresse eingeben und anmelden.</li>
</ol>
<?php else: ?>
<ol style="padding-left:18px;margin:6px 0 0;line-height:1.7">
<li>Datei auf dem Handy herunterladen und öffnen.</li>
<li>Android fragt einmalig, ob der Browser Apps installieren darf. Das bitte erlauben.</li>
<li>App öffnen, Serveradresse eingeben und anmelden.</li>
<li>Updates: neue Datei laden und darüber installieren. Eure Anmeldung bleibt erhalten.</li>
</ol>
<?php endif; ?>
</div>
</div>
<?php endforeach; ?>
</div>
<?php if ($isAdmin): ?>
<p class="muted" style="font-size:.82rem;margin-top:18px">
Hinweis für Administratoren: Zum Aktualisieren einer App die neue Datei per FTP in <code>app_downloads/</code> hochladen und die alte ersetzen (Namen: <code>DeskHub-Setup.exe</code> und <code>DeskHub.apk</code>). Die Seite zeigt automatisch Größe, Datum und Prüfsumme der neuen Datei. Die Dateien sind nur für angemeldete Mitarbeiter abrufbar.
</p>
<?php endif; ?>
<?php require __DIR__ . '/_footer.php'; ?>