305 lines
9.5 KiB
PHP
305 lines
9.5 KiB
PHP
<html>
|
|
<head>
|
|
<title>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;
|
|
|
|
}
|
|
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
<body>
|
|
<?php
|
|
include "../ConnectDB.php";
|
|
// Start the session
|
|
session_start();
|
|
// Check if the user is already logged in
|
|
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {
|
|
if(isset($_SESSION['user_type']) && $_SESSION['user_type'] === 'seller'){
|
|
echo "<script type='text/javascript'>
|
|
window.top.location.href = '../seller/home.php';
|
|
</script>";
|
|
}
|
|
if(isset($_SESSION['user_type']) && $_SESSION['user_type'] === 'admin'){
|
|
echo "<script type='text/javascript'>
|
|
window.top.location.href = '../admin/home.php';
|
|
</script>";
|
|
}
|
|
if(isset($_SESSION['user_type']) && $_SESSION['user_type'] === 'guide'){
|
|
echo "<script type='text/javascript'>
|
|
window.top.location.href = '../guide/home.php';
|
|
</script>";
|
|
}
|
|
}
|
|
?>
|
|
|
|
<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>
|
|
|
|
<body>
|
|
<h1>Travel Plan</h1>
|
|
|
|
<?php
|
|
if (session_status() == PHP_SESSION_NONE) {
|
|
session_start();
|
|
}
|
|
|
|
if (!isset($_SESSION['visit_date'])) {
|
|
$_SESSION['visit_date'] = 1;
|
|
}
|
|
|
|
if (isset($_GET['nextday'])) {
|
|
$_SESSION['visit_date'] += 1;
|
|
}
|
|
if (!isset($_SESSION['page'])) {
|
|
$_SESSION['page'] = 1;
|
|
}
|
|
if (isset($_GET['nextpage'])) {
|
|
$_SESSION['page'] += 1;
|
|
}
|
|
if (isset($_GET['lastpage']) && $_SESSION['page'] > 1) {
|
|
$_SESSION['page'] -= 1;
|
|
}
|
|
|
|
$start_day = ($_SESSION['page'] - 1) * 3 + 1;
|
|
$end_day = $start_day + 2;
|
|
|
|
|
|
if (isset($_GET['resetday'])) {
|
|
$_SESSION['visit_date'] = 1;
|
|
|
|
|
|
$sql = "DELETE FROM stay_plan";
|
|
if ($conn->query($sql) !== TRUE) {
|
|
echo "Error: " . $sql . "<br>" . $conn->error;
|
|
}
|
|
|
|
|
|
$sql = "DELETE FROM restaurant_booking";
|
|
if ($conn->query($sql) !== TRUE) {
|
|
echo "Error: " . $sql . "<br>" . $conn->error;
|
|
}
|
|
|
|
|
|
$sql = "DELETE FROM attraction_plan";
|
|
if ($conn->query($sql) !== TRUE) {
|
|
echo "Error: " . $sql . "<br>" . $conn->error;
|
|
}
|
|
|
|
|
|
$sql = "DELETE FROM guide_plan";
|
|
if ($conn->query($sql) !== TRUE) {
|
|
echo "Error: " . $sql . "<br>" . $conn->error;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$visit_date = $_SESSION['visit_date'];
|
|
|
|
if (isset($_GET['hotel_id'])) {
|
|
$hotel_id = $_GET['hotel_id'];
|
|
$sql = "INSERT INTO hotel_booking (visit_date, hotel_id) VALUES ('$visit_date', '$hotel_id')";
|
|
if ($conn->query($sql) === TRUE) {
|
|
echo "New record created successfully";
|
|
} else {
|
|
echo "Error: " . $sql . "<br>" . $conn->error;
|
|
}
|
|
}
|
|
|
|
if (isset($_GET['restaurant_id'])) {
|
|
$restaurant_id = $_GET['restaurant_id'];
|
|
$sql = "INSERT INTO restaurant_booking (visit_date,booking_id, restaurant_id) VALUES ('$visit_date','$booking_id', '$restaurant_id')";
|
|
if ($conn->query($sql) === TRUE) {
|
|
echo "New record created successfully";
|
|
} else {
|
|
echo "Error: " . $sql . "<br>" . $conn->error;
|
|
}
|
|
}
|
|
if (isset($_GET['attraction_id'])) {
|
|
$attraction_id = $_GET['attraction_id'];
|
|
$sql = "INSERT INTO attraction_booking (visit_date, booking_id, attraction_id) VALUES ('$visit_date', '$booking_id', '$attraction_id')";
|
|
if ($conn->query($sql) === TRUE) {
|
|
echo "New record created successfully";
|
|
} else {
|
|
echo "Error: " . $sql . "<br>" . $conn->error;
|
|
}
|
|
}
|
|
if (isset($_GET['u_id'])) {
|
|
$u_id = $_GET['u_id'];
|
|
$sql = "INSERT INTO guide_booking (visit_date, booking_id, guide_id) VALUES ('$visit_date', '$booking_id', '$u_id')";
|
|
if ($conn->query($sql) === TRUE) {
|
|
echo "New record created successfully";
|
|
} else {
|
|
echo "Error: " . $sql . "<br>" . $conn->error;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//echo "<div class='day-plan'>";
|
|
// echo "<table><tr><th>Day</th><th>Hotel Name</th><th>Restaurant Name</th><th>Attraction Name</th><th>Guiding Name</th></tr>";
|
|
|
|
for ($visit_date = $start_day; $visit_date <= min($end_day, $_SESSION['visit_date']); $visit_date++){
|
|
|
|
echo "<table><tr><th>Day</th><th>Hotel Name</th><th>Restaurant Name</th><th>Attraction Name</th><th>Guiding Name</th></tr>";
|
|
|
|
$sql = "SELECT hotel_id FROM hotel_booking WHERE visit_date = $visit_date";
|
|
$result = $conn->query($sql);
|
|
$hotel_ids = [];
|
|
while ($row = $result->fetch_assoc()) {
|
|
$hotel_ids[] = $row["hotel_id"];
|
|
}
|
|
$hotel_names = [];
|
|
foreach ($hotel_ids as $hotel_id) {
|
|
$sql = "SELECT name FROM hotel WHERE hotel_id = $hotel_id";
|
|
$result = $conn->query($sql);
|
|
if ($row = $result->fetch_assoc()) {
|
|
$hotel_names[] = $row["name"];
|
|
}
|
|
}
|
|
$hotel_name = count($hotel_names) > 0 ? implode(", ", $hotel_names) : "No stay plan";
|
|
|
|
$sql = "SELECT restaurant_id FROM restaurant_booking WHERE visit_date = $visit_date";
|
|
$result = $conn->query($sql);
|
|
$restaurant_ids = [];
|
|
while ($row = $result->fetch_assoc()) {
|
|
$restaurant_ids[] = $row["restaurant_id"];
|
|
}
|
|
|
|
$restaurant_names = [];
|
|
foreach ($restaurant_ids as $restaurant_id) {
|
|
$sql = "SELECT name FROM restaurant WHERE restaurant_id = $restaurant_id";
|
|
$result = $conn->query($sql);
|
|
if ($row = $result->fetch_assoc()) {
|
|
$restaurant_names[] = $row["name"];
|
|
}
|
|
}
|
|
$restaurant_name = count($restaurant_names) > 0 ? implode(", ", $restaurant_names) : "No food plan";
|
|
|
|
$sql = "SELECT attraction_id FROM transport_flight_booking WHERE visit_date = $visit_date";
|
|
$result = $conn->query($sql);
|
|
$attraction_ids = [];
|
|
while ($row = $result->fetch_assoc()) {
|
|
$attraction_ids[] = $row["attraction_id"];
|
|
}
|
|
|
|
$attraction_names = [];
|
|
foreach ($attraction_ids as $attraction_id) {
|
|
$sql = "SELECT name FROM attraction WHERE attraction_id = $attraction_id";
|
|
$result = $conn->query($sql);
|
|
if ($row = $result->fetch_assoc()) {
|
|
$attraction_names[] = $row["name"];
|
|
}
|
|
}
|
|
$attraction_name = count($attraction_names) > 0 ? implode(", ", $attraction_names) : "No attraction plan";
|
|
|
|
$sql = "SELECT guide_id FROM guide_booking WHERE visit_date = $visit_date";
|
|
$result = $conn->query($sql);
|
|
$guide_ids = [];
|
|
while ($row = $result->fetch_assoc()) {
|
|
$guide_ids[] = $row["guide_id"];
|
|
}
|
|
|
|
$guide_names = [];
|
|
foreach ($guide_ids as $guide_id) {
|
|
$sql = "SELECT username FROM guide WHERE u_id = $guide_id";
|
|
$result = $conn->query($sql);
|
|
if ($row = $result->fetch_assoc()) {
|
|
$guide_names[] = $row["username"];
|
|
}
|
|
}
|
|
$guide_name = count($guide_names) > 0 ? implode(", ", $guide_names) : "No guiding plan";
|
|
|
|
|
|
echo "<tr><td>Day " . $day . "</td><td>" . $hotel_name . "</td><td>" . $restaurant_name . "</td><td>" . $attraction_name . "</td><td>" . $guide_name . "</td></tr></table>";
|
|
|
|
echo "</div>";
|
|
echo "</table>";
|
|
|
|
}
|
|
|
|
|
|
$conn->close();
|
|
?>
|
|
</body>
|
|
|
|
<div style="text-align: center; margin: 20px 0;" >
|
|
<p style="font-size:25px">Current page: <?php echo $_SESSION['page']; ?></p>
|
|
<button class="pagebutton1" onclick="window.location.href='?nextday=1'">Next Day</button>
|
|
<button class="pagebutton1" onclick="window.location.href='?resetday=1'">Reset Day</button>
|
|
<button class="pagebutton2" onclick="if (<?php echo $_SESSION['day']; ?> > <?php echo $_SESSION['page'] * 3; ?>) window.location.href='?nextpage=1'">Next Page</button>
|
|
<button class="pagebutton2" onclick="window.location.href='?lastpage=1'">Last Page</button>
|
|
</div>
|
|
</div>
|
|
<div style="text-align: center; margin: 0px 0; " class="receipt">
|
|
<a href="receipt.html" class="bottom-link" style="color:white;font-size:25px; background-color:rgba(225,249,255,0.5)">confirm.</a><br><br>
|
|
<a href="recharge.html" class="bottom-link" style="color:white;font-size:25px; background-color:rgba(225,249,255,0.5)">if you don't have enough money,click here to recharge.</a>
|
|
<br><br><br><br><br><br>
|
|
</html>
|