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/old20140407/staff/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/(Del)pathways.org.hk/MIS20140127/old20140407/staff/form.php
<?php
define("UPLOAD_DIR", "upload/");

/////Connect DB here~~
include_once '../include/DBConnect.php';

class Staff {

    public static function statusOptions() {
        return array(
            1 => 'Active',
            2 => 'Inactive',
        );
    }

    public static function workingModeOptions() {
        return array(
            1 => 'Monthly based',
            2 => 'Hourly based',
            3 => 'Volunteer'
        );
    }

    public static function attendanceLeaveOptions() {
        return array(
            1 => 'Teacher Sick Leave',
            2 => 'Annual Leave',
            3 => 'Casual Leave',
            4 => 'Students absent',
            5 => 'No pay Lesson',
        );
    }

}

class General {

    public static function fields() {
        return array(
            'id', 'createby', 'createdate', 'lastupby', 'lastupdate',
        );
    }

    public static function genderOptions() {
        return array(
            1 => 'Male',
            2 => 'Female',
        );
    }

}

class FileLimite {

    public static function MaxSize() {
        $MaxFileSize = 1024 * 1024;   //1MB
        return $MaxFileSize;
    }

    public static function FileType() {
        return array(
            1 => 'pdf',
            2 => 'doc',
            3 => 'jpg',
            4 => 'sql'
        );
    }

}

$deleted = 0;
date_default_timezone_set("Hongkong");
$today = date("Y-m-d");
$currentLocation = '';
$SHCreateDate = "";
$SHCreateBy = "";
$action = 'Insert';
$SVersion = -1;
$is_disabled = "";


// Select Campus option from mis_campus
$query = "select * from campus where deleted = ? ORDER BY sort";
$result = $dbh->prepare($query);
$result->bindParam(1, $deleted);
$result->execute();
$campuses = $result->fetchAll();

// Select Position option from staff_position
$query = "select * from position where deleted = ? ORDER BY sort";
$result = $dbh->prepare($query);
$result->bindParam(1, $deleted);
$result->execute();
$staff_positions = $result->fetchAll();

// Select Program option from program
$query = "select * from program where deleted = ? ORDER BY sort";
$result = $dbh->prepare($query);
$result->bindParam(1, $deleted);
$result->execute();
$programs = $result->fetchAll();

// Select Subject option from subject
$query = "select * from subject where deleted = ? ORDER BY sort";
$result = $dbh->prepare($query);
$result->bindParam(1, $deleted);
$result->execute();
$subjects = $result->fetchAll();

// Set Staff Status Options
$staffStatusOptions = Staff::statusOptions();
// Set F/M option
$genderOptions = General::genderOptions();

///////////////////////////////////////////
////////////////Before Read////////////////
///$_GET is used in modification(update),//
////$_POST is used in submition(insert)////
if ($_GET) {
    $seachID = $_GET['staff_id'];
    $action = $_GET['action'];
    //var_dump($seachID);

    $query = "SELECT * FROM `staff` WHERE `staff_id` = '$seachID' "; //AND `deleted` = '$deleted'
    $result = $dbh->prepare($query);
    $result->execute();
    while ($ResultSet = $result->fetch(PDO::FETCH_ASSOC)) {
        $RootID = $ResultSet['root_id'];
        $staff_code = $ResultSet['staff_code'];
        //var_dump($RootID);
        $HadDelete = $ResultSet['deleted'];
        $status = $ResultSet['status'];
        $join_date = $ResultSet['join_date'];

        //var_dump($join_date);
        //$registration_date = date('Y-m-d',  strtotime($ResultSet['registration_date']));
        $registration_date = $ResultSet['registration_date'];
        $last_name = $ResultSet['last_name'];
        $first_name = $ResultSet['first_name'];
        $ch_name = $ResultSet['ch_name'];
        $gender = $ResultSet['gender'];
        $date_of_brith = $ResultSet['date_of_brith'];
        //$date_of_brith = date('Y-m-d',  strtotime($ResultSet['date_of_brith']));
        $home_tel = $ResultSet['home_tel'];
        $mobile = $ResultSet['mobile'];
        $email = $ResultSet['email'];
        $address = $ResultSet['address'];
        $address2 = $ResultSet['address2'];
        $address3 = $ResultSet['address3'];
        $refer_by = $ResultSet['refer_by'];

        $remarks = $ResultSet['remarks'];
    }

    $query = "SELECT * 
FROM  `staff_salary_history` 
WHERE  `staff_id` =  '$RootID' and deleted=0 and version=(Select Max(version) from staff_salary_history where staff_id=$RootID)"; //AND `deleted` = '$deleted'
    $result = $dbh->prepare($query);
    $result->execute();
    while ($ResultSet = $result->fetch(PDO::FETCH_ASSOC)) {
        $SH_ID = $ResultSet['staff_his_id'];

        $position_id = $ResultSet['position_id'];
        $is_monthly = $ResultSet['is_monthly'];
        $is_volunteer = $ResultSet['is_volunteer'];
        $is_hourly = $ResultSet['is_hourly'];

        $SHCreateDate = $ResultSet['createdate'];
        $SHCreateBy = $ResultSet['createby'];
        $SVersion = $ResultSet['version'];
        $salary = $ResultSet['salary'];
        $rate1 = $ResultSet['rate1'];
        $rate2 = $ResultSet['rate2'];
        $rate3 = $ResultSet['rate3'];
        $rate4 = $ResultSet['rate4'];
        $rate5 = $ResultSet['rate5'];
        $rate6 = $ResultSet['rate6'];
        $other_rate = $ResultSet['other_rate_desc'];
    }

    $query = "SELECT * FROM `staff_education`  WHERE `staff_id` = '$seachID' AND `deleted` = '$deleted'";
    $result = $dbh->prepare($query);
    $result->execute();
    $staff_edu = $result->fetchAll();

    $query = "SELECT * FROM `staff_experience`  WHERE `staff_id` = '$seachID' AND `deleted` = '$deleted'";
    $result = $dbh->prepare($query);
    $result->execute();
    $staff_exp = $result->fetchAll();

    $query = "SELECT * FROM `staff_training`  WHERE `staff_id` = '$seachID' AND `deleted` = '$deleted'";
    $result = $dbh->prepare($query);
    $result->execute();
    $staff_train = $result->fetchAll();

    $query = "SELECT * FROM `staff_attachment` WHERE `staff_id` = '$seachID' AND `deleted` = '$deleted'";
    $result = $dbh->prepare($query);
    $result->execute();
    $staff_attachments = $result->fetchAll();

    //History Record , program & subject
    //Resave Data, if no permission to Edit
    $query = "SELECT * FROM `staff_program` WHERE `staff_id` = '$SH_ID' AND `deleted` = '$deleted'";
    $result = $dbh->prepare($query);
    $result->execute();
    $programTemp = $result->fetchAll();
    //var_dump($programTemp);

    $query = "SELECT * FROM `staff_subject` WHERE `staff_id` = '$SH_ID' AND `deleted` = '$deleted'";
    $result = $dbh->prepare($query);
    $result->execute();
    $subjectTemp = $result->fetchAll();
    //var_dump($subjectTemp);
}

