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

147 lines
5.1 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="../user/home.css?version=1" type="text/css" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.hotel{
background-color:rgba(355,355,355,0.7);
width:45%;
margin:0 auto;
cursor:pointer;
}
</style>
</head>
<body>
<header>
<div class="logo">
<a href="home.php"><img src="../../icon/favicon/logo_white.svg" alt="RoamEase"></a>
</div>
<div class="nav-links">
<a href="../seller_add/stays.php">Add</a>
<a href="../../login/interfaces/profile_seller.php">Account</a>
</div>
</header>
<header>
<nav>
<a href="stays.php">
<img src="../../icon/header/stays.svg" alt="Stays">
</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>
</nav>
</header>
<script>
window.onload = function() {
myFunction();
};
</script>
<div id="pageContainer" style="display: block; ">
</div>
<div id="pageButtons" class="buttonDiv"></div>
<script>
var currentPage = 1;
var totalPages = 1;
var judge=1;
function myFunction() {
var input = "";
var filter = input;
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var response = JSON.parse(this.responseText);
var data = response.data;
totalPages = response.total_pages;
var html = '';
if (data[0]=="No result"){
html="<p style='text-align:center; font-size:40px;'>You don't have any hotel.</p>";
judge=0;
}else{
html+='<div style="font-size: 40px; color: black;text-align: center;">Here is the hotel you have.</div><br><br>';
for (var i = 0; i < data.length; i++) {
html += '<div class="hotel" style="cursor:default;">';
html += '<table style="border: none; cursor:pointer;">';
html += '<tr><td rowspan="5"><img width=130; height=100; src="data:image/jpeg;base64,'+data[i].image+'" alt="Hotel Image"></td>';
html += '<td>Name</td><td><p style="font-size:20px; font-family: Times New Roman, Times, serif;">' + data[i].hname + '</p></td></tr>';
html += '<tr><td>City</td><td>' + data[i].cname + '</td></tr>';
html += '<tr><td>Rating</td><td>';
for (var j = 0; j < 5; j++) {
if (j < Math.floor(data[i].rating)) {
html += '<img width="30" height="30" src="../../icon/filled_star.svg" alt="Filled Star">';
} else if (j < data[i].rating && data[i].rating - j < 1) {
html += '<img width="30" height="30" src="../../icon/half_star.svg" alt="Half Star">';
} else {
html += '<img width="30" height="30" src="../../icon/empty_star.svg" alt="Empty Star">';
}
}
html += '</td></tr>';
html += '<tr><td>Type</td><td>' + data[i].hotel_type_name + '</td></tr>';
html += '</table>';
html += '<button style="width: 10%; height: 40px;" onclick="deleteFunction(\'' + data[i].hotel_id + '\')" >Delete</button>';
html += '</div><br>';
}
html += '<p style="text-align:center; font-size:30px;">Current page:' + currentPage+'</p>';
}
document.getElementById("pageContainer").innerHTML = html;
}
};
xmlhttp.open("GET", "getHotel.php?q="+filter+"&page="+currentPage, true);
xmlhttp.send();
}
function deleteFunction(id) {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var response = JSON.parse(this.responseText);
var time=response.time;
time=time.toFixed(6);
alert('Successfully delete. Running time: '+time+'s');
}
};
xmlhttp.open("POST", "deleteHotel.php", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send("restaurantId=" + id);
}
function formatDate(date) {
var year = date.getFullYear();
var month = (date.getMonth() + 1).toString().padStart(2, '0');
var day = date.getDate().toString().padStart(2, '0');
return year + '-' + month + '-' + day;
}
</script>
</div>
<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>
</body>
</html>