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
|
<!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> .table{ background:#feffde; } </style> <body> <?php $studentid = ""; $countstudent = 0; $createdate = date('Y-m-d'); $state = array('Application Form', 'Assessment', 'Schedule');
if (isset($_POST['addstu'])) { $maxwid; $stuid; $subid; $proid; $next; $ishead; $inserted = false; $newstate = $_POST['state']; $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`, `state_id`) 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, $newstate); $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 pathways-container"> <form id="search_form" class="form-inline" action="" method="POST"> <table border="0" class="table table-bordered table-hover table-condensed"> <?php $searchdata = "select waiting_id, stu_linking_id, program_id, subject_id,state_id 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> <td width="20%"><label>Student</label></td> <td><?php $sth = $dbh->query("SELECT CONCAT(last_name, ' ', first_name) studentname,`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'] ?>"> <?php } ?> </td> </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> <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> <td width="20%"><label>State</label></td> <td><select name="state" class="state" style="width:150px"> <?php for ($a = 0; $a < count($state); $a++) { ?> <option <?php if ($row1->state_id == $a) { ?> selected <?php } ?> value="<?= $a ?>"><?= $state[$a] ?></option> <?php } ?> </select></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="input-append date-picker"> <button class="btn" name="addstu" value="addstu" style="margin-left:30px" type="submit">Edit</button> </div> </form> </div> <!-- /container --> </body> </html>
|