403Webshell
Server IP : 210.245.233.93  /  Your IP : 216.73.216.226
Web Server : Apache/2.2.15 (CentOS)
System : Linux webserver2.onesolution.com.hk 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64
User : apache ( 48)
PHP Version : 5.3.3
Disable Function : exec, shell_exec, system, passthru, popen, proc_open, pcntl_exec
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/(Del)pathways.org.hk/MIS20140127/old20140314/student/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/(Del)pathways.org.hk/MIS20140127/old20140314/student/Add_stu.php
<!DOCTYPE html>
<?php
require_once '../include/head.php';
require_once '../include/checkuser.php';
require_once '../include/Nav_bar.php';
include_once '../include/DBConnect.php';

if (isset($_POST['submit']) && $_POST['submit'] == 'Save') {

    $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'];
    //$reg_no = $_POST['old_reg_no'];
    $old_reg_no = $_POST['old_reg_no'];
    $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_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'];
    $address2 = $_POST['address1'];
    $address3 = $_POST['address2'];
    $district = $_POST['district'];
    $school_name = $_POST['school_name'];
    $school_district = $_POST['sch_district'];
    $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'];
    
    $medication = $_POST['medication'];
    $traveling_allowance = $_POST['traveling_allowance'];
    
    $query_gene = "Select cam_short_form from campus where campus_id='$reg_campus'";
    $result_gene = $dbh->query($query_gene);
    $result_gene->setFetchMode(PDO::FETCH_OBJ);
    $cam_short_form = $result_gene->fetch()->cam_short_form;
    $year=explode("-",$sem_yr);
    $front_yr = substr($year[0] ,2);
    $last_yr = substr($year[1], 2);
    $new_id = $cam_short_form . $front_yr . $last_yr . $old_id;
    $reg_no = $cam_short_form . $old_reg_no;
    echo "<script>alert('Student ID(new system):" . $new_id . "  Registration No(new system):" . $reg_no . "')</script>";

    $query = "Insert into student set New_stu_ID='$new_id', Old_stu_ID='$old_id', Sem_yr='$sem_yr', 
    createby='$input_by', createdate=Now(), lastupby=0, lastupdate=Now(), actived='$is_actived', deleted=0,registration_no='$reg_no',old_registration_no='$old_reg_no',
    reg_campus_id='$reg_campus', 
    input_date='$input_date', registration_date='$reg_date', is_pathway_student='$is_pathway_stu', 
    is_in_school_student='$is_in_school', 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',address2='$address2',address3='$address3',
    district_id='$district',school_name='$school_name',sch_district_id='$school_district', 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', 
    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',traveling_allowance='$traveling_allowance'";

    $result = $dbh->query($query);
    
    $get_linking_q='Select Max(linking_id) as l from student';
    $get_link_r=$dbh->query($get_linking_q);
    $get_link_r->setFetchMode(PDO::FETCH_OBJ);
    $linking_id=$get_link_r->fetch()->l;//this is the root_id also 
    
    $query_root="Update student set root_id='$linking_id' where New_stu_ID='$new_id' and Sem_yr='$sem_yr' and deleted=0";
    $dbh->query($query_root);
    
    $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 ($_POST['refer_by'][0] != "") {

        for ($i = 0; $i < count($_POST['refer_by']); $i++) {
            $no_of_same = 0;
            $refer_by = $_POST['refer_by'][$i];
            $assessed_by = $_POST['assessed_by'][$i];
            $assessed_date = $_POST['assessed_date'][$i];
            $f = "assessed_doc" . $i;

            $myFile = $_FILES[$f];
            if ($myFile['name'] != "") {

                if ($myFile["error"] !== UPLOAD_ERR_OK) {
//echo "<p>An error occurred.</p>";
                    $error = "<p>An error occurred.</p>";
                    exit;
                }

// ensure a safe filename
                $name = preg_replace("/[^A-Z0-9._-]/i", "_", $myFile["name"]);

// don't overwrite an existing file
                $parts = pathinfo($name);
                while (file_exists('diagnose_report/' . $name)) {
                    $no_of_same++;
                    $name = $parts["filename"] . "-" . $no_of_same . "." . $parts["extension"];
                }

// preserve file from temporary directory
                $success = move_uploaded_file($myFile["tmp_name"], 'diagnose_report/' . $name);
                if (!$success) {
                    $msg = "<p>Unable to save file.</p>";
                    echo "<script>alert('$msg')</script>";
                    exit;
                } else {
                    $msg = $name;
                }

// set proper permissions on the new file
                chmod('diagnose_report/' . $name, 0644);
            }

            $dir = 'diagnose_report/' . $name;
            $query5 = "Insert into student_document set stu_linking_id='$linking_id',createby='$input_by',
            createdate=Now(),lastupby=0, lastupdate=Now(), actived=1, deleted=0,refer_by='$refer_by',
                assessed_by='$assessed_by',assessed_doc='$dir', assessed_date='$assessed_date'";

            $result5 = $dbh->query($query5);
            if (!$result5) {
                echo "<script>alert('Error 5.')</script>";
            }
        }
    }

    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'";
            $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'";
            $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>");
    }
}
?>
<html>
    <head>
        <script type="text/javascript" src="../include/FileUpload/ajaxfileupload.js"></script>
        <style>
            .table{
                background:#eeefde;
            }
        </style>
        <script>
            var is_import;
            var browse;
            $(document).ready(function() {
                Add_Diagnoses();
                Add_aspect();
                is_import = 'F';
                browse=$('#browse').clone();
            });
            $(document).on('click', '#upload',
                    function ajaxFileUpload() {
                        $.ajaxFileUpload({
                            url: 'upload_stu_photo.php',
                            secureuri: false,
                            fileElementId: 'browse',
                            dataType: 'json',
                            data: {name: 'logan', id: 'id'},
                            success: function(data, status) {
                                if (typeof (data.error) != 'undefined')
                                {
                                    if (data.error != '') {
                                        alert(data.error);
                                    }
                                    else {
                                        loading.src = "student_photo/" + data.msg;
                                        $('#photo').val("student_photo/" + data.msg);
                                    }
                                }
                            },
                            error: function(data, status, e) {
                                alert("error");
                                alert(e);
                            }
                        });
                        return false;
                    });
            $(function() {
                var limit_date = new Date();
                var curr_yr = limit_date.getFullYear();
                limit_date.setYear(curr_yr - 3);
                $('.date-picker').datetimepicker({pickTime: false, format: 'yyyy-MM-dd'});
                $('#day_of_birth').datetimepicker({autoclose: true, pickTime: false, format: 'yyyy-MM-dd', endDate: limit_date});
                $(document).on('click', '#import', function() {
                    is_import = 'T';
                });
            });
            $(document).on('click', '#add_assessed', function() {
                $.ajax({
                    type: "POST",
                    url: "ajax_stu_add_assess.php",
                    data: {
                        i: $('#i').val()
                    },
                    cache: false,
                    success: function(html) {
                        $("#add_thing2").append(html);
                        var tem_i = $("#i").val();
                        tem_i++;
                        $("#i").val(tem_i);
                        $('.date-picker').datetimepicker({pickTime: false, format: 'yyyy-MM-dd'});
                    }
                });//add_assessed
            });
            $(document).on('change', '#subsidy', function() {
                $.ajax({
                    type: "POST",
                    url: "ajax_add_stu.php",
                    data: {
                        subsidy: $('#subsidy').val()
                    },
                    cache: false,
                    success: function(html) {
                        $("#subsidy_show").html(html);
                    }
                });
            });
            function Add_Diagnoses() {
                var array = new Array();
                var tr = "";
                for (var i = 0; i < (document.getElementsByName("diagnose[]")).length; i++) {
                    if (document.getElementsByName("diagnose[]")[i].checked == true) {
                        array.push((document.getElementsByName("diagnoseval[]")[i].value));
                    }
                }
                for (var i = 0; i < array.length; i++) {
                    tr +=
                            "<tr>" +
                            "<td style=\"border: 1px solid #dddddd;width: 50px;\"><button onclick=\"delete_row(this);\" type='button' class=\"btn\"><i class=\"icon-remove\"></i></button></td>" +
                            "<td>" + array[i] + "</td>" +
                            "</tr>";
                }
                $('#Add_Diagnoses').html(tr);
            }
            function Add_aspect() {
                var array = new Array();
                var tr = "";
                for (var i = 0; i < (document.getElementsByName("add_aspect[]")).length; i++) {
                    if (document.getElementsByName("add_aspect[]")[i].checked == true) {
                        array.push((document.getElementsByName("add_aspectval[]")[i].value));
                    }
                }
                for (var i = 0; i < array.length; i++) {
                    tr +=
                            "<tr>" +
                            "<td style=\"border: 1px solid #dddddd;width: 50px;\"><button onclick=\"delete_row(this);\" type='button' class=\"btn\"><i class=\"icon-remove\"></i></button></td>" +
                            "<td>" + array[i] + "</td>" +
                            "</tr>";
                }
                $('#Add_Aspect').html(tr);
            }
            function delete_row(e) {
                $(e).parent().parent().remove();
            }
            $(document).on('focusout', '#DOB', function() {
                if (is_import == 'F') {
                    if ($('#last_name').val().length != 0 && $('#first_name').val().length != 0 && $('#DOB').val().length != 0) {
                        $.ajax({
                            type: "POST",
                            url: "ajax_checking.php",
                            data: {
                                last_name: $('#last_name').val(),
                                first_name: $('#first_name').val(),
                                DOB: $('#DOB').val()
                            },
                            cache: false,
                            success: function(html) {
                                if (html == 'yes') {
                                    alert('There is a record duplicated with the record you are inputting.Please,input again');
                                    window.location = 'Add_stu.php';
                                }
                                else {
                                    alert('The record you are inputting is not duplicated.');
                                }
                            }
                        });
                    }
                }
            });
            $(document).on('focusout', '#last_name', function() {
                if (is_import == 'F') {
                    if ($('#last_name').val().length != 0 && $('#first_name').val().length != 0 && $('#DOB').val().length != 0) {
                        $.ajax({
                            type: "POST",
                            url: "ajax_checking.php",
                            data: {
                                last_name: $('#last_name').val(),
                                first_name: $('#first_name').val(),
                                DOB: $('#DOB').val()
                            },
                            cache: false,
                            success: function(html) {
                                if (html == 'yes') {
                                    alert('There is a record duplicated with the record you are inputting.Please,input again');
                                    window.location = 'Add_stu.php';
                                }
                                else {
                                    alert('The record you are inputting is not duplicated.');
                                }
                            }
                        });
                    }
                }
            });
            $(document).on('focusout', '#first_name', function() {
                if (is_import == 'F') {
                    if ($('#last_name').val().length != 0 && $('#first_name').val().length != 0 && $('#DOB').val().length != 0) {
                        $.ajax({
                            type: "POST",
                            url: "ajax_checking.php",
                            data: {
                                last_name: $('#last_name').val(),
                                first_name: $('#first_name').val(),
                                DOB: $('#DOB').val()
                            },
                            cache: false,
                            success: function(html) {
                                if (html == 'yes') {
                                    alert('There is a record duplicated with the record you are inputting.Please,input again');
                                    window.location = 'Add_stu.php';
                                }
                                else {
                                    alert('The record you are inputting is not duplicated.');
                                }
                            }
                        });
                    }
                }
            });
            function delete_photo() {
                $.ajax({
                    type: "POST",
                    url: "ajax_delete_photo.php",
                    data: {
                        photo:$('#photo').val()
                    },
                    cache: false,
                    success: function(html) {
                        if(html=='Yes'){
                            alert('Delete photo successful');
                            $('#loading').attr('src','student_photo/personal_photo.gif');
                            $('#photo').val('no photo');
                            $('#browse').replaceWith(browse);
                        }
                        else{
                            alert('Fail to delete this photo');
                        }
                    }
                });
            }
            $(document).on('focusout', '#sem_yr', function() {
                if($('#sem_yr').val()==$('#hidden_sem_yr').val()){
                    alert('Please input another Semester year.');
                }
            });
        </script>
    </head>
    <body>      
