Upload via GUI (267 Dateien)

This commit is contained in:
2026-10-19 18:06:02 +00:00
parent 51656d6578
commit 4466c959f7
6 changed files with 125 additions and 23 deletions
+53 -9
View File
@@ -84,7 +84,10 @@ $departments = departments_for_select($pdo, [(int) $ticket['department_id']]);
$priorities = $pdo->query('SELECT * FROM priorities ORDER BY sort_order')->fetchAll();
$agents = $pdo->query('SELECT id, name FROM staff WHERE is_active = 1 ORDER BY name')->fetchAll();
$teams = $pdo->query('SELECT id, name FROM teams WHERE is_active = 1 ORDER BY name')->fetchAll();
$cannedResponses = $pdo->query('SELECT id, title, body FROM canned_responses ORDER BY title')->fetchAll();
// Nur Vorlagen dieser Abteilung und solche, die für alle Abteilungen gelten (keine Abteilung zugeordnet)
$cannedStmt = $pdo->prepare('SELECT id, title, body, department_id FROM canned_responses WHERE department_id IS NULL OR department_id = ? ORDER BY title');
$cannedStmt->execute([(int) $ticket['department_id']]);
$cannedResponses = $cannedStmt->fetchAll();
$helpTopicName = null;
if (!empty($ticket['help_topic_id'])) {
@@ -252,12 +255,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
log_activity($pdo, $ticket['id'], $staff['id'], 'Automatisch zugewiesen (erste Antwort)');
}
$signature = trim($staff['signature'] ?? '');
if ($signature === '') {
$deptSigStmt = $pdo->prepare('SELECT signature FROM departments WHERE id = ?');
$deptSigStmt->execute([$ticket['department_id']]);
$signature = (string) $deptSigStmt->fetchColumn();
}
// Signatur laut Auswahl im Antwortformular (eigene, Abteilung oder keine); ohne Angabe wie bisher
$signature = resolve_reply_signature($pdo, $staff, (int) $ticket['department_id'], isset($_POST['signature_choice']) ? (string) $_POST['signature_choice'] : null);
$ccEmails = array_column($collaborators, 'email');
notify_customer_new_reply($ticket, $message, $signature, $ccEmails);
save_mentions($pdo, $ticket['id'], $threadId, $staff['id'], $message, $ticket);
@@ -996,6 +995,14 @@ $sourceLabel = $sourceLabels[$ticket['source']] ?? $ticket['source'];
<div class="card">
<h3>Antworten / Notiz</h3>
<?php
$sigOwn = trim((string) ($staff['signature'] ?? ''));
$sigDeptStmt = $pdo->prepare('SELECT signature FROM departments WHERE id = ?');
$sigDeptStmt->execute([$ticket['department_id']]);
$sigDept = trim((string) $sigDeptStmt->fetchColumn());
$sigDefault = $sigOwn !== '' ? 'own' : ($sigDept !== '' ? 'dept' : 'none');
$sigHtml = ['own' => $sigOwn !== '' ? sanitize_staff_html($sigOwn) : '', 'dept' => $sigDept !== '' ? sanitize_staff_html($sigDept) : '', 'none' => ''];
?>
<form method="post" enctype="multipart/form-data">
<?= csrf_field() ?>
<input type="hidden" name="action" value="reply" id="form-action">
@@ -1021,8 +1028,16 @@ $sourceLabel = $sourceLabels[$ticket['source']] ?? $ticket['source'];
<div style="display:flex;gap:8px;align-items:center;margin-bottom:6px">
<select id="canned_picker" style="flex:1" onchange="applyCannedResponse(this)">
<option value="">– Vorlage wählen –</option>
<?php foreach ($cannedResponses as $cr): ?>
<option value="<?= $cr['id'] ?>" data-body="<?= e($cr['body']) ?>"><?= e($cr['title']) ?></option>
<?php
$cannedOwn = array_filter($cannedResponses, fn($cr) => !empty($cr['department_id']));
$cannedAll = array_filter($cannedResponses, fn($cr) => empty($cr['department_id']));
foreach ([['Abteilung „' . ($ticket['department_name'] ?? '') . '“', $cannedOwn], ['Für alle Abteilungen', $cannedAll]] as [$groupLabel, $groupItems]):
if (!$groupItems) continue; ?>
<optgroup label="<?= e($groupLabel) ?>">
<?php foreach ($groupItems as $cr): ?>
<option value="<?= $cr['id'] ?>" data-body="<?= e($cr['body']) ?>"><?= e($cr['title']) ?></option>
<?php endforeach; ?>
</optgroup>
<?php endforeach; ?>
</select>
<button type="button" id="canned-preview-btn" style="display:none;font-size:.78rem;padding:5px 10px" class="btn secondary" onclick="toggleCannedPreview()">Vorschau</button>
@@ -1030,6 +1045,35 @@ $sourceLabel = $sourceLabels[$ticket['source']] ?? $ticket['source'];
<div id="canned-preview" style="display:none;background:var(--bg-soft);border:1px solid var(--border);border-radius:6px;padding:12px;font-size:.84rem;line-height:1.7;margin-bottom:8px;max-height:200px;overflow-y:auto"></div>
<?php endif; ?>
<textarea name="message" id="message-field" data-richtext placeholder="Nachricht eingeben..." required></textarea>
<div id="reply-signature" style="margin:14px 0">
<div style="display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:6px">
<label for="signature_choice" style="margin:0">Signatur</label>
<select name="signature_choice" id="signature_choice" style="width:auto;min-width:260px">
<option value="own" <?= $sigDefault === 'own' ? 'selected' : '' ?> <?= $sigOwn === '' ? 'disabled' : '' ?>>Meine Signatur<?= $sigOwn === '' ? ' (nicht hinterlegt)' : '' ?></option>
<option value="dept" <?= $sigDefault === 'dept' ? 'selected' : '' ?> <?= $sigDept === '' ? 'disabled' : '' ?>>Abteilung „<?= e($ticket['department_name']) ?>“<?= $sigDept === '' ? ' (nicht hinterlegt)' : '' ?></option>
<option value="none" <?= $sigDefault === 'none' ? 'selected' : '' ?>>Keine Signatur</option>
</select>
<a href="/staff/profile.php?tab=signature" class="muted" style="font-size:.78rem">Meine Signatur bearbeiten</a>
</div>
<div id="signature-preview" style="border:1px dashed var(--border);border-radius:8px;padding:12px 14px;font-size:.88rem;line-height:1.6;color:var(--muted);background:var(--bg-soft,transparent);min-height:20px"></div>
<div class="muted" style="font-size:.76rem;margin-top:4px">Wird nur an öffentliche Antworten angehängt, nicht an interne Notizen.</div>
</div>
<script>
(function () {
var sigs = <?= json_encode($sigHtml, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP) ?>;
var sel = document.getElementById('signature_choice');
var box = document.getElementById('signature-preview');
function show() {
var html = sigs[sel.value] || '';
if (html) { box.innerHTML = html; box.style.opacity = '1'; }
else { box.textContent = sel.value === 'none' ? 'Es wird keine Signatur angehängt.' : 'Keine Signatur hinterlegt.'; box.style.opacity = '.7'; }
}
sel.addEventListener('change', show);
show();
})();
</script>
<div class="field-row">
<div>
<label for="attachments">Anhänge (optional, mehrere möglich)</label>