Upload via GUI (267 Dateien)

This commit is contained in:
2026-10-19 18:06:00 +00:00
parent c800be9693
commit 51656d6578
13 changed files with 516 additions and 54 deletions
+30 -8
View File
@@ -8,6 +8,7 @@ $fieldTypes = [
'text' => 'Einzeiliger Text',
'textarea' => 'Mehrzeiliger Text',
'select' => 'Dropdown-Auswahl',
'radio' => 'Radio-Auswahl (Punkte)',
'checkbox' => 'Checkbox (Ja/Nein)',
'number' => 'Zahl',
'date' => 'Datum',
@@ -25,20 +26,22 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$isRequired = !empty($_POST['is_required']) ? 1 : 0;
$isActive = !empty($_POST['is_active']) ? 1 : 0;
$sort = (int) ($_POST['sort_order'] ?? 0);
$radioInline = !empty($_POST['radio_inline']) ? 1 : 0;
$helpText = form_help_compose((string) ($_POST['help_text'] ?? ''), (string) ($_POST['link_url'] ?? ''), (string) ($_POST['link_word'] ?? ''), $label);
if ($label === '') $errors[] = 'Bitte eine Bezeichnung angeben.';
if ($type === 'select' && $optionsRaw === '') $errors[] = 'Bitte mindestens eine Option angeben (eine pro Zeile).';
if (in_array($type, ['select', 'radio'], true) && $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()]);
$pdo->prepare('INSERT INTO custom_fields (label, field_type, options, help_topic_id, is_required, is_active, sort_order, radio_inline, help_text, created_at) VALUES (?,?,?,?,?,?,?,?,?,?)')
->execute([$label, $type, $optionsRaw ?: null, $helpTopicId, $isRequired, $isActive, $sort, $radioInline, $helpText ?: null, 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]);
$pdo->prepare('UPDATE custom_fields SET label=?, field_type=?, options=?, help_topic_id=?, is_required=?, is_active=?, sort_order=?, radio_inline=?, help_text=? WHERE id=?')
->execute([$label, $type, $optionsRaw ?: null, $helpTopicId, $isRequired, $isActive, $sort, $radioInline, $helpText ?: null, $id]);
audit_log($admin['id'], "Ticket-Feld aktualisiert: {$label}");
flash('success', 'Feld aktualisiert.');
}
@@ -61,7 +64,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$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'
WHERE cf.department_id IS NULL ORDER BY cf.sort_order, cf.label'
)->fetchAll();
$helpTopics = $pdo->query('SELECT * FROM help_topics ORDER BY name')->fetchAll();
@@ -128,17 +131,36 @@ require __DIR__ . '/_header.php';
<input type="text" id="label" name="label" value="<?= e($editField['label'] ?? '') ?>" placeholder="z. B. Vertragsnummer" required>
<label for="field_type">Feldtyp</label>
<select name="field_type" id="field_type" onchange="document.getElementById('options-row').style.display = this.value==='select' ? 'block' : 'none'">
<select name="field_type" id="field_type" onchange="document.getElementById('options-row').style.display = (this.value==='select' || this.value==='radio') ? 'block' : 'none'; document.getElementById('radio-row').style.display = this.value==='radio' ? 'block' : 'none'">
<?php foreach ($fieldTypes as $val => $lbl): ?>
<option value="<?= $val ?>" <?= ($editField['field_type'] ?? 'text') === $val ? 'selected' : '' ?>><?= e($lbl) ?></option>
<?php endforeach; ?>
</select>
<div id="options-row" style="display:<?= ($editField['field_type'] ?? '') === 'select' ? 'block' : 'none' ?>">
<div id="options-row" style="display:<?= in_array($editField['field_type'] ?? '', ['select', 'radio'], true) ? 'block' : 'none' ?>">
<label for="options">Optionen (eine pro Zeile)</label>
<textarea id="options" name="options" placeholder="Option 1&#10;Option 2&#10;Option 3"><?= e($editField['options'] ?? '') ?></textarea>
</div>
<?php $__rt = $editField['field_type'] ?? ''; $__ri = $editField['radio_inline'] ?? 0; ?>
<div id="radio-row" style="display:<?= ($__rt === 'radio') ? 'block' : 'none' ?>">
<label for="radio_inline">Anordnung der Optionen</label>
<select id="radio_inline" name="radio_inline">
<option value="0" <?= empty($__ri) ? 'selected' : '' ?>>Untereinander</option>
<option value="1" <?= !empty($__ri) ? 'selected' : '' ?>>Nebeneinander</option>
</select>
</div>
<?php $__hStored = $editField['help_text'] ?? ''; ?>
<?php [$__hPlain, $__hUrl, $__hWord] = form_help_split($__hStored); ?>
<label for="help_text">Hinweistext (optional)</label>
<textarea id="help_text" name="help_text" rows="3" placeholder="z. B. Ich habe die Nutzerbedingungen gelesen und akzeptiert."><?= e($__hPlain) ?></textarea>
<div class="field-row">
<div><label for="link_word">Verlinkter Teil des Textes</label><input type="text" id="link_word" name="link_word" value="<?= e($__hWord) ?>" placeholder="z. B. Nutzerbedingungen"></div>
<div><label for="link_url">Link-Adresse</label><input type="text" id="link_url" name="link_url" value="<?= e($__hUrl) ?>" placeholder="https://…"></div>
</div>
<p class="muted" style="font-size:.78rem;margin:3px 0 0">Bei einer <strong>Checkbox</strong> steht der Text neben dem Kästchen, bei anderen Feldern unter dem Feld. Das Wort aus „Verlinkter Teil“ wird im Text zum Link auf die Adresse. Eine Checkbox als <strong>Pflichtfeld</strong> muss angehakt werden.</p>
<label for="help_topic_id">Gilt für Hilfe-Thema</label>
<select name="help_topic_id" id="help_topic_id">
<option value="">Alle Themen (oder Formular ohne Themenauswahl)</option>