Upload via GUI (340 Dateien)

This commit is contained in:
2026-10-26 21:19:30 +00:00
parent 2452849c74
commit b6f4370f9c
4 changed files with 12 additions and 1 deletions
@@ -52,6 +52,7 @@ function run_auto_close_tickets(PDO $pdo, bool $verbose = false): array
foreach ($tickets as $t) {
$pdo->prepare("UPDATE tickets SET status = 'closed', closed_at = ?, updated_at = ? WHERE id = ?")
->execute([$now, $now, $t['id']]);
ticket_sla_status_transition($pdo, (int) $t['id'], (string) $t['status'], 'closed');
log_activity($pdo, (int) $t['id'], null, "Automatisch geschlossen (keine Kundenreaktion seit {$days} Tagen)");
$closed++;
if ($verbose) {
@@ -182,6 +182,7 @@ function run_check_escalations(PDO $pdo, bool $verbose = false): array
if ($rule['action_set_status']) {
$pdo->prepare('UPDATE tickets SET status = ?, updated_at = ? WHERE id = ?')
->execute([$rule['action_set_status'], $now, $ticket['id']]);
ticket_sla_status_transition($pdo, (int) $ticket['id'], (string) $ticket['status'], (string) $rule['action_set_status']);
$changes[] = 'Status gesetzt auf: ' . $rule['action_set_status'];
}
+8
View File
@@ -32,6 +32,7 @@ function run_check_sla(PDO $pdo, bool $verbose = false): array
"SELECT t.*, d.email AS department_email, d.name AS department_name FROM tickets t
JOIN departments d ON d.id = t.department_id
WHERE t.status NOT IN ('resolved','closed')
AND t.sla_paused_at IS NULL
AND t.resolution_due_at IS NOT NULL
AND t.resolution_due_at < ?"
);
@@ -44,6 +45,7 @@ function run_check_sla(PDO $pdo, bool $verbose = false): array
foreach ($overdue as $t) {
if (!$t['is_overdue']) {
$pdo->prepare('UPDATE tickets SET is_overdue = 1 WHERE id = ?')->execute([$t['id']]);
ticket_sla_log_overdue($pdo, (int) $t['id'], 'resolution', (string) $t['resolution_due_at']);
log_activity($pdo, $t['id'], null, 'SLA überschritten – Ticket als überfällig markiert');
if ($t['department_email']) {
@@ -63,6 +65,12 @@ function run_check_sla(PDO $pdo, bool $verbose = false): array
}
}
$responseStmt = $pdo->prepare("SELECT id, first_response_due_at FROM tickets
WHERE first_responded_at IS NULL AND first_response_due_at IS NOT NULL AND first_response_due_at < ?
AND sla_paused_at IS NULL AND status NOT IN ('resolved','closed')");
$responseStmt->execute([$now]);
foreach ($responseStmt->fetchAll() as $ticket) ticket_sla_log_overdue($pdo, (int) $ticket['id'], 'first_response', (string) $ticket['first_response_due_at']);
// Tickets, die nicht mehr überfällig sind (z.B. weil sie gelöst wurden), zurücksetzen
$pdo->exec("UPDATE tickets SET is_overdue = 0 WHERE status IN ('resolved','closed') AND is_overdue = 1");
+2 -1
View File
@@ -198,8 +198,9 @@ function fetch_emails_for_account(PDO $pdo, array $account, bool $verbose): arra
'INSERT INTO ticket_threads (ticket_id, author_type, message, is_internal_note, created_at) VALUES (?,?,?,0,?)'
)->execute([$ticket['id'], 'customer', $body, $now]);
$newStatus = in_array($ticket['status'], ['answered', 'resolved']) ? 'open' : $ticket['status'];
$newStatus = in_array($ticket['status'], ['answered', 'resolved', 'pending']) ? 'open' : $ticket['status'];
$pdo->prepare('UPDATE tickets SET status=?, updated_at=? WHERE id=?')->execute([$newStatus, $now, $ticket['id']]);
ticket_sla_status_transition($pdo, (int) $ticket['id'], (string) $ticket['status'], $newStatus);
log_activity($pdo, $ticket['id'], null, 'Antwort per E-Mail empfangen');
notify_new_reply_channels($ticket, $body);
webhook_dispatch($pdo, 'ticket.replied', (int) $ticket['id'], ['author' => 'customer']);