| 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/Event/ |
Upload File : |
<!DOCTYPE html>
<html>
<head>
<?php include_once '../include/DBConnect.php'; ?>
<?php require_once '../include/head.php'; ?>
<?php require_once '../include/checkuser.php'; ?>
<?php require_once '../include/Nav_bar.php'; ?>
<script>
var student_id,staff_id,row=0,row_staff=0,date;
$(function(){
$.fn.modal.Constructor.prototype.enforceFocus = function () {};
$('#programme_fee').change(function(){
var fee = $('#programme_fee').val();
$.get('Event_AddFrom_ajax.php?feetype=' + fee, funfee);
});
function funfee(res){
$('#programme_fee_tr').html(res);
}
$("#subject_id").change(function(){
var programme = $("#programme_id").val();
var subject = $(this).val();
$.get("Event_AddFrom_ajax.php?subject="+subject+"&programme="+programme, funsubpro);
});
function funsubpro(res) {
var str = res.split("|");
var primary_individual_price = str[0];
var primary_group_price = str[1];
var primary_package_price = str[2];
var secondary_individual_price = str[3];
var secondary_group_price = str[4];
var secondary_package_price = str[5];
if (primary_individual_price == 0 && primary_group_price == 0 && primary_package_price == 0 &&
secondary_individual_price == 0 && secondary_group_price == 0 && secondary_package_price == 0) {
$('#programme_fee').val(3);
$('#programme_fee').change();
} else {
if (primary_package_price == 0 && secondary_package_price == 0) {
$('#programme_fee').val(2);
$('#programme_fee').change();
} else {
$('#programme_fee').val(1);
$('#programme_fee').change();
}
}
$("#primary_ind").val(primary_individual_price);
$("#primary_gp").val(primary_group_price);
$("#secondary_ind").val(secondary_individual_price);
$("#secondary_gp").val(secondary_group_price);
$("#primary_package_fee").val(primary_package_price);
$("#secondary_package_fee").val(secondary_package_price);
}
$('#start_date_id').datetimepicker({ autoclose: true,pickTime: false, startDate: new Date() });
$('#start_date_id').datetimepicker().on('changeDate', function(ev){
date = new Date($('#Start_date').val());
$('#End_date_id').datetimepicker('setStartDate',date);
$('#End_date_id').datetimepicker('setDate',date);
$('#End_date_id').datetimepicker('show');
$('#start_date_id').datetimepicker('hide');
$('#End_date_id').datetimepicker('remove');
});
$('.timepicker_start').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' });
$('#End_date_id').datetimepicker({ autoclose: true,pickTime: false,startDate: new Date() });
$('#End_date_id').datetimepicker().on('changeDate', function(ev){ $('#End_date_id').datetimepicker('hide'); });
$('.time_1').focus(function(){ $(this).val(''); });
$('.time_2').focus(function(){ $(this).val(''); });
$('.time_1').keyup(function(){
if($(this).val() >= 24){
$(this).val('');
}else {
if($(this).val().length == 2)
$(this).parent().next().next().children().focus();
}
});
$('.time_2').keyup(function(e){
if($(this).val() >= 60 ){
$(this).val('');
}else {
if($(this).val().length == 2)
$(this).parent().next().next().next().next().children().focus();
}
});
$("#commentForm").validate();
$("#student_name").select2();
$('#staff_name').select2();
$("#student_name").on("select2-selecting", function(e) { student_id=e.val.split(","); });
$('#staff_name').on("select2-selecting", function(e){ staff_id=e.val.split(",") });
$('#btn_addstudent').click(function(){ row++; $('#student_table').append('<tr id="tr_'+row+'"> <td><button type="button" class="btn" onclick="displayResult('+row+');"><i class="icon-remove"></i></button></td> <td>'+student_id[0]+'</td> <td>'+student_id[1]+' ( '+student_id[2]+' ) '+'<input type="hidden" name="student_id[]" value="'+student_id[3]+'"/></td> </tr>') });
$('#btn_addstaff').click(function() { row_staff++; if($('#Rate_staff').val()!='') $('#staff_table').append('<tr id="row_'+row_staff+'"> <td><button type="button" class="btn" onclick="deleterow('+row_staff+')" ><i class="icon-remove"></i></button></td> <td>'+staff_id[0]+' ( '+staff_id[1]+' ) '+'</td> <td>'+$('#Rate_staff').val()+' <input type="hidden" name="staff_id[]" value="'+staff_id[2]+'" /><input type="hidden" name="staff_rate[]" value="'+$('#Rate_staff').val()+'" /></td> </tr>') });
});
function displayResult(r){
var row = document.getElementById("tr_"+r);
row.parentNode.removeChild(row);
}
function deleterow(r){
var row = document.getElementById("row_"+r);
row.parentNode.removeChild(row);
}
function limit_time(e){
var arr = $(e).val().split(":")[0] * 3600 + $(e).val().split(":")[1]*60 + 15*60 ;
$(e).parent().next().next().next().next().children().timepicker('option',{disableTimeRanges: [['6:00',arr]]});
};
function undisabled_select(){
$('#school_type').attr("disabled", false);
$('#programme_id').attr("disabled", false);
$('#subject_id').attr("disabled", false);
}
</script>
<?php if (!isset($_GET['event_id']) && !isset($_GET['view'])) { ?>
<style>
.div-background {
border: 1px solid #E6E6E6;
border-radius: 6px 6px 6px 6px;
background-color: #EEEFDE;
padding-top: 10px;
padding-bottom: 10px;
}
</style>
<?php } ?>
<?php if (isset($_GET['event_id']) && !isset($_GET['view'])) { ?>
<style>
.div-background {
border: 1px solid #E6E6E6;
border-radius: 6px 6px 6px 6px;
background-color: #feffde;
padding-top: 10px;
padding-bottom: 10px;
}
</style>
<?php } ?>
</head>
<?php
if (isset($_POST['Event_delete'])) {
$dbh->query("UPDATE `event` SET `lastupdate`=now(),`deleted`=1 WHERE `event_id`='" . $_GET['event_id'] . "' ");
$dbh->query("UPDATE `event_lesson` set`lastupdate`=now(),`deleted`=1 WHERE `event_id`='" . $_GET['event_id'] . "'");
$dbh->query("UPDATE `lesson` set `lastupdate`=now(),`deleted`=1 WHERE `lesson_id` in (select lesson_id from event_lesson WHERE `event_id`='" . $_GET['event_id'] . "')");
$dbh->query("UPDATE `lesson_attendance` set `lastupdate`=now(),`deleted`=1 WHERE `lesson_id` in (select lesson_id from event_lesson WHERE `event_id`='" . $_GET['event_id'] . "')");
header("Location: Event_List.php");
}
?>
<?php
$code = '';
$class_size = '';
$programme = '';
$subject_id = '';
$primary_ind = '';
$primary_gp = '';
$secondary_ind = '';
$secondary_gp = '';
$primary_package_fee = '';
$primary_package_discount = '';
$secondary_package_fee = '';
$secondary_package_discount = '';
$Programme_fee_type = 0;
?>
<?php
//////////////////////////////////////Edit page get new data //////////////////////////////////////////////////////////////
if (isset($_POST['Event_Save'])) {
$code = $_POST['code'];
$class_size = $_POST['class_size'];
$programme = $_POST['programme'];
$subject_id = $_POST['subject_id'];
$Programme_fee_type = $_POST['programme_fee'];
$school_type = $_POST['school_type'];
if ($Programme_fee_type == 1) {
$primary_ind = $_POST['primary_ind'];
$primary_gp = $_POST['primary_gp'];
$secondary_ind = $_POST['secondary_ind'];
$secondary_gp = $_POST['secondary_gp'];
$primary_package_fee = 0;
$primary_package_discount = 0;
$secondary_package_fee = 0;
$secondary_package_discount = 0;
}
if ($Programme_fee_type == 2) {
$primary_ind = 0;
$primary_gp = 0;
$secondary_ind = 0;
$secondary_gp = 0;
$primary_package_fee = $_POST['primary_package_fee'];
$primary_package_discount = $_POST['primary_package_discount'];
$secondary_package_fee = $_POST['secondary_package_fee'];
$secondary_package_discount = $_POST['secondary_package_discount'];
}
if ($Programme_fee_type == 3) {
$primary_ind = 0;
$primary_gp = 0;
$secondary_ind = 0;
$secondary_gp = 0;
$primary_package_fee = 0;
$primary_package_discount = 0;
$secondary_package_fee = 0;
$secondary_package_discount = 0;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////update data to db//////////////////////////////////////////////////////////////
$sth = $dbh->query('UPDATE `event` SET `lastupdate`=now(),`deleted`=1 WHERE `event_id` = ' . $_REQUEST['event_id'] . '');
$sth = $dbh->prepare("INSERT INTO `event`(`createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`,
`event_code`, `program_id`, `subject_id`, `class_size`, `programme_fee_type`,
`primary_individual_price`, `primary_group_price`, `primary_package_price`,
`secondary_individual_price`, `secondary_group_price`, `secondary_package_price`,`is_free`,school_id)
Values(1,now(),1,now(),1,0,?,?,?,?,?,?,?,?,?,?,?,1,?)");
$sth->bindParam(1, $code);
$sth->bindParam(2, $programme);
$sth->bindParam(3, $subject_id);
$sth->bindParam(4, $class_size);
$sth->bindParam(5, $Programme_fee_type);
$sth->bindParam(6, $primary_ind);
$sth->bindParam(7, $primary_gp);
$sth->bindParam(8, $primary_package_fee);
$sth->bindParam(9, $secondary_ind);
$sth->bindParam(10, $secondary_gp);
$sth->bindParam(11, $secondary_package_fee);
$sth->bindParam(12, $school_type);
$sth->execute();
$tmp_lesson_id = array();
$sth = $dbh->query("SELECT `lesson_id` FROM `event_lesson` WHERE `event_id`=" . $_GET['event_id'] . " and deleted=0 and actived=1");
while ($ResultSet = $sth->fetch(PDO::FETCH_ASSOC)) {
array_push($tmp_lesson_id, $ResultSet['lesson_id']);
}
$sth = $dbh->query("UPDATE `event_lesson` SET `lastupdate`=now(),`deleted`=1 WHERE `event_id`=" . $_GET['event_id'] . "");
$sth = $dbh->query("select max(event_id) id from event");
$event_id = $sth->fetch(PDO::FETCH_ASSOC);
foreach ($tmp_lesson_id as $tmp) {
$sth2 = $dbh->query("INSERT INTO `event_lesson`(`event_id`, `createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `lesson_id`) VALUES (" . $event_id['id'] . ",0,now(),0,now(),1,0," . $tmp . ")");
}
echo '<script>location.href = "Event_List.php";</script>';
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////Edit page first load all value for the field/////////////////////////////////////////////
if (isset($_REQUEST['event_id'])) {
$sth = $dbh->prepare('SELECT * FROM `event` WHERE `event_id`=?');
$sth->bindParam(1, $_REQUEST['event_id']);
$sth->execute();
while ($ResultSet = $sth->fetch(PDO::FETCH_ASSOC)) {
$code = $ResultSet['event_code'];
$class_size = $ResultSet['class_size'];
$programme = $ResultSet['program_id'];
$subject_id = $ResultSet['subject_id'];
$primary_ind = $ResultSet['primary_individual_price'];
$primary_gp = $ResultSet['primary_group_price'];
$secondary_ind = $ResultSet['secondary_individual_price'];
$secondary_gp = $ResultSet['secondary_group_price'];
$primary_package_fee = $ResultSet['primary_package_price'];
//$primary_package_discount = $ResultSet['package_discount'];
$primary_package_discount = 0;
$secondary_package_fee = $ResultSet['secondary_package_price'];
//$secondary_package_discount = $ResultSet['sec_package_discount'];
$primary_package_discount = 0;
$Programme_fee_type = $ResultSet['programme_fee_type'];
$school_type = $ResultSet['school_id'];
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
?>
<body>
<!-- line between nav bar and content -->
<div class="text-right">
<ul class="breadcrumb">
<li><a href="Event_List.php">Event</a> <span class="divider">></span></li>
<?php if (isset($_GET['event_id']) && !isset($_GET['view'])) { ?>
<li class="active">Edit Event</li>
<?php } ?>
<?php if (!isset($_GET['view']) && !isset($_GET['event_id'])) { ?>
<li class="active">Add Event</li>
<?php } ?>
<?php if (isset($_GET['view'])) { ?>
<li class="active">View Event</li>
<?php } ?>
</ul>
</div>
<div class="container-fluid <?= (isset($_GET['view']) && isset($_GET['event_id'])) ? "pathways-container" : "div-background" ?>">
<?php if (isset($_GET['event_id']) && !isset($_GET['view'])) { ?><h3>Edit Event</h3>
<?php } if (!isset($_GET['view']) && !isset($_GET['event_id'])) { ?><h3>Add Event</h3>
<?php } if (isset($_GET['view'])) { ?><h3>View Evnet</h3> <?php } ?>
<form method="post" action="<?php if (isset($_REQUEST['event_id'])) echo '';else echo 'Event_DetailFrom.php'; ?>" id="commentForm" autocomplete="off">
<table>
<tr>
<td style="width: 200px;text-align: right;"><label for="school_type">School Type</label></td>
<td style="width: 30px"></td>
<td><!-- new -->
<?php
if (isset($_GET['view'])) {
if ($school_type == 0) $editview_eventtype = "Pathways";
if ($school_type == 1) $editview_eventtype = "In-School";
if ($school_type != 0 || $school_type != 1) {
$sth = $dbh->query("SELECT concat(sch_name,' ( ',sch_ch_name,' ) ') sch_name FROM `school` WHERE actived = 1 and deleted = 0 and root_id = $school_type ");
$result = $sth->fetch(PDO::FETCH_ASSOC);
$editview_eventtype = $result['sch_name'];
}
?>
<input type="text" value="<?= $editview_eventtype ?>" readonly/>
<?php } else { ?>
<select id="school_type" autocomplete="off" name="school_type" class="required" >
<option></option>
<option <?= (isset($school_type)) ? ($school_type == 0) ? "selected" : "" : "" ?> value="0">Pathways</option>
<option <?= (isset($school_type)) ? ($school_type == 1) ? "selected" : "" : "" ?> value="1">In-School</option>
<?php $sth = $dbh->query("SELECT root_id, sch_code, sch_name, sch_ch_name FROM `school` WHERE actived = 1 and deleted = 0"); ?>
<?php while ($Result = $sth->fetch(PDO::FETCH_ASSOC)) { ?>
<option <?= (isset($school_type)) ? ($school_type == $Result['root_id']) ? "selected" : "" : "" ?> value="<?= $Result['root_id'] ?>"><?= $Result['sch_name'] ?> ( <?= $Result['sch_ch_name'] ?> ) </option>
<?php } ?>
</select>
<?php } ?>
</td>
</tr>
<tr style="height: 15px"></tr>
<tr>
<?php if (isset($_GET['event_id'])) { ?>
<!-- Code -->
<td style="width: 200px;text-align: right;"><label for="code_id">Code</label></td>
<td style="width: 30px"></td>
<td><input readonly id="code_id" autocomplete="off" type="text" maxlength="150" placeholder="Code" value="<?= $code ?>" name="code" class="required" /></td>
<?php } else { ?>
<td style="width: 200px;text-align: right;"><label for="event_type">Event Type</label></td>
<td style="width: 30px"></td>
<td><!-- new -->
<select id="event_type" autocomplete="off" name="event_type" class="required" >
<option></option>
<option value="0">Group</option>
<option value="1">Indvidual</option>
</select>
</td>
<?php } ?>
<!-- Class Size -->
<td style="width: 200px;text-align: right;"><label for="class_size">Class Size</label></td>
<td style="width: 30px"></td>
<td><input <?= (isset($_GET['view'])) ? "readonly" : "" ?> id="class_size" class="required" type="text" maxlength="150" placeholder="Class Size" value="<?= $class_size ?>" name="class_size" autocomplete="off" onkeydown="return ( event.ctrlKey || event.altKey || (47<event.keyCode && event.keyCode<58 && event.shiftKey==false) || (95<event.keyCode && event.keyCode<106) || (event.keyCode==8) || (event.keyCode==9) || (event.keyCode>34 && event.keyCode<40) || (event.keyCode==46) )"/></td>
<!-- new group/ind -->
</tr>
<tr style="height: 15px"></tr>
<tr>
<!-- programme -->
<td style="width: 200px;text-align: right;"><label for="Programme_id">Programme</label></td>
<td style="width: 30px"></td>
<td>
<?php if (isset($_GET['view'])) { ?>
<?php $sth = $dbh->query("SELECT program_code FROM `program` WHERE actived=1 and deleted = 0 and program_id = $programme order by `sort`"); ?>
<?php $result = $sth->fetch(PDO::FETCH_ASSOC); ?>
<?php $editview_program = $result['program_code']; ?>
<input type="text" value="<?= $editview_program ?>" readonly name="programme" />
<?php } else { ?>
<?php echo '<script>$(function(){ document.getElementById(\'programme_id\').value = ' . $programme . '}); </script>'; ?>
<?php $sth = $dbh->query('SELECT * FROM `program` WHERE `deleted` = 0 order by `sort`'); ?>
<select <?= (isset($_GET['view']) || isset($_GET['event_id'])) ? "disabled" : "" ?> id="programme_id" name="programme" class="required">
<?php echo '<option value=""></option>'; ?>
<?php while ($ResultSet = $sth->fetch(PDO::FETCH_ASSOC)) { ?>
<option value="<?= $ResultSet['program_id'] ?>"><?= $ResultSet['program_code'] ?></option>
<?php } ?>
</select>
<?php } ?>
</td>
<!-- Subject -->
<td style="width: 200px;text-align: right;"><label for="class_size">Subject</label></td>
<td style="width: 30px"></td>
<td>
<?php if (isset($_GET['view'])) { ?>
<?php $sth = $dbh->query("SELECT sub_code FROM `subject` WHERE actived=1 and deleted=0 and subject_id=$subject_id order by `sort`"); ?>
<?php $result = $sth->fetch(PDO::FETCH_ASSOC); ?>
<?php $editview_subject = $result['sub_code']; ?>
<input type="text" value="<?= $editview_subject ?>" readonly name="subject_id" />
<?php } else { ?>
<?php echo '<script>$(function(){ document.getElementById(\'subject_id\').value = ' . $subject_id . '}); </script>'; ?>
<?php $sth = $dbh->query('SELECT * FROM `subject` WHERE `deleted` = 0 order by `sort`'); ?>
<select <?= (isset($_GET['view']) || isset($_GET['event_id'])) ? "disabled" : "" ?> id="subject_id" name="subject_id" class="required">
<?php echo '<option value=""></option>'; ?>
<?php while ($ResultSet = $sth->fetch(PDO::FETCH_ASSOC)) { ?>
<option value="<?= $ResultSet['subject_id'] ?>"><?= $ResultSet['sub_code'] ?></option>
<?php } ?>
</select>
<?php } ?>
</td>
</tr>
<tr style="height: 15px"></tr>
<tr>
<?php
// if ($school_type == 1)
// echo '<script>$(function(){ document.getElementById(\'Inschool\').checked = true;}); </script>';
// if ($school_type == 2)
// echo '<script>$(function(){ document.getElementById(\'OutsideSchool\').checked = true;}); </script>';
//
?>
<!-- Type of school -->
<!-- <td style="width: 200px;text-align: right;"><label for="Type_id">Type</label></td>
<td style="width: 30px"></td>
<td><label class="radio inline">In-school<input type="radio" value="1" name="school_type" id="Inschool" class="required"/></label></td>
<td><label class="radio inline">Outside school<input type="radio" value="2" name="school_type" id="OutsideSchool" class="required"/></label></td>-->
</tr>
</table>
<hr/>
<table>
<tr>
<!-- Programme Fee -->
<td style="width: 200px;text-align: right;" class="required"><label>Programme Fee</label></td>
<td style="width: 30px"></td>
<td>
<?php if (isset($_GET['view'])) { ?>
<input type="text" readonly value=" <?= ($Programme_fee_type == 1) ? "Hourly" : ($Programme_fee_type == 2) ? "Package" : ($Programme_fee_type == 3) ? "Free" : '' ?> "/>
<?php } else { ?>
<?php echo '<script>$(function(){ document.getElementById(\'programme_fee\').value = ' . $Programme_fee_type . '}); </script>'; ?>
<select id="programme_fee" name="programme_fee" class="required">
<option value=""></option>
<option value="1">Hourly</option>
<option value="2">Package</option>
<option value="3">Free</option>
</select>
<?php } ?>
</td>
</tr>
<tr style="height: 15px"></tr>
<!-- Programme Fee Type -->
<tbody id="programme_fee_tr">
<?php if ($Programme_fee_type == 1) { ?>
<tr>
<!-- Prinary Ind$ -->
<td style="width: 200px;text-align: right;"><label>Primary Ind $</label></td>
<td style="width: 30px"></td>
<td><input <?= (isset($_GET['view'])) ? "readonly" : "" ?> class="required" id="primary_ind" type="text" maxlength="150" placeholder="Primary Ind $" value="<?= $primary_ind ?>" name="primary_ind" autocomplete="off" onkeydown="return ( event.ctrlKey || event.altKey || (47<event.keyCode && event.keyCode<58 && event.shiftKey==false) || (95<event.keyCode && event.keyCode<106) || (event.keyCode==8) || (event.keyCode==9) || (event.keyCode>34 && event.keyCode<40) || (event.keyCode==46) )"/></td>
<td style="width: 20px"></td>
<!-- Primary Gp$ -->
<td style="text-align: right;"><label>Gp $</label></td>
<td style="width: 30px"></td>
<td><input <?= (isset($_GET['view'])) ? "readonly" : "" ?> class="required" id="primary_gp" type="text" maxlength="150" placeholder="Primary Gp $" value="<?= $primary_gp ?>" name="primary_gp" autocomplete="off" onkeydown="return ( event.ctrlKey || event.altKey || (47<event.keyCode && event.keyCode<58 && event.shiftKey==false) || (95<event.keyCode && event.keyCode<106) || (event.keyCode==8) || (event.keyCode==9) || (event.keyCode>34 && event.keyCode<40) || (event.keyCode==46) )"/></td>
</tr>
<tr style="height: 15px"></tr>
<tr>
<!-- Secondary Ind$ -->
<td style="width: 200px;text-align: right;"><label>Secondary Ind $</label></td>
<td style="width: 30px"></td>
<td><input <?= (isset($_GET['view'])) ? "readonly" : "" ?> class="required" id="secondary_ind" type="text" maxlength="150" placeholder="Secondary Ind $" value="<?= $secondary_ind ?>" name="secondary_ind" autocomplete="off" onkeydown="return ( event.ctrlKey || event.altKey || (47<event.keyCode && event.keyCode<58 && event.shiftKey==false) || (95<event.keyCode && event.keyCode<106) || (event.keyCode==8) || (event.keyCode==9) || (event.keyCode>34 && event.keyCode<40) || (event.keyCode==46) )"/></td>
<td style="width: 20px"></td>
<!-- Secondary Gp$ -->
<td style="text-align: right;"><label>Gp $</label></td>
<td style="width: 30px"></td>
<td><input <?= (isset($_GET['view'])) ? "readonly" : "" ?> class="required" id="secondary_gp" type="text" maxlength="150" placeholder="Secondary Gp $" value="<?= $secondary_gp ?>" name="secondary_gp" autocomplete="off" onkeydown="return ( event.ctrlKey || event.altKey || (47<event.keyCode && event.keyCode<58 && event.shiftKey==false) || (95<event.keyCode && event.keyCode<106) || (event.keyCode==8) || (event.keyCode==9) || (event.keyCode>34 && event.keyCode<40) || (event.keyCode==46) )"/></td>
</tr>
<tr style="height: 15px"></tr>
<?php } if ($Programme_fee_type == 2) { ?>
<tr> <!-- Package Fee -->
<td style="width: 200px;text-align: right;"><label>Primary Package Fee</label></td>
<td style="width: 30px"></td>
<td><input <?= (isset($_GET['view'])) ? "readonly" : "" ?> class="required" id="primary_package_fee" type="text" maxlength="150" placeholder="Primary Package $" value="<?= $primary_package_fee ?>" name="primary_package_fee" autocomplete="off" onkeydown="return ( event.ctrlKey || event.altKey || (47<event.keyCode && event.keyCode<58 && event.shiftKey==false) || (95<event.keyCode && event.keyCode<106) || (event.keyCode==8) || (event.keyCode==9) || (event.keyCode>34 && event.keyCode<40) || (event.keyCode==46) )"/></td>
<td style="width: 20px"></td>
<!-- Package Discount -->
<td style="display: none;" ><label>Primary Package Discount</label></td>
<td style="width: 30px;display: none;"></td>
<td style="display: none;"><input <?= (isset($_GET['view'])) ? "readonly" : "" ?> class="required" id="primary_package_discount" type="text" maxlength="150" placeholder="Primary Package Discount" value="<?= $primary_package_discount ?>" name="primary_package_discount" autocomplete="off" onkeydown="return ( event.ctrlKey || event.altKey || (47<event.keyCode && event.keyCode<58 && event.shiftKey==false) || (95<event.keyCode && event.keyCode<106) || (event.keyCode==8) || (event.keyCode==9) || (event.keyCode>34 && event.keyCode<40) || (event.keyCode==46) )"/></td>
<!--</tr>-->
<!--<tr style="height: 15px;"></tr>-->
<!--<tr>-->
<td style="width: 200px;text-align: right;"><label>Secondary Package Fee</label></td>
<td style="width: 30px"></td>
<td><input <?= (isset($_GET['view'])) ? "readonly" : "" ?> class="required" id="secondary_package_fee" type="text" maxlength="150" placeholder="Secondary Package $" value="<?= $secondary_package_fee ?>" name="secondary_package_fee" autocomplete="off" onkeydown="return ( event.ctrlKey || event.altKey || (47<event.keyCode && event.keyCode<58 && event.shiftKey==false) || (95<event.keyCode && event.keyCode<106) || (event.keyCode==8) || (event.keyCode==9) || (event.keyCode>34 && event.keyCode<40) || (event.keyCode==46) )"/></td>
<td style="width: 20px"></td>
<!-- new -->
<td style="display: none;"><label>Secondary Package Discount</label></td>
<td style="width: 30px;display: none;"></td>
<td style="display: none;"><input <?= (isset($_GET['view'])) ? "readonly" : "" ?> class="required" id="secondary_package_discount" type="text" maxlength="150" placeholder="Secondary Package Discount" value="<?= $secondary_package_discount ?>" name="secondary_package_discount" autocomplete="off" onkeydown="return ( event.ctrlKey || event.altKey || (47<event.keyCode && event.keyCode<58 && event.shiftKey==false) || (95<event.keyCode && event.keyCode<106) || (event.keyCode==8) || (event.keyCode==9) || (event.keyCode>34 && event.keyCode<40) || (event.keyCode==46) )"/></td>
</tr>
<?php } ?>
</tbody>
</table>
<hr/>
<!-- ↑ display on add and edit page -->
<!-- ↓ display on add page -->
<?php if (!isset($_REQUEST['event_id'])) { ?>
<h4>Time</h4>
<table>
<tr>
<!-- Start date -->
<td style="width: 200px;text-align: right;"><label>Start Date</label></td>
<td style="width: 30px"></td>
<td>
<div class="input-append date-picker" id="start_date_id">
<input id="Start_date" class="dateISO required" type="text" maxlength="200" placeholder="Start Date" data-format="yyyy-MM-dd" value=" " name="start_date" autocomplete="off">
<span class="add-on">
<i class="icon-calendar" data-date-icon="icon-calendar" data-time-icon="icon-time"></i>
</span>
</div>
</td>
<td style="width: 20px"></td>
<!-- End Date -->
<td style="text-align: right;"><label>End Date</label></td>
<td style="width: 30px"></td>
<td>
<div class="input-append date-picker" id="End_date_id">
<input id="End_date" class="dateISO required" type="text" maxlength="200" placeholder="End Date" data-format="yyyy-MM-dd" value=" " name="End_date" autocomplete="off">
<span class="add-on">
<i class="icon-calendar" data-date-icon="icon-calendar" data-time-icon="icon-time"></i>
</span>
</div>
</td>
</tr>
</table>
<div style="height: 15px;"></div>
<table>
<tr>
<!-- Rate -->
<td style = "width: 200px;text-align: right;"><label>Rate</label></td>
<td style = "width: 30px"></td>
<td>
<select name="Rate_select" class="required">
<option value=""></option>
<option value="1">1 week</option>
<option value="2">2 week</option>
<option value="3">3 week</option>
<option value="4">Month</option>
</select>
</td>
</tr>
</table>
<div style="height: 15px;"></div>
<table>
<!-- Select Date & Time & RoomID -->
<?php
$sth = $dbh->query('SELECT `room_ID`, `actived`, `deleted` FROM `venue` WHERE `actived`=1 and `deleted`=0 order by 1');
$option = '<option value=""></option>';
while ($ResultSet = $sth->fetch(PDO::FETCH_ASSOC)) {
$option .= "<option value=" . $ResultSet['room_id'] . ">" . $ResultSet['room_id'] . "</option>";
}
$date = array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");
for ($i = 1; $i <= 7; $i++) {
$i2 = $i - 1;
?>
<tr>
<td style = "width: 200px;text-align: right;">
<!-- Date select with checkbox -->
<label><?= $date[$i2] ?><input style="margin-left: 8px;margin-bottom: 5px;" class="checkbox_select required" type = "checkbox" id = "<?= $i ?>check_date" name = "check_date[]" value="<?= $i2 ?>" /></label>
</td>
<td style = "width: 30px"></td>
<!-- Start Time -->
<td><label>Start Time</label></td>
<td style = "width: 30px"></td>
<td><input style="width: 80px;" type="text" class="timepicker_start" id="start_time_<?= $i ?>" name="start_time[]" onchange="limit_time(this);" /></td>
<td style = "width: 70px;text-align: center;color: #AAAAAA;padding-bottom: 10px;">(24 Hour)</td>
<!-- End Time -->
<td><label>End Time</label></td>
<td style = "width: 30px"></td>
<td><input style="width: 80px;" type="text" class="timepicker_end" id="end_time_<?= $i ?>" name="end_time[]" onchange="limit_time(this);" /></td>
<td style = "width: 70px;text-align: center;color: #AAAAAA;padding-bottom: 10px;">(24 Hour)</td>
<td><!-- Room ID -->
<select name="Room_id[]" autocomplete="off"><?= $option ?></select>
</td>
</tr>
<?php } ?>
</table>
<hr/>
<!-- Submit button that is display in add page -->
<input type="submit" id="Event_Next" name="Event_Next" class="btn btn-danger" value="Next"/>
<?php if (!isset($_POST)) { ?>
<input type="button" value="Back" class="btn btn-danger" onclick="history.back()"/>
<?php } ?>
<?php } if (isset($_REQUEST['event_id']) && !isset($_GET['view'])) { ?>
<input type="submit" id="Event_Save" name="Event_Save" class="btn btn-danger" value="Save" onclick="undisabled_select();"/>
<input type="submit" id="Event_delete" name="Event_delete" class="btn btn-danger" value="Delete"/>
<?php } ?>
<?php if (!isset($_GET['view'])) { ?>
<input type="button" value="Back" class="btn btn-danger" onclick="history.back()"/>
<?php } ?>
</form>
<?php
if (isset($_GET['view'])) {
$lesson_date = array();
$sth = $dbh->query("select `room_id`,`date`,`start_time`,`end_time`,`lesson_id`,teaching_hr from lesson where `lesson_id` in (
SELECT `lesson_id` FROM `event_lesson` WHERE `event_id`=" . $_REQUEST['event_id'] . " and `actived`=1 and `deleted`=0 ) order by 2");
while ($ResultSet = $sth->fetch(PDO::FETCH_ASSOC)) {
array_push($lesson_date, array($ResultSet['date'], $ResultSet['start_time'], $ResultSet['end_time'], $ResultSet['room_id'], $ResultSet['lesson_id'], $ResultSet['teaching_hr']));
}
?>
<table class="table table-striped table-bordered table-hover table-condensed">
<thead>
<tr>
<th>Lesson Date</th>
<th>Start Time</th>
<th>End Time</th>
<th>Teaching Hour</th>
<th>Room ID</th>
<th style="width:30%;">Student</th>
<th style="width:30%;">Staff</th>
</tr>
</thead>
<tbody id="lesson_table">
<?php $counter = 0; ?>
<?php
$staffrate = array("Monthly", "Teacher ( In House )", "Teacher ( Outside School )",
"Teacher Assistant ( In House )", "Teacher Assistant ( Outside School )", "Traveling", "Other");
?>
<?php foreach ($lesson_date as $arr) { ?>
<?php $counter++; ?>
<tr>
<td><?= $arr[0] ?></td>
<td><?= $arr[1] ?></td>
<td><?= $arr[2] ?></td>
<td><?= $arr[5] ?> Minutes</td>
<td><?= $arr[3] ?></td>
<td style="width: 100px;text-align: left;">
<?php $sth = $dbh->query("SELECT root_id,`New_stu_ID` id,`ch_name`,CONCAT(`last_name`,' ',`first_name`) name, lesson_id, stu_linking_id, reason_id,package_discount FROM `student`,lesson_attendance WHERE student.actived=1 and student.deleted=0 and root_id = stu_linking_id and `lesson_id` in ( select lesson_id from lesson where lesson_id =" . $arr[4] . " ) and lesson_attendance.deleted =0 and lesson_attendance.actived =1") ?>
<?php while ($ResultSet = $sth->fetch(PDO::FETCH_ASSOC)) { ?>
ID : <?= $ResultSet['id'] ?> | <?= $ResultSet['name'] ?> ( <?= $ResultSet['ch_name'] ?> ) | <?= ($ResultSet['reason_id'] == 1) ? "Normal Class" : "Make-up Class" ?> | Package Discount : $<?= number_format($ResultSet['package_discount'], 2) ?> <br/>
<?php } ?>
</td>
<td style="width: 100px;text-align: left;">
<?php $sth = $dbh->query("SELECT la.staff_id,ch_name,CONCAT(`last_name`,' ',`first_name`) name, lesson_id,rate_type,is_substitute FROM staff s,lesson_attendance la WHERE la.staff_id = s.root_id and `lesson_id` in ( select lesson_id from lesson where lesson_id = " . $arr[4] . ")and la.actived=1 and la.deleted=0 and s.actived=1 and s.deleted=0 "); ?>
<?php while ($ResultSet = $sth->fetch(PDO::FETCH_ASSOC)) { ?>
<?= $staffrate[(int) $ResultSet['rate_type']] ?><?= ($ResultSet['is_substitute'] == 1) ? " ( Substitute ) " : "" ?> | <?= $ResultSet['name'] ?> ( <?= $ResultSet['ch_name'] ?> ) <br/>
<?php } ?>
</td>
</tr>
<?php } ?>
<?php } ?>
</tbody>
</table>
<hr/>
<?php if (isset($_GET['view'])) { ?>
<input type="button" value="Back" class="btn btn-danger" onclick="history.back()"/>
<?php } ?>
</div>
</div> <!-- /container -->
</body>
</html>