Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include "../../database/connection.php";
- ?>
- <?php
- include '../../include/controller.php';
- $session_username = $_SESSION['username'];
- $session_role = $_SESSION['role'];
- if(empty($_SESSION['username'])){
- header("location:../../login");
- }
- if($session_role != "admin"){
- header("location:../../forbidden");
- }
- ?>
- <!-- ADD item -->
- <?php
- if(isset($_POST["add_btn"])){
- $item_name = mysqli_real_escape_string($connection,$_POST['item_name']);
- $item_code = mysqli_real_escape_string($connection,$_POST['item_code']);
- $item_category = mysqli_real_escape_string($connection,$_POST['category']);
- $item_description = mysqli_real_escape_string($connection,$_POST['description']);
- $sql = mysqli_query($connection,"INSERT INTO tbl_items (item_name,item_code,item_description,item_category,item_critical_lvl,item_date)VALUES ('$item_name','$item_code','$item_description','$item_category','$item_critical_lvl','$date')");
- $add_inventory_query = mysqli_query($connection,"INSERT INTO tbl_inventory(item_name,item_code,date,qty)VALUES ('$item_name','$item_code','$date','0')");
- header("location:inventory");
- }
- ?>
- <!-- INSTOCK ITEM -->
- <?php
- if(isset($_POST["instock_btn"])){
- $id = $_POST["id"];
- $item_name = mysqli_real_escape_string($connection,$_POST["item_name"]);
- $item_code = mysqli_real_escape_string($connection,$_POST["item_code"]);
- $drno = mysqli_real_escape_string($connection,$_POST["drno"]);
- $quantity = mysqli_real_escape_string($connection,$_POST["quantity"]);
- $remark = mysqli_real_escape_string($connection,$_POST["remark"]);
- $sql = mysqli_query($connection,"INSERT INTO tbl_issuance(date,item_name,item_code,qty, in_out,remarks)VALUES ('$date_time','$item_name','$item_code','$quantity','in','$remarks')");
- $add_inv = mysqli_query($connection,"UPDATE tbl_inventory SET qty=(qty + '$quantity') WHERE id='$id' ");
- header("location:inventory");
- }
- ?>
- <!-- OUTSTOCK ITEM -->
- <?php
- if(isset($_POST["outstock_btn"])){
- $id = $_POST["id"];
- $item_name = mysqli_real_escape_string($connection,$_POST['item_name']);
- $item_code = mysqli_real_escape_string($connection,$_POST["item_code"]);
- $drno = mysqli_real_escape_string($connection,$_POST["drno"]);
- $quantity = mysqli_real_escape_string($connection,$_POST["quantity"]);
- $received = mysqli_real_escape_string($connection,$_POST["received"]);
- $remark = mysqli_real_escape_string($connection,$_POST["remark"]);
- $sql = mysqli_query($connection,"INSERT INTO tbl_issuance(date,item_name,item_code,qty, sender_receiver,in_out,remarks)VALUES ('$date_time','$item_name','$item_code','$quantity','$received','out','$remarks')");
- $minus_inv = mysqli_query($connection,"UPDATE tbl_inventory SET qty=(qty - '$quantity') WHERE id='$id' ");
- header("location:inventory");
- }
- ?>
- <!-- EDIT ITEM -->
- <?php
- if(isset($_POST["edit_btn"])){
- $id = mysqli_real_escape_string($connection, $_POST["id"]);
- $item_name = mysqli_real_escape_string($connection,$_POST['item_name']);
- $item_code = mysqli_real_escape_string($connection,$_POST['item_code']);
- $item_category = mysqli_real_escape_string($connection,$_POST['category']);
- $item_description = mysqli_real_escape_string($connection,$_POST['description']);
- mysqli_query($connection,"UPDATE tbl_items SET item_name='$item_name',item_code='$item_code',item_category='$item_category',item_description='$item_description'WHERE id='$edit_item_id' ");
- header("location:inventory");
- }
- ?>
- <!-- DELETE ITEM -->
- <?php
- if(isset($_POST["delete_btn"])){
- $id = $_POST["delete_id"];
- mysqli_query($connection,"DELETE FROM tbl_items WHERE id='$id'");
- mysqli_query($connection,"DELETE FROM tbl_inventory WHERE id='$id'");
- header("location:inventory");
- }
- ?>
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
- <meta name="description" content="">
- <meta name="author" content="">
- <link rel="icon" href="../../designer/logo.png">
- <title>GTIMS | Admin</title>
- <!-- Bootstrap core CSS -->
- <link href="css/bootstrap.min.css" rel="stylesheet">
- <!-- Custom styles for this template -->
- <link href="custom/index.css" rel="stylesheet">
- </head>
- <body>
- <!-- FOR TOP MENU -->
- <?php
- include 'topmenu.php';
- ?>
- <!-- LOGOUT MODAL -->
- <div class="modal fade" id="logout" 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">Logout</h5>
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
- <span aria-hidden="true">×</span>
- </button>
- </div>
- <div class="modal-body">
- <div class="alert alert-danger">Are you sure you want to logout
- <strong>
- <?php echo $_SESSION['username']; ?>?
- </strong>
- </div>
- </div>
- <div class="modal-footer">
- <a href="../../logout">
- <button type="button" class="btn btn-danger">YES </button>
- </a>
- <button type="button" class="btn btn-dark" data-dismiss="modal">Close</button>
- </div>
- </div>
- </div>
- </div>
- <!-- FOR SIDE MENU -->
- <?php
- include 'sidemenu.php';
- ?>
- <main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-4">
- <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
- <h1 class="h2">Inventory</h1>
- <div class="btn-toolbar mb-2 mb-md-0">
- </div>
- <div class="btn-toolbar mb-2 mb-md-0">
- <div class="btn-group mr-2">
- <button type="submit" name="export_btn" class="btn btn-sm btn-outline-dark">Export</button>
- <a href="#addModal" data-toggle="modal">
- <button type="button" class="btn btn-sm btn-outline-dark"><span data-feather="user-plus"></span> Add</button>
- </a>
- </div>
- </div>
- </div>
- <!-- SEARCH -->
- <form>
- <table>
- <tr>
- <td><select class="form-control" name="search-option">
- <option value="">--SELECT--</option>
- <option value="not">Name of Test</option>
- <option value="cn">Control Number</option>
- <option value="category">Category</option>
- </select>
- </td>
- <td width="50%"><input type="text" name="search" class="form-control" placeholder="Search"></td>
- </tr>
- </table>
- </form>
- <!-- ADD ITEM MODAL -->
- <div class="modal fade" id="addModal" 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"><span data-feather="plus-circle"></span> Add</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">
- <div class="form-group">
- <label for="item_name" class="col-form-label">Name of Material:</label>
- <input type="text" class="form-control" id="item_name" name="item_name" placeholder="Name of Material" required="">
- </div>
- <div class="form-group">
- <label for="item_code" class="col-form-label">Control Number:</label>
- <input type="text" class="form-control" id="item_code" name="item_code" placeholder="Item Code" required="">
- </div>
- <div class="form-group">
- <label for="category" class="col-form-label">Category:</label>
- <input type="text" class="form-control" id="category" name="category" placeholder="Category" required="">
- </div>
- <div class="form-group">
- <label for="critical_lvl" class="col-form-label">Critical Level:</label>
- <input type="text" class="form-control" id="critical_lvl" name="critical_lvl" placeholder="Critical Level" required="">
- </div>
- <div class="form-group">
- <label for="description" class="col-form-label">Description:</label>
- <input type="text" class="form-control" id="description" name="description" placeholder="Description" required="">
- </div>
- </div>
- <div class="modal-footer">
- <button type="submit" class="btn btn-success" name="add_btn"><span data-feather="plus"></span>Add</button>
- <button type="button" class="btn btn-dark" data-dismiss="modal"><span data-feather="x"></span>Close</button>
- </div>
- </div>
- </form>
- </div>
- </div>
- <!-- FETCH DATA -->
- <?php
- $fetch = mysqli_query($connection,"SELECT tbl_items.id, tbl_items.item_name, tbl_items.item_code, tbl_items.item_description, tbl_items.item_category, tbl_items.item_critical_lvl AS critical_lvl, tbl_inventory.qty AS qty FROM tbl_items join tbl_inventory ON tbl_items.item_code=tbl_inventory.item_code");
- ?>
- <br>
- <table class="table table-bordered talbe-striped">
- <thead class="thead-dark">
- <tr>
- <th>Name of Material</th>
- <th>Control Number</th>
- <th>Category</th>
- <th>Description</th>
- <th>Quantity</th>
- <th style="text-align: center;">Action</th>
- </tr>
- </thead>
- <?php while($row = mysqli_fetch_assoc($fetch)) {
- $id = $row['id'];
- $item_name = $row['item_name'];
- $item_code = $row['item_code'];
- $item_category = $row['item_category'];
- $item_description = $row['item_description'];
- $critical_lvl = $row['critical_lvl'];
- $qty = $row['qty'];
- if($qty == 0){
- $alert = "<div class='alert alert-danger'>
- <strong>$qty</strong> No Stock
- </div>";
- }else if($critical_lvl >= $qty){
- $alert = "<div class='alert alert-warning'>
- <strong>$qty</strong> Critical Level
- </div>";
- }else {
- $alert = $qty;
- }
- ?>
- <tbody>
- <tr>
- <td>
- <?php echo $item_name; ?>
- </td>
- <td>
- <?php echo $item_code; ?>
- </td>
- <td>
- <?php echo $item_category; ?>
- </td>
- <td>
- <?php echo $item_description; ?>
- </td>
- <td>
- <?php echo $alert; ?>
- </td>
- <td>
- <a href="#instockModal<?php echo $id;?>" data-toggle="modal">
- <button type="button" class="btn btn-success"><span data-feather="plus"></span></button>
- </a>
- <a href="#outStockModal<?php echo $id;?>" data-toggle="modal">
- <button type="button" class="btn btn-default"><span data-feather="minus"></span></button>
- </a>
- <a href="#editModal<?php echo $id;?>" data-toggle="modal">
- <button type="button" class="btn btn-warning"><span data-feather="edit"></span></button>
- </a>
- <a href="#deleteModal<?php echo $id;?>" data-toggle="modal">
- <button type="button" class="btn btn-danger"><span data-feather="trash-2"></span></button>
- </a>
- </td>
- </tr>
- </tbody>
- <!-- IN STOCK ITEM MODAL-->
- <div class="modal fade" id="instockModal<?php echo $id;?>" 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"><span data-feather="plus-circle"></span> Instock</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">
- <div class="form-group">
- <input type="hidden" name="id" value="<?php echo $id?>">
- </div>
- <div class="form-group">
- <label for="item_name" class="col-form-label">Name of Material:</label>
- <input type="text" class="form-control" id="item_name" name="item_name" placeholder="Item Name" required readonly value="<?php echo $item_name; ?>">
- </div>
- <div class="form-group">
- <label for="item_code" class="col-form-label">Control Number:</label>
- <input type="text" class="form-control" id="item_code" name="item_code" placeholder="Item Code" required readonly value="<?php echo $item_code; ?>" autocomplete="off">
- </div>
- <div class="form-group">
- <label for="drno" class="col-form-label">DR No:</label>
- <input type="text" class="form-control" id="drno" name="drno" placeholder="DR No" required="">
- </div>
- <div class="form-group">
- <label for="quantity" class="col-form-label">Quantity:</label>
- <input type="text" class="form-control" id="quantity" name="quantity" placeholder="Quantity" required="">
- </div>
- <div class="form-group">
- <label for="remark" class="col-form-label">Remarks:</label>
- <textarea class="form-control" name="remark" placeholder="Remarks" required=""></textarea>
- </div>
- </div>
- <div class="modal-footer">
- <button type="submit" class="btn btn-success" name="instock_btn"><span data-feather="plus"></span>Add</button>
- <button type="button" class="btn btn-dark" data-dismiss="modal"><span data-feather="x"></span>Close</button>
- </div>
- </div>
- </form>
- </div>
- </div>
- <!-- OUT STOCK ITEM-->
- <div class="modal fade" id="outStockModal<?php echo $id;?>" 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"><span data-feather="plus-circle"></span> Instock</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">
- <div class="form-group">
- <input type="hidden" name="id" value="<?php echo $id?>">
- </div>
- <div class="form-group">
- <label for="item_name" class="col-form-label">Name of Material:</label>
- <input type="text" class="form-control" id="item_name" name="item_name" placeholder="Item Name" required readonly value="<?php echo $item_name; ?>">
- </div>
- <div class="form-group">
- <label for="item_code" class="col-form-label">Control Number:</label>
- <input type="text" class="form-control" id="item_code" name="item_code" placeholder="Item Code" required readonly value="<?php echo $item_code; ?>" autocomplete="off">
- </div>
- <div class="form-group">
- <label for="drno" class="col-form-label">DR No:</label>
- <input type="text" class="form-control" id="drno" name="drno" placeholder="DR No" required="">
- </div>
- <div class="form-group">
- <label for="quantity" class="col-form-label">Quantity:</label>
- <input type="text" class="form-control" id="quantity" name="quantity" placeholder="Quantity" required="">
- </div>
- <div class="form-group">
- <label for="received" class="col-form-label">Received By:</label>
- <input type="text" class="form-control" id="received" name="received" placeholder="Received By" required="">
- </div>
- <div class="form-group">
- <label for="remark" class="col-form-label">Remarks:</label>
- <textarea class="form-control" name="remark" placeholder="Remarks" required=""></textarea>
- </div>
- </div>
- <div class="modal-footer">
- <button type="submit" class="btn btn-default" name="outstock_btn"><span data-feather="minus"></span> Out</button>
- <button type="button" class="btn btn-dark" data-dismiss="modal"><span data-feather="x"></span>Close</button>
- </div>
- </div>
- </form>
- </div>
- </div>
- <!-- EDIT ITEM-->
- <div class="modal fade" id="editModal<?php echo $id;?>" 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"><span data-feather="plus-circle"></span> Instock</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">
- <div class="form-group">
- <input type="hidden" name="id" value="<?php echo $id?>">
- </div>
- <div class="form-group">
- <label for="item_name" class="col-form-label">Name of Material:</label>
- <input type="text" class="form-control" id="item_name" name="item_name" placeholder="Item Name" value="<?php echo $item_name; ?>">
- </div>
- <div class="form-group">
- <label for="item_code" class="col-form-label">Control Number:</label>
- <input type="text" class="form-control" id="item_code" name="item_code" placeholder="Item Code" required readonly value="<?php echo $item_code; ?>" autocomplete="off">
- </div>
- <div class="form-group">
- <label for="category" class="col-form-label">Category:</label>
- <input type="text" class="form-control" id="category" name="category" placeholder="" value="<?php echo $item_category;?>">
- </div>
- <div class="form-group">
- <label for="description" class="col-form-label">Description:</label>
- <input type="text" class="form-control" id="description" name="description" placeholder="Descrption" value="<?php echo $item_description?>">
- </div>
- </div>
- <div class="modal-footer">
- <button type="submit" class="btn btn-default" name="edit_btn"><span data-feather="edit"></span> Edit</button>
- <button type="button" class="btn btn-dark" data-dismiss="modal"><span data-feather="x"></span>Close</button>
- </div>
- </div>
- </form>
- </div>
- </div>
- <!-- DELETE MODAL -->
- <div class="modal fade" id="deleteModal<?php echo $id;?>" 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"><span data-feather="trash-2"></span> Delete</h5>
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
- <span aria-hidden="true">×</span>
- </button>
- </div>
- <form method="POST">
- <div class="modal-body">
- <input type="hidden" name="delete_id" value="<?php echo $id; ?>">
- <div class="alert alert-danger">Are you sure you want delete <strong>
- <?php echo $item_name; ?>?</strong>
- </div>
- <div class="modal-footer">
- <button type="submit" class="btn btn-danger" name="delete_btn"><span data-feather="trash-2"></span> Delete</button>
- <button type="button" class="btn btn-dark" data-dismiss="modal"><span data-feather="x"></span> Close</button>
- </div>
- </div>
- </form>
- </div>
- </div>
- </div>
- <?php }?>
- </table>
- </main>
- <!-- Bootstrap core JavaScript
- ================================================== -->
- <!-- Placed at the end of the document so the pages load faster -->
- <script src="js/jquery.js"></script>
- <script src="js/bootstrap.min.js"></script>
- <!-- Icons -->
- <script src="custom/icon.js"></script>
- <script>
- feather.replace()
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement