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

$laybuy = new Laybuy($conn);


if (!$laybuy->deletePaymentDetails($payment_id)) {
    header('Location:laybuy_and_loans.php');
    exit();
} else {
    echo "<div class='alert alert-danger'>Failed to delete entry.</div>";
}
?>