-
Notifications
You must be signed in to change notification settings - Fork 0
/
inventoryreport.php
186 lines (173 loc) · 6.17 KB
/
inventoryreport.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<?php
require_once('connectvars.php');
require_once('appfunctions.php');
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$form_type = mysqli_real_escape_string($dbc, trim($_GET['type']));
$page_title = 'Inventory Report';
$page_access = 'All';
include('header.php');
//include other scripts needed here
//end header
echo '</head>';
//start body
echo '<body>';
//include nav bar
include('navbar-teachers.php');
?>
<div class="bd-pageheader bg-primary text-white pt-4 pb-4">
<div class="container">
<h1>
Classes
</h1>
<p class="lead">
Manage and submit lesson plans, weekly assessment data, and inventory
</p>
</div>
</div>
<div class="container mt-5 mb-5">
<div class="row">
<div class="col-12">
<h1>
Inventory Report
</h1>
<p class="lead">
Use this page to view inventory updates
</p>
<p>
<a class="btn btn-outline-primary" href="inventory.php">Inventory Input</a>
<a class="btn btn-outline-primary" href="inventoryscan.php">Inventory Scan</a>
</p>
<h2>
Last Scanned Items
</h2>
<p>
Listed below are the last 20 items that have been scanned.
</p>
<table class="table table-striped">
<thead>
<tr>
<th>Item No.</th>
<th>Name/Title</th>
<th>Scanned Room</th>
<th>Inventory Room</th>
<th>Scanned By</th>
<th>Scan Date/Time</th>
</tr>
</thead>
<tbody>
<?php
$query = "SELECT item_id, firstname, lastname, scan.room AS scanroom, i.room AS iroom, title, scan_datetime FROM inventory_scan AS scan LEFT JOIN inventory AS i ON (scan.item_id = i.itemId) LEFT JOIN staff_list AS sl ON (scan.username = sl.username) ORDER BY scan_id DESC LIMIT 20";
$result = mysqli_query($dbc, $query);
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_array($result)) {
echo '<tr><td>' . $row['item_id'] . '</td><td>' . $row['title'] . '</td><td>' . $row['scanroom'] . '</td><td>' . $row['iroom'] . '</td><td>' . $row['firstname'] . ' ' . $row['lastname'] . '</td><td>' . parseDatetime($row['scan_datetime']) . '</td></tr>';
}
}
?>
</tbody>
</table>
<h2>
Missing/Stolen Items
</h2>
<table class="table table-striped">
<thead>
<tr>
<th>Item No.</th>
<th>Location</th>
<th>Room</th>
<th>Fund</th>
<th>Name/Title</th>
<th>Serial</th>
<th>Reported by</th>
<th>Report Date</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<?php
$query = "SELECT i.itemId, location, i.room, title, serial, firstname, lastname, date, description FROM inventory AS i LEFT JOIN inventory_updates AS iu USING (itemId) LEFT JOIN staff_list AS sl ON (iu.username = sl.username) WHERE iu.status = 'Missing/Damaged' ORDER BY location, i.room";
$result = mysqli_query($dbc, $query);
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_array($result)) {
$name = $row['firstname'] . ' ' .$row['lastname'];
echo '<tr><td>' . $row['itemId'] . '</td><td>' . $row['location'] . '</td><td>' . $row['room'] . '</td><td>' . $row['fund'] . '</td><td>' . $row['title'] . '</td><td>' . $row['serial'] . '</td><td>' . $name . '</td><td>' . makeDateAmerican($row['date']) . '</td><td>' . $row['description'] . '</td></tr>';
}
}
?>
</tbody>
</table>
<h2>
Last Reporting Date
</h2>
<table class="table table-striped table-responsive">
<thead>
<tr>
<th>Location</th>
<th>Room</th>
<th>Assigned Teacher</th>
<th>Last Reporting Date</th>
<th>Items Status</th>
</tr>
</thead>
<tbpdy>
<?php
$query = "SELECT location, i.room, firstname, lastname, date FROM inventory AS i LEFT JOIN inventory_updates AS iu USING (itemId) LEFT JOIN staff_list AS sl ON (FIND_IN_SET(i.room, sl.room) <> 0) GROUP BY location, room ORDER BY location, i.room";
$result = mysqli_query($dbc, $query);
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_array($result)) {
$name = $row['firstname'] . ' ' .$row['lastname'];
echo '<tr';
if ($row['date'] !== null) {
$total = 0;
$present = 0;
$date = $row['date'];
$location = $row['location'];
$room = $row['room'];
$query = "SELECT itemId, status FROM inventory_updates AS iu LEFT JOIN inventory AS i USING (itemId) WHERE date = '$date' AND location = '$location' AND room = '$room'";
$data = mysqli_query($dbc, $query);
while ($item = mysqli_fetch_array($data)) {
if ($item['status'] == 'Present') {
$present++;
}
$total++;
}
if ($total == $present) {
echo ' class="table-success"';
}
else {
echo ' class="table-danger"';
}
}
else {
echo ' class="table-warning"';
}
echo '><td>' . $row['location'] . '</td><td>' . $row['room'] . '</td><td>' . $name . '</td><td>';
if ($row['date'] !== null) {
echo makeDateAmerican($row['date']);
echo '</td>';
if ($total == $present) {
echo '<td>All Items Present</td>';
}
else {
$missing = $total - $present;
echo '<td>' . $missing . ' ITEM(S) MISSING</td>';
}
}
else {
echo '<td>Nothing Submitted</td>';
}
echo '</tr>';
}
}
?>
</tbpdy>
</table>
</div>
</div>
</div>
<?php
mysqli_close($dbc);
//include footer
include('footer.php');
?>