<?php
/**
 * Manager Logout API
 * Handles manager logout
 */

session_start();
require 'config.php';

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

if (!isset($_SESSION['manager_id'])) {
    sendResponse(false, 'No active session', null);
}

$manager_id = $_SESSION['manager_id'];

// Update manager status to offline
$sql = "UPDATE managers SET is_online = FALSE WHERE id = " . intval($manager_id);
$conn->query($sql);

// Destroy session
session_destroy();

sendResponse(true, 'Logout successful', null);
?>
