<?php
session_start();
include "connection.php";
include "validation.php";

header("Content-Type: application/json");

$response = [
    "status" => false,
    "message" => ""
];

try {
    if (!isset($_SESSION["user"])) {
        $response["message"] = "Unauthorized access.";
        echo json_encode($response);
        exit;
    }

    $student_id = $_SESSION["user"]["id"];

    Database::iud("DELETE FROM `ready_to_pay` WHERE `student_id` = '" . $student_id . "'");

    $response["status"] = true;
    $response["message"] = "Ready to Pay list cleared successfully.";
} catch (Exception $e) {
    $response["message"] = "Error: " . $e->getMessage();
}

echo json_encode($response);
exit;
?>
