Files
4WDCSA.co.za/payment_confirmation.php

150 lines
5.3 KiB
PHP

<?php
define('HEADER_VARIANT', '02');
require_once('header.php');
checkUserSession();
$user_id = $_SESSION['user_id'];
if (!isset($_GET['token']) || empty($_GET['token'])) {
die("Invalid request.");
}
$token = $_GET['token'];
// echo $token;
$booking_id = decryptData($token, $salt);
// Retrieve booking details from the database
$sql = "SELECT eft_id, total_amount, discount_amount, trip_id, course_id FROM bookings WHERE booking_id = ?";
$stmt = $conn->prepare($sql);
if (!$stmt) {
die("Prepare failed: " . $conn->error);
}
$stmt->bind_param("i", $booking_id);
$stmt->execute();
$stmt->bind_result($eft_id, $amount, $discount, $trip_id, $course_id);
$stmt->fetch();
$stmt->close();
// Check if booking was found
if (!$eft_id) {
die("Error: Booking not found.");
}
// Retrieve trip details
$sql = "SELECT trip_name, start_date, end_date FROM trips WHERE trip_id = ?";
$stmt = $conn->prepare($sql);
if (!$stmt) {
die("Prepare failed: " . $conn->error);
}
$stmt->bind_param("i", $trip_id);
$stmt->execute();
$stmt->bind_result($trip_name, $start_date, $end_date);
$stmt->fetch();
$stmt->close();
// Retrieve trip details
$sql = "SELECT course_type, date FROM courses WHERE course_id = ?";
$stmt = $conn->prepare($sql);
if (!$stmt) {
die("Prepare failed: " . $conn->error);
}
$stmt->bind_param("i", $course_id);
$stmt->execute();
$stmt->bind_result($type, $start_date);
$stmt->fetch();
$stmt->close();
if ($type === "driver_training") {
$course_name = "Basic 4X4 Driver Training Course";
} elseif ($type === "bush_mechanics") {
$course_name = "Bush Mechanics Course";
} elseif ($type === "rescue_recovery") {
$course_name = "Rescue & Recovery Training Course";
} else {
$course_name = "General Course"; // Default fallback description
}
// $start_date = $date;
// Get user's email
$sql = "SELECT email FROM users WHERE user_id = ?";
$stmt = $conn->prepare($sql);
if (!$stmt) {
die("Prepare failed: " . $conn->error);
}
$stmt->bind_param("i", $user_id);
$stmt->execute();
$stmt->bind_result($user_email);
$stmt->fetch();
$stmt->close();
$conn->close();
$payment_amount = $amount - $discount;
?>
<?php
$bannerFolder = 'assets/images/banners/';
$bannerImages = glob($bannerFolder . '*.{jpg,jpeg,png,webp}', GLOB_BRACE);
$randomBanner = 'assets/images/base4/camping.jpg'; // default fallback
if (!empty($bannerImages)) {
$randomBanner = $bannerImages[array_rand($bannerImages)];
}
?>
<section class="page-banner-area pt-50 pb-35 rel z-1 bgs-cover" style="background-image: url('<?php echo $randomBanner; ?>');">
<div class="banner-overlay"></div>
<div class="container">
<div class="banner-inner text-white mb-50">
<h2 class="page-title mb-10" data-aos="fade-left" data-aos-duration="1500" data-aos-offset="50">Payment</h2>
<nav aria-label="breadcrumb">
<ol class="breadcrumb justify-content-center mb-20" data-aos="fade-right" data-aos-delay="200" data-aos-duration="1500" data-aos-offset="50">
<li class="breadcrumb-item"><a href="index.php">Home</a></li>
<li class="breadcrumb-item">Booking</li>
<li class="breadcrumb-item active">Payment</li>
</ol>
</nav>
</div>
</div>
</section>
<!-- About Us Area start -->
<section class="about-us-area pt-90 pb-100 rel z-1">
<div class="container">
<div class="row gap-100 align-items-center">
<div class="col-lg-12">
<div class="destination-details-content rmb-55" data-aos="fade-left" data-aos-duration="1500" data-aos-offset="50">
<div class="section-title mb-25">
<span class="h2 mb-15">Booking Summary:</span>
<h2><?php
if ($trip_name != NULL){
echo htmlspecialchars($trip_name).'</h2><h3>'. htmlspecialchars($start_date).' - '.htmlspecialchars($end_date).'</h3>';
} else {
echo htmlspecialchars($course_name).'</h2><h3>'. htmlspecialchars($start_date).'</h3>';
}?>
</div>
<p>Your invoice has been sent to <b><?php echo htmlspecialchars($user_email); ?></b>. Please upload your proof of payment below.</p>
<!-- <p>Bookings not paid for within 24 hours will be forfeited.</p> -->
<h5>Payment Details:</h5>
<p>The Four Wheel Drive Club of Southern Africa<br>FNB<br>Account Number: 58810022334<br>Branch code: 250655<br>Reference: <?php echo htmlspecialchars($eft_id); ?><br>Amount: R <?php echo number_format($payment_amount, 2); ?></p>
<a href="submit_pop.php" class="theme-btn style-two style-three" style="width:100%;">
<span data-hover="Submit Proof of Payment">Submit Proof of Payment</span>
<i class="fal fa-arrow-right"></i>
</a>
</div>
</div>
</div>
</div>
</section>
<!-- About Us Area end -->
<?php include_once("insta_footer.php"); ?>