updated code
This commit is contained in:
parent
1893b034e6
commit
72c0f0fbf3
3 changed files with 24 additions and 26 deletions
|
@ -3,7 +3,7 @@
|
||||||
require('../admin/components/db_config.php');
|
require('../admin/components/db_config.php');
|
||||||
require('../admin/components/utils.php');
|
require('../admin/components/utils.php');
|
||||||
|
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set("America/Chicago");
|
||||||
|
|
||||||
if(isset($_POST['check_availability'])){
|
if(isset($_POST['check_availability'])){
|
||||||
$frm_data = filteration($_POST);
|
$frm_data = filteration($_POST);
|
||||||
|
|
|
@ -3,14 +3,14 @@
|
||||||
require('../admin/components/db_config.php');
|
require('../admin/components/db_config.php');
|
||||||
require('../admin/components/utils.php');
|
require('../admin/components/utils.php');
|
||||||
require('../admin/components/api.php');
|
require('../admin/components/api.php');
|
||||||
require("../components/sendgrid/sendgrid-php.php");
|
require('../components/sendgrid/sendgrid-php.php');
|
||||||
|
|
||||||
date_default_timezone_set("America/Chicago");
|
date_default_timezone_set("America/Chicago");
|
||||||
|
|
||||||
//sendgrid
|
//sendgrid
|
||||||
function send_mail($mail, $name, $token){
|
function send_mail($mail, $name, $token){
|
||||||
$email = new \SendGrid\Mail\Mail();
|
$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->setSubject("Account Verification Link");
|
||||||
|
|
||||||
$email->addTo($mail, $name);
|
$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)){
|
if($sendgrid->send($email)){
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -93,8 +93,5 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -1,3 +1,4 @@
|
||||||
|
<?php require('./components/config.php')?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
|
@ -101,7 +102,6 @@
|
||||||
$user_res = select("SELECT * FROM `user_creds` WHERE `id`=? LIMIT 1", [$_SESSION['uerID']], "i");
|
$user_res = select("SELECT * FROM `user_creds` WHERE `id`=? LIMIT 1", [$_SESSION['uerID']], "i");
|
||||||
$user_data = mysqli_fetch_assoc($user_res);
|
$user_data = mysqli_fetch_assoc($user_res);
|
||||||
|
|
||||||
|
|
||||||
//get accommodation & additional accommodation
|
//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]'");
|
$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 = "";
|
$accommodation_data = "";
|
||||||
|
@ -125,7 +125,7 @@
|
||||||
<div class="col-lg-7 col-md-12">
|
<div class="col-lg-7 col-md-12">
|
||||||
<div class="card mb-4 border-0 shadow-sm">
|
<div class="card mb-4 border-0 shadow-sm">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form id="booking_form">
|
<form action="reserved.php" method="post" id="booking_form">
|
||||||
<h5>Booking Detail</h5>
|
<h5>Booking Detail</h5>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6 mb-3">
|
<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">
|
<div id="info_loader" class="spinner-border text-secondary mb-3 d-none" role="status">
|
||||||
<span class="visually-hidden">Loading...</span>
|
<span class="visually-hidden">Loading...</span>
|
||||||
</div>
|
</div>
|
||||||
<p class="mb-3 text-danger" id="pay_info">Please provide check-in and check-out date</p>
|
<p class="mb-3 text-danger" id="reserve_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>
|
<button name="reserve_now" class="btn-third" style="width: 100%; text-transform: uppercase;" disabled>Reserve now</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
@ -246,17 +246,17 @@
|
||||||
|
|
||||||
let booking_form = document.getElementById('booking_form');
|
let booking_form = document.getElementById('booking_form');
|
||||||
let info_loader = document.getElementById('info_loader');
|
let info_loader = document.getElementById('info_loader');
|
||||||
let pay_info = document.getElementById('pay_info');
|
let reserve_info = document.getElementById('reserve_info');
|
||||||
|
|
||||||
function check_availability(){
|
function check_availability(){
|
||||||
let checkin_val = booking_form.elements['checkin'].value;
|
let checkin_val = booking_form.elements['checkin'].value;
|
||||||
let checkout_val = booking_form.elements['checkout'].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 !=''){
|
if(checkin_val !='' && checkout_val !=''){
|
||||||
pay_info.classList.add('d-none');
|
reserve_info.classList.add('d-none');
|
||||||
pay_info.classList.replace('text-dark', 'text-danger');
|
reserve_info.classList.replace('text-dark', 'text-danger');
|
||||||
info_loader.classList.remove('d-none');
|
info_loader.classList.remove('d-none');
|
||||||
|
|
||||||
|
|
||||||
|
@ -271,30 +271,31 @@
|
||||||
xhr.onload = function(){
|
xhr.onload = function(){
|
||||||
let data = JSON.parse(this.responseText);
|
let data = JSON.parse(this.responseText);
|
||||||
if(data.status == 'check_in_out_equal'){
|
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'){
|
} 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'){
|
} 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'){
|
} 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{
|
} else{
|
||||||
//pay_info.innerHTML = "Number of days: " +data.days+ "<br> Total Price: $"+data.payment;
|
reserve_info.innerHTML = `
|
||||||
pay_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;">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>
|
<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');
|
reserve_info.classList.replace('text-danger', 'text-dark');
|
||||||
booking_form.elements['pay_now'].removeAttribute('disabled');
|
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');
|
info_loader.classList.add('d-none');
|
||||||
}
|
}
|
||||||
xhr.send(data)
|
xhr.send(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
Add table
Reference in a new issue