diff --git a/DeskHub-Webseite/api/staff/v1/ticket.php b/DeskHub-Webseite/api/staff/v1/ticket.php index bcd6dd75..ecb9f29d 100644 --- a/DeskHub-Webseite/api/staff/v1/ticket.php +++ b/DeskHub-Webseite/api/staff/v1/ticket.php @@ -121,4 +121,9 @@ $summary['customFields'] = array_map(fn($r) => [ 'type' => (string) $r['field_type'], 'value' => $r['field_type'] === 'checkbox' ? ($r['value'] ? 'Ja' : 'Nein') : (string) $r['value'], ], $cfStmt->fetchAll()); +try { + $summary['similar'] = ticket_similar($pdo, $ticket, staff_department_ids($staff)); +} catch (Throwable $e) { + $summary['similar'] = ['articles' => [], 'tickets' => []]; +} api_json(['ticket' => $summary]); diff --git a/DeskHub-Webseite/api/staff/v1/ticket_update.php b/DeskHub-Webseite/api/staff/v1/ticket_update.php index 2604e248..136ba8e9 100644 --- a/DeskHub-Webseite/api/staff/v1/ticket_update.php +++ b/DeskHub-Webseite/api/staff/v1/ticket_update.php @@ -11,7 +11,8 @@ if ($number === '') { } $pdo = get_db(); $ticket = api_find_ticket($pdo, $staff, $number); -if ($ticket['source'] !== 'chat') { +// Wiedervorlage und Beobachten sind unabhängig von der Bearbeitungssperre +if ($ticket['source'] !== 'chat' && (array_key_exists('status', $body) || array_key_exists('assignedStaffId', $body))) { $lockedByName = ticket_locked_by_other($ticket, (int) $staff['id'], $pdo); if ($lockedByName) { api_error(409, 'TICKET_LOCKED', "Dieses Ticket wird gerade von \"$lockedByName\" bearbeitet."); @@ -63,8 +64,26 @@ if (array_key_exists('assignedStaffId', $body)) { } } +// Wiedervorlage ("snoozeUntil": Datum/Uhrzeit oder null zum Aufheben) und Beobachten ("following": true/false) +if (array_key_exists('snoozeUntil', $body)) { + if ($body['snoozeUntil'] === null || $body['snoozeUntil'] === '') { + ticket_snooze_clear($pdo, (int) $ticket['id'], (int) $staff['id'], 'Wiedervorlage aufgehoben (Mobile App)'); + } else { + $until = date('Y-m-d H:i:s', (int) strtotime((string) $body['snoozeUntil'])); + $untilTs = strtotime($until); + if ($untilTs <= time() + 30 || $untilTs > time() + 366 * 86400) { + api_error(422, 'INVALID_SNOOZE', 'Die Wiedervorlage muss in der Zukunft liegen (höchstens 1 Jahr).'); + } + ticket_snooze_set($pdo, (int) $ticket['id'], (int) $staff['id'], $until); + } +} +if (array_key_exists('following', $body)) { + if (!empty($body['following'])) ticket_follow($pdo, (int) $ticket['id'], (int) $staff['id']); + else ticket_unfollow($pdo, (int) $ticket['id'], (int) $staff['id']); +} + if (!$updates) { - api_json(['ticket' => api_ticket_summary($ticket)]); + api_json(['ticket' => api_ticket_summary(api_find_ticket($pdo, $staff, $number))]); } $updates[] = 'updated_at = ?'; $params[] = $now; diff --git a/DeskHub-Webseite/api/staff/v1/tickets.php b/DeskHub-Webseite/api/staff/v1/tickets.php index 67e36d71..51a8b095 100644 --- a/DeskHub-Webseite/api/staff/v1/tickets.php +++ b/DeskHub-Webseite/api/staff/v1/tickets.php @@ -15,6 +15,13 @@ if ($departmentFilter !== '') { array_push($params, ...$departmentParams); } +// Wiedervorlage: ausgeblendet, außer mit ?snoozed=1 (dann nur diese) +$where[] = !empty($_GET['snoozed']) ? (ticket_snooze_available() ? "t.snoozed_until > '" . db_now() . "'" : '1=0') : ticket_not_snoozed_sql('t'); +// Beobachtet: nur Tickets, die der angemeldete Mitarbeiter beobachtet (?following=1) +if (!empty($_GET['following'])) { + $where[] = 't.id IN (SELECT ticket_id FROM ticket_followers WHERE staff_id = ?)'; + $params[] = (int) $staff['id']; +} $statuses = array_values(array_filter( array_map('trim', explode(',', (string) ($_GET['status'] ?? 'open,pending,answered,on_hold'))), fn(string $status) => in_array($status, MOBILE_API_STATUSES, true) diff --git a/DeskHub-Webseite/api/staff/v1/web_pages.php b/DeskHub-Webseite/api/staff/v1/web_pages.php new file mode 100644 index 00000000..1c13e7e6 --- /dev/null +++ b/DeskHub-Webseite/api/staff/v1/web_pages.php @@ -0,0 +1,21 @@ + web_handoff_pages($staff)]); +} + +$body = api_request_body(); +$path = trim((string) ($body['path'] ?? '')); +$url = $path !== '' ? web_handoff_create($pdo, $staff, $path) : null; +if ($url === null) { + api_error(403, 'PAGE_NOT_ALLOWED', 'Diese Seite darf nicht geöffnet werden.'); +} +api_json(['url' => $url]);