File "addproduct.php"
Full path: /home/atrmarke/public_html/atrdemolive.site/mzm/pages/addproduct.php
File
size: 10.57 KB B
MIME-type: text/x-php
Charset: utf-8
Download Open Edit Advanced Editor Back
<?php
ob_start();
include("db/cn.php");
if($_GET){
$id = $_GET["id"];
$del_query = mysqli_query($connection,"delete FROM products where id = '$id'
");
echo "<script type='text/javascript'>window.location.href = 'addproduct.php';</script>";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title> مدینہ زرعی مرکز اینڈ سپرے سینٹر</title>
<!-- Custom fonts for this template-->
<link href="../vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css2?family=Quicksand:wght@200;300;400;500;600;700&display=swap" rel="stylesheet">
<!-- Custom styles for this template-->
<link href="../css/sb-admin-2.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<style>
body {
font-family: 'Quicksand', sans-serif;
}
#product-container-wrapper {
max-height: 700px; /* Adjust the maximum height as needed */
overflow-y: auto; /* Enable vertical scroll when content overflows */
}
.chart-container {
position: relative;
background: rgba(255, 255, 255, 0.9);
border-radius: 10px;
padding: 15px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}
canvas {
max-width: 100%;
height: auto;
}
.bg-gradient-primary{
background:#0A4657;
color:#fff;
}
.btn-primary{
background:#0A4657;
color:#fff;
border:1px #0A4657 solid;
}
.btn-primary:hover{
background:#fff;
border:1px #0A4657 solid;
color:#0A4657;
}
.chart-container {
position: relative;
background: rgba(255, 255, 255, 0.9);
border-radius: 10px;
padding: 15px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}
canvas {
max-width: 100%;
height: auto;
}
.fa-download:hover{
color:#953E39;
}
tr{
font-weight:700;
color:#000;
}
</style>
<body id="page-top">
<!-- Page Wrapper -->
<div id="wrapper">
<!-- Sidebar -->
<?php
include("common/sd.php");
?>
<!-- End of Sidebar -->
<!-- Content Wrapper -->
<div id="content-wrapper" class="d-flex flex-column">
<!-- Main Content -->
<div id="content">
<!-- Topbar -->
<nav class="navbar navbar-expand navbar-light bg-white topbar mb-4 static-top shadow">
<!-- Sidebar Toggle (Topbar) -->
<button id="sidebarToggleTop" class="btn btn-link d-md-none rounded-circle mr-3">
<i class="fa fa-bars"></i>
</button>
<!-- Topbar Search -->
<?php include('common/log.php'); ?>
<!-- Topbar Navbar -->
</nav>
<!-- End of Topbar -->
<!-- Begin Page Content -->
<?php
$q = mysqli_query($connection,"select * from products");
$totalQ = 0;
$totalT = 0;
while($r = mysqli_fetch_array($q)){
$totalQ += $r["quantity"];
$totalT += $r["total_amount"];
}
?>
<div class="container-fluid">
<div class="row">
<div class="col-sm-7">
<h3 style="color:#212529;font-weight:700;"> Product Management</h3>
</div>
<div class="col-sm-5" style="border:1px solid #0A4657; padding:7px; border-radius:77px;background:#0A4657;">
<div class="search-container">
<input type="text" id="search-input" class="form-control" placeholder="Search Product by Name:-" style="border-radius:77px;border:none;font-weight:700;" />
<div class="search-icon">
</div>
</div>
</div>
</div>
</div>
<br>
<div class="container-fluid">
<div class="row">
<div class="col-4">
<table class=" table table-bordered text-center bg-white">
<tr>
<td style="background:#0A4657;color:#fff;font-weight:700;">Total Quantity</td>
<td><?php echo $totalQ; ?></td>
</tr>
</table>
</div>
<div class="col-4">
<table class="table table-bordered text-center bg-white">
<tr>
<td style="background:#0A4657;color:#fff;font-weight:700;">Total Amount</td>
<td><?php echo $totalT; ?></td>
</tr>
</table>
</div>
<div class="col-4"></div>
</div>
</div>
<br />
<div class="container-fluid text-center">
<div class="row">
<div class="col-sm-12" id="product-container-wrapper">
<div class="row text-center" id="products-container" >
<?php
// Fetch products from database
$sql = "SELECT * FROM products";
$result = $connection->query($sql);
if ($result->num_rows > 0) {
echo '<table id="productTable" class="table table-stripped table-hover table-lg bg-white">';
echo '<tr style="color:#fff; background:#212529; font-size:14px;">';
echo '<th>Sr#</th>';
echo '<th>Item Code</th>';
echo '<th>Product</th>';
echo '<th>Company</th>';
echo '<th>Supplier</th>';
echo '<th>R.~ Qty ~</th>';
echo '<th>Sale Price(Rs)</th>';
echo '<th>Purchase Price(Rs)</th>';
echo '<th>Total Amount(Rs)</th>';
echo '<th>Expiry</th>';
echo '<th>Update</th>';
echo '<th>Delete</th>';
echo '</tr>';
$sr_no = 1;
while ($row = $result->fetch_assoc()) {
$rowStyle = $row["quantity"] < $row["mini_quantity"] ? 'background-color: #A10300; color: white; font-weight:700;' : '';
// Handle expiry style
$expiryStyle = '';
if (!empty($row["expiry"])) {
$expiryDate = new DateTime($row["expiry"]);
$today = new DateTime();
$interval = $today->diff($expiryDate);
$daysToExpire = (int)$interval->format('%r%a');
if ($daysToExpire >= 0 && $daysToExpire <= 20) {
$expiryStyle = 'background-color: #6E3335; color: white;';
}
}
echo '<tr style="font-size:14px;font-weight:700;color:#000; ' . $rowStyle . '" class="product-row" data-category="' . $row["company"] . '">';
echo '<td style="font-weight:600;">' . $sr_no++ . '</td>';
echo '<td style="font-weight:600;">' . $row["product_id"] . '</td>';
echo '<td style="font-weight:800;color:#000;">' . $row["product_name"] . '</td>';
echo '<td class="text-capitalize" style="font-weight:600;">' . $row["company"] . '</td>';
echo '<td style="font-weight:600; text-transform:capitalize;">' . $row["supplier"] . '</td>';
echo '<td style="font-weight:700;color:#000;">' . $row["quantity"] . '</td>';
echo '<td class="text-capitalize"> ' . $row["retail_price"] . ' </td>';
echo '<td class="text-capitalize"> ' . $row["trade_price"] . ' </td>';
echo '<td style="font-weight:800;color:#000;"> ' . round($row["total_amount"], 0) . ' </td>';
echo '<td style="' . $expiryStyle . ' font-weight:800;">' . $row["expiry"] . '</td>';
echo '<td><a href="product_update.php?id=' . $row["id"] . '"><button type="button" class="btn btn-dark btn-sm"><i class="fas fa-clipboard-check"></i></button></a></td>';
echo '<td><a href="addproduct.php?id=' . $row["id"] . '" onclick="return confirm(\'Are you sure HAJI you want to delete this product?\')"><button type="button" class="btn btn-danger btn-sm">x</button></a></td>';
echo '</tr>';
}
echo '</table>';
} else {
echo "No products found";
}
?>
</div>
</div>
<div class="" >
</div>
</div>
</div>
<!-- /.container-fluid -->
</div>
<br><br>
<!-- End of Main Content -->
<!-- Footer -->
<?php include("common/main_ft.php"); ?>
<!-- End of Footer -->
</div>
<!-- End of Content Wrapper -->
</div>
<!-- End of Page Wrapper -->
<!-- Scroll to Top Button-->
<a class="scroll-to-top rounded" href="#page-top">
<i class="fas fa-angle-up"></i>
</a>
<!-- Logout Modal-->
<div class="modal fade" id="logoutModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Ready to Leave?</h5>
<button class="close" type="button" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">Select "Logout" below if you are ready to end your current session.</div>
<div class="modal-footer">
<button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
<a class="btn btn-primary" href="">Logout</a>
</div>
</div>
</div>
</div>
<script>
document.addEventListener("DOMContentLoaded", function() {
document.getElementById("search-input").addEventListener("input", function() {
var searchText = this.value.toLowerCase();
var rows = document.querySelectorAll(".product-row");
rows.forEach(function(row) {
var productName = row.querySelector("td:nth-child(3)").textContent.toLowerCase();
if (productName.includes(searchText)) {
row.style.display = "table-row";
} else {
row.style.display = "none";
}
});
});
});
</script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.10.2/dist/umd/popper.min.js"></script>
<!-- Bootstrap core JavaScript-->
<script src="../vendor/jquery/jquery.min.js"></script>
<script src="../vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Core plugin JavaScript-->
<script src="../vendor/jquery-easing/jquery.easing.min.js"></script>
<!-- Custom scripts for all pages-->
<script src="../js/sb-admin-2.min.js"></script>
</body>
</html>