Advertisement
Guest User

Untitled

a guest
Nov 20th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.08 KB | None | 0 0
  1. <?php
  2. include "../../database/connection.php";
  3. ?>
  4. <?php
  5. include '../../include/controller.php';
  6. $session_username = $_SESSION['username'];
  7. $session_role = $_SESSION['role'];
  8. if(empty($_SESSION['username'])){
  9. header("location:../../login");
  10. }
  11. if($session_role != "admin"){
  12. header("location:../../forbidden");
  13. }
  14. ?>
  15. <!-- ADD item -->
  16. <?php
  17. if(isset($_POST["add_btn"])){
  18. $item_name = mysqli_real_escape_string($connection,$_POST['item_name']);
  19. $item_code = mysqli_real_escape_string($connection,$_POST['item_code']);
  20. $item_category = mysqli_real_escape_string($connection,$_POST['category']);
  21. $item_description = mysqli_real_escape_string($connection,$_POST['description']);
  22. $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')");
  23. $add_inventory_query = mysqli_query($connection,"INSERT INTO tbl_inventory(item_name,item_code,date,qty)VALUES ('$item_name','$item_code','$date','0')");
  24. header("location:inventory");
  25. }
  26. ?>
  27. <!-- INSTOCK ITEM -->
  28. <?php
  29. if(isset($_POST["instock_btn"])){
  30. $id = $_POST["id"];
  31. $item_name = mysqli_real_escape_string($connection,$_POST["item_name"]);
  32. $item_code = mysqli_real_escape_string($connection,$_POST["item_code"]);
  33. $drno = mysqli_real_escape_string($connection,$_POST["drno"]);
  34. $quantity = mysqli_real_escape_string($connection,$_POST["quantity"]);
  35. $remark = mysqli_real_escape_string($connection,$_POST["remark"]);
  36. $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')");
  37. $add_inv = mysqli_query($connection,"UPDATE tbl_inventory SET qty=(qty + '$quantity') WHERE id='$id' ");
  38. header("location:inventory");
  39. }
  40. ?>
  41. <!-- OUTSTOCK ITEM -->
  42. <?php
  43. if(isset($_POST["outstock_btn"])){
  44. $id = $_POST["id"];
  45. $item_name = mysqli_real_escape_string($connection,$_POST['item_name']);
  46. $item_code = mysqli_real_escape_string($connection,$_POST["item_code"]);
  47. $drno = mysqli_real_escape_string($connection,$_POST["drno"]);
  48. $quantity = mysqli_real_escape_string($connection,$_POST["quantity"]);
  49. $received = mysqli_real_escape_string($connection,$_POST["received"]);
  50. $remark = mysqli_real_escape_string($connection,$_POST["remark"]);
  51. $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')");
  52. $minus_inv = mysqli_query($connection,"UPDATE tbl_inventory SET qty=(qty - '$quantity') WHERE id='$id' ");
  53. header("location:inventory");
  54. }
  55. ?>
  56. <!-- EDIT ITEM -->
  57. <?php
  58. if(isset($_POST["edit_btn"])){
  59. $id = mysqli_real_escape_string($connection, $_POST["id"]);
  60. $item_name = mysqli_real_escape_string($connection,$_POST['item_name']);
  61. $item_code = mysqli_real_escape_string($connection,$_POST['item_code']);
  62. $item_category = mysqli_real_escape_string($connection,$_POST['category']);
  63. $item_description = mysqli_real_escape_string($connection,$_POST['description']);
  64. 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' ");
  65. header("location:inventory");
  66. }
  67. ?>
  68. <!-- DELETE ITEM -->
  69. <?php
  70. if(isset($_POST["delete_btn"])){
  71. $id = $_POST["delete_id"];
  72. mysqli_query($connection,"DELETE FROM tbl_items WHERE id='$id'");
  73. mysqli_query($connection,"DELETE FROM tbl_inventory WHERE id='$id'");
  74. header("location:inventory");
  75. }
  76. ?>
  77. <!doctype html>
  78. <html lang="en">
  79. <head>
  80. <meta charset="utf-8">
  81. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  82. <meta name="description" content="">
  83. <meta name="author" content="">
  84. <link rel="icon" href="../../designer/logo.png">
  85.  
  86. <title>GTIMS | Admin</title>
  87.  
  88. <!-- Bootstrap core CSS -->
  89. <link href="css/bootstrap.min.css" rel="stylesheet">
  90.  
  91. <!-- Custom styles for this template -->
  92. <link href="custom/index.css" rel="stylesheet">
  93. </head>
  94. <body>
  95. <!-- FOR TOP MENU -->
  96. <?php
  97. include 'topmenu.php';
  98. ?>
  99. <!-- LOGOUT MODAL -->
  100. <div class="modal fade" id="logout" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  101. <div class="modal-dialog" role="document">
  102. <div class="modal-content">
  103. <div class="modal-header">
  104. <h5 class="modal-title" id="exampleModalLabel">Logout</h5>
  105. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  106. <span aria-hidden="true">&times;</span>
  107. </button>
  108. </div>
  109. <div class="modal-body">
  110. <div class="alert alert-danger">Are you sure you want to logout
  111. <strong>
  112. <?php echo $_SESSION['username']; ?>?
  113. </strong>
  114. </div>
  115. </div>
  116. <div class="modal-footer">
  117. <a href="../../logout">
  118. <button type="button" class="btn btn-danger">YES </button>
  119. </a>
  120. <button type="button" class="btn btn-dark" data-dismiss="modal">Close</button>
  121. </div>
  122. </div>
  123. </div>
  124. </div>
  125. <!-- FOR SIDE MENU -->
  126. <?php
  127. include 'sidemenu.php';
  128. ?>
  129. <main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-4">
  130. <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
  131. <h1 class="h2">Inventory</h1>
  132. <div class="btn-toolbar mb-2 mb-md-0">
  133. </div>
  134. <div class="btn-toolbar mb-2 mb-md-0">
  135. <div class="btn-group mr-2">
  136. <button type="submit" name="export_btn" class="btn btn-sm btn-outline-dark">Export</button>
  137. <a href="#addModal" data-toggle="modal">
  138. <button type="button" class="btn btn-sm btn-outline-dark"><span data-feather="user-plus"></span> Add</button>
  139. </a>
  140. </div>
  141. </div>
  142. </div>
  143. <!-- SEARCH -->
  144. <form>
  145. <table>
  146. <tr>
  147. <td><select class="form-control" name="search-option">
  148. <option value="">--SELECT--</option>
  149. <option value="not">Name of Test</option>
  150. <option value="cn">Control Number</option>
  151. <option value="category">Category</option>
  152. </select>
  153. </td>
  154. <td width="50%"><input type="text" name="search" class="form-control" placeholder="Search"></td>
  155. </tr>
  156. </table>
  157. </form>
  158. <!-- ADD ITEM MODAL -->
  159. <div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  160. <div class="modal-dialog" role="document">
  161. <div class="modal-content">
  162. <div class="modal-header">
  163. <h5 class="modal-title" id="exampleModalLabel"><span data-feather="plus-circle"></span> Add</h5>
  164. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  165. <span aria-hidden="true">&times;</span>
  166. </button>
  167. </div>
  168. <div class="modal-body">
  169. <form method="POST">
  170. <div class="form-group">
  171. <label for="item_name" class="col-form-label">Name of Material:</label>
  172. <input type="text" class="form-control" id="item_name" name="item_name" placeholder="Name of Material" required="">
  173. </div>
  174. <div class="form-group">
  175. <label for="item_code" class="col-form-label">Control Number:</label>
  176. <input type="text" class="form-control" id="item_code" name="item_code" placeholder="Item Code" required="">
  177. </div>
  178. <div class="form-group">
  179. <label for="category" class="col-form-label">Category:</label>
  180. <input type="text" class="form-control" id="category" name="category" placeholder="Category" required="">
  181. </div>
  182. <div class="form-group">
  183. <label for="critical_lvl" class="col-form-label">Critical Level:</label>
  184. <input type="text" class="form-control" id="critical_lvl" name="critical_lvl" placeholder="Critical Level" required="">
  185. </div>
  186. <div class="form-group">
  187. <label for="description" class="col-form-label">Description:</label>
  188. <input type="text" class="form-control" id="description" name="description" placeholder="Description" required="">
  189. </div>
  190. </div>
  191. <div class="modal-footer">
  192. <button type="submit" class="btn btn-success" name="add_btn"><span data-feather="plus"></span>Add</button>
  193. <button type="button" class="btn btn-dark" data-dismiss="modal"><span data-feather="x"></span>Close</button>
  194. </div>
  195. </div>
  196. </form>
  197. </div>
  198. </div>
  199. <!-- FETCH DATA -->
  200. <?php
  201. $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");
  202. ?>
  203. <br>
  204. <table class="table table-bordered talbe-striped">
  205. <thead class="thead-dark">
  206. <tr>
  207. <th>Name of Material</th>
  208. <th>Control Number</th>
  209. <th>Category</th>
  210. <th>Description</th>
  211. <th>Quantity</th>
  212. <th style="text-align: center;">Action</th>
  213. </tr>
  214. </thead>
  215. <?php while($row = mysqli_fetch_assoc($fetch)) {
  216. $id = $row['id'];
  217. $item_name = $row['item_name'];
  218. $item_code = $row['item_code'];
  219. $item_category = $row['item_category'];
  220. $item_description = $row['item_description'];
  221. $critical_lvl = $row['critical_lvl'];
  222. $qty = $row['qty'];
  223. if($qty == 0){
  224. $alert = "<div class='alert alert-danger'>
  225. <strong>$qty</strong> No Stock
  226. </div>";
  227.  
  228. }else if($critical_lvl >= $qty){
  229. $alert = "<div class='alert alert-warning'>
  230. <strong>$qty</strong> Critical Level
  231. </div>";
  232. }else {
  233. $alert = $qty;
  234. }
  235. ?>
  236. <tbody>
  237. <tr>
  238. <td>
  239. <?php echo $item_name; ?>
  240. </td>
  241. <td>
  242. <?php echo $item_code; ?>
  243. </td>
  244. <td>
  245. <?php echo $item_category; ?>
  246. </td>
  247. <td>
  248. <?php echo $item_description; ?>
  249. </td>
  250. <td>
  251. <?php echo $alert; ?>
  252. </td>
  253. <td>
  254. <a href="#instockModal<?php echo $id;?>" data-toggle="modal">
  255. <button type="button" class="btn btn-success"><span data-feather="plus"></span></button>
  256. </a>
  257. <a href="#outStockModal<?php echo $id;?>" data-toggle="modal">
  258. <button type="button" class="btn btn-default"><span data-feather="minus"></span></button>
  259. </a>
  260. <a href="#editModal<?php echo $id;?>" data-toggle="modal">
  261. <button type="button" class="btn btn-warning"><span data-feather="edit"></span></button>
  262. </a>
  263. <a href="#deleteModal<?php echo $id;?>" data-toggle="modal">
  264. <button type="button" class="btn btn-danger"><span data-feather="trash-2"></span></button>
  265. </a>
  266. </td>
  267. </tr>
  268. </tbody>
  269. <!-- IN STOCK ITEM MODAL-->
  270. <div class="modal fade" id="instockModal<?php echo $id;?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  271. <div class="modal-dialog" role="document">
  272. <div class="modal-content">
  273. <div class="modal-header">
  274. <h5 class="modal-title" id="exampleModalLabel"><span data-feather="plus-circle"></span> Instock</h5>
  275. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  276. <span aria-hidden="true">&times;</span>
  277. </button>
  278. </div>
  279. <div class="modal-body">
  280. <form method="POST">
  281. <div class="form-group">
  282. <input type="hidden" name="id" value="<?php echo $id?>">
  283. </div>
  284. <div class="form-group">
  285. <label for="item_name" class="col-form-label">Name of Material:</label>
  286. <input type="text" class="form-control" id="item_name" name="item_name" placeholder="Item Name" required readonly value="<?php echo $item_name; ?>">
  287. </div>
  288. <div class="form-group">
  289. <label for="item_code" class="col-form-label">Control Number:</label>
  290. <input type="text" class="form-control" id="item_code" name="item_code" placeholder="Item Code" required readonly value="<?php echo $item_code; ?>" autocomplete="off">
  291. </div>
  292. <div class="form-group">
  293. <label for="drno" class="col-form-label">DR No:</label>
  294. <input type="text" class="form-control" id="drno" name="drno" placeholder="DR No" required="">
  295. </div>
  296. <div class="form-group">
  297. <label for="quantity" class="col-form-label">Quantity:</label>
  298. <input type="text" class="form-control" id="quantity" name="quantity" placeholder="Quantity" required="">
  299. </div>
  300. <div class="form-group">
  301. <label for="remark" class="col-form-label">Remarks:</label>
  302. <textarea class="form-control" name="remark" placeholder="Remarks" required=""></textarea>
  303. </div>
  304. </div>
  305. <div class="modal-footer">
  306. <button type="submit" class="btn btn-success" name="instock_btn"><span data-feather="plus"></span>Add</button>
  307. <button type="button" class="btn btn-dark" data-dismiss="modal"><span data-feather="x"></span>Close</button>
  308. </div>
  309. </div>
  310. </form>
  311. </div>
  312. </div>
  313. <!-- OUT STOCK ITEM-->
  314. <div class="modal fade" id="outStockModal<?php echo $id;?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  315. <div class="modal-dialog" role="document">
  316. <div class="modal-content">
  317. <div class="modal-header">
  318. <h5 class="modal-title" id="exampleModalLabel"><span data-feather="plus-circle"></span> Instock</h5>
  319. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  320. <span aria-hidden="true">&times;</span>
  321. </button>
  322. </div>
  323. <div class="modal-body">
  324. <form method="POST">
  325. <div class="form-group">
  326. <input type="hidden" name="id" value="<?php echo $id?>">
  327. </div>
  328. <div class="form-group">
  329. <label for="item_name" class="col-form-label">Name of Material:</label>
  330. <input type="text" class="form-control" id="item_name" name="item_name" placeholder="Item Name" required readonly value="<?php echo $item_name; ?>">
  331. </div>
  332. <div class="form-group">
  333. <label for="item_code" class="col-form-label">Control Number:</label>
  334. <input type="text" class="form-control" id="item_code" name="item_code" placeholder="Item Code" required readonly value="<?php echo $item_code; ?>" autocomplete="off">
  335. </div>
  336. <div class="form-group">
  337. <label for="drno" class="col-form-label">DR No:</label>
  338. <input type="text" class="form-control" id="drno" name="drno" placeholder="DR No" required="">
  339. </div>
  340. <div class="form-group">
  341. <label for="quantity" class="col-form-label">Quantity:</label>
  342. <input type="text" class="form-control" id="quantity" name="quantity" placeholder="Quantity" required="">
  343. </div>
  344. <div class="form-group">
  345. <label for="received" class="col-form-label">Received By:</label>
  346. <input type="text" class="form-control" id="received" name="received" placeholder="Received By" required="">
  347. </div>
  348. <div class="form-group">
  349. <label for="remark" class="col-form-label">Remarks:</label>
  350. <textarea class="form-control" name="remark" placeholder="Remarks" required=""></textarea>
  351. </div>
  352. </div>
  353. <div class="modal-footer">
  354. <button type="submit" class="btn btn-default" name="outstock_btn"><span data-feather="minus"></span> Out</button>
  355. <button type="button" class="btn btn-dark" data-dismiss="modal"><span data-feather="x"></span>Close</button>
  356. </div>
  357. </div>
  358. </form>
  359. </div>
  360. </div>
  361. <!-- EDIT ITEM-->
  362. <div class="modal fade" id="editModal<?php echo $id;?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  363. <div class="modal-dialog" role="document">
  364. <div class="modal-content">
  365. <div class="modal-header">
  366. <h5 class="modal-title" id="exampleModalLabel"><span data-feather="plus-circle"></span> Instock</h5>
  367. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  368. <span aria-hidden="true">&times;</span>
  369. </button>
  370. </div>
  371. <div class="modal-body">
  372. <form method="POST">
  373. <div class="form-group">
  374. <input type="hidden" name="id" value="<?php echo $id?>">
  375. </div>
  376. <div class="form-group">
  377. <label for="item_name" class="col-form-label">Name of Material:</label>
  378. <input type="text" class="form-control" id="item_name" name="item_name" placeholder="Item Name" value="<?php echo $item_name; ?>">
  379. </div>
  380. <div class="form-group">
  381. <label for="item_code" class="col-form-label">Control Number:</label>
  382. <input type="text" class="form-control" id="item_code" name="item_code" placeholder="Item Code" required readonly value="<?php echo $item_code; ?>" autocomplete="off">
  383. </div>
  384. <div class="form-group">
  385. <label for="category" class="col-form-label">Category:</label>
  386. <input type="text" class="form-control" id="category" name="category" placeholder="" value="<?php echo $item_category;?>">
  387. </div>
  388. <div class="form-group">
  389. <label for="description" class="col-form-label">Description:</label>
  390. <input type="text" class="form-control" id="description" name="description" placeholder="Descrption" value="<?php echo $item_description?>">
  391. </div>
  392. </div>
  393. <div class="modal-footer">
  394. <button type="submit" class="btn btn-default" name="edit_btn"><span data-feather="edit"></span> Edit</button>
  395. <button type="button" class="btn btn-dark" data-dismiss="modal"><span data-feather="x"></span>Close</button>
  396. </div>
  397. </div>
  398. </form>
  399. </div>
  400. </div>
  401. <!-- DELETE MODAL -->
  402. <div class="modal fade" id="deleteModal<?php echo $id;?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  403. <div class="modal-dialog" role="document">
  404. <div class="modal-content">
  405. <div class="modal-header">
  406. <h5 class="modal-title"><span data-feather="trash-2"></span> Delete</h5>
  407. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  408. <span aria-hidden="true">&times;</span>
  409. </button>
  410. </div>
  411. <form method="POST">
  412. <div class="modal-body">
  413. <input type="hidden" name="delete_id" value="<?php echo $id; ?>">
  414. <div class="alert alert-danger">Are you sure you want delete <strong>
  415. <?php echo $item_name; ?>?</strong>
  416. </div>
  417. <div class="modal-footer">
  418. <button type="submit" class="btn btn-danger" name="delete_btn"><span data-feather="trash-2"></span> Delete</button>
  419. <button type="button" class="btn btn-dark" data-dismiss="modal"><span data-feather="x"></span> Close</button>
  420. </div>
  421. </div>
  422. </form>
  423. </div>
  424. </div>
  425. </div>
  426. <?php }?>
  427. </table>
  428. </main>
  429. <!-- Bootstrap core JavaScript
  430. ================================================== -->
  431. <!-- Placed at the end of the document so the pages load faster -->
  432. <script src="js/jquery.js"></script>
  433. <script src="js/bootstrap.min.js"></script>
  434.  
  435. <!-- Icons -->
  436. <script src="custom/icon.js"></script>
  437. <script>
  438. feather.replace()
  439. </script>
  440. </body>
  441. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement