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/LeaveApplication/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/(Del)pathways.org.hk/MIS20140127/old20140407/LeaveApplication/Student_App_Form.php
<?php
include_once '../include/DBConnect.php';
include_once 'CheckFollowUpAction.php';

#### Lesson State ####
//state , 1 = Normal class , 2 = Make up class , 3 = Need make up
//        4 = cancel , 5 = Had make up

class General {

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

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

}

class Leave {

    public static function Type() {
        return array(
            1 => 'Annual Leave',
            2 => 'Marriage Leave',
            3 => 'Maternity Leave',
            4 => 'No Pay Leave',
            5 => 'Sick Leave'
        );
    }

//    public static function duration(){
//        return array(
//            1 => 'Whole day',
//            2 => 'Morning',
//            3 => 'Afternoon'
//        );
//    }

    public static function Status() {
        return array(
            0 => 'Pending',
            1 => 'Approved'
        );
    }

}

$genderOptions = General::genderOptions();
$leaveType = Leave::Type();
$leaveStatus = Leave::Status();
//$leaveDuration = Leave::duration();

date_default_timezone_set("Hongkong");
$today = date("Y-m-d");
$todaytime = date(" G:i");
$LID = "";
$CurrentAction = "Insert";
$SubmitFormWithoutWarning = 'true';
$Leave_Assistant = new LeaveAssistant($dbh);
$isEditBlock = FALSE;

if ($_GET) {
    //Get leave_id and action
    if (isset($_GET['leave_id']) && isset($_GET['action'])) {
        $LID = $_GET['leave_id'];
        $CurrentAction = $_GET['action'];
        //var_dump($CurrentAction);
        $SubmitFormWithoutWarning = 'false';
    }
    $query = "SELECT createby,createdate,`stu_linking_id`,reason_id,start_date,end_date,is_approved FROM `leave_app` WHERE `leave_id` = '$LID' and deleted = 0";
    $result = $dbh->prepare($query);
    $result->execute();
    while ($ResultSet = $result->fetch(PDO::FETCH_ASSOC)) {
        //var_dump($ResultSet);
        $get_createby = $ResultSet['createby'];
        $get_createdate = substr($ResultSet['createdate'], 0, 10);
        $get_student_id = $ResultSet['stu_linking_id'];
        $get_leave_reason = $ResultSet['reason_id'];
        $get_SDateTime = date_create($ResultSet['start_date']);
        $get_EDateTime = date_create($ResultSet['end_date']);
        $get_leave_status = $ResultSet['is_approved'];
    }
}

if ($_POST) {
    $actived = 1;
    $deleted = 0;
    $Sdate = $_POST['SDate'];
    $Stime = $_POST['STime'];
    $SdateTime = $Sdate . ' ' . $Stime;
    //var_dump($SdateTime);

    $Edate = $_POST['EDate'];
    $Etime = $_POST['ETime'];
    $EdateTime = $Edate . ' ' . $Etime;
    //var_dump($EdateTime);
    //Delete current record from leave_app table
    if ($LID != "" && $CurrentAction == "Edit") {
        ##################################
        #### Undo All related lesson  ####
        //$query = "SELECT `lesson_id` FROM `leave_lesson` WHERE `leave_id` = '$LID'";
        $query = "select `lesson_id`,`leave_lesson_id` from `leave_lesson` where `leave_id`='$LID' and `lesson_id` not in (SELECT `lesson_id` FROM 
            `lesson`l WHERE (concat(l.`date`,' ',l.`start_time`) >= '$SdateTime' OR  concat(l.`date`,' ',l.`end_time`) >='$SdateTime') AND
                (concat(l.`date`,' ',l.`start_time`) <= '$EdateTime' OR concat(l.`date`,' ',l.`end_time`) <='$EdateTime') and l.`actived`=1 
                    and l.`deleted`=0)";
        $result = $dbh->prepare($query);
        $result->execute();
        $Related_Lesson_IDs = $result->fetchAll();
//    while ($ResultSet = $result->fetch(PDO::FETCH_ASSOC)) {
        foreach ($Related_Lesson_IDs as $RLID) {
            $UpdateLesson_ID = $RLID['lesson_id'];
            $UpdateLeaveLesson_id = $RLID['leave_lesson_id'];
            $Leave_Assistant->undoOneLessonforStudent($UpdateLesson_ID, $get_student_id);
            //set to be delete
            $Leave_Assistant->DeleteLeaveLessonRecord($UpdateLeaveLesson_id);
        }
        #### Final Checking of attendance, after delete leave record ####
        foreach ($Related_Lesson_IDs as $RLID) {
            $checking_lesson_id = $RLID['lesson_id'];
            ## Update attendance(state = 1) where student have not leave record ##
            $Leave_Assistant->UpdateLessonStateForStudent($checking_lesson_id, $get_student_id);

            ## UpDate student attendance record ##
            $query = "UPDATE `lesson_attendance` SET `attendance`=1 WHERE `actived`=1 and `deleted`=0 and `stu_linking_id`='$get_student_id' 
                and `lesson_id`='$checking_lesson_id'";
            $sth = $dbh->prepare($query);
            $sth->execute();
        }
        ###########################################
        #### Deleted the previous Leave Record ####
        $query = "UPDATE `leave_app` SET `deleted`= '1' WHERE `leave_id` = '$LID'";
        $sth = $dbh->prepare($query);
        $sth->execute();
    }

    $input_by = $_POST['input_by'];
    $input_date = date("Y-m-d G:i:s");

    $SID = -1;
    $stuID = $_POST['student_name'];

    $leave_reason = $_POST['leave_type'];
    //approved or pendding
    $leave_status = 0; //$_POST['leave_status']; //0;
    $approved_by = -1;
    $remarks = "";

    $query = "INSERT INTO `leave_app`( `createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `staff_id`, `stu_linking_id`, `start_date`, `end_date`, `reason_id`, `approve_by`, `is_approved`, `remarks`) 
        VALUES ('$input_by','$input_date','$input_by','$input_date','$actived','$deleted','$SID','$stuID','$SdateTime','$EdateTime','$leave_reason','$approved_by','$leave_status','$remarks')";
    $sth = $dbh->prepare($query);
    if ($stuID != "")
        $sth->execute();

    $Current_Leave_Record_ID = "";
    $get_leave_app_start_date = "";
    $get_leave_app_end_date = "";
    $query = "Select `leave_id`,`start_date`,`end_date` from `leave_app` where `createdate`='$input_date' and `lastupdate`='$input_date' and `actived`='$actived' and `deleted`='$deleted' and `staff_id`='$SID' and `stu_linking_id`='$stuID' and `start_date`='$SdateTime' and `end_date`='$EdateTime' and `reason_id`='$leave_reason' and `approve_by`='$approved_by' and `is_approved`='$leave_status' and `remarks`='$remarks' ";
    $result = $dbh->prepare($query);
    $result->execute();
    while ($ResultSet = $result->fetch(PDO::FETCH_ASSOC)) {
        //var_dump($ResultSet['leave_id']);
        $Current_Leave_Record_ID = $ResultSet['leave_id'];
        $get_leave_app_start_date = $ResultSet['start_date'];
        $get_leave_app_end_date = $ResultSet['end_date'];
    }

    // check ,insert and update related record

    $currentProcess_lesson_id = -1;
//    $query = "select l.start_time,l.end_time,l.date,e.event_code ,l.room_id,l.lesson_id,la.attend_id from lesson l,event_lesson el,event e ,lesson_attendance la where la.actived=1 and la.deleted=0 and l.lesson_id = la.lesson_id and 
//            l.lesson_id in ( SELECT lesson_id FROM `lesson_attendance` WHERE `staff_id`='$SID' and `date`>= '$Sdate' and `date`<= '$Edate' ) and el.lesson_id = l.lesson_id and el.event_id in (select event_id from event 
//            where actived=1 and deleted =0) and e.event_id = el.event_id and (('$Stime' <= l.start_time AND '$Etime' >= l.start_time ) OR ('$Stime' <= l.end_time AND '$Etime' >= l.end_time ) OR ('$Stime' >= l.start_time AND '$Etime'<= l.end_time))";
    $query = "SELECT l.`lesson_id`,la.`attend_id` FROM `lesson`as l,`lesson_attendance` as la 
        WHERE (concat(l.`date`,' ',l.`start_time`) >= '$get_leave_app_start_date' OR 
            concat(l.`date`,' ',l.`end_time`) >='$get_leave_app_start_date') AND 
                (concat(l.`date`,' ',l.`start_time`) <= '$get_leave_app_end_date' OR 
                    concat(l.`date`,' ',l.`end_time`) <='$get_leave_app_end_date') and
                        la.`stu_linking_id`='$stuID' and la.`actived`=1 and la.`deleted` = 0 
                            and l.`lesson_id`= la.`lesson_id`";
    if ($LID != "" && $CurrentAction == "Edit") {
        $query .= " and l.`lesson_id` not in (select `lesson_id` from `leave_lesson` where `leave_id`='$LID' and `actived`=1 and `deleted`=0)";
    }
    $result = $dbh->prepare($query);
    $result->execute();
    while ($ResultSet = $result->fetch(PDO::FETCH_ASSOC)) {
        $Leave_lesson_id = $ResultSet['lesson_id'];
        //var_dump($Leave_lesson_id);
        //var_dump($currentProcess_lesson_id);

        $update_lesson_attendance_id = $ResultSet['attend_id'];
        //Update related student lesson_attendance record
        $query = "UPDATE `lesson_attendance` SET `state` = 3, `attendance` = 0 WHERE `attend_id` = '$update_lesson_attendance_id' and `stu_linking_id` ='$stuID'";
        $sth = $dbh->prepare($query);
        $sth->execute();

        if ($currentProcess_lesson_id != $Leave_lesson_id) {
            $query = "INSERT INTO `leave_lesson`(`leave_id`, `createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `lesson_id`) 
            VALUES ('$Current_Leave_Record_ID','$input_by','$input_date','$input_by','$input_date','$actived','$deleted','$Leave_lesson_id')";
            $sth = $dbh->prepare($query);
            $sth->execute();

            $query = "UPDATE `lesson` SET `lesson_leave_status`= 1 WHERE `lesson_id` = '$Leave_lesson_id' and `lesson_leave_status`= 0";
            $sth = $dbh->prepare($query);
            $sth->execute();
            $currentProcess_lesson_id = $Leave_lesson_id;
        }
    }

    if ($LID != "" && $CurrentAction == "Edit") {
        $query = "SELECT `lesson_id` FROM `leave_lesson` WHERE `actived`=1 and `deleted`=0 and `leave_id`='$LID'";
        $result = $dbh->prepare($query);
        $result->execute();
        $Previous_Leave_Lesson_Record = $result->fetchAll(PDO::FETCH_ASSOC);
        foreach ($Previous_Leave_Lesson_Record as $PLLR) {
            $Previous_Leave_Lesson_ID = $PLLR['lesson_id'];
            $query = "INSERT INTO `leave_lesson`(`leave_id`, `createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `lesson_id`) 
            VALUES ('$Current_Leave_Record_ID','$input_by','$input_date','$input_by','$input_date','$actived','$deleted','$Previous_Leave_Lesson_ID')";
            $sth = $dbh->prepare($query);
            $sth->execute();
        }
    }

    $result = ($_GET) ? "Update data successful." : "Insert data successful";
    echo "<script>alert('" . $result . "');</script>";
    echo "<script>location.href = 'LeaveIndex.php';</script>";
}
?>


