45 lines
No EOL
1.5 KiB
PHP
45 lines
No EOL
1.5 KiB
PHP
<?php
|
|
|
|
require('../admin/components/db_config.php');
|
|
require('../admin/components/utils.php');
|
|
|
|
date_default_timezone_set("America/Chicago");
|
|
|
|
if(isset($_POST['check_availability'])){
|
|
$frm_data = filteration($_POST);
|
|
$status = "";
|
|
$result = "";
|
|
|
|
//booking time validation
|
|
$today_date = new DateTime(date("M-d-Y"));
|
|
$checkin_date = new DateTime($frm_data['check_in']);
|
|
$checkout_date = new DateTime($frm_data['check_out']);
|
|
|
|
if($checkin_date == $checkout_date){
|
|
$status = 'check_in_out_equal';
|
|
$result = json_encode(["status" => $status]);
|
|
} else if($checkout_date < $checkin_date){
|
|
$status = 'check_out_earlier';
|
|
$result = json_encode(["status" => $status]);
|
|
} else if($checkin_date < $today_date){
|
|
$status = 'check_in_earlier';
|
|
$result = json_encode(["status" => $status]);
|
|
}
|
|
//booking availability
|
|
if($status!=''){
|
|
echo $result;
|
|
} else{
|
|
session_start();
|
|
$_SESSION['room'];
|
|
|
|
//check room availability
|
|
$count_days = date_diff($checkin_date, $checkout_date)->days;
|
|
$payment = $_SESSION['room']['price'] * $count_days;
|
|
$_SESSION['room']['payment'] = $payment;
|
|
$_SESSION['room']['available'] = true;
|
|
|
|
$result = json_encode(["status" => 'available', "days" => $count_days, "payment" => $payment]);
|
|
echo $result;
|
|
}
|
|
}
|
|
?>
|