<?php

include "classes/class.loader.php";

$db = new db();

$calls = new functions();

$db->query("UPDATE `bookings` SET `status` = 2 WHERE `record_id` = '{$_GET['record_id']}'");

$booking = $db->query("SELECT * FROM `bookings` WHERE `record_id` = '{$_GET['record_id']}' LIMIT 1");

$booking = $booking->fetch_assoc();

$email = new email();

$email->add_address($calls->get_user_email($booking['user_id']), $calls->get_username($booking['user_id']));
$email->add_address("walruslector@gamil.com", "Jana");
$email->add_address("unleashed.offleashed@gamil.com", "Rika");

$email->subject("Unleashed - Booking Confirmed");

$email->body("<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 approved.</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>");

$email->send();

header("location: home.php");