Initial commit
This commit is contained in:
58
indexes/process/addcart.php
Normal file
58
indexes/process/addcart.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
include "../ConnectDB.php";
|
||||
|
||||
session_start();
|
||||
$username = mysqli_real_escape_string($conn, $_SESSION['username']);
|
||||
$usertype = mysqli_real_escape_string($conn, $_SESSION['user_type']);
|
||||
if($usertype == "seller"){
|
||||
$a = "seller_availability";
|
||||
}
|
||||
else{
|
||||
$a = "buyer_availability";
|
||||
}
|
||||
|
||||
if(isset($_GET["name"], $_GET["quantity"])) {
|
||||
$name = $_GET["name"];
|
||||
$quantity = $_GET["quantity"];
|
||||
|
||||
//if get null value
|
||||
if($quantity == ""){
|
||||
echo "<script type='text/javascript'>
|
||||
window.top.location.href = '../../home.php';
|
||||
</script>";
|
||||
return;
|
||||
}
|
||||
|
||||
$check_sql = "SELECT $a FROM inventory WHERE name = '$name'";
|
||||
$res = mysqli_query($conn, $check_sql);
|
||||
$avail = mysqli_fetch_array($res);
|
||||
|
||||
//if not available
|
||||
if($avail[$a] != 1){
|
||||
echo "<script type='text/javascript'>
|
||||
alert('This fruit is currently unavailable!');
|
||||
window.top.location.href = '../../home.php';
|
||||
</script>";
|
||||
return;
|
||||
}
|
||||
|
||||
$sql_quant = "SELECT $name FROM $usertype WHERE name='$username'";
|
||||
$res = mysqli_query($conn, $sql_quant);
|
||||
if ($res) {
|
||||
$num = mysqli_fetch_array($res);
|
||||
//if seller tries to sell more than 100kg fruits
|
||||
if(($usertype == "seller" && $num[$name] + $quantity <= 100) || $usertype == "buyer"){
|
||||
$add = "UPDATE $usertype SET $name = $name+$quantity WHERE name='$username'";
|
||||
$res = mysqli_query($conn, $add);
|
||||
}
|
||||
else{
|
||||
echo "<script type='text/javascript'>
|
||||
alert('You can only sell 100kg/type fruit one time!');
|
||||
window.top.location.href = '../../home.php';
|
||||
</script>";
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
header('Location: ./interfaces/success.php');
|
||||
?>
|
||||
148
indexes/process/cart.css
Normal file
148
indexes/process/cart.css
Normal file
@@ -0,0 +1,148 @@
|
||||
#grid{
|
||||
position:absolute;
|
||||
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;
|
||||
}
|
||||
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);
|
||||
}
|
||||
img: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;
|
||||
}
|
||||
body{
|
||||
height: 100%;
|
||||
width: 99%;
|
||||
z-index: 1;
|
||||
align-items: center;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
/* Hide scrollbar when not needed */
|
||||
body::-webkit-scrollbar {
|
||||
width: 0.5em;
|
||||
}
|
||||
body::-webkit-scrollbar-thumb {
|
||||
width: 0.5em;
|
||||
background: linear-gradient(rgba(109, 103, 103, 0.6), #00000000);
|
||||
border-radius: 0.25em;
|
||||
}
|
||||
#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;
|
||||
}
|
||||
129
indexes/process/cart_index.php
Normal file
129
indexes/process/cart_index.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Online Fruit Store</title>
|
||||
<script src="iframe.js"></script>
|
||||
<script src="item_modify.js"></script>
|
||||
<link rel="stylesheet" href="./cart.css" type="text/css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<br><br><br><br><br><br><br>
|
||||
|
||||
<div id="grid">
|
||||
|
||||
<?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"){
|
||||
$a = "seller_availability";
|
||||
$sql_col = "DESCRIBE seller";
|
||||
$m = "seller_price";
|
||||
}
|
||||
else{
|
||||
$a = "buyer_availability";
|
||||
$sql_col = "DESCRIBE buyer";
|
||||
$m = "buyer_price";
|
||||
}
|
||||
|
||||
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {
|
||||
$res = mysqli_query($conn, $sql_col);
|
||||
|
||||
// Extract column names into an array
|
||||
$col_name = array();
|
||||
while ($row = mysqli_fetch_array($res)) {
|
||||
$col_name[] = $row['Field'];
|
||||
}
|
||||
|
||||
$sql_cart = "SELECT * FROM $usertype WHERE name='$username'";
|
||||
$result = mysqli_query($conn, $sql_cart);
|
||||
$col = mysqli_num_fields($result);
|
||||
$goods = mysqli_fetch_array($result);
|
||||
$total = 0;
|
||||
|
||||
for ($i = 3; $i < $col; $i++) {
|
||||
//check availability
|
||||
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
|
||||
$check_sql = "SELECT $a FROM inventory WHERE name = '$col_name[$i]'";
|
||||
$res = mysqli_query($conn, $check_sql);
|
||||
$avail = mysqli_fetch_array($res);
|
||||
if($avail[$a] == 0 && $avail[$a] != null){
|
||||
echo "<script type='text/javascript'>
|
||||
alert('$col_name[$i] is currently unavailable!');
|
||||
</script>";
|
||||
}
|
||||
|
||||
if($goods[$i] > 0){
|
||||
$col_name_i = mysqli_real_escape_string($conn, $col_name[$i]);
|
||||
|
||||
//display image
|
||||
$sql_img = "SELECT img FROM inventory WHERE name='$col_name_i'";
|
||||
$picaddress = mysqli_query($conn, $sql_img);
|
||||
$img = mysqli_fetch_array($picaddress);
|
||||
|
||||
//get item
|
||||
$sql_price = "SELECT $m FROM inventory WHERE name='$col_name[$i]'";
|
||||
$res = mysqli_query($conn, $sql_price);
|
||||
$price = mysqli_fetch_array($res);
|
||||
|
||||
//unit price
|
||||
$unitprice = $price[$m];
|
||||
//total price
|
||||
$total += $unitprice * $goods[$i];
|
||||
|
||||
//display
|
||||
echo '<table id="items">';
|
||||
echo '<tr>';
|
||||
echo '<td width="20%">';
|
||||
echo '<img src="data:image/jpeg;base64,' . base64_encode($img['img']) . '" title="' . $col_name[$i] . '" id="' . $col_name[$i] . '" onclick="details(this)">';
|
||||
echo '</td>';
|
||||
echo '<td width="20%">';
|
||||
echo '<h4 style="margin: 0%;">' . $col_name[$i] . '</h4>';
|
||||
echo '</td>';
|
||||
echo '<td width="24%" id="icon">';
|
||||
echo '<p>¥'.$unitprice.'</p>';
|
||||
echo '</td>';
|
||||
echo '<td width="6%" id="icon">';
|
||||
echo '<img src="../../icon/add.svg" id="' . $col_name[$i] . '" onclick="item_add(this)">';
|
||||
echo '</td>';
|
||||
echo '<td width="8%">';
|
||||
echo '<input type="text" style="margin: 0%;" id="' . $col_name[$i] . '" value="' . $goods[$i] . '" onfocusout="item_modify(this)">';
|
||||
echo '</td>';
|
||||
echo '<td width="6%" id="icon">';
|
||||
echo '<img src="../../icon/subtract.svg" id="' . $col_name[$i] . '" onclick="item_subtract(this)">';
|
||||
echo '</td>';
|
||||
echo '<td width="6%" id="icon">';
|
||||
echo '<img src="../../icon/del.svg" id="' . $col_name[$i] . '" onclick="item_del(this)">';
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
echo '</table>';
|
||||
}
|
||||
}
|
||||
if($total != 0){
|
||||
echo '<br>';
|
||||
echo '<table width="20%" style="text-align: center;">';
|
||||
echo '<tr>';
|
||||
echo '<td><h1>Total Price: ¥ '.$total.'</h1></td>';
|
||||
echo '</tr>';
|
||||
echo '<tr>';
|
||||
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>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
149
indexes/process/checkup.php
Normal file
149
indexes/process/checkup.php
Normal file
@@ -0,0 +1,149 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Online Fruit Store</title>
|
||||
<link rel="stylesheet" href="./cart.css" type="text/css" />
|
||||
<script src="./item_modify.js"></script>
|
||||
<style>
|
||||
button {
|
||||
height: 32px;
|
||||
width: 300px;
|
||||
border: none;
|
||||
background: linear-gradient(to right, rgb(26, 117, 172), rgb(26, 158, 144));
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
box-shadow: 0px 0px 0px #424242;
|
||||
transition: 0.3s;
|
||||
border-radius: 5px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<br><br><br><br>
|
||||
|
||||
<div id="grid">
|
||||
|
||||
<?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") {
|
||||
$a = "seller_availability";
|
||||
$sql_col = "DESCRIBE seller";
|
||||
$m = "seller_price";
|
||||
} else {
|
||||
$a = "buyer_availability";
|
||||
$sql_col = "DESCRIBE buyer";
|
||||
$m = "buyer_price";
|
||||
}
|
||||
|
||||
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {
|
||||
// Get column names from the buyer table
|
||||
$res = mysqli_query($conn, $sql_col);
|
||||
|
||||
// Extract column names into an array
|
||||
$col_name = array();
|
||||
while ($row = mysqli_fetch_array($res)) {
|
||||
$col_name[] = $row['Field'];
|
||||
}
|
||||
|
||||
$sql_cart = "SELECT * FROM $usertype WHERE name='$username'";
|
||||
$result = mysqli_query($conn, $sql_cart);
|
||||
//get column number
|
||||
$col = mysqli_num_fields($result);
|
||||
//get goods
|
||||
$goods = mysqli_fetch_array($result);
|
||||
$total = 0;
|
||||
|
||||
//sub-banner
|
||||
echo '<table id="items" style="align-items: center; width: 98.5%; height: 5%;">';
|
||||
echo '<tr>';
|
||||
echo '<th width="30%">Image</th>';
|
||||
echo '<th width="20%">Fruit</th>';
|
||||
echo '<th width="30%">Unit-price</th>';
|
||||
echo '<th width="20%">Order</th>';
|
||||
echo '</tr>';
|
||||
echo '</table>';
|
||||
|
||||
for ($i = 3; $i < $col; $i++) {
|
||||
//check availability
|
||||
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
|
||||
$check_sql = "SELECT $a FROM inventory WHERE name = '$col_name[$i]'";
|
||||
$res = mysqli_query($conn, $check_sql);
|
||||
$avail = mysqli_fetch_array($res);
|
||||
if ($avail[$a] == 0 && $avail[$a] !== null) {
|
||||
echo "<script type='text/javascript'>
|
||||
alert('$col_name[$i] is currently unavailable!');
|
||||
</script>";
|
||||
}
|
||||
|
||||
if ($goods[$i] > 0) {
|
||||
//display image
|
||||
$sql_img = "SELECT img FROM inventory WHERE name='$col_name[$i]'";
|
||||
$picaddress = mysqli_query($conn, $sql_img);
|
||||
$img = mysqli_fetch_array($picaddress);
|
||||
|
||||
//get unit price
|
||||
$sql_price = "SELECT $m FROM inventory WHERE name='$col_name[$i]'";
|
||||
$res = mysqli_query($conn, $sql_price);
|
||||
$price = mysqli_fetch_array($res);
|
||||
|
||||
//unit price
|
||||
$unitprice = $price[$m];
|
||||
//total price
|
||||
$total += $unitprice * $goods[$i];
|
||||
|
||||
//display
|
||||
echo '<table id="items">';
|
||||
echo '<tr>';
|
||||
echo '<td width="24%">';
|
||||
echo '<img src="data:image/jpeg;base64,' . base64_encode($img['img']) . '" title="' . $col_name[$i] . '" id="' . $col_name[$i] . '"">';
|
||||
echo '</td>';
|
||||
echo '<td width="24%">';
|
||||
echo '<h4 style="margin: 0%;">' . $col_name[$i] . '</h4>';
|
||||
echo '</td>';
|
||||
echo '<td width="24%" id="icon">';
|
||||
echo '<p>¥'.$unitprice.'</p>';
|
||||
echo '</td>';
|
||||
echo '<td width="8%" id="icon">';
|
||||
echo '<img src="../../icon/add.svg" id="' . $col_name[$i] . '" onclick="item_checkup_add(this)">';
|
||||
echo '</td>';
|
||||
echo '<td width="12%">';
|
||||
echo '<input type="text" style="margin: 0%;" id="' . $col_name[$i] . '" value="' . $goods[$i] . '" onblur="item_checkup_modify(this)">';
|
||||
echo '</td>';
|
||||
echo '<td width="8%" id="icon">';
|
||||
echo '<img src="../../icon/subtract.svg" id="' . $col_name[$i] . '" onclick="item_checkup_subtract(this)">';
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
echo '</table>';
|
||||
}
|
||||
}
|
||||
echo '<br>';
|
||||
echo '<table width="20%" style="text-align: center;">';
|
||||
echo '<tr>';
|
||||
echo '<td><h1>Total Price: ¥ '.$total.'</h1></td>';
|
||||
echo '</tr>';
|
||||
echo '<td>';
|
||||
echo '<form action="./order.php" method="POST">';
|
||||
if($usertype == 'buyer'){
|
||||
echo '<button type="submit">Order</button>';
|
||||
}
|
||||
else{
|
||||
echo '<button type="submit">Sell</button>';
|
||||
}
|
||||
echo '</form>';
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
echo '</table>';
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
113
indexes/process/checkup_now.php
Normal file
113
indexes/process/checkup_now.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<link rel="stylesheet" href="./cart.css" type="text/css" />
|
||||
<?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") {
|
||||
$a = "seller_availability";
|
||||
$m = "seller_price";
|
||||
}
|
||||
else {
|
||||
$a = "buyer_availability";
|
||||
$m = "buyer_price";
|
||||
}
|
||||
|
||||
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {
|
||||
if (isset($_GET["name"], $_GET["quantity"])) {
|
||||
|
||||
echo '<br><br><br><br>';
|
||||
|
||||
//check availability
|
||||
if($_GET["quantity"] > 100 && $usertype == "seller"){
|
||||
echo "<script type='text/javascript'>
|
||||
alert('You can only sell 100kg/type fruit one time!');
|
||||
window.top.location.href = '../../home.php';
|
||||
</script>";
|
||||
exit();
|
||||
}
|
||||
|
||||
$name = mysqli_real_escape_string($conn, $_GET["name"]);
|
||||
$check_sql = "SELECT $a FROM inventory WHERE name = '$name'";
|
||||
$res = mysqli_query($conn, $check_sql);
|
||||
$avail = mysqli_fetch_array($res);
|
||||
if ($avail[$a] == 0 && $avail[$a] !== null) {
|
||||
$errorMessage = $_GET["name"] . " is currently unavailable";
|
||||
echo "<script type='text/javascript'>
|
||||
window.location.href = './interfaces/failed.php?why=" . urlencode($errorMessage) . "';
|
||||
</script>";
|
||||
exit();
|
||||
}
|
||||
|
||||
//get image
|
||||
$sql_img = "SELECT img FROM inventory WHERE name='$name'";
|
||||
$picaddress = mysqli_query($conn, $sql_img);
|
||||
$img = mysqli_fetch_array($picaddress);
|
||||
|
||||
//get unit price
|
||||
$sql_price = "SELECT $m FROM inventory WHERE name='$name'";
|
||||
$res = mysqli_query($conn, $sql_price);
|
||||
$price = mysqli_fetch_array($res);
|
||||
//get unit total price
|
||||
$fruitprice = $price[$m] * $_GET["quantity"];
|
||||
|
||||
//display
|
||||
echo '<table id="items" style="align-items: center; width: 98.5%;">';
|
||||
echo '<tr>';
|
||||
echo '<th width="30%">Image</th>';
|
||||
echo '<th width="30%">Fruit</th>';
|
||||
echo '<th width="20%">Order</th>';
|
||||
echo '<th width="20%">Unit-price</th>';
|
||||
echo '</tr>';
|
||||
echo '</table>';
|
||||
|
||||
echo '<table id="items" style="align-items: center; width: 98.5%;">';
|
||||
echo '<tr>';
|
||||
echo '<td width="30%">';
|
||||
echo '<img src="data:image/jpeg;base64,' . base64_encode($img['img']) . '" title="' . $name . '" id="' . $name . '">';
|
||||
echo '</td>';
|
||||
echo '<td width="30%">';
|
||||
echo '<h4 style="margin: 0%;">' . $name . '</h4>';
|
||||
echo '</td>';
|
||||
echo '<td width="20%">';
|
||||
echo '<p style="margin: 0%;" id="' . $name . '">' . $_GET["quantity"] . ' kg</p>';
|
||||
echo '</td>';
|
||||
echo '<td width="20%">';
|
||||
echo '<p style="margin: 0%;">¥'.$price[$m].'/kg</p>';
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
echo '</table>';
|
||||
|
||||
echo '<br>';
|
||||
|
||||
echo '<table style="text-align: center;" width="100%">';
|
||||
echo '<tr>';
|
||||
echo '<td><h1>Total Price: ¥ '.$fruitprice.'</h1></td>';
|
||||
echo '</tr>';
|
||||
echo '<td>';
|
||||
|
||||
$urlParams = "name=" . urlencode($_GET["name"]) . "&amount=" . urlencode($_GET["quantity"]); // URL-encode the parameters
|
||||
echo '<form action="./ordernow.php?' . $urlParams . '" method="POST">';
|
||||
if ($usertype == 'buyer') {
|
||||
echo '<button type="submit">Order</button>';
|
||||
}
|
||||
else {
|
||||
echo '<button style="align-items: center; width: 98.5%;" type="submit">Sell</button>';
|
||||
}
|
||||
echo '</form>';
|
||||
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
echo '</table>';
|
||||
}
|
||||
else{
|
||||
echo "<script type='text/javascript'>
|
||||
window.location.href = './interfaces/failed.php?why=Unknown Error Occurred';
|
||||
</script>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
45
indexes/process/iframe.js
Normal file
45
indexes/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);
|
||||
}
|
||||
}
|
||||
|
||||
94
indexes/process/index_.php
Normal file
94
indexes/process/index_.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<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">';
|
||||
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/process/interfaces/failed.php
Normal file
25
indexes/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';}, 1200);
|
||||
</script>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
17
indexes/process/interfaces/instruct.css
Normal file
17
indexes/process/interfaces/instruct.css
Normal file
@@ -0,0 +1,17 @@
|
||||
#area{
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
width: 45%;
|
||||
left: 0;
|
||||
top: 12%;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
margin: auto;
|
||||
user-select: none;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
}
|
||||
img{
|
||||
width: 40%;
|
||||
height: 40%;
|
||||
margin: none;
|
||||
}
|
||||
76
indexes/process/interfaces/show_receipt.php
Normal file
76
indexes/process/interfaces/show_receipt.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Success</title>
|
||||
<style>
|
||||
td{
|
||||
font-size: small;
|
||||
}
|
||||
th{
|
||||
font-size: small;
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" href="../cart.css" type="text/css" />
|
||||
<link rel="stylesheet" href="./instruct.css" type="text/css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="area">
|
||||
<img style="margin:0%;" onclick="gotohome()" src="../../../icon/check.svg">
|
||||
<h1>Success</h1>
|
||||
<h3 onclick="gotohome()" style="cursor: hand; color: green;">return home</h3>
|
||||
|
||||
<?php
|
||||
if(isset($_GET["details"], $_GET["total"], $_GET["date"])) {
|
||||
|
||||
echo '<div id="grid">';
|
||||
|
||||
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("|", $_GET["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>".$_GET["date"]."</td>";
|
||||
echo "<td>¥".$_GET["total"]."</td>";
|
||||
echo '</tr>';
|
||||
|
||||
echo "</table>";
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
?>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function gotohome(){
|
||||
window.top.location.href = '../../../home.php';
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
16
indexes/process/interfaces/success.php
Normal file
16
indexes/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 = '../../../home.php';}, 600);
|
||||
</script>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
149
indexes/process/item_details.php
Normal file
149
indexes/process/item_details.php
Normal file
@@ -0,0 +1,149 @@
|
||||
<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";
|
||||
}
|
||||
$sql="SELECT * FROM inventory WHERE name = '".$_GET['myParam']."' ";
|
||||
$res = mysqli_query($conn, $sql);
|
||||
$goods = mysqli_fetch_assoc($res);
|
||||
?>
|
||||
|
||||
<div id="area">
|
||||
<table>
|
||||
<tr>
|
||||
<td width="50%" style="text-align: right;">
|
||||
<img src="data:image/jpeg;base64,<?php echo base64_encode($goods['img']); ?>" 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>
|
||||
36
indexes/process/item_modify.js
Normal file
36
indexes/process/item_modify.js
Normal file
@@ -0,0 +1,36 @@
|
||||
function item_add(tag){
|
||||
var name = tag.id;
|
||||
window.location.href = "./modify/item_add.php?name=" + name;
|
||||
}
|
||||
|
||||
function item_subtract(tag){
|
||||
var name = tag.id;
|
||||
window.location.href = "./modify/item_subtract.php?name=" + name;
|
||||
}
|
||||
|
||||
function item_del(tag){
|
||||
var name = tag.id;
|
||||
window.location.href = "./modify/item_del.php?name=" + name;
|
||||
}
|
||||
|
||||
function item_modify(tag){
|
||||
var name = tag.id;
|
||||
var quantity = tag.value;
|
||||
window.location.href = "./modify/item_modify.php?name=" + name + "&quantity=" + quantity;
|
||||
}
|
||||
|
||||
function item_checkup_add(tag){
|
||||
var name = tag.id;
|
||||
window.location.href = "./modify/item_checkup_add.php?name=" + name;
|
||||
}
|
||||
|
||||
function item_checkup_subtract(tag){
|
||||
var name = tag.id;
|
||||
window.location.href = "./modify/item_checkup_subtract.php?name=" + name;
|
||||
}
|
||||
|
||||
function item_checkup_modify(tag){
|
||||
var name = tag.id;
|
||||
var quantity = tag.value;
|
||||
window.location.href = "./modify/item_checkup_modify.php?name=" + name + "&quantity=" + quantity;
|
||||
}
|
||||
33
indexes/process/modify/item_add.php
Normal file
33
indexes/process/modify/item_add.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
include "../../ConnectDB.php";
|
||||
session_start();
|
||||
$username = mysqli_real_escape_string($conn, $_SESSION['username']);
|
||||
$usertype = mysqli_real_escape_string($conn, $_SESSION['user_type']);
|
||||
|
||||
if(isset($_GET["name"])) {
|
||||
$name = $_GET["name"];
|
||||
//seller cannot add more than 100kg
|
||||
if($usertype == "seller"){
|
||||
$sql_check = "SELECT $name FROM seller WHERE name='$username'";
|
||||
$res = mysqli_query($conn, $sql_check);
|
||||
$num = mysqli_fetch_array($res);
|
||||
if($num[$name] + 1 > 100){
|
||||
echo "<script type='text/javascript'>
|
||||
alert('You cannot sell more than 100kg/fruit one time!');
|
||||
window.location.href = '../cart_index.php';
|
||||
</script>";
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
$add = "UPDATE $usertype SET $name = $name + 1 WHERE name='$username'";
|
||||
$res = mysqli_query($conn, $add);
|
||||
if(!$res){
|
||||
echo "<script type='text/javascript'>
|
||||
alert('Error occurred!');
|
||||
</script>";
|
||||
}
|
||||
}
|
||||
|
||||
header('Location: ../cart_index.php');
|
||||
?>
|
||||
34
indexes/process/modify/item_checkup_add.php
Normal file
34
indexes/process/modify/item_checkup_add.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
include "../../ConnectDB.php";
|
||||
session_start();
|
||||
$username = mysqli_real_escape_string($conn, $_SESSION['username']);
|
||||
$usertype = mysqli_real_escape_string($conn, $_SESSION['user_type']);
|
||||
|
||||
if(isset($_GET["name"])) {
|
||||
$name = $_GET["name"];
|
||||
//seller cannot add more than 100kg
|
||||
//seller cannot add more than 100kg
|
||||
if($usertype == "seller"){
|
||||
$sql_check = "SELECT $name FROM seller WHERE name='$username'";
|
||||
$res = mysqli_query($conn, $sql_check);
|
||||
$num = mysqli_fetch_array($res);
|
||||
if($num[$name] + 1 > 100){
|
||||
echo "<script type='text/javascript'>
|
||||
alert('You cannot sell more than 100kg/fruit one time!');
|
||||
window.location.href = '../cart_index.php';
|
||||
</script>";
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
$add = "UPDATE $usertype SET $name = $name + 1 WHERE name='$username'";
|
||||
$res = mysqli_query($conn, $add);
|
||||
if(!$res){
|
||||
echo "<script type='text/javascript'>
|
||||
alert('Error occurred!');
|
||||
</script>";
|
||||
}
|
||||
}
|
||||
|
||||
header('Location: ../checkup.php');
|
||||
?>
|
||||
34
indexes/process/modify/item_checkup_modify.php
Normal file
34
indexes/process/modify/item_checkup_modify.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
include "../../ConnectDB.php";
|
||||
session_start();
|
||||
$username = mysqli_real_escape_string($conn, $_SESSION['username']);
|
||||
$usertype = mysqli_real_escape_string($conn, $_SESSION['user_type']);
|
||||
|
||||
if (isset($_GET["name"], $_GET["quantity"])) {
|
||||
if ($_GET["quantity"] > 0 && ($_GET["quantity"] <= 100 || $usertype == "buyer")) {
|
||||
$quantity = $_GET["quantity"];
|
||||
$name = mysqli_real_escape_string($conn, $_GET["name"]);
|
||||
$add = "UPDATE $usertype SET `$name` = $quantity WHERE name='$username'";
|
||||
$res = mysqli_query($conn, $add);
|
||||
if (!$res) {
|
||||
echo "<script type='text/javascript'>
|
||||
alert('Error occurred!');
|
||||
</script>";
|
||||
}
|
||||
}
|
||||
else if ($_GET["quantity"] > 100 && $usertype == "seller") {
|
||||
echo "<script type='text/javascript'>
|
||||
alert('You can only buy 100kg of each type of fruit at a time!');
|
||||
</script>";
|
||||
}
|
||||
else{
|
||||
echo "<script type='text/javascript'>
|
||||
alert('You cannot buy nothing!');
|
||||
</script>";
|
||||
}
|
||||
}
|
||||
|
||||
echo "<script type='text/javascript'>
|
||||
window.location.href = '../checkup.php';
|
||||
</script>";
|
||||
?>
|
||||
34
indexes/process/modify/item_checkup_subtract.php
Normal file
34
indexes/process/modify/item_checkup_subtract.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
include "../../ConnectDB.php";
|
||||
session_start();
|
||||
$username = mysqli_real_escape_string($conn, $_SESSION['username']);
|
||||
$usertype = mysqli_real_escape_string($conn, $_SESSION['user_type']);
|
||||
|
||||
if (isset($_GET["name"])) {
|
||||
$name = $_GET["name"];
|
||||
$sql_quant = "SELECT $name FROM $usertype WHERE name='$username'";
|
||||
$res = mysqli_query($conn, $sql_quant);
|
||||
|
||||
if ($res) {
|
||||
$num = mysqli_fetch_array($res);
|
||||
|
||||
if ($num[$name] > 1) {
|
||||
$add = "UPDATE $usertype SET `$name` = `$name` - 1 WHERE name='$username'";
|
||||
$res = mysqli_query($conn, $add);
|
||||
}
|
||||
else {
|
||||
echo "<script type='text/javascript'>
|
||||
alert('You cannot buy for nothing!');
|
||||
</script>";
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Handle the SQL query error
|
||||
echo "Error: " . mysqli_error($conn);
|
||||
}
|
||||
}
|
||||
|
||||
echo "<script type='text/javascript'>
|
||||
window.location.href = '../checkup.php';
|
||||
</script>";
|
||||
?>
|
||||
14
indexes/process/modify/item_del.php
Normal file
14
indexes/process/modify/item_del.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
include "../../ConnectDB.php";
|
||||
session_start();
|
||||
$username = mysqli_real_escape_string($conn, $_SESSION['username']);
|
||||
$usertype = mysqli_real_escape_string($conn, $_SESSION['user_type']);
|
||||
|
||||
if(isset($_GET["name"])) {
|
||||
$name = $_GET["name"];
|
||||
$add = "UPDATE $usertype SET $name = 0 WHERE name='$username'";
|
||||
$res = mysqli_query($conn, $add);
|
||||
}
|
||||
|
||||
header('Location: ../cart_index.php');
|
||||
?>
|
||||
23
indexes/process/modify/item_modify.php
Normal file
23
indexes/process/modify/item_modify.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
include "../../ConnectDB.php";
|
||||
session_start();
|
||||
$username = mysqli_real_escape_string($conn, $_SESSION['username']);
|
||||
$usertype = mysqli_real_escape_string($conn, $_SESSION['user_type']);
|
||||
|
||||
if(isset($_GET["name"], $_GET["quantity"])) {
|
||||
$name = $_GET["name"];
|
||||
$quantity = $_GET["quantity"];
|
||||
|
||||
if(($usertype == "seller" && $quantity >= 0 && $quantity <= 100) || ($usertype == "buyer" && $quantity >= 0)){
|
||||
$add = "UPDATE $usertype SET $name = $quantity WHERE name='$username'";
|
||||
$res = mysqli_query($conn, $add);
|
||||
}
|
||||
else{
|
||||
echo "<script type='text/javascript'>
|
||||
alert('Please input a valid amount of fruit!');
|
||||
</script>";
|
||||
}
|
||||
}
|
||||
header('Location: ../cart_index.php');
|
||||
?>
|
||||
|
||||
13
indexes/process/modify/item_subtract.php
Normal file
13
indexes/process/modify/item_subtract.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
include "../../ConnectDB.php";
|
||||
session_start();
|
||||
$username = mysqli_real_escape_string($conn, $_SESSION['username']);
|
||||
$usertype = mysqli_real_escape_string($conn, $_SESSION['user_type']);
|
||||
|
||||
if(isset($_GET["name"])) {
|
||||
$name = $_GET["name"];
|
||||
$add = "UPDATE $usertype SET $name = $name-1 WHERE name='$username'";
|
||||
$res = mysqli_query($conn, $add);
|
||||
}
|
||||
header('Location: ../cart_index.php');
|
||||
?>
|
||||
172
indexes/process/order.php
Normal file
172
indexes/process/order.php
Normal file
@@ -0,0 +1,172 @@
|
||||
<?php
|
||||
include "../ConnectDB.php";
|
||||
|
||||
// Start the session
|
||||
session_start();
|
||||
|
||||
// Escape the username and user type for security
|
||||
$username = mysqli_real_escape_string($conn, $_SESSION['username']);
|
||||
$usertype = mysqli_real_escape_string($conn, $_SESSION['user_type']);
|
||||
|
||||
// Define table and column names based on the user type
|
||||
if ($usertype == 'seller') {
|
||||
$a = "seller_availability";
|
||||
$m = "seller_price";
|
||||
$r = "seller_receipt";
|
||||
$sql_col = "DESCRIBE seller";
|
||||
$c = "profit";
|
||||
} else {
|
||||
$a = "buyer_availability";
|
||||
$m = "buyer_price";
|
||||
$r = "buyer_receipt";
|
||||
$sql_col = "DESCRIBE buyer";
|
||||
$c = "money";
|
||||
}
|
||||
|
||||
// Get column names from the buyer/seller table
|
||||
$res = mysqli_query($conn, $sql_col);
|
||||
|
||||
// Extract column names into an array
|
||||
$col_name = array();
|
||||
while ($row = mysqli_fetch_array($res)) {
|
||||
$col_name[] = $row['Field'];
|
||||
}
|
||||
|
||||
// Retrieve the user's cart items
|
||||
$sql_cart = "SELECT * FROM $usertype WHERE name='$username'";
|
||||
$result = mysqli_query($conn, $sql_cart);
|
||||
$col = mysqli_num_fields($result);
|
||||
$goods = mysqli_fetch_array($result);
|
||||
$details = "";
|
||||
$total = 0;
|
||||
|
||||
for ($i = 3; $i < $col; $i++) {
|
||||
if ($goods[$i] > 0) {
|
||||
$sql_check_availability = "SELECT $a FROM inventory WHERE name='$col_name[$i]'";
|
||||
$res = mysqli_query($conn, $sql_check_availability);
|
||||
$avail = mysqli_fetch_array($res);
|
||||
if ($avail[$a] != 1) {
|
||||
// Handle unavailability case (e.g., display an error message)
|
||||
echo "<script type='text/javascript'>
|
||||
window.location.href = './interfaces/failed.php?why=Item \'$col_name[$i]\'. is currently unavailable';
|
||||
</script>";
|
||||
exit();
|
||||
}
|
||||
|
||||
//get inventory
|
||||
$sql_check_inventory = "SELECT quantities FROM inventory WHERE name='$col_name[$i]'";
|
||||
$res = mysqli_query($conn, $sql_check_inventory);
|
||||
$inventory = mysqli_fetch_array($res);
|
||||
|
||||
//if sufficient inventory
|
||||
if ($inventory['quantities'] >= $goods[$i] || $usertype == "seller") {
|
||||
$sql_price = "SELECT $m FROM inventory WHERE name='$col_name[$i]'";
|
||||
$res = mysqli_query($conn, $sql_price);
|
||||
$price = mysqli_fetch_array($res);
|
||||
//unit price
|
||||
$fruitprice = $price[$m] * $goods[$i];
|
||||
//total price
|
||||
$total += $fruitprice;
|
||||
}
|
||||
else {
|
||||
echo "<script type='text/javascript'>
|
||||
window.location.href = './interfaces/failed.php?why=Insufficient inventory for item \'$col_name[$i]\'.';
|
||||
</script>";
|
||||
exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if buyer donot have enough balance
|
||||
$sql_checkmoney = "SELECT $c FROM $usertype WHERE name='$username'";
|
||||
$res = mysqli_query($conn, $sql_checkmoney);
|
||||
$balance = mysqli_fetch_array($res);
|
||||
if($balance[$c] < $total && $usertype == "buyer"){
|
||||
echo "<script type='text/javascript'>
|
||||
window.location.href = './interfaces/failed.php?why=Insufficient Balance';
|
||||
</script>";
|
||||
exit();
|
||||
}
|
||||
|
||||
//check cashflow
|
||||
$sql_sell_out = "SELECT details FROM buyer_receipt WHERE name='sell_out'";
|
||||
$result = mysqli_query($conn, $sql_sell_out);
|
||||
$sell_out = mysqli_fetch_array($result);
|
||||
|
||||
$sql_buy_in = "SELECT details FROM seller_receipt WHERE name='buy_in'";
|
||||
$result = mysqli_query($conn, $sql_buy_in);
|
||||
$buy_in = mysqli_fetch_array($result);
|
||||
$profit = $sell_out['details'] - $buy_in['details'];
|
||||
|
||||
//if insufficient cashflow
|
||||
if($profit < $total && $usertype == "seller"){
|
||||
echo "<script type='text/javascript'>
|
||||
window.location.href = './interfaces/failed.php?why=Insufficient Cashflow';
|
||||
</script>";
|
||||
exit();
|
||||
}
|
||||
|
||||
else{
|
||||
for ($i = 3; $i < $col; $i++) {
|
||||
if ($goods[$i] > 0) {
|
||||
//get price
|
||||
$sql_price = "SELECT $m FROM inventory WHERE name='$col_name[$i]'";
|
||||
$res = mysqli_query($conn, $sql_price);
|
||||
$price = mysqli_fetch_array($res);
|
||||
//unit total price
|
||||
$fruitprice = $price[$m] * $goods[$i];
|
||||
|
||||
// Update the user's cart by setting the item quantity to 0
|
||||
$sql_closecart = "UPDATE $usertype SET `$col_name[$i]` = 0 WHERE name='$username'";
|
||||
$res = mysqli_query($conn, $sql_closecart);
|
||||
|
||||
// Update the inventory based on the user type
|
||||
if ($usertype == 'buyer') {
|
||||
$sql_update_inventory = "UPDATE inventory SET quantities = quantities - $goods[$i] WHERE name='$col_name[$i]'";
|
||||
} else {
|
||||
$sql_update_inventory = "UPDATE inventory SET quantities = quantities + $goods[$i] WHERE name='$col_name[$i]'";
|
||||
}
|
||||
$res = mysqli_query($conn, $sql_update_inventory);
|
||||
|
||||
// Create the details string for the receipt
|
||||
$details .= "$col_name[$i]|$goods[$i]|$price[$m]|$fruitprice|";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get the current date and time in HK
|
||||
$date = new DateTime('now');
|
||||
$date->setTimezone(new DateTimeZone('Asia/Hong_Kong'));
|
||||
$formattedDate = $date->format('Y-m-d H:i:s');
|
||||
|
||||
// Use the formatted date in your SQL query
|
||||
$sql_add_receipt = "INSERT INTO `$r` (`name`, `details`, `total`, `date`) VALUES ('$username', '$details', '$total', '$formattedDate')";
|
||||
|
||||
$result = mysqli_query($conn, $sql_add_receipt);
|
||||
|
||||
// Deduct the total amount from the user's money
|
||||
if($usertype == "buyer"){
|
||||
$sql_money = "UPDATE buyer SET money = money - $total WHERE name='$username'";
|
||||
$sql_profit = "UPDATE buyer_receipt SET details = details + $total WHERE name='sell_out'";
|
||||
}
|
||||
else{
|
||||
$sql_money = "UPDATE seller SET profit = profit + $total WHERE name='$username'";
|
||||
$sql_profit = "UPDATE seller_receipt SET details = details + $total WHERE name='buy_in'";
|
||||
}
|
||||
$result = mysqli_query($conn, $sql_money);
|
||||
$result_profit = mysqli_query($conn, $sql_profit);
|
||||
|
||||
if ($result && $result_profit) {
|
||||
echo "<script type='text/javascript'>
|
||||
var details = '" . $details . "';
|
||||
var total = '" . $total . "';
|
||||
var date = '" . $formattedDate . "';
|
||||
window.location.href = './interfaces/show_receipt.php?details=' + encodeURIComponent(details) + '&total=' + encodeURIComponent(total) + '&date=' + encodeURIComponent(date);
|
||||
</script>";
|
||||
}
|
||||
|
||||
else{
|
||||
header('Location: ./interfaces/failed.php');
|
||||
}
|
||||
|
||||
?>
|
||||
131
indexes/process/ordernow.php
Normal file
131
indexes/process/ordernow.php
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
include "../ConnectDB.php";
|
||||
|
||||
// Start the session
|
||||
session_start();
|
||||
|
||||
// Escape the username and user type for security
|
||||
$username = mysqli_real_escape_string($conn, $_SESSION['username']);
|
||||
$usertype = mysqli_real_escape_string($conn, $_SESSION['user_type']);
|
||||
|
||||
// Define table and column names based on the user type
|
||||
if ($usertype == 'seller') {
|
||||
$a = "seller_availability";
|
||||
$m = "seller_price";
|
||||
$r = "seller_receipt";
|
||||
$c = "profit";
|
||||
}
|
||||
else {
|
||||
$a = "buyer_availability";
|
||||
$m = "buyer_price";
|
||||
$r = "buyer_receipt";
|
||||
$c = "money";
|
||||
}
|
||||
|
||||
if (isset($_GET["name"], $_GET["amount"])) {
|
||||
$name = mysqli_real_escape_string($conn, $_GET["name"]);
|
||||
|
||||
//check availability
|
||||
$check_sql = "SELECT $a FROM inventory WHERE name = '$name'";
|
||||
$res = mysqli_query($conn, $check_sql);
|
||||
$avail = mysqli_fetch_array($res);
|
||||
if ($avail[$a] == 0 && $avail[$a] !== null) {
|
||||
$errorMessage = urlencode("$name is currently unavailable");
|
||||
header("Location: ./interfaces/failed.php?why=$errorMessage");
|
||||
exit();
|
||||
}
|
||||
|
||||
//get inventory
|
||||
$sql_check_inventory = "SELECT quantities FROM inventory WHERE name = '$name'";
|
||||
$res = mysqli_query($conn, $sql_check_inventory);
|
||||
$inventory = mysqli_fetch_array($res);
|
||||
|
||||
//if sufficient inventery
|
||||
if ($inventory['quantities'] >= $_GET["amount"] || $usertype == "seller") {
|
||||
$sql_price = "SELECT $m FROM inventory WHERE name='$name'";
|
||||
$res = mysqli_query($conn, $sql_price);
|
||||
$price = mysqli_fetch_array($res);
|
||||
//unit total price
|
||||
$fruitprice = $price[$m] * $_GET["amount"];
|
||||
|
||||
//get user balance
|
||||
$sql_checkmoney = "SELECT $c FROM $usertype WHERE name = '$username'";
|
||||
$res = mysqli_query($conn, $sql_checkmoney);
|
||||
$balance = mysqli_fetch_array($res);
|
||||
|
||||
//if buyer have no balance
|
||||
if ($balance[$c] < $fruitprice && $usertype == "buyer") {
|
||||
$errorMessage = urlencode("Insufficient Balance");
|
||||
header("Location: ./interfaces/failed.php?why=$errorMessage");
|
||||
exit();
|
||||
}
|
||||
|
||||
//check cashflow
|
||||
$sql_sell_out = "SELECT details FROM buyer_receipt WHERE name='sell_out'";
|
||||
$result = mysqli_query($conn, $sql_sell_out);
|
||||
$sell_out = mysqli_fetch_array($result);
|
||||
|
||||
$sql_buy_in = "SELECT details FROM seller_receipt WHERE name='buy_in'";
|
||||
$result = mysqli_query($conn, $sql_buy_in);
|
||||
$buy_in = mysqli_fetch_array($result);
|
||||
$profit = $sell_out['details'] - $buy_in['details'];
|
||||
|
||||
//if insufficient cashflow
|
||||
if($profit < $total && $usertype == "seller"){
|
||||
echo "<script type='text/javascript'>
|
||||
window.location.href = './interfaces/failed.php?why=Insufficient Cashflow';
|
||||
</script>";
|
||||
exit();
|
||||
}
|
||||
|
||||
//update user balance
|
||||
if ($usertype == 'buyer') {
|
||||
$sql_update_inventory = "UPDATE inventory SET quantities = quantities - {$_GET["amount"]} WHERE name='$name'";
|
||||
}
|
||||
else {
|
||||
$sql_update_inventory = "UPDATE inventory SET quantities = quantities + {$_GET["amount"]} WHERE name='$name'";
|
||||
}
|
||||
$res = mysqli_query($conn, $sql_update_inventory);
|
||||
|
||||
// Create the details string for the receipt
|
||||
$details = "$name|{$_GET["amount"]}|$price[$m]|$fruitprice|";
|
||||
|
||||
// Get the current date and time in Hong Kong
|
||||
$date = new DateTime('now', new DateTimeZone('Asia/Hong_Kong'));
|
||||
$formattedDate = $date->format('Y-m-d H:i:s');
|
||||
|
||||
// Use the formatted date in your SQL query
|
||||
$sql_add_receipt = "INSERT INTO `$r` (`name`, `details`, `total`, `date`) VALUES ('$username', '$details', '$fruitprice', '$formattedDate')";
|
||||
|
||||
$result = mysqli_query($conn, $sql_add_receipt);
|
||||
|
||||
// Deduct the total amount from the user's money
|
||||
if ($usertype == "buyer") {
|
||||
$sql_money = "UPDATE buyer SET money = money - $fruitprice WHERE name='$username'";
|
||||
$sql_profit = "UPDATE buyer_receipt SET details = details + $fruitprice WHERE name='sell_out'";
|
||||
} else {
|
||||
$sql_money = "UPDATE seller SET profit = profit + $fruitprice WHERE name='$username'";
|
||||
$sql_profit = "UPDATE seller_receipt SET details = details + $fruitprice WHERE name='buy_in'";
|
||||
}
|
||||
$result = mysqli_query($conn, $sql_money);
|
||||
$result_profit = mysqli_query($conn, $sql_profit);
|
||||
|
||||
if ($result && $result_profit) {
|
||||
echo "<script type='text/javascript'>
|
||||
var details = '" . $details . "';
|
||||
var total = '" . $fruitprice . "';
|
||||
var date = '" . $formattedDate . "';
|
||||
window.location.href = './interfaces/show_receipt.php?details=' + encodeURIComponent(details) + '&total=' + encodeURIComponent(total) + '&date=' + encodeURIComponent(date);
|
||||
</script>";
|
||||
}
|
||||
else {
|
||||
header('Location: ./interfaces/failed.php');
|
||||
}
|
||||
}
|
||||
else {
|
||||
$errorMessage = urlencode("Insufficient inventory for item '$name'");
|
||||
header("Location: ./interfaces/failed.php?why=$errorMessage");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
?>
|
||||
85
indexes/process/receipt.php
Normal file
85
indexes/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>';
|
||||
?>
|
||||
213
indexes/process/show_item.css
Normal file
213
indexes/process/show_item.css
Normal file
@@ -0,0 +1,213 @@
|
||||
#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;
|
||||
font-style: rgb(10, 22, 44);
|
||||
user-select: none;
|
||||
text-align: center;
|
||||
align-items: left;
|
||||
}
|
||||
#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;
|
||||
}
|
||||
|
||||
/* Hide scrollbar when not needed */
|
||||
body::-webkit-scrollbar {
|
||||
width: 0.5em;
|
||||
}
|
||||
body::-webkit-scrollbar-thumb {
|
||||
width: 0.5em;
|
||||
background: linear-gradient(rgba(109, 103, 103, 0.6), #00000000);
|
||||
border-radius: 0.25em;
|
||||
}
|
||||
#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