<?php

require_once '../includes/config.php';

if(!isset($_SESSION['lawyer_id'])){
    header("Location: ../login.php");
    exit;
}

$id = (int)$_GET['id'];
$status = $_GET['status'];

$allowed = ['confirmed','completed','cancelled'];

if(in_array($status, $allowed)){

    $db = getDB();

    $stmt = $db->prepare("
        UPDATE appointments
        SET status=?
        WHERE id=?
    ");

    $stmt->execute([$status, $id]);
}

header("Location: appointments.php");
exit;