require_once('app_top.php');
require_once('header.php');
$gid = $_REQUEST['gid']; // ?? '';
$rid = $_REQUEST['rid'];
$a = $_REQUEST['action']; // ?? '';
$updateme = $_REQUEST['updateme']; // ?? '';
// $_REQUEST['rtype'] ?? '';
if (!empty($_REQUEST['rtype'])) //abb 20-8-12 Force RESERVE if rtype defined
{
$rtype = $_REQUEST['rtype']; // reservation type
$room_booking_status = 2;
$atype = 2;
$action = 'form';
} else {
// check room status in room_list table
// abb 20-8-12 VIP is VIP, 18 is need cleaning
$room_list_status = return_value('room_list','status',"WHERE rid = '$rid'");
//$update = $_REQUEST['update'];
$atype = $_REQUEST['atype']; // ?? '';
$choosen_date = $_SESSION['chosen_date']; //abb 20-8-12 in date('Y-m-d H:i:s') format
$choosen_date_Ymd = date('Y-m-d', $choosen_date); //abb 20-8-12 in date('Y-m-d H:i:s') format
$choosen_date_strttYmd = strtotime(date('Y-m-d', $choosen_date)); //abb 20-8-12 in date('Y-m-d H:i:s') format
//echo 'line 89 - Choosen Date - ',$choosen_date_strttYmd;
$result = db_query("SELECT log_id, guest_id, room_id, checkin, checkout, status FROM room_log WHERE room_id = '$rid' AND status != 0 AND status != 2");
$row = $result-> fetch_object();
if($result-> num_rows > 0)
{
$log_id = $row-> log_id;
$guest_id = $row-> guest_id;
$checkin = $row-> checkin;
$checkin_strttYmd = strtotime(date('Y-m-d', strtotime($checkin))); //abb 20-8-12 in date('Y-m-d H:i:s') format
$checkout = $row-> checkout;
$checkout_strttYmd = strtotime(date('Y-m-d', strtotime($checkout))); //abb 20-8-12 in date('Y-m-d H:i:s') format
$status = $row-> status;
$room_id = $row-> room_id;
//echo '
line 110-logid-',$log_id,'
';
//echo $status.'
';
$room_num = return_value('room_list','room_num',"WHERE rid = '$room_id'");
//echo $choosen_date_strttYmd, ' - ', $checkin_strttYmd, ' - ', $checkout_strttYmd;
if ($choosen_date_strttYmd >= $checkin_strttYmd && $choosen_date_strttYmd <= $checkout_strttYmd && $status != 0)
{
/*
//abb 20-08-12 check if booked but not checkout
if($status == 1)
{
//abb 20-8-12 Even status 2 reserved but no log request then still force FORM
if($_REQUEST['log'] != '')
{
$action = 'info';
} else {
$action = 'info';
}
} else {
$action = 'info';
}
*/
//abb 20-08-12 check if reserved
if($status == 2 && $_REQUEST['log'] !='')
{
$action = 'info';
} else {
//abb 20-8-12 Even status 2 reserved but no log request then still force FORM
if($_REQUEST['log'] != '')
{
$action = 'info';
} else {
$action = 'info';
//$status = 0;
}
}
//echo 'line135';
} else {
$action = 'form';
}
//}while($row = $result-> fetch_object());
} else{ // if no previous record
$action = 'form';
$status = 0;
$room_id = $rid;
}
} //rtype
switch($action)
{
case 'info':
if ($_REQUEST['log'] != '')
{
$log_id = $_REQUEST['log'];
$status = return_value('room_log','status',"WHERE log_id='$log_id'");
}
if($_REQUEST['log'])
{
$log_id = $_REQUEST['log'];
$status = return_value('room_log','status',"WHERE log_id='$log_id'");
} else {
if ($status == 2)
{
$action = 'info';
$status = 1;
}
}
//echo $status;
//echo ' Status test : ', $status,'';
switch ($status)
{
default:
//TBA
break;
case '1': //booked
room_status_update($log_id, $room_id, $action, $status, $gid);
echo '
Room No. : '. $room_num.'
'; echo 'Start Time : '.date('d M Y h:i A', strtotime($checkin)).'
' ; echo 'Estimated End Time : '. date('d M Y h:i A', strtotime($checkout)) .'
'; echo ''; echo 'Room No. : '. $room_num.'
'; echo 'Start Time : '. date('d M Y h:i A', strtotime($checkin)) .'
' ; echo 'Estimated End Time : '. date('d M Y h:i A', strtotime($checkout)) .'
'; echo ''; echo '