<?php
include('../include/auth.php');
include('../include/lskfjwfe.php');

$id = $_GET['id'];
$sql = "DELETE FROM availability_groups WHERE id='$id'";
mysqli_query($db2, $sql);

// Log action
$user = $_SESSION['user_id'];
$action = "Delete Availability Group";
$details = "Deleted availability group ID: $id";
$log_query = "INSERT INTO action_logs (action, details, user, timestamp) VALUES ('$action', '$details', '$user', NOW())";
mysqli_query($db2, $log_query);

echo json_encode(["success" => true]);
?>