<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <?php require_once '../include/head.php'; ?>
        <?php require_once '../include/checkuser.php'; ?>
        <?php require_once '../include/Nav_bar.php'; ?>
        <script>
            var Sdate = null, Edate = null, date;
            var SubmitForm = <?= $SubmitFormWithoutWarning ?>;
            var WarningText = "</br>the <b>action</b> of related record done before <b>will undo</b>";
            $(function() {
                $('div input').height(20); //fix size for input box
                //$('#SDate_id').datetimepicker({pickTime: false, startDate: new Date()});
                //$('#EDate_id').datetimepicker({pickTime: false, startDate: new Date()});
                $('.date-picker').datetimepicker({pickTime: false, startDate: new Date()});
                //$('.time-picker').datetimepicker({pickDate: false});
                $('.time-picker').timepicker({'timeFormat': 'H:i', 'step': 5, 'minTime': '6:00', 'maxTime': '22:00'});
                //$('.timepicker_end').timepicker({ 'timeFormat': 'H:i','step': 5,'minTime':'6:00','maxTime': '22:00' });   
//                $('#SDate').val('<?= $today . $todaytime ?>'); //Generate by system 
//                $('#EDate').val('<?= $today . $todaytime ?>'); //Generate by system 
                $("#myselect").select2({
                    placeholder: "Student Code",
                    minimumInputLength: 1,
                    allowClear: true
                });
                $("#myselect2").select2({
                    placeholder: "Student Name | Code",
                    minimumInputLength: 0,
                    allowClear: true
                });
                var date;
                $('#SDate_id').datetimepicker().on('changeDate', function(ev) {
                    Sdate = $('#SDate').val();
                    date = new Date($('#SDate').val());
                    //alert(date);
                    $('#EDate_id').datetimepicker('setStartDate', date);
                    if ($('#EDate').val() === "") {
                        $('#EDate_id').datetimepicker('setDate', date);
                        $('#EDate_id').datetimepicker('show');
                    }
                    $('#SDate_id').datetimepicker('hide');
                    $('#EDate_id').datetimepicker('remove');
                });
                $('#EDate_id').datetimepicker().on('changeDate', function(ev) {
                    Edate = $('#EDate').val();
                    date = new Date($('#EDate').val());
                    //alert($('#SDate').val());
                    $('#SDate_id').datetimepicker('setEndDate', date);
                    if ($('#SDate').val() === "") {
                        $('#SDate_id').datetimepicker('setDate', date);
                        $('#SDate_id').datetimepicker('show');
                    }
                    $('#EDate_id').datetimepicker('hide');
                });
                $("#Staff_Leave_Form").validate({
                    submitHandler: function(form)
                    {
                        //alert(SubmitForm);
                        if (SubmitForm === false) {
                            bootbox.dialog('<b>Are you sure to Edit this records?</b><br><br><b>Note:</b> If you edit this record, ' + WarningText, [
                                {
                                    'label': 'Save',
                                    'class': 'btn-danger',
                                    'callback': function() {
                                        SubmitForm = true;
                                        document.getElementById('Save').click();
                                    }
                                },
                                {
                                    'label': 'Cancel',
                                    'class': 'btn'
                                }
                            ]);
                        }
                        if (SubmitForm === true) {
                            $('#Save').button('loading');
                            $(form).ajaxSubmit();
                        }
                    }
                });
            });
            function limit_time(e) {
                var clearValue = false;
                if ($('#SDate').val() === "") {
                    document.getElementById("SDate").focus();
                    $('#SDate_id').datetimepicker('show');
                    clearValue = true;
                }
                else if ($('#EDate').val() === "") {
                    document.getElementById("EDate").focus();
                    $('#EDate_id').datetimepicker('show');
                    clearValue = true;
                }
                else {
                    if ($('#SDate').val() === $('#EDate').val()) { //imcomplete
                        //.split(":")[0] * 3600 + $(e).val().split(":")[1] * 60;
//                        if($('#STime').val()!=="" && $('#ETime').val()!==""){
//                            if($('#STime').val()>=$('#ETime').val()!==""){
//                                alert("warn time ");
//                            }
//                        }
                        if (e === document.getElementById('STime')) {
                            var arr = $(e).val();
                            $('#ETime').timepicker('option', {disableTimeRanges: [['6:00', arr]]});
                        }
                        else if (e === document.getElementById('ETime')) {
                            var arr = $(e).val();
                            $('#STime').timepicker('option', {disableTimeRanges: [[arr, '22:01']]});
                        }
                    }
                }
                if (clearValue === true) {
                    if (e === document.getElementById('STime')) {
                        $('#STime').val("");
                    }
                    else if (e === document.getElementById('ETime')) {
                        $('#ETime').val("");
                    }
                }
            }


