/var/www/(Del)pathways.org.hk/MIS20140127/old20140414/student/stu_import.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
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
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <?php
        
require_once '../include/head.php';
        require_once 
'../include/checkuser.php';
        require_once 
'../include/Nav_bar.php';
        include_once 
'../include/DBConnect.php';
        
?>
        <script>
            $(function() {
                var DeleteID = 0;
                $('#select_all_btn').click(function() {
                    var $selectAllCheckbox = $('.select-all-checkbox');
                    $selectAllCheckbox.prop('checked', !$selectAllCheckbox.prop('checked'));
                });
                $('#stu_name').select2();
            });
            function check_all(obj, cName) {
                var checkboxs = document.getElementsByName(cName);
                for (var i = 0; i < checkboxs.length; i++) {
                    checkboxs[i].checked = obj.checked;
                }
            };
        </script>
        <?php if(isset($_POST['submit'])) { ?>
            <script>
                $(function(){
                    $('#stu_name').select2().select2('val','<?=$_POST['stu_name']?>');
                });
            </script>
        <?php ?>
    </head>
    <body>
        <!-- line between nav bar and content -->
        <div class="text-right">
            <ul class="breadcrumb">
                <li><a href="student.php">Student Record</a></li>
                <li><a href="#"></a> <span class="divider">&gt;</span></li>
                <li><a href="Add_stu.php">Add Student Record</a></li>
                <li><a href="#"></a> <span class="divider">&gt;</span></li>
                <li class="active">Import Student Record</li>
            </ul>
        </div>
        <!-- line between nav bar and content -->

        <div class="container-fluid pathways-container">
            <div>
                <table border="0" width="100%">
                    <tr>
                        <td><h2>Search a Student</h2></td>
                    </tr>
                </table>
            </div>
            <div class="pathways-search">
                <form action="" method="POST" class="form-inline">
                    <table border="0" width="100%">
                        <tr>
                            <?php
                            
if (isset($_POST['submit']) && $_POST['submit'] == "Search") {
                                
$campus=$_POST['campus'];
                                
$status=$_POST['status'];
                                
$stu_name=$_POST['stu_name'];
                                
$yr=$_POST['sem_yr'];
                            
?>
                            <td>Name
                                <select name="stu_name" id="stu_name" >
                                    <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>
                            </td>
                            <td>
                                Campus
                                <select name='campus'>
                                    <option value='All'>All</option>
                                    <?php
                                    $query 
"Select campus_id,campus_name from campus";
                                    
$result $dbh->query($query);
                                    
$result->setFetchMode(PDO::FETCH_OBJ);
                                    while (
$row $result->fetch()) {
                                        if(
$row->campus_id==$campus)
                                            print 
'<option value=' $row->campus_id ' selected>' $row->campus_name '</option>';
                                        else
                                            print 
'<option value=' $row->campus_id '>' $row->campus_name '</option>';
                                    }
                                    
?>
                                </select>
                            </td>
                            
                            <td>
                                Semaster_Year
                                <select name="sem_yr">
                                    <?php
                                    $query12
="Select Sem_yr as yr from student group by Sem_yr";
                                    
$result12=$dbh->query($query12);
                                    
$result12->setFetchMode(PDO::FETCH_OBJ);
                                    while(
$row12=$result12->fetch()){
                                        if(
$row12->yr==$yr)
                                            print 
'<option value="' $row12->yr '" selected>' $row12->yr '</option>';
                                        else
                                            print 
'<option value="' $row12->yr '">' $row12->yr '</option>';
                                    }
                                    
?>
                                </select>
                            </td>
                            
                            <td>
                                Status
                                <select name='status'>
                                    <?php
                                    
if($status=='1'){
                                    
?>
                                    <option value='All'>All</option>
                                    <option value='1' selected>Active</option>
                                    <option value='0'>Disable</option>
                                    <?php
                                    
}
                                    else{
                                        if(
$status=='0'){
                                    
?>
                                    <option value='All'>All</option>
                                    <option value='1'>Active</option>
                                    <option value='0' selected>Disable</option>
                                    <?php
                                        
}
                                        else{
                                   
?>
                                    <option value='All'>All</option>
                                    <option value='1'>Active</option>
                                    <option value='0'>Disable</option>
                                    <?php
                                        
}
                                    }
                                    
?>
                                </select>
                            </td>
                            <?php
                            
}
                            else{
                            
?>
                            <td>Name
                                <select name="stu_name" id="stu_name" >
                                    <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> 
                            </td>
                            <td>
                                Campus
                                <select name='campus'>
                                    <option value='All'>All</option>
                                    <?php
                                    $query 
"Select campus_id,campus_name from campus";
                                    
$result $dbh->query($query);
                                    
$result->setFetchMode(PDO::FETCH_OBJ);
                                    while (
$row $result->fetch()) {
                                        print 
'<option value=' $row->campus_id '>' $row->campus_name '</option>';
                                    }
                                    
?>
                                </select>
                            </td>
                            <td>
                                Semaster_Year
                                <select name="sem_yr">
                                    <?php
                                    $curr_yr
=date("Y");
                                    
$curr_mon=date("M");
                                    echo 
"<script>alert('.$curr_yr.' '.$curr_mon.')</script>";
                                    
$query12="Select Sem_yr as yr from student group by Sem_yr";
                                    
$result12=$dbh->query($query12);
                                    
$result12->setFetchMode(PDO::FETCH_OBJ);
                                    while(
$row12=$result12->fetch()){
                                        
$year explode("-"$row12->yr);
                                        if(
$curr_yr==$year[0]&&$curr_mon>=9){
                                            print 
'<option value="' $row12->yr '"selected>' $row12->yr '</option>';
                                        }
                                        else{
                                            if(
$curr_yr==$year[1]&&$curr_mon<9){
                                                print 
'<option value="' $row12->yr '"selected>' $row12->yr '</option>';
                                            }
                                            else
                                                print 
'<option value="' $row12->yr '">' $row12->yr '</option>';
                                        }
                                    }
                                    
?>
                                </select>
                            </td>
                            <td>
                                Status
                                <select name='status'>
                                    <option value='All'>All</option>
                                    <option value='1'>Active</option>
                                    <option value='0'>Disable</option>
                                </select>
                            </td>
                            <?php
                            
}
                            
?>
                            <td><input type="submit" name="submit" class='btn' id='Search' value="Search"></td>
                        </tr><!--input search field-->
                    </table>
                </form>
            </div>
            <form action="" method="POST">
                <table border="0" class="table table-striped table-bordered table-hover table-condensed">
                    <thead>
                        <tr>
                            <th>&nbsp;</th>
                            <th>Name</th>
                            <th>Chinese Name</th>
                            <th>Year/Grade</th>
                            <th>Emergency Contact Person</th>
                            <th>Emergency Contact No. </th>
                        </tr>
                    </thead>
                    <tbody id='search_result'>
                        <?php
                        
if (isset($_POST['submit']) && $_POST['submit'] == "Search") {
                            
$campus_id $_POST['campus'];
                            
$stu_name $_POST['stu_name'];
                            if (
$stu_name == 'ALL')
                                
$stu_name ' ';
                            
$status $_POST['status'];
                            if (
$status == 'All' && $campus_id == 'All') {
                                
$query1 "Select s.linking_id,s.first_name,s.last_name,s.ch_name,s.eme_contact_name,
                        s.eme_contact_number,g.grade from student as s,grade as g,student_grade as l
                           where s.linking_id=l.student_grade_id and l.grade_id=g.grade_id and s.deleted='0' 
                           and concat(last_name,' ',first_name,'(',ch_name,')') like '%
$stu_name%' and Sem_yr='$yr'";
                            } else {
                                if (
$campus_id == 'All') {
                                    
$query1 "Select s.linking_id,s.first_name,s.last_name,s.ch_name,s.eme_contact_name,
                              s.eme_contact_number,g.grade from student as s,grade as g,student_grade as l
                               where s.linking_id=l.student_grade_id and l.grade_id=g.grade_id and s.deleted='0' 
                                 and concat(last_name,' ',first_name,'(',ch_name,')') like '%
$stu_name%' and s.actived='$status' and Sem_yr='$yr'";
                                } else {
                                    if (
$status == 'All') {
                                        
$query1 "Select s.linking_id,s.first_name,s.last_name,s.ch_name,s.eme_contact_name,
                              s.eme_contact_number,g.grade from student as s,grade as g,student_grade as l
                               where s.linking_id=l.student_grade_id and l.grade_id=g.grade_id and s.deleted='0' 
                                 and concat(last_name,' ',first_name,'(',ch_name,')') like '%
$stu_name%' and s.reg_campus_id='$campus_id' and Sem_yr='$yr'";
                                    } else {
                                        
$query1 "Select s.linking_id,s.first_name,s.last_name,s.ch_name,s.eme_contact_name,
                              s.eme_contact_number,g.grade from student as s,grade as g,student_grade as l
                               where s.linking_id=l.student_grade_id and l.grade_id=g.grade_id and s.deleted='0' 
                                 and concat(last_name,' ',first_name,'(',ch_name,')') like '%
$stu_name%' and s.reg_campus_id='$campus_id' and s.actived='$status' and Sem_yr='$yr'";
                                    }
                                }
                            }
                            
$result1 $dbh->query($query1);
                            
$result1->setFetchMode(PDO::FETCH_OBJ);
                            while (
$row $result1->fetch()) {
                                print 
'<tr>';
                                print 
'<td><input type="button" name="import" class="btn" value="Import" onClick="window.location=\'Add_stu.php?linking_id=' $row->linking_id '\'"></td>';
                                print 
'<td>' $row->last_name ' ' $row->first_name '</td>';
                                print 
'<td>' $row->ch_name '</td>';
                                print 
'<td>' $row->grade '</td>';
                                print 
'<td>' $row->eme_contact_name '</td>';
                                print 
'<td>' $row->eme_contact_number '</td>';
                                print 
'</tr>';
                            }
                        }
                        
?>
                    </tbody>
                </table>   
            </form>
        </div>
    </body>
</html>