[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: product-stock.php
<?php include("../admin/includes/functions/functions.php");?> <?php include("../admin/db/db.php");?> <?php if(!isset($_SESSION['username_Xw211qAAsq4'])) { header('Location: ../auth/'); exit(); } else{ $pageTitle1 = 'Product Stock'; $shopname = $_SESSION['business_name_Xw211qAAsq4']; $currency = mysqli_query($new,"SELECT currency from barber_admin WHERE business_name = '$shopname'"); $fechC = mysqli_fetch_array($currency); $qurtyCurrency = $fechC['currency']; $message=""; if(isset($_POST['add'])){ $product_name = test_input($_POST['product_name']); $qty = test_input($_POST['qty']); $price = test_input($_POST['price']); $supplier_id = test_input($_POST['supplier_id']); $date = test_input($_POST['date']); $product_code = test_input($_POST['product_code']); $cost = test_input($_POST['cost']); $sele = mysqli_query($new,"SELECT * FROM products WHERE product_name = '$product_name' AND business_name = '$shopname'"); $conrow = mysqli_fetch_array($sele); $dbvendor = $conrow['product_name']; if($product_name==""){ $message = '<script> $(document).ready(function(){ swal("Warning!", "Product name required", "warning");}); </script>'; } if($qty==""){ $message = '<script> $(document).ready(function(){ swal("Warning!", "Product Qty is required", "warning");}); </script>'; } if($price==""){ $message = '<script> $(document).ready(function(){ swal("Warning!", "Product price is required", "warning");}); </script>'; } if($date==""){ $message = '<script> $(document).ready(function(){ swal("Warning!", "Date is required", "warning");}); </script>'; } if($supplier_id==""){ $message = '<script> $(document).ready(function(){ swal("Warning!", "Select supplier name", "warning");}); </script>'; } if($product_name === $dbvendor ){ $message = '<script> $(document).ready(function(){ swal("Warning!", "Product name already exist", "warning");}); </script>'; } if(!$message){ $stmt = $con->prepare("insert into products (product_name,product_code,qty,cost,price,supplier,date,business_name) values(?,?,?,?,?,?,?,?) "); $stmt->execute(array($product_name,$product_code,$qty,$cost,$price,$supplier_id,$date,$shopname)); $message = '<script> $(document).ready(function(){ swal("Success!", "New product added", "success");}); </script>'; } } if(isset($_POST['del'])){ $SID = test_input($_POST['SID']); $stmt = $con->prepare("DELETE from products where pro_id = ?"); $stmt->execute(array($SID)); $message = '<script> $(document).ready(function(){ swal("Success!", "Product deleted", "success");}); </script>'; //header("Location: product-stock"); } if(isset($_POST['update'])){ $pro_id = test_input($_POST['pro_id']); $product_name = test_input($_POST['product_name']); $qty = test_input($_POST['qty']); $price = test_input($_POST['price']); $supplier_id = test_input($_POST['supplier_id']); $date = test_input($_POST['date']); $product_code = test_input($_POST['product_code']); $cost = test_input($_POST['cost']); $stmt = $con->prepare("update products set product_name = ?, product_code = ?, qty = ?, cost = ?, price = ?, supplier = ?, date = ? where pro_id = ?"); $stmt->execute(array($product_name,$product_code,$qty,$cost,$price,$supplier_id,$date,$pro_id)); $message = '<script> $(document).ready(function(){ swal("Success!", "Product updated", "success");}); </script>'; //header("Location: product-stock"); } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title> <?php echo $shopname;?> - <?php echo $pageTitle1;?></title> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <link href="plugins/datatables/dataTables.bootstrap4.css" rel="stylesheet" type="text/css" /> <link href="plugins/datatables/responsive.bootstrap4.css" rel="stylesheet" type="text/css" /> <link href="plugins/datatables/buttons.bootstrap4.css" rel="stylesheet" type="text/css" /> <link href="plugins/datatables/select.bootstrap4.css" rel="stylesheet" type="text/css" /> <script src="https://code.jquery.com/jquery-3.6.4.min.js" integrity="sha256-oP6HI9z1XaZNBrJURtCoUT5SUnxFr8s3BzRl+cbzUq8=" crossorigin="anonymous"></script> <!-- App css --> <link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> <link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" /> <link href="assets/css/theme.min.css" rel="stylesheet" type="text/css" /> <link rel="shortcut icon" href="../assets/icon.png" type="image/x-icon"> <link rel="icon" href="../assets/icon.png" type="image/x-icon"> <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script> <style> #preloader { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 9999; background-color: #fff; } #loader { display: block; position: absolute; top: 50%; left: 50%; border: 16px solid #f3f3f3; border-top: 16px solid #3498db; border-radius: 50%; width: 70px; height: 70px; animation: spin 2s linear infinite; } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } </style> </head> <body> <div id="preloader"> <div id="loader"></div> </div> <!-- Begin page --> <div id="layout-wrapper"> <div class="header-border"></div> <?php include("includes/template/head.php");?> <?php include("includes/template/side.php");?> <div class="main-content"> <div class="page-content"> <div class="container-fluid"> <!-- start page title --> <div class="row"> <div class="col-12"> <div class="page-title-box d-flex align-items-center justify-content-between"> <h4 class="mb-0 font-size-18">Products</h4> <?php if($message != "") { echo ($message) ; } ?> <div class="page-title-right"> <ol class="breadcrumb m-0"> <li class="breadcrumb-item"><a href="javascript: void(0);"><?= $shopname;?></a></li> <li class="breadcrumb-item active"><?php echo $pageTitle1;?></li> </ol> </div> </div> </div> </div> <!-- end page title --> <div class="row"> <div class="col-lg-12"> <div class="card"> <div class="card-body"> <?php $stmt = $con->prepare("SELECT account_type FROM barber_admin WHERE username = ? and business_name = ?"); $stmt->execute(array($username,$shopname)); $userstatus = $stmt->fetchAll(); foreach($userstatus as $sta) { $namee = $sta['account_type']; } $select_role = mysqli_query($new,"SELECT * FROM role_permissions WHERE business_name = '$shopname' and type = '$namee' and page_name = 'Service'"); $rowroles = mysqli_fetch_array($select_role); $updaterecord = $rowroles['updaterecord']; $deleterecord = $rowroles['deleterecord']; $add_db = $rowroles['add']; $type = $rowroles['type']; ?> <?php if($namee != "Admin"){?> <button type="button" class="btn btn-primary waves-effect waves-light" data-toggle="modal" data-target=".bd-example-modal-lg">Add</button> <!-- <button type="button" disabled class="btn btn-primary waves-effect waves-light">Add Service</button> --> <?php } elseif($namee == "Admin" and $add_db == '1' ) {?> <button type="button" class="btn btn-primary waves-effect waves-light" data-toggle="modal" data-target=".bd-example-modal-lg">Add</button> <?php } elseif ($namee == "Admin" and $add_db == '0'){?> <button type="button" disabled class="btn btn-primary waves-effect waves-light">Add</button> <?php }?> <br /><br /> <div class="table-responsive"> <table id="basic-datatable" class="table table-hover table-striped table-bordered"> <thead style="background-color:#428bca;border:#428bca;"> <tr style="color: #ffffff;"> <th>ID</th> <th>Product</th> <th>Code</th> <th>Qty</th> <th>Cost</th> <th>Price</th> <th>Profit</th> <th>Supplier</th> <!-- <th>Date</th> --> <th>Action</th> </tr> </thead> <?php $cont = 1; $stmt = $con->prepare("SELECT * FROM products,supplier WHERE products.supplier = supplier.supplier_id and products.business_name = ? order by product_name"); $stmt->execute(array($shopname)); $rows_services = $stmt->fetchAll(); ?> <tr> <?php foreach($rows_services as $service){ ?> <td><?php echo $cont++;?></td> <td><?php echo $service['product_name'];?></td> <td><?php echo $service['product_code'];?></td> <td><?php echo $service['qty'];?></td> <td><?php echo number_format($service['cost'],2).' '.$qurtyCurrency;?></td> <td><?php echo number_format($service['price'],2).' '.$qurtyCurrency;?></td> <td><?php echo number_format($service['price'] - $service['cost'],2 ).' '.$qurtyCurrency;?></td> <td><?php echo $service['supplier_name'];?></td> <!-- <td><?php echo date("F d Y",strtotime($service['date'])) ?></td> --> <td> <?php $edit_data = "edit_".$service["pro_id"];?> <?php $delete_data = "delete_".$service["pro_id"];?> <?php if($namee != "Admin"){?> <li class="list-inline-item" data-toggle="tooltip" title="Edit"> <a href="#" data-toggle="modal" data-target="#<?php echo $edit_data; ?>" data-placement="top"><i class="fa fa-edit"></i></a> </li> <!-- <button type="button" disabled class="btn btn-primary waves-effect waves-light">Add Service</button> --> <?php } elseif($namee == "Admin" and $updaterecord == '1' ) {?> <li class="list-inline-item" data-toggle="tooltip" title="Edit"> <a href="#" data-toggle="modal" data-target="#<?php echo $edit_data; ?>" data-placement="top"><i class="fa fa-edit"></i></a> </li> <?php } elseif ($namee == "Admin" and $updaterecord == '0'){?> <li class="list-inline-item" data-toggle="tooltip" title="Locked"> <a class="disabled" data-placement="top"><i class="fa fa-edit"></i></a> </li> <?php }?> <?php if($namee != "Admin"){?> <li class="list-inline-item" data-toggle="tooltip" title="Delete"> <a href="#" data-toggle="modal" data-target="#<?php echo $delete_data; ?>" data-placement="top"><i class="fa fa-trash-alt" style="color:red"></i></a> </li> <!-- <button type="button" disabled class="btn btn-primary waves-effect waves-light">Add Service</button> --> <?php } elseif($namee == "Admin" and $deleterecord == '1' ) {?> <li class="list-inline-item" data-toggle="tooltip" title="Delete"> <a href="#" data-toggle="modal" data-target="#<?php echo $delete_data; ?>" data-placement="top"><i class="fa fa-trash-alt" style="color:red"></i></a> </li> <?php } elseif ($namee == "Admin" and $deleterecord == '0'){?> <li class="list-inline-item" data-toggle="tooltip" title="Locked"> <a class="disabled" data-placement="top"><i class="fa fa-trash-alt" style="color:red"></i></a> </li> <?php }?> <ul> <!-- EDIT Modal --> <div class="modal fade bd-example-modal-lg12" id="<?php echo $edit_data; ?>" tabindex="-1" role="dialog" aria-labelledby="<?php echo $edit_data; ?>" aria-hidden="true"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title h4" id="myLargeModalLabel">Edit products</h5> <button type="button" class="close waves-effect waves-light" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> <form class="row g-3" enctype="multipart/form-data" method="post"> <!-- Left Column --> <div class="col-md-6"> <!-- Product Name --> <div class="mb-3"> <label for="product_name" class="form-label">Product Name</label> <input type="text" id="product_name" name="product_name" value="<?php echo $service['product_name']; ?>" class="form-control" autocomplete="off"> </div> <input type="hidden" name="pro_id" value="<?php echo $service['pro_id']; ?>"> <!-- Product Code --> <div class="mb-3"> <label for="product_code" class="form-label">Product Code</label> <input type="text" id="product_code" name="product_code" value="<?php echo $service['product_code']; ?>" class="form-control" autocomplete="off"> </div> <!-- Quantity --> <div class="mb-3"> <label for="qty" class="form-label">Quantity</label> <input type="number" id="qty" name="qty" value="<?php echo $service['qty']; ?>" class="form-control" autocomplete="off"> </div> <div class="mb-3"> <label for="date" class="form-label">Date</label> <input type="date" id="date" name="date" value="<?php echo $service['date']; ?>" class="form-control"> </div> </div> <!-- Right Column --> <div class="col-md-6"> <!-- Cost Price --> <div class="mb-3"> <label for="cost" class="form-label">Cost Price</label> <input type="number" id="cost" name="cost" value="<?php echo $service['cost']; ?>" class="form-control" autocomplete="off"> </div> <!-- Supplier Name --> <!-- Selling Price --> <div class="mb-3"> <label for="price" class="form-label">Selling Price</label> <input type="number" id="price" name="price" value="<?php echo $service['price']; ?>" class="form-control" autocomplete="off"> </div> <!-- Date --> <div class="mb-3"> <label for="supplier_id" class="form-label">Supplier Name</label> <?php $stmt = $con->prepare("SELECT * FROM supplier WHERE business_name = ? order by supplier_name"); $stmt->execute(array($shopname)); $rows_categories = $stmt->fetchAll(); ?> <select class="form-control" name="supplier_id" required > <option value="">Select Supplier</option> <?php foreach($rows_categories as $category){ echo "<option value = '".$category['supplier_id']."'>"; echo $category['supplier_name']; echo "</option>"; } ?> </select> </div> <!-- Submit Button --> <div class="d-grid gap-2 col-6 mx-auto"> <button type="submit" name="update" class="btn btn-success">Send</button> </div> </div> </form> </div> </div> </div> </div> <!-- <div class="modal fade bd-example-modal-lg12" id="<?php echo $edit_data; ?>" tabindex="-1" role="dialog" aria-labelledby="<?php echo $edit_data; ?>" aria-hidden="true"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-body"> <div class="modal-body" style="width: 100%"> <form class="row" enctype="multipart/form-data" method="post"> <div class="col-md-12 col-lg-6"> <div class="form-group row"> <label for="company_name" class="col-sm-5 col-form-label">Product name</label> <div class="col-sm-10"> <input type="text" name="product_name" class="form-control" value="<?php echo $service['product_name']; ?>" style="height : 45px;" autocomplete="off"> </div> </div> <input type="hidden" name="pro_id" value="<?php echo $service['pro_id']; ?>"> <div class="form-group row"> <label for="start_date" class="col-sm-5 col-form-label">Qty </label> <div class="col-sm-10"><input type="number" name="qty" value="<?php echo $service['qty']; ?>" class="form-control" style="height : 45px;" autocomplete="off"> </div> </div> </div> <br /> <div class="col-md-12 col-lg-6"> <div class="form-group row"> <label for="charge_payable" class="col-sm-5 col-form-label">Price </label> <div class="col-sm-10"> <input type="number" name="price" class="form-control" value="<?php echo $service['price']; ?>" style="height : 45px;" autocomplete="off"> </div> </div> <div class="form-group row"> <label for="start_date" class="col-sm-5 col-form-label"> Supplier name</label> <div class="col-sm-10"> <?php $stmt = $con->prepare("SELECT * FROM supplier WHERE business_name = ? order by supplier_name"); $stmt->execute(array($shopname)); $rows_categories = $stmt->fetchAll(); ?> <select class="form-control" name="supplier_id" required > <option value="">Select Supplier</option> <?php foreach($rows_categories as $category){ echo "<option value = '".$category['supplier_id']."'>"; echo $category['supplier_name']; echo "</option>"; } ?> </select> </div> </div> <div class="form-group row"> <label for="start_date" class="col-sm-5 col-form-label"> Date</label> <div class="col-sm-10"> <input type="date" name="date" class="form-control" value="<?php echo $service['date']; ?>" style="height : 45px;"> </div> </div> <br/> <div class="form-group col-md-4"> <button type="submit" name="update" class="btn btn-success form-control">Send</button> </div> </div> </form> </div> </div> </div> </div> </div> --> <div class="modal fade" id="<?php echo $delete_data; ?>" tabindex="-1" role="dialog" aria-labelledby="<?php echo $delete_data; ?>" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="exampleModalLabel">Delete Stock</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> <form method="POST"> Are you sure you want to delete this Stock? </div> <input type="hidden" name="SID" value="<?php echo $service['pro_id']; ?>"> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button> <button type="submit" name="del" class="btn btn-danger delete_category_bttn">Delete</button> </form> </div> </div> </div> </div> </li> </ul> </td> </tr> <?php };?> </tbody> </table> </div> </div> <!--end card body--> </div> <!-- end card--> </div> <!-- end col --> </div> <!--end row--> </div> <!-- container-fluid --> </div> <!-- End Page-content --> <?php include("includes/template/newfooter.php");?> </div> <!-- end main content--> </div> <!-- END layout-wrapper --> <!-- Overlay--> <div class="menu-overlay"></div> <?php //include("includes/modals/ProductModal.php");?> <div class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title h4" id="myLargeModalLabel">Add products</h5> <button type="button" class="close waves-effect waves-light" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> <form class="row g-3" enctype="multipart/form-data" method="post"> <!-- Left Column --> <div class="col-md-6"> <!-- Product Name --> <div class="mb-3"> <label for="product_name" class="form-label">Product Name</label> <input type="text" id="product_name" name="product_name" class="form-control" autocomplete="off"> </div> <!-- Product Code --> <div class="mb-3"> <label for="product_code" class="form-label">Product Code</label> <input type="text" id="product_code" name="product_code" class="form-control" autocomplete="off"> </div> <!-- Quantity --> <div class="mb-3"> <label for="qty" class="form-label">Quantity</label> <input type="number" id="qty" name="qty" class="form-control" autocomplete="off"> </div> <div class="mb-3"> <label for="date" class="form-label">Date</label> <input type="date" id="date" name="date" class="form-control"> </div> </div> <!-- Right Column --> <div class="col-md-6"> <!-- Cost Price --> <div class="mb-3"> <label for="cost" class="form-label">Cost Price</label> <input type="number" id="cost" name="cost" class="form-control" autocomplete="off"> </div> <!-- Supplier Name --> <!-- Selling Price --> <div class="mb-3"> <label for="price" class="form-label">Selling Price</label> <input type="number" id="price" name="price" class="form-control" autocomplete="off"> </div> <!-- Date --> <div class="mb-3"> <label for="supplier_id" class="form-label">Supplier Name</label> <select class="form-control" id="supplier_id" name="supplier_id"> <option value="">Select Supplier</option> <?php $stmt = $con->prepare("SELECT * FROM supplier WHERE business_name = ? ORDER BY supplier_name"); $stmt->execute(array($shopname)); $rows_categories = $stmt->fetchAll(); foreach($rows_categories as $category) { echo "<option value='".$category['supplier_id']."'>".$category['supplier_name']."</option>"; } ?> </select> </div> <!-- Submit Button --> <div class="d-grid gap-2 col-6 mx-auto"> <button type="submit" name="add" class="btn btn-success">Send</button> </div> </div> </form> </div> </div> </div> </div> <script src="assets/js/jquery.min.js"></script> <script src="assets/js/bootstrap.bundle.min.js"></script> <script src="assets/js/metismenu.min.js"></script> <script src="assets/js/waves.js"></script> <script src="assets/js/simplebar.min.js"></script> <script src="plugins/raphael/raphael.min.js"></script> <script src="assets/pages/dashboard-demo.js"></script> <script src="assets/js/theme.js"></script> <script src="plugins/datatables/jquery.dataTables.min.js"></script> <script src="plugins/datatables/dataTables.bootstrap4.js"></script> <script src="plugins/datatables/dataTables.responsive.min.js"></script> <script src="plugins/datatables/responsive.bootstrap4.min.js"></script> <script src="plugins/datatables/dataTables.buttons.min.js"></script> <script src="plugins/datatables/buttons.bootstrap4.min.js"></script> <script src="plugins/datatables/dataTables.keyTable.min.js"></script> <script src="plugins/datatables/dataTables.select.min.js"></script> <script src="assets/pages/datatables-demo.js"></script> <script type="text/javascript"> document.onreadystatechange = function() { if (document.readyState !== "complete") { document.querySelector("#preloader").style.display = "block"; } else { document.querySelector("#preloader").style.display = "none"; } }; </script> <!-- jQuery --> </body> </html>
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.82 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002