-
Notifications
You must be signed in to change notification settings - Fork 7
/
reports.php
405 lines (338 loc) · 13.6 KB
/
reports.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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
<?php
$subsys="reports";
require_once('db-open.php');
include('local-dls.php');
require_once('session.inc');
require_once('functions.php');
header_html("Dispatch :: Reports");
?>
<body vlink="blue" link="blue" alink="cyan">
<?php
include('include-title.php');
if (!CheckAuthByLevel('reports', $_SESSION["access_level"])) {
print "Access level too low to access Reports page.";
exit;
}
// Initialize date arrays for choosers, unit array for unit chooser
$incidents_dates = array();
$incidents_types = array();
$units_dates = array();
$units = array();
$message_types = array();
$unit_filter_sets = array();
$query = "SELECT DATE_FORMAT(ts_opened,'%Y-%m-%d') as ts_date FROM incidents GROUP BY ts_date DESC";
$result = mysql_query($query) or die("In query: $query<br>\nError: ".mysql_error());
while ($line = mysql_fetch_object($result)) {
array_push($incidents_dates, $line->ts_date);
}
mysql_free_result($result);
$query = "SELECT DATE_FORMAT(ts, '%Y-%m-%d') as ts_date FROM messages GROUP BY ts_date DESC";
$result = mysql_query($query) or die("In query: $query<br>\nError: ".mysql_error());
while ($line = mysql_fetch_object($result)) {
array_push($units_dates, $line->ts_date);
}
mysql_free_result($result);
foreach ($incidents_dates as $idate) {
if (!in_array($idate, $units_dates)) {
array_push($units_dates, $idate);
}
}
sort($units_dates);
$query = "SELECT unit FROM units ORDER BY unit ASC";
$result = mysql_query($query) or die("In query: $query<br>\nError: ".mysql_error());
while ($line = mysql_fetch_object($result)) {
array_push($units, $line->unit);
}
natsort($units);
mysql_free_result($result);
$query = "SELECT call_type FROM incident_types ORDER BY call_type ASC";
$result = mysql_query($query) or die("In query: $query<br>\nError: ".mysql_error());
while ($line = mysql_fetch_object($result)) {
array_push($incidents_types, $line->call_type);
}
mysql_free_result($result);
$query = "SELECT message_type FROM message_types ORDER BY message_type ASC";
$result = mysql_query($query) or die("In query: $query<br>\nError: ".mysql_error());
while ($line = mysql_fetch_object($result)) {
array_push($message_types, $line->message_type);
}
mysql_free_result($result);
$query = "SELECT DISTINCT filter_set_name FROM unit_filter_sets ORDER BY filter_set_name ASC";
$result = mysql_query($query) or die("In query: $query<br>\nError: ".mysql_error());
while ($line = mysql_fetch_object($result)) {
array_push($unit_filter_sets, $line->filter_set_name);
}
mysql_free_result($result);
?>
<div style="float: left; width: 400px;">
<div class="rbtn">
<form style="margin: 0px" name="myform" method="GET" action="reports-summary.php">
<font class="h2"><u>Incidents Summary Report</u></font><br>
<table>
<tr> <td class="text" align=left>Start Date </td>
<td align=left><SELECT name="startdate">
<?php
sort($incidents_dates);
foreach($incidents_dates as $idate) {
print "<OPTION ";
#if (date('Y-m-d', time()-86400) == $idate) print "selected ";
print "value=\"".$idate."\">".date('D', strtotime($idate)) . " ". $idate . "</option>\n";
}
?>
</select></td><td> </td></tr>
<tr> <td class="text" align=left>End Date </td>
<td align=left><SELECT name="enddate">
<?php
sort($incidents_dates);
foreach($incidents_dates as $idate) {
// This is a poor way of doing it, assumes there are incidents each day and that operational period was continuous through today.
// Also not sure of this code.
// TODO: refactor to only exclude last idate if idate==today.
print "<OPTION ";
if (date('Y-m-d', time()-86400) == $idate) print "selected ";
print "value=\"".$idate."\">".date('D', strtotime($idate)) . " ". $idate . "</option>\n";
}
?>
</select></td><td> </td></tr>
<tr> <td class="text">Show empty dates?
<td> <input type="checkbox" name="show-alldates" checked /></tr>
<tr><td></td></tr>
<tr> <td><input class="btn" type="submit" name="summary_report" value="Get Report" /></td></tr>
</table>
</form>
</div>
<!-- ---------------------------------------------------------------------------------->
<div class="rbtn">
<form style="margin: 0px" name="myform" method="GET" action="reports-incidents.php">
<div class="h2"><u>Incident Details Report</u></div>
<table>
<tr> <td title="Get report for a specific incident/call number" class="Text" align=left>For Incident # : </td>
<td title="Get report for a specific incident/call number" align=left><INPUT type=text name="call_number">
<input class="btn" type="submit" name="incidents_report" value="Get Report PDF" /></td></tr>
</table>
</form>
<table>
<tr> <td colspan=2 align=center> <hr> </td></tr>
<form style="margin: 0px" name="myform" method="GET" action="reports-incidents.php">
<tr> <td class="text" align=left>Start Date </td>
<td align=left><SELECT name="startdate">
<?php
sort($incidents_dates);
foreach($incidents_dates as $idate) {
print "<OPTION ";
if (date('Y-m-d', time()-86400) == $idate) print "selected ";
print "value=\"".$idate."\">".date('D', strtotime($idate)) . " ". $idate . "</option>\n";
}
?>
</select></td><td> </td></tr>
<tr> <td class="text" align=left>End Date </td>
<td align=left><SELECT name="enddate">
<?php
sort($incidents_dates);
foreach($incidents_dates as $idate) {
print "<OPTION ";
if (date('Y-m-d', time()-86400) == $idate) print "selected ";
print "value=\"".$idate."\">".date('D', strtotime($idate)) . " ". $idate . "</option>\n";
}
?>
</select></td><td> </td></tr>
<tr><td></td></tr>
<tr> <td class="text" align=left>Incident Type </td>
<td align=left><SELECT name="selected-type">
<?php
print "<option selected value=\"\">All types</option>\n";
foreach($incidents_types as $itype) {
print "<option value=\"".$itype."\">".$itype."</option>\n";
}
?>
</select></td><td> </td></tr>
<tr><td></td></tr>
<tr> <td class="text">All Incidents For Date</td>
<td align="left"> <input type="checkbox" name="mode" checked disabled value="report-by-date" /></td></tr>
<tr> <td class="text">Exclude TRAINING calls?</td>
<td> <input type="checkbox" checked name="hidetraining" value="1" /></tr>
<tr> <td class="text">New page for each incident?</td>
<td> <input type="checkbox" checked name="always-pagebreak" value="1" /></tr>
<tr> <td></td></tr>
<tr> <td><input class="btn" type="submit" name="incidents_report" value="Get Report PDF" /></td></tr>
</table>
</form>
</div>
<!-- ---------------------------------------------------------------------------------->
<div class="rbtn">
<form style="margin: 0px" name="myform" method="GET" action="reports-messages.php">
<font class="h2"><u>Message Report</u></font><br>
<table>
<tr>
<td class="text" align="left">Message Type</td>
<td align="left">
<SELECT name="message_type">
<OPTION value="All Messages">All Messages</option>
<?php
foreach($message_types as $message_type) {
print "<option value=\"".$message_type."\">".$message_type."</option>\n";
}
?>
</select></td> <td> </td></tr>
<tr>
<td class="text" align="left">Date</td>
<td align="left"><select name="selected-date">
<?php
foreach($units_dates as $idate) {
print "<option ";
if (date('Y-m-d', time()-86400) == $idate) print "selected ";
print "value=\"".$idate."\">".date('D', strtotime($idate)) . " ". $idate . "</option>\n";
}
?>
</select></td>
<td></td>
</tr>
<tr> <td></td> </tr>
<tr> <td><input class="btn" type="submit" name="messages_report" value="Get Report PDF" /></td> </tr>
</table>
</form>
</div>
</div> <!-- outer -->
<div style="float: left; width: 20px;">
</div> <!-- outer -->
<div style="float: left; width: 400px;">
<div class="rbtn">
<form style="margin: 0px" name="myform" method="GET" action="reports-responsetimes.php">
<font class="h2"><u>Response Times Report</u></font><br>
<table>
<tr> <td class="text" align=left>Start Date </td>
<td align=left><SELECT name="startdate">
<?php
sort($incidents_dates); // TODO: these sorts are all massively repetitive and unnecessary, right??
foreach($incidents_dates as $idate) {
print "<OPTION ";
if (date('Y-m-d', time()-86400) == $idate) print "selected ";
print "value=\"".$idate."\">".date('D', strtotime($idate)) . " ". $idate . "</option>\n";
}
?>
</select></td><td> </td></tr>
<tr> <td class="text" align=left>End Date </td>
<td align=left><SELECT name="enddate">
<?php
sort($incidents_dates); // TODO: these sorts are all massively repetitive and unnecessary, right??
foreach($incidents_dates as $idate) {
print "<OPTION ";
if (date('Y-m-d', time()-86400) == $idate) print "selected ";
print "value=\"".$idate."\">".date('D', strtotime($idate)) . " ". $idate . "</option>\n";
}
?>
</select></td><td> </td></tr>
<tr><td></td></tr>
<tr> <td class="text" align=left>Filter by Unit Set? </td>
<td align=left><SELECT name="filterset">
<?php
print "<option selected value=\"\">All units</option>\n";
foreach($unit_filter_sets as $setname) {
print "<option value=\"".$setname."\">".$setname."</option>\n";
}
?>
</select></td><td> </td></tr>
<tr> <td class="text" align=left>Filter by incident type? </td>
<td align=left><SELECT name="incidenttypes">
<?php
print "<option selected value=\"filter\">Select specific types</option>\n";
print "<option value=\"all\">All types (except TRAINING)</option>\n";
?>
</select></td><td> </td></tr>
<tr><td></td></tr>
<tr> <td><INPUT class="btn" type="submit" name="units_report" value="Get Report PDF"></td></tr>
</table>
</form>
</div>
<!-- ---------------------------------------------------------------------------------->
<div class="rbtn">
<form style="margin: 0px" name="myform" method="GET" action="reports-units.php">
<font class="h2"><u>Unit Details Report</u></font><br>
<table>
<tr> <td class="text" align="left">Unit</td>
<td align="left"><select name="unit">
<?php
foreach($units as $unit) {
print "<OPTION value=\"".$unit."\">".$unit."</option>\n";
}
?>
</select></td><td> </td></tr>
<tr> <td class="text" align=left>Start Date </td>
<td align=left><SELECT name="startdate">
<?php
sort($units_dates); // TODO: these sorts are all massively repetitive and unnecessary, right??
foreach($units_dates as $idate) {
print "<OPTION ";
if (date('Y-m-d', time()-86400) == $idate) print "selected ";
print "value=\"".$idate."\">".date('D', strtotime($idate)) . " ". $idate . "</option>\n";
}
?>
<tr> <td class="text" align=left>End Date </td>
<td align=left><SELECT name="enddate">
<?php
foreach($units_dates as $idate) {
print "<OPTION ";
if (date('Y-m-d', time()-86400) == $idate) print "selected ";
print "value=\"".$idate."\">".date('D', strtotime($idate)) . " ". $idate . "</option>\n";
}
?>
</select></td><td> </td></tr>
</select></td><td> </td></tr>
<tr><td></td></tr>
<tr> <td><INPUT class="btn" type="submit" name="units_report" value="Get Report PDF"></td></tr>
</table>
</form>
</div>
<!-- ---------------------------------------------------------------------------------->
<div class="rbtn">
<form style="margin: 0px" name="myform" method="GET" action="reports-utilization.php">
<font class="h2"><u>Unit Utilization Report</u></font><br>
<table>
<tr> <td class="text" align=left>Start Date </td>
<td align=left><SELECT name="startdate">
<?php
sort($incidents_dates); // TODO: these sorts are all massively repetitive and unnecessary, right??
foreach($incidents_dates as $idate) {
print "<OPTION ";
if (date('Y-m-d', time()-86400) == $idate) print "selected ";
print "value=\"".$idate."\">".date('D', strtotime($idate)) . " ". $idate . "</option>\n";
}
?>
</select></td><td> </td></tr>
<tr> <td class="text" align=left>End Date </td>
<td align=left><SELECT name="enddate">
<?php
sort($incidents_dates); // TODO: these sorts are all massively repetitive and unnecessary, right??
foreach($incidents_dates as $idate) {
print "<OPTION ";
if (date('Y-m-d', time()-86400) == $idate) print "selected ";
print "value=\"".$idate."\">".date('D', strtotime($idate)) . " ". $idate . "</option>\n";
}
?>
</select></td><td> </td></tr>
<tr><td></td></tr>
<tr> <td class="text" align=left>Filter by Unit Set? </td>
<td align=left><SELECT name="filterset">
<?php
print "<option selected value=\"\">All units</option>\n";
foreach($unit_filter_sets as $setname) {
print "<option value=\"".$setname."\">".$setname."</option>\n";
}
?>
</select></td><td> </td></tr>
<tr> <td class="text" align=left>Filter by incident type? </td>
<td align=left><SELECT name="incidenttypes">
<?php
print "<option value=\"filter\">Select specific types</option>\n";
print "<option selected value=\"all\">All types (except TRAINING)</option>\n";
?>
</select></td><td> </td></tr>
<tr><td></td></tr>
<tr> <td><INPUT class="btn" type="submit" name="units_report" value="Get Report PDF"></td></tr>
</table>
</form>
</div>
<!-- ---------------------------------------------------------------------------------->
</body>
</html>