<?php
session_start();
include 'dbconn.php';

if (!isset($_SESSION['admin_logged_in']) || $_SESSION['admin_logged_in'] !== true) {
    header('Location: index.php');
    exit;
}

$clinicId = isset($_GET['id']) ? intval($_GET['id']) : 0;
$action = $_GET['action'] ?? '';

if ($clinicId > 0 && in_array($action, ['lock', 'unlock'])) {
    $newStatus = ($action === 'lock') ? 'Locked' : 'Active';
    $stmt = $mysqli->prepare("UPDATE clinics SET status = ? WHERE id = ?");
    $stmt->bind_param("si", $newStatus, $clinicId);
    $stmt->execute();
}

header("Location: all_clinics.php");
exit;
?>
