'Einzeiliger Text', 'textarea' => 'Mehrzeiliger Text', 'select' => 'Dropdown-Auswahl', 'checkbox' => 'Checkbox (Ja/Nein)', 'number' => 'Zahl', 'date' => 'Datum', ]; if ($_SERVER['REQUEST_METHOD'] === 'POST') { verify_csrf(); $action = $_POST['action'] ?? ''; if ($action === 'create' || $action === 'update') { $label = trim($_POST['label'] ?? ''); $type = array_key_exists($_POST['field_type'] ?? '', $fieldTypes) ? $_POST['field_type'] : 'text'; $optionsRaw = trim($_POST['options'] ?? ''); $helpTopicId = ($_POST['help_topic_id'] ?? '') !== '' ? (int) $_POST['help_topic_id'] : null; $isRequired = !empty($_POST['is_required']) ? 1 : 0; $isActive = !empty($_POST['is_active']) ? 1 : 0; $sort = (int) ($_POST['sort_order'] ?? 0); if ($label === '') $errors[] = 'Bitte eine Bezeichnung angeben.'; if ($type === 'select' && $optionsRaw === '') $errors[] = 'Bitte mindestens eine Option angeben (eine pro Zeile).'; if (!$errors) { if ($action === 'create') { $pdo->prepare('INSERT INTO custom_fields (label, field_type, options, help_topic_id, is_required, is_active, sort_order, created_at) VALUES (?,?,?,?,?,?,?,?)') ->execute([$label, $type, $optionsRaw ?: null, $helpTopicId, $isRequired, $isActive, $sort, db_now()]); audit_log($admin['id'], "Ticket-Feld erstellt: {$label}"); flash('success', 'Feld erstellt.'); } else { $id = (int) $_POST['id']; $pdo->prepare('UPDATE custom_fields SET label=?, field_type=?, options=?, help_topic_id=?, is_required=?, is_active=?, sort_order=? WHERE id=?') ->execute([$label, $type, $optionsRaw ?: null, $helpTopicId, $isRequired, $isActive, $sort, $id]); audit_log($admin['id'], "Ticket-Feld aktualisiert: {$label}"); flash('success', 'Feld aktualisiert.'); } redirect('/staff/custom_fields.php'); } } if ($action === 'delete') { $id = (int) $_POST['id']; $labelStmt = $pdo->prepare('SELECT label FROM custom_fields WHERE id = ?'); $labelStmt->execute([$id]); $delLabel = $labelStmt->fetchColumn(); $pdo->prepare('DELETE FROM custom_fields WHERE id = ?')->execute([$id]); audit_log($admin['id'], "Ticket-Feld gelöscht: {$delLabel}"); flash('success', 'Feld gelöscht (bereits erfasste Werte bleiben in bestehenden Tickets sichtbar).'); redirect('/staff/custom_fields.php'); } } $fields = $pdo->query( 'SELECT cf.*, ht.name AS help_topic_name FROM custom_fields cf LEFT JOIN help_topics ht ON ht.id = cf.help_topic_id ORDER BY cf.sort_order, cf.label' )->fetchAll(); $helpTopics = $pdo->query('SELECT * FROM help_topics ORDER BY name')->fetchAll(); $editId = $_GET['edit'] ?? null; $editField = null; if ($editId) { $stmt = $pdo->prepare('SELECT * FROM custom_fields WHERE id = ?'); $stmt->execute([$editId]); $editField = $stmt->fetch(); } $pageTitle = 'Ticket-Felder'; $activePage = 'custom_fields'; require __DIR__ . '/_header.php'; ?>

Individuelle Ticket-Felder

Diese Felder erscheinen zusätzlich zu Name, E-Mail, Betreff und Beschreibung auf dem Formular „Neues Ticket erstellen“. Die eingegebenen Werte werden im Ticket angezeigt.

BezeichnungTypHilfe-ThemaPflichtfeldAktiv
Bearbeiten ·
Noch keine individuellen Felder angelegt.

Auf „Alle Themen“ belassen, damit das Feld unabhängig vom gewählten Anliegen erscheint.