-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgradlist_edit.php
168 lines (146 loc) · 5.25 KB
/
gradlist_edit.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
<?php
//If there is no step set...
if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['addMoreStudentsButton'])){
$editMode = true;
$step = 3;
include('gradlist_add.php');
?>
</td></tr>
</table>
</td>
</tr>
</table>
<?php
include('includes/footer.php');
die();
}
//Including DAO Classes
require_once($classpath . 'GradListDAO.php');
require_once($classpath . 'StudentDAO.php');
$userDAO = new UserDAO($DB_server, $DB_user, $DB_pass, $DB_conn);
$isAdmin = $userDAO->isSuperAdmin($_COOKIE["uid"]);
$gradListDAO = new GradListDAO($DB_server, $DB_user, $DB_pass, $DB_conn);
$studentDAO = new StudentDAO($DB_server, $DB_user, $DB_pass, $DB_conn, $_COOKIE["uid"], $isAdmin);
//SETTING POST VARS
if (isset($_POST['userIDs'])) {
$userIDs = $_POST['userIDs'];
}
$gradListID = $_POST['gradListID'] ?? 0;
$rankUpdateStatus = '';
//SETTTING REQUEST VARS
$gsid = $_REQUEST['gsid'] ?? 0;
if (isset($_POST['gradListID'])) {
$glid = $gradListID;
} else {
$glid = $_REQUEST['glid'] ?? 0;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['updateListButton'])) {
$idList = explode(',', $userIDs);
for($ii = 0; $ii < count($idList); $ii++){
$newRank = $_POST['newRank_'. $idList[$ii]];
$gradListDAO->updateGradRank($gradListID, $idList[$ii], $newRank);
}
$glid = $gradListID;
$rankUpdateStatus = "Student's new ranks have been updated.";
}
$act2 = $_REQUEST['act2'] ?? '';
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['removeStudentsButton'])) {
//remove student(s) from a gradlist
foreach ($_POST['gsid'] as $value) {
$gradListDAO->removeGrad($value);
}
} elseif ($gsid > 0 && $act2 == 'ud') {
//Undo a student's graduation
$undoErrMsg = $gradListDAO->undoGrad($gsid, $scid ?? 0, $FULL_GRAD_FEE);
}
if($glid > 0){
if($action == 'gl.rem'){
$gradListDAO->removeGradList($glid);
$glid = -1;
//Returning a list of graduation lists this user has access to
$gradListRS = $gradListDAO->getGradLists($_COOKIE["uid"]);
}
$studentListRS = $gradListDAO->getGradStudents($glid);
$rankListRS = $studentDAO->getRankListByUser($_COOKIE["uid"]);
if($rankListRS != false){
$showRank = true;
$ii = 0;
while($row = mysqli_fetch_array($rankListRS, MYSQLI_ASSOC)){
if($showRank){
$rankListName[$ii] = $row['rank_name'];
$rankListID[$ii++] = $row['id'];
}
//We need to filter out anything above 2nd brown
if($row['rank_name'] == '1st Brown'){
$showRank = false;
}
}
}
}else{
//Returning a list of graduation lists this user has access to
$gradListRS = $gradListDAO->getGradLists($_COOKIE["uid"]);
}
?>
<table align="left" bgcolor="White" width="100%">
<tr>
<th class="title" colspan="2">Edit Your Graduation List</th>
</tr>
<tr><td> </td></tr>
<?php
if(strlen($rankUpdateStatus) > 0){
echo ' <tr><td colspan="2" align="center" class="success">' . $rankUpdateStatus . '</td></tr><tr><td> </td></tr>';
}
if($gradListID > 0 || $glid > 0){
if(isset($undoErrMsg) && strlen($undoErrMsg)>0){
?>
<tr><td colspan="2" align="center"><span class="error"><?= $undoErrMsg ?></span></td></tr>
<?php
}
?>
<tr><td colspan="2">
<?php
include('gradlist_table.php');
?>
</td></tr>
<?php
} else {
?>
<tr>
<td width="5%"> </td>
<td align="left">
<?php
if(mysqli_num_rows($gradListRS) > 0){
$currentSchool = '';
$firstSchool = true;
?>
<?php
while($glRow = mysqli_fetch_array($gradListRS, MYSQLI_ASSOC)){
if($currentSchool != $glRow['school_id']){
$currentSchool = $glRow['school_id'];
if(!$firstSchool){echo ' </ul>';}
else{$firstSchool = false;}
?>
<u><b><?= $glRow['school_name'] ?></b></u>
<ul>
<?php
}
$gradDate = date("F",strtotime($glRow['grad_date'])) . ' ' . date("j",strtotime($glRow['grad_date'])) . ', ' . date("Y",strtotime($glRow['grad_date']));
$removeButton = '';
if($glRow['read_only'] == 0 && $gradListDAO->isGradListPaid($glRow['id']) == 0 ){
$removeButton = ' <a href="index.php?action=gl.rem&glid=' . $glRow['id'] . '" onclick="return confirm(\'Are you sure you want to remove the graduation list for [' . $gradDate . ']?\');"><img src="' . $imgRoot . 'button_delete.png" border="0" alt="Remove List"></a>';
}
?>
<li><a href="index.php?action=gl.edit&scid=<?= $glRow['school_id'] ?>&glid=<?= $glRow['id'] ?>"><?= $gradDate ?></a><?= $removeButton ?></li>
<?php
}
?>
</ul>
<?php
}
?>
</td>
</tr>
<?php
}
?>
</table>