<?php $i = 0; ?>
        <!-- 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 class="active">Add Student Record</li>
            </ul>
        </div>
        <div class="container-fluid pathways-container">
            <form action="" method="POST" enctype="multipart/form-data" id="form">
                <table border="0" class="table table-bordered table-hover table-condensed">
                    <tr>
                        <td colspan="4">
                            <h2>Add Student Record</h2>
                            <input type="button" class="btn pull-right" id="import" name="import" value="Import Data" onclick="window.location = 'stu_import.php'">
                        </td>
                    </tr>
<?php
$curr_yr = date("Y");
$curr_yr-=3;
$curr_mon = date("m");
$curr_day= date("d");
if (!isset($_GET['linking_id'])) {
    ?>
                        <tr>
                            <td colspan="4"><b><h4>Student Record</h4></b></td>
                        </tr>
                        <tr>
                            <td>Student No.(Old System)</td><td><input type="text" name="old_stu_id" required="true"></td>
                            <td>Student No.(New System)</td><td><input type="text" name="new_stu_id" readonly="true"></td>
                        </tr>
                        <tr>
                            <td>Semester_year</td><td colspan="3"><input type="text" name="sem_yr" placeholder="2013-2014" required="true" id="sem_yr1"></td>
                        </tr>
                        <tr>
                            <td>Registration No(Old system)</td>
                            <td>
                                <input type="text" name="old_reg_no" required="true">
                            </td>
                            <td>Registration No</td>
                            <td>
                                <input type="text" name="new_reg_no" readonly="true">
                            </td>
                        </tr>
                        <tr>
                            <td>Registration Campus</td>
                            <td>
                                <select name="reg_campus" required="true">
                                    <option></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>Registration Date</td>
                            <td>
                                <div class="input-append date-picker">
                                    <input type="text" name="reg_date" class="dateISO" required="true">
                                    <span class="add-on">
                                        <i class="icon-calendar" data-date-icon="icon-calendar" data-time-icon="icon-time"></i>
                                    </span>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>Registration Semester</td>
                            <td colspan="3"><input type="text" name="reg_sem_yr" placeholder="2013-2014" required="true"></td>
                        </tr>
                        <tr>
                            <td>Type</td>
                            <td>
                                <input type="checkbox" name="is_pathway_stu" value="1">Pathway Student
                                <input type="checkbox" name="is_in_school" value="1">In-School Student
                            </td>
                            <td>Status</td>
                            <td><select name="is_actived" required="true"><option></option><option value="1">Active</option><option value="0">Disable</option></select></td>
                        </tr>
                        <tr>
                            <td>Data Input Date</td>
                            <td>
                                <div class="input-append date-picker">
                                    <input type="text" name="input_date" class="dateISO" required="true" data-format="yyyy-MM-dd">
                                    <span class="add-on">
                                        <i class="icon-calendar" data-date-icon="icon-calendar" data-time-icon="icon-time"></i>
                                    </span>
                                </div>
                            </td>
                            <td>Input By</td>
                            <td>
                                <input type="text" name="input_by" value="Chung Wai ki" readonly="true" required="true">
                            </td>
                        </tr>
                        <tr><td colspan="4"><hr></td></tr>
                        <tr>
                            <td colspan="4"><b><h4>Student Information</h4></b></td>
                        </tr>
                        <tr>
                            <td>Date of Birth</td>
                            <td colspan="3">
                                <div class="input-append" id="day_of_birth">
                                    <input type="text" name="date_of_birth" id="DOB" class="dateISO" required="true" value="<?=$curr_yr.'-'.$curr_mon.'-'.$curr_day?>">
                                    <span class="add-on">
                                        <i class="icon-calendar" data-date-icon="icon-calendar" data-time-icon="icon-time"></i>
                                    </span>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>Last Name</td>
                            <td><input type="text" id="last_name" name="last_name" required="true"></td>
                            <td>First Name</td>
                            <td><input type="text" id="first_name" name="first_name" required="true"></td>
                        </tr>
                        <tr>
                            <td>中文姓名</td>
                            <td><input type="text" name="ch_name" required="true"></td>
                            <td>Gender</td>
                            <td><select name="gender"><option></option><option value="1">Male</option><option value="0">Female</option></select></td>
                        </tr>
                        <tr>
                            <td>Tel(Home)</td>
                            <td><input type="tel" name="home_tel" placeholder="24131323" required="true"></td>
                            <td>Fax</td>
                            <td><input type="tel" name="fax"></td>
                        </tr>
                        <tr>
                            <td>E-mail</td>
                            <td colspan="3"><input type="email" name="email" placeholder="user@example.com"></td>
                        </tr>
                        <tr>
                            <td>Address</td>
                            <td colspan="2"><input type="text" name="address" required="true" class="input-block-level"></td>
                            <td rowspan="6">
                        <center>
                            <img id="loading" src="student_photo/personal_photo.gif">
                            <input type="hidden" name="photo" id="photo" value="no photo">
                        </center>
                        </td>
                        </tr>
                        <tr>
                            <td>Address2</td>
                            <td colspan="2"><input type="text" name="address1" required="true" class="input-block-level"></td>
                        </tr>
                        <tr>
                            <td>Address3</td>
                            <td colspan="2"><input type="text" name="address2" required="true" class="input-block-level"></td>
                        </tr>
                        <tr>
                            <td>District</td>
                            <td colspan="2">
                                <select name="district" required="true">
                                    <option></option>
                                    <?php
                                    $query1 = "Select district,district_id from district";
                                    $result1 = $dbh->query($query1);
                                    $result1->setFetchMode(PDO::FETCH_OBJ);
                                    while ($row = $result1->fetch()) {
                                        print '<option value=' . $row->district_id . '>' . $row->district . '</option>';
                                    }
                                    ?>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>Name of School Attending</td>
                            <td colspan="2"><input type="text" name="school_name" required="true"></td>
                        </tr>
                        <tr>
                            <td>School District</td>
                            <td colspan="2">
                                <select name="sch_district" required="true">
                                    <option></option>
                                    <?php
                                    $query1 = "Select district,district_id from district";
                                    $result1 = $dbh->query($query1);
                                    $result1->setFetchMode(PDO::FETCH_OBJ);
                                    while ($row = $result1->fetch()) {
                                        print '<option value=' . $row->district_id . '>' . $row->district . '</option>';
                                    }
                                    ?>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>Year/Grade</td>
                            <td colspan="2">
                                <select name="grade" required="true">
                                    <option></option>
                                    <?php
                                    $query2 = "Select grade_id,grade from grade";
                                    $result2 = $dbh->query($query2);
                                    $result2->setFetchMode(PDO::FETCH_OBJ);
                                    while ($row = $result2->fetch()) {
                                        print '<option value=' . $row->grade_id . '.>' . $row->grade . '</option>';
                                    }
                                    ?>
                                </select>
                            </td>
                            <td>
                        <center>
                            <input type="file" name="browse" id="browse" size="10">
                        </center>
                        </td>
                        </tr>
                        <tr>
                            <td colspan='3'></td>
                            <td>
                        <center>
                            <input type='button' name='upload' id='upload' class='btn' value='Upload'>
                            <input type='button' name='remove' id='remove' class='btn' value='Remove' onclick="delete_photo();">
                        </center>
                        </td>
                        </tr>

                        <tr><td colspan="4"><hr></td></tr>
                        <tr>
                            <td colspan="4"><b><h4>Father</h4></b></td>
                        </tr>
                        <tr>
                            <td>Name</td>
                            <td><input type="text" name="father_name"></td>
                            <td>Occupation</td>
                            <td><input type="text" name="father_occ"></td>
                        </tr>
                        <tr>
                            <td>Mobile</td>
                            <td><input type="tel" name="father_mobile"></td>
                            <td>Tel(Office)</td>
                            <td><input type="tel" name="father_off_tel"></td>
                        </tr>

                        <tr><td colspan="4"><hr></td></tr>
                        <tr>
                            <td colspan="4"><b><h4>Mother</h4></b></td>
                        </tr>
                        <tr>
                            <td>Name</td>
                            <td><input type="text" name="mother_name"></td>
                            <td>Occupation</td>
                            <td><input type="text" name="mother_occ"></td>
                        </tr>
                        <tr>
                            <td>Mobile</td>
                            <td><input type="tel" name="mother_mobile"></td>
                            <td>Tel(Office)</td>
                            <td><input type="tel" name="mother_off_tel"></td>
                        </tr>

                        <tr><td colspan="4"><hr></td></tr>
                        <tr>
                            <td colspan="4"><b><h4>Guardian</h4></b></td>
                        </tr>
                        <tr>
                            <td>Name</td>
                            <td><input type="text" name="guard_name"></td>
                            <td>Occupation</td>
                            <td><input type="text" name="guard_occ"></td>
                        </tr>
                        <tr>
                            <td>Relationship</td>
                            <td><input type="text" name="guard_relationship"></td>
                            <td>Tel(Home)</td>
                            <td><input type="tel" name="guard_tel_home"></td>
                        </tr>
                        <tr>
                            <td>Mobile</td>
                            <td><input type="tel" name="guard_mobile"></td>
                            <td>Tel(Office)</td>
                            <td><input type="tel" name="guard_off_tel"></td>
                        </tr>

                        <tr><td colspan="4"><hr></td></tr>
                        <tr>
                            <td colspan="4"><b><h4>Emergency Contact Person</h4></b></td>
                        </tr>
                        <tr>
                            <td>Name</td>
                            <td><input type="text" name="eme_name"></td>
                            <td>Contact No.</td>
                            <td><input type="tel" name="eme_contact_no"></td>
                        </tr>
                        <tr>
                            <td>Relationship</td>
                            <td colspan="3"><input type="text" name="eme_relationship"></td>
                        </tr>

                        <tr><td colspan="4"><hr></td></tr>
                        <tr>
                            <td><b><h4>Diagnoses</h4></b></td>
                            <td><button type="button" class="btn" id="diagnoses_btn" data-toggle="modal" data-target="#diagnoses"><i class="icon-plus" ></i> Add</button></td>
                            <td><b><h4>Intellectual Functioning </h4></b></td>
                            <td><button type="button" class="btn" id="add_aspect_btn" data-toggle="modal" data-target="#add_aspect"><i class="icon-plus" ></i> Add</button></td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <table id="Add_Diagnoses" style="width: 80%;border: 1px solid #dddddd;margin-left: 40px;margin-bottom: 10px;margin-top: 10px;margin-right: 10px;" >

                                </table>
                            </td>
                            <td colspan="2">
                                <table id="Add_Aspect" style="width: 80%;border: 1px solid #dddddd;margin-left: 40px;margin-bottom: 10px;margin-top: 10px;margin-right: 10px;" >

                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td>Refer to</td>
                            <td><input type="text" name="refer_by[]"></td>
                            <td>Assessed By</td>
                            <td><input type="text" name="assessed_by[]"></td>
                        </tr>
                        <tr>
                            <td>Assessed date</td>
                            <td>
                                <div class="input-append date-picker">
                                    <input type="text" name="assessed_date[]" class="dateISO">
                                    <span class="add-on">
                                        <i class="icon-calendar" data-date-icon="icon-calendar" data-time-icon="icon-time"></i>
                                    </span>
                                </div>
                            </td>

                            <td>Assessed document</td>
                            <td colspan="3">
                                <div class="fileupload fileupload-new" style="margin:0px" data-provides="fileupload">
                                    <div class="input-append">
                                        <div class="uneditable-input ">
                                            <i class="icon-file fileupload-exists"></i>
                                            <span class="fileupload-preview"><a href="diagnose_report/<? //= $attachment[$attribute]                     ?>" target="_blank"><? //= $attachment[$attribute]                  ?></a></span>
                                        </div>
                                        <span class="btn btn-file">
                                            <span class="fileupload-new">Select file</span>
                                            <span class="fileupload-exists">Change</span>
                                            <input type="file" name="assessed_doc<?= $i ?>">
    <?php $i++; ?>
                                            <input type='hidden' name='i' id='i' value='<?= $i ?>' >
                                        </span>
                                        <a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
                                    </div>
                                </div>
                            </td>
                        </tr>
                        <tbody id='add_thing2'></tbody>
                        <tr>
                            <td colspan="4"><input type="button" class="btn" name="add_assessed" id="add_assessed" value="Add a record"></td>
                        </tr>


                        <tr>
                            <td>Medication</td>
                            <td colspan="4"><textarea name="medication"></textarea></td>
                        </tr>
                        <tr><td colspan="4"><hr></td></tr>
                        <tr><td colspan="4"><b><h4>Assessment Result</h4></b></td></tr>

                        <tr><td colspan="4"><hr></td></tr>
                        <tr><td colspan="4"><b><h4>Subsidy</h4></b></td></tr>
                        <tr>
                            <td>
                                <select name="select_subsidy" id="subsidy">
                                    <option value="1">None</option>
                                    <option value="2">Subsidy Rate</option>
                                </select>
                            </td>
                            <td colspan="3"><input type="text" name="subsidy_pecent" id="subsidy_percent" value="0%" readonly="true"></td>
                        </tr>
                        <tr>
                        <tbody id="subsidy_show"></tbody>
                        </tr>
                        <tr>
                            <td>Traveling Allowance </td>
                            <td colspan="3">
                                <select name="traveling_allowance" required="true">
                                    <option></option>
                                    <option value="1">Yes</option>
                                    <option value="0">No</option>
                                </select>
                            </td>
                        </tr>
                    </table>
                    <input type="submit" name="submit" class="btn" value="Save">
                    <input type="button" value="Back" class="btn" onclick="history.back()"/>
                    <div style="display: none;" class="modal fade" id="add_aspect" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static">
                        <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                    <h4>Additional aspects</h4>
                                </div>
                                <div class="modal-body">
                                    <table border="0">
                                        <?php
                                        $query3 = "Select aspect_id,aspect_name from additional_aspect";
                                        $result3 = $dbh->query($query3);
                                        $result3->setFetchMode(PDO::FETCH_OBJ);
                                        while ($row = $result3->fetch()) {
                                            print '<tr>';
                                            print '<td>';
                                            print '<input type="checkbox" name="add_aspect[]" value="' . $row->aspect_id . '">' . $row->aspect_name;
                                            print '<input type="hidden" name="add_aspectval[]" value="' . $row->aspect_name . '">';
                                            print '</td>';
                                            print '</tr>';
                                        }
                                        ?>
                                    </table>
                                </div>
                                <div class="modal-footer">
                                    <input type="button" name="submit_aspect" class="btn" value="Add" data-dismiss="modal" onclick="Add_aspect();">
                                </div>
                            </div>
                        </div>
                    </div>

                    <div style="display: none;" class="modal fade" id="diagnoses" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static">
                        <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                    <h4>Diagnoses</h4>
                                </div>
                                <div class="modal-body">
                                    <table border="0">
                                        <?php
                                        $query3 = "Select diagnose_id,diagnose_name from diagnose";
                                        $result3 = $dbh->query($query3);
                                        $result3->setFetchMode(PDO::FETCH_OBJ);
                                        while ($row = $result3->fetch()) {
                                            print '<tr>';
                                            print '<td>';
                                            print '<input type="checkbox" name="diagnose[]" value="' . $row->diagnose_id . '">' . $row->diagnose_name;
                                            print '<input type="hidden" name="diagnoseval[]" value="' . $row->diagnose_name . '">';
                                            print '</td>';
                                            print '</tr>';
                                        }
                                        ?>
                                    </table>
                                </div>
                                <div class="modal-footer">
                                    <input type="button" name="submit_diagnose" class="btn" value="Add" data-dismiss="modal" onclick="Add_Diagnoses();">
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </body>
    </html>
    <?php
} else {
    $i = 0;
    $linking_id = $_GET['linking_id'];
    $query_init = "Select Old_stu_id as o,New_stu_id as n,Sem_yr as s_yr,root_id,
    createby, createdate, lastupby, lastupdate, actived, deleted,registration_no,old_registration_no,
    reg_campus_id,input_date, registration_date, is_pathway_student, is_in_school_student,
    reg_sem_year,last_name, first_name, ch_name, gender, date_of_birth, home_tel,
    fax, email, photo, address,address2,address3,district_id,school_name,sch_district_id, father_name,
    father_occupation, father_mobile, father_off_tel,mother_name, mother_occupation,
    mother_mobile, mother_off_tel, guardian_name,guardian_occupation, guardian_relationship,
    guardian_mobile, guardian_home_tel,guardian_off_tel, eme_contact_name, eme_contact_number,
    eme_contact_relationship, ch_assessment_ID, ch_assessment_date,
    en_assessment_ID, en_assessment_date, math_assessment_ID, math_assessment_date,
    medication,traveling_allowance from student where linking_id='$linking_id' and deleted='0'";
    $query_init1 = "Select grade_id from student_grade where student_grade_id='$linking_id' and deleted='0'";
    $query_init2 = "Select diagnose_id from student_diagnose where stu_dia_ID='$linking_id' and deleted='0'";
    $query_init3 = "Select aspect_id from student_additional_aspect where stu_add_ID='$linking_id' and deleted='0'";
    
    $result = $dbh->query($query_init);
    $result->setFetchMode(PDO::FETCH_OBJ);
    $row = $result->fetch();

    $result1 = $dbh->query($query_init1);
    $result1->setFetchMode(PDO::FETCH_OBJ); //grade
    $row_init = $result1->fetch();

    $result2 = $dbh->query($query_init2);
    $result3 = $dbh->query($query_init3);
    ?>
    <tr>
        <td colspan="4"><b><h4>Student Record</h4></b></td>
    </tr>
    <tr>
        <td>Student No.(Old System)</td><td><input type="text" name="old_stu_id" required="true" readonly="true" value="<?= $row->o ?>"></td>
        <td>Student No.(New System)</td><td><input type="text" name="new_stu_id" required="true" readonly="true" value="<?= $row->n ?>"></td>
    </tr>
    <tr>
        <td>Semester_year</td>
        <td colspan="3">
            <input type="text" name="sem_yr" placeholder="2013-2014" required="true" id="sem_yr" value="<?= $row->s_yr; ?>">
            <input type="hidden" name="old_sem_yr" id="hidden_sem_yr" value="<?= $row->s_yr; ?>">
        </td>
    </tr>
    <tr>
        <td>Registration No(Old system)</td>
        <td>
            <input type="text" name="old_reg_no" required="true" value="<?= $row->old_registration_no; ?>" readonly="true">
        </td>
        <td>Registration No</td>
        <td>
            <input type="text" name="reg_no" required="true" value="<?= $row->registration_no; ?>" readonly="true">
        </td>
    </tr>
    <tr>
        <td>Registration Campus</td>
        <td>
            <select name="reg_campus" required="true">
                <option></option>
                <?php
                $query = "Select campus_id,campus_name from campus";
                $result = $dbh->query($query);
                $result->setFetchMode(PDO::FETCH_OBJ);
                while ($row1 = $result->fetch()) {
                    if ($row->reg_campus_id == $row1->campus_id)
                        print '<option value=' . $row1->campus_id . ' selected>' . $row1->campus_name . '</option>';
                    else
                        print '<option value=' . $row1->campus_id . '>' . $row1->campus_name . '</option>';
                }
                ?>
            </select>
        </td>
        <td>Registration Date</td>
        <td>
            <div class="input-append date-picker">
                <input type="text" name="reg_date" class="dateISO" required="true" value="<?= $row->registration_date; ?>">
                <span class="add-on">
                    <i class="icon-calendar" data-date-icon="icon-calendar" data-time-icon="icon-time"></i>
                </span>
            </div>
        </td>
    </tr>
    <tr>
        <td>Registration Semester</td>
        <td colspan="3"><input type="text" name="reg_sem_yr" placeholder="2013-2014" required="true" value="<?= $row->reg_sem_year ?>"></td>
    </tr>
    <tr>
        <td>Type</td>
        <td>
            <?php
            if ($row->is_pathway_student == 1) {
                ?>
                <input type="checkbox" name="is_pathway_stu" value="1" checked>Pathway Student
                <?php
            } else {
                ?>
                <input type="checkbox" name="is_pathway_stu" value="1">Pathway Student
                <?php
            }
            ?>
            <?php
            if ($row->is_in_school_student == 1) {
                ?>
                <input type="checkbox" name="is_in_school" value="1" checked>In-School Student
                <?php
            } else {
                ?>
                <input type="checkbox" name="is_in_school" value="1">In-School Student
                <?php
            }
            ?>
        </td>
        <td>Status</td>
        <td>
            <select name="is_actived" required="true">
                <option></option>
                <?php
                if ($row->actived == 1) {
                    ?>
                    <option value="1" selected>Active</option>
                    <option value="0">Disable</option>
                    <?php
                } else {
                    ?>
                    <option value="1">Active</option>
                    <option value="0" selected>Disable</option>
                    <?php
                }
                ?>
            </select>
        </td>
    </tr>
    <tr>
        <td>Data Input Date</td>
        <td>
            <div class="input-append date-picker">
                <input type="text" name="input_date" class="dateISO" required="true" readonly="true" data-format="yyyy-MM-dd" value="<?= $row->input_date; ?>">
                <span class="add-on">
                    <i class="icon-calendar" data-date-icon="icon-calendar" data-time-icon="icon-time"></i>
                </span>
            </div>
        </td>
        <td>Input By</td>
        <td>
            <input type="text" name="input_by" value="Chung Wai ki" readonly="true" required="true">
        </td>
    </tr>
    <tr><td colspan="4"><hr></td></tr>
    <tr>
        <td colspan="4"><b><h4>Student Information</h4></b></td>
    </tr>
    <tr>
        <td>Date of Birth</td>
        <td colspan="3">
            <div class="input-append" id="day_of_birth">
                <input type="text" name="date_of_birth" id="DOB" class="dateISO" required="true" value="<?= $row->date_of_birth ?>">
                <span class="add-on">
                    <i class="icon-calendar" data-date-icon="icon-calendar" data-time-icon="icon-time"></i>
                </span>
            </div>
        </td>
    </tr>
    <tr>
        <td>Last Name</td>
        <td><input type="text" name="last_name" id="last_name" required="true" value="<?= $row->last_name; ?>"></td>
        <td>First Name</td>
        <td><input type="text" name="first_name" id="first_name" required="true" value="<?= $row->first_name; ?>"></td>
    </tr>
    <tr>
        <td>中文姓名</td>
        <td><input type="text" name="ch_name" required="true" value="<?= $row->ch_name; ?>"></td>
        <td>Gender</td>
        <td>
            <select name="gender" required="true">
                <option></option>
                <?php
                if ($row->gender == 1) {
                    ?>
                    <option value="1" selected>Male</option>
                    <option value="0">Female</option>
                    <?php
                } else {
                    ?>
                    <option value="1">Male</option>
                    <option value="0" selected>Female</option>
                    <?php
                }
                ?>
            </select>
        </td>
    </tr>
    
    <tr>
        <td>Tel(Home)</td>
        <td><input type="tel" name="home_tel" placeholder="24131323" required="true" value="<?= $row->home_tel ?>"></td>
        <td>Fax</td>
        <td><input type="tel" name="fax" value="<?= $row->fax ?>"></td>
    </tr>
    <tr>
        <td>E-mail</td>
        <td colspan="3"><input type="email" name="email" placeholder="user@example.com" value="<?= $row->email ?>"></td>
    </tr>
    <tr>
        <td>Address</td>
        <td colspan="2"><input type="text" name="address" required="true" class="input-block-level" value="<?= $row->address ?>"></td>
        <td rowspan="6">
    <center>
        <?php
        if ($row->photo != 'no photo') {
            ?>
            <img id="loading" src="<?= $row->photo ?>">
            <input type="hidden" name="photo" id="photo" value="<?= $row->photo ?>">
            <?php
        } else {
            ?>
            <img id="loading" src="student_photo/personal_photo.gif">
            <input type="hidden" name="photo" id="photo" value="no photo">
            <?php
        }
        ?>
    </center>
    </td>
    </tr>
    <tr>
        <td>Address2</td>
        <td colspan="2"><input type="text" name="address1" required="true" class="input-block-level" value="<?= $row->address2 ?>"></td>
    </tr>
    <tr>
        <td>Address3</td>
        <td colspan="2"><input type="text" name="address2" required="true" class="input-block-level" value="<?= $row->address3 ?>"></td>
    </tr>
    <tr>
        <td>District</td>
        <td colspan="2">
            <select name="district"  required="true">
                <option></option>
                <?php
                $query1 = "Select district,district_id from district";
                $result4 = $dbh->query($query1);
                $result4->setFetchMode(PDO::FETCH_OBJ);
                while ($row1 = $result4->fetch()) {
                    if ($row1->district_id == $row->district_id)
                        print '<option value=' . $row1->district_id . ' selected>' . $row1->district . '</option>';
                    else
                        print '<option value=' . $row1->district_id . '>' . $row1->district . '</option>';
                }
                ?>
            </select>
        </td>
    </tr>
    <tr>
        <td>Name of School Attending</td>
        <td colspan="2"><input type="text" name="school_name" required="true"></td>
    </tr>
    <tr>
        <td>School District</td>
        <td colspan="2" required="true">
            <select name="sch_district">
                <option></option>
                <?php
                $query1 = "Select district,district_id from district";
                $result4 = $dbh->query($query1);
                $result4->setFetchMode(PDO::FETCH_OBJ);
                while ($row1 = $result4->fetch()) {
                    print '<option value=' . $row1->district_id . '>' . $row1->district . '</option>';
                }
                ?>
            </select>
        </td>
    </tr>
    <tr>
        <td>Year/Grade</td>
        <td colspan="2">
            <select name="grade" required="true">
                <option></option>
                <?php
                $query2 = "Select grade_id,grade from grade";
                $result5 = $dbh->query($query2);
                $result5->setFetchMode(PDO::FETCH_OBJ);
                while ($row1 = $result5->fetch()) {
                   print '<option value=' . $row1->grade_id . '.>' . $row1->grade . '</option>';
                }
                ?>
            </select>
        </td>
        <td>
    <center>
        <input type="file" name="browse" id="browse" size="10">
    </center>
    </td>
    </tr>
    <tr>
        <td colspan='3'></td>
        <td>
    <center>
        <input type='button' name='upload' id='upload' class='btn' value='Upload'>
        <input type='button' name='remove' id='remove' class='btn' value='Remove' onclick="delete_photo();">
    </center>
    </td>
    </tr>

    <tr><td colspan="4"><hr></td></tr>
    <tr>
        <td colspan="4"><b><h4>Father</h4></b></td>
    </tr>
    <tr>
        <td>Name</td>
        <td><input type="text" name="father_name" value='<?= $row->father_name ?>'></td>
        <td>Occupation</td>
        <td><input type="text" name="father_occ" value='<?= $row->father_occupation ?>'></td>
    </tr>
    <tr>
        <td>Mobile</td>
        <td><input type="tel" name="father_mobile" value='<?= $row->father_mobile ?>'></td>
        <td>Tel(Office)</td>
        <td><input type="tel" name="father_off_tel" value='<?= $row->father_off_tel ?>'></td>
    </tr>

    <tr><td colspan="4"><hr></td></tr>
    <tr>
        <td colspan="4"><b><h4>Mother</h4></b></td>
    </tr>
    <tr>
        <td>Name</td>
        <td><input type="text" name="mother_name" value='<?= $row->mother_name ?>'></td>
        <td>Occupation</td>
        <td><input type="text" name="mother_occ" value='<?= $row->father_occupation ?>'></td>
    </tr>
    <tr>
        <td>Mobile</td>
        <td><input type="tel" name="mother_mobile" value='<?= $row->mother_mobile ?>'></td>
        <td>Tel(Office)</td>
        <td><input type="tel" name="mother_off_tel" value='<?= $row->mother_off_tel ?>'></td>
    </tr>

    <tr><td colspan="4"><hr></td></tr>
    <tr>
        <td colspan="4"><b><h4>Guardian</h4></b></td>
    </tr>
    <tr>
        <td>Name</td>
        <td><input type="text" name="guard_name" value='<?= $row->guardian_name ?>'></td>
        <td>Occupation</td>
        <td><input type="text" name="guard_occ" value='<?= $row->guardian_occupation ?>'></td>
    </tr>
    <tr>
        <td>Relationship</td>
        <td><input type="text" name="guard_relationship" value='<?= $row->guardian_relationship ?>'></td>
        <td>Tel(Home)</td>
        <td><input type="tel" name="guard_tel_home" value='<?= $row->guardian_home_tel ?>'></td>
    </tr>
    <tr>
        <td>Mobile</td>
        <td><input type="tel" name="guard_mobile" value='<?= $row->guardian_mobile ?>'></td>
        <td>Tel(Office)</td>
        <td><input type="tel" name="guard_off_tel" value='<?= $row->guardian_off_tel ?>'></td>
    </tr>

    <tr><td colspan="4"><hr></td></tr>
    <tr>
        <td colspan="4"><b><h4>Emergency Contact Person</h4></b></td>
    </tr>
    <tr>
        <td>Name</td>
        <td><input type="text" name="eme_name" value='<?= $row->eme_contact_name ?>'></td>
        <td>Contact No.</td>
        <td><input type="tel" name="eme_contact_no" value='<?= $row->eme_contact_number ?>'></td>
    </tr>
    <tr>
        <td>Relationship</td>
        <td colspan="3"><input type="text" name="eme_relationship" value='<?= $row->eme_contact_relationship ?>'></td>
    </tr>

    <tr><td colspan="4"><hr></td></tr>
    <tr>
        <td><b><h4>Diagnoses</h4></b></td>
        <td><button type="button" class="btn" id="diagnoses_btn" data-toggle="modal" data-target="#diagnoses"><i class="icon-plus" ></i> Add</button></td>
        <td><b><h4>Intellectual Functioning </h4></b></td>
        <td><button type="button" class="btn" id="add_aspect_btn" data-toggle="modal" data-target="#add_aspect"><i class="icon-plus" ></i> Add</button></td>
    </tr>
    <tr>
        <td colspan="2">
            <table id="Add_Diagnoses" style="width: 80%;border: 1px solid #dddddd;margin-left: 40px;margin-bottom: 10px;margin-top: 10px;margin-right: 10px;" >

            </table>
        </td>
        <td colspan="2">
            <table id="Add_Aspect" style="width: 80%;border: 1px solid #dddddd;margin-left: 40px;margin-bottom: 10px;margin-top: 10px;margin-right: 10px;" >

            </table>
        </td>
    </tr>
    <?php
    $query7 = "Select stu_doc_id,stu_linking_id,refer_by,assessed_by,assessed_doc,assessed_date
                        from student_document where stu_linking_id=(Select root_id from student where linking_id='$linking_id')";
    $query8 = "Select count(*) as num from student_document where stu_linking_id=(Select root_id from student where linking_id='$linking_id')";
    $result7 = $dbh->query($query7);

    $result8 = $dbh->query($query8);
    $result8->setFetchMode(PDO::FETCH_OBJ);
    $no_of_doc = $result8->fetch()->num;

    if ($result7->rowcount() != 0) {
        $result7->setFetchMode(PDO::FETCH_OBJ);
        while ($row7 = $result7->fetch()) {
            $i = 0;
            ?>
            <tr>
                <td>Refer to</td>
                <td><input type="text" name="refer_by[]" value="<?= $row7->refer_by ?>"></td>
                <td>Assessed By</td>
                <td><input type="text" name="assessed_by[]" value="<?= $row7->assessed_by ?>"></td>
            </tr>
            <tr>
                <td>Assessed date</td>
                <td>
                    <div class="input-append date-picker">
                        <input type="text" name="assessed_date[]" class="dateISO" value="<?= $row7->assessed_date ?>">
                        <span class="add-on">
                            <i class="icon-calendar" data-date-icon="icon-calendar" data-time-icon="icon-time"></i>
                        </span>
                    </div>
                </td>
                <td>Assessed document</td>
                <td colspan="3">
                    <div class="fileupload fileupload-new" style="margin:0px" data-provides="fileupload">
                        <div class="input-append">
                            <div class="uneditable-input ">
                                <i class="icon-file fileupload-exists"></i>
                                <span class="fileupload-preview"><a href="<?= $row7->assessed_doc ?>" target="_blank"><?= $row7->assessed_doc ?></a></span>
                            </div>
                            <span class="btn btn-file">
                                <span class="fileupload-new">Select file</span>
                                <span class="fileupload-exists">Change</span>
                                <input type="file" name="assessed_doc<?= $i ?>">
                                <?php if ($i == 0) { ?>
                                    <input type='hidden' name='i' id='i' value='<?= $no_of_doc ?>' >
            <?php } ?>
                            </span>
                            <a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
                        </div>
                    </div>
                </td>
            </tr>
            <?php
            $i++;
        }
    } else {
        ?>
        <tr>
            <td>Refer to</td>
            <td><input type="text" name="refer_by[]"></td>
            <td>Assessed By</td>
            <td><input type="text" name="assessed_by[]"></td>
        </tr>
        <tr>
            <td>Assessed date</td>
            <td>
                <div class="input-append date-picker">
                    <input type="text" name="assessed_date[]" class="dateISO">
                    <span class="add-on">
                        <i class="icon-calendar" data-date-icon="icon-calendar" data-time-icon="icon-time"></i>
                    </span>
                </div>
            </td>

            <td>Assessed document</td>
            <td colspan="3">
                <div class="fileupload fileupload-new" style="margin:0px" data-provides="fileupload">
                    <div class="input-append">
                        <div class="uneditable-input ">
                            <i class="icon-file fileupload-exists"></i>
                            <span class="fileupload-preview"><a href="diagnose_report/<? //= $attachment[$attribute]                     ?>" target="_blank"><? //= $attachment[$attribute]                  ?></a></span>
                        </div>
                        <span class="btn btn-file">
                            <span class="fileupload-new">Select file</span>
                            <span class="fileupload-exists">Change</span>
                            <input type="file" name="assessed_doc<?= $i ?>">
        <?php $i++; ?>
                            <input type='hidden' name='i' id='i' value='<?= $i ?>' >
                        </span>
                        <a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
                    </div>
                </div>
            </td>
        </tr>
        <?php
    }
    ?>
    <tbody id='add_thing2'></tbody>
    <tr>
        <td colspan="4"><input type="button" class="btn" name="add_assessed" id="add_assessed" value="Add a record"></td>
    </tr>


    <tr>
        <td>Medication</td>
        <td colspan="4"><textarea name="medication"><?= $row->medication ?></textarea></td>
    </tr>
    <tr><td colspan="4"><hr></td></tr>
    <tr><td colspan="4"><b><h4>Assessment Result</h4></b></td></tr>

    <tr><td colspan="4"><hr></td></tr>
    <tr><td colspan="4"><b><h4>Subsidy</h4></b></td></tr>
    <tr>
        <td>
            <select name="select_subsidy" id="subsidy">
                <option value="1">None</option>
                <option value="2">Subsidy Rate</option>
            </select>
        </td>
        <td colspan="3"><input type="text" name="subsidy_pecent" id="subsidy_percent" value="0%" readonly="true"></td>
    </tr>
    <tr>
    <tbody id="subsidy_show"></tbody>
    </tr>
    <tr>
        <td>Traveling Allowance </td>
        <td colspan="3">
            <select name="traveling_allowance" required="true">
                <option></option>
                <?php
                if ($row->traveling_allowance == 1) {
                    ?>
                    <option value="1" selected>Yes</option>
                    <option value="0">No</option>
                    <?php
                } else {
                    ?>
                    <option value="1">Yes</option>
                    <option value="0" selected>No</option>
                    <?php
                }
                ?>
            </select>
        </td>
    </tr>
    </table>
    <input type="submit" name="submit" class="btn" value="Save">
    <input type="button" value="Back" class="btn" onclick="history.back()"/>
    <div style="display: none;" class="modal fade" id="add_aspect" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4>Addidtional aspects</h4>
                </div>
                <div class="modal-body">
                    <table border="0">
                        <?php
                        $check = FALSE;
                        $query3 = "Select aspect_id,aspect_name from additional_aspect";
                        $result6 = $dbh->query($query3);
                        $result6->setFetchMode(PDO::FETCH_OBJ);
                        while ($row = $result6->fetch()) {
                            $result3 = $dbh->query($query_init3);
                            $result3->setFetchMode(PDO::FETCH_OBJ); //aspect
                            print '<tr>';
                            print '<td>';
                            while ($row1 = $result3->fetch()) {
                                if ($row1->aspect_id == $row->aspect_id)
                                    $check = TRUE;
                            }
                            if ($check == TRUE) {
                                print '<input type="checkbox" name="add_aspect[]" value="' . $row->aspect_id . '" checked>' . $row->aspect_name;
                                print '<input type="hidden" name="add_aspectval[]" value="' . $row->aspect_name . '" >';
                            } else {
                                print '<input type="checkbox" name="add_aspect[]" value="' . $row->aspect_id . '">' . $row->aspect_name;
                                print '<input type="hidden" name="add_aspectval[]" value="' . $row->aspect_name . '" >';
                            }
                            print '</td>';
                            print '</tr>';
                            $check = FALSE;
                        }
                        ?>
                    </table>
                </div>
                <div class="modal-footer">
                    <input type="button" name="submit_aspect" class="btn" value="Add" data-dismiss="modal" onclick="Add_aspect();">
                </div>
            </div>
        </div>
    </div>

    <div style="display: none;" class="modal fade" id="diagnoses" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4>Diagnoses</h4>
                </div>
                <div class="modal-body">
                    <table border="0">
                        <?php
                        $query3 = "Select diagnose_id,diagnose_name from diagnose";
                        $result30 = $dbh->query($query3);
                        $result30->setFetchMode(PDO::FETCH_OBJ);
                        while ($row = $result30->fetch()) {
                            $result2 = $dbh->query($query_init2);
                            $result2->setFetchMode(PDO::FETCH_OBJ); //diagnose
                            print '<tr>';
                            print '<td>';
                            while ($row_init2 = $result2->fetch()) {
                                if ($row_init2->diagnose_id == $row->diagnose_id) {
                                    $check = TRUE;
                                }
                            }
                            if ($check == TRUE) {
                                print '<input type="checkbox" name="diagnose[]" value="' . $row->diagnose_id . '" checked>' . $row->diagnose_name;
                                print '<input type="hidden" name="diagnoseval[]" value="' . $row->diagnose_name . '" >';
                            } else {
                                print '<input type="checkbox" name="diagnose[]" value="' . $row->diagnose_id . '">' . $row->diagnose_name;
                                print '<input type="hidden" name="diagnoseval[]" value="' . $row->diagnose_name . '" >';
                            }
                            print '</td>';
                            print '</tr>';
                            $check = FALSE;
                        }
                        ?>
                    </table>
                </div>
                <div class="modal-footer">
                    <input type="button" name="submit_diagnose" class="btn" value="Add" data-dismiss="modal" onclick="Add_Diagnoses();">
                </div>
            </div>
        </div>
    </div>
    </form>
    </div> <!-- /container -->
    </body>
    </html>
    <?php
}
?>

Youez - 2016 - github.com/yon3zu
LinuXploit