<?php
// ajax/get_notification_count.php
session_start();
require_once '../../config/database.php';

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

if(!isset($_SESSION['customer_id'])) {
    echo json_encode(0);
    exit;
}

$database = new Database();
$db = $database->getConnection();

$query = "SELECT COUNT(*) as count FROM notifications 
          WHERE customer_id = :customer_id AND is_read = 0";
$stmt = $db->prepare($query);
$stmt->execute([':customer_id' => $_SESSION['customer_id']]);
$result = $stmt->fetch(PDO::FETCH_ASSOC);

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