2025-06-06 17:31:03 +08:00

327 lines
10 KiB
PHP

<?php
session_start();
include '../ConnectDB.php';
$uid = $_SESSION['uid'] ?? 0;
$data = $_GET;
$data['page'] = $data['page'] ?? 1;
$data['pageSize'] = 5;
$sql = "select * from bookings where uid = {$uid} ";
$result = mysqli_query($conn, $sql);
$result = mysqli_fetch_all($result, MYSQLI_ASSOC);
$total = count($result);
$totalPage = ceil($total / $data['pageSize']);
$offset = ($data['page'] - 1) * $data['pageSize'];
$sql = "select * from bookings where uid = {$uid} limit {$offset},{$data['pageSize']} ";
$result = mysqli_query($conn, $sql);
$result = mysqli_fetch_all($result, MYSQLI_ASSOC);
foreach ($result as $k => $v) {
$table = [
'attraction_booking',
'hotel_booking',
'restaurant_booking',
'guide_booking',
'transport_flight_booking',
'transport_railway_booking'
];
foreach ($table as $item) {
if ($item == 'hotel_booking') {
$sql = "select h.name,hy.room_type_name,t1.price as fee from $item as t
join hotel_room as t1 on t1.hotel_room_id = t.hotel_room_id
join hotel as h on t1.hotel_id = h.hotel_id
join hotel_room_type as hy on hy.room_type_id = t1.room_type_id
where booking_id = " . $v['booking_id'];
}
if ($item == 'attraction_booking') {
$sql = "select a.name,a.price as fee from $item as t
join attraction as a on a.attraction_id =t.attraction_id
where booking_id = " . $v['booking_id'];
}
if ($item == 'restaurant_booking') {
$sql = "select t1.name,t1.fee from $item as t
join restaurant as t1 on t1.restaurant_id = t.restaurant_id
where booking_id = " . $v['booking_id'];
}
if ($item == 'guide_booking') {
$sql = "select g.username,g.fee from $item as t
join user_guide as g on g.u_id = t.guide_id
where booking_id = " . $v['booking_id'];
}
if ($item == 'transport_flight_booking') {
$sql = "select flight_code, class, fc.fee from $item as t
join transport_flight_class as fc on fc.flight_class_id = t.flight_class_id
join transport_flight as f on f.flight_id = fc.flight_id
join transport_airline as a on a.airline_id = f.airline_id
where booking_id = " . $v['booking_id'];
}
if ($item == 'transport_railway_booking') {
$sql = "select train_code, class, rs.fee from $item as t
join transport_railway_class as rs on rs.train_seat_id = t.railway_class_id
join transport_railway as r on r.train_id = rs.train_id
where booking_id = " . $v['booking_id'];
}
$result2 = mysqli_query($conn, $sql);
$result2 = mysqli_fetch_all($result2, MYSQLI_ASSOC);
$result[$k][$item] = $result2;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Plans@Roamease</title>
<link rel="shortcut icon" href="../../icon/favicon/favicon.ico" type="image/x-icon" />
<link rel="icon" href="../../icon/favicon/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="./home.css?version=1" type="text/css" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.pagebutton1{
width:120px;
height:50px;
}
.pagebutton2{
width:120px;
height:50px;
}
.receipt{
background-color:rgba(240,220,200,0.5);
}
.day-plan {
background-color:rgba(355,355,355,0.7);
width:750px;
margin:0 auto;
cursor:pointer;
}
.buttonAdd{
background-color: #28a745;
border: none;
color: white;
padding: 10px 20px;
text-decoration: none;
display: inline-block;
border-radius: 5px;
transition:background-color 0.3s ease;
cursor:pointer;
}
.buttonAdd:hover{
background-color:#28a745;
}
.buttonAdd:active{
background-color:green;
transform: translateY(1px);
}
th{
text-align:left;
}
table, th {
border-bottom: 2px solid grey;
}
.tablePlan{
border-radius:0px;
border-right: 1px solid black;
border-left: 1px solid black;
border-top: 1px solid white;
}
</style>
</head>
<body>
<header>
<div class="logo">
<a href="../../index.php"><img src="../../icon/favicon/logo_white.svg" alt="RoamEase"></a>
</div>
<div class="nav-links">
<?php
if (isset($_SESSION['loggedin'])) {
echo '<a href="./process/cart.php">Cart</a>
<a href="../../login/login.php">Account</a>';
}
else {
echo '<a href="../../login/register.php">Sign up</a>
<a href="../../login/username.php">Log in</a>';
}
?>
</div>
</header>
<header>
<nav>
<a href="stays.php">
<img src="../../icon/header/stays.svg" alt="Stays">
</a>
<a href="transport.php">
<img src="../../icon/header/transportations.svg" alt="Transportations">
</a>
<a href="foods.php">
<img src="../../icon/header/foods.svg" alt="Foods">
</a>
<a href="attractions.php">
<img src="../../icon/header/attractions.svg" alt="Attractions">
</a>
<a href="guiding.php">
<img src="../../icon/header/guiding.svg" alt="Guiding">
</a>
<a href="plans.php" style="border-color: white;">
<img src="../../icon/header/plans.svg" alt="Plans">
</a>
</nav>
</header>
<div >
<div class="buttonAdd" style="margin-top: 20px;margin-bottom: 20px;" onclick="addPlan()">
<a href="#" style="text-decoration: none; color:white; font-size:19px;" class="btn btn-success" >Add Plan</a>
</div>
<script>
function addPlan() {
var day = prompt("Enter the day:");
if (day !== null) {
var url = "./plans_do.php?type=add&day=" + encodeURIComponent(day);
window.location.href = url;
}
}
</script>
<div>
<table class="tablePlan" style="width:90%; ">
<thead>
<tr border-bottom: 1px>
<th scope="col">Day</th>
<th scope="col">Hotel Name</th>
<th scope="col">Attraction Name</th>
<th scope="col">Restaurant Name</th>
<th scope="col">Guiding Name</th>
<th scope="col">Flight</th>
<th scope="col">Railway</th>
<th scope="col">Total Fee</th>
<th scope="col">Operate</th>
</tr>
</thead>
<tbody>
<?php
foreach ($result as $k => $v) {
$total = 0;
?>
<tr>
<td>
<p><?php echo $v['day'] . ' DAY'; ?></p>
<a class="buttonAdd" href="plans_do.php?type=change&id=<?php echo $v['booking_id'];?>" >
<?php
if (isset($_SESSION['bid']) && $_SESSION['bid'] == $v['booking_id']) {
echo '<b><i>Current</b></i>';
} else {
echo 'select';
}
?>
</a>
</td>
<td>
<?php foreach ($v['hotel_booking'] as $v1) {
$total = bcadd($total, $v1['fee'], 2);
?>
<p>
<?php echo $v1['name'] . '--' . $v1['room_type_name'] . '--¥' . $v1['fee']; ?>
</p>
<?php } ?>
</td>
<td>
<?php foreach ($v['attraction_booking'] as $v1) {
$total = bcadd($total, $v1['fee'], 2);
?>
<p>
<?php echo $v1['name'] . '--¥' . $v1['fee']; ?>
</p>
<?php } ?>
</td>
<td>
<?php foreach ($v['restaurant_booking'] as $v1) {
$total = bcadd($total, $v1['fee'], 2);
?>
<p>
<?php echo $v1['name'] . '--¥' . $v1['fee']; ?>
</p>
<?php } ?>
</td>
<td>
<?php foreach ($v['guide_booking'] as $v1) {
$total = bcadd($total, $v1['fee'], 2);
?>
<p>
<?php echo $v1['username'] . '--¥' . $v1['fee']; ?>
</p>
<?php } ?>
</td>
<td>
<?php foreach ($v['transport_flight_booking'] as $v1) {
$total = bcadd($total, $v1['fee'], 2);
?>
<p>
<?php echo $v1['flight_code'] . '--' . $v1['class'] . '--¥' . $v1['fee']; ?>
</p>
<?php } ?>
</td>
<td>
<?php foreach ($v['transport_railway_booking'] as $v1) {
$total = bcadd($total, $v1['fee'], 2);
?>
<p>
<?php echo $v1['train_code'] . '--' . $v1['class'] . '--¥' . $v1['fee']; ?>
</p>
<?php } ?>
</td>
<td>
<?php echo $total; ?>
</td>
<td>
<a href="./plans_do.php?type=reset&id=<?php echo $v['booking_id']?>" class="buttonAdd">Reset Day</a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>