<?php if ($_GET) { ?>
                $(function() {
                    $('#myselect2').select2().select2('val', '<?= $get_student_id ?>');
                    $('#leave_type').val('<?= $get_leave_reason ?>');
                    $('#SDate').val('<?= date_format($get_SDateTime, 'Y-m-d') ?>');
                    $('#EDate').val('<?= date_format($get_EDateTime, 'Y-m-d') ?>');
                    $('#leave_status').val(<?= $get_leave_status ?>);
                    $('#delete_btn').click(function()
                    {
                        bootbox.dialog('<b>Are you sure to Delete this records?</b><br><br><b>Note:</b> If you delete this record, ' + WarningText, [
                            {
                                'label': 'Delete',
                                'class': 'btn-danger',
                                'callback': function() {
                                    DeleteID = <?= $LID ?>;
                                    Target = <?= $get_student_id ?>;
                                    $.ajax({
                                        url: 'delete/delete.php', //This is the current doc
                                        type: "POST",
                                        data: {Data: DeleteID, Target: Target},
                                        success: function(data) {
                                            var obj = $.parseJSON(data);
                                            location.href = 'LeaveIndex.php'; //reload this page
                                        }

                                    });
                                }
                            },
                            {
                                'label': 'Cancel',
                                'class': 'btn'
                            }
                        ]);
                    });
                });
<?php } ?>
            function UndoButtonUnavailable(isMakeUpChain, isInvoiceGened, isPayrollGened, isUsedByOtherLeave) {
                var content = "";
                if (isMakeUpChain!=="")
                    content += "<br> - Having another make up lesson "+isMakeUpChain+" arranged for this lesson";
                if (isInvoiceGened)
                    content += "<br> - Student in this lesson have generated invoice";
                if (isPayrollGened)
                    content += "<br> - Teacher in this lesson have generated payroll";
                if (isUsedByOtherLeave)
                    content += "<br> - This make up lesson have other leave application";
                bootbox.dialog('<b>Sorry, The Undo Button is Unavailable now</b><br><br><b>The reason is:</b>' + content, [
                    {
                        'label': 'OK',
                        'class': 'btn'
                    },
                    {
                        'label': 'Cancel',
                        'class': 'btn'
                    }
                ]);
                return false;
            }
        </script>
    </head>
    <body>
        <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">Leave Application</li>
            </ul>
        </div>

        <div class="container-fluid pathways-container">
            <!--<a class="btn pull-right" <?= ($name != "") ? 'href="historyfrom.php?root_id=' . $RootID . '&action=Insert"' : 'disabled="disabled"' ?> ><i class="icon-plus"></i>Add</a>-->
            <h2>Student Application</h2>

            <form  class="form-horizontal" action="" method="post" id="Staff_Leave_Form" >
                <div class="control-group">
                    <?php
                    $attribute = 'input_by';
                    $label = 'Input By';
                    ?>
                    <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
                    <div class="controls form-inline">
                        <input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="required" value="<?= $_GET ? $get_createby : $_SESSION['MIS_login']['username'] ?>" placeholder="<?= $label ?>" maxlength="200" disabled />
                        <input type="hidden" id="<?= $attribute ?>" name="<?= $attribute ?>" class="required" value="<?= $_GET ? $get_createby : $_SESSION['MIS_login']['username'] ?>" maxlength="200" />
                    </div>
                </div>
                <div class="control-group">
                    <?php
                    $attribute = 'input_date';
                    $label = 'Input 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="<?= $_GET ? $get_createdate : $today ?>" data-format="yyyy-MM-dd" placeholder="<?= $label ?>" maxlength="200" disabled />
                            <input type="hidden" id="<?= $attribute ?>" name="<?= $attribute ?>" class="dateISO" value="<?= $_GET ? $get_createdate : $today ?>" data-format="yyyy-MM-dd" maxlength="200"/>
                            <!--<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">
                                        <select id="myselect" name="<?= $attribute ?>" id="<?= $attribute ?>" style="width:300px">
                                            <option value=""></option>
                <?php
                $query = 'SELECT CONCAT( last_name,  " ", first_name,  "(", ch_name,  ")" ) AS name,root_id,staff_code FROM staff WHERE deleted =0 GROUP BY name';
                $result = $dbh->prepare($query);
                $result->execute();
                while ($ResultSet = $result->fetch(PDO::FETCH_ASSOC)) {
                    ?>
                                                                                                                                                                            <option  value="<?= $ResultSet['root_id'] ?>" id="S<?= $ResultSet['root_id'] ?>" ><?= $ResultSet['staff_code'] ?></option>
                    <?php
                }
                ?>
                                        </select>
                                    </div>
                                </div>-->
                <div class="control-group">
                    <?php
                    $attribute = 'student_name';
                    $label = 'Student Name | Code';
                    ?>
                    <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" />
                        <select id="myselect2" name="<?= $attribute ?>" id="<?= $attribute ?>" style="width:300px" required <?= $CurrentAction == "View" ? "disabled" : "" ?> >
                            <option value=""></option>
                            <?php
                            $query = 'SELECT CONCAT( last_name,  " ", first_name,  "(", ch_name,  ")" ) AS name,`linking_id`,`root_id`,`New_stu_ID` FROM student WHERE deleted =0 and actived =1 GROUP BY name';
                            $result = $dbh->prepare($query);
                            $result->execute();
                            while ($ResultSet = $result->fetch(PDO::FETCH_ASSOC)) {
                                ?>
                                <option  value="<?= $ResultSet['root_id'] ?>" id="S<?= $ResultSet['root_id'] ?>" ><?= $ResultSet['name'] . " | " . $ResultSet['new_stu_id'] ?></option>
                                <?php
                            }
                            ?>
                        </select>
                        <?php
                        $attribute = 'zh_name';
                        $label = '中文姓名';
                        ?>
                        <!--<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="" value="" placeholder="<?= $label ?>" maxlength="200" />-->
                    </div>
                </div>
                <div class="control-group">
                    <?php
                    $attribute = 'leave_type';
                    $label = 'Leave Type';
                    ?>
                    <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
                    <div class="controls form-inline">
                        <select id="<?= $attribute ?>" name="<?= $attribute ?>" class=""  placeholder="<?= $label ?>" <?= $CurrentAction == "View" ? "disabled" : "" ?>>
                            <!--<option value=""></option>-->
                            <?php foreach ($leaveType as $leaveValue => $leaveLabel) { ?>
                                <option value="<?= $leaveValue ?>"><?= $leaveLabel ?></option>
                            <?php } ?>
                        </select>
                    </div>
                </div>
                <div class="control-group">
                    <?php
                    $attribute = 'SDate';
                    $label = 'Start Date';
                    ?>
                    <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
                    <div class="controls form-inline">
                        <div class="input-append date-picker" id="SDate_id">
                            <input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="dateISO" data-format="yyyy-MM-dd" placeholder="<?= $label ?>" maxlength="200" value="<?= $_GET ? date_format($get_SDateTime, 'Y-m-d') : '' ?>" required <?= $CurrentAction == "View" ? "disabled" : "" ?> />
                            <?php if ($CurrentAction != "View") { ?>
                                <span class="add-on"><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>
                            <?php } ?>
                        </div>
                        <?php
                        $attribute = 'EDate';
                        $label = 'End Date';
                        ?>
                        <label class="control-label" style="float:none;" for="<?= $attribute ?>" ><?= $label ?></label>
                        <div class="input-append date-picker" id="EDate_id">
                            <input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" style="margin-left:20px" class="dateISO" data-format="yyyy-MM-dd" placeholder="<?= $label ?>" maxlength="200" value="<?= $_GET ? date_format($get_EDateTime, 'Y-m-d') : '' ?>" required <?= $CurrentAction == "View" ? "disabled" : "" ?> />
                            <?php if ($CurrentAction != "View") { ?>
                                <span class="add-on"><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>
                            <?php } ?>
                        </div>

                    </div>
                </div>
                <div class="control-group">
                    <?php
                    $attribute = 'STime';
                    $label = 'Start Time';
                    ?>
                    <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
                    <div class="controls form-inline">
                        <!--<div class="input-append time-picker" id="STime_id">-->
                        <input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="time-picker" data-format="hh:mm" placeholder="<?= $label ?>" maxlength="200" onchange="limit_time(this);" value="<?= $_GET ? date_format($get_SDateTime, 'G:i') : '' ?>" required <?= $CurrentAction == "View" ? "disabled" : "" ?> />
                        <!--<span class="add-on"><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>-->
                        <!--</div>-->

                        <?php
                        $attribute = 'ETime';
                        $label = 'End Time';
                        ?>
                        <label class="control-label" style="float:none" for="<?= $attribute ?>" ><?= $label ?></label>
                        <!--<div class="input-append time-picker" id="ETime_id">-->
                        <input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" style="margin-left:20px" class="time-picker" data-format="hh:mm" placeholder="<?= $label ?>" maxlength="200" onchange="limit_time(this);" value="<?= $_GET ? date_format($get_EDateTime, 'G:i') : '' ?>" required <?= $CurrentAction == "View" ? "disabled" : "" ?> />
<!--                            <span class="add-on"><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>-->
                        <!--</div>-->
                    </div>
                </div>
                <input type="hidden" name="leave_status" id="leave_status" value="0" />
                <!--                <div class="control-group">
                <?php
                $attribute = 'leave_duration';
                $label = 'Leave Duration';
                ?>
                                    <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
                                    <div class="controls form-inline">
                                        <select id="<?= $attribute ?>" name="<?= $attribute ?>" class=""  placeholder="<?= $label ?>">
                                            <option value=""></option>
                <?php foreach ($leaveDuration as $ldValue => $ldLabel) { ?>
                                                                                                                                                                                                    <option value="<?= $ldValue ?>"><?= $ldLabel ?></option>
                <?php } ?>
                                        </select>
                                    </div>
                                </div>-->
                <!--                <div class="control-group">
                <?php
                $attribute = 'leave_status';
                $label = 'Leave Status';
                ?>
                                    <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
                                    <div class="controls form-inline">
                                        <select id="<?= $attribute ?>" name="<?= $attribute ?>" class=""  placeholder="<?= $label ?>">
                                            <option value=""></option>
                <?php foreach ($leaveStatus as $lsValue => $lsLabel) { ?>
                                                                                                                                                                            <option value="<?= $lsValue ?>"><?= $lsLabel ?></option>
                <?php } ?>
                                        </select>
                                    </div>
                                </div>-->
                <hr>
                    <?php
                    if ($CurrentAction == "View") {
                        ?>
                        <table class = "table table-striped table-bordered table-hover table-condensed" style = "width:100%" >
                            <thead>
                                <tr>
                                    <th style = "width:10%" >Date</th>
                                    <th style = "width:10%" >Time</th>
                                    <th style = "width:10%" >Program</th>
                                    <th style = "width:10%" >Subject</th>
                                </tr>
                            </thead>
                            <tbody>

                                <?php
                                $query = "SELECT l.start_time, l.end_time, l.date, e.event_code, e.event_id, l.room_id, l.lesson_id ,l.`lesson_leave_status`
FROM  lesson l, event_lesson el, event e, lesson_attendance la , leave_lesson ll
WHERE la.actived =1
AND la.deleted =0
AND l.lesson_id = la.lesson_id
AND l.lesson_id = ll.lesson_id
AND ll.deleted = '0'
and ll.leave_id = '$LID'
and la.stu_linking_id = '$get_student_id'
AND el.lesson_id = l.lesson_id
AND el.event_id
IN (
SELECT event_id
FROM event
WHERE actived =1
AND deleted =0
)
AND e.event_id = el.event_id";
                                $result = $dbh->prepare($query);
                                $result->execute();
                                $students_Leave_Lesson_Record = $result->fetchAll();
                                foreach ($students_Leave_Lesson_Record as $SLLRecord) {
                                    $current_lesson_id = $SLLRecord['lesson_id'];
                                    $isButtonAvailable = $Leave_Assistant->isUndoButtonAvailable($current_lesson_id);
                                    if ($isButtonAvailable['available'] == FALSE) {
                                        $isEditBlock = TRUE;
                                        $onclickListener = "UndoButtonUnavailable('" . $isButtonAvailable['isLessonInMakeUpChain'] . "','" . $isButtonAvailable['isLessonInvoiceGened'] . "','" . $isButtonAvailable['isLessonPayrollGened'] . "','" . $isButtonAvailable['isMakeUpLessonUsed'] . "')";
                                    }
                                    ?>
                                    <tr>
                                        <td>
                                            <?php print '<b>' . $SLLRecord['date'] . '</b>'; ?>
                                        </td>
                                        <td>
                                            <?php
                                            $get_Stime = date_create($SLLRecord['start_time']);
                                            $get_Etime = date_create($SLLRecord['end_time']);
                                            print date_format($get_Stime, 'H:i') . '-' . date_format($get_Etime, 'H:i')
                                            ?>
                                        </td>
                                        <td>
                                            <?php print $SLLRecord['event_code'] ?>
                                        </td>
                                        <td>
                                            <?php print $SLLRecord['room_id'] ?>
                                        </td>
                <!--                                <td>
                                            
                                        </td>
                                        <td>
                                            
                                        </td>-->
                                    </tr>
                                    <?php
                                }
                                ?>
                            </tbody>
                        </table>
                        <?php
                    }
                    if ($CurrentAction != "View") {
                        ?>
                        <button  class="btn btn-danger" data-loading-text="Loading..." id="Save" >Save</button>
                        <?php
                        if ($CurrentAction == "Edit") {
                            print '<button  class="btn btn-danger" style="margin-left:5px" id="delete_btn" type="button" onclick="deleteRecord()">Delete</button>';
                        }
                    } else {

                        if ($isEditBlock == TRUE) {
                            ?>
                            <button  class="btn btn-danger" style="margin-left:5px" id="" type="button" onclick="return <?= $onclickListener ?>" >Edit</button>
                            <?php
                        } else {
                            print '<a href="Student_App_Form.php?leave_id=' . $LID . '&action=Edit" class="btn btn-danger">Edit</a>';
                        }
                    }
                    ?>
                    <button  class="btn btn-danger" type="button" onclick="history.back();" >Back</button>
            </form>
        </div>
    </body>
</html>   

Youez - 2016 - github.com/yon3zu
LinuXploit