-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathallSessionsByLibrarian.php
executable file
·185 lines (156 loc) · 7.39 KB
/
allSessionsByLibrarian.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
<?php
include('control/connectionVars.php');
include('classes/InstructionSession.php');
include('classes/User.php');
include('control/functions.php');
require_once('control/startSession.php');
// Insert the page header
$page_title = 'All Sessions - by Librarian';
include('includes/header.php');
// $thisUser=$_SESSION['thisUser'];
(isset($_GET['semester']) && $_GET['semester'] != "") ? $semester = $_GET['semester'] : $semester = "any";
(isset($_GET['year']) && $_GET['year'] != "") ? $year = $_GET['year'] : $year = "any";
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
or die('Error connecting to the stupid database');
$query ='select '.
's.sesdID as sessionID, '.
'p.ppleFName as FirstName, '.
'p.ppleLName as LastName, '.
'cp.crspName as CoursePrefix, '.
's.sesdCourseNumber as CourseNumber, '.
's.sesdCourseSection as CourseSection, '.
's.sesdCourseTitle as CourseTitle, '.
's.sesdDate as Date, '.
's.sesdFaculty as Faculty, '.
's.sesdFellowPresent as FellowPresent, '.
'sl.seslName as SessionLength, '.
'sl.seslMinutes as SessionMinutes, '.
's.sesdNumStudents as StudentCount, '.
's.sesdOutcomeDone as OutcomeDone, '.
's.sesdAssessed as AssessedDone '.
'from '.
'sessiondesc s, '.
'sesslength sl, '.
'courseprefix cp, '.
'librarianmap lm, '.
'people p '.
'where '.
's.sesdcrspID = cp.crspID '.
'and lm.libmppleID=p.ppleID '.
'and s.sesdlibmID = lm.libmID '.
'and s.sesdseslID = sl.seslID ';
if (isset($_GET['semester']) && $_GET['semester'] != "any") {
switch ($_GET['semester']) {
case "spring":
$query .= "and MONTH(s.sesdDate) <= 4 ";
break;
case "fall":
$query .= "and MONTH(s.sesdDate) >= 8 ";
break;
case "summer":
$query .= "and MONTH(s.sesdDate) > 4 AND MONTH(s.sesdDate) < 8 ";
break;
}
}
if (isset($_GET['year']) && (is_numeric($_GET['year']) || $_GET['year'] == 'any')) {
$year = $_GET['year'];
} else {
$year = 'any';
}
if ($year != 'any') {
$query .= 'and ((YEAR(s.sesdDate)=' . $year . ' and MONTH(s.sesdDate)<=4) or (YEAR(s.sesdDate)=' . ($year-1) . ' and MONTH(s.sesdDate)>=8)) ';
}
echo '<h2>All Sessions by Librarian - '.htmlspecialchars($semester).' semester, AY '.$year.'</h2>';
/*TODO: this is an annoying workaround that prevents the focus to filter input from breaking (can't click or enter */
echo'<span> </span>';
$query .= 'order by '.
'LastName, '.
'CoursePrefix, '.
'CourseNumber, '.
'CourseSection;';
// 9 columns.
$output = '<div class="dataTables_filter">
<label for="dataTables_filter">Filter</label><input type="text" id="dataTables_filter" class="ui-widget" />
<label for="dataTables_invert">Invert</label><input type="checkbox" id="dataTables_invert" />
</div>
<table id="allSessions"><thead id="allSessionsHead"><tr>'.
// *** for dataTables grouping addOn ***
// *** delete header and data lines if not used ***
"<th>Librarian</th>".
// *** ***
'<th>Course Number</th>'.
'<th>Course Faculty</th>'.
'<th>Fellow Present</th>'.
'<th>Session Held</th>'.
'<th>Semester</th>'.
'<th>Week</th>'.
'<th>Students</th>'.
'<th>Minutes</th>'.
'<th>Outcomes?</th>'.
'<th>Assessed?</th>'.
'</tr></thead><tbody>';
$result = mysqli_query($dbc, $query) or die('Error in allSessionsByLibrarian: ' . mysqli_error($dbc));
while ( $row = mysqli_fetch_assoc( $result) )
{
$librarian=$row['LastName'].", ".$row['FirstName'];
$courseNumber=$row['CoursePrefix'].$row['CourseNumber'].'-'.$row['CourseSection'];
$courseFaculty=$row['Faculty'];
$fellowPresent=$row['FellowPresent'];
$sessionDate=$row['Date'];
$semester= toSemester($sessionDate);
$weekNumber= toWeekNumber($sessionDate);
$numberOfStudents=$row['StudentCount'];
$sessionMinutes=$row['SessionMinutes'];
$outcomesDone=$row['OutcomeDone'];
$assessedDone=$row['AssessedDone'];
$output.="<tr class='allSessions'>".
// *** for dataTables grouping addOn ***
// *** delete header and data line if not used ***
"<td class='allSessions'>$librarian</td>".
// *** ***
"<td class='allSessions'>$courseNumber</td>".
"<td class='allSessions'>$courseFaculty</td>".
"<td class='allSessions'>$fellowPresent</td>".
"<td class='allSessions'>$sessionDate</td>".
"<td class='allSessions'>$semester</td>".
"<td class='allSessions'>$weekNumber</td>".
"<td class='allSessions'>$numberOfStudents</td>".
"<td class='allSessions'>$sessionMinutes</td>".
"<td class='allSessions'>$outcomesDone</td>".
"<td class='allSessions'>$assessedDone</td>".
"</tr>";
}
$output.='</tbody></table>';
echo $output;
$jsOutput .= '
var oTable = $("#allSessions").dataTable({
"sDom": "T<\'clear\'>lrtip",
"bPaginate": false,
"oTableTools": {
"sSwfPath":"swf/copy_csv_xls_pdf.swf",
"aButtons":[
{
"sExtends": "csv",
"sButtonText": "Excel/CSV",
"mColumns": [0, 1, 2, 3, 4, 5, 6]
}, {
"sExtends": "pdf",
"sButtonText": "PDF",
"mColumns": [ 1, 2, 3, 4, 5, 6]
}, {
"sExtends": "print",
"sButtonText": "Print",
"mColumns": [0, 1, 2, 3, 4, 5, 6]
}, {
"sExtends": "copy",
"sButtonText": "Copy",
"mColumns": [0, 1, 2, 3, 4, 5, 6]
}
]
}
}).rowGrouping({
bExpandableGrouping: true /*,
asExpandedGroups: [] */
});';
include('includes/footer.php');
?>