| 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 : |
<?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'
);
}
}
/////Connect DB here~~
include_once '../include/DBConnect.php';
$deleted = 0;
date_default_timezone_set("Hongkong");
$today = date("Y-m-d");
// 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();
$action = "";
$MaxVersion;
$TempSHID;
$SHCreateBy;
$SHCreateDate;
$name = "";
$position_id = "";
$salary = "";
$rate1 = "";
$rate2 = "";
$rate3 = "";
$rate4 = "";
$rate5 = "";
$rate6 = "";
$other_rate = "";
$is_monthly = "0";
$is_volunteer = "0";
$is_hourly = "0";
if ($_GET) {
if (isset($_GET['root_id'])) {
$action = $_GET['action'];
// var_dump($action);
// var_dump($_GET['root_id']);
$RID = $_GET['root_id'];
$query = "SELECT `last_name`,`first_name`,`ch_name` FROM `staff` WHERE `root_id` = '$RID' and deleted=0";
$result = $dbh->prepare($query);
$result->execute();
if ($ResultSet = $result->fetch(PDO::FETCH_ASSOC)) {
$name = $ResultSet['last_name'] . ' ' . $ResultSet['first_name'] . ', ' . $ResultSet['ch_name'] . '';
}
$query = "SELECT max(version),`createdate`,`createby`,max(staff_his_id) FROM staff_salary_history WHERE staff_id = '$RID' and deleted = 0";
$result = $dbh->prepare($query);
$result->execute();
if ($ResultSet = $result->fetch(PDO::FETCH_ASSOC)) {
$MaxVersion = $ResultSet['max(version)'];
$TempSHID = $ResultSet['max(staff_his_id)'];
$SHCreateBy = $ResultSet['createby'];
$SHCreateDate = $ResultSet['createdate'];
}
if ($action == "Edit") {
$EditVersion = $_GET['version'];
//var_dump($EditVersion);
//Select all base data and set into inputbox
$query = "SELECT *
FROM `staff_salary_history`
WHERE `staff_id` = '$RID' and deleted=0 and version='$EditVersion'"; //AND `deleted` = '$deleted'
$result = $dbh->prepare($query);
$result->execute();
while ($ResultSet = $result->fetch(PDO::FETCH_ASSOC)) {
$SH_ID = $ResultSet['staff_his_id'];
//new
$position_id = $ResultSet['position_id'];
//var_dump($position_id);
$is_monthly = $ResultSet['is_monthly'];
$is_volunteer = $ResultSet['is_volunteer'];
$is_hourly = $ResultSet['is_hourly'];
$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'];
}
}
}
};
if ($_POST) {
$createby = 0;
$actived = 1;
$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;
}
}
if ($action == "Insert") {
$SHCreateDate = $today;
$MaxVersion++;
$query = "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 ('$RID','$SHCreateBy','$SHCreateDate','$createby','$today','$actived','$deleted','$salary','$rate1','$rate2','$rate3','$rate4','$rate5','$rate6','$other_rate','$MaxVersion','$position_id','$is_monthly','$is_volunteer','$is_hourly')";
$sth = $dbh->prepare($query);
$sth->execute();
$sth = $dbh->prepare("SELECT staff_his_id FROM `staff_salary_history`
WHERE `staff_id` = '$RID' and deleted=0 and version='$MaxVersion'");
$sth->execute();
if ($ResultSet = $sth->fetch(PDO::FETCH_ASSOC)) {
$SH_ID = $ResultSet['staff_his_id'];
}
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();
}
}
}
if ($action == "Edit") {
$sth = $dbh->prepare("UPDATE `staff_salary_history` SET `deleted`= '1' WHERE `staff_id` = '$RID' and `version`='$EditVersion'");
$sth->execute();
$query = "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 ('$RID','$SHCreateBy','$SHCreateDate','$createby','$today','$actived','$deleted','$salary','$rate1','$rate2','$rate3','$rate4','$rate5','$rate6','$other_rate','$EditVersion','$position_id','$is_monthly','$is_volunteer','$is_hourly')";
$sth = $dbh->prepare($query);
$sth->execute();
$sth = $dbh->prepare("SELECT staff_his_id FROM `staff_salary_history`
WHERE `staff_id` = '$RID' and deleted=0 and version='$EditVersion'");
$sth->execute();
if ($ResultSet = $sth->fetch(PDO::FETCH_ASSOC)) {
$SH_ID = $ResultSet['staff_his_id'];
}
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();
}
}
}
$result = ($action == "Edit") ? "Update data successful." : "Insert data successful.";
echo "<script>alert('" . $result . "');</script>";
echo "<script>location.href = 'history_index.php?root_id=$RID';</script>";
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="js/select2/select2.css" rel="stylesheet"/>
<script src="js/select2/select2.js"></script>
<?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);
$('.date-picker').datetimepicker({pickTime: false});
//alert('abc');
$('#position_id').val('<?= $position_id ?>');
$('#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 ?>');
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');
});
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;
}
}
</script>
</head>
<body>
<?php
if ($action == "Insert") {
//var_dump($action);
$TName = "Add Staff Salary History";
$Bcolor = 'style="background-color:#eeefde"';
} else {
//var_dump($action);
$TName = "Edit Staff Salary History";
$Bcolor = 'style="background-color:#feffde"';
}
?>
<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"><?= $TName ?></li>
</ul>
</div>
<div class="container-fluid pathways-container " <?= $Bcolor ?> >
<h3><?= $TName ?></h3>
<form class="form-horizontal" action="" method="post" enctype="multipart/form-data">
<h5> Staff Information </h5>
<div class="control-group">
<?php
$attribute = 'staff_name';
$label = 'Staff Name';
?>
<label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls form-inline">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>" class="" value="<?= $name ?>" placeholder="<?= $label ?>" maxlength="200" disabled />
</div>
</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="" value='' 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[]" 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[]" 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[]" 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 ?>" 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 ?>" 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 ?>" 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 ?>" 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 ?>" 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 ?>" 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 ?>" 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 ?>" maxlength="200" />
</div>
</div>
<button class="btn btn-danger" id="" onclick="return countClicks();" >Save</button>
<a href="history_index.php?root_id=<?= $RID ?>" class="btn btn-danger">Back</a>
</form>
</div>
</body>
</html>
<?php
if ($action == 'Edit') {
$query = "SELECT * FROM `staff_program` WHERE `staff_id` = '$SH_ID' AND `deleted` = '$deleted'";
$result = $dbh->prepare($query);
$result->execute();
while ($ResultSet = $result->fetch(PDO::FETCH_ASSOC)) {
?>
<script>
$(function() {
$('input:checkbox[id="program_<?= $ResultSet['program_id'] ?>"]').attr('checked', 'checked');
});</script>
<?php
//var_dump($ResultSet);
};
$query = "SELECT * FROM `staff_subject` WHERE `staff_id` = '$SH_ID' AND `deleted` = '$deleted'";
$result = $dbh->prepare($query);
$result->execute();
while ($ResultSet = $result->fetch(PDO::FETCH_ASSOC)) {
?>
<script>
$(function() {
$('input:checkbox[id="subject_<?= $ResultSet['subject_id'] ?>"]').attr('checked', 'checked');
});
</script>
<?php
//var_dump($ResultSet);
};
}
?>