-
Notifications
You must be signed in to change notification settings - Fork 2
/
statistics.php
156 lines (124 loc) · 4.23 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
<?php
require_once 'inc/standard.php';
//$page = new Page($name, $css);
$page = new Page('statistics', ALL);
$page->setTitle('Statistics');
$page->startGraph();
//adds the jQuery Sparkline to the header
$var_array = new VarArray();
/* User Statistics
*
*/
//Top Participants
$sql = "SELECT users.ucinetid, COUNT(*) as num_events FROM users, barcodes, scans, events
WHERE users.ucinetid = barcodes.ucinetid
AND barcodes.barcode = scans.barcode
AND scans.eid = events.eid
AND users.elig = 1
GROUP BY users.name
ORDER BY num_events DESC
LIMIT 10;";
$DB->query($sql);
$top_participants = '<div class="row">
<h2>Top Participants</h2>
<div class="legend_pie">
<div class="legend_pie_inside">
<div class="row center">
<span class="left">User</span>
<span class="right">Number of Events</span>
</div>';
$result = $DB->resultToArray();
if(!empty($result))
{
foreach($result as $key => $value)
{
$top_participants .= '<div class="row">
<font color="#003333">
<span class="left">'.$value[0].'</span>
<span class="right">'.$value[1].'</span>
</font><br>
</div>';
}
}
$top_participants .= " </div>
</div>
</div>";
foreach($var_array->getAccess() as $key => $value)
{
//echo $key.' => '.$value;
$access[$value] = $DB->countOf('users', 'access = "'.$key.'"');
}
$access_stat = new Statistic('pie', 'user_access', 'Registered Users - Access', $access, 6); //play with this number to change up the colors
/*end Major Statistics*/
/*
* Major Statistics
*/
foreach ($var_array->getMajors() as $major) {
$where .= 'major NOT LIKE \''.$major.'\' AND ';
if($major != "Other")
{
$majors[$major] = $DB->countOf('users', 'major = "'.$major.'"');
}
else
{
$where = substr($where, 0, strlen($where)-5);
//echo "where: ".$where;
//$majors["other"] = $DB->countOf('users', $where_majors_not_like, 1);
$majors["Other"] = $DB->countOf('users', $where);
}
}
$majors_stat = new Statistic('pie', 'user_majors', 'Registered Users - Major', $majors, 0);//play with this number to change up the colors
/*end Major Statistics*/
/*
* Levels Statistics
*/
foreach ($var_array->getLevels() as $level) {
$levels[$level] = $DB->countOf('users', 'level = "'.$level.'"');
}
$levels_stat = new Statistic('pie', 'user_levels', 'Registered Users - Level', $levels, 2);//play with this number to change up the colors
/* end Levels Statistic */
/*
* Events Statistics
*/
foreach ($var_array->getDates() as $key => $value) {
$new_key = date('n/d',strtotime($key));
$events[$new_key] = $DB->countOf('events', 'date = "'.$key.'"');
//echo 'date = "'.$key.'" - '.$events[$new_key].'<br>';
}
$events_stat = new Statistic('bar', 'events_stat', 'Number of Events on Each Day', $events, 2);//play with this number to change up the colors
/* end Events Statistic */
/*
* Events Statistics
*/
foreach ($var_array->getDates(false, true) as $key => $value) {
$new_key = date('n/d',strtotime($key));
$sql = 'SELECT COUNT(*)
FROM scans
LEFT JOIN events
ON scans.eid = events.eid
WHERE events.date LIKE "'.$key.'"';
$scans[$new_key] = $DB->queryUniqueValue($sql);
//echo 'date = "'.$key.'"';
}
$participation_stat = new Statistic('bar', 'scans_week', 'Participation on Each Day', $scans, 7);//play with this number to change up the colors
/* end Events Statistic */
$bottom .= $top_participants;
$bottom .= '<div class="separator"></div>';
$bottom .= $access_stat->display();
$bottom .= '<div class="separator"></div>';
$bottom .= $majors_stat->display();
$bottom .= '<div class="separator"></div>';
$bottom .= $levels_stat->display();
$bottom .= '<div class="separator"></div>';
$bottom .= $events_stat->display();
$bottom .= '<div class="separator"></div>';
$bottom .= $participation_stat->display();
/*
$bottom .= '<div id="chart"></div>
<script src="js/chart.js"></script>';
*/
$box = new Box('Statistics', $bottom);
$content = $box->display('full');
$page->setContent($content);
$page->buildPage();
?>