hjkhjkjhkhjkgjghjhgjhgjghjhghjghjhgjjnbvnvbnvk
bnmbnmbnhjkhjkhjkhjktyutyutyuytutyutyutyhgjgjghjgjghjguytutyry
/
home
/
wjcvelqp
/
public_html
/
despiteloveday.com.ng
/
Upload FileeE
HOME
<?php $page_title = 'Book Now'; session_start(); require_once 'config/database.php'; require_once 'config/paystack.php'; require_once 'includes/auth.php'; $customer = getCustomer(); $error = ''; $success_ref = ''; $success_method = ''; $selected_room = isset($_GET['room']) ? $_GET['room'] : ''; // Room pricing (fallback if DB rooms not used) $roomPrices = [ 'single' => ['name' => 'Single Room', 'price' => 35000, 'unit' => 'night', 'label' => '₦35,000 / night'], 'one-bedroom' => ['name' => 'Room & Parlor', 'price' => 55000, 'unit' => 'night', 'label' => '₦55,000 / night'], 'two-bedroom' => ['name' => '2 Bedroom Apartment', 'price' => 90000, 'unit' => 'night', 'label' => '₦90,000 / night'], 'photoshoot' => ['name' => 'Photoshoot Space', 'price' => 20000, 'unit' => 'hour', 'label' => '₦20,000 / hour'], ]; $check_in_time = getSiteSetting('check_in_time', '1:00 PM'); $check_out_time = getSiteSetting('check_out_time', '12:00 PM'); if ($_SERVER['REQUEST_METHOD'] === 'POST') { $guest_name = trim($_POST['guest_name'] ?? ''); $guest_email = trim($_POST['guest_email'] ?? ''); $guest_phone = trim($_POST['guest_phone'] ?? ''); $room_type = trim($_POST['room_type'] ?? ''); $check_in = trim($_POST['check_in'] ?? ''); $check_out = trim($_POST['check_out'] ?? ''); $guests = max(1, intval($_POST['guests'] ?? 1)); $special = trim($_POST['special_requests'] ?? ''); $hours = max(1, intval($_POST['hours'] ?? 1)); $pay_method = trim($_POST['payment_method'] ?? 'pay_at_property'); if (!in_array($pay_method, ['online', 'pay_at_property'])) { $pay_method = 'pay_at_property'; } if (empty($guest_name) || empty($guest_email) || empty($guest_phone) || empty($room_type) || empty($check_in)) { $error = 'Please fill in all required fields.'; } elseif (!isset($roomPrices[$room_type])) { $error = 'Invalid room selected.'; } elseif (!filter_var($guest_email, FILTER_VALIDATE_EMAIL)) { $error = 'Please enter a valid email address.'; } else { $room = $roomPrices[$room_type]; $amount = 0; $nights = 1; $duration_label = ''; if ($room_type === 'photoshoot') { $amount = $room['price'] * $hours; $check_out = $check_in; $duration_label = $hours . ' hour' . ($hours > 1 ? 's' : ''); } else { if (empty($check_out) || $check_out <= $check_in) { $check_out = date('Y-m-d', strtotime($check_in . ' +1 day')); } $nights = max(1, (strtotime($check_out) - strtotime($check_in)) / 86400); $amount = $room['price'] * $nights; $duration_label = $nights . ' night' . ($nights > 1 ? 's' : ''); } $reference = 'DL' . strtoupper(bin2hex(random_bytes(5))); $db = getDB(); $booking_id = null; // Online: status = pending (awaiting admin approval) // Pay at property: status = confirmed (reservation held), payment unpaid $status = ($pay_method === 'online') ? 'pending' : 'confirmed'; if ($db) { try { $roomMap = [ 'single' => 1, 'one-bedroom' => 2, 'two-bedroom' => 3, 'photoshoot' => 4 ]; $room_id = $roomMap[$room_type] ?? null; $customer_id = isCustomerLoggedIn() ? $_SESSION['customer_id'] : null; $stmt = $db->prepare("INSERT INTO bookings (booking_ref, customer_id, room_id, guest_name, guest_email, guest_phone, check_in, check_out, guests, total_amount, special_requests, payment_method, status, payment_status) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'unpaid')"); $stmt->execute([ $reference, $customer_id, $room_id, $guest_name, $guest_email, $guest_phone, $check_in, $check_out, $guests, $amount, $special, $pay_method, $status ]); $booking_id = $db->lastInsertId(); } catch (Exception $e) { $error = 'Could not save booking. Please try again or contact us.'; } } if (empty($error)) { $_SESSION['pending_booking'] = [ 'ref' => $reference, 'booking_id' => $booking_id, 'name' => $guest_name, 'email' => $guest_email, 'phone' => $guest_phone, 'room_type' => $room_type, 'room_name' => $room['name'], 'check_in' => $check_in, 'check_out' => $check_out, 'guests' => $guests, 'amount' => $amount, 'duration' => $duration_label, 'special' => $special, 'payment_method'=> $pay_method ]; $success_ref = $reference; $success_method = $pay_method; // For online we do NOT redirect to Paystack yet — wait for admin approval // User will pay later from check-booking page after approval } } } include 'includes/header.php'; ?> <section class="page-hero"> <div class="container"> <h1>Book Your Stay</h1> <p>Reserve online. Pay at the property or request online payment after admin approval.</p> </div> </section> <section class="booking-section"> <div class="container"> <?php if ($error): ?> <div class="alert alert-error" style="max-width:800px; margin:0 auto 30px;"> <?php echo htmlspecialchars($error); ?> </div> <?php endif; ?> <?php if ($success_ref): ?> <div class="booking-success-card" style="max-width:720px; margin:0 auto; background:#fff; border-radius:16px; box-shadow:0 10px 40px rgba(0,0,0,0.08); padding:40px; text-align:center;"> <div style="width:72px;height:72px;background:linear-gradient(135deg,#D4AF37,#B8941F);border-radius:50%;display:flex;align-items:center;justify-content:center;margin:0 auto 20px;font-size:32px;color:#0B1C33;"> <i class="fas fa-check"></i> </div> <h2 style="color:#0B1C33;margin-bottom:8px;">Booking Request Received</h2> <p style="font-size:1.1rem;margin-bottom:6px;">Your reference number:</p> <p style="font-size:1.8rem;font-weight:700;color:#D4AF37;letter-spacing:2px;margin-bottom:24px;"><?php echo htmlspecialchars($success_ref); ?></p> <?php if ($success_method === 'pay_at_property'): ?> <div style="background:#f8f6f0;border-radius:12px;padding:20px;text-align:left;margin-bottom:24px;"> <p style="margin:0 0 10px;"><strong><i class="fas fa-info-circle"></i> Pay at the property</strong></p> <ul style="margin:0;padding-left:20px;line-height:1.7;color:#334;"> <li>Your reservation is held. Please arrive and pay at the cashier.</li> <li><strong>Check-in:</strong> <?php echo htmlspecialchars($check_in_time); ?> | <strong>Check-out:</strong> <?php echo htmlspecialchars($check_out_time); ?></li> <li>Download or print your booking receipt and present it on arrival.</li> <li>You can look up this booking anytime with the reference number above.</li> </ul> </div> <?php else: ?> <div style="background:#f0f7ff;border-radius:12px;padding:20px;text-align:left;margin-bottom:24px;"> <p style="margin:0 0 10px;"><strong><i class="fas fa-clock"></i> Online payment — awaiting admin approval</strong></p> <ul style="margin:0;padding-left:20px;line-height:1.7;color:#334;"> <li>Our team will review availability and approve your booking.</li> <li>Once approved, return here or use <strong>Check Booking</strong> with your reference to complete payment online via Paystack.</li> <li><strong>Check-in:</strong> <?php echo htmlspecialchars($check_in_time); ?> | <strong>Check-out:</strong> <?php echo htmlspecialchars($check_out_time); ?></li> </ul> </div> <?php endif; ?> <div style="display:flex;flex-wrap:wrap;gap:12px;justify-content:center;"> <a href="receipt.php?ref=<?php echo urlencode($success_ref); ?>" class="btn btn-gold" target="_blank"> <i class="fas fa-download"></i> Download Receipt </a> <a href="check-booking.php?ref=<?php echo urlencode($success_ref); ?>" class="btn btn-outline"> <i class="fas fa-search"></i> Check Booking Status </a> <a href="index.php" class="btn btn-outline">Back to Home</a> </div> </div> <?php else: ?> <div class="booking-card"> <div class="booking-info"> <h3>How Booking Works</h3> <p>Choose how you prefer to pay. Both options create a booking with a unique reference number.</p> <ul class="booking-features"> <li><i class="fas fa-money-bill-wave"></i> <strong>Pay at property</strong> — Book now, pay cashier on arrival</li> <li><i class="fas fa-credit-card"></i> <strong>Pay online</strong> — Admin reviews availability first, then you pay</li> <li><i class="fas fa-clock"></i> Check-in <?php echo htmlspecialchars($check_in_time); ?> · Check-out <?php echo htmlspecialchars($check_out_time); ?></li> <li><i class="fas fa-search"></i> Track any booking with your reference number</li> <li><i class="fas fa-file-invoice"></i> Download receipt after booking</li> </ul> <div style="margin-top:32px; padding-top:24px; border-top:1px solid rgba(255,255,255,0.15);"> <p style="font-size:14px; margin-bottom:10px;"><strong>Our Rates</strong></p> <p style="font-size:13px; opacity:0.9; margin-bottom:4px;">Single Room — ₦35,000 / night</p> <p style="font-size:13px; opacity:0.9; margin-bottom:4px;">Room & Parlor — ₦55,000 / night</p> <p style="font-size:13px; opacity:0.9; margin-bottom:4px;">2 Bedroom Apt — ₦90,000 / night</p> <p style="font-size:13px; opacity:0.9;">Photoshoot — ₦20,000 / hour</p> </div> </div> <div class="booking-form-wrap"> <form method="POST" action="" id="bookingForm" data-validate> <div class="form-group"> <label>Full Name *</label> <input type="text" name="guest_name" class="form-control" required placeholder="Your full name" value="<?php echo htmlspecialchars($_POST['guest_name'] ?? ($customer['full_name'] ?? '')); ?>"> </div> <div class="form-row"> <div class="form-group"> <label>Email Address *</label> <input type="email" name="guest_email" class="form-control" required placeholder="you@example.com" value="<?php echo htmlspecialchars($_POST['guest_email'] ?? ($customer['email'] ?? '')); ?>"> </div> <div class="form-group"> <label>Phone / WhatsApp *</label> <input type="tel" name="guest_phone" class="form-control" required placeholder="+234 800 000 0000" value="<?php echo htmlspecialchars($_POST['guest_phone'] ?? ($customer['phone'] ?? '')); ?>"> </div> </div> <div class="form-group"> <label>Select Room / Space *</label> <select name="room_type" id="roomType" class="form-control" required onchange="updateForm()"> <option value="">— Choose —</option> <?php foreach ($roomPrices as $key => $r): ?> <option value="<?php echo $key; ?>" data-price="<?php echo $r['price']; ?>" data-unit="<?php echo $r['unit']; ?>" <?php echo ($selected_room === $key || (isset($_POST['room_type']) && $_POST['room_type'] === $key)) ? 'selected' : ''; ?>> <?php echo $r['name']; ?> — <?php echo $r['label']; ?> </option> <?php endforeach; ?> </select> </div> <div class="form-row"> <div class="form-group"> <label id="dateLabel">Check-in Date *</label> <input type="date" name="check_in" id="checkIn" class="form-control" required min="<?php echo date('Y-m-d'); ?>" value="<?php echo htmlspecialchars($_POST['check_in'] ?? ''); ?>" onchange="updateForm()"> </div> <div class="form-group" id="checkoutGroup"> <label>Check-out Date *</label> <input type="date" name="check_out" id="checkOut" class="form-control" min="<?php echo date('Y-m-d', strtotime('+1 day')); ?>" value="<?php echo htmlspecialchars($_POST['check_out'] ?? ''); ?>" onchange="updateForm()"> </div> <div class="form-group" id="hoursGroup" style="display:none;"> <label>Number of Hours *</label> <input type="number" name="hours" id="hours" class="form-control" min="1" max="24" value="2" onchange="updateForm()" oninput="updateForm()"> </div> </div> <div class="form-group"> <label>Number of Guests</label> <input type="number" name="guests" class="form-control" min="1" max="10" value="<?php echo intval($_POST['guests'] ?? 1); ?>"> </div> <div class="form-group"> <label>Special Requests (optional)</label> <textarea name="special_requests" class="form-control" placeholder="Arrival time, special needs, etc."><?php echo htmlspecialchars($_POST['special_requests'] ?? ''); ?></textarea> </div> <div class="form-group"> <label>Payment Method *</label> <div style="display:grid;gap:10px;"> <label style="display:flex;align-items:flex-start;gap:12px;padding:14px 16px;border:1.5px solid #E2E8F0;border-radius:10px;cursor:pointer;background:#fff;"> <input type="radio" name="payment_method" value="pay_at_property" checked style="margin-top:3px;" onchange="updatePayHint()"> <span> <strong>Pay at the property (Cashier)</strong><br> <small style="color:#64748b;">Book now, download receipt, pay when you arrive. Reservation is held immediately.</small> </span> </label> <label style="display:flex;align-items:flex-start;gap:12px;padding:14px 16px;border:1.5px solid #E2E8F0;border-radius:10px;cursor:pointer;background:#fff;"> <input type="radio" name="payment_method" value="online" style="margin-top:3px;" onchange="updatePayHint()"> <span> <strong>Pay online (after admin approval)</strong><br> <small style="color:#64748b;">We review availability first. Once approved, you complete payment via Paystack.</small> </span> </label> </div> <p id="payHint" style="font-size:12px;color:#64748b;margin-top:8px;"> You will get a reference number and can download your receipt right away. </p> </div> <div id="totalBox" style="background:var(--cream,#f8f6f0); border-radius:10px; padding:18px 20px; margin-bottom:22px; display:none;"> <div style="display:flex; justify-content:space-between; align-items:center;"> <div> <div style="font-size:13px; color:var(--gray-600,#64748b);">Estimated Total</div> <div id="totalLabel" style="font-size:14px; color:var(--navy,#0B1C33); margin-top:2px;"></div> </div> <div id="totalAmount" style="font-size:1.6rem; font-weight:700; color:var(--gold-dark,#B8941F);"></div> </div> </div> <button type="submit" class="btn btn-gold btn-lg" style="width:100%;" id="submitBtn"> <i class="fas fa-calendar-check"></i> Confirm Booking </button> <p style="font-size:12px; color:var(--gray-600,#64748b); margin-top:14px; text-align:center;"> Check-in from <?php echo htmlspecialchars($check_in_time); ?> · Check-out by <?php echo htmlspecialchars($check_out_time); ?> </p> <?php if (!$customer): ?> <p style="font-size:12px; color:var(--gray-600,#64748b); margin-top:10px; text-align:center;"> Booking as guest. <a href="register.php" style="color:var(--navy,#0B1C33);">Create an account</a> to track bookings easily. </p> <?php else: ?> <p style="font-size:12px; color:var(--gray-600,#64748b); margin-top:10px; text-align:center;"> Logged in as <strong><?php echo htmlspecialchars($customer['full_name']); ?></strong>. </p> <?php endif; ?> </form> </div> </div> <?php endif; ?> </div> </section> <script> function updateForm() { var sel = document.getElementById('roomType'); var opt = sel.options[sel.selectedIndex]; var unit = opt ? opt.getAttribute('data-unit') : ''; var price = opt ? parseFloat(opt.getAttribute('data-price') || 0) : 0; var checkoutGroup = document.getElementById('checkoutGroup'); var hoursGroup = document.getElementById('hoursGroup'); var dateLabel = document.getElementById('dateLabel'); var totalBox = document.getElementById('totalBox'); var totalAmount = document.getElementById('totalAmount'); var totalLabel = document.getElementById('totalLabel'); if (!opt || !opt.value) { totalBox.style.display = 'none'; return; } if (unit === 'hour') { checkoutGroup.style.display = 'none'; hoursGroup.style.display = 'block'; dateLabel.textContent = 'Date *'; var hours = parseInt(document.getElementById('hours').value || 1, 10); var amt = price * hours; totalLabel.textContent = hours + ' hour' + (hours > 1 ? 's' : '') + ' × ₦' + price.toLocaleString(); totalAmount.textContent = '₦' + amt.toLocaleString(); totalBox.style.display = 'block'; } else { checkoutGroup.style.display = 'block'; hoursGroup.style.display = 'none'; dateLabel.textContent = 'Check-in Date *'; var ci = document.getElementById('checkIn').value; var co = document.getElementById('checkOut').value; if (ci && co && co > ci) { var nights = Math.max(1, Math.round((new Date(co) - new Date(ci)) / 86400000)); var amt = price * nights; totalLabel.textContent = nights + ' night' + (nights > 1 ? 's' : '') + ' × ₦' + price.toLocaleString(); totalAmount.textContent = '₦' + amt.toLocaleString(); totalBox.style.display = 'block'; } else if (ci) { totalLabel.textContent = '1 night × ₦' + price.toLocaleString() + ' (select checkout)'; totalAmount.textContent = '₦' + price.toLocaleString(); totalBox.style.display = 'block'; } else { totalBox.style.display = 'none'; } } } function updatePayHint() { var online = document.querySelector('input[name="payment_method"][value="online"]').checked; var hint = document.getElementById('payHint'); var btn = document.getElementById('submitBtn'); if (online) { hint.textContent = 'After admin approves, use your reference on the Check Booking page to pay online.'; btn.innerHTML = '<i class="fas fa-paper-plane"></i> Submit for Approval'; } else { hint.textContent = 'You will get a reference number and can download your receipt right away.'; btn.innerHTML = '<i class="fas fa-calendar-check"></i> Confirm Booking'; } } document.addEventListener('DOMContentLoaded', function() { updateForm(); updatePayHint(); }); </script> <?php include 'includes/footer.php'; ?>