Files
2026-03-05 10:25:39 +01:00

23 lines
664 B
PHP

<?php
declare(strict_types=1);
require_once __DIR__ . '/_bootstrap.php';
require_auth_json(['client','praticien','secretaire','admin']);
$compteId = (int)($_SESSION['compte_id'] ?? 0);
if ($compteId <= 0) json_response(['ok'=>false,'error'=>'auth_required'], 401);
$stmt = $pdo->prepare("SELECT msg_unread, rdv_unread FROM push_badge_counters WHERE compte_id = ?");
$stmt->execute([$compteId]);
$row = $stmt->fetch(PDO::FETCH_ASSOC) ?: ['msg_unread'=>0,'rdv_unread'=>0];
$msg = (int)($row['msg_unread'] ?? 0);
$rdv = (int)($row['rdv_unread'] ?? 0);
json_response([
'ok' => true,
'msg_unread' => $msg,
'rdv_unread' => $rdv,
'total' => $msg + $rdv,
]);