/var/www/(Del)pathways.org.hk/MIS2/old/student/Add_stu2.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
<?php
include_once '../include/DBConnect.php';
$old_id=$_POST['old_stu_id'];
$new_id=$_POST['new_stu_id'];
$sem_yr=$_POST['sem_yr'];
$input_by=$_POST['input_by'];
$input_date=$_POST['input_date'];

$is_actived=$_POST['is_actived'];
$app_date=$_POST['app_date'];
$reg_date=$_POST['reg_date'];
if(isset(
$_POST['is_pathway_stu']))
    
$is_pathway_stu=$_POST['is_pathway_stu'];
else
    
$is_pathway_stu=0;
if(isset(
$_POST['is_in_school']))
    
$is_in_school=$_POST['is_in_school'];
else
    
$is_in_school=0;
$reg_num=$_POST['reg_num'];
$reg_campus=$_POST['reg_campus'];
$reg_sem_yr=$_POST['reg_sem_yr'];
$last_name=$_POST['last_name'];
$first_name=$_POST['first_name'];
$ch_name=$_POST['ch_name'];
$gender=$_POST['gender'];
$date_of_birth=$_POST['date_of_birth'];
$home_tel=$_POST['home_tel'];
$fax=$_POST['fax'];
$email=$_POST['email'];
$address=$_POST['address'];
$district=$_POST['district'];
$school_name=$_POST['school_name'];
$grade=$_POST['grade'];
$photo=$_POST['photo'];

$father_name=$_POST['father_name'];
$father_occ=$_POST['father_occ'];
$father_mobile=$_POST['father_mobile'];
$father_off_tel=$_POST['father_off_tel'];

$mother_name=$_POST['mother_name'];
$mother_occ=$_POST['mother_occ'];
$mother_mobile=$_POST['mother_mobile'];
$mother_off_tel=$_POST['mother_off_tel'];

$Guard_name=$_POST['guard_name'];
$Guard_occ=$_POST['guard_occ'];
$Guard_relationship=$_POST['guard_relationship'];
$Guard_tel_home=$_POST['guard_tel_home'];
$guard_mobile=$_POST['guard_mobile'];
$guard_off_tel=$_POST['guard_off_tel'];

$eme_name=$_POST['eme_name'];
$eme_contact_no=$_POST['eme_contact_no'];
$eme_relationship=$_POST['eme_relationship'];

$refer_by=$_POST['refer_by'];
$other_refer_by=$_POST['other_refer_by'];
$assessed_by=$_POST['assessed_by'];
$other_assessed_by=$_POST['other_assessed_by'];
$remarks=$_POST['remarks'];
$medication=$_POST['medication'];

$query="Insert into student set New_stu_ID='$new_id', Old_stu_ID='$old_id', Sem_yr='$sem_yr', root_id='$new_id',
    createby='
$input_by', createdate=Now(), lastupby=0, lastupdate=Now(), actived='$is_actived', deleted=0, reg_campus_id='$reg_campus', 
    input_date='
$input_date', application_date='$app_date', registration_date='$reg_date', is_pathway_student='$is_pathway_stu', 
    is_in_school_student='
$is_in_school',registration_number='$reg_num', reg_sem_year='$reg_sem_yr',last_name='$last_name', first_name='$first_name', 
    ch_name='
$ch_name', gender='$gender', date_of_birth='$date_of_birth', home_tel='$home_tel', fax='$fax', email='$email', photo='$photo', address='$address',
    district_id='
$district',school_name='$school_name', father_name='$father_name', father_occupation='$father_occ', father_mobile='$father_mobile', father_off_tel='$father_off_tel',
    mother_name='
$mother_name', mother_occupation='$mother_occ', mother_mobile='$mother_mobile', mother_off_tel='$mother_off_tel', guardian_name='$Guard_name',
    guardian_occupation='
$Guard_occ', guardian_relationship='$Guard_relationship', guardian_mobile='$guard_mobile', guardian_home_tel='$Guard_tel_home', 
    guardian_off_tel='
$guard_off_tel', eme_contact_name='$eme_name', eme_contact_number='$eme_contact_no', eme_contact_relationship='$eme_relationship', 
    remarks='
$remarks', ch_assessment_ID=NULL, ch_assessment_date=NULL,
    en_assessment_ID=NULL, en_assessment_date=NULL, math_assessment_ID=NULL, math_assessment_date=NULL,
    medication='
$medication'";

    
$result=$dbh->query($query);
    
$query1="Insert into student_grade set student_grade_id=(Select linking_id from student 
    where New_stu_ID='
$new_id' and Sem_yr='$sem_yr' and lastupdate=(Select MAX(lastupdate) from student 
        where New_stu_ID='
$new_id' and Sem_yr='$sem_yr')),createby='$input_by', createdate=Now(),
        lastupby=0, lastupdate=Now(), actived=1, deleted=0,grade_id='
$grade'";
$result1=$dbh->query($query1);
if(isset(
$_POST['subsidy_get'])){
for(
$i=0;$i<count($_POST['subsidy_get']);$i++){
    
$subsidy_get=$_POST['subsidy_get'][$i];
    
$query2="Insert into student_subsidy set stu_subsidy_id=(Select linking_id from student 
    where New_stu_ID='
$new_id' and Sem_yr='$sem_yr' and lastupdate=(Select MAX(lastupdate) from student 
        where New_stu_ID='
$new_id' and Sem_yr='$sem_yr')),createby='$input_by', createdate=Now(),
        lastupby=0, lastupdate=Now(), actived=1, deleted=0,subsidy_id='
$subsidy_get'";
    
$result2=$dbh->query($query2);
    if(!
$result2){
        echo 
"<script>alert('Error 2.')</script>";
    }
}
}
if (isset(
$_POST['diagnose'])) {
    for (
$i 0$i count($_POST['diagnose']); $i++) {
        
$diagnose $_POST['diagnose'][$i];
        
$query3 "Insert into student_diagnose set stu_dia_ID=(Select linking_id from student 
    where New_stu_ID='
$new_id' and Sem_yr='$sem_yr' and lastupdate=(Select MAX(lastupdate) from student 
        where New_stu_ID='
$new_id' and Sem_yr='$sem_yr')),createby='$input_by', createdate=Now(),
        lastupby=0, lastupdate=Now(), actived=1, deleted=0,diagnose_id='
$diagnose',refer_by='$refer_by',other_refer_by='$other_refer_by'";
        
$result3 $dbh->query($query3);
        if (!
$result3) {
            echo 
"<script>alert('Error 3.')</script>";
        }
    }
}
if (isset(
$_POST['add_aspect'])) {
    for (
$i 0$i count($_POST['add_aspect']); $i++) {
        
$add_aspect $_POST['add_aspect'][$i]; //add_aspect
        
$query4 "Insert into student_additional_aspect set stu_add_ID=(Select linking_id from student 
    where New_stu_ID='
$new_id' and Sem_yr='$sem_yr' and lastupdate=(Select MAX(lastupdate) from student 
        where New_stu_ID='
$new_id' and Sem_yr='$sem_yr')),createby='$input_by', createdate=Now(),
        lastupby=0, lastupdate=Now(), actived=1, deleted=0,aspect_id='
$add_aspect',assessed_by='$assessed_by',other_assessed_by='$other_assessed_by'";
        
$result4 $dbh->query($query4);
        if (!
$result4) {
            echo 
"<script>alert('Error 4.')</script>";
        }
    }
}
if(
$result&&$result1){
    echo 
"<script>alert('Insert data successful.')</script>";
    echo(
"<script>location.href ='student.php';</script>");
}
?>