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

$name = $_POST['name'];
$alias = strtolower(str_replace(' ', '', $_POST['alias']));

$sql = "INSERT INTO availability_groups (name, alias) VALUES ('$name', '$alias')";
mysqli_query($db2, $sql);

// Log action
$user = $_SESSION['user_id'];
$action = "Add Availability Group";
$details = "Added availability group: $name";
mysqli_query($db2, "INSERT INTO action_logs (action, details, user, timestamp) VALUES ('$action', '$details', '$user', NOW())");

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