<?php
session_start();
include 'config.php';


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

if (isset($_GET['id'])) {
    $leave_id = $_GET['id'];

    // Update leave request status to Rejected
    $reject_sql = "UPDATE leave_requests SET status = 'Rejected' WHERE id = ?";
    $stmt = $conn->prepare($reject_sql);
    $stmt->bind_param("i", $leave_id);
    
    if ($stmt->execute()) {
        header("Location: leave_dashboard.php");
        exit();
    } else {
        echo "Error rejecting leave request!";
    }
} else {
    echo "Invalid leave request ID.";
    exit();
}
?>

</body>
</html>
