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

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

if(!isset($_SESSION['customer_id'])) {
    echo json_encode(['success' => false]);
    exit;
}

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

$query = "UPDATE notifications SET is_read = 1, read_at = NOW() 
          WHERE customer_id = :customer_id AND is_read = 0";
$stmt = $db->prepare($query);
$success = $stmt->execute([':customer_id' => $_SESSION['customer_id']]);

echo json_encode(['success' => $success]);
?>