-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgradlist_bb_edit.php
169 lines (152 loc) · 5.81 KB
/
gradlist_bb_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
169
<?php
//Include util functions
require_once('includes/util.php');
//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);
$glid = $_REQUEST['glid'] ?? '';
$gsid = $_REQUEST['gsid'] ?? '';
$step = $_REQUEST['step'] ?? '';
$rankUpdateStatus = '';
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
if(isset($_POST['updateListButton'])){
$idList = explode(',',$userIDs);
for($ii = 0;$ii < count($idList);$ii++){
eval('$newRank = $newRank_' . $idList[$ii]. ';');
$gradListDAO->updateBBGradRank($gradListID,$idList[$ii],$newRank);
}
$glid = $_POST['gradListID'];
$rankUpdateStatus = "Student's new ranks have been updated.";
$step = 2;
}elseif(isset($_POST['mergeButton'])){
$updateResultText = '';
$gradStudentRS = $gradListDAO->getBBGradStudents($_POST['gradListID']);
$setReadOnly = true;
while($setReadOnly && $row = mysqli_fetch_array($gradStudentRS, MYSQLI_ASSOC)){
//Unable to Run updateStudentRankByGraduation(...) because of mySQL version...
//we may be able to use this the mySQL version is updated...
//
//$updateResult = $studentDAO->updateStudentRankByGraduation($gradListID, $row['id']);
$updateResult = $studentDAO->updateStudentRank($row['id'], $row['new_rank_id']);
if($updateResult){
$updateResultText .= $row['first_name'] . ' ' . $row['last_name'] . ' has been updated<br>';
}else{
$updateResultText .= $row['first_name'] . ' ' . $row['last_name'] . ' could NOT be updated<br>';
$setReadOnly = false;
}
}
if ($setReadOnly){
$gradListDAO->markBBListReadOnly($_POST['gradListID']);
}
}
}
if($gsid > 0){
$gradListDAO->removeBBGrad($gsid);
$step = 2;
}
if($glid > 0){
$studentListRS = $gradListDAO->getBBGradStudents($glid);
$rankListRS = $studentDAO->getBBCandidateRankList();
if($rankListRS != false){
$ii = 0;
while ($row = mysqli_fetch_assoc($rankListRS)) {
$rankSeq[$ii] = intval($row['sequence']);
$rankListName[$ii] = $row['rank_name'];
$rankListID[$ii++] = $row['id'];
}
}
}else{
//Returning a list of graduation lists
$gradListRS = $gradListDAO->getAllBBGradLists();
}
//Setting the text per step...
if($step == 4){
$stepText = 'Step 4: Black Belt Gradation Merge Complete';
}elseif($step == 3){
$stepText = 'Step 3: Merge the Graduation List with the Main Database';
}elseif($step == 2){
if($gradListDAO->isBBGradListReadOnly($glid)){
$stepText = 'Step 2: Review Download the Graduation List';
}else{
$stepText = 'Step 2: Confirm/Review the Graduation List';
}
}else{
$stepText = 'Step 1: Choose a Graduation List';
}
if ($step == 3){
$nextStep = $step + 1;
echo '<form name="gradListEdit" action="index.php?action=' . $action . '&step=' . $nextStep . '" method="POST">';
}
?>
<table align="left" bgcolor="White" width="100%">
<tr>
<th class="title" colspan="2">Merge Your Graduation List</th>
</tr>
<tr><td> </td></tr>
<tr><td align="left" colspan="2"> <u><b><?= $stepText ?><b></u></td></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($step == 2 && $glid > 0){
?>
<tr><td colspan="2">
<?php
include('gradlist_bb_table.php');
?>
</td></tr>
<?php
}elseif($step == 3){
?>
<tr>
<td align="center" colspan="2">
<input name="gradListID" type="hidden" value="<?= $_POST['gradListID'] ?>">
<input name="mergeButton" type="submit" value="Click Here To Run Rank Update!">
</td>
</tr>
<tr><td> </td></tr>
<?php
}elseif($step == 4){
?>
<tr><td colspan="2" align="center"><?= $updateResultText ?></td></tr>
<tr><td colspan="2"> </td></tr>
<tr><td colspan="2" align="center"><a href="index.php?action=gl.bbedit&glid=<?= $_POST['gradListID'] ?>&step=2">Click Here To Continue</a></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_assoc($gradListRS)){
$gradDate = date("F",strtotime($glRow['grad_date'])) . ' ' . date("j",strtotime($glRow['grad_date'])) . ', ' . date("Y",strtotime($glRow['grad_date']));
?>
<li><a href="index.php?action=gl.bbedit&step=2&glid=<?= $glRow['id'] ?>"><?= $gradDate ?></a></li>
<?php
}
?>
</ul>
<?php
}else{
echo '<span class="error">No graduation lists are available to be merged.</span>';
}
?>
</td>
</tr>
<?php
}
?>
</table>
<?php
if ($step == 3){echo '</form>';}
?>