<?php
include "classes/class.loader.php";
$db = new db();
$calls = new functions();

$db->query("UPDATE `bookings` SET `status` = 3 WHERE `record_id` = '{$_GET['record_id']}'");
$db->query("DELETE FROM visit_trans WHERE booking_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->subject("Unleashed - Booking Declined");
$email->body("Your booking has been declined by the admin.");
$email->send();
header("location: home.php");