-
Notifications
You must be signed in to change notification settings - Fork 3
/
inventory.php
92 lines (82 loc) · 2.71 KB
/
inventory.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!DOCTYPE html>
<html>
<?php
include_once("header.php");
include_once("db.php");
?>
<h2 id="demofont3">Inventory</h2>
<body>
<link rel="stylesheet" href="style/protocol.css">
<div class="color">
<?php
//Creating table of inventory
$sql = "SELECT InventName, Amount, Unit FROM Inventory ORDER BY InventName";
$result = mysqli_query($conn,$sql);
if (mysqli_num_rows($result) == 0) {
print("No chemicals in inventory<br>\n");
} else {
echo "<table border='1' class='center'>";
echo "<tr><th>Chemical</th><th>Amount in inventory</th><th>Alerts</th>";
while($row = mysqli_fetch_row($result)) {
echo "<tr><td>";
echo $row[0];
echo "</td><td>";
echo $row[1] . " " . $row[2];
echo "</td><td style='color:#FF0000'>";
if ($row[1] <= 50) {
echo "Running out of stock!";
}
echo "</td><tr>";
}
}
echo "</table>";
?>
</div>
<h2 id="demofont3">Add or remove chemicals</h2>
<!--To add chemicals-->
<div class="color">
<div class='add_chemicals' style="margin:0px">
<form action="add_to_inventory.php" method="POST">
<div class="search-box">
<label name="chemical_name">Chemical:</label>
<input type="text" name="chemical_name" required autocomplete="off" />
<div class="result"></div>
</div>
<br><label name="amount">Amount (ml):</label>
<select name="amount" style="width:200px"></br>
<option selected="selected"></option>;
<?php
for($x=-500;$x<=10000;$x+=50) {
print "<option value='$x'>$x</option>";
}
?>
</select><br>
<button name="submit" type="submit" class="button"><span>Enter</span></button></br>
</form>
</div>
</div>
<h2 style='opacity:0'>Blank Space</h2>
<script type="text/javascript">
$(document).ready(function(){
$('.search-box input[type="text"]').on("keyup input", function(){
/* Get input value on change */
var inputVal = $(this).val();
var resultDropdown = $(this).siblings(".result");
if(inputVal.length){
$.get("livesearchFORinventory.php", {term: inputVal}).done(function(data){
// Display the returned data in browser
resultDropdown.html(data);
});
} else{
resultDropdown.empty();
}
});
// Set search input value on click of result item
$(document).on("click", ".result p", function(){
$(this).parents(".search-box").find('input[type="text"]').val($(this).text());
$(this).parent(".result").empty();
});
});
</script>
</body>
</html>