<?php
// ==========================================
// FILE: admin/ajax/get-notifications.php
// ==========================================
/* Save as: admin/ajax/get-notifications.php */
define('ROVO_APP', true);
require_once '../../config.php';
require_once '../../Auth.php';

if (!$auth->isLoggedIn()) {
    die(json_encode(['error' => 'Unauthorized']));
}

header('Content-Type: application/json');

$user_id = $auth->getCurrentUser()['id'];

$sql = "SELECT COUNT(*) as count FROM notifications WHERE user_id = ? AND is_read = 0";
$result = $db->fetchOne($sql, [$user_id]);

echo json_encode([
    'count' => $result['count'] ?? 0
]);
?>