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

131 lines
5.8 KiB
PHP

<html>
<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">
<header>
<style>
.pagebutton{
background-color: #ADD8FF;
border: none;
color: white;
text-decoration: none;
display: inline-block;
font-size: 13px;
width:15%;
border-radius: 10px;
font-size:17px;
transition:background-color 0.3s ease;
}
</style>
<div class="logo">
<a href="../home.php"><img src="../../../icon/favicon/logo_white.svg" alt="RoamEase"></a>
</div>
<div class="nav-links">
<?php
session_start();
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" style="border-color: white;">
<img src="../../../icon/header/guiding.svg" alt="Guiding">
</a>
<a href="../plans.php">
<img src="../../../icon/header/plans.svg" alt="Plans">
</a>
</nav>
</header>
<style>
table tr td:first-child {
width: 160px;
}
</style>
<script>
var attractionDetail; // Declare globally
var aid; // Declare globally
function GoodFunction(){
var urlParams = new URLSearchParams(window.location.search);
aid = urlParams.get('id');
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
attractionDetail = JSON.parse(this.responseText);
console.log(attractionDetail);
var detailHtml = '<table style="border-collapse: collapse; width:100%; height:70%; margin-top:-1.1%;">';
detailHtml += '<tr><td>Name</td><td>' + attractionDetail[0].username + '</td></tr>';
detailHtml += '<tr><td>Working age</td><td>' + attractionDetail[0].working_age + '</td></tr>';
detailHtml += '<tr><td>Type</td><td>' + attractionDetail[0].guide_type_name + '</td></tr>';
detailHtml += '<tr><td>Fee</td><td>' + attractionDetail[0].fee+ 'RMB</td></tr>';
detailHtml += '<tr><td> &nbsp</td><td></td>&nbsp</tr>';
detailHtml += '<tr><td style="vertical-align:top">Description</td><td style="vertical-align:top">' + attractionDetail[0].descrip + '</td></tr>';
detailHtml += '<tr><td><div class="input-field with button"><input type="date" id="start_date" class="edit-button" name="start_date" style="border:none;" onchange="setMinEndDate()" onkeydown="return false" required><label for="start_date">Visit date</label></td>';
detailHtml += '<td><div class="input-field with button"><input type="date" id="end_date" class="edit-button" name="end_date" style="border:none;" onchange="setMinEndDate()" onkeydown="return false" required><label for="end_date">End date</label></td>';
detailHtml += '<td><div class="input-field"><input type="number" id="quantity" name="quantity" placeholder=" " required value=""><label for="quantity">Quantity</label></div></td></tr>';
detailHtml += '<tr><td><button id="add_cart">Add cart</button></td></tr>';
detailHtml += '</table>';
detailHtml +='<a href="../guiding.php" style="text-decoration:none;"><button class="pageButton">Go back</button></a>';
detailHtml +='<a href="../guiding.php" style="text-decoration:none;"><button class="pageButton">Go back</button></a>';
document.getElementById("detail").innerHTML = detailHtml;
}
document.getElementById('add_cart').addEventListener('click', add_cart);
}
xmlhttp.open("GET", "getGuInfo.php?id=" + aid, true);
xmlhttp.send();
}
function add_cart() {
let start_date = document.getElementById("start_date").value;
let end_date = document.getElementById("end_date").value;
let quantity = document.getElementById("quantity").value;
let price = attractionDetail[0].price; // Now accessible
window.location.href = '../addcart.php?target_id=' + aid + '&start_date=' + start_date + '&end_date=' + end_date + '&quantity=' + quantity + '&table=4&price=' + price;
}
GoodFunction();
</script>
<div id="detail"></div><br><br><br>
<footer>
<div class="logo">
<a href="../../../index.php"><img src="../../../icon/favicon/textlogo.svg" alt="RoamEase" height="50px"></a>
<p style="font-size:10%;">©2023 COMP3013 Group10</p>
</div>
<div class="nav-links" style="font-size: 80%;">
<a href="#" style="color: white; margin: 0 10px;">About us</a>
<a href="#" style="color: white; margin: 0 10px;">Privacy Policy</a>
<a href="#" style="color: white; margin: 0 10px;">Terms For Usage</a>
</div>
</footer>
</html>