From b6f4370f9cbe5bce37527ec0da7f7692a3188123 Mon Sep 17 00:00:00 2001 From: M_Viper Date: Mon, 26 Oct 2026 21:19:30 +0000 Subject: [PATCH] Upload via GUI (340 Dateien) --- DeskHub-Webseite/cron/auto_close_tickets.php | 1 + DeskHub-Webseite/cron/check_escalations.php | 1 + DeskHub-Webseite/cron/check_sla.php | 8 ++++++++ DeskHub-Webseite/cron/fetch_emails.php | 3 ++- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/DeskHub-Webseite/cron/auto_close_tickets.php b/DeskHub-Webseite/cron/auto_close_tickets.php index ea722c89..71e4fa46 100644 --- a/DeskHub-Webseite/cron/auto_close_tickets.php +++ b/DeskHub-Webseite/cron/auto_close_tickets.php @@ -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) { diff --git a/DeskHub-Webseite/cron/check_escalations.php b/DeskHub-Webseite/cron/check_escalations.php index e4d98ec0..a5ee8931 100644 --- a/DeskHub-Webseite/cron/check_escalations.php +++ b/DeskHub-Webseite/cron/check_escalations.php @@ -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']; } diff --git a/DeskHub-Webseite/cron/check_sla.php b/DeskHub-Webseite/cron/check_sla.php index 98335d7c..d6c8f721 100644 --- a/DeskHub-Webseite/cron/check_sla.php +++ b/DeskHub-Webseite/cron/check_sla.php @@ -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"); diff --git a/DeskHub-Webseite/cron/fetch_emails.php b/DeskHub-Webseite/cron/fetch_emails.php index baf626c1..c262f462 100644 --- a/DeskHub-Webseite/cron/fetch_emails.php +++ b/DeskHub-Webseite/cron/fetch_emails.php @@ -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']);