74 lines
No EOL
3 KiB
PHP
74 lines
No EOL
3 KiB
PHP
<?php
|
|
require('../components/utils.php');
|
|
require('../components/db_config.php');
|
|
adminLogin();
|
|
|
|
date_default_timezone_set("UTC");
|
|
|
|
|
|
if(isset($_POST['get_booking'])){
|
|
$frm_data = filteration($_POST);
|
|
$query = "SELECT bo.*, bd.* FROM `booking_order` bo INNER JOIN `booking_detail` bd ON bo.booking_id = bd.booking_id WHERE (bo.order_id LIKE ? OR bd.phone LIKE ? OR bd.user_name LIKE ? OR bd.user_lastname LIKE ?) AND (bo.booking_status =? AND bo.arrival =?) ORDER BY bo.booking_id ASC";
|
|
$res = select($query, ["%$frm_data[search]%", "%$frm_data[search]%", "%$frm_data[search]%", "%$frm_data[search]%", "pending", 0], 'ssssss');
|
|
$i = 1;
|
|
$table_data = "";
|
|
|
|
if(mysqli_num_rows($res)==0){
|
|
echo "No data available";
|
|
exit;
|
|
}
|
|
|
|
while($data = mysqli_fetch_assoc($res)){
|
|
$date = date("M-d-Y", strtotime($data['datentime']));
|
|
$checkin = date("M-d-Y", strtotime($data['check_in']));
|
|
$checkout = date("M-d-Y", strtotime($data['check_out']));
|
|
|
|
$table_data .= "
|
|
<tr>
|
|
<td>$i</td>
|
|
<td> $data[user_name] $data[user_lastname]<br>
|
|
</td>
|
|
<td>$data[order_id]</td>
|
|
<td style='font-size: 14px;'>
|
|
<b>Room:</b> $data[room_name]<br>
|
|
<b>Price:</b> $$data[price]/night<br>
|
|
<b>Total:</b> $$data[total_pay]
|
|
</td>
|
|
<td style='font-size: 14px;'>
|
|
<b>Book date:</b> $date<br>
|
|
<b>Check-in:</b> $checkin<br>
|
|
<b>Check-out:</b> $checkout<br>
|
|
</td>
|
|
<td>
|
|
<button type='button' onclick='room_number($data[booking_id])' class='btn-third text-white fw-bold mb-2' style='font-size: 12px;' data-bs-toggle='modal' data-bs-target='#room-number'>Room Number</button><br>
|
|
<button type='button' onclick='cancel_booking($data[booking_id])' class='btn-cancel text-white fw-bold' style='font-size: 12px;'>Cancel Booking</button>
|
|
</td>
|
|
</tr>
|
|
";
|
|
$i++;
|
|
}
|
|
echo $table_data;
|
|
|
|
}
|
|
|
|
if(isset($_POST['room_number'])){
|
|
$frm_data = filteration($_POST);
|
|
$query = "UPDATE `booking_order` bo INNER JOIN `booking_detail` bd ON bo.booking_id = bd.booking_id SET bo.arrival = ?, bo.review = ?, bd.room_no = ? WHERE bo.booking_id = ?";
|
|
$values = [1, 0, $frm_data['room_no'], $frm_data['booking_id']];
|
|
$res = update($query, $values, 'iisi');
|
|
|
|
echo ($res == 2) ? 1 : 0;
|
|
}
|
|
|
|
if(isset($_POST['cancel_booking'])){
|
|
$frm_data = filteration($_POST);
|
|
$query = "UPDATE `booking_order` SET `booking_status` =? WHERE booking_id =?";
|
|
$values = ['cancel', $frm_data['booking_id']];
|
|
$res = update($query, $values, 'si');
|
|
|
|
echo $res;
|
|
}
|
|
|
|
|
|
|
|
?>
|