-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin_inventory.php
executable file
·106 lines (84 loc) · 4.06 KB
/
admin_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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
include 'tpl/auth.php';
include 'tpl/sql.php';
// Pull the details of the cultivars etc coz we're going to need those:
// Eventually we'll put the Facilities in here too but I'm lazy so this is a note for future-me
$sql = "SELECT id,cultivar_name from cultivars";
$result = mysqli_query($con,$sql);
$cultivars = mysqli_fetch_all($result, MYSQLI_ASSOC);
/*if ((strlen($_POST['submit']) > 1) && (strlen($_POST['newplants']) > 0)) {
// We define newplants as a low number as a fallback in case of issues
$newplants = 1;
// Pull the details from the submitted form
$cultivarid = filter_var($_POST['cultivar'], FILTER_SANITIZE_STRING);
$facilityid = filter_var($_POST['facility'], FILTER_SANITIZE_STRING);
$newplants = filter_var($_POST['newplants'], FILTER_SANITIZE_STRING);
// variables needed for the inserts
$date = date('Y-m-d');
$current_row_for_insert = 0;
while ($current_row_for_insert <= $newplants) {
// Make a UniqueID for the plant
$plant_uniqueid = uniqid('p', true);
// Increase plant #
$current_row_for_insert++;
$sql="INSERT INTO inventory (facilityid, date_of_spawn, plant_uniqueid, season_id, plant_num, where_is_it_now, current_state, cultivar) VALUES ('$facilityid','$date','$plant_uniqueid','1','$current_row_for_insert','Nursery','In the early life stages','$cultivarid')";
//if (mysqli_query($conn, $sql)) {
if ($result = mysqli_query($con, $sql)) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
}
$savesuccess = 'true';
}
*/
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>growTENT :: View inventory</title>
<!-- Sets initial viewport load and disables zooming -->
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
<!-- Makes your prototype chrome-less once bookmarked to your phone's home screen -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<!-- Include the compiled Ratchet CSS -->
<link rel="stylesheet" href="ratchet-theme-ios.min.css">
<link rel="stylesheet" href="ratchet.min.css">
<link rel="stylesheet" href="app.css">
<!-- Include the compiled Ratchet JS -->
<!-- <script src="ratchet.js"></script> -->
</head>
<body>
<!-- Make sure all your bars are the first things in your <body> -->
<header class="bar bar-nav">
<a href="admin.php"><button class="btn btn-link btn-nav pull-left">
<span class="icon icon-home"></span>
Home
</button></a>
<h1 class="title">Current inventory</h1>
</header>
<!-- Wrap all non-bar HTML in the .content div (this is actually what scrolls) -->
<div class="content">
<p class="content-padded" align="center">Current inventory (all alive plants)</p>
<div class="card">
<?php
// LazyJo says we'll need to also INNER JOIN on Facility in the future
// But that's a problem for future-me
// $sql = "SELECT cultivars.cultivar_name, inventory.id, inventory.plant_uniqueid, inventory.season_id, inventory.where_is_it_now, inventory.plant_num FROM inventory INNER JOIN cultivars ON inventory.cultivar=cultivars.id ORDER BY inventory.id DESC LIMIT 500";
$sql = "SELECT * FROM inventory WHERE is_alive='1' ORDER BY ID DESC";
$result = mysqli_query($con,$sql);
$row = mysqli_fetch_all($result, MYSQLI_ASSOC);
echo " <ul class='table-view'>\n";
foreach($row as $currentrow) {
echo " <li class='table-view-cell'>\n<a href='admin_viewplant.php?p=" . $currentrow['plant_uniqueid'] . "' class='navigate-right'>" . $currentrow['cultivar'] . ", Season " . $currentrow['season_id'] . ", Location: " . $currentrow['where_is_it_now'] . ", Plant # " . $currentrow['plant_num'] . ", Unique ID: " . $currentrow['plant_uniqueid'] . "</a></li>";
// echo " <li class='table-view-cell'>" . $currentrow[cultivar_name] . " " . $currentrow[plant_uniqueid] . "<a href='admin_viewplant.php?p=" . $currentrow[plant_uniqueid] . "' class='navigate-right'>View</a></li>";
}
echo "</ul><br />\n";
?>
</form>
</div>
</div>
</body>
</html>