-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstats.php
More file actions
169 lines (165 loc) · 3.84 KB
/
Copy pathstats.php
File metadata and controls
169 lines (165 loc) · 3.84 KB
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
<?php
require_once("./includes/session_timeout.inc.php");
require("./includes/session_var_setup.inc.php");
require_once("./includes/connection.inc.php");
if (isset($_POST['settingsubmit'])){
require("./includes/settingupdate.inc.php");
}
$connw = dbConnect('write');
$completed_emails = '';
if($_SESSION['role'] != 'admin'){
header('Location: index.php');
}
$sql = "SELECT showduration FROM users WHERE role = 'trainer'";
$result = $connw->query($sql);
?>
<html>
<head>
<script language="Javascript">
function hideA(x)
{
if (x.checked)
{
document.getElementById("A").style.display="none";
document.getElementById("B").style.display="block";
}
}
function showA(x)
{
if (x.checked)
{
document.getElementById("A").style.display="block";
document.getElementById("B").style.display="none";
}
}
</script>
<title="Settings Management">
</head>
<body>
<h1></h1>
<table width="400px"><tr><td>
<h1>Statistics Page</h1>
<p>This stats page provides basic information, including alerts about incomplete checklists and missing attendance.</p>
</td></tr></table>
<table border="2">
<tr><td>Number 1 hour shows:</td>
<td><?php
$show1hr = 0;
$show2hr = 0;
while($row = $result->fetch_assoc()){
if($row['showduration'] == 1) {
$show1hr++;
} else {
$show2hr++;
}
}
echo $show1hr;
?></td></tr>
<tr><td>Number 2 hour shows:</td>
<td><?php echo $show2hr;?></td>
</tr>
<tr>
<td>Max Capacity</td>
<td><?php echo $setting['max1hour'] * $show1hr
+ $setting['max2hour'] * $show2hr;?></td>
</tr>
<tr><td>Enrolled Students</td>
<td><?php
$result->close();
$sql = "SELECT user_id FROM users WHERE role = 'trainee'";
$result = $connw->query($sql);
echo $result->num_rows;
?></td></tr>
</table>
<p>
<label for="simple">Simple Info</label>
<input type="radio" onchange="showA(this)" name="selector" value="simple" checked>
<label for="detailed">Detailed Info</label>
<input type="radio" onchange="hideA(this)" name="selector" value="detailed">
<?php
$result->close();
$sql = "SELECT * FROM users JOIN attendance ON users.user_id = attendance.user_id WHERE role = 'trainee'";
$students = $connw->query($sql);
?>
<div id="A" style="display: block">
<h2>Breakdown by Trainee</h2>
<table border="2">
<tr>
<th>Name</th>
<th>Email</th>
<th>Attendance</th>
</tr>
<?php
while($student = $students->fetch_assoc()){?>
<tr>
<td><?php echo $student['fname'] . ' ' . $student['lname']; ?></td>
<td><?php echo $student['email']; ?></td>
<td><?php
$numweeks = 0;
for ($i = $showweek; $i > 0; $i--) {
if ($student[$i . "_attend"]){
$numweeks++;
}
}
if ($numweeks >= 2) {
echo "Complete!";
$completed_emails .= $student['email'] . ', ';
} else {
echo "incolmplete";
}
?></td>
</tr>
<?php }
?>
</table>
<?php if($completed_emails){
echo "<h4>Here are the emails of completed trainees:</h4>";
echo $completed_emails;
} ?>
</div>
<?php
$students->close();
$sql = "SELECT * FROM users WHERE role = 'trainer'";
$result = $connw->query($sql);
?>
<div id="B" style="Display: none">
<h2>Detailed Show Info</h2>
<?php while ($row = $result->fetch_assoc()) {?>
<h3><?php echo $row['fname'] . ' ' . $row['lname'] . ' (' . $row['showname']
. ')';?></h3>
<table border="2">
<tr>
<th>Attendee</th>
<th>Email</th>
<th>Missing Attendance?</th>
</tr>
<?php
$sql = "SELECT * FROM users JOIN attendance ON users.user_id = attendance.user_id
WHERE showchoice = " . $row['user_id'];
$students = $connw->query($sql);
while ($student = $students->fetch_assoc()) {?>
<tr>
<td><?php echo $student['fname'] . ' ' . $student['lname']; ?></td>
<td><?php echo $student['email']; ?></td>
<td><?php
$problems = '';
for ($i = $showweek; $i > 0; $i--) {
if (!$student[$i . "_attend"]){
$problems .= 'Missed Show ' . $i . ' ';
}
}
if ($problems) {
echo $problems;
} else {
echo "OK!";
}
?></td>
</tr>
<?php }
?>
</table>
<?php } ?>
</div>
<p><a href="index.php">Home</a></p>
</body>
</html>