2025-06-06 17:14:52 +08:00

136 lines
4.5 KiB
PHP

<link rel="stylesheet" href="../../index.css" type="text/css" />
<html>
<head>
<style>
textarea{
background-color: #00000000;
border: none;
border-radius: 12px;
outline: none;
font-size: 75%;
width: 100%;
height: max-content;
}
textarea:focus{
border: none;
}
body{
overflow: auto;
}
</style>
</head>
</html>
<?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['user_type']) && $_SESSION['user_type'] === 'admin') {
echo '<br><br><br><br><br><br><br>';
//check cashflow
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
$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'];
echo "<h2 style='text-align: center; color: white;'>Cash Flow: ¥".$profit."</h2>";
$sql = "SELECT * FROM inventory";
$result = mysqli_query($conn, $sql);
$row = mysqli_num_rows($result);
if($row <= 0){
echo '<h2>Nothing Here</h2>';
return;
}
echo '<div id="grid">';
for ($i = 0; $i < $row; $i++) {
//get number of columns
$fields = mysqli_num_fields($result);
//Get each row data and display
while ($row_data = mysqli_fetch_array($result)){
echo '<table id="items" style="text-align: left;">';
echo '<tr>';
echo '<th>Image </th>';
echo '<td colspan="2">
<img src="data:image/jpeg;base64,' . base64_encode($row_data['img']) . '" title="' . $row_data['imgname'] . '" id="' . $row_data['name'] . '" onclick="details(this)"
style="width:30%"></td>';
echo '</tr>';
echo "<tr>";
echo "<th width='40%'>Name </th>";
echo "<td width='60%' colspan='2'>".$row_data['name']."</td>";
echo "</tr>";
echo "<tr>";
echo "<th>Short description </th>";
echo "<td colspan='2'>".$row_data['simpledesc']."</td>";
echo "</tr>";
echo "<tr>";
echo "<th width='40%'>Full description </th>";
echo "<td width='60%' style='overflox: auto;' colspan='2'><textarea readonly>"
.$row_data['fulldesc']."</textarea></td>";
echo "</tr>";
echo "<tr>";
echo "<th width='40%'>Inventory </th>";
echo "<td windth='max-content'>".$row_data['quantities']." kg</td>";
echo "</tr>";
echo "<tr>";
echo "<th width='40%'>Buyer price </th>";
echo "<td windth='max-content'>¥ ".$row_data['buyer_price']."</td>";
echo "</tr>";
echo "<tr>";
echo "<th>Seller price </th>";
echo "<td windth='max-content'>¥ ".$row_data['seller_price']."</td>";
echo "</tr>";
echo "<tr>";
echo "<th>buyer availability </th>";
if($row_data['buyer_availability'] == '1'){
echo "<td>available</td>";
}
else{
echo "<td>not available</td>";
}
echo "</tr>";
echo "<tr>";
echo "<th>Seller availability </th>";
if($row_data['seller_availability'] == '1'){
echo "<td>available</td>";
}
else{
echo "<td>not available</td>";
}
echo "</tr>";
echo "</table>";
}
}
echo '</div>';
}
else{
echo "<script type='text/javascript'>
alert('Only admin can visit!');
</script>";
}
}
else{
echo "<script type='text/javascript'>
window.location.href = '../../index.html';
</script>";
}
?>