<?php
session_start();
require_once __DIR__ . '/../../includes/auth.php';
require_once __DIR__ . '/../../classes/Database.php';
require_once __DIR__ . '/../../classes/User.php';


$database = new Database();
$conn = $database->getConnection();


$auth = new Auth($conn);


if (!isset($_SESSION['user_id'])) {
    header('Location: login.php');
    exit();
}
$auth->enforceSuperAdminPrivileges($_SESSION['user_id']);


if (!isset($_GET['id'])) {
    header('Location: users_list.php');
    exit();
}
$user_id = $_GET['id'];


$user = new User($conn);
if ($user->deleteUser($user_id)) {
    header('Location: users_list.php');
    exit();
} else {
    echo "<div class='alert alert-danger'>Failed to delete user.</div>";
}
?>