26 lines
759 B
PHP
26 lines
759 B
PHP
<?php
|
|
require_once __DIR__ . '/../includes/bootstrap.php';
|
|
$staff = require_staff_login();
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
$pdo = get_db();
|
|
$number = $_GET['n'] ?? '';
|
|
$known = max(0, (int) ($_GET['count'] ?? 0));
|
|
|
|
$stmt = $pdo->prepare('SELECT id, department_id FROM tickets WHERE ticket_number = ?');
|
|
$stmt->execute([$number]);
|
|
$ticket = $stmt->fetch();
|
|
|
|
if (!$ticket || !staff_can_access_department($staff, (int) $ticket['department_id'])) {
|
|
echo json_encode(['new_count' => $known]);
|
|
exit;
|
|
}
|
|
|
|
// Mitarbeiter sehen auch interne Notizen
|
|
$stmt = $pdo->prepare('SELECT COUNT(*) FROM ticket_threads WHERE ticket_id = ?');
|
|
$stmt->execute([$ticket['id']]);
|
|
$count = (int) $stmt->fetchColumn();
|
|
|
|
echo json_encode(['new_count' => $count]);
|