| 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/old20140414/LeaveApplication/ |
Upload File : |
<?php
include_once '../include/DBConnect.php';
include_once 'CheckFollowUpAction.php';
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'
);
}
}
$leaveType = Leave::Type();
$genderOptions = General::genderOptions();
date_default_timezone_set("Hongkong");
$today = date("Y-m-d");
$Leave_Assistant = new LeaveAssistant($dbh);
if ($_GET) {
if (isset($_GET['leave_id']) && isset($_GET['action'])) {
$LID = $_GET['leave_id'];
$CurrentAction = $_GET['action'];
//var_dump($CurrentAction);
//var_dump($LID);
}
//if Action = 3, Data is pass form Event_DetailFrom.php
if ($CurrentAction == 3) {
$get_lesson_id = $_GET['lesson_id'];
$get_event_id_from_event = $_GET['event_id'];
$Leave_Assistant->checkAll($get_event_id_from_event, $get_lesson_id);
}
$query = "SELECT * 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']); //substr($ResultSet['start_date'], 0, 16);
$get_EDateTime = date_create($ResultSet['end_date']); //substr($ResultSet['end_date'], 0, 16);
// $get_leave_status = $ResultSet['is_approved'];
}
$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();
//var_dump($staffs_Leave_Lesson_Record);
$query = "SELECT `last_name`,`first_name`,`ch_name`,`gender` FROM `student` WHERE `root_id`='$get_student_id' and `deleted`= '0'";
$result = $dbh->prepare($query);
$result->execute();
while ($ResultSet = $result->fetch(PDO::FETCH_ASSOC)) {
$get_staff_last_name = $ResultSet['last_name'];
$get_staff_first_name = $ResultSet['first_name'];
$get_staff_ch_name = $ResultSet['ch_name'];
$get_gender = $ResultSet['gender'];
}
}
if ($_POST) {
if (isset($_POST['cancel_lesson_id'])) {
if (isset($_POST['Cancel'])) {
//echo $_POST['cancel_lesson_id'];
$UpdateLesson_ID = $_POST['cancel_lesson_id'];
//Update student attendance record
$query = "UPDATE `lesson_attendance` SET `state`=4 ,`make_up_lesson_id`=0, `make_up_lesson_remark`='' WHERE `lesson_id` = '$UpdateLesson_ID' and deleted =0 and actived = 1 and `stu_linking_id` ='$get_student_id'";
$sth = $dbh->prepare($query);
$sth->execute();
$query = "select `attend_id` from `lesson_attendance` where `lesson_id`= '$UpdateLesson_ID' and `state`='3' and `stu_linking_id`>0";
$sth = $dbh->prepare($query);
$sth->execute();
$Not_Finish_Attendance_record = $result->fetchAll();
if (!($Not_Finish_Attendance_record)) {
$query = "UPDATE `lesson` SET `lesson_leave_status`='0' WHERE `lesson_id` = '$UpdateLesson_ID'";
$sth = $dbh->prepare($query);
$sth->execute();
}
$Textresult = "Cancel Lesson Successful.";
} else if (isset($_POST['Undo'])) {
#### Reset value ####
//Reset attendance record
$UpdateLesson_ID = $_POST['cancel_lesson_id'];
$Leave_Assistant->undoOneLessonforStudent($UpdateLesson_ID, $get_student_id);
$Textresult = "Active Lesson Successful.";
}
echo "<script>alert('" . $Textresult . "');</script>";
echo "<script>location.href = 'Student_Approve.php?leave_id=" . $LID . "&action=FollowUpAction';</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>
$(function() {
$('div input').height(20); //fix size for input box
$('.date-picker').datetimepicker({pickTime: false});
$('#SDate').val('<?= $today ?>'); //Generate by system
$('#EDate').val('<?= $today ?>'); //Generate by system
});
<?php if ($_GET) { ?>
$(function() {
$('#leave_type').val('<?= $get_leave_reason ?>');
$('#SDate').val('<?= date_format($get_SDateTime, 'Y-m-d') ?>');
$('#EDate').val('<?= date_format($get_EDateTime, 'Y-m-d') ?>');
$('#last_name').val('<?= $get_staff_last_name ?>');
$('#first_name').val('<?= $get_staff_first_name ?>');
$('#zh_name').val('<?= $get_staff_ch_name ?>');
$('#gender').val('<?= $get_gender ?>');
});
// function CancelLesson(lesson_id, action)
// {
// bootbox.dialog('Are you sure to cancel this lesson ?', [
// {
// 'label': 'Delete',
// 'class': 'btn-danger',
// 'callback': function() {
// CancelID = lesson_id;
// Action = action;
// $.ajax({
// url: 'Cancel_Lesson.php', //This is the current doc
// type: "POST",
// data: {Data: CancelID, Action: Action},
// success: function(data) {
// var obj = $.parseJSON(data);
// alert(obj[1]);
// location.href = ''; //reload this page
// }
//
// });
// }
// },
// {
// 'label': 'Cancel',
// 'class': 'btn'
// }
// ]);
// }
// ;
function CancelLesson(lesson_id, action) {
CancelID = lesson_id;
Action = action;
$('#cancel_lesson_id').val(CancelID);
//alert(CancelID + " " + Action);
}
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 Edit and Delete Button is Unavailable now</b><br><br><b>The reason is:</b>' + content, [
{
'label': 'OK',
'class': 'btn'
},
{
'label': 'Cancel',
'class': 'btn'
}
]);
return false;
}
<?php } ?>
</script>
</head>
<body>
<div class="text-right">
<ul class="breadcrumb">
<!--<li><a href="#">Master</a> <span class="divider">></span></li>-->
<!-- <li><a href="index.php">Staff</a> <span class="divider">></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 Approve</h2>
<form class="form-horizontal" action="" method="post" >
<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" disabled="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" disabled="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" disabled="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 ?>" disabled="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 = 'SDate';
$label = 'Start 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" disabled="disabled" />
<!--<span class="add-on"><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>-->
</div>
<?php
$attribute = 'EDate';
$label = 'End Date';
?>
<label class="control-label" style="float:none;margin-left:20px" for="<?= $attribute ?>" ><?= $label ?></label>
<div class="input-append date-picker">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" style="margin-left:20px" class="dateISO" value="" 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 = 'STime';
$label = 'Start Time';
?>
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls form-inline">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" placeholder="<?= $label ?>" disabled="disabled" value="<?= date_format($get_SDateTime, 'G:i') ?>"/>
<?php
$attribute = 'ETime';
$label = 'End Time';
?>
<label class="control-label" style="float:none" for="<?= $attribute ?>" ><?= $label ?></label>
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" style="margin-left:15px" placeholder="<?= $label ?>" disabled="disabled" value="<?= date_format($get_EDateTime, 'G:i') ?>" />
</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 ?>" disabled >
<!--<option value=""></option>-->
<?php foreach ($leaveType as $leaveValue => $leaveLabel) { ?>
<option value="<?= $leaveValue ?>"><?= $leaveLabel ?></option>
<?php } ?>
</select>
</div>
</div>
<hr>
<input type="hidden" id="cancel_lesson_id" name="cancel_lesson_id" value="" />
<h5>Lesson</h5>
<table class="table table-striped table-bordered table-hover table-condensed" style="width:100%" >
<thead>
<tr>
<!-- <th style="min-width:130px; width:50px">View</th>-->
<th style="min-width:50px; width:50px;width:20%">Action</th>
<th style="width:10%" >Date</th>
<th style="width:10%" >Time</th>
<th style="width:10%" >Program</th>
<th style="width:10%" >Subject</th>
<!-- <th style="width:10%" >Staff</th>
<th style="width:10%" >Sudent</th>-->
<!--<th style="width:10%" >Make up</th>-->
<!-- <th>AdminEdit</th>-->
</tr>
</thead>
<tbody>
<?php
foreach ($students_Leave_Lesson_Record as $SLLRecord) {
$query = ""
?>
<tr>
<td>
<?php if ($SLLRecord['lesson_leave_status'] == 1) { ?>
<a href="../Event/Event_DetailFrom.php?lesson_id=<?= $SLLRecord['lesson_id'] ?>&event_id=<?= $SLLRecord['event_id'] ?>&action=3&leave_id=<?= $LID?>" class="btn">Make Up Lesson</a>
<!--<a href="../Event/Event_DetailFrom.php?lesson_id=<?= $SLLRecord['lesson_id'] ?>&event_id=<?= $SLLRecord['event_id'] ?>&action=2&leave_id=<?= $LID ?>" class="btn">Substitute Teacher</a>-->
<button name="Cancel" class="btn" onclick="CancelLesson(<?= $SLLRecord['lesson_id'] ?>, 1);" >Cancel Lesson</button>
<?php
} else if ($SLLRecord['lesson_leave_status'] == 0) {
$current_lesson_id = $SLLRecord['lesson_id'];
$isButtonAvailable = $Leave_Assistant->isUndoButtonAvailable($current_lesson_id);
//var_dump($isButtonAvailable);
if ($isButtonAvailable['available'] == TRUE) {
$onclickListener = "CancelLesson('$current_lesson_id', 2);";
} else if ($isButtonAvailable['available'] == FALSE) {
$onclickListener = "UndoButtonUnavailable('" . $isButtonAvailable['isLessonInMakeUpChain'] . "','" . $isButtonAvailable['isLessonInvoiceGened'] . "','" . $isButtonAvailable['isLessonPayrollGened'] . "','".$isButtonAvailable['isMakeUpLessonUsed']."')";
}
?>
<button name="Undo" class="btn" onclick="return <?= $onclickListener ?>" >Undo Action</button>
<?php
}
?>
</td>
<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>
<button class="btn btn-danger" type="button" onclick="location.href = '../LeaveApplication/LeaveIndex.php';" >Ok</button>
<!--<button class="btn btn-danger" type="button" onclick="location.href = '../LeaveApplication/LeaveIndex.php';" >Back</button>-->
</form>
</div>
</body>
</html>