| Server IP : 210.245.233.93 / Your IP : 216.73.216.226 Web Server : Apache/2.2.15 (CentOS) System : Linux webserver2.onesolution.com.hk 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 User : apache ( 48) PHP Version : 5.3.3 Disable Function : exec, shell_exec, system, passthru, popen, proc_open, pcntl_exec MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/(Del)pathways.org.hk/MIS20140127/old20140314/LeaveApplication/ |
Upload File : |
<?php
include_once '../include/DBConnect.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 Status() {
return array(
0 => 'Pending',
1 => 'Approved'
);
}
}
$genderOptions = General::genderOptions();
$leaveType = Leave::Type();
$leaveStatus = Leave::Status();
date_default_timezone_set("Hongkong");
$today = date("Y-m-d");
if ($_POST) {
$actived = 1;
$deleted = 0;
$input_by = $_POST['input_by'];
$input_date = $_POST['input_date'];
$staff_id_1 = $_POST['staff_code'];
$staff_id_2 = $_POST['staff_name'];
$SID = "";
$stuID = -1;
if($staff_id_1 == $staff_id_2){
$SID = $staff_id_1;
}
else{
echo '<script>alert("Your input data have some problems");</script>';
echo '<script>history.back();</script>';
}
$Sdate = $_POST['SDate'];
$Edate = $_POST['EDate'];
$Stime = $_POST['STime'];
$Etime = $_POST['ETime'];
$is_full_date = -1;
$event_id = -1;
$is_sick = -1;
$leave_type = $_POST['leave_type'];
$leave_status = $_POST['leave_status'];
$approved_by = -1;
$remarks = "";
$query = "INSERT INTO `leave_app`(`createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `staff_id`, `stu_linking_id`, `leave_date`, `is_full_day`, `event_id`, `is_sick`, `reason`, `approve_by`, `is_approve`, `remarks`)
VALUES ('$input_by','$input_date','$input_by','$input_date','$actived','$deleted','$SID','$stuID','$Sdate','$is_full_date','$event_id','$is_sick','$leave_type','$approved_by','$leave_status','$remarks')";
$sth = $dbh->prepare($query);
if($SID !="")
$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>
$(function() {
$('div input').height(20); //fix size for input box
$('.date-picker').datetimepicker({pickTime: false});
$('.time-picker').datetimepicker({pickDate: false});
$('#SDate').val('<?= $today ?>'); //Generate by system
$('#EDate').val('<?= $today ?>'); //Generate by system
$("#myselect").select2({
placeholder: "Staff Code",
minimumInputLength: 1,
allowClear: true
});
$("#myselect2").select2({
placeholder: "Staff Name",
minimumInputLength: 2,
allowClear: true
});
});
</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>Staff Application</h2>
<form class="form-horizontal" action="" method="post" >
<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="<?= $_SESSION['MIS_login']['username'] ?>" placeholder="<?= $label ?>" maxlength="200" disabled />
<input type="hidden" id="<?= $attribute ?>" name="<?= $attribute ?>" class="required" value="<?= $_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="<?= $today ?>" data-format="yyyy-MM-dd" placeholder="<?= $label ?>" maxlength="200" disabled />
<input type="hidden" id="<?= $attribute ?>" name="<?= $attribute ?>" class="dateISO" value="<?= $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 = 'staff_name';
$label = 'Staff 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" />
<select id="myselect2" 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['name'] ?></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 ?>">
<!--<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">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="dateISO" value="" data-format="yyyy-MM-dd" placeholder="<?= $label ?>" maxlength="200" />
<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">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" style="margin-left:20px" class="dateISO" value="" data-format="yyyy-MM-dd" placeholder="<?= $label ?>" 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 = 'STime';
$label = 'Start Time';
?>
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls form-inline">
<div class="input-append time-picker">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="dateISO" value="" data-format="hh:mm" placeholder="<?= $label ?>" maxlength="200" />
<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">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" style="margin-left:20px" class="dateISO" value="" data-format="hh:mm" placeholder="<?= $label ?>" 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 = '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>
<button class="btn btn-danger" id="">Save</button>
<button class="btn btn-danger" type="button" onclick="history.back();" >Back</button>
</form>
</div>
</body>
</html>