BLACKSITE
:
216.73.217.4
:
104.37.75.190 / alpenpass.ca
:
Linux server3.pointsplan.com 5.14.0-503.38.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Apr 18 08:52:10 EDT 2025 x86_64
:
/
home
/
apca
/
www
/
Upload File:
files >> /home/apca/www/add-to-rental-cart-original.php
<?php session_start(); include('includes/config.php'); if (!isset($_SESSION['login'])) { die("Error: User is not logged in."); } if ($_SERVER['REQUEST_METHOD'] === 'POST') { $user_id = $_SESSION['login']; // Using email as user_id $vehicle_id = $_POST['vehicleID']; $vehicle_name = $_POST['vehicleName']; $from_date = $_POST['fromdate']; $to_date = $_POST['todate']; $message = $_POST['message']; // Calculate duration $date1 = strtotime($from_date); $date2 = strtotime($to_date); $diff = abs($date2 - $date1); $days = floor($diff / (60 * 60 * 24)); $hours = floor(($diff % (60 * 60 * 24)) / (60 * 60)); // Fetch rental rates $stmt = $dbh->prepare("SELECT * FROM tblvehicles WHERE id = :vehicle_id"); $stmt->bindParam(':vehicle_id', $vehicle_id, PDO::PARAM_INT); $stmt->execute(); $vehicle = $stmt->fetch(PDO::FETCH_ASSOC); if (!$vehicle) { die("Error: Vehicle not found."); } // Determine pricing if ($days < 1 && $hours < 1) { $amount_charged = $vehicle['hourly']; $rate_name = "Hourly"; $insurance_fee = $vehicle['ins1_2']; } elseif ($days < 1 && $hours < 4) { $amount_charged = $vehicle['four_hours']; $rate_name = "Four Hours"; $insurance_fee = $vehicle['ins4']; } elseif ($days < 1 && $hours >= 4) { $amount_charged = $vehicle['all_day']; $rate_name = "All Day"; $insurance_fee = $vehicle['insFull']; } elseif ($days >= 10) { $amount_charged = $vehicle['ten_days_plus'] * $days; $rate_name = "10 Days+"; $insurance_fee = $vehicle['insFull'] * $days; } else { $amount_charged = $vehicle['two_to_nine_days'] * $days; $rate_name = "2-9 Days"; $insurance_fee = $vehicle['insFull'] * $days; } // Additional costs $security_deposit = $vehicle['security_deposit']; $taxable_total = $amount_charged + $insurance_fee; $gst = $taxable_total * 0.05; $pst = $taxable_total * 0.07; $total_due = $taxable_total + $gst + $pst + $security_deposit; $booking_no = mt_rand(100000000, 999999999); // Insert into rental_cart table $stmt = $dbh->prepare("INSERT INTO rental_cart (user_id, vehicle_id, vehicle_name, from_date, to_date, message, rate_name, amount_charged, insurance_fee, security_deposit, taxable_total, gst, pst, total_due, booking_no) VALUES (:user_id, :vehicle_id, :vehicle_name, :from_date, :to_date, :message, :rate_name, :amount_charged, :insurance_fee, :security_deposit, :taxable_total, :gst, :pst, :total_due, :booking_no)"); $stmt->execute([ ':user_id' => $user_id, ':vehicle_id' => $vehicle_id, ':vehicle_name' => $vehicle_name, ':from_date' => $from_date, ':to_date' => $to_date, ':message' => $message, ':rate_name' => $rate_name, ':amount_charged' => $amount_charged, ':insurance_fee' => $insurance_fee, ':security_deposit' => $security_deposit, ':taxable_total' => $taxable_total, ':gst' => $gst, ':pst' => $pst, ':total_due' => $total_due, ':booking_no' => $booking_no ]); // Redirect to rental cart header("Location: rental-cart.php"); exit(); } ?>