-
Notifications
You must be signed in to change notification settings - Fork 9
/
statistics.php
283 lines (232 loc) · 8.17 KB
/
statistics.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
<?php
// This file is part of the Huygens Remote Manager
// Copyright and license notice: see license.txt
use hrm\Nav;
use hrm\stats\Stats;
use hrm\Util;
require_once dirname(__FILE__) . '/inc/bootstrap.php';
session_start();
if (isset($_GET['home'])) {
header("Location: " . "home.php");
exit();
}
if (!isset($_SESSION['user']) || !$_SESSION['user']->isLoggedIn()) {
header("Location: " . "login.php");
exit();
}
$message = "";
// Create a Stats object
$stats = new Stats($_SESSION['user']->name());
// Get a list of possible variable to be plotted
//$possibleVariables = $stats->getPieChartVariables( );
// Get a list of statistics names for the <select> element
$possibleStats = $stats->getAllDescriptiveNames();
// Filters
$fromDate = $stats->getFromDate();
$toDate = $stats->getToDate();
$groupNames = $stats->getGroupNames();
// Was some statistics chosen?
if (isset($_POST["Statistics"])) {
$stats->setSelectedStatistics($_POST["Statistics"]);
}
// Was some FromDate chosen?
if (isset($_POST["FromDate"])) {
$chosenFromDate = $_POST["FromDate"];
} else {
$chosenFromDate = $fromDate;
}
// Was some ToDate chosen?
if (isset($_POST["ToDate"])) {
$chosenToDate = $_POST["ToDate"];
} else {
$chosenToDate = $toDate;
}
// Was some Group chosen?
if (isset($_POST["Group"])) {
$chosenGroupName = $_POST["Group"];
} else {
$chosenGroupName = $groupNames[0];
}
// Set the filters
$stats->setFromDateFilter($chosenFromDate);
$stats->setToDateFilter($chosenToDate);
$stats->setGroupFilter($chosenGroupName);
// If the statistics is a graph, we display the generated javascript via the
// '$generatedScript' header inclusion; otherwhise, we get the (PHP) script into
// the differently-named variable $tableScript.
if ($stats->isGraph() == true) {
$generatedScript = $stats->getStatistics();
$tableScript = "";
} else {
$generatedScript = "";
$tableScript = $stats->getStatistics();
}
// HighChart JavaScript library inclusions
$script = array(
"highcharts/jquery.min.js",
"highcharts/excanvas.compiled.js",
"highcharts/highcharts.js",
'calendar/calendar.js');
require_once("./inc/extern/calendar/classes/tc_calendar.php");
if (Util::using_IE()) {
$meta = '<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>';
}
include("header.inc.php");
?>
<div id="nav">
<div id="navleft">
<ul>
<?php
echo(Nav::linkWikiPage('HuygensRemoteManagerHelpStatistics'));
?>
</ul>
</div>
<div id="navright">
<ul>
<?php
echo(Nav::textUser($_SESSION['user']->name()));
echo(Nav::linkHome(Util::getThisPageName()));
?>
</ul>
</div>
<div class="clear"></div>
</div>
<!-- Here we put a select element for the user to choose which stats he
wants to display -->
<div id="stats">
<form method="post" action="" id="displayStats">
<fieldset>
<legend>
<a href="javascript:openWindow(
'http://www.svi.nl/HuygensRemoteManagerHelpStatistics')">
<img src="images/help.png" alt="?"/>
</a>
Statistics
</legend>
<select name="Statistics"
title="Available statistics"
id="Statistics"
class="selection"
size="1">
<!-- Show/hide the group selector based on the statistics chosen -->
<script>
$(document).ready(function () {
$('select#Statistics').change(function () {
if ($('select#Statistics').val() == 'Export all statistics to file') {
$('select#Group').hide();
$('#cal_filter').hide();
} else {
$('select#Group').show();
$('#cal_filter').show();
}
})
});
</script>
<?php
foreach ($possibleStats as $currentStats) {
if ($currentStats == $stats->getSelectedStatistics()) {
$selected = "selected=\"selected\"";
} else {
$selected = "";
}
?>
<option <?php echo $selected ?>>
<?php echo $currentStats ?>
</option>
<?php
}
?>
</select>
<div id="cal_filter">
[From] Filter by date [To]
<div id="cal_from">
<?php
// Filter: from date
$cal = new tc_calendar("FromDate", true, false);
$cal->setIcon("./inc/extern/calendar/images/iconCalendar.gif");
$cal->setDate(
date('d', strtotime($chosenFromDate)),
date('m', strtotime($chosenFromDate)),
date('Y', strtotime($chosenFromDate)));
$cal->setPath("./inc/extern/calendar/");
$cal->setYearInterval(
date('Y', strtotime($stats->getFromDate())),
date('Y', strtotime($stats->getToDate())));
$cal->setAlignment('left', 'bottom');
$cal->setDatePair('FromDate', 'ToDate', $chosenToDate);
$cal->writeScript();
?>
</div>
<div id="cal_to">
<?php
// Filter: to date
$cal = new tc_calendar("ToDate", true, false);
$cal->setIcon("./inc/extern/calendar/images/iconCalendar.gif");
$cal->setDate(
date('d', strtotime($chosenToDate)),
date('m', strtotime($chosenToDate)),
date('Y', strtotime($chosenToDate)));
$cal->setPath("./inc/extern/calendar/");
$cal->setYearInterval(
date('Y', strtotime($stats->getFromDate())),
date('Y', strtotime($stats->getToDate())));
$cal->setAlignment('right', 'bottom');
$cal->setDatePair('FromDate', 'ToDate', $chosenFromDate);
$cal->writeScript();
?>
</div>
<!-- Filter: Group This is visible only for the admin user-->
<?php
if ($_SESSION['user']->isAdmin()) {
?>
<select name="Group"
title="Available groups"
id="Group"
class="selection"
size="1">
<?php
foreach ($groupNames as $groupName) {
if ($groupName == $chosenGroupName) {
$selected = "selected=\"selected\"";
} else {
$selected = "";
}
?>
<option <?php echo $selected ?>><?php echo $groupName ?></option>
<?php
}
?>
</select>
<?php
}
?>
</div> <!-- cal_filter -->
<div style="clear:both;">
<input type="submit" name="Submit" value="Go!"/>
</div>
</fieldset>
</form>
</div>
<!-- Hack for IE -->
<script type="text/javascript">
if ($.browser.msie) {
if ($.browser.version >= 9) {
$("#stats").css("height", "90");
}
}
</script>
<?php
if ($stats->isGraph() == true) {
?>
<!-- This is where the graph will be displayed -->
<div id="statschart"></div>
<?php
} else {
?>
<div id="statstable"><?php echo $tableScript; ?></div>
<?php
}
?>
<?php
include("footer.inc.php");
?>