<?php
session_start();
require_once __DIR__ . '/../../includes/auth.php';
require_once __DIR__ . '/../../classes/Database.php';
require_once __DIR__ . '/../../classes/Payroll.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: salaries.php');
    exit();
}
$grade_id = $_GET['id'];


$payroll = new Payroll($conn);
if ($payroll->deleteGrade($grade_id)) {
    header('Location: salaries.php');
    exit();
} else {
    echo "<div class='alert alert-danger'>Failed to delete user.</div>";
}
?>