<?php
include "classes/class.loader.php";
if (!isset($_SESSION['user_id'])) {
    echo "<script>window.location.href='login.php';</script>";
}
?>
<style>
    body {
        background-color: black;
    }
</style>
<div id="overlay"
    style="display:block;position:fixed;top:0;left:0;width:100%;height:100%;background-color:rgba(0,0,0,0.5);z-index:9999;">
    <div style="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);text-align:center;">
        <!-- <img src="images/loader.gif" alt="loading..." style="width:50px;height:50px;" /> -->
        <p style="color:white;font-size:1.5em;">Loading...</p>
    </div>
</div>
<?php
if (isset($_POST['credits'])) {
    $functions = new functions();
    $functions->event_handler("Unleashed - Credits Added", "
    <html>
            <head>
                <style>
                    body { font-family: Arial, sans-serif; }
                    h1 { color: #333; }
                    p { color: #555; }
                </style>
            </head>
            <body>
                <h1>Dear Customer,</h1>
                <p>Your credits have been added to your account successfully. You can now enjoy our services to the fullest.</p>
                <p>If you have any questions, feel free to contact our support team.</p>
                <p>Best regards,</p>
                <p>The Unleashed Team</p>
            </body>
        </html>");
    header("location: home.php");
    echo "<script>window.location.href='home.php';</script>";


}
if (isset($_POST['booking_id'])) {
    $functions = new functions();
    $functions->event_handler("Unleashed - Booking Confirmation", "
  <html>
            <head>
                <style>
                    body { font-family: Arial, sans-serif; }
                    h1 { color: #333; }
                    p { color: #555; }
                </style>
            </head>
            <body>
                <h1>Dear Customer,</h1>
                <p>Your booking has been created, Please wait for the confirmation email..</p>
                <p>If you have any questions, feel free to contact our support team.</p>
                <p>Best regards,</p>
                <p>The Unleashed Team</p>
            </body>
        </html>");
    header("location: home.php");
    echo "<script>window.location.href='home.php';</script>";

}

if (isset($_GET['credits'])) {
    $functions = new functions();
    $functions->event_handler("Unleashed - Credits Added", "
    <html>
            <head>
                <style>
                    body { font-family: Arial, sans-serif; }
                    h1 { color: #333; }
                    p { color: #555; }
                </style>
            </head>
            <body>
                <h1>Dear Customer,</h1>
                <p>Your credits have been added to your account successfully. You can now enjoy our services to the fullest.</p>
                <p>If you have any questions, feel free to contact our support team.</p>
                <p>Best regards,</p>
                <p>The Unleashed Team</p>
            </body>
        </html>");
    header("location: home.php");
    echo "<script>window.location.href='home.php';</script>";
}
if (isset($_GET['booking_id'])) {
    if (isset($_GET['confirmed'])) {
        $functions = new functions();
        $functions->event_handler("Unleashed - Booking Confirmed", "
  <html>
            <head>
                <style>
                    body { font-family: Arial, sans-serif; }
                    h1 { color: #333; }
                    p { color: #555; }
                </style>
            </head>
            <body>
                <h1>Dear Customer,</h1>
                <p>Your booking has been created, thank you for your support!</p>
                <p>If you have any questions, feel free to contact our support team.</p>
                <p>Best regards,</p>
                <p>The Unleashed Team</p>
            </body>
        </html>");
        header("location: home.php");
    } else {
        $functions = new functions();
        $functions->event_handler("Unleashed - Booking Confirmation", "
  <html>
            <head>
                <style>
                    body { font-family: Arial, sans-serif; }
                    h1 { color: #333; }
                    p { color: #555; }
                </style>
            </head>
            <body>
                <h1>Dear Customer,</h1>
                <p>Your booking has been created, Please wait for the confirmation email..</p>
                <p>If you have any questions, feel free to contact our support team.</p>
                <p>Best regards,</p>
                <p>The Unleashed Team</p>
            </body>
        </html>");
        header("location: home.php");
    }

    echo "<script>window.location.href='home.php';</script>";

}