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
|
<!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'; ?> <?php $waiting_id = $_GET['id']; ?> <script> $(function() { $('.date-picker').datetimepicker({pickTime: false}); $('.stun').select2(); }); </script> </head> <style> .div-background { border: 1px solid #E6E6E6; border-radius: 6px 6px 6px 6px; background-color: #feffde; padding-top: 10px; padding-bottom: 10px; } </style> <body> <?php $studentid = ""; $countstudent = 0; $createdate = date('Y-m-d'); $state = array('Application Form', 'Assessment', 'Schedule'); if (isset($_POST['deleted'])) { $delwid = $waiting_id; $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>"); } }
if (isset($_POST['addstu'])) { $maxwid; $stuid; $subid; $proid; $next; $ishead; $inserted = false; $get_state = array(0, 0, 0); $countsta = 0; $remark = $_POST['remark']; foreach ($_POST['state'] as $value) { $get_state[$countsta] = $value; $countsta++; } $searchdata = "select stu_linking_id, program_id, subject_id, priority, is_head from waiting_list where deleted = 0 and waiting_id = '$waiting_id' group by waiting_id"; $result = $dbh->query($searchdata); $result->setFetchMode(PDO::FETCH_OBJ); while ($row = $result->fetch()) { $stuid = $row->stu_linking_id; $proid = $row->program_id; $subid = $row->subject_id; $next = $row->priority; $ishead = $row->is_head; }
$sth = $dbh->prepare("INSERT INTO `waiting_list`(`createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `stu_linking_id`, `program_id`, `subject_id`, `priority`, `is_head`, `app_form`, `assessment`, `schedule`, `remark`) VALUES (1, now(), 1 ,now(),1,0,?,?,?,?,?,?,?,?,?)"); $sth->bindParam(1, $stuid); $sth->bindParam(2, $proid); $sth->bindParam(3, $subid); $sth->bindParam(4, $next); $sth->bindParam(5, $ishead); $sth->bindParam(6, $get_state[0]); $sth->bindParam(7, $get_state[1]); $sth->bindParam(8, $get_state[2]); $sth->bindParam(9, $remark); $sth->execute();
$sth = $dbh->prepare("UPDATE `waiting_list` SET `lastupby`=1,`lastupdate`=now(),`deleted` = 1 WHERE waiting_id = '$waiting_id'"); $sth->execute();
$max = "select max(waiting_id) as maxid from waiting_list"; $sqlmax = $dbh->query($max); $sqlmax->setFetchMode(PDO::FETCH_OBJ); while ($row = $sqlmax->fetch()) { $maxwid = $row->maxid; } $sth = $dbh->prepare("UPDATE `waiting_list` SET `lastupby`=1,`lastupdate`=now(),`priority` = '$maxwid' WHERE priority = '$waiting_id' and deleted = 0"); $sth->execute();
$inserted = true;
if ($inserted) { echo "<script>alert('update successful.')</script>"; echo("<script>location.href ='index.php';</script>"); } if ($inserted == false) echo "<script>alert('Error!!! Delete fail')</script>"; } ?> <!-- line between nav bar and content --> <div class="text-right"> <ul class="breadcrumb"> <li class="active">Edit WaitingList</li> </ul> </div> <!-- line between nav bar and content --> <div class="container-fluid div-background"> <form id="search_form" class="form-inline" action="" method="POST"> <table border="0" style="background:#feffde;"> <?php $searchdata = "select waiting_id, stu_linking_id, program_id, subject_id, app_form, assessment, schedule, remark from waiting_list where deleted = 0 and waiting_id = '$waiting_id' group by waiting_id"; $result = $dbh->query($searchdata); $result->setFetchMode(PDO::FETCH_OBJ); while ($row1 = $result->fetch()) { ?> <tr><td><h3>Edit Waiting List</h3></td></tr> <tr style="height: 15px"></tr> <tr> <td width="20%"><label>Student</label></td> <td><?php $sth = $dbh->query("SELECT CONCAT(last_name, ' ', first_name) studentname,`ch_name` ch_name FROM `student` WHERE `root_id`='$row1->stu_linking_id' and `deleted`=0 "); ?> <?php while ($ResultSet = $sth->fetch(PDO::FETCH_ASSOC)) { ?> <input type="text" readonly value="<?= $ResultSet['studentname'] ?> | <?= $ResultSet['ch_name'] ?>"> <?php } ?> </td> </tr> <tr style="height: 15px"></tr> <tr> <td width="20%"><label class="" id="program" name="program">Program</label></td> <td><?php $query = "select program_code from program where program_id ='$row1->program_id' "; $result = $dbh->query($query); $result->setFetchMode(PDO::FETCH_OBJ); while ($row = $result->fetch()) { ?> <input type="text" readonly value="<?= $row->program_code ?>"> <?php } ?> </td> </tr> <tr style="height: 15px"></tr> <tr> <td width="20%"><label class="" id="program" name="subject" value="subject" >Subject</label></td> <td> <?php $query = "select sub_code from subject where subject_id = '$row1->subject_id'"; $result = $dbh->query($query); $result->setFetchMode(PDO::FETCH_OBJ); while ($row = $result->fetch()) { ?> <input type="text" readonly value ="<?= $row->sub_code ?>"> <?php } ?> </td>
</tr> <tr style="height: 15px"></tr> <tr> <td width="20%"><label>State</label></td> <td> <input type="checkbox" name ="state[]" <?php if ($row1->app_form == 1) { ?> checked <?php } ?> value="1"><?= $state[0] ?> <input type="checkbox" name ="state[]" <?php if ($row1->assessment == 1) { ?> checked <?php } ?> value="1"><?= $state[1] ?> <input type="checkbox" name ="state[]" <?php if ($row1->schedule == 1) { ?> checked <?php } ?> value="1"><?= $state[2] ?></td> </tr> <tr style="height: 15px"></tr> <tr> <td width="20%"><label>Remark</label></td> <td><textarea rows="4" cols="20" name="remark"><?= $row1->remark ?></textarea></td> </tr> <!--tr> <td><label width="20%">Priority</label></td> <td><input type="text" name="priority" id="priority" onkeydown="return (event.ctrlKey || event.altKey || (47 < event.keyCode && event.keyCode < 58 && event.shiftKey == false) || (95 < event.keyCode && event.keyCode < 106) || (event.keyCode == 8) || (event.keyCode == 9) || (event.keyCode > 34 && event.keyCode < 40) || (event.keyCode == 46))"></td> </tr--> </table> <?php } ?> <div class="pathways-inline-block"> <a href="index.php" class="btn" style="margin-left:20px">Back</a> </div> <div class="pathways-inline-block"> <button class="btn" name="deleted" value="deleted" style="margin-left:40px" type="submit">Delete</button> </div> <div class="input-append date-picker"> <button class="btn" name="addstu" value="addstu" style="margin-left:20px" type="submit">Save</button> </div> </form> </div> <!-- /container --> </body> </html>
|