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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
|
<!DOCTYPE html> <html> <head> <?php require_once '../include/head.php'; ?> <?php require_once '../include/checkuser.php'; ?> <?php require_once '../include/Nav_bar.php'; ?> <?php include_once '../include/DBConnect.php'; ?> <script> $(function() { $('.date-picker').datetimepicker({pickTime: false}); $('#search_form').validate(); $('.time').timepicker({'step': 15, 'timeFormat': 'H:i', 'minTime': '06:00', 'maxTime': '23:30'}); $('.staff_name').select2(); $('.stun').select2(); var DeleteID = 0; $('#select_all_btn').click(function() { var $selectAllCheckbox = $('.select-all-checkbox'); $selectAllCheckbox.prop('checked', !$selectAllCheckbox.prop('checked')); }); }); function check_all(obj, cName) { var checkboxs = document.getElementsByName(cName); for (var i = 0; i < checkboxs.length; i++) { checkboxs[i].checked = obj.checked; } } ; </script> </head> <body> <?php $state = array('Application Form', 'Assessment', 'Schedule'); $a; if (isset($_POST['waiting_select'])) { $delwid = $_POST['waiting_select']; $nextid; $delhead; $cid; $delfromhead = false; $delfromN = false; $deleted = false; $delcheckquery = "select is_head, priority from waiting_list where waiting_id = '$delwid'"; $sqldelcheckquery = $dbh->query($delcheckquery); $sqldelcheckquery->setFetchMode(PDO::FETCH_OBJ); while ($row = $sqldelcheckquery->fetch()) { $nextid = $row->priority; $delhead = $row->is_head; } if ($delhead == 1) { $delfromhead = true; $delfromN = false; } else { $delfromhead = false; $delfromN = true; } if ($delfromhead) { if ($nextid != null) { $sth = $dbh->prepare("UPDATE `waiting_list` SET `lastupby`=1,`lastupdate`=now(),`is_head` = 1 WHERE waiting_id = '$nextid'"); $sth->execute(); } $sth = $dbh->prepare("UPDATE `waiting_list` SET `lastupby`=1,`lastupdate`=now(),`deleted` = 1 WHERE waiting_id = '$delwid'"); $sth->execute(); $deleted = true; } if ($delfromN) { $delquery = "select waiting_id from waiting_list where priority ='$delwid'"; $sqldelquery = $dbh->query($delquery); $sqldelquery->setFetchMode(PDO::FETCH_OBJ); while ($row1 = $sqldelquery->fetch()) { $cid = $row1->waiting_id; } $sth = $dbh->prepare("UPDATE `waiting_list` SET `lastupby`=1,`lastupdate`=now(),`priority` = '$nextid' WHERE waiting_id = '$cid'"); $sth->execute(); $sth = $dbh->prepare("UPDATE `waiting_list` SET `lastupby`=1,`lastupdate`=now(),`deleted` = 1 WHERE waiting_id = '$delwid'"); $sth->execute(); $deleted = true; } if ($deleted) { echo "<script>alert('deleted data successful.')</script>"; echo("<script>location.href ='index.php';</script>"); } } ?> <!-- line between nav bar and content --> <div class="text-right"> <ul class="breadcrumb"> <li class="active">Waiting List</li> </ul> </div> <!-- line between nav bar and content --> <div class="container-fluid pathways-container"> <div> <table border="0" width="100%"> <tr> <td><h2>WaitingList</h2></td> <td><a href="add.php" class="btn pull-right"><i class="icon-plus"></i> Add</a></td> </tr> </table> </div> <div class="pathways-search"> <form id="search_form" class="form-inline" action="" method="POST"> <div class="pathways-inline-block"> <label class="" id="program" name="program">Program</label> <select id="program" name="program" class="input-medium" value="program" > <option value="ALL">ALL</option> <?php $query = "select program_code from program "; $result = $dbh->query($query); $result->setFetchMode(PDO::FETCH_OBJ); while ($row = $result->fetch()) { ?> <option <?php if (isset($_POST['go'])) if ($_POST['program'] == $row->program_code) { ?> selected <?php } ?> value ="<?= $row->program_code ?>"><?= $row->program_code ?></option> <?php } ?> </select> </div> <div class="pathways-inline-block"> <label class="" id="program" name="subject" value="subject" >Subject</label> <select id="subject" name="subject" class="input-medium" > <option value="ALL">ALL</option> <?php $query = "select sub_code from subject "; $result = $dbh->query($query); $result->setFetchMode(PDO::FETCH_OBJ); while ($row = $result->fetch()) { ?> <option <?php if (isset($_POST['go'])) if ($_POST['subject'] == $row->sub_code) { ?> selected <?php } ?> value ="<?= $row->sub_code ?>"><?= $row->sub_code ?></option> <?php } ?> </select>
</div> <div class="pathways-inline-block"> <label>Student</label> <select name="stun" id="stun" class="stun" style="width:150px"> <option value="ALL">All</option> <?php $sth = $dbh->query("SELECT linking_id,`New_stu_ID` id,CONCAT(last_name, ' ', first_name) studentname,`ch_name`FROM `student` WHERE `actived`=1 and`deleted`=0 group by `New_stu_ID`,`Sem_yr`"); ?> <?php while ($ResultSet = $sth->fetch(PDO::FETCH_ASSOC)) { ?> <option value="<?= $ResultSet['studentname'] ?>"><?= $ResultSet['studentname'] ?></option> <?php } ?> </select> </div> <div class="pathways-inline-block"> <label>State</label> <select name="state" class="state" style="width:150px"> <option value="-1">ALL</option> <?php for ($a = 0; $a < count($state); $a++) { ?> <option <?php if(isset($_POST['go'])) { if(isset($_POST['state']) && $a==$_POST['state']) { ?> selected <?php }} ?>value="<?= $a ?>"><?= $state[$a] ?></option> <?php } ?> </select> </div> <!--div class="pathways-inline-block"> <label>Priority</label> <input type="number" name="priority" id="priority" value="1" required=""> </div--> <div class="pathways-inline-block"> <button class="btn" name="go" value="go" style="margin-left:30px" type="submit">Search</button> </div> </form> </div> <?php if (isset($_POST['go'])) { $countp; $loop; $searchstudent = NULL; $program = NULL; $subject = NULL; //if ($_POST['stun'] != "ALL") //$searchstudent = " CONCAT(s.last_name, ' ', s.first_name) = '" . $_POST['stun'] . "' and "; if ($_POST['program'] != 'ALL') $program = "p.program_code ='" . $_POST['program'] . "' and "; if ($_POST['subject'] != 'ALL') $subject = "sub.sub_code ='" . $_POST['subject'] . "' and "; ?> <div class="pathways-search"> <form id="form" action="" method="POST"> <!--div class="btn-group"> <input type="button" id="select_all_btn" class="btn btn-small" value="Select All"> <input type="submit" name="delete" class='btn btn-small' value="Delete"> </div--> <table class="table table-striped table-bordered table-hover table-condensed" id="tablehead"> <thead> <tr> <th style= "min-width:20px;width:5%" > </th> <th style= "width:5%" >Edit</th> <th style= "width:17%">create date</th> <th style= "width:10%">Year/Grade</th> <th >Student name</th> <th style= "width:10%">program</th> <th style= "width:10%">subject</th> <!--th style="min-width:50px; width:100px">priority</th--> <th style= "width:8%">State</th> <!--th style="">Assessment Result</th--> </tr> </thead> <tbody> <?php $query = "select g.grade as grade, s.linking_id as linking_id, s.root_id as rootid, s.last_name as stuln, s.first_name as stufn,w.waiting_id as waiting_id,w.state_id as state_id, w.createdate as cd, w.program_id as pro_id, w.subject_id as sub_id, w.priority as priority_id, p.program_code as pc, sub.sub_code as sc from student_grade sg, grade g, student s, waiting_list w, program p, subject sub where w.is_head = 1 and " . $program . $subject . " w.deleted = 0 and p.deleted = 0 and s.deleted = 0 and sub.deleted = 0 and sg.deleted = 0 and g.deleted = 0 and w.stu_linking_id = s.root_id and w.program_id = p.program_id and w.subject_id = sub.subject_id and sg.student_grade_id = s.linking_id and g.grade_id = sg.grade_id group by w.waiting_id"; $resstu = $dbh->query($query); $resstu->setFetchMode(PDO::FETCH_OBJ); while ($rowstu = $resstu->fetch()) { //$countpriority = 1; $nextpriority = $rowstu->priority_id; $stuname = $rowstu->stuln . " " . $rowstu->stufn; ?> <input type="hidden" name="pro_select[]" class="select-all-checkbox" value="<?= $rowstu->pro_id ?>"> <input type="hidden" name="sub_select[]" class="select-all-checkbox" value="<?= $rowstu->sub_id ?>"> <input type="hidden" name="stu_select[]" class="select-all-checkbox" value="<?= $rowstu->rootid ?>"> <?php if (($_POST['stun'] == "ALL" || $_POST['stun'] == $stuname) && ($_POST['state'] == "-1" || $_POST['state'] == $rowstu->state_id)) { ?> <tr> <td> <button class="btn" name="waiting_select" value="<?= $rowstu->waiting_id ?>" type="submit"><i class="icon-remove"></i></button> </td> <td> <a href="edit.php?id=<?= $rowstu->waiting_id ?>" class="btn">Edit</a> </td> <td> <h5><?php echo $rowstu->cd; ?></h5> </td> <td> <h5><?php echo $rowstu->grade; ?></h5> </td> <td> <a href="../student/student_edit.php?linking_id=<?= $rowstu->linking_id ?>&action=View"><h5><?php echo $stuname; ?></h5></a> </td> <td> <h5><?php echo $rowstu->pc; ?></h5> </td> <td> <h5><?php echo $rowstu->sc; ?></h5> </td> <!--td> <h5><?php // echo $countpriority; ?></h5> </td--> <td> <h5><?php echo $state[$rowstu->state_id]; ?></h5> </td> <!--td> <h5><?php //echo 'No Assessment Result'; ?></h5> </td--> </tr> <?php } while ($nextpriority != null) { $query1 = "select g.grade as grade, s.root_id as rootid, s.linking_id as linking_id, s.last_name as stuln, s.first_name as stufn,w.waiting_id as waiting_id,w.state_id as state_id, w.createdate as cd, w.program_id as pro_id, w.subject_id as sub_id, w.priority as priority_id, p.program_code as pc, sub.sub_code as sc from student_grade sg, grade g, student s, waiting_list w, program p, subject sub where w.waiting_id = '$nextpriority' and " . $program . $subject . " w.deleted = 0 and p.deleted = 0 and s.deleted = 0 and sub.deleted = 0 and sg.deleted = 0 and g.deleted = 0 and w.stu_linking_id = s.root_id and w.program_id = p.program_id and w.subject_id = sub.subject_id and sg.student_grade_id = s.linking_id and g.grade_id = sg.grade_id group by w.waiting_id"; $resstu1 = $dbh->query($query1); $resstu1->setFetchMode(PDO::FETCH_OBJ); while ($rowstu1 = $resstu1->fetch()) { //$countpriority++; $nextpriority = $rowstu1->priority_id; $stuname = $rowstu1->stuln . " " . $rowstu1->stufn; ?> <input type="hidden" name="pro_select[]" class="select-all-checkbox" value="<?= $rowstu1->pro_id ?>"> <input type="hidden" name="sub_select[]" class="select-all-checkbox" value="<?= $rowstu1->sub_id ?>"> <input type="hidden" name="stu_select[]" class="select-all-checkbox" value="<?= $rowstu1->rootid ?>"> <?php if (($_POST['stun'] == "ALL" || $_POST['stun'] == $stuname)&&($_POST['state'] == "-1" || $_POST['state'] == $rowstu1->state_id)) { ?> <tr> <td> <button class="btn" name="waiting_select" value="<?= $rowstu1->waiting_id ?>" type="submit"><i class="icon-remove"></i></button> </td> <td> <a href="edit.php?id=<?= $rowstu1->waiting_id ?>" class="btn">Edit</a> </td> <td> <h5><?php echo $rowstu1->cd; ?></h5> </td> <td> <h5><?php echo $rowstu1->grade; ?></h5> </td> <td> <a href="../student/student_edit.php?linking_id=<?= $rowstu1->linking_id ?>&action=View"><h5><?php echo $stuname; ?></h5></a> </td> <td> <h5><?php echo $rowstu1->pc; ?></h5> </td> <td> <h5><?php echo $rowstu1->sc; ?></h5> </td> <!--td> <h5><?php //echo $countpriority; ?></h5> </td--> <td> <h5><?php echo $state[$rowstu1->state_id]; ?></h5> </td> <td> <h5><?php echo 'No Assessment Result'; ?></h5> </td> </tr> <?php } } } } ?> </tbody> </table> </form> <?php } ?> </div> <!-- date picker --> </div> <!-- /container --> </body> </html>
|