Initial commit
This commit is contained in:
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>
|
||||
Reference in New Issue
Block a user