-
Notifications
You must be signed in to change notification settings - Fork 293
/
rollGroups.php
executable file
·132 lines (121 loc) · 6 KB
/
rollGroups.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
<?php
/*
Gibbon, Flexible & Open School System
Copyright (C) 2010, Ross Parker
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@session_start();
if (isActionAccessible($guid, $connection2, '/modules/Roll Groups/rollGroups.php') == false) {
//Acess denied
echo "<div class='error'>";
echo __($guid, 'You do not have access to this action.');
echo '</div>';
} else {
//Proceed!
echo "<div class='trail'>";
echo "<div class='trailHead'><a href='".$_SESSION[$guid]['absoluteURL']."'>".__($guid, 'Home')."</a> > <a href='".$_SESSION[$guid]['absoluteURL'].'/index.php?q=/modules/'.getModuleName($_GET['q']).'/'.getModuleEntry($_GET['q'], $connection2, $guid)."'>".__($guid, getModuleName($_GET['q']))."</a> > </div><div class='trailEnd'>".__($guid, 'View Roll Groups').'</div>';
echo '</div>';
echo '<p>';
echo __($guid, 'This page shows all roll groups in the current school year.');
echo '</p>';
try {
$data = array('gibbonSchoolYearID' => $_SESSION[$guid]['gibbonSchoolYearID']);
$sql = 'SELECT gibbonSchoolYear.gibbonSchoolYearID, gibbonRollGroupID, gibbonSchoolYear.name as yearName, gibbonRollGroup.name, gibbonRollGroup.nameShort, gibbonPersonIDTutor, gibbonPersonIDTutor2, gibbonPersonIDTutor3, gibbonSpace.name AS space, website FROM gibbonRollGroup JOIN gibbonSchoolYear ON (gibbonRollGroup.gibbonSchoolYearID=gibbonSchoolYear.gibbonSchoolYearID) LEFT JOIN gibbonSpace ON (gibbonRollGroup.gibbonSpaceID=gibbonSpace.gibbonSpaceID) WHERE gibbonSchoolYear.gibbonSchoolYearID=:gibbonSchoolYearID ORDER BY sequenceNumber, gibbonRollGroup.name';
$result = $connection2->prepare($sql);
$result->execute($data);
} catch (PDOException $e) {
echo "<div class='error'>".$e->getMessage().'</div>';
}
if ($result->rowCount() < 1) {
echo "<div class='error'>";
echo __($guid, 'There are no records to display.');
echo '</div>';
} else {
echo "<table cellspacing='0' style='width: 100%'>";
echo "<tr class='head'>";
echo '<th>';
echo __($guid, 'Name');
echo '</th>';
echo '<th>';
echo __($guid, 'Form Tutors');
echo '</th>';
echo '<th>';
echo __($guid, 'Room');
echo '</th>';
echo '<th>';
echo __($guid, 'Students');
echo '</th>';
echo '<th>';
echo __($guid, 'Website');
echo '</th>';
echo '<th>';
echo __($guid, 'Actions');
echo '</th>';
echo '</tr>';
$count = 0;
$rowNum = 'odd';
while ($row = $result->fetch()) {
if ($count % 2 == 0) {
$rowNum = 'even';
} else {
$rowNum = 'odd';
}
//COLOR ROW BY STATUS!
echo "<tr class=$rowNum>";
echo '<td>';
echo $row['name'];
echo '</td>';
echo '<td>';
try {
$dataTutor = array('gibbonPersonID1' => $row['gibbonPersonIDTutor'], 'gibbonPersonID2' => $row['gibbonPersonIDTutor2'], 'gibbonPersonID3' => $row['gibbonPersonIDTutor3']);
$sqlTutor = 'SELECT gibbonPersonID, surname, preferredName FROM gibbonPerson WHERE gibbonPersonID=:gibbonPersonID1 OR gibbonPersonID=:gibbonPersonID2 OR gibbonPersonID=:gibbonPersonID3';
$resultTutor = $connection2->prepare($sqlTutor);
$resultTutor->execute($dataTutor);
} catch (PDOException $e) {
echo "<div class='error'>".$e->getMessage().'</div>';
}
while ($rowTutor = $resultTutor->fetch()) {
echo formatName('', $rowTutor['preferredName'], $rowTutor['surname'], 'Staff', false, true);
if ($rowTutor['gibbonPersonID'] == $row['gibbonPersonIDTutor'] and $resultTutor->rowCount() > 1) {
echo ' ('.__($guid, 'Main Tutor').')';
}
echo '<br/>';
}
echo '</td>';
echo '<td>';
echo $row['space'];
echo '</td>';
echo '<td>';
try {
$dataCount = array('gibbonRollGroupID' => $row['gibbonRollGroupID']);
$sqlCount = "SELECT gibbonPerson.gibbonPersonID FROM gibbonStudentEnrolment INNER JOIN gibbonPerson ON gibbonStudentEnrolment.gibbonPersonID=gibbonPerson.gibbonPersonID WHERE gibbonRollGroupID=:gibbonRollGroupID AND status='Full' AND (dateStart IS NULL OR dateStart<='".date('Y-m-d')."') AND (dateEnd IS NULL OR dateEnd>='".date('Y-m-d')."') ORDER BY preferredName, surname";
$resultCount = $connection2->prepare($sqlCount);
$resultCount->execute($dataCount);
} catch (PDOException $e) {
echo "<div class='error'>".$e->getMessage().'</div>';
}
echo $resultCount->rowCount();
echo '</td>';
echo '<td>';
if ($row['website'] != '') {
echo "<a target='_blank' href='".$row['website']."'>".$row['website'].'</a>';
}
echo '</td>';
echo '<td>';
echo "<a href='".$_SESSION[$guid]['absoluteURL'].'/index.php?q=/modules/'.$_SESSION[$guid]['module'].'/rollGroups_details.php&gibbonRollGroupID='.$row['gibbonRollGroupID']."'><img title='".__($guid, 'View')."' src='./themes/".$_SESSION[$guid]['gibbonThemeName']."/img/plus.png'/></a> ";
echo '</td>';
echo '</tr>';
++$count;
}
echo '</table>';
}
}