$clicked = 0;
if ($_POST) {
    //var_dump($clicked);
    $clicked++;
    if ($clicked != 1)
        return;
    if (isset($RootID)) {
//        var_dump($seachID);
        $deleted = 1;
        $sth = $dbh->prepare("UPDATE `staff` SET `deleted`= '$deleted' WHERE `root_id` = '$RootID'");
        $sth->execute();
    }

    $test = "POST";
    $RID = $_POST['TempRootID'];

    $status = $_POST['status'];
    $join_date = $_POST['join_date'];
    $registration_date = $today; //$_POST['registration_date'];
    $last_name = $_POST['last_name'];
    $first_name = $_POST['first_name'];
    $zh_name = $_POST['zh_name'];
    $gender = $_POST['gender'];
    $dob = $_POST['dob'];
    $tel = $_POST['tel'];
    $mobile = $_POST['mobile'];
    $email = $_POST['email'];
    $address = $_POST['address'];
    $address2 = $_POST['address2'];
    $address3 = $_POST['address3'];
    $refer_by = $_POST['refer_by'];//$_SESSION['MIS_login']['loginname'];
    //var_dump($refer_by);

    /* if it have permission to edit mode OR insertion of new record, 
     * Salary information will pass by $_POST, else it will use the 
     * Salary information had got above
     */
    if (isset($_POST['salary'])) {
//        $W = "Having Permission";
//        var_dump($W);
        $position_id = $_POST['position_id'];
        $salary = $_POST['salary'];
        $rate1 = $_POST['rate1'];
        $rate2 = $_POST['rate2'];
        $rate3 = $_POST['rate3'];
        $rate4 = $_POST['rate4'];
        $rate5 = $_POST['rate5'];
        $rate6 = $_POST['rate6'];
        $other_rate = $_POST['rate6_other'];
        $is_monthly = 0;
        $is_hourly = 0;
        $is_volunteer = 0;
        if (isset($_POST['workingMode'])) {
            $WorkingModeChecked = $_POST['workingMode'];
            foreach ($WorkingModeChecked as $WMChecked) {
                if ($WMChecked == 1)
                    $is_monthly = 1;
                if ($WMChecked == 2)
                    $is_hourly = 1;
                if ($WMChecked == 3)
                    $is_volunteer = 1;
            }
        }
    } else {
        /* In the case user have not permission to Edit Salary information,
         * it will resave the previous Salary information in new record,
         * we need to delete the previous Salary record in `staff_salary_history`
         */
        $deleted = 1;
        $sth = $dbh->prepare("UPDATE `staff_salary_history` SET `deleted`= '$deleted' WHERE `staff_id` = '$RootID'");
        $sth->execute();

        $W = "NO PERMISSION";
        $deleted = 0;
    }
    $remarks = ''; //$_POST['remarks'];
    //Checking which working mode checked
    ////base data define
    $currentStaff;
    date_default_timezone_set("Hongkong");
    $today = date("Y-m-d H:i:s");
    $createby = 0;
    $actived = 1;
    $deleted = 0;

    //Reset root_id 
    if ($RID == 0) {
        $RID = NULL;
    }
    if ($SVersion != -1) {

        $deleted = 1;
        $sth = $dbh->prepare("UPDATE `staff_salary_history` SET `deleted`= '$deleted' WHERE `staff_id` = '$RootID' and `version`='$SVersion'");
        $sth->execute();
        $deleted = 0;
    }
    if ($action == "Insert")
        $SVersion = 1;
    if (isset($_POST['EditWay'])) {
        if ($_POST['EditWay'] == 2)
            $SVersion++;
    }

    $sth = $dbh->prepare("INSERT INTO `staff`(`createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `status`, `join_date`, `registration_date`, `last_name`, `first_name`, `ch_name`, `gender`, `date_of_brith`, `home_tel`, `mobile`, `email`, `address`, `address2`, `address3`, `refer_by`, `remarks`, `root_id`) VALUES 
($createby,'$today',$createby,'$today',$actived,$deleted,'$status','$join_date','$registration_date','$last_name','$first_name','$zh_name','$gender','$dob','$tel','$mobile','$email','$address','$address2','$address3','$refer_by','$remarks','$RID')");
    $sth->execute();

    //find root_id,staff_id,staff_code from the inserted record
    $sth = $dbh->prepare("SELECT  `staff_id`,`root_id`,`staff_code` FROM  `staff` WHERE  `createdate` =  '$today' AND `last_name` = '$last_name'");
    $sth->execute();
    while ($ResultSet = $sth->fetch(PDO::FETCH_ASSOC)) {
        $currentStaff = $ResultSet['staff_id'];
        $rootID = $ResultSet['root_id'];
        $staff_code = $ResultSet['staff_code'];
    }

    ///////////////////Setting Root ID//////////////////////////
    //if No root_id, that is a new user, staff_id become root_id 
    if ($rootID == null || $rootID == 0) {
        $sth = $dbh->prepare("UPDATE `staff` SET `root_id`= '$currentStaff' WHERE `staff_id` = '$currentStaff'");
        $sth->execute();
    }
    //Setting Staff code by new root id, and Format
    if ($staff_code == null) {
        $sth = $dbh->prepare("SELECT `root_id` FROM  `staff`  WHERE `staff_id` = '$currentStaff'");
        $sth->execute();
        if ($ResultSet = $sth->fetch(PDO::FETCH_ASSOC)) {
            $rootID = $ResultSet['root_id'];
        }
        $staff_code = "S" . $currentLocation;
        if ($rootID < 10)
            $staff_code .= '000';
        else if ($rootID < 100)
            $staff_code .= '00';
        else if ($rootID < 1000)
            $staff_code .= '0';
        $staff_code .= $rootID;

        $sth = $dbh->prepare("UPDATE `staff` SET `staff_code`= '$staff_code' WHERE `staff_id` = '$currentStaff'");
        $sth->execute();
    }
    //Insert campus record
    if (isset($_POST['campus'])) {
        $CampusesChecked = $_POST['campus'];
        foreach ($CampusesChecked as $campusChecked) {
            $sth = $dbh->prepare("INSERT INTO `staff_campus`( `staff_id`, `createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `campus_id`) VALUES ('$currentStaff','$createby','$today','$createby','$today','$actived','$deleted','$campusChecked')");
            $sth->execute();
        }
    }

    /////////////////////////////////////////////
    //Insertion of multi-selection information //
    /////////////////////////////////////////////
    //Insert Salary
    if ($SHCreateDate == "") {
        $SHCreateDate = $today;
        $SHCreateBy = $refer_by;
    } else {
        $SHCreateDate = $SHCreateDate;
        $SHCreateBy = $SHCreateBy;
    }
    $sth = $dbh->prepare("INSERT INTO `staff_salary_history`( `staff_id`, `createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `salary`, `rate1`, `rate2`, `rate3`, `rate4`, `rate5`, `rate6`, `other_rate_desc`,`version`,`position_id`,`is_monthly`,`is_volunteer`,`is_hourly`) 
                                    VALUES ('$rootID','$SHCreateBy','$SHCreateDate','$createby','$today','$actived','$deleted','$salary','$rate1','$rate2','$rate3','$rate4','$rate5','$rate6','$other_rate','$SVersion','$position_id','$is_monthly','$is_volunteer','$is_hourly')");
    $sth->execute();

    //Select SH_ID, Used to INSERT `programs` and `subject` Record
    $sth = $dbh->prepare("SELECT * 
FROM  `staff_salary_history` 
WHERE  `staff_id` =  '$rootID' and deleted=0 and version=(Select Max(version) from staff_salary_history where staff_id=$rootID)");
    $sth->execute();
    while ($ResultSet = $sth->fetch(PDO::FETCH_ASSOC)) {
        $SH_ID = $ResultSet['staff_his_id'];
    }
    //IF HAVING PERMISSION
    if (isset($_POST['salary'])) {
        //Insert programs record
        if (isset($_POST['programs'])) {
            $ProgramsChecked = $_POST['programs'];
            foreach ($ProgramsChecked as $programChecked) {
                $sth = $dbh->prepare("INSERT INTO `staff_program`(`staff_id`, `createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `program_id`) VALUES ('$SH_ID','$createby','$today','$createby','$today','$actived','$deleted','$programChecked')");
                $sth->execute();
            }
        }
        //Insert subjects record
        if (isset($_POST['subjects'])) {
            $SubjectsChecked = $_POST['subjects'];
            foreach ($SubjectsChecked as $subjectChecked) {
                $sth = $dbh->prepare("INSERT INTO `staff_subject`(`staff_id`, `createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `subject_id`) VALUES ('$SH_ID','$createby','$today','$createby','$today','$actived','$deleted','$subjectChecked')");
                $sth->execute();
            }
        }
    } else {
        //NO Permission Case, re-insert data from $programTemp & $subjectTemp(pervious data)
        foreach ($programTemp as $program) {
            $ProID = $program['program_id'];
            $sth = $dbh->prepare("INSERT INTO `staff_program`(`staff_id`, `createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `program_id`) VALUES ('$SH_ID','$createby','$today','$createby','$today','$actived','$deleted','$ProID')");
            $sth->execute();
        }
        foreach ($subjectTemp as $subject) {
            $SubID = $subject['subject_id'];
            $sth = $dbh->prepare("INSERT INTO `staff_subject`(`staff_id`, `createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `subject_id`) VALUES ('$SH_ID','$createby','$today','$createby','$today','$actived','$deleted','$SubID')");
            $sth->execute();
        }
    }
    //var_dump($currentStaff);
    //Get an array, staff
    if (isset($_POST['staff'])) {
        $StaffData = $_POST['staff'];
        //var_dump($StaffData);
        //Insert educations record
        if (isset($StaffData['educations'])) {
            $eduRecord = $StaffData['educations'];
            foreach ($eduRecord as $edu) {
                $edu_Sdate = $edu['Sdate'];
                $edu_Edate = $edu['Edate'];
                $edu_desc = $edu['desc'];
                if ($edu_desc != "") {
                    $sth = $dbh->prepare("INSERT INTO `staff_education`( `staff_id`, `createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `start_date`, `end_date`, `education`) VALUES ('$currentStaff','$createby','$today','$createby','$today','$actived','$deleted','$edu_Sdate','$edu_Edate','$edu_desc')");
                    $sth->execute();
                }
            }
        }
        //Insert Experiences record
        if (isset($StaffData['experiences'])) {
            $expRecord = $StaffData['experiences'];
            foreach ($expRecord as $exp) {
                $exp_Sdate = $exp['Sdate'];
                $exp_Edate = $exp['Edate'];
                $exp_desc = $exp['desc'];
                if ($exp_desc != "") {
                    $sth = $dbh->prepare("INSERT INTO `staff_experience`(`staff_id`, `createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `start_date`, `end_date`, `remarks`) VALUES ('$currentStaff','$createby','$today','$createby','$today','$actived','$deleted','$exp_Sdate','$exp_Edate','$exp_desc')");
                    $sth->execute();
                }
            }
        }
        //Insert Trainings record
        if (isset($StaffData['trainings'])) {
            $traRecored = $StaffData['trainings'];
            foreach ($traRecored as $tra) {
                $tra_Sdate = $tra['Sdate'];
                $tra_Edate = $tra['Edate'];
                $tra_desc = $tra['desc'];
                if ($tra_desc != "") {
                    $sth = $dbh->prepare("INSERT INTO `staff_training`( `staff_id`, `createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `start_date`, `end_date`, `remarks`) VALUES ('$currentStaff','$createby','$today','$createby','$today','$actived','$deleted','$tra_Sdate','$tra_Edate','$tra_desc')");
                    $sth->execute();
                }
            }
        }
        //Insert Attachments record
        if (isset($StaffData['attachments'])) {
            $attRecord = $StaffData['attachments'];
            foreach ($attRecord as $key => $att) {

                $att_other = $att['other'];
                $file = "ATT_" . ($key - 1);
                //var_dump($file);
                //var_dump(isset($_FILES[$file]));
                if (isset($att['pdf'])) {
                    $att_pdf = $att['pdf'];
                    $sth = $dbh->prepare("INSERT INTO `staff_attachment`( `staff_id`, `createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `pdf`, `remarks`) VALUES ('$currentStaff','$createby','$today','$createby','$today','$actived','$deleted','$att_pdf','$att_other')");
                    $sth->execute();
                }

                if (isset($_FILES[$file])) {
                    $myFile = $_FILES[$file];
                    //var_dump($myFile);
                    if ($myFile['name'] != "") {
                        //var_dump($myFile);
                        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
                        $i = 0;
                        $parts = pathinfo($name);
                        while (file_exists(UPLOAD_DIR . $name)) {
                            $i++;
                            $name = $parts["filename"] . "-" . $i . "." . $parts["extension"];
                        }

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

                        // set proper permissions on the new file
                        chmod(UPLOAD_DIR . $name, 0644);
                        $sth = $dbh->prepare("INSERT INTO `staff_attachment`( `staff_id`, `createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `pdf`, `remarks`) VALUES ('$currentStaff','$createby','$today','$createby','$today','$actived','$deleted','$name','$att_other')");
                        $sth->execute();
                    }
                }
            }
        }
    }

    //Output result of submittion
    $result = ($_GET) ? "Update data successful." : "Insert data successful.The Staff Code is $staff_code";
    echo "<script>alert('" . $result . "');</script>";
    echo "<script>location.href = 'index.php';</script>";
}
?>
<!DOCTYPE html>
<html>
    <head>
        <?php require_once '../include/head.php';      ?>
        <?php require_once '../include/checkuser.php'; ?>
        <?php require_once '../include/Nav_bar.php';   ?>  

        <script>
            var MaxFileSize = <?= FileLimite::MaxSize() ?>;
            function CheckFileSize(FileID) {
                //alert('Setted EventListener for ' + FileID);
                document.getElementById(FileID).addEventListener('change', checkFile, false);
            }
            ;
            function checkFile(e) {
                var file_list = e.target.files;
                for (var i = 0, file; file = file_list[i]; i++) {
                    var sFileName = file.name;
                    var sFileExtension = sFileName.split('.')[sFileName.split('.').length - 1].toLowerCase();
                    var iFileSize = file.size;
                    var iConvert = (file.size / 1048576).toFixed(2);
                    var worngExtension = true;
                    //compare all limited file types, worngExtension = false if same 
                    var LimitedType = <?php echo json_encode(FileLimite::FileType()); ?>;
                    jQuery.each(LimitedType, function(i, val) {
                        //alert(i + ": " + val);
                        if (sFileExtension == val)
                            worngExtension = false;
                    });
                    //handle worng file
                    if (iFileSize > MaxFileSize || worngExtension) {
                        //warning message to user
                        txt = (iFileSize > MaxFileSize) ? 'Your file size is too large,\n' : '';
                        txt += (worngExtension) ? 'file format is not allowed.' : '';
                        txt += "\n\nFile type : " + sFileExtension + "\n\n";
                        //txt += "FileSize: " + iFileSize + "\n\n";
                        txt += "Size: " + iConvert + " MB (" + iFileSize + ") \n\n";
                        txt += "Please make sure your file is in pdf format and less than 1 MB.\n\n";
                        alert(txt);
                        var DeleteID = 'Remove_' + e.target.id;
                        //clicking the remove button to remove the file
                        document.getElementById(DeleteID).click();
                        var TempID = e.target.id + '_Temp';
                        //get the previous File(for editing record)
                        var previousFile = $('#' + TempID).val();
                        //if previous file found, reset the file
                        if (previousFile != null) {
                            var PreviewBoxID = e.target.id + '_preview';
                            //set back the layout
                            data = '<a href="upload/' + previousFile + '" target="_blank">' + previousFile + '</a>'
                            $("#" + PreviewBoxID).append(data);
                            $("#Status_" + e.target.id).removeClass('fileupload-new');
                            $("#Status_" + e.target.id).addClass('fileupload-exists');
                        }
                    }
                }
            }
            $(function() {
                $('div input').height(20); //fix size for input box
                $('.date-picker').datetimepicker({pickTime: false});
                $('#registration_date').val('<?= $today ?>'); //Generate by system 
<?php if ($_GET) { ?>
                    $('#TempRootID').val(<?= $RootID ?>);
                    $('#position_id').val(<?= $position_id ?>);
                    $('#status').val(<?= $status ?>);
                    $('#join_date').val('<?= $join_date ?>');
                    $('#registration_date').val('<?= $registration_date ?>');
                    $('#last_name').val('<?= $last_name ?>');
                    $('#first_name').val('<?= $first_name ?>');
                    $('#zh_name').val('<?= $ch_name ?>');
                    $('#dob').val('<?= $date_of_brith ?>');
                    $('#gender').val(<?= $gender ?>);
                    $('#mobile').val('<?= $mobile ?>');
                    $('#tel').val('<?= $home_tel ?>');
                    $('#email').val('<?= $email ?>');
                    $('#address').val('<?= $address ?>');
                    $('#address2').val('<?= $address2 ?>');
                    $('#address3').val('<?= $address3 ?>');
                    $('.refer_by').val('<?= $refer_by ?>');
                    $('.staff_code').val('<?= $staff_code ?>')
                    $('#salary').val('<?= $salary ?>');
                    $('#rate1').val('<?= $rate1 ?>');
                    $('#rate2').val('<?= $rate2 ?>');
                    $('#rate3').val('<?= $rate3 ?>');
                    $('#rate4').val('<?= $rate4 ?>');
                    $('#rate5').val('<?= $rate5 ?>');
                    $('#rate6').val('<?= $rate6 ?>');
                    $('#rate6_other').val('<?= $other_rate ?>');
                    $('#remarks').val('<?= $remarks ?>');
                    //setting workingMode CheckBox
                    is_monthly = <?= $is_monthly ?>;
                    is_hourly = <?= $is_hourly ?>;
                    is_volunteer = <?= $is_volunteer ?>;
                    if (is_monthly == 1)
                        $('input:checkbox[id="workingMode1"]').attr('checked', 'checked');
                    if (is_hourly == 1)
                        $('input:checkbox[id="workingMode2"]').attr('checked', 'checked');
                    if (is_volunteer == 1)
                        $('input:checkbox[id="workingMode3"]').attr('checked', 'checked');
                    $('#delete_btn').click(function()
                    {
                        bootbox.dialog('Are you sure to delete this records?', [
                            {
                                'label': 'Delete',
                                'class': 'btn-danger',
                                'callback': function() {
                                    DeleteID = <?= $seachID ?>;
                                    $.ajax({
                                        url: 'delete/delete.php', //This is the current doc
                                        type: "POST",
                                        data: {Data: DeleteID},
                                        success: function(data) {
                                            var obj = $.parseJSON(data);
                                            location.href = 'index.php'; //reload this page
                                        }

                                    });
                                }
                            },
                            {
                                'label': 'Cancel',
                                'class': 'btn'
                            }
                        ]);
                    })
                            ;
<?php } ?>
            });

            function deleteRow(RowID)
            {
                var element = document.getElementById(RowID);
                //alert("delete " + RowID);
                element.parentNode.removeChild(element);
            }
            ;
            var ClickCount = 0;
            function countClicks() {
                var clickLimit = 1; //Max number of clicks
                if (ClickCount >= clickLimit) {
                    //alert("You can only click this button " + clickLimit + " times.");
                    return false;
                }
                else
                {
                    ClickCount++;
                    return true;
                }
            }
            function disableButton() {
            }
            ;

        </script>
    </head>
    <body>
        <?php
        if ($action == "Insert") {
            //var_dump($action);
            $TName = "Add Staff Record";
            $Bcolor = 'style="background-color:#eeefde"';
        } else {
            //var_dump($action);
            $Bcolor = 'style="background-color:#‎feffde‬"';

            if ($action == "View") {
                $is_disabled = 'disabled';
                $TName = "View Staff Record";
            } else {
                $TName = "Edit Staff Record";
            }
        }
        ?>
        <!-- line between nav bar and content -->
        <div class="text-right">
            <ul class="breadcrumb">
                <!--<li><a href="#">Master</a> <span class="divider">&gt;</span></li>-->
                <li><a href="index.php">Staff</a> <span class="divider">&gt;</span></li>
                <li class="active"><?= $TName ?></li>
            </ul>
        </div>
        <!-- line between nav bar and content -->
        <div class="container-fluid pathways-container" <?= $Bcolor ?> >
            <!-- table 
            <button id="check">check</button>-->
            <h3><?= $TName ?></h3>

            <form  class="form-horizontal" action="" method="post" enctype="multipart/form-data">
                <h5> Staff Information </h5>
                <div class="control-group">
                    <?php $label = 'Campus'; ?>
                    <label class="control-label"><?= $label ?></label>
                    <div class="controls form-inline">
                        <?php
                        foreach ($campuses as $campus) {
                            print '<input type="checkbox" id="campus_' . $campus['campus_id'] . '" name="campus[]"  value="' . $campus['campus_id'] . '" ' . $is_disabled . ' />';
                            print '<label for="campus' . $campus['campus_id'] . '">' . $campus['campus_name'] . '</label>';
                        }
                        ?>
                    </div>
                </div>
                <div class="control-group">
                    <?php
                    $attribute = 'status';
                    $label = 'Status';
                    ?>
                    <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
                    <div class="controls form-inline">
                        <select id="<?= $attribute ?>" name="<?= $attribute ?>" class="required" placeholder="" <?= $is_disabled ?> >
                            <option value=""></option>
                            <?php
                            foreach ($staffStatusOptions as $StatusValue => $status) {
                                print '<option value="' . $StatusValue . '">' . $status . '</option>';
                            }
                            ?>
                        </select>
                    </div>
                </div>
                <div class="control-group">
                    <?php
                    $attribute = 'join_date';
                    $label = 'Join Date';
                    ?>
                    <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
                    <div class="controls form-inline">
                        <div class="input-append date-picker">
                            <input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="dateISO" value="" data-format="yyyy-MM-dd" placeholder="<?= $label ?>" maxlength="200" <?= $is_disabled ?> />
                            <span class="add-on" <?= $action == 'View' ? 'style="visibility:hidden"' : '' ?> ><i data-time-icon="icon-time" data-date-icon="icon-calendar" ></i></span>

                        </div>
                        <?php
                        $attribute = 'registration_date';
                        $label = 'Data Input Date';
                        ?>
                        <label class="control-label" style="float:none" for="<?= $attribute ?>"><?= $label ?></label>
                        <div class="input-append date-picker">
                            <input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="required dateISO" style="margin-left:15px" value="<?= $today ?>" data-format="yyyy-MM-dd" placeholder="<?= $label ?>" maxlength="200" disabled="disabled" />
                            <!--<span class="add-on"><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>-->
                        </div>

                    </div>

                </div>
                <div class="control-group">
                    <?php
                    $attribute = 'staff_code';
                    $label = 'Staff Code'
                    ?>
                    <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
                    <div class="controls form-inline">
                        <input type="text" id="<?= $attribute ?>" name="" class="<?= $attribute ?>" value="<?= $_GET ? '' : 'generate after submit' ?>" placeholder="<?= $label ?>" maxlength="200" disabled="disabled"/>
                        <input type="hidden" id="<?= $attribute ?>" name="<?= $attribute ?>" class="<?= $attribute ?>" value="" placeholder="<?= $label ?>" maxlength="200"/>

                        <?php
                        $attribute = 'refer_by';
                        $label = 'Input By';
                        ?>

                        <label class="control-label" style="float:none"  for="<?= $attribute ?>"><?= $label ?></label>
                        <input type="hidden" id="<?= $attribute ?>" style="margin-left:15px" name="<?= $attribute ?>" class="<?= $attribute ?>" value="<?= $_GET ? '' : $_SESSION['MIS_login']['username']; ?>" placeholder="<?= $label ?>" maxlength="200"/>
                        <input type="text" id="<?= $attribute ?>" style="margin-left:15px" name="" class="<?= $attribute ?>" value="<?= $_GET ? '' : $_SESSION['MIS_login']['username']; ?>" placeholder="<?= $label ?>" maxlength="200" disabled="disabled"/>
                    </div>
                </div>

                <hr />

                <div class="control-group">
                    <?php
                    $attribute = 'last_name';
                    $label = 'Last Name';
                    ?>
                    <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
                    <div class="controls form-inline">
                        <!-- Store the Root ID here, and pass to $_Post after submited -->
                        <input type="hidden" id="TempRootID" name="TempRootID" value="0" />
                        <input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="required" value="" placeholder="<?= $label ?>" maxlength="200" <?= $is_disabled ?> />
                        <?php
                        $attribute = 'first_name';
                        $label = 'First Name';
                        ?>
                        <label class="control-label" style="float:none" for="<?= $attribute ?>"><?= $label ?></label>
                        <input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="required" style="margin-left:15px" value="" placeholder="<?= $label ?>" maxlength="200" <?= $is_disabled ?> />
                    </div>
                </div>
                <div class="control-group">
                    <?php
                    $attribute = 'zh_name';
                    $label = '中文姓名';
                    ?>
                    <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
                    <div class="controls form-inline">
                        <input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="" value="" placeholder="<?= $label ?>" maxlength="200" <?= $is_disabled ?> />
                        <?php
                        $attribute = 'gender';
                        $label = 'Gender';
                        ?>
                        <label class="control-label" style="float:none" for="<?= $attribute ?>"><?= $label ?></label>
                        <select id="<?= $attribute ?>" name="<?= $attribute ?>" class="" style="margin-left:15px" placeholder="<?= $label ?>" <?= $is_disabled ?> >
                            <option value=""></option>
                            <?php foreach ($genderOptions as $genderValue => $genderLabel) { ?>
                                <option value="<?= $genderValue ?>"><?= $genderLabel ?></option>
                            <?php } ?>
                        </select>
                    </div>
                </div>
                <div class="control-group">
                    <?php
                    $attribute = 'dob';
                    $label = 'Date of Birth';
                    ?>
                    <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
                    <div class="controls form-inline">
                        <div class="input-append date-picker">
                            <input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="dateISO" value="" data-format="yyyy-MM-dd" placeholder="<?= $label ?>" maxlength="200" <?= $is_disabled ?> />
                            <span class="add-on" <?= $action == 'View' ? 'style="visibility:hidden"' : '' ?> ><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>
                        </div>
                    </div>
                </div>
                <div class="control-group">
                    <?php
                    $attribute = 'mobile';
                    $label = 'Mobile';
                    ?>
                    <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
                    <div class="controls form-inline">
                        <input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="" value="" placeholder="<?= $label ?>" maxlength="200" <?= $is_disabled ?> />
                        <?php
                        $attribute = 'tel';
                        $label = 'Tel';
                        ?>
                        <label class="control-label" style="float:none" for="<?= $attribute ?>"><?= $label ?></label>
                        <input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="" style="margin-left:15px" value="" placeholder="<?= $label ?>" maxlength="200" <?= $is_disabled ?> />
                    </div>
                </div>
                <div class="control-group">
                    <?php
                    $attribute = 'email';
                    $label = 'E-mail';
                    ?>
                    <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
                    <div class="controls form-inline">
                        <input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="input-xlarge email" value="" placeholder="<?= $label ?>" maxlength="200" <?= $is_disabled ?> />
                    </div>
                </div>
                <div class="control-group">
                    <?php
                    $attribute = 'address';
                    $label = 'Address';
                    ?>
                    <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
                    <div class="controls form-inline">
                        <input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="input-block-level" value="" placeholder="<?= $label ?>" maxlength="200" <?= $is_disabled ?> />
                        <input type="text" id="<?= $attribute ?>2" name="<?= $attribute ?>2" class="input-block-level" value="" placeholder="<?= $label ?>" maxlength="200" <?= $is_disabled ?> />
                        <input type="text" id="<?= $attribute ?>3" name="<?= $attribute ?>3" class="input-block-level" value="" placeholder="<?= $label ?>" maxlength="200" <?= $is_disabled ?> />
                    </div>
                </div>

                <hr />
                <h5>Additional Information</h5>
                <div class="control-group">
                    <?php
                    $attribute = 'EditWay';
                    $label = 'EditWay ';
                    if ($action == "AdminEidt") {
                        ?>
                        <label class="control-label"  for="<?= $attribute ?>"><?= $label ?></label>
                        <div class="controls form-inline">
    <!--                            <select id="<?= $attribute ?>" name="<?= $attribute ?>" class="" <?= ($action == "AdminEidt" || $action == "Insert") ? '' : 'disabled="disabled"' ?>  placeholder="">
                                <option value="1">Update(Cover this record)</option>
                                <option value="2">New(Create new record)</option>
                            </select>-->
                            <a class="btn btn-danger" href="historyfrom.php?root_id=<?= $RootID ?>&action=Insert">New (Create new record)</a>
                            <a href="history_index.php?root_id=<?= $RootID ?>" class="btn btn-danger" <?=
                            $action == "Insert" ? 'style="visibility:hidden"' : '';
                            ($action == "AdminEidt" || $action == "Insert") ? '' : 'disabled="disabled"'
                            ?> >History</a>

                        </div>
                        <hr />
                        <?php
                    };
                    ?>
                </div>

                <div class="control-group">
                    <?php
                    $attribute = 'position_id';
                    $label = 'Position';
                    ?>
                    <label class="control-label"  for="<?= $attribute ?>"><?= $label ?></label>
                    <div class="controls form-inline">
                        <select id="<?= $attribute ?>" name="<?= $attribute ?>" class="" <?= ($action == "AdminEidt" || $action == "Insert") ? '' : 'disabled="disabled"' ?>  placeholder="">
                            <option value=""></option>
                            <?php
                            foreach ($staff_positions as $staff_position) {
                                print '<option value="' . $staff_position['position_id'] . '">' . $staff_position['position_name'] . '</option>';
                            }
                            ?>
                        </select>
                    </div>
                </div>
                <div class="control-group">
                    <?php
                    $attribute = 'programs';
                    $label = 'Programs';
                    ?>
                    <label class="control-label"><?= $label ?></label>
                    <div class="controls form-inline">
                        <?php foreach ($programs as $program) { ?>
                            <input type="checkbox" id="program_<?= $program['program_id'] ?>" name="programs[]" <?= ($action == "AdminEidt" || $action == "Insert") ? '' : 'disabled="disabled"' ?> value="<?= $program['program_id'] ?>"/>
                            <label for="program_<?= $program['program_id'] ?>"><?= $program['program_code'] ?></label>
                        <?php } ?>
                    </div>
                </div>
                <div class="control-group">
                    <?php
                    $attribute = 'subjects';
                    $label = 'Subjects';
                    ?>
                    <label class="control-label"><?= $label ?></label>
                    <div class="controls form-inline">
                        <?php foreach ($subjects as $subject): ?>
                            <input type="checkbox" id="subject_<?= $subject['subject_id'] ?>" name="subjects[]" <?= ($action == "AdminEidt" || $action == "Insert") ? '' : 'disabled="disabled"' ?> value="<?= $subject['subject_id'] ?>"/>
                            <label for="subject_<?= $subject['subject_id'] ?>"><?= $subject['sub_code'] ?></label>
                        <?php endforeach; ?>
                    </div>
                </div>
                <div class="control-group">
                    <?php
                    $attribute = 'working_mode';
                    $label = 'Working Mode';
                    ?>
                    <label class="control-label"><?= $label ?></label>
                    <div class="controls form-inline">
                        <?php foreach (Staff::workingModeOptions() as $value => $label) { ?>
                            <!--                            <label class="radio inline">
                                                            <input type="radio" name="working_mode"  value="<?= $value ?>" />
                            <?= $label ?>
                                                        </label>-->
                            <input type="checkbox" id="workingMode<?= $value ?>"  name="workingMode[]" <?= ($action == "AdminEidt" || $action == "Insert") ? '' : 'disabled="disabled"' ?> value="<?= $value ?>"/>
                            <label for="<?= $label ?>"><?= $label ?></label>
                        <?php } ?>
                    </div>
                </div>

                <h5>Salary</h5>
                <div class="control-group">
                    <?php
                    $attribute = 'salary';
                    $label = 'Salary';
                    ?>
                    <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
                    <div class="controls form-inline">
                        <input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="number" value="" placeholder="<?= $label ?>" <?= ($action == "AdminEidt" || $action == "Insert") ? '' : 'disabled="disabled"' ?> maxlength="200" />
                        <span>By Month</span>
                    </div>
                </div>
                <div class="control-group">
                    <?php
                    $attribute = 'rate1';
                    $label = 'Rate 1';
                    ?>
                    <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
                    <div class="controls form-inline">
                        <input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="number" value="" placeholder="<?= $label ?>" <?= ($action == "AdminEidt" || $action == "Insert") ? '' : 'disabled="disabled"' ?> maxlength="200" />
                        <span>Teacher (In House)</span>
                    </div>
                </div>
                <div class="control-group">
                    <?php
                    $attribute = 'rate2';
                    $label = 'Rate 2';
                    ?>
                    <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
                    <div class="controls form-inline">
                        <input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="number" value="" placeholder="<?= $label ?>" <?= ($action == "AdminEidt" || $action == "Insert") ? '' : 'disabled="disabled"' ?> maxlength="200" />
                        <span>Teacher (Outside School)</span>
                    </div>
                </div>
                <div class="control-group">
                    <?php
                    $attribute = 'rate3';
                    $label = 'Rate 3';
                    ?>
                    <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
                    <div class="controls form-inline">
                        <input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="number" value="" placeholder="<?= $label ?>" <?= ($action == "AdminEidt" || $action == "Insert") ? '' : 'disabled="disabled"' ?> maxlength="200" />
                        <span>Teaching Assistant (In House)</span>
                    </div>
                </div>
                <div class="control-group">
                    <?php
                    $attribute = 'rate4';
                    $label = 'Rate 4';
                    ?>
                    <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
                    <div class="controls form-inline">
                        <input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="number" value="" placeholder="<?= $label ?>" <?= ($action == "AdminEidt" || $action == "Insert") ? '' : 'disabled="disabled"' ?> maxlength="200" />
                        <span>Teaching Assistant (Outside School)</span>
                    </div>
                </div>
                <div class="control-group">
                    <?php
                    $attribute = 'rate5';
                    $label = 'Rate 5';
                    ?>
                    <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
                    <div class="controls form-inline">
                        <input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="number" value="" placeholder="<?= $label ?>" <?= ($action == "AdminEidt" || $action == "Insert") ? '' : 'disabled="disabled"' ?> maxlength="200" />
                        <span>Traveling</span>
                    </div>
                </div>
                <div class="control-group">
                    <?php
                    $attribute = 'rate6';
                    $label = 'Rate 6';
                    ?>
                    <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
                    <div class="controls form-inline">
                        <input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="number" value="" placeholder="<?= $label ?>" <?= ($action == "AdminEidt" || $action == "Insert") ? '' : 'disabled="disabled"' ?> maxlength="200" />
                        <?php
                        $attribute = 'rate6_other';
                        $label = 'Other';
                        ?>
                        <label class="" for="<?= $attribute ?>"><?= $label ?></label>
                        <input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="" style="margin-left:15px" value="" placeholder="<?= $label ?>" <?= ($action == "AdminEidt" || $action == "Insert") ? '' : 'disabled="disabled"' ?> maxlength="200" />
                    </div>
                </div>

                <?php
                $attribute = 'remarks';
                $label = 'Remarks';
                ?>
                <div style="visibility:hidden">
                    <hr />
                    <h5><label class="" style="font-weight: bold" for="<?= $attribute ?>" ><?= $label ?></label></h5>
                    <div class="control-group" >
                        <textarea id="<?= $attribute ?>" name="<?= $attribute ?>" class="input-block-level" rows="3" placeholder="<?= $label ?>"></textarea>
                        <div class="controls">
                        </div>
                    </div>

                </div>
                <hr />

                <button type="button" id="add_education_btn" class="btn pull-right" <?= $is_disabled ?> ><i class="icon-plus"></i> Add</button>
                <h5>Education</h5>
                <table class="table table-striped table-bordered table-hover table-condensed">
                    <thead>
                        <tr>
                            <th style="min-width:200px; width:200px">Start Date</th>
                            <th style="min-width:200px; width:200px">End Date</th>
                            <th>Description</th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody id="education_tbody">
                        <?php $i = 0; ?>
                        <?php
                        if ($_GET) {
                            foreach ($staff_edu as $education) {
                                ?>
                                <tr id="staff[educations][<?= $i + 1 ?>]">
                                    <td >
                                        <?php
                                        $label = 'Start Date';
                                        ?>
                                        <div class="input-append date-picker">
                                            <input type="text"  name="staff[educations][<?= $i + 1 ?>][Sdate]" id="staff[educations][<?= $i + 1 ?>][Sdate]" class="dateISO" value="<?= $education['start_date'] ?>" data-format="yyyy-MM-dd" placeholder="<?= $label ?>" maxlength="200" <?= $is_disabled ?> />
                                            <span class="add-on" <?= $action == 'View' ? 'style="visibility:hidden"' : '' ?> ><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>
                                        </div>
                                    </td>
                                    <td >
                                        <?php
                                        $label = 'End Date';
                                        ?>
                                        <div class="input-append date-picker">
                                            <input type="text"  name="staff[educations][<?= $i + 1 ?>][Edate]" id="staff[educations][<?= $i + 1 ?>][Edate]" class="dateISO" value="<?= $education['end_date'] ?>" data-format="yyyy-MM-dd" placeholder="<?= $label ?>" maxlength="200" <?= $is_disabled ?> />
                                            <span class="add-on" <?= $action == 'View' ? 'style="visibility:hidden"' : '' ?> ><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>
                                        </div>
                                    </td>
                                    <td>
                                        <?php
                                        $attribute = 'desc';
                                        $label = 'Description';
                                        ?>
                                        <input type="text" name="staff[educations][<?= $i + 1 ?>][<?= $attribute ?>]" id="staff[educations][<?= $i + 1 ?>][<?= $attribute ?>]" class="input-block-level" value="<?= $education['education'] ?>" placeholder="<?= $label ?>" maxlength="200" size="100%" <?= $is_disabled ?> />

                                    </td>
                                    <td>
                                        <button  class="btn" type="button" onclick="deleteRow('staff[educations][<?= $i + 1 ?>]')" <?= $is_disabled ?> ><i class="icon-remove"></i></button>
                                    </td>

                                </tr>
                                <?php $i++; ?>
                                <?php
                            };
                        }
                        ?>
                        <tr id="staff[educations][<?= $i + 1 ?>]">
                            <td >
                                <?php
                                $label = 'Start Date';
                                ?>
                                <div class="input-append date-picker">
                                    <input type="text"  name="staff[educations][<?= $i + 1 ?>][Sdate]" id="staff[educations][<?= $i + 1 ?>][Sdate]" class="dateISO" value="" data-format="yyyy-MM-dd" placeholder="<?= $label ?>" maxlength="200" <?= $is_disabled ?> />
                                    <span class="add-on" <?= $action == 'View' ? 'style="visibility:hidden"' : '' ?> ><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>
                                </div>
                            </td>
                            <td >
                                <?php
                                $label = 'End Date';
                                ?>
                                <div class="input-append date-picker">
                                    <input type="text"  name="staff[educations][<?= $i + 1 ?>][Edate]" id="staff[educations][<?= $i + 1 ?>][Edate]" class="dateISO" value="" data-format="yyyy-MM-dd" placeholder="<?= $label ?>" maxlength="200" <?= $is_disabled ?> />
                                    <span class="add-on" <?= $action == 'View' ? 'style="visibility:hidden"' : '' ?> ><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>
                                </div>
                            </td>
                            <td>
                                <?php
                                $attribute = 'desc';
                                $label = 'Description';
                                ?>
                                <input type="text" name="staff[educations][<?= $i + 1 ?>][<?= $attribute ?>]" id="staff[educations][<?= $i + 1 ?>][<?= $attribute ?>]" class="input-block-level" value="" placeholder="<?= $label ?>" maxlength="200" size="100%" <?= $is_disabled ?> />

                            </td>
                            <td>
                                <button  class="btn" type="button" onclick="deleteRow('staff[educations][<?= $i + 1 ?>]')" <?= $is_disabled ?> ><i class="icon-remove"></i></button>
                            </td>
                        </tr>
                        <?php $i++; ?>
                    </tbody>
                </table>
                <input  type="hidden" id="educationsRow" name="educationsRow" value="<?= $i ?>"/>
                <script type="text/javascript">
            $(function() {
                //var i = document.getElementById('educationsRow').value;
                var i = <?= $i ?>;
                $('#add_education_btn').click(function() {
                    var $row = $(
                            '<tr id="staff[educations][' + (i + 1) + ']">' +
                            '<td>' +
                            '<div class="input-append date-picker">' +
                            '<input type="text" name="staff[educations][' + (i + 1) + '][Sdate]" id="staff[educations][' + (i + 1) + '][Sdate]" class="dateISO" value="" data-format="yyyy-MM-dd" placeholder="Start Date" maxlength="200" />' +
                            '<span class="add-on"><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>' +
                            '</div>' +
                            '</td>' +
                            '<td>' +
                            '<div class="input-append date-picker">' +
                            '<input type="text" name="staff[educations][' + (i + 1) + '][Edate]" id="staff[educations][' + (i + 1) + '][Edate]" class="dateISO" value="" data-format="yyyy-MM-dd" placeholder="End Date" maxlength="200" />' +
                            '<span class="add-on"><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>' +
                            '</div>' +
                            '</td>' +
                            '<td>' +
                            '<input type="text" name="staff[educations][' + (i + 1) + '][desc]" id="staff[educations][' + (i + 1) + '][desc]" class="input-block-level" value="" placeholder="Description" maxlength="200" size="100%" />' +
                            '</td>' +
                            '<td>' +
                            '<button  class="btn" type="button" onclick="deleteRow(\'staff[educations][' + (i + 1) + ']\')"><i class="icon-remove"></i></button>' +
                            '</td>' +
                            '</tr>'
                            );
                    $('.date-picker', $row).datetimepicker({pickTime: false});
                    $row.appendTo($('#education_tbody'));
                    if ($.browser.msie) {
                        $(window).resize(); // fix IE placeholder position
                        if ($.placeholder) {
                            $.placeholder.shim();
                        }
                    }
                    //i = document.getElementById('educationsRow').value;
                    i++;
                    $('#educationsRow').val(i);
                    $('div input').height(20);
                });
            });</script>
                <hr />

                <button type="button" id="add_experience_btn" class="btn pull-right" <?= $is_disabled ?> ><i class="icon-plus"></i> Add</button>
                <h5>Experience</h5>
                <table class="table table-striped table-bordered table-hover table-condensed">
                    <thead>
                        <tr>
                            <th style="min-width:200px; width:200px">Start Date</th>
                            <th style="min-width:200px; width:200px">End Date</th>
                            <th>Description</th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody id="experience_tbody">
                        <?php $i = 0; ?>
                        <?php
                        if ($_GET) {
                            foreach ($staff_exp as $experience) {
                                ?>
                                <tr id="staff[experiences][<?= $i + 1 ?>]">
                                    <td>
                                        <?php
                                        $label = 'Start Date';
                                        ?>
                                        <div class="input-append date-picker">
                                            <input type="text" name="staff[experiences][<?= $i + 1 ?>][Sdate]" id="staff[experiences][<?= $i + 1 ?>][Sdate]" class="dateISO" value="<?= $experience['start_date'] ?>" data-format="yyyy-MM-dd" placeholder="<?= $label ?>" maxlength="200" <?= $is_disabled ?> />
                                            <span class="add-on" <?= $action == 'View' ? 'style="visibility:hidden"' : '' ?> ><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>
                                        </div>
                                    </td>
                                    <td>
                                        <?php
                                        $label = 'End Date';
                                        ?>
                                        <div class="input-append date-picker">
                                            <input type="text" name="staff[experiences][<?= $i + 1 ?>][Edate]" id="staff[experiences][<?= $i + 1 ?>][Edate]" class="dateISO" value="<?= $experience['end_date'] ?>" data-format="yyyy-MM-dd" placeholder="<?= $label ?>" maxlength="200" <?= $is_disabled ?> />
                                            <span class="add-on" <?= $action == 'View' ? 'style="visibility:hidden"' : '' ?> ><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>
                                        </div>
                                    </td>
                                    <td>
                                        <?php
                                        $attribute = 'desc';
                                        $label = 'Description';
                                        ?>
                                        <input type="text" name="staff[experiences][<?= $i + 1 ?>][desc]" id="staff[experiences][<?= $i + 1 ?>][desc]" class="input-block-level" value="<?= $experience['remarks'] ?>" placeholder="<?= $label ?>" maxlength="200" size="100%" <?= $is_disabled ?> />
                                    </td>
                                    <td>
                                        <button  class="btn" type="button" onclick="deleteRow('staff[experiences][<?= $i + 1 ?>]')" <?= $is_disabled ?> ><i class="icon-remove"></i></button>
                                    </td>
                                </tr>
                                <?php $i++; ?>
                                <?php
                            };
                        }
                        ?>
                        <tr id="staff[experiences][<?= $i + 1 ?>]">
                            <td>
                                <?php
                                $label = 'Start Date';
                                ?>
                                <div class="input-append date-picker">
                                    <input type="text" name="staff[experiences][<?= $i + 1 ?>][Sdate]" id="staff[experiences][<?= $i + 1 ?>][Sdate]" class="dateISO" value="" data-format="yyyy-MM-dd" placeholder="<?= $label ?>" maxlength="200" <?= $is_disabled ?> />
                                    <span class="add-on" <?= $action == 'View' ? 'style="visibility:hidden"' : '' ?> ><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>
                                </div>
                            </td>
                            <td>
                                <?php
                                $label = 'End Date';
                                ?>
                                <div class="input-append date-picker">
                                    <input type="text" name="staff[experiences][<?= $i + 1 ?>][Edate]" id="staff[experiences][<?= $i + 1 ?>][Edate]" class="dateISO" value="" data-format="yyyy-MM-dd" placeholder="<?= $label ?>" maxlength="200" <?= $is_disabled ?> />
                                    <span class="add-on" <?= $action == 'View' ? 'style="visibility:hidden"' : '' ?> ><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>
                                </div>
                            </td>
                            <td>
                                <?php
                                $attribute = 'desc';
                                $label = 'Description';
                                ?>
                                <input type="text" name="staff[experiences][<?= $i + 1 ?>][desc]" id="staff[experiences][<?= $i + 1 ?>][desc]" class="input-block-level" value="" placeholder="<?= $label ?>" maxlength="200" size="100%" <?= $is_disabled ?> />
                            </td>
                            <td>
                                <button  class="btn" type="button" onclick="deleteRow('staff[experiences][<?= $i + 1 ?>]')" <?= $is_disabled ?> ><i class="icon-remove"></i></button>
                            </td>
                        </tr>
                        <?php
                        $i++;
                        ?>
                    </tbody>
                </table>
                <input  type="hidden" id="experiencesRow" name="experiencesRow" value="<?= $i ?>"/>
                <script type="text/javascript">
            $(function() {
                //var i = document.getElementById('experiencesRow').value;
                var i = <?= $i ?>;
                $('#add_experience_btn').click(function() {
                    var $row = $(
                            '<tr id="staff[experiences][' + (i + 1) + ']">' +
                            '<td>' +
                            '<div class="input-append date-picker">' +
                            '<input type="text" name="staff[experiences][' + (i + 1) + '][Sdate]" id="staff[experiences][' + (i + 1) + '][Sdate]" class="dateISO" value="" data-format="yyyy-MM-dd" placeholder="Start Date" maxlength="200" />' +
                            '<span class="add-on"><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>' +
                            '</div>' +
                            '</td>' +
                            '<td>' +
                            '<div class="input-append date-picker">' +
                            '<input type="text" name="staff[experiences][' + (i + 1) + '][Edate]" id="staff[experiences][' + (i + 1) + '][Edate]" class="dateISO" value="" data-format="yyyy-MM-dd" placeholder="End Date" maxlength="200" />' +
                            '<span class="add-on"><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>' +
                            '</div>' +
                            '</td>' +
                            '<td>' +
                            '<input type="text" name="staff[experiences][' + (i + 1) + '][desc]" id="staff[experiences][' + (i + 1) + '][desc]" class="input-block-level" value="" placeholder="Description" maxlength="200" size="100%" />' +
                            '</td>' +
                            '<td>' +
                            '<button  class="btn" type="button" onclick="deleteRow(\'staff[experiences][' + (i + 1) + ']\')"><i class="icon-remove"></i></button>' +
                            '</td>' +
                            '</tr>'
                            );
                    $('.date-picker', $row).datetimepicker({pickTime: false});
                    $row.appendTo($('#experience_tbody'));
                    if ($.browser.msie) {
                        $(window).resize(); // fix IE placeholder position
                        if ($.placeholder) {
                            $.placeholder.shim();
                        }
                    }
                    i++;
                    $('#experiencesRow').val(i);
                    $('div input').height(20);
                });
            });</script>

                <hr />

                <button type="button" id="add_training_btn" class="btn pull-right" <?= $is_disabled ?> ><i class="icon-plus"></i> Add</button>
                <h5>Training</h5>
                <table class="table table-striped table-bordered table-hover table-condensed">
                    <thead>
                        <tr>
                            <th style="min-width:200px; width:200px">Start Date</th>
                            <th style="min-width:200px; width:200px">End Date</th>
                            <th>Description</th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody id="training_tbody">
                        <?php $i = 0; ?>
                        <?php
                        if ($_GET) {
                            foreach ($staff_train as $training) {
                                ?>
                                <tr id="staff[trainings][<?= $i + 1 ?>]">
                                    <td>
                                        <?php
                                        $label = 'Start Date';
                                        ?>
                                        <div class="input-append date-picker">
                                            <input type="text" name="staff[trainings][<?= $i + 1 ?>][Sdate]" id="staff[trainings][<?= $i + 1 ?>][Sdate]" class="dateISO" value="<?= $training['start_date'] ?>" data-format="yyyy-MM-dd" placeholder="<?= $label ?>" maxlength="200" <?= $is_disabled ?> />
                                            <span class="add-on" <?= $action == 'View' ? 'style="visibility:hidden"' : '' ?> ><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>
                                        </div>
                                    </td>
                                    <td>
                                        <?php
                                        $label = 'End Date';
                                        ?>
                                        <div class="input-append date-picker">
                                            <input type="text" name="staff[trainings][<?= $i + 1 ?>][Edate]" id="staff[trainings][<?= $i + 1 ?>][Edate]" class="dateISO" value="<?= $training['end_date'] ?>" data-format="yyyy-MM-dd" placeholder="<?= $label ?>" maxlength="200" <?= $is_disabled ?> />
                                            <span class="add-on" <?= $action == 'View' ? 'style="visibility:hidden"' : '' ?> ><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>
                                        </div>
                                    </td>
                                    <td>
                                        <?php
                                        $attribute = 'desc';
                                        $label = 'Description';
                                        ?>
                                        <input type="text" name="staff[trainings][<?= $i + 1 ?>][<?= $attribute ?>]" id="staff[trainings][<?= $i + 1 ?>][<?= $attribute ?>]" class="input-block-level" value="<?= $training['remarks'] ?>" placeholder="<?= $label ?>" maxlength="200" size="100%" <?= $is_disabled ?> />
                                    </td>
                                    <td>
                                        <button  class="btn" type="button" onclick="deleteRow('staff[trainings][<?= $i + 1 ?>]')" <?= $is_disabled ?> ><i class="icon-remove"></i></button>
                                    </td>
                                </tr>
                                <?php
                                $i++;
                            };
                        }
                        ?>
                        <tr id="staff[trainings][<?= $i + 1 ?>]">
                            <td>
                                <?php
                                $label = 'Start Date';
                                ?>
                                <div class="input-append date-picker">
                                    <input type="text" name="staff[trainings][<?= $i + 1 ?>][Sdate]" id="staff[trainings][<?= $i + 1 ?>][Sdate]" class="dateISO" value="" data-format="yyyy-MM-dd" placeholder="<?= $label ?>" maxlength="200" <?= $is_disabled ?> />
                                    <span class="add-on" <?= $action == 'View' ? 'style="visibility:hidden"' : '' ?> ><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>
                                </div>
                            </td>
                            <td>
                                <?php
                                $label = 'End Date';
                                ?>
                                <div class="input-append date-picker">
                                    <input type="text" name="staff[trainings][<?= $i + 1 ?>][Edate]" id="staff[trainings][<?= $i + 1 ?>][Edate]" class="dateISO" value="" data-format="yyyy-MM-dd" placeholder="<?= $label ?>" maxlength="200" <?= $is_disabled ?> />
                                    <span class="add-on" <?= $action == 'View' ? 'style="visibility:hidden"' : '' ?> ><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>
                                </div>
                            </td>
                            <td>
                                <?php
                                $attribute = 'desc';
                                $label = 'Description';
                                ?>
                                <input type="text" name="staff[trainings][<?= $i + 1 ?>][<?= $attribute ?>]" id="staff[trainings][<?= $i + 1 ?>][<?= $attribute ?>]" class="input-block-level" value="" placeholder="<?= $label ?>" maxlength="200" size="100%" <?= $is_disabled ?> />
                            </td>
                            <td>
                                <button  class="btn" type="button" onclick="deleteRow('staff[trainings][<?= $i + 1 ?>]')" <?= $is_disabled ?> ><i class="icon-remove"></i></button>
                            </td>
                        </tr>
                        <?php $i++; ?>
                    </tbody>
                </table>
                <input  type="hidden" id="trainingsRow" name="trainingsRow" value="<?= $i ?>"/>
                <script type="text/javascript">
            $(function() {
                //var i = document.getElementById('trainingsRow').value;
                var i = <?= $i ?>;
                $('#add_training_btn').click(function() {
                    var $row = $(
                            '<tr id="staff[trainings][' + (i + 1) + ']">' +
                            '<td>' +
                            '<div class="input-append date-picker">' +
                            '<input type="text" name="staff[trainings][' + (i + 1) + '][Sdate]" id="staff[trainings][' + (i + 1) + '][Sdate]" class="dateISO" value="" data-format="yyyy-MM-dd" placeholder="Start Date" maxlength="200" />' +
                            '<span class="add-on"><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>' +
                            '</div>' +
                            '</td>' +
                            '<td>' +
                            '<div class="input-append date-picker">' +
                            '<input type="text" name="staff[trainings][' + (i + 1) + '][Edate]" id="staff[trainings][' + (i + 1) + '][Edate]" class="dateISO" value="" data-format="yyyy-MM-dd" placeholder="End Date" maxlength="200" />' +
                            '<span class="add-on"><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>' +
                            '</div>' +
                            '</td>' +
                            '<td>' +
                            '<input type="text" name="staff[trainings][' + (i + 1) + '][desc]" ID="staff[trainings][' + (i + 1) + '][desc]" class="input-block-level" value="" placeholder="Description" maxlength="200" size="100%" />' +
                            '</td>' +
                            '<td>' +
                            '<button  class="btn" type="button" onclick="deleteRow(\'staff[trainings][' + (i + 1) + ']\')"><i class="icon-remove"></i></button>' +
                            '</td>' +
                            '</tr>'
                            );
                    $('.date-picker', $row).datetimepicker({pickTime: false});
                    $row.appendTo($('#training_tbody'));
                    if ($.browser.msie) {
                        $(window).resize(); // fix IE placeholder position
                        if ($.placeholder) {
                            $.placeholder.shim();
                        }
                    }
                    $('div input').height(20);
                    i++;
                    $('#trainingsRow').val(i);
                });
            });</script>

                <hr />

                <button type="button" id="add_attachment_btn" class="btn pull-right" <?= $is_disabled ?> ><i class="icon-plus"></i> Add</button>
                <h5>Attachment</h5>
                <table class="table table-striped table-bordered table-hover table-condensed">
                    <thead>
                        <tr>
                            <th width='30%'>Description</th>
                            <th width='70%'>Upload PDF</th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody id="attachment_tbody">
                        <?php
                        $i = 0;
                        ?>
                        <?php
                        if ($_GET) {
                            foreach ($staff_attachments as $attachment) {
                                ?>
                                <tr id="staff[attachments][<?= $i + 1 ?>]">
                                    <td>
                                        <?php
                                        $attribute = 'other';
                                        $label = 'Description';
                                        ?>
                                        <input type="text" name="staff[attachments][<?= $i + 1 ?>][<?= $attribute ?>]" class="" value="<?= $attachment['remarks'] ?>" placeholder="<?= $label ?>" maxlength="200" <?= $is_disabled ?> />
                                    </td>
                                    <td>
                                        <?php
                                        $attribute = 'pdf';
                                        $label = 'Upload PDF';
                                        ?>
                                        <div class="fileupload fileupload-exists" style="margin:0px" data-provides="fileupload" id="Status_ATT_<?= $i ?>" >
                                            <?php if (!empty($attachment[$attribute])): ?>
                                                <input type="hidden" name="staff[attachments][<?= $i + 1 ?>][<?= $attribute ?>]" id="ATT_<?= $i ?>_Temp" value="<?= $attachment[$attribute] ?>" <?= $is_disabled ?> />
                                            <?php endif; ?>
                                            <div class="input-append">
                                                <div class="uneditable-input " width='100%'>
                                                    <i class="icon-file fileupload-exists"></i>
                                                    <span class="fileupload-preview" id="ATT_<?= $i ?>_preview"><a href="<?= $action=="View"?'':'upload/'.$attachment['pdf']?>" target="_blank"><?= $attachment['pdf'] ?></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="ATT_<?= $i ?>" size="" id="ATT_<?= $i ?>"  onClick="CheckFileSize('ATT_<?= $i ?>');" <?= $is_disabled ?> />
                                                </span>
                                                <a href="#" class="btn fileupload-exists" data-dismiss="fileupload" id="Remove_ATT_<?= $i ?>" <?= $is_disabled ?> >Remove</a>
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <button  class="btn" type="button" onclick="deleteRow('staff[attachments][<?= $i + 1 ?>]')" <?= $is_disabled ?> ><i class="icon-remove"></i></button>
                                    </td>
                                </tr>
                                <?php
                                $i++;
                            };
                        }
                        ?>
                        <?php //foreach ($staff['attachments'] ? : array(array()) as $attachment):             ?>
                        <tr id="staff[attachments][<?= $i + 1 ?>]">
                            <td>
                                <?php
                                $attribute = 'other';
                                $label = 'Description';
                                ?>
                                <input type="text" name="staff[attachments][<?= $i + 1 ?>][<?= $attribute ?>]" class="" value="" placeholder="<?= $label ?>" maxlength="200" <?= $is_disabled ?> />
                            </td>
                            <td>
                                <?php
                                $attribute = 'pdf';
                                $label = 'Upload PDF';
                                ?>
                                <div class="fileupload fileupload-new" style="margin:0px" data-provides="fileupload" id="Status_ATT_<?= $i ?>" >
                                    <div class="input-append">
                                        <div class="uneditable-input ">
                                            <i class="icon-file fileupload-exists"></i>
                                            <span class="fileupload-preview"><a href="upload/<? //= $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="ATT_<?= $i ?>" id="ATT_<?= $i ?>" size="" onClick="CheckFileSize('ATT_<?= $i ?>');" <?= $is_disabled ?> />
                                        </span>
                                        <a href="#" class="btn fileupload-exists" data-dismiss="fileupload" id="Remove_ATT_<?= $i ?>" <?= $is_disabled ?> >Remove</a>
                                    </div>
                                </div>
                            </td>
                            <td>
                                <button  class="btn" type="button" onclick="deleteRow('staff[attachments][<?= $i + 1 ?>]')" <?= $is_disabled ?> ><i class="icon-remove"></i></button>
                            </td>
                        </tr>
                        <?php $i++; ?>
                        <?php //endforeach;                ?>
                    </tbody>
                </table>
                <input  type="hidden" id="attachmentsRow" name="attachmentsRow" disabled="disabled" value="<?= $i ?>"/>
                <script type="text/javascript">
            $(function() {
                //var i = document.getElementById('attachmentsRow').value;
                var i = <?= $i ?>;
                $('#add_attachment_btn').click(function() {
                    var $row = $(
                            '<tr id="staff[attachments][' + (i + 1) + ']">' +
                            '<td>' +
                            '<input type="text" name="staff[attachments][' + (i + 1) + '][other]" class="" value="" placeholder="Description" maxlength="200" />' +
                            '</td>' +
                            '<td>' +
                            '<div class="fileupload fileupload-new" style="margin:0px" data-provides="fileupload" id="Status_ATT_<?= $i ?>" >' +
                            '<div class="input-append">' +
                            '<div class="uneditable-input ">' +
                            '<i class="icon-file fileupload-exists"></i>' +
                            '<span class="fileupload-preview"></span>' +
                            '</div>' +
                            '<span class="btn btn-file">' +
                            '<span class="fileupload-new">Select file</span>' +
                            '<span class="fileupload-exists">Change</span>' +
                            '<input type="file" name="ATT_' + i + '" id="ATT_' + i + '" onClick="CheckFileSize(\'ATT_' + i + '\');" />' +
                            '</span>' +
                            '<a href="#" class="btn fileupload-exists" data-dismiss="fileupload" id="Remove_ATT_' + i + '" >Remove</a>' +
                            '</div>' +
                            '</div>' +
                            '</td>' +
                            '<td>' +
                            '<button  class="btn" type="button" onclick="deleteRow(\'staff[attachments][' + (i + 1) + ']\')"><i class="icon-remove"></i></button>' +
                            '</td>' +
                            '</tr>'
                            );
                    $row.appendTo($('#attachment_tbody'));
                    if ($.browser.msie) {
                        $(window).resize(); // fix IE placeholder position
                        if ($.placeholder) {
                            $.placeholder.shim();
                        }
                    }
                    $('div input').height(20);
                    i++;
                    $('#attachmentsRow').val(i);
                });
            });</script>


                <!--<div class="control-group">-->


                <!-- </div>-->
                <?php
                if ($action != 'View') {
                    print '<button  class="btn btn-danger" id="Save" onclick="return countClicks();" >Save</button>';
                    if ($action != 'Insert')
                        print '<button  class="btn btn-danger" style="margin-left:5px" id="delete_btn" type="button" onclick="deleteRecord()">Delete</button>';
                }
                ?>
                <button  class="btn btn-danger" type="button" onclick="history.back();" >Back</button>
            </form>
            <!--<button  class="btn btn-danger" id="submit">Save(AJax)</button>-->
        </div> <!-- /container -->
    </body>
</html>
<?php
// for check box set value
if ($_GET) {
    $deleted = 0;
    $query = "SELECT * FROM `staff_campus` WHERE `staff_id` = '$seachID' AND `deleted` = '$deleted'";
    $result = $dbh->prepare($query);
    $result->execute();
    while ($ResultSet = $result->fetch(PDO::FETCH_ASSOC)) {
        ?>
        <script>
            $(function() {
                $('input:checkbox[id="campus_<?= $ResultSet['campus_id'] ?>"]').attr('checked', 'checked');
            });</script>
        <?php
        //var_dump($ResultSet);
    };
    foreach ($programTemp as $key => $value) {
        ?>
        <script>
            $(function() {
                $('input:checkbox[id="program_<?= $value['program_id'] ?>"]').attr('checked', 'checked');
            });</script>
        <?php
        //var_dump($ResultSet);
    };
    foreach ($subjectTemp as $key => $value) {
        ?>
        <script>
            $(function() {
                $('input:checkbox[id="subject_<?= $value['subject_id'] ?>"]').attr('checked', 'checked');
            });
        </script>
        <?php
    };
}
?>



Youez - 2016 - github.com/yon3zu
LinuXploit