| 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 : |
<?php
include_once '../include/DBConnect.php';
date_default_timezone_set("Hongkong");
$today = date("Y-m-d");
$SID = "";
$staffs_Leave_Record = array();
$students_Leave_Record = array();
class LeaveSearch {
public static function searchType() {
return array(
'A' => 'All',
'Student' => 'Student',
'Staff' => 'Staff'
);
}
}
if (!$_POST) {
$query = 'SELECT lapp.*,CONCAT( last_name, " ", first_name, "(", ch_name, ")" ) AS name FROM leave_app lapp,staff s WHERE `stu_linking_id` = "-1" AND lapp.staff_id > 0 AND s.deleted = 0 AND lapp.deleted = 0 AND s.root_id = lapp.staff_id order by lapp.`leave_id`';
$result = $dbh->prepare($query);
$result->execute();
$staffs_Leave_Record = $result->fetchAll();
$query = 'SELECT lapp.*,CONCAT( last_name, " ", first_name, "(", ch_name, ")" ) AS name FROM leave_app lapp,student stu WHERE lapp.`stu_linking_id` >0 AND lapp.staff_id ="-1" AND stu.deleted = 0 and stu.actived=1 AND lapp.deleted = 0 and lapp.actived=1 AND stu.root_id = lapp.`stu_linking_id` order by lapp.`leave_id`';
$result = $dbh->prepare($query);
$result->execute();
$students_Leave_Record = $result->fetchAll();
}
$get_Search_Target = "";
$get_Search_Name = "";
if ($_POST) {
if (isset($_POST['search'])) {
$search = $_POST['search'];
//var_dump($search);
$get_Search_Target = $search['type'];
$get_Search_Name = $search['InputValue'];
$search_Date_Query = "";
if ($search['SDate'] != "" && $search['EDate'] != "") {
$get_Search_SDate = date_format(date_create($search['SDate'] . ' 00:00:00'), 'Y-m-d H:i:s');
$get_Search_EDate = date_format(date_create($search['EDate'] . ' 23:59:59'), 'Y-m-d H:i:s');
$search_Date_Query = " and lapp.`createdate`>='$get_Search_SDate' and lapp.`createdate`<='$get_Search_EDate' ";
}
if ($get_Search_Target == "Staff" || $get_Search_Target == "A") {
//if($get_Search_Name!="")
$query = 'SELECT lapp.*,CONCAT( last_name, " ", first_name, "(", ch_name, ")" ) AS name FROM leave_app lapp,staff s WHERE `stu_linking_id` = "-1" AND lapp.staff_id > 0 AND s.deleted = 0 AND lapp.deleted = 0 AND s.root_id = lapp.staff_id ';
$query.= " and concat(last_name,' ',first_name,'(',ch_name,')') like '%$get_Search_Name%'";
$query.= $search_Date_Query;
$query.= ' order by lapp.`leave_id`';
$result = $dbh->prepare($query);
$result->execute();
$staffs_Leave_Record = $result->fetchAll();
}
if ($get_Search_Target == "Student" || $get_Search_Target == "A") {
$query = 'SELECT lapp.*,CONCAT( last_name, " ", first_name, "(", ch_name, ")" ) AS name FROM leave_app lapp,student stu WHERE lapp.`stu_linking_id` >0 AND lapp.staff_id ="-1" AND stu.deleted = 0 and stu.actived=1 AND lapp.deleted = 0 and lapp.actived=1 AND stu.root_id = lapp.`stu_linking_id` ';
$query.= " and concat(last_name,' ',first_name,'(',ch_name,')') like '%$get_Search_Name%'";
$query.= $search_Date_Query;
$query.= ' order by lapp.`leave_id`';
$result = $dbh->prepare($query);
$result->execute();
$students_Leave_Record = $result->fetchAll();
}
}
}
?>
<!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>
$(document).ready(function() {
$('div input').height(20);
//$('.date-picker').datetimepicker({pickTime: false});
DBdata = [];
CurrentInput = '';
//Output selected data
$("#e11_2").on("change", function(e) {
//alert("change " + JSON.stringify({val: e.val, added: e.added, removed: e.removed}));
});
//loading data form database
$.ajax({
url: 'list.php', //This is the current doc
type: "POST",
data: {Data: CurrentInput, Data2: 10},
success: function(data) {
var obj = $.parseJSON(data);
// alert(JSON.stringify(obj));
//alert(JSON.stringify(Data));
$.each(obj, function(key, value) {
DBdata.push({id: value['staffName'], text: value['staffName']});
});
//alert(JSON.stringify(DBdata));
}
});
//setting select2
$("#e11_2").select2({
minimumInputLength: 0,
maximumSelectionSize: 1,
createSearchChoice: function(term, data) {
//alert(JSON.stringify(data));
CurrentInput = term;
//alert(term);
return {id: term, text: term};
},
multiple: false,
data: DBdata
});
//$('#e11_2').select2('val',{ id: 'Sid6', text:'X' }) ;
//var search = ;
//if(search!=="")
<?php if ($_POST && $get_Search_Name != "") { ?>
$(function() {
$('#e11_2').select2('data', {id: '<?= $get_Search_Name ?>', text: '<?= $get_Search_Name ?>'});
});
<?php } ?>
});
$(function() {
$('.date-picker').datetimepicker({pickTime: false});
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');
});
});
<?php if ($_POST) { ?>
$('#search_type_div option[value=<?= $get_Search_Target ?>]').attr('selected', 'selected');
<?php } ?>
function ApproveLeave(ALID) {
$.ajax({
url: 'approve_leave.php', //This is the current doc
type: "POST",
data: {ALID: ALID},
success: function(data) {
var obj = $.parseJSON(data);
$.each(obj, function(key, value) {
//alert(value['success']);
});
location.reload();
}
});
}
</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>Leave Application</h2>
<div class="pathways-search">
<form id="search_form" class="form-inline" action="" method="POST">
<div class="pathways-inline-block">
Search by Name:
<input type="hidden" id="e11_2" style="width:300px" tabindex="-1" name="search[InputValue]" class="select2-offscreen" value="">
</div>
<div class="pathways-inline-block" id="search_type_div">
Type:
<select id="search_type" style="width:150px" name="search[type]" value="">
<?php
foreach (LeaveSearch::searchType() as $TValue => $Type) {
$selected = "";
if ($get_Search_Target == $TValue)
$selected = "selected";
print '<option value="' . $TValue . '" ' . $selected . ' >' . $Type . '</option>';
}
?>
</select>
</div>
<div class="pathways-inline-block">
<?php
$attribute = 'SDate';
$label = 'Start Date';
?>
<div class="controls form-inline">
<label class="control-label" style="float:none;" for="<?= $attribute ?>" ><?= $label ?></label>
<div class="input-append date-picker" id="SDate_id">
<input type="text" id="<?= $attribute ?>" name="search[<?= $attribute ?>]" class="dateISO" data-format="yyyy-MM-dd" placeholder="<?= $label ?>" value="<?= $_POST ? $search['SDate'] : '' ?>" maxlength="200" value="" />
<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;" for="<?= $attribute ?>" ><?= $label ?></label>
<div class="input-append date-picker" id="EDate_id">
<input type="text" id="<?= $attribute ?>" name="search[<?= $attribute ?>]" style="margin-left:20px" class="dateISO" data-format="yyyy-MM-dd" placeholder="<?= $label ?>" value="<?= $_POST ? $search['EDate'] : '' ?>" maxlength="200" value="" />
<span class="add-on"><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>
</div>
<div class="pathways-inline-block">
<!--<input type="hidden" id="Staff_ID" name="search[Staff_ID]" value="0" />-->
<button type="submit" class="btn" style="margin-left:30px">Search</button>
</div>
</div>
</div>
<input type="hidden" id="approve_leave" name="approve_leave" value="" />
</form>
</div>
<form id="form" action="" method="post">
<div class="pathways-inline-block" style="width:100%" >
<div class="pathways-inline-block"style="width:100%" >
<h3>Staff <a class="btn pull-right" href="Staff_App_Form.php"><i class="icon-plus"></i>Add</a></h3>
</div>
<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:10%">Edit</th>
<th style="width:10%" >Date</th>
<th style="width:10%" >Name</th>
<th style="width:15%" >duration</th>
<!-- <th>AdminEdit</th>-->
</tr>
</thead>
<tbody>
<?php
$displayStatusColor = "";
foreach ($staffs_Leave_Record as $staffLRecord) {
//var_dump($staffLRecord);
$pass = 0;
//Set which color have to display in each tr
$SeachLeaveID = $staffLRecord['leave_id'];
$query = "SELECT l.lesson_id,ll.leave_lesson_id FROM `leave_lesson`ll,`lesson`l WHERE `leave_id` = '$SeachLeaveID' AND l.`actived` = '1' AND l.`deleted` = '0' AND l.`lesson_leave_status`= '1' AND ll.actived ='1' and ll.deleted='0' and ll.lesson_id = l.lesson_id";
$result = $dbh->prepare($query);
$result->execute();
$staffs_Leave_Lesson_Record = $result->fetchAll();
if ($staffs_Leave_Lesson_Record) {
$displayStatusColor = "error";
//var_dump($staffs_Leave_Lesson_Record);
} else {
$displayStatusColor = "success";
$pass = 1;
}
?>
<tr class="<?= $displayStatusColor ?>">
<td>
<div class="btn-group" data-toggle="buttons">
<a href="Staff_App_Form.php?leave_id=<?= $staffLRecord['leave_id'] ?>&action=View" class="btn">View</a>
<?php
if ($staffLRecord['is_approved'] == 1) {
?>
<a href="Staff_Approve.php?leave_id=<?= $staffLRecord['leave_id'] ?>&action=FollowUpAction" class="btn"><!--<i class="icon-pencil"></i>-->Action</a>
<?php
} else {
?>
<button name="Approved" type="button" class="btn" onclick="ApproveLeave(<?= $staffLRecord['leave_id'] ?>);" >Approve</button>
<?php
}
?>
<!--<button name="Approved" class="btn" onclick="" >Approved</button>-->
<!--<a href="Staff_Approve.php?leave_id=<?= $staffLRecord['leave_id'] ?>&makeup_lesson_id=3&lesson_id=2&action=1&event_id=1" class="btn">testing</a>-->
</div>
</td>
<td>
<?php print '<b>' . substr($staffLRecord['createdate'], 0, 10) . '</b>'; ?>
</td>
<td>
<?php print '<b>' . $staffLRecord['name'] . '</b>'; ?>
</td>
<td>
<?php
$get_Sdate = date_create($staffLRecord['start_date']);
$get_Edate = date_create($staffLRecord['end_date']);
if (date_format($get_Sdate, 'Y-m-d') != date_format($get_Edate, 'Y-m-d')) {
print '<b>' . date_format($get_Sdate, 'Y-m-d (H:i)') . '</b>';
print '<br>TO<br>';
print '<b>' . date_format($get_Edate, 'Y-m-d (H:i)') . '</b>';
} else {
print '<b>' . date_format($get_Sdate, 'Y-m-d') . '</b>';
print '<br>';
print '(' . date_format($get_Sdate, 'H:i') . '-' . date_format($get_Edate, 'H:i') . ')';
}
?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<div class="pathways-inline-block" style="width:100%" >
<div class="pathways-inline-block"style="width:100%" >
<h3>Student<a class="btn pull-right" href="Student_App_Form.php"><i class="icon-plus"></i>Add</a></h3>
</div>
<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:10%">Edit</th>
<th style="width:10%" >Date</th>
<th style="width:10%" >Name</th>
<th style="width:15%" >duration</th>
<!-- <th>AdminEdit</th>-->
</tr>
</thead>
<tbody>
<?php
$displayStatusColor = "";
foreach ($students_Leave_Record as $studentLRecord) {
//var_dump($staffLRecord);
$pass = 0;
//Set which color have to display in each tr
$SeachLeaveID = $studentLRecord['leave_id'];
$query = "SELECT l.lesson_id,ll.leave_lesson_id FROM `leave_lesson`ll,`lesson`l WHERE `leave_id` = '$SeachLeaveID' AND l.`actived` = '1' AND l.`deleted` = '0' AND l.`lesson_leave_status`= '1' AND ll.actived ='1' and ll.deleted='0' and ll.lesson_id = l.lesson_id";
$result = $dbh->prepare($query);
$result->execute();
$students_Leave_Lesson_Record = $result->fetchAll();
if ($students_Leave_Lesson_Record) {
$displayStatusColor = "error";
//var_dump($staffs_Leave_Lesson_Record);
} else {
$displayStatusColor = "success";
$pass = 1;
}
?>
<tr class="<?= $displayStatusColor ?>">
<td>
<div class="btn-group" data-toggle="buttons">
<a href="Student_App_Form.php?leave_id=<?= $studentLRecord['leave_id'] ?>&action=View" class="btn">View</a>
<?php
if ($studentLRecord['is_approved'] == 1) {
?>
<a href="Student_Approve.php?leave_id=<?= $studentLRecord['leave_id'] ?>&action=FollowUpAction" class="btn"><!--<i class="icon-pencil"></i>-->Action</a>
<?php
} else {
?>
<button name="Approved" type="button" class="btn" onclick="ApproveLeave(<?= $studentLRecord['leave_id'] ?>);" >Approve</button>
<?php
}
?>
</div>
</td>
<td>
<?php print '<b>' . substr($studentLRecord['createdate'], 0, 10) . '</b>'; ?>
</td>
<td>
<?php print '<b>' . $studentLRecord['name'] . '</b>'; ?>
</td>
<td>
<?php
$get_Sdate = date_create($studentLRecord['start_date']);
$get_Edate = date_create($studentLRecord['end_date']);
if (date_format($get_Sdate, 'Y-m-d') != date_format($get_Edate, 'Y-m-d')) {
print '<b>' . date_format($get_Sdate, 'Y-m-d (H:i)') . '</b>';
print '<br>TO<br>';
print '<b>' . date_format($get_Edate, 'Y-m-d (H:i)') . '</b>';
} else {
print '<b>' . date_format($get_Sdate, 'Y-m-d') . '</b>';
print '<br>';
print '(' . date_format($get_Sdate, 'H:i') . '-' . date_format($get_Edate, 'H:i') . ')';
}
?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</form>
</div>
</body>
</html>