Initial Commit
This commit is contained in:
129
indexes/user/process/cart.css
Normal file
129
indexes/user/process/cart.css
Normal file
@@ -0,0 +1,129 @@
|
||||
#grid{
|
||||
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
flex-wrap: wrap;
|
||||
margin: none;
|
||||
border: none;
|
||||
width: 100%;
|
||||
left:1.5%;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
font-style: rgb(10, 22, 44);
|
||||
user-select: none;
|
||||
}
|
||||
#items{
|
||||
text-align: center;
|
||||
background-color: rgba(255, 255, 255, 0.4);
|
||||
color: black;
|
||||
font-size: 200%;
|
||||
border-radius: 12px;
|
||||
backdrop-filter: blur(4px);
|
||||
margin: 1%;
|
||||
margin-right: 4%;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
font-style: rgb(10, 22, 44);
|
||||
user-select: none;
|
||||
width: 95%;
|
||||
height: 5vw;
|
||||
transition: 0.3s;
|
||||
}
|
||||
#items img{
|
||||
border-radius: 12px;
|
||||
width:40%;
|
||||
height: 40%;
|
||||
margin: none;
|
||||
padding: none;
|
||||
overflow:hidden;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
-webkit-background-size:cover;
|
||||
-moz-background-size:cover;
|
||||
background-size:cover;
|
||||
cursor: hand;
|
||||
transition: 0.5s;
|
||||
}
|
||||
#icon{
|
||||
border-radius: 12%;
|
||||
width: 6%;
|
||||
height: 6%;
|
||||
overflow:hidden;
|
||||
cursor: hand;
|
||||
transition: 0.5s;
|
||||
}
|
||||
#items:hover{
|
||||
box-shadow: 0px 0px 10px rgb(106, 104, 104);
|
||||
}
|
||||
p,h5:hover{
|
||||
cursor: hand;
|
||||
}
|
||||
input{
|
||||
font-size: 80%;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
background-color: #00000000;
|
||||
border: none;
|
||||
outline: none;
|
||||
}
|
||||
input:focus{
|
||||
border-bottom: 2px solid red;
|
||||
width: 80%;
|
||||
}
|
||||
#detail_window{
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
transform: scale(1.7);
|
||||
/* 垂直居中 */
|
||||
top: 10%;
|
||||
bottom: 0;
|
||||
height: 50%;
|
||||
/* 水平居中 */
|
||||
left: 0%;
|
||||
right: 0%;
|
||||
width: 57%;
|
||||
margin: auto;
|
||||
|
||||
user-select: none;
|
||||
background-color: rgba(239, 230, 230, 0.5);
|
||||
border: 0px;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0px 0px 16px rgb(70, 69, 69);
|
||||
backdrop-filter: blur(20px);
|
||||
}
|
||||
#overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(109, 103, 103, 0.6);
|
||||
backdrop-filter: blur(4px);
|
||||
z-index: 10000;
|
||||
}
|
||||
#closebutton{
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
transform: scale(1.4);
|
||||
top: 14%;
|
||||
height: 2.2%;
|
||||
margin-left: 95%;
|
||||
width: 2.2%;
|
||||
font-size: 80%;
|
||||
user-select: none;
|
||||
border: 0px;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0px 0px 16px rgb(142, 142, 142);
|
||||
}
|
||||
#closebutton:hover{
|
||||
background-color: red;
|
||||
}
|
||||
button{
|
||||
height: 32px;
|
||||
width: 300px;
|
||||
border: solid white 0px;
|
||||
background: linear-gradient(to right, rgb(26, 117, 172), rgb(26, 158, 144));
|
||||
color: white;
|
||||
cursor: hand;
|
||||
box-shadow: 0px 0px 0px #424242;
|
||||
transition: 0.3s;
|
||||
border-radius: 5px;
|
||||
}
|
||||
306
indexes/user/process/cart.php
Normal file
306
indexes/user/process/cart.php
Normal file
@@ -0,0 +1,306 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Cart</title>
|
||||
<script src="iframe.js"></script>
|
||||
<script src="./item_modify.js"></script>
|
||||
<link rel="stylesheet" href="./cart.css" type="text/css" />
|
||||
<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">
|
||||
</head>
|
||||
|
||||
<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['usertype']) && !$_SESSION['usertype'] === 'buyer'){
|
||||
header('Location: ../../../index.php');
|
||||
}
|
||||
}
|
||||
else{
|
||||
header('Location: ../../../index.php');
|
||||
}
|
||||
$u_id = $_SESSION['uid'];
|
||||
?>
|
||||
|
||||
<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="./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">
|
||||
<img src="../../../icon/header/plans.svg" alt="Plans">
|
||||
</a>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<div id="grid">
|
||||
|
||||
<?php
|
||||
$username = mysqli_real_escape_string($conn, $_SESSION['username']);
|
||||
$uid = mysqli_real_escape_string($conn, $_SESSION['uid']);
|
||||
|
||||
$sql_cart_bookings = "SELECT * FROM cart_bookings WHERE u_id='$u_id'";
|
||||
$result_cart_bookings = mysqli_query($conn, $sql_cart_bookings);
|
||||
$num_rows = mysqli_num_rows($result_cart_bookings);
|
||||
|
||||
while ($cartBooking = mysqli_fetch_assoc($result_cart_bookings)) {
|
||||
$booking_id = $cartBooking['booking_id'];
|
||||
// Use a switch statement for different booking types
|
||||
switch ($cartBooking['booking_type_id']) {
|
||||
case '1':
|
||||
$bookingQuery = "SELECT * FROM hotel_booking WHERE booking_id = " . $booking_id;
|
||||
$bookingResult = mysqli_query($conn, $bookingQuery);
|
||||
$bookingDetails = mysqli_fetch_assoc($bookingResult);
|
||||
|
||||
$quantity = $bookingDetails['quantity'];
|
||||
$id = $bookingDetails['hotel_room_id'];
|
||||
$start_date = $bookingDetails['start_date'];
|
||||
$end_date = $bookingDetails['end_date'];
|
||||
|
||||
$productQuery = "SELECT hotel_room.hotel_id, hotel_room.price, hotel_room_type.room_type_image, hotel.name, hotel_room_type.room_type_name FROM hotel_room JOIN hotel ON (hotel_room.hotel_id = hotel.hotel_id) JOIN hotel_room_type ON (hotel_room.room_type_id = hotel_room_type.room_type_id) WHERE hotel_room_id = " . $bookingDetails['hotel_room_id'];
|
||||
$bookingResult = mysqli_query($conn, $productQuery);
|
||||
$productDetails = mysqli_fetch_assoc($bookingResult);
|
||||
|
||||
$price = $productDetails['price'];
|
||||
$img = $productDetails['room_type_image'];
|
||||
$name = $productDetails['name'] . " - " . $productDetails['room_type_name'];
|
||||
|
||||
break;
|
||||
case '2':
|
||||
$bookingQuery = "SELECT * FROM restaurant_booking WHERE booking_id = " . $booking_id;
|
||||
$bookingResult = mysqli_query($conn, $bookingQuery);
|
||||
$bookingDetails = mysqli_fetch_assoc($bookingResult);
|
||||
|
||||
$quantity = $bookingDetails['quantity'];
|
||||
$id = $bookingDetails['restaurant_id'];
|
||||
$start_date = $bookingDetails['visit_date'];
|
||||
$end_date = null;
|
||||
|
||||
$productQuery = "SELECT name, fee, restaurant_style.restaurant_style_image FROM restaurant JOIN restaurant_style ON (restaurant.restaurant_style_id = restaurant_style.restaurant_style_id) WHERE restaurant_id = " . $bookingDetails['restaurant_id'];
|
||||
$bookingResult = mysqli_query($conn, $productQuery);
|
||||
$productDetails = mysqli_fetch_assoc($bookingResult);
|
||||
|
||||
$price = $productDetails['fee'];
|
||||
$img = $productDetails['restaurant_style_image'];
|
||||
$name = $productDetails['name'];
|
||||
|
||||
break;
|
||||
case '3':
|
||||
$bookingQuery = "SELECT * FROM attraction_booking WHERE booking_id = " . $booking_id;
|
||||
$bookingResult = mysqli_query($conn, $bookingQuery);
|
||||
$bookingDetails = mysqli_fetch_assoc($bookingResult);
|
||||
|
||||
$quantity = $bookingDetails['quantity'];
|
||||
$id = $bookingDetails['attraction_id'];
|
||||
$start_date = $bookingDetails['visit_date'];
|
||||
$end_date = null;
|
||||
|
||||
$productQuery = "SELECT name, price, attraction_type.attraction_type_image FROM attraction JOIN attraction_type ON (attraction.attraction_type_id = attraction_type.attraction_type_id) WHERE attraction_id = " . $bookingDetails['attraction_id'];
|
||||
$bookingResult = mysqli_query($conn, $productQuery);
|
||||
$productDetails = mysqli_fetch_assoc($bookingResult);
|
||||
|
||||
$price = $productDetails['price'];
|
||||
$img = $productDetails['attraction_type_image'];
|
||||
$name = $productDetails['name'];
|
||||
|
||||
break;
|
||||
case '4':
|
||||
$bookingQuery = "SELECT * FROM guide_booking WHERE booking_id = " . $booking_id;
|
||||
$bookingResult = mysqli_query($conn, $bookingQuery);
|
||||
$bookingDetails = mysqli_fetch_assoc($bookingResult);
|
||||
|
||||
$quantity = $bookingDetails['quantity'];
|
||||
$id = $bookingDetails['guide_id'];
|
||||
$start_date = $bookingDetails['start_date'];
|
||||
$end_date = $bookingDetails['end_date'];
|
||||
|
||||
$productQuery = "SELECT user_guide.username, user_guide.fee, user_guide.avatar FROM user_guide WHERE u_id = " . $bookingDetails['guide_id'];
|
||||
$bookingResult = mysqli_query($conn, $productQuery);
|
||||
$productDetails = mysqli_fetch_assoc($bookingResult);
|
||||
|
||||
$price = $productDetails['fee'];
|
||||
$img = $productDetails['avatar'];
|
||||
$name = $productDetails['username'];
|
||||
|
||||
break;
|
||||
case '5':
|
||||
$bookingQuery = "SELECT * FROM transport_flight_booking WHERE booking_id = " . $booking_id;
|
||||
$bookingResult = mysqli_query($conn, $bookingQuery);
|
||||
$bookingDetails = mysqli_fetch_assoc($bookingResult);
|
||||
|
||||
$quantity = $bookingDetails['quantity'];
|
||||
$id = $bookingDetails['flight_class_id'];
|
||||
$start_date = $bookingDetails['visit_date'];
|
||||
$end_date = null;
|
||||
|
||||
$productQuery = "SELECT transport_flight_class.flight_id, transport_flight_class.class, transport_flight_class.fee, transport_flight.flight_code, transport_flight.takeoff_time, transport_flight.landing_time FROM transport_flight_class JOIN transport_flight ON (transport_flight.flight_id = transport_flight_class.flight_id) WHERE flight_class_id = " . $bookingDetails['flight_class_id'];
|
||||
$bookingResult = mysqli_query($conn, $productQuery);
|
||||
$productDetails = mysqli_fetch_assoc($bookingResult);
|
||||
|
||||
$price = $productDetails['fee'];
|
||||
$img = '';
|
||||
$name = $productDetails['flight_code'] . " - " . $productDetails['class'];
|
||||
|
||||
break;
|
||||
case '6':
|
||||
$bookingQuery = "SELECT * FROM transport_railway_booking WHERE booking_id = " . $booking_id;
|
||||
$bookingResult = mysqli_query($conn, $bookingQuery);
|
||||
$bookingDetails = mysqli_fetch_assoc($bookingResult);
|
||||
|
||||
$quantity = $bookingDetails['quantity'];
|
||||
$id = $bookingDetails['railway_class_id'];
|
||||
$visit_date = $bookingDetails['visit_date'];
|
||||
$end_date = null;
|
||||
|
||||
$productQuery = "SELECT transport_railway_class.train_id, transport_railway_class.class, transport_railway_class.fee, transport_railway.train_code, transport_railway.start_time, transport_railway.arrive_time FROM transport_railway_class JOIN transport_railway ON (transport_railway.train_id = transport_railway_class.train_id) WHERE train_seat_id = " . $id;
|
||||
$bookingResult = mysqli_query($conn, $productQuery);
|
||||
$productDetails = mysqli_fetch_assoc($bookingResult);
|
||||
|
||||
$price = $productDetails['fee'];
|
||||
$img = '';
|
||||
$name = $productDetails['train_code'] . " - " . $productDetails['class'];
|
||||
|
||||
break;
|
||||
default:
|
||||
echo "Unknown booking type";
|
||||
continue 2; // Skip to the next cart booking
|
||||
}
|
||||
|
||||
//unit price
|
||||
$unitprice = $cartBooking['subtotal_price'];
|
||||
|
||||
//choose
|
||||
$choose = $cartBooking['choose'];
|
||||
|
||||
//display
|
||||
echo '<table id="items" style="border:none;">';
|
||||
echo '<tr>';
|
||||
echo '<td width="15%">';
|
||||
|
||||
if ($img != ''){
|
||||
echo '<img src="data:image/jpeg;base64,' . base64_encode($img) . '" title="' . $id . '" id="' . $id . '" onclick="details(this)">';
|
||||
}
|
||||
|
||||
echo '</td>';
|
||||
//name
|
||||
echo '<td width="20%">';
|
||||
echo '<h4 style="margin: 0%; font-size: large;">' . $name . '</h4>';
|
||||
echo '</td>';
|
||||
|
||||
if($end_date != null){
|
||||
//start date
|
||||
echo '<td width="10%">';
|
||||
echo '<p style="font-size: large;">'.$start_date.'</p>';
|
||||
echo '</td>';
|
||||
//start date
|
||||
echo '<td width="10%">';
|
||||
echo '<p style="font-size: large;">'.$end_date.'</p>';
|
||||
echo '</td>';
|
||||
}
|
||||
else{
|
||||
//start date
|
||||
echo '<td width="20%">';
|
||||
echo '<p style="font-size: large;">'.$start_date.'</p>';
|
||||
echo '</td>';
|
||||
}
|
||||
|
||||
//unit price
|
||||
echo '<td width="10%">';
|
||||
echo '<p style="font-size: large;">¥'.$unitprice.'</p>';
|
||||
echo '</td>';
|
||||
//add
|
||||
echo '<td width="6%" id="icon">';
|
||||
echo '<img src="../../../icon/add.svg" id="' . $booking_id . '" name="'. $cartBooking['booking_type_id'] .'" onclick="item_add(this)">';
|
||||
echo '</td>';
|
||||
//modify
|
||||
echo '<td width="8%">';
|
||||
echo '<input type="text" style="margin: 0%; font-size: large;" name="'. $cartBooking['booking_type_id'] .'" id="' . $booking_id . '" value="' . $quantity . '" onfocusout="item_modify(this)">';
|
||||
echo '</td>';
|
||||
//subtract
|
||||
echo '<td width="6%" id="icon">';
|
||||
echo '<img src="../../../icon/subtract.svg" id="' . $booking_id . '" name="'. $cartBooking['booking_type_id'] .'" onclick="item_subtract(this)">';
|
||||
echo '</td>';
|
||||
//delete
|
||||
echo '<td width="6%" id="icon">';
|
||||
echo '<img src="../../../icon/delete.svg" id="' . $booking_id . '" name="'. $cartBooking['booking_type_id'] .'" onclick="item_del(this)">';
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
echo '</table>';
|
||||
}
|
||||
|
||||
$cart_total_Query = "SELECT cart_total_price FROM user_buyer WHERE u_id = " . $u_id;
|
||||
$cart_total_Result = mysqli_query($conn, $cart_total_Query);
|
||||
$cart_total_price = mysqli_fetch_assoc($cart_total_Result);
|
||||
$total = $cart_total_price['cart_total_price'];
|
||||
|
||||
if($num_rows != 0){
|
||||
echo '<table width="20%" style="text-align: center; border:none; background-color: transparent;">';
|
||||
echo '<tr>';
|
||||
echo '<td><h1>Total Price: ¥ '.$total.'</h1></td>';
|
||||
echo '<td>';
|
||||
echo '<form action="./checkup.php">';
|
||||
echo '<button type="submit">Check up</button>';
|
||||
echo '</form>';
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
echo '</table>';
|
||||
}
|
||||
else{
|
||||
echo '<h1>Nothing Here</h1>';
|
||||
echo '<br><br><br><br><br><br><br><br><br><br><br><br><br>
|
||||
<br><br><br><br><br><br><br><br><br><br><br><br><br><br>';
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</div>
|
||||
<footer>
|
||||
<img src="../../../icon/favicon/logo_white.svg" alt="RoamEase" width="300px">
|
||||
<div style="margin: 20px 0;">
|
||||
<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>
|
||||
<p>© 2023 COMP3013 Group10. All rights reserved.</p>
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
295
indexes/user/process/checkup.php
Normal file
295
indexes/user/process/checkup.php
Normal file
@@ -0,0 +1,295 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Cart</title>
|
||||
<script src="iframe.js"></script>
|
||||
<script src="./item_modify.js"></script>
|
||||
<link rel="stylesheet" href="./cart.css" type="text/css" />
|
||||
<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">
|
||||
</head>
|
||||
|
||||
<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['usertype']) && !$_SESSION['usertype'] === 'buyer'){
|
||||
header('Location: ../../../index.php');
|
||||
}
|
||||
}
|
||||
else{
|
||||
header('Location: ../../../index.php');
|
||||
}
|
||||
$u_id = $_SESSION['uid'];
|
||||
?>
|
||||
|
||||
<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="./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">
|
||||
<img src="../../../icon/header/plans.svg" alt="Plans">
|
||||
</a>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<div id="grid">
|
||||
|
||||
<?php
|
||||
$username = mysqli_real_escape_string($conn, $_SESSION['username']);
|
||||
$uid = mysqli_real_escape_string($conn, $_SESSION['uid']);
|
||||
|
||||
$sql_cart_bookings = "SELECT * FROM cart_bookings WHERE u_id='$u_id' AND choose = '1'";
|
||||
$result_cart_bookings = mysqli_query($conn, $sql_cart_bookings);
|
||||
$num_rows = mysqli_num_rows($result_cart_bookings);
|
||||
|
||||
while ($cartBooking = mysqli_fetch_assoc($result_cart_bookings)) {
|
||||
$booking_id = $cartBooking['booking_id'];
|
||||
// Use a switch statement for different booking types
|
||||
switch ($cartBooking['booking_type_id']) {
|
||||
case '1':
|
||||
$bookingQuery = "SELECT * FROM hotel_booking WHERE booking_id = " . $booking_id;
|
||||
$bookingResult = mysqli_query($conn, $bookingQuery);
|
||||
$bookingDetails = mysqli_fetch_assoc($bookingResult);
|
||||
|
||||
$quantity = $bookingDetails['quantity'];
|
||||
$id = $bookingDetails['hotel_room_id'];
|
||||
$start_date = $bookingDetails['start_date'];
|
||||
$end_date = $bookingDetails['end_date'];
|
||||
|
||||
$productQuery = "SELECT hotel_room.hotel_id, hotel_room.price, hotel_room_type.room_type_image, hotel.name, hotel_room_type.room_type_name FROM hotel_room JOIN hotel ON (hotel_room.hotel_id = hotel.hotel_id) JOIN hotel_room_type ON (hotel_room.room_type_id = hotel_room_type.room_type_id) WHERE hotel_room_id = " . $bookingDetails['hotel_room_id'];
|
||||
$bookingResult = mysqli_query($conn, $productQuery);
|
||||
$productDetails = mysqli_fetch_assoc($bookingResult);
|
||||
|
||||
$price = $productDetails['price'];
|
||||
$img = $productDetails['room_type_image'];
|
||||
$name = $productDetails['name'] . " - " . $productDetails['room_type_name'];
|
||||
|
||||
break;
|
||||
case '2':
|
||||
$bookingQuery = "SELECT * FROM restaurant_booking WHERE booking_id = " . $booking_id;
|
||||
$bookingResult = mysqli_query($conn, $bookingQuery);
|
||||
$bookingDetails = mysqli_fetch_assoc($bookingResult);
|
||||
|
||||
$quantity = $bookingDetails['quantity'];
|
||||
$id = $bookingDetails['restaurant_id'];
|
||||
$start_date = $bookingDetails['visit_date'];
|
||||
$end_date = null;
|
||||
|
||||
$productQuery = "SELECT name, fee, restaurant_style.restaurant_style_image FROM restaurant JOIN restaurant_style ON (restaurant.restaurant_style_id = restaurant_style.restaurant_style_id) WHERE restaurant_id = " . $bookingDetails['restaurant_id'];
|
||||
$bookingResult = mysqli_query($conn, $productQuery);
|
||||
$productDetails = mysqli_fetch_assoc($bookingResult);
|
||||
|
||||
$price = $productDetails['fee'];
|
||||
$img = $productDetails['restaurant_style_image'];
|
||||
$name = $productDetails['name'];
|
||||
|
||||
break;
|
||||
case '3':
|
||||
$bookingQuery = "SELECT * FROM attraction_booking WHERE booking_id = " . $booking_id;
|
||||
$bookingResult = mysqli_query($conn, $bookingQuery);
|
||||
$bookingDetails = mysqli_fetch_assoc($bookingResult);
|
||||
|
||||
$quantity = $bookingDetails['quantity'];
|
||||
$id = $bookingDetails['attraction_id'];
|
||||
$start_date = $bookingDetails['visit_date'];
|
||||
$end_date = null;
|
||||
|
||||
$productQuery = "SELECT name, price, attraction_type.attraction_type_image FROM attraction JOIN attraction_type ON (attraction.attraction_type_id = attraction_type.attraction_type_id) WHERE attraction_id = " . $bookingDetails['attraction_id'];
|
||||
$bookingResult = mysqli_query($conn, $productQuery);
|
||||
$productDetails = mysqli_fetch_assoc($bookingResult);
|
||||
|
||||
$price = $productDetails['price'];
|
||||
$img = $productDetails['attraction_type_image'];
|
||||
$name = $productDetails['name'];
|
||||
|
||||
break;
|
||||
case '4':
|
||||
$bookingQuery = "SELECT * FROM guide_booking WHERE booking_id = " . $booking_id;
|
||||
$bookingResult = mysqli_query($conn, $bookingQuery);
|
||||
$bookingDetails = mysqli_fetch_assoc($bookingResult);
|
||||
|
||||
$quantity = $bookingDetails['quantity'];
|
||||
$id = $bookingDetails['guide_id'];
|
||||
$start_date = $bookingDetails['start_date'];
|
||||
$end_date = $bookingDetails['end_date'];
|
||||
|
||||
$productQuery = "SELECT user_guide.username, user_guide.fee, user_guide.avatar FROM user_guide WHERE u_id = " . $bookingDetails['guide_id'];
|
||||
$bookingResult = mysqli_query($conn, $productQuery);
|
||||
$productDetails = mysqli_fetch_assoc($bookingResult);
|
||||
|
||||
$price = $productDetails['fee'];
|
||||
$img = $productDetails['avatar'];
|
||||
$name = $productDetails['username'];
|
||||
|
||||
break;
|
||||
case '5':
|
||||
$bookingQuery = "SELECT * FROM transport_flight_booking WHERE booking_id = " . $booking_id;
|
||||
$bookingResult = mysqli_query($conn, $bookingQuery);
|
||||
$bookingDetails = mysqli_fetch_assoc($bookingResult);
|
||||
|
||||
$quantity = $bookingDetails['quantity'];
|
||||
$id = $bookingDetails['flight_class_id'];
|
||||
$start_date = $bookingDetails['visit_date'];
|
||||
$end_date = null;
|
||||
|
||||
$productQuery = "SELECT transport_flight_class.flight_id, transport_flight_class.class, transport_flight_class.fee, transport_flight.flight_code, transport_flight.takeoff_time, transport_flight.landing_time FROM transport_flight_class JOIN transport_flight ON (transport_flight.flight_id = transport_flight_class.flight_id) WHERE flight_class_id = " . $bookingDetails['flight_class_id'];
|
||||
$bookingResult = mysqli_query($conn, $productQuery);
|
||||
$productDetails = mysqli_fetch_assoc($bookingResult);
|
||||
|
||||
$price = $productDetails['fee'];
|
||||
$img = '';
|
||||
$name = $productDetails['flight_code'] . " - " . $productDetails['class'];
|
||||
|
||||
break;
|
||||
case '6':
|
||||
$bookingQuery = "SELECT * FROM transport_railway_booking WHERE booking_id = " . $booking_id;
|
||||
$bookingResult = mysqli_query($conn, $bookingQuery);
|
||||
$bookingDetails = mysqli_fetch_assoc($bookingResult);
|
||||
|
||||
$quantity = $bookingDetails['quantity'];
|
||||
$id = $bookingDetails['railway_class_id'];
|
||||
$visit_date = $bookingDetails['visit_date'];
|
||||
$end_date = null;
|
||||
|
||||
$productQuery = "SELECT transport_railway_class.train_id, transport_railway_class.class, transport_railway_class.fee, transport_railway.train_code, transport_railway.start_time, transport_railway.arrive_time FROM transport_railway_class JOIN transport_railway ON (transport_railway.train_id = transport_railway_class.train_id) WHERE train_seat_id = " . $id;
|
||||
$bookingResult = mysqli_query($conn, $productQuery);
|
||||
$productDetails = mysqli_fetch_assoc($bookingResult);
|
||||
|
||||
$price = $productDetails['fee'];
|
||||
$img = '';
|
||||
$name = $productDetails['train_code'] . " - " . $productDetails['class'];
|
||||
|
||||
break;
|
||||
default:
|
||||
echo "Unknown booking type";
|
||||
continue 2; // Skip to the next cart booking
|
||||
}
|
||||
|
||||
//unit price
|
||||
$unitprice = $cartBooking['subtotal_price'];
|
||||
|
||||
//choose
|
||||
$choose = $cartBooking['choose'];
|
||||
|
||||
//display
|
||||
echo '<table id="items" style="border:none;">';
|
||||
echo '<tr>';
|
||||
echo '<td width="15%">';
|
||||
|
||||
if ($img != ''){
|
||||
echo '<img src="data:image/jpeg;base64,' . base64_encode($img) . '" title="' . $id . '" id="' . $id . '" onclick="details(this)">';
|
||||
}
|
||||
|
||||
echo '</td>';
|
||||
//name
|
||||
echo '<td width="20%">';
|
||||
echo '<h4 style="margin: 0%; font-size: large;">' . $name . '</h4>';
|
||||
echo '</td>';
|
||||
|
||||
if($end_date != null){
|
||||
//start date
|
||||
echo '<td width="15%">';
|
||||
echo '<p style="font-size: large;">'.$start_date.'</p>';
|
||||
echo '</td>';
|
||||
//start date
|
||||
echo '<td width="15%">';
|
||||
echo '<p style="font-size: large;">'.$end_date.'</p>';
|
||||
echo '</td>';
|
||||
}
|
||||
else{
|
||||
//start date
|
||||
echo '<td width="30%">';
|
||||
echo '<p style="font-size: large;">'.$start_date.'</p>';
|
||||
echo '</td>';
|
||||
}
|
||||
|
||||
//unit price
|
||||
echo '<td width="15%">';
|
||||
echo '<p style="font-size: large;">¥'.$unitprice.'</p>';
|
||||
echo '</td>';
|
||||
|
||||
//quantity
|
||||
echo '<td width="20%">';
|
||||
echo '<p style="margin: 0%; font-size: large;" name="'. $cartBooking['booking_type_id'] .'" id="' . $booking_id . '" value="' . $quantity . '">x' . $quantity . '</p>';
|
||||
echo '</td>';
|
||||
|
||||
echo '</tr>';
|
||||
echo '</table>';
|
||||
}
|
||||
|
||||
$cart_total_Query = "SELECT cart_total_price FROM user_buyer WHERE u_id = " . $u_id;
|
||||
$cart_total_Result = mysqli_query($conn, $cart_total_Query);
|
||||
$cart_total_price = mysqli_fetch_assoc($cart_total_Result);
|
||||
$total = $cart_total_price['cart_total_price'];
|
||||
|
||||
if($num_rows != 0){
|
||||
echo '<table width="20%" style="text-align: center; border:none; background-color: transparent;">';
|
||||
echo '<tr>';
|
||||
echo '<td><h1>Total Price: ¥ '.$total.'</h1></td>';
|
||||
echo '<td>';
|
||||
echo '<form action="./order.php" method="post">';
|
||||
echo '<input type="hidden" name="total" value="'.$total.'">';
|
||||
echo '<button type="submit">Order</button>';
|
||||
echo '</form>';
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
echo '</table>';
|
||||
}
|
||||
else{
|
||||
echo '<h1>Nothing Here</h1>';
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</div>
|
||||
<footer>
|
||||
<img src="../../../icon/favicon/logo_white.svg" alt="RoamEase" width="300px">
|
||||
<div style="margin: 20px 0;">
|
||||
<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>
|
||||
<p>© 2023 COMP3013 Group10. All rights reserved.</p>
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
45
indexes/user/process/iframe.js
Normal file
45
indexes/user/process/iframe.js
Normal file
@@ -0,0 +1,45 @@
|
||||
function details(tag){
|
||||
var name = tag.id;
|
||||
makeIFrame('./item_details.php?myParam=' + name);
|
||||
}
|
||||
|
||||
function makeIFrame(url) {
|
||||
var existence = document.getElementById("detail_window");
|
||||
if (!existence) {
|
||||
// Create the overlay div and add it to the page
|
||||
var overlay = document.createElement("div");
|
||||
overlay.id = "overlay";
|
||||
document.body.appendChild(overlay);
|
||||
|
||||
// Create the iframe and add it to the overlay div
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.setAttribute("src", url);
|
||||
iframe.id = "detail_window";
|
||||
overlay.appendChild(iframe);
|
||||
|
||||
// Create the close button and add it to the overlay div
|
||||
var closeButton = document.createElement("button");
|
||||
closeButton.innerHTML = "x";
|
||||
closeButton.title = "Close";
|
||||
closeButton.id = "closebutton";
|
||||
overlay.appendChild(closeButton);
|
||||
|
||||
// Add event listener to close the iframe when the close button is clicked
|
||||
closeButton.addEventListener("click", closeIFrame);
|
||||
|
||||
// Add event listener to close the iframe when clicked outside
|
||||
setTimeout(function() {
|
||||
overlay.addEventListener("click", closeIFrame);
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
|
||||
// Function to close the iframe and remove the overlay div from the page
|
||||
function closeIFrame() {
|
||||
var overlay = document.getElementById("overlay");
|
||||
if (overlay) {
|
||||
overlay.removeEventListener("click", closeIFrame);
|
||||
overlay.parentNode.removeChild(overlay);
|
||||
}
|
||||
}
|
||||
|
||||
101
indexes/user/process/index_.php
Normal file
101
indexes/user/process/index_.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Online Fruit Store</title>
|
||||
<script src="./iframe.js"></script>
|
||||
<link rel="stylesheet" href="./show_item.css" type="text/css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<br><br><br><br><br><br><br>
|
||||
|
||||
<div id="grid">
|
||||
<?php
|
||||
include '../ConnectDB.php';
|
||||
session_start();
|
||||
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {
|
||||
$usertype = $_SESSION['user_type'];
|
||||
if($usertype == "seller"){
|
||||
$a = "seller_availability";
|
||||
$p = "seller_price";
|
||||
}
|
||||
else{
|
||||
$a = "buyer_availability";
|
||||
$p = "buyer_price";
|
||||
}
|
||||
|
||||
//check availability
|
||||
$sql_rownum="SELECT * FROM inventory WHERE $a='1'";
|
||||
$res = mysqli_query($conn, $sql_rownum);
|
||||
if (!$res) {
|
||||
die('Query failed: ' . mysqli_error($conn));
|
||||
}
|
||||
$row = mysqli_num_rows($res);
|
||||
|
||||
//read in and display
|
||||
for ($i = 0; $i < $row; $i++) {
|
||||
while ($goods = mysqli_fetch_array($res)){
|
||||
//if inventory == 0, hide it from buyer
|
||||
if($goods['quantities'] != 0 || $usertype == "seller"){
|
||||
echo '<div id="items">';
|
||||
if (!empty($goods['imgname'])) {
|
||||
$imagePath = "../../img/" . $goods['imgname'];
|
||||
if (file_exists($imagePath)) {
|
||||
echo '<img src="' . $imagePath . '" title="' . $goods['name'] . '" id="' . $goods['name'] . '" onmousedown="details(this)">';
|
||||
}
|
||||
} else {
|
||||
echo '<img src="data:image/jpeg;base64,' . base64_encode($goods['img']) . '" title="' . $goods['name'] . '" id="' . $goods['name'] . '" onmousedown="details(this)">';
|
||||
}
|
||||
echo '<h5 style="margin: 0%; margin-bottom: 3%; margin-top: 3%; font-size: 70%;" id="' . $goods['name'] . '" onclick="details(this)">' . $goods['name'] . '</h5>';
|
||||
echo '<p style="font-size: small; margin: 0%;" id="' . $goods['name'] . '" onclick="details(this)">' . $goods['simpledesc'] . '</p>';
|
||||
echo '<p style="font-size: small; margin: 0%; color: blue;" id="' . $goods['name'] . '" onclick="details(this)">¥' . $goods[$p] . '/kg</p>';
|
||||
echo '<img class="icon_1" src="../../icon/addcart.svg" title="add to cart" id="' . $goods['name'] . '" onclick="addcart(this)">';
|
||||
echo '<img class="icon_2" src="../../icon/checkout.svg" title="buy now" id="' . $goods['name'] . '" onclick="buynow(this)">';
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<!--dialog for adding fruit-->
|
||||
<dialog class="dialog">
|
||||
<form method="dialog">
|
||||
Add <input type="number" id="amount" value="1" placeholder="how many"> kg
|
||||
<br><br>
|
||||
<button class="dialogbutton" type="submit" value="add cart">Check</button>
|
||||
<button class="dialogbutton" id="cancel-button">Cancel</button>
|
||||
</form>
|
||||
</dialog>
|
||||
|
||||
<script>
|
||||
function addcart(tag){
|
||||
var name = tag.id;
|
||||
var dialog = document.querySelector('dialog');
|
||||
dialog.showModal();
|
||||
dialog.addEventListener('close', function(event) {
|
||||
var amount = document.getElementById("amount").value;
|
||||
var targetButton = event.target.returnValue;
|
||||
if (targetButton === "add cart" && amount !== "") {
|
||||
window.location.href = "addcart.php?name=" + name + "&quantity=" + amount;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function buynow(tag){
|
||||
var name = tag.id;
|
||||
var dialog = document.querySelector('dialog');
|
||||
dialog.showModal();
|
||||
dialog.addEventListener('close', function(event) {
|
||||
var amount = document.getElementById("amount").value;
|
||||
var targetButton = event.target.returnValue;
|
||||
if (targetButton === "add cart" && amount !== "") {
|
||||
window.location.href = "checkup_now.php?name=" + name + "&quantity=" + amount;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
25
indexes/user/process/interfaces/failed.php
Normal file
25
indexes/user/process/interfaces/failed.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Error Occurred</title>
|
||||
<link rel="stylesheet" href="./instruct.css" type="text/css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="area">
|
||||
<img src="../../../../icon/close.svg">
|
||||
<h2 style="margin: none; padding: none;">Oops!</h2>
|
||||
<?php
|
||||
if(isset($_GET["why"])) {
|
||||
echo "<h1>".$_GET["why"]."</h1>";
|
||||
}
|
||||
else{
|
||||
echo "<h1>The order closed due to some error!</h1>";
|
||||
}
|
||||
?>
|
||||
<a href='../cart_index.php' style="text-decoration: none;">Try again</a>
|
||||
<script type='text/javascript'>
|
||||
setTimeout(function() {window.top.location.href = '../cart.php';}, 500);
|
||||
</script>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
17
indexes/user/process/interfaces/instruct.css
Normal file
17
indexes/user/process/interfaces/instruct.css
Normal file
@@ -0,0 +1,17 @@
|
||||
#area{
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
width: 300px;
|
||||
left: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
margin: auto;
|
||||
user-select: none;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
}
|
||||
img{
|
||||
width: 45%;
|
||||
height: 45%;
|
||||
margin: none;
|
||||
}
|
||||
16
indexes/user/process/interfaces/success.php
Normal file
16
indexes/user/process/interfaces/success.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Success</title>
|
||||
<link rel="stylesheet" href="./instruct.css" type="text/css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="area">
|
||||
<img src="../../../../icon/check.svg">
|
||||
<h1>Success</h1>
|
||||
<script type='text/javascript'>
|
||||
setTimeout(function() {window.top.location.href = '../../../../index.php';}, 500);
|
||||
</script>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
165
indexes/user/process/item_details.php
Normal file
165
indexes/user/process/item_details.php
Normal file
@@ -0,0 +1,165 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="./iframe.js"></script>
|
||||
<link rel="stylesheet" href="./show_item.css" type="text/css" />
|
||||
<style>
|
||||
#area{
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
width: 95%;
|
||||
left: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
margin: auto;
|
||||
user-select: none;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
}
|
||||
img{
|
||||
border-radius: 12px;
|
||||
margin-top: 2.5%;
|
||||
width: 65%;
|
||||
height: 65%;
|
||||
overflow:hidden;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
-webkit-background-size:cover;
|
||||
-moz-background-size:cover;
|
||||
background-size:cover;
|
||||
transition: 0.5s;
|
||||
}
|
||||
img:hover{
|
||||
border-radius: 12px;
|
||||
margin-top: 2.5%;
|
||||
width: 70%;
|
||||
height: 70%;
|
||||
overflow:hidden;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
-webkit-background-size:cover;
|
||||
-moz-background-size:cover;
|
||||
background-size:cover;
|
||||
transition: 0.5s;
|
||||
}
|
||||
pre{
|
||||
white-space:pre-wrap;
|
||||
user-select: text;
|
||||
text-align: left;
|
||||
}
|
||||
.checkicon{
|
||||
width: 6%;
|
||||
height: 6%;
|
||||
}
|
||||
.checkicon:hover{
|
||||
width: 8%;
|
||||
height: 8%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<!--dialog for adding fruit-->
|
||||
<dialog class="dialog">
|
||||
<form method="dialog">
|
||||
Add <input type="number" id="amount" value="1" placeholder="how many"> kg
|
||||
<br><br>
|
||||
<button class="dialogbutton" type="submit" value="add cart">Check</button>
|
||||
<button class="dialogbutton" id="cancel-button">Cancel</button>
|
||||
</form>
|
||||
</dialog>
|
||||
|
||||
|
||||
<script>
|
||||
// get the value of the 'myParam' query parameter from the URL
|
||||
var myParamValue = new URLSearchParams(window.location.search).get('myParam');
|
||||
</script>
|
||||
|
||||
<?php
|
||||
include "../ConnectDB.php";
|
||||
session_start();
|
||||
$usertype = mysqli_real_escape_string($conn, $_SESSION['user_type']);
|
||||
if ($usertype == "seller") {
|
||||
$p = "seller_price";
|
||||
} else {
|
||||
$p = "buyer_price";
|
||||
}
|
||||
if (isset($_GET['myParam']) && !empty($_GET['myParam'])) {
|
||||
$sql = "SELECT * FROM inventory WHERE name = '" . $_GET['myParam'] . "'";
|
||||
$res = mysqli_query($conn, $sql);
|
||||
$goods = mysqli_fetch_assoc($res);
|
||||
|
||||
if (!empty($goods['imgname'])) {
|
||||
$imagePath = "../../img/" . $goods['imgname'];
|
||||
|
||||
if (file_exists($imagePath)) {
|
||||
$image = $imagePath;
|
||||
}
|
||||
} else {
|
||||
$image = 'data:image/jpeg;base64,' . base64_encode($goods['img']);
|
||||
}
|
||||
} else {
|
||||
// Handle the case when myParam is not set or is empty
|
||||
$image = "../../img/default_image_path.jpg";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div id="area">
|
||||
<table>
|
||||
<tr>
|
||||
<td width="50%" style="text-align: right;">
|
||||
<img src="<?php echo $image; ?>" title="<?php echo $goods['name']; ?>">
|
||||
</td>
|
||||
<td width="50%">
|
||||
<h1><?php echo $goods['name']; ?></h1>
|
||||
<h3><?php echo $goods['simpledesc']; ?></h3>
|
||||
<h4 style="color: blue;">Inventory: <?php echo $goods['quantities']; ?>kg        Price: ¥<?php echo $goods[$p]; ?>/kg</h4>
|
||||
<?php
|
||||
if ($usertype == "seller" || $usertype == "buyer") {
|
||||
echo "<img class='checkicon' src='../../icon/addcart.svg' title='add to cart' id='". $goods['name']."' onclick='addcart(this)'>";
|
||||
echo "<img class='checkicon' src='../../icon/checkout.svg' title='buy now' id='".$goods['name']."' onclick='buynow(this)'>";
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<pre>
|
||||
<?php echo $goods['fulldesc']; ?>
|
||||
</pre>
|
||||
|
||||
<br><br>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function addcart(tag){
|
||||
var name = tag.id;
|
||||
var dialog = document.querySelector('dialog');
|
||||
dialog.showModal();
|
||||
dialog.addEventListener('close', function(event) {
|
||||
var amount = document.getElementById("amount").value;
|
||||
var targetButton = event.target.returnValue;
|
||||
if (targetButton === "add cart" && amount !== "") {
|
||||
window.location.href = "addcart.php?name=" + name + "&quantity=" + amount;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function buynow(tag){
|
||||
var name = tag.id;
|
||||
var dialog = document.querySelector('dialog');
|
||||
dialog.showModal();
|
||||
dialog.addEventListener('close', function(event) {
|
||||
var amount = document.getElementById("amount").value;
|
||||
var targetButton = event.target.returnValue;
|
||||
if (targetButton === "add cart" && amount !== "") {
|
||||
window.location.href = "checkup_now.php?name=" + name + "&quantity=" + amount;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
24
indexes/user/process/item_modify.js
Normal file
24
indexes/user/process/item_modify.js
Normal file
@@ -0,0 +1,24 @@
|
||||
function item_add(tag){
|
||||
var id = tag.id;
|
||||
var table = tag.name;
|
||||
window.location.href = "./modify/item_add.php?booking_id=" + id + "&table=" + table;
|
||||
}
|
||||
|
||||
function item_subtract(tag){
|
||||
var id = tag.id;
|
||||
var table = tag.name;
|
||||
window.location.href = "./modify/item_subtract.php?booking_id=" + id + "&table=" + table;
|
||||
}
|
||||
|
||||
function item_del(tag){
|
||||
var id = tag.id;
|
||||
var table = tag.name;
|
||||
window.location.href = "./modify/item_del.php?booking_id=" + id + "&table=" + table;
|
||||
}
|
||||
|
||||
function item_modify(tag){
|
||||
var id = tag.id;
|
||||
var quantity = tag.value;
|
||||
var table = tag.name;
|
||||
window.location.href = "./modify/item_modify.php?booking_id=" + id + "&quantity=" + quantity + "&table=" + table;
|
||||
}
|
||||
62
indexes/user/process/modify/item_add.php
Normal file
62
indexes/user/process/modify/item_add.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
include "../../../ConnectDB.php";
|
||||
|
||||
session_start();
|
||||
$uid = mysqli_real_escape_string($conn, $_SESSION['uid']);
|
||||
|
||||
if (isset($_GET["booking_id"]) && isset($_GET["table"])) {
|
||||
$booking_id = $_GET["booking_id"];
|
||||
|
||||
switch ($_GET["table"]) {
|
||||
case '1':
|
||||
$table = "hotel_booking";
|
||||
break;
|
||||
case '2':
|
||||
$table = "restaurant_booking";
|
||||
break;
|
||||
case '3':
|
||||
$table = "attraction_booking";
|
||||
break;
|
||||
case '4':
|
||||
$table = "guide_booking";
|
||||
break;
|
||||
case '5':
|
||||
$table = "transport_flight_booking";
|
||||
break;
|
||||
case '6':
|
||||
$table = "transport_railway_booking";
|
||||
break;
|
||||
default:
|
||||
echo "Unknown booking type";
|
||||
}
|
||||
|
||||
$price_query = "SELECT `subtotal_price` FROM cart_bookings WHERE booking_id=" . $booking_id;
|
||||
$priceRes = mysqli_query($conn, $price_query);
|
||||
$price = mysqli_fetch_assoc($priceRes);
|
||||
$price = $price["subtotal_price"];
|
||||
|
||||
$quantity_query = "SELECT quantity FROM `$table` WHERE booking_id='$booking_id'";
|
||||
$res = mysqli_query($conn, $quantity_query);
|
||||
$quantity = mysqli_fetch_assoc($res);
|
||||
$quantity = $quantity['quantity'];
|
||||
|
||||
$add = "UPDATE `$table` SET quantity = '$quantity' + 1 WHERE booking_id='$booking_id'";
|
||||
$res = mysqli_query($conn, $add);
|
||||
if (!$res) {
|
||||
echo "<script type='text/javascript'>
|
||||
alert('Error occurred!');
|
||||
</script>";
|
||||
}
|
||||
|
||||
$total = "UPDATE user_buyer SET cart_total_price = cart_total_price + '$price' WHERE u_id='$uid'";
|
||||
$res = mysqli_query($conn, $total);
|
||||
if (!$res) {
|
||||
echo "<script type='text/javascript'>
|
||||
alert('Error occurred!');
|
||||
</script>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
header('Location: ../cart.php');
|
||||
?>
|
||||
65
indexes/user/process/modify/item_del.php
Normal file
65
indexes/user/process/modify/item_del.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
include "../../../ConnectDB.php";
|
||||
|
||||
session_start();
|
||||
$uid = mysqli_real_escape_string($conn, $_SESSION['uid']);
|
||||
|
||||
if (isset($_GET["booking_id"]) && isset($_GET["table"])) {
|
||||
$booking_id = mysqli_real_escape_string($conn, $_GET["booking_id"]);
|
||||
|
||||
switch ($_GET["table"]) {
|
||||
case '1':
|
||||
$table = "hotel_booking";
|
||||
break;
|
||||
case '2':
|
||||
$table = "restaurant_booking";
|
||||
break;
|
||||
case '3':
|
||||
$table = "attraction_booking";
|
||||
break;
|
||||
case '4':
|
||||
$table = "guide_booking";
|
||||
break;
|
||||
case '5':
|
||||
$table = "transport_flight_booking";
|
||||
break;
|
||||
case '6':
|
||||
$table = "transport_railway_booking";
|
||||
break;
|
||||
default:
|
||||
echo "Unknown booking type";
|
||||
}
|
||||
|
||||
$subtotal_price = "SELECT subtotal_price FROM cart_bookings WHERE booking_id='$booking_id'";
|
||||
$res = mysqli_query($conn, $subtotal_price);
|
||||
$subtotal_price = mysqli_fetch_assoc($res);
|
||||
$subtotal_price = $subtotal_price['subtotal_price'];
|
||||
|
||||
$quantity_query = "SELECT quantity FROM `$table` WHERE booking_id='$booking_id'";
|
||||
$res = mysqli_query($conn, $quantity_query);
|
||||
$quantity = mysqli_fetch_assoc($res);
|
||||
$quantity = $quantity['quantity'];
|
||||
|
||||
$delete_query = "DELETE FROM bookings WHERE booking_id='$booking_id'";
|
||||
$res = mysqli_query($conn, $delete_query);
|
||||
if (!$res) {
|
||||
echo "<script type='text/javascript'>
|
||||
alert('Error occurred!');
|
||||
</script>";
|
||||
} else {
|
||||
header('Location: ../cart.php'); // Redirect after successful deletion
|
||||
}
|
||||
|
||||
$total = "UPDATE user_buyer SET cart_total_price = cart_total_price - ('$subtotal_price' * '$quantity') WHERE u_id='$uid'";
|
||||
$res = mysqli_query($conn, $total);
|
||||
if (!$res) {
|
||||
echo "<script type='text/javascript'>
|
||||
alert('Error occurred!');
|
||||
</script>";
|
||||
}
|
||||
exit();
|
||||
} else {
|
||||
header('Location: ../cart.php'); // Redirect if booking_id is not set
|
||||
exit();
|
||||
}
|
||||
?>
|
||||
68
indexes/user/process/modify/item_modify.php
Normal file
68
indexes/user/process/modify/item_modify.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
include "../../../ConnectDB.php";
|
||||
|
||||
session_start();
|
||||
$uid = mysqli_real_escape_string($conn, $_SESSION['uid']);
|
||||
|
||||
if (isset($_GET["booking_id"]) && isset($_GET["table"]) && isset($_GET["quantity"])) {
|
||||
|
||||
$booking_id = $_GET["booking_id"];
|
||||
$quantity = $_GET["quantity"];
|
||||
if($quantity > 0){
|
||||
|
||||
switch ($_GET["table"]) {
|
||||
case '1':
|
||||
$table = "hotel_booking";
|
||||
break;
|
||||
case '2':
|
||||
$table = "restaurant_booking";
|
||||
break;
|
||||
case '3':
|
||||
$table = "attraction_booking";
|
||||
break;
|
||||
case '4':
|
||||
$table = "guide_booking";
|
||||
break;
|
||||
case '5':
|
||||
$table = "transport_flight_booking";
|
||||
break;
|
||||
case '6':
|
||||
$table = "transport_railway_booking";
|
||||
break;
|
||||
default:
|
||||
echo "Unknown booking type";
|
||||
exit();
|
||||
}
|
||||
|
||||
$quantity_query = "SELECT quantity FROM `$table` WHERE booking_id='$booking_id'";
|
||||
$res = mysqli_query($conn, $quantity_query);
|
||||
$old_quantity = mysqli_fetch_assoc($res);
|
||||
$old_quantity = $old_quantity['quantity'];
|
||||
|
||||
$price_query = "SELECT `subtotal_price` FROM cart_bookings WHERE booking_id=" . $booking_id;
|
||||
$priceRes = mysqli_query($conn, $price_query);
|
||||
$price = mysqli_fetch_assoc($priceRes);
|
||||
$price = $price["subtotal_price"];
|
||||
|
||||
$modified_price = $price * ($quantity - $old_quantity);
|
||||
|
||||
$add = "UPDATE `$table` SET quantity = '$quantity' WHERE booking_id='$booking_id'";
|
||||
$res = mysqli_query($conn, $add);
|
||||
if (!$res) {
|
||||
echo "<script type='text/javascript'>
|
||||
alert('Error occurred!');
|
||||
</script>";
|
||||
}
|
||||
|
||||
$total = "UPDATE user_buyer SET cart_total_price = cart_total_price + '$modified_price' WHERE u_id='$uid'";
|
||||
$res = mysqli_query($conn, $total);
|
||||
if (!$res) {
|
||||
echo "<script type='text/javascript'>
|
||||
alert('Error occurred!');
|
||||
</script>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
header('Location: ../cart.php');
|
||||
?>
|
||||
69
indexes/user/process/modify/item_subtract.php
Normal file
69
indexes/user/process/modify/item_subtract.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
include "../../../ConnectDB.php";
|
||||
|
||||
session_start();
|
||||
$uid = mysqli_real_escape_string($conn, $_SESSION['uid']);
|
||||
|
||||
if (isset($_GET["booking_id"]) && isset($_GET["table"])) {
|
||||
$booking_id = $_GET["booking_id"];
|
||||
|
||||
switch ($_GET["table"]) {
|
||||
case '1':
|
||||
$table = "hotel_booking";
|
||||
break;
|
||||
case '2':
|
||||
$table = "restaurant_booking";
|
||||
break;
|
||||
case '3':
|
||||
$table = "attraction_booking";
|
||||
break;
|
||||
case '4':
|
||||
$table = "guide_booking";
|
||||
break;
|
||||
case '5':
|
||||
$table = "transport_flight_booking";
|
||||
break;
|
||||
case '6':
|
||||
$table = "transport_railway_booking";
|
||||
break;
|
||||
default:
|
||||
echo "Unknown booking type";
|
||||
}
|
||||
|
||||
$price_query = "SELECT `subtotal_price` FROM cart_bookings WHERE booking_id=" . $booking_id;
|
||||
$priceRes = mysqli_query($conn, $price_query);
|
||||
$price = mysqli_fetch_assoc($priceRes);
|
||||
$price = $price["subtotal_price"];
|
||||
|
||||
$quantity_query = "SELECT quantity FROM `$table` WHERE booking_id='$booking_id'";
|
||||
$res = mysqli_query($conn, $quantity_query);
|
||||
$quantity = mysqli_fetch_assoc($res);
|
||||
$quantity = $quantity['quantity'];
|
||||
|
||||
if($quantity > 1){
|
||||
$add = "UPDATE `$table` SET quantity = '$quantity' - 1 WHERE booking_id='$booking_id'";
|
||||
$res = mysqli_query($conn, $add);
|
||||
if (!$res) {
|
||||
echo "<script type='text/javascript'>
|
||||
alert('Error occurred!');
|
||||
</script>";
|
||||
}
|
||||
|
||||
$total = "UPDATE user_buyer SET cart_total_price = cart_total_price - '$price' WHERE u_id='$uid'";
|
||||
$res = mysqli_query($conn, $total);
|
||||
if (!$res) {
|
||||
echo "<script type='text/javascript'>
|
||||
alert('Error occurred!');
|
||||
</script>";
|
||||
}
|
||||
}
|
||||
else{
|
||||
echo "<script type='text/javascript'>
|
||||
alert('You cannot buy 0 quantity!');
|
||||
</script>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
header('Location: ../cart.php');
|
||||
?>
|
||||
173
indexes/user/process/order.php
Normal file
173
indexes/user/process/order.php
Normal file
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
include "../../ConnectDB.php";
|
||||
|
||||
// Start the session
|
||||
session_start();
|
||||
|
||||
// Escape the username and user type for security
|
||||
$u_id = mysqli_real_escape_string($conn, $_SESSION['uid']);
|
||||
|
||||
// Retrieve the total price
|
||||
$total_price = $_POST['total'];
|
||||
|
||||
// If buyer do not have enough balance
|
||||
$sql_check_balance = "SELECT balance FROM user_buyer WHERE u_id = '$u_id'";
|
||||
$res = mysqli_query($conn, $sql_check_balance);
|
||||
$balance = mysqli_fetch_array($res);
|
||||
if($balance['balance'] < $total_price){
|
||||
echo "<script type='text/javascript'>
|
||||
window.location.href = './interfaces/failed.php?why=Insufficient Balance';
|
||||
</script>";
|
||||
exit();
|
||||
}
|
||||
|
||||
$new_receipt_query = "INSERT INTO `receipt` (`u_id`, `total_price`) VALUES ('$u_id', '$total_price')";
|
||||
$new_receipt_set = mysqli_query($conn, $new_receipt_query);
|
||||
$receipt_id = mysqli_insert_id($conn);
|
||||
|
||||
// Update information
|
||||
$sql_cart_bookings = "SELECT * FROM cart_bookings WHERE u_id='$u_id' AND choose = '1'";
|
||||
$result_cart_bookings = mysqli_query($conn, $sql_cart_bookings);
|
||||
$num_rows = mysqli_num_rows($result_cart_bookings);
|
||||
|
||||
while ($cartBooking = mysqli_fetch_assoc($result_cart_bookings)) {
|
||||
$booking_id = $cartBooking['booking_id'];
|
||||
$booking_type_id = $cartBooking['booking_type_id'];
|
||||
$subtotal_price = $cartBooking['subtotal_price'];
|
||||
// Use a switch statement for different booking types
|
||||
switch ($booking_type_id) {
|
||||
case '1':
|
||||
$bookingQuery = "UPDATE `hotel_booking` SET payment_status = '1' WHERE booking_id = " . $booking_id;
|
||||
$bookingResult = mysqli_query($conn, $bookingQuery);
|
||||
|
||||
$sellerQuery = "SELECT hotel_booking.quantity, seller_id FROM hotel_booking JOIN hotel_room ON (hotel_room.hotel_room_id = hotel_booking.hotel_room_id) JOIN hotel ON (hotel.hotel_id = hotel_room.hotel_id) WHERE booking_id = " . $booking_id;
|
||||
$sellerResult = mysqli_query($conn, $sellerQuery);
|
||||
$sellerResult = mysqli_fetch_assoc($sellerResult);
|
||||
$seller_id = $sellerResult['seller_id'];
|
||||
$quantity = $sellerResult['quantity'];
|
||||
$sub_price = $quantity * $subtotal_price;
|
||||
|
||||
$sellerQuery = "UPDATE `user_seller` SET balance = balance + '$sub_price' WHERE u_id = " . $seller_id;
|
||||
$sellerResult = mysqli_query($conn, $sellerQuery);
|
||||
|
||||
$receiptQuery = "INSERT INTO `receipt_bookings`(`receipt_id`, `booking_id`, `booking_type_id`, `booking_status`, `subtotal_price`, `quantity`, `seller_id`) VALUES ('$receipt_id','$booking_id','1','Unused','$subtotal_price', '$quantity', '$seller_id')";
|
||||
$receiptResult = mysqli_query($conn, $receiptQuery);
|
||||
|
||||
break;
|
||||
case '2':
|
||||
$bookingQuery = "UPDATE `restaurant_booking` SET payment_status = '1' WHERE booking_id = " . $booking_id;
|
||||
$bookingResult = mysqli_query($conn, $bookingQuery);
|
||||
|
||||
$sellerQuery = "SELECT restaurant_booking.quantity, seller_id FROM restaurant_booking JOIN restaurant ON (restaurant_booking.restaurant_id = restaurant.restaurant_id) WHERE booking_id = " . $booking_id;
|
||||
$sellerResult = mysqli_query($conn, $sellerQuery);
|
||||
$sellerResult = mysqli_fetch_assoc($sellerResult);
|
||||
$seller_id = $sellerResult['seller_id'];
|
||||
$quantity = $sellerResult['quantity'];
|
||||
$sub_price = $quantity * $subtotal_price;
|
||||
|
||||
$sellerQuery = "UPDATE `user_seller` SET balance = balance + '$sub_price' WHERE u_id = " . $seller_id;
|
||||
$sellerResult = mysqli_query($conn, $sellerQuery);
|
||||
|
||||
$receiptQuery = "INSERT INTO `receipt_bookings`(`receipt_id`, `booking_id`, `booking_type_id`, `booking_status`, `subtotal_price`, `quantity`, `seller_id`) VALUES ('$receipt_id','$booking_id','2','Unused','$subtotal_price', '$quantity', '$seller_id')";
|
||||
$receiptResult = mysqli_query($conn, $receiptQuery);
|
||||
|
||||
break;
|
||||
case '3':
|
||||
$bookingQuery = "UPDATE `attraction_booking` SET payment_status = '1' WHERE booking_id = " . $booking_id;
|
||||
$bookingResult = mysqli_query($conn, $bookingQuery);
|
||||
|
||||
$sellerQuery = "SELECT attraction_booking.quantity, seller_id FROM attraction_booking JOIN attraction ON (attraction_booking.attraction_id = attraction.attraction_id) WHERE booking_id = " . $booking_id;
|
||||
$sellerResult = mysqli_query($conn, $sellerQuery);
|
||||
$sellerResult = mysqli_fetch_assoc($sellerResult);
|
||||
$seller_id = $sellerResult['seller_id'];
|
||||
$quantity = $sellerResult['quantity'];
|
||||
$sub_price = $quantity * $subtotal_price;
|
||||
|
||||
$sellerQuery = "UPDATE `user_seller` SET balance = balance + '$sub_price' WHERE u_id = " . $seller_id;
|
||||
$sellerResult = mysqli_query($conn, $sellerQuery);
|
||||
|
||||
$receiptQuery = "INSERT INTO `receipt_bookings`(`receipt_id`, `booking_id`, `booking_type_id`, `booking_status`, `subtotal_price`, `quantity`, `seller_id`) VALUES ('$receipt_id','$booking_id','3','Unused','$subtotal_price', '$quantity', '$seller_id')";
|
||||
$receiptResult = mysqli_query($conn, $receiptQuery);
|
||||
|
||||
break;
|
||||
case '4':
|
||||
$bookingQuery = "UPDATE `guide_booking` SET payment_status = '1' WHERE booking_id = " . $booking_id;
|
||||
$bookingResult = mysqli_query($conn, $bookingQuery);
|
||||
|
||||
$sellerQuery = "SELECT guide_booking.quantity, guide_id FROM guide_booking WHERE booking_id = " . $booking_id;
|
||||
$sellerResult = mysqli_query($conn, $sellerQuery);
|
||||
$sellerResult = mysqli_fetch_assoc($sellerResult);
|
||||
$seller_id = $sellerResult['guide_id'];
|
||||
$quantity = $sellerResult['quantity'];
|
||||
$sub_price = $quantity * $subtotal_price;
|
||||
|
||||
$sellerQuery = "UPDATE `user_guide` SET balance = balance + '$sub_price' WHERE u_id = " . $seller_id;
|
||||
$sellerResult = mysqli_query($conn, $sellerQuery);
|
||||
|
||||
$receiptQuery = "INSERT INTO `receipt_bookings`(`receipt_id`, `booking_id`, `booking_type_id`, `booking_status`, `subtotal_price`, `quantity`, `seller_id`) VALUES ('$receipt_id','$booking_id','4','Unused','$subtotal_price', '$quantity', '$seller_id')";
|
||||
$receiptResult = mysqli_query($conn, $receiptQuery);
|
||||
|
||||
break;
|
||||
case '5':
|
||||
$bookingQuery = "UPDATE `transport_flight_booking` SET payment_status = '1' WHERE booking_id = " . $booking_id;
|
||||
$bookingResult = mysqli_query($conn, $bookingQuery);
|
||||
|
||||
$sellerQuery = "SELECT transport_flight_booking.quantity, airline_id FROM transport_flight_booking JOIN transport_flight_class ON (transport_flight_booking.flight_class_id = transport_flight_class.flight_class_id) JOIN transport_flight ON (transport_flight.flight_id = transport_flight_class.flight_id) WHERE booking_id = " . $booking_id;
|
||||
$sellerResult = mysqli_query($conn, $sellerQuery);
|
||||
$sellerResult = mysqli_fetch_assoc($sellerResult);
|
||||
$airline_id = $sellerResult['airline_id'];
|
||||
$quantity = $sellerResult['quantity'];
|
||||
$sub_price = $quantity * $subtotal_price;
|
||||
|
||||
$sellerQuery = "SELECT seller_id FROM transport_airline WHERE airline_id = " . $airline_id;
|
||||
$sellerResult = mysqli_query($conn, $sellerQuery);
|
||||
$seller_id = mysqli_fetch_assoc($sellerResult);
|
||||
$seller_id = $seller_id['seller_id'];
|
||||
|
||||
$sellerQuery = "UPDATE `user_seller` SET balance = balance + '$sub_price' WHERE u_id = " . $seller_id;
|
||||
$sellerResult = mysqli_query($conn, $sellerQuery);
|
||||
|
||||
$receiptQuery = "INSERT INTO `receipt_bookings`(`receipt_id`, `booking_id`, `booking_type_id`, `booking_status`, `subtotal_price`, `quantity`, `seller_id`) VALUES ('$receipt_id','$booking_id','5','Unused','$subtotal_price', '$quantity', '$seller_id')";
|
||||
$receiptResult = mysqli_query($conn, $receiptQuery);
|
||||
|
||||
break;
|
||||
case '6':
|
||||
$bookingQuery = "UPDATE `transport_railway_booking` SET payment_status = '1' WHERE booking_id = " . $booking_id;
|
||||
$bookingResult = mysqli_query($conn, $bookingQuery);
|
||||
|
||||
$sellerQuery = "SELECT transport_railway_booking.quantity, seller_id FROM transport_railway_booking JOIN transport_railway_class ON (transport_railway_booking.railway_class_id = transport_railway_class.train_seat_id) JOIN transport_railway ON (transport_railway.train_id = transport_railway_class.train_id) WHERE booking_id = " . $booking_id;
|
||||
$sellerResult = mysqli_query($conn, $sellerQuery);
|
||||
$sellerResult = mysqli_fetch_assoc($sellerResult);
|
||||
$seller_id = $sellerResult['seller_id'];
|
||||
$quantity = $sellerResult['quantity'];
|
||||
$sub_price = $quantity * $subtotal_price;
|
||||
|
||||
$sellerQuery = "UPDATE `user_seller` SET balance = balance + '$sub_price' WHERE u_id = " . $seller_id;
|
||||
$sellerResult = mysqli_query($conn, $sellerQuery);
|
||||
|
||||
$receiptQuery = "INSERT INTO `receipt_bookings`(`receipt_id`, `booking_id`, `booking_type_id`, `booking_status`, `subtotal_price`, `quantity`, `seller_id`) VALUES ('$receipt_id','$booking_id','6','Unused','$subtotal_price', '$quantity', '$seller_id')";
|
||||
$receiptResult = mysqli_query($conn, $receiptQuery);
|
||||
|
||||
break;
|
||||
default:
|
||||
echo "Unknown booking type";
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
// Update cart
|
||||
$bookingQuery = "DELETE FROM `cart_bookings` WHERE u_id = '$u_id' AND choose = '1'";
|
||||
$bookingResult = mysqli_query($conn, $bookingQuery);
|
||||
|
||||
// User balance
|
||||
$bookingQuery = "UPDATE `user_buyer` SET balance = balance - '$total_price', cart_total_price = '0' WHERE u_id = " . $u_id;
|
||||
$bookingResult = mysqli_query($conn, $bookingQuery);
|
||||
|
||||
if($bookingResult){
|
||||
header('Location: ./interfaces/success.php');
|
||||
}
|
||||
else{
|
||||
header('Location: ./interfaces/failed.php');
|
||||
}
|
||||
|
||||
?>
|
||||
85
indexes/user/process/receipt.php
Normal file
85
indexes/user/process/receipt.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
td{
|
||||
font-size: small;
|
||||
}
|
||||
th{
|
||||
font-size: small;
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" href="./cart.css" type="text/css" />
|
||||
</head>
|
||||
</html>
|
||||
|
||||
<?php
|
||||
include "../ConnectDB.php";
|
||||
|
||||
// Start the session
|
||||
session_start();
|
||||
$username = mysqli_real_escape_string($conn, $_SESSION['username']);
|
||||
$usertype = mysqli_real_escape_string($conn, $_SESSION['user_type']);
|
||||
if($usertype == "seller"){
|
||||
$r = "seller_receipt";
|
||||
}
|
||||
else{
|
||||
$r = "buyer_receipt";
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM $r WHERE name='$username'";
|
||||
$result = mysqli_query($conn, $sql);
|
||||
$row = mysqli_num_rows($result);
|
||||
|
||||
if($row <= 0){
|
||||
echo '<h3>Nothing Here</h3>';
|
||||
return;
|
||||
}
|
||||
|
||||
echo '<div id="grid">';
|
||||
|
||||
for ($i = 0; $i < $row; $i++) {
|
||||
//get number of columns
|
||||
$fields = mysqli_num_fields($result);
|
||||
|
||||
//Get each row data
|
||||
while ($row_data = mysqli_fetch_array($result)){
|
||||
echo '<table id="items">';
|
||||
//display for each fruit
|
||||
echo '<tr>';
|
||||
echo '<th width="20%">Fruit</th>';
|
||||
echo '<th width="20%">Quantity (kg)</th>';
|
||||
echo '<th width="20%">Unit price (¥/kg)</th>';
|
||||
echo '<th width="20%">Retail price (¥)</th>';
|
||||
echo '</tr>';
|
||||
|
||||
//explode details messages to display
|
||||
$list = explode("|", $row_data['details']);
|
||||
for($index = 0; $index < count($list); $index++){
|
||||
if($index % 4 == 0){
|
||||
echo "<tr>";
|
||||
echo "<td>".$list[$index]."</td>";
|
||||
}
|
||||
else echo "<td>".$list[$index]."</td>";
|
||||
}
|
||||
|
||||
//display for total price and date
|
||||
echo '<tr style="color: blue;">';
|
||||
echo '<th></th>';
|
||||
echo '<th></th>';
|
||||
echo '<th>Date</th>';
|
||||
echo '<th>Total price</th>';
|
||||
echo '</tr>';
|
||||
|
||||
echo '<tr style="color: blue;">';
|
||||
echo '<th></th>';
|
||||
echo '<th></th>';
|
||||
echo "<td>".$row_data['date']."</td>";
|
||||
echo "<td>¥".$row_data['total']."</td>";
|
||||
echo '</tr>';
|
||||
|
||||
echo "</table>";
|
||||
}
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
?>
|
||||
202
indexes/user/process/show_item.css
Normal file
202
indexes/user/process/show_item.css
Normal file
@@ -0,0 +1,202 @@
|
||||
#grid{
|
||||
position:absolute;
|
||||
display: flex;
|
||||
justify-content: left;
|
||||
flex-wrap: wrap;
|
||||
margin: none;
|
||||
border: none;
|
||||
width: 100%;
|
||||
left:1.5%;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
user-select: none;
|
||||
text-align: center;
|
||||
}
|
||||
#items{
|
||||
display: block;
|
||||
background-color: rgba(255, 255, 255, 0.4);
|
||||
color: black;
|
||||
font-size: 200%;
|
||||
border-radius: 12px;
|
||||
backdrop-filter: blur(4px);
|
||||
margin: 3%;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
font-style: rgb(10, 22, 44);
|
||||
user-select: none;
|
||||
text-align: center;
|
||||
padding: 0.2%;
|
||||
width: 26vw;
|
||||
height: 30vw;
|
||||
transition: 0.3s;
|
||||
}
|
||||
img{
|
||||
border-radius: 12px;
|
||||
margin-top: 2.5%;
|
||||
width: 95%;
|
||||
height: 60%;
|
||||
overflow:hidden;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
-webkit-background-size:cover;
|
||||
-moz-background-size:cover;
|
||||
background-size:cover;
|
||||
cursor: hand;
|
||||
transition: 0.5s;
|
||||
}
|
||||
.icon_1{
|
||||
left: 40%;
|
||||
position: absolute;
|
||||
display: block;
|
||||
text-align: right;
|
||||
border-radius: 12%;
|
||||
width: 9%;
|
||||
height: 9%;
|
||||
margin: 1%;
|
||||
overflow:hidden;
|
||||
cursor: hand;
|
||||
}
|
||||
.icon_1:hover{
|
||||
width: 9%;
|
||||
height: 9%;
|
||||
}
|
||||
.icon_2{
|
||||
left: 50%;
|
||||
position: absolute;
|
||||
display: block;
|
||||
text-align: right;
|
||||
border-radius: 12%;
|
||||
width: 9%;
|
||||
height: 9%;
|
||||
margin: 1%;
|
||||
overflow:hidden;
|
||||
cursor: hand;
|
||||
transition: 0.5s;
|
||||
}
|
||||
.icon_2:hover{
|
||||
width: 9%;
|
||||
height: 9%;
|
||||
}
|
||||
#items:hover{
|
||||
box-shadow: 0px 0px 10px rgb(106, 104, 104);
|
||||
}
|
||||
img:hover{
|
||||
margin-top: 0%;
|
||||
box-shadow: 0px 0px 10px rgb(106, 104, 104);
|
||||
width: 100%;
|
||||
height: 62%;
|
||||
}
|
||||
h5:hover{
|
||||
cursor: hand;
|
||||
}
|
||||
#detail_window{
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
transform: scale(1.7);
|
||||
/* 垂直居中 */
|
||||
top: 10%;
|
||||
bottom: 0;
|
||||
height: 50%;
|
||||
/* 水平居中 */
|
||||
left: 0%;
|
||||
right: 0%;
|
||||
width: 57%;
|
||||
margin: auto;
|
||||
|
||||
user-select: none;
|
||||
background-color: rgba(239, 230, 230, 0.5);
|
||||
border: 0px;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0px 0px 16px rgb(70, 69, 69);
|
||||
backdrop-filter: blur(20px);
|
||||
}
|
||||
#overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(109, 103, 103, 0.6);
|
||||
backdrop-filter: blur(4px);
|
||||
z-index: 10000;
|
||||
}
|
||||
body{
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
#closebutton{
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
transform: scale(1.4);
|
||||
top: 14%;
|
||||
height: 2.2%;
|
||||
margin-left: 95%;
|
||||
width: 2.2%;
|
||||
font-size: 80%;
|
||||
user-select: none;
|
||||
border: 0px;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0px 0px 16px rgb(142, 142, 142);
|
||||
}
|
||||
#closebutton:hover{
|
||||
background-color: red;
|
||||
}
|
||||
.dialog{
|
||||
background-color: rgba(255, 255, 255, 0.5);
|
||||
color: black;
|
||||
font-size: 150%;
|
||||
box-shadow: 0px 0px 10px rgb(106, 104, 104);
|
||||
border-radius: 12px;
|
||||
border: none;
|
||||
backdrop-filter: blur(20px);
|
||||
height: 20%;
|
||||
width: 40%;
|
||||
margin: auto;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
font-style: rgb(10, 22, 44);
|
||||
user-select: none;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
padding-top: 5%;
|
||||
}
|
||||
dialog::backdrop {
|
||||
background-color: rgba(75, 75, 75, 0.598);
|
||||
}
|
||||
.dialogbutton{
|
||||
height: 25%;
|
||||
width: 40%;
|
||||
font-size: medium;
|
||||
border: solid white 0px;
|
||||
background: linear-gradient(to right, rgb(26, 117, 172), rgb(26, 158, 144));
|
||||
color: white;
|
||||
cursor: hand;
|
||||
box-shadow: 0px 0px 0px #424242;
|
||||
transition: 0.3s;
|
||||
border-radius: 5px;
|
||||
margin-top: 5%;
|
||||
}
|
||||
.dialogbutton:hover {
|
||||
box-shadow: 0px 0px 10px #424242;
|
||||
}
|
||||
input{
|
||||
font-size: 100%;
|
||||
text-align: center;
|
||||
background-color: rgba(255, 255, 255, 0.5);
|
||||
border-radius: 5px;
|
||||
border-top: none;
|
||||
border-left: none;
|
||||
border-right: none;
|
||||
outline: none;
|
||||
border-bottom: 1px solid grey;
|
||||
height: 20%;
|
||||
width: 40%;
|
||||
box-shadow: 0px 0px 0px #424242;
|
||||
transition: 0.3s;
|
||||
backdrop-filter: blur(20px);
|
||||
}
|
||||
input:focus{
|
||||
background-color: rgb(234, 241, 254);
|
||||
box-shadow: 0px 0px 10px #424242;
|
||||
}
|
||||
input:hover{
|
||||
box-shadow: 0px 0px 10px #424242;
|
||||
}
|
||||
Reference in New Issue
Block a user