updated code

This commit is contained in:
Juthatip McDevitt 2024-06-26 15:50:12 -05:00
parent 1893b034e6
commit 72c0f0fbf3
3 changed files with 24 additions and 26 deletions

View file

@ -3,7 +3,7 @@
require('../admin/components/db_config.php');
require('../admin/components/utils.php');
date_default_timezone_set('UTC');
date_default_timezone_set("America/Chicago");
if(isset($_POST['check_availability'])){
$frm_data = filteration($_POST);

View file

@ -3,14 +3,14 @@
require('../admin/components/db_config.php');
require('../admin/components/utils.php');
require('../admin/components/api.php');
require("../components/sendgrid/sendgrid-php.php");
require('../components/sendgrid/sendgrid-php.php');
date_default_timezone_set("America/Chicago");
//sendgrid
function send_mail($mail, $name, $token){
$email = new \SendGrid\Mail\Mail();
$email->setFrom(SENDGRID_EMAIL, SENDGRID_SENDER);
$email->setFrom(SENDGRID_EMAIL, SENDGRID_SENDER); //setup in api.php
$email->setSubject("Account Verification Link");
$email->addTo($mail, $name);
@ -21,7 +21,7 @@
"
);
$sendgrid = new \SendGrid(SENDGRID_API_KEY);
$sendgrid = new \SendGrid(SENDGRID_API_KEY); //setup in api.php
if($sendgrid->send($email)){
return 1;
@ -93,8 +93,5 @@
}
}
};
}
?>

View file

@ -1,3 +1,4 @@
<?php require('./components/config.php')?>
<!DOCTYPE html>
<html lang="en">
<head>
@ -101,7 +102,6 @@
$user_res = select("SELECT * FROM `user_creds` WHERE `id`=? LIMIT 1", [$_SESSION['uerID']], "i");
$user_data = mysqli_fetch_assoc($user_res);
//get accommodation & additional accommodation
$accom_q = mysqli_query($con, "SELECT a.name FROM `accommodation` a INNER JOIN `room_accommodation` raccom ON a.id = raccom.accommodation_id WHERE raccom.room_id = '$room_data[id]'");
$accommodation_data = "";
@ -125,7 +125,7 @@
<div class="col-lg-7 col-md-12">
<div class="card mb-4 border-0 shadow-sm">
<div class="card-body">
<form id="booking_form">
<form action="reserved.php" method="post" id="booking_form">
<h5>Booking Detail</h5>
<div class="row">
<div class="col-md-6 mb-3">
@ -160,8 +160,8 @@
<div id="info_loader" class="spinner-border text-secondary mb-3 d-none" role="status">
<span class="visually-hidden">Loading...</span>
</div>
<p class="mb-3 text-danger" id="pay_info">Please provide check-in and check-out date</p>
<button name="pay_now" class="btn-third" style="width: 100%; text-transform: uppercase;" disabled>pay now</button>
<p class="mb-3 text-danger" id="reserve_info">Please provide check-in and check-out date</p>
<button name="reserve_now" class="btn-third" style="width: 100%; text-transform: uppercase;" disabled>Reserve now</button>
</div>
</div>
</form>
@ -243,20 +243,20 @@
<?php require('./components/script.php') ?>
<script>
let booking_form = document.getElementById('booking_form');
let info_loader = document.getElementById('info_loader');
let pay_info = document.getElementById('pay_info');
let reserve_info = document.getElementById('reserve_info');
function check_availability(){
let checkin_val = booking_form.elements['checkin'].value;
let checkout_val = booking_form.elements['checkout'].value;
booking_form.elements['pay_now'].setAttribute('disabled', true);
booking_form.elements['reserve_now'].setAttribute('disabled', true);
if(checkin_val !='' && checkout_val !=''){
pay_info.classList.add('d-none');
pay_info.classList.replace('text-dark', 'text-danger');
reserve_info.classList.add('d-none');
reserve_info.classList.replace('text-dark', 'text-danger');
info_loader.classList.remove('d-none');
@ -271,29 +271,30 @@
xhr.onload = function(){
let data = JSON.parse(this.responseText);
if(data.status == 'check_in_out_equal'){
pay_info.innerText = "No options matching your search, please make sure your check-in and check-out date is not the same!";
reserve_info.innerText = "No options matching your search, please make sure your check-in and check-out date is not the same!";
} else if(data.status == 'check_out_earlier'){
pay_info.innerText = "No options matching your search, please check your check-out date";
reserve_info.innerText = "No options matching your search, please check your check-out date";
} else if(data.status == 'check_in_earlier'){
pay_info.innerText = "No options matching your search, please check your check-in date";
reserve_info.innerText = "No options matching your search, please check your check-in date";
} else if(data.status == 'unavailable'){
pay_info.innerText = "We are sorry, this room is not available at this time.";
reserve_info.innerText = "We are sorry, this room is not available at this time.";
} else{
//pay_info.innerHTML = "Number of days: " +data.days+ "<br> Total Price: $"+data.payment;
pay_info.innerHTML = `
reserve_info.innerHTML = `
<div style='width: 200px; display: flex; flex-direction: row; justify-content: space-between; font-size: 14px;'><p style="font-weight: 600;">Number of days</p> <p> ${+data.days}</p></div>
<div style='width: 200px; display: flex; flex-direction: row; justify-content: space-between; font-size: 14px;'><p style="font-weight: 600;">Total amount</p> <p>$${+data.payment}</p></div>
`;
pay_info.classList.replace('text-danger', 'text-dark');
booking_form.elements['pay_now'].removeAttribute('disabled');
reserve_info.classList.replace('text-danger', 'text-dark');
booking_form.elements['reserve_now'].removeAttribute('disabled');
}
pay_info.classList.remove('d-none');
reserve_info.classList.remove('d-none');
info_loader.classList.add('d-none');
}
xhr.send(data)
xhr.send(data);
}
}
</script>
</body>