| 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/Event_Attendance/ |
Upload File : |
<!DOCTYPE html>
<html>
<head>
<?php require_once '../include/head.php'; ?>
<?php require_once '../include/checkuser.php'; ?>
<?php require_once '../include/Nav_bar.php'; ?>
<?php include_once '../include/DBConnect.php'; ?>
<script>
$(function() {
$('.date-picker').datetimepicker({pickTime: false});
$('#startdate').datetimepicker().on('changeDate', function(ev) {
var date = new Date($('#start_date').val());
$('#enddate').datetimepicker('setStartDate', date);
$('#enddate').datetimepicker('setDate', date);
$('#enddate').datetimepicker('show');
$('#startdate').datetimepicker('hide');
$('#enddate').datetimepicker('remove');
});
$('#search_form').validate();
$('.time').timepicker({'step': 15, 'timeFormat': 'H:i', 'minTime': '06:00', 'maxTime': '23:30'});
$('.stun').select2();
$('.staff_name').select2();
});
</script>
<?php if (isset($_POST['go'])) { ?>
<script>
$(function() {
$('#stun').select2().select2('val', '<?= $_POST['stun'] ?>');
$('#staff_name').select2().select2('val', '<?= $_POST['staff_name'] ?>');
});
</script>
<?php } ?>
</head>
<body>
<?php
$countlesson = 0;
$countstaff = 0;
$countstudent = 1;
$studentid = "";
$staffid = "";
$startdate = date('Y-m-d');
$enddate = date('Y-m-d');
$today = date('Y-m-d');
if (isset($_POST['save'])) {
if (isset($_POST['startdate']) && isset($_POST['enddate'])) {
$startdate = $_POST['startdate'];
$enddate = $_POST['enddate'];
}
for ($i = strtotime($startdate); $i <= strtotime($enddate); $i = $i + 86400) {
$today = date('Y-m-d', $i);
$countstaff = 0;
$countstudent = 1;
$countlesson = 0;
$hvrecord = false;
$search = "select date from lesson_attendance where deleted = 0 group by date";
$evdate = $dbh->query($search);
$evdate->setFetchMode(PDO::FETCH_OBJ);
while ($sd = $evdate->fetch()) {
if ($sd->date == $today)
$hvrecord = true;
}
if ($hvrecord) {
foreach ($_POST["lessonid_$today"] as $lid) {
if (isset($_POST["staffid_" . $today . "_$lid"])) {
foreach ($_POST["staffid_" . $today . "_$lid"] as $insertid) {
$sth = $dbh->prepare("UPDATE lesson_attendance SET deleted = 1 WHERE staff_id = ? and date = ? and lesson_id = ?");
$sth->bindParam(1, $insertid);
$sth->bindParam(2, $today);
$sth->bindParam(3, $lid);
$sth->execute();
$sth = $dbh->prepare("INSERT INTO `lesson_attendance`(`lesson_id`, `createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `stu_linking_id`, `staff_id`, `attendance`, `date`, `in_time`, `out_time`, `rate_type`, `payroll_gened`, `invoice_gened`, `is_charge`, `package_discount`, `is_substitute`, `reason_id`) VALUES (?,1,now(),1,now(),1,0,NULL,?,?,?,?,?,?,?,?,?,?,?,?)");
$sth->bindParam(1, $lid);
$sth->bindParam(2, $insertid);
$sth->bindParam(3, $_POST["staffr_" . $countstaff . "_$lid"][$today]);
$sth->bindParam(4, $today);
$sth->bindParam(5, $_POST["start_time_" . $countstaff . "_$lid"][$today]);
$sth->bindParam(6, $_POST["end_time_" . $countstaff . "_$lid"][$today]);
$sth->bindParam(7, $_POST["rate_" . $countstaff . "_$lid"]);
$sth->bindParam(8, $_POST["payroll_gened_" . $countstaff . "_$lid"]);
$sth->bindParam(9, $_POST["invoice_gened_" . $countstaff . "_$lid"]);
$sth->bindParam(10, $_POST["is_charge_" . $countstaff . "_$lid"]);
$sth->bindParam(11, $_POST["package_discount_" . $countstaff . "_$lid"]);
$sth->bindParam(12, $_POST["is_substitute_" . $countstaff . "_$lid"]);
$sth->bindParam(13, $_POST["reason_" . $countstaff . "_$lid"][$today]);
$sth->execute();
$countstaff +=2;
$countlesson++;
echo $insertid;
}
}
$countlesson = 0;
if (isset($_POST["stuid_" . $today . "_$lid"])) {
foreach ($_POST["stuid_" . $today . "_$lid"] as $insertid) {
$sth = $dbh->prepare("UPDATE lesson_attendance SET deleted = 1 WHERE stu_linking_id = ? and date = ? and lesson_id = ?");
$sth->bindParam(1, $insertid);
$sth->bindParam(2, $today);
$sth->bindParam(3, $lid);
$sth->execute();
$sth = $dbh->prepare("INSERT INTO `lesson_attendance`(`lesson_id`, `createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `stu_linking_id`, `staff_id`, `attendance`, `date`, `in_time`, `out_time`, `rate_type`, `payroll_gened`, `invoice_gened`, `is_charge`, `package_discount`, `is_substitute`, `reason_id`) VALUES (?,1,now(),1,now(),1,0,?,NULL,?,?,?,?,'0.0',?,?,?,?,?,?)");
$sth->bindParam(1, $lid);
$sth->bindParam(2, $insertid);
$sth->bindParam(3, $_POST["stur_" . $countstudent . "_$lid"][$today]);
$sth->bindParam(4, $today);
$sth->bindParam(5, $_POST["start_time_" . $countstudent . "_$lid"][$today]);
$sth->bindParam(6, $_POST["end_time_" . $countstudent . "_$lid"][$today]);
$sth->bindParam(7, $_POST["payroll_gened_" . $countstudent . "_$lid"]);
$sth->bindParam(8, $_POST["invoice_gened_" . $countstudent . "_$lid"]);
$sth->bindParam(9, $_POST["is_charge_" . $countstudent . "_$lid"]);
$sth->bindParam(10, $_POST["package_discount_" . $countstudent . "_$lid"]);
$sth->bindParam(11, $_POST["is_substitute_" . $countstudent . "_$lid"]);
$sth->bindParam(12, $_POST["reason_" . $countstudent . "_$lid"][$today]);
$sth->execute();
$countstudent +=2;
$countlesson++;
}
}
}
}
}
echo "<script>alert('Add successful.')</script>";
}
?>
<!-- line between nav bar and content -->
<div class="text-right">
<ul class="breadcrumb">
<li class="active">Event Attendance</li>
</ul>
</div>
<!-- line between nav bar and content -->
<div class="container-fluid pathways-container">
<h3>Event Attendance</h3>
<div class="pathways-search">
<form id="search_form" class="form-inline" action="" method="POST">
<div class="pathways-inline-block">
<label class="" id="event_code" name="event_code">Event Code</label>
<input type="text" id="event_code" name="event_code" class="input-medium" placeholder="Event Code" value="<?php if (isset($_POST['go'])) echo $_POST['event_code']; ?>">
</div>
<div class="pathways-inline-block">
<label class="" id="program" name="program">Program</label>
<select id="program" name="program" class="input-medium" value="program" >
<option value="ALL">ALL</option>
<?php
$query = "select program_code from program ";
$result = $dbh->query($query);
$result->setFetchMode(PDO::FETCH_OBJ);
while ($row = $result->fetch()) {
?>
<option <?php if (isset($_POST['go'])) if ($_POST['program'] == $row->program_code) { ?> selected <?php } ?> value ="<?= $row->program_code ?>"><?= $row->program_code ?></option>
<?php } ?>
</select>
</div>
<div class="pathways-inline-block">
<label class="" id="program" name="subject" value="subject" >Subject</label>
<select id="subject" name="subject" class="input-medium" >
<option value="ALL">ALL</option>
<?php
$query = "select sub_code from subject ";
$result = $dbh->query($query);
$result->setFetchMode(PDO::FETCH_OBJ);
while ($row = $result->fetch()) {
?>
<option <?php if (isset($_POST['go'])) if ($_POST['subject'] == $row->sub_code) { ?> selected <?php } ?> value ="<?= $row->sub_code ?>"><?= $row->sub_code ?></option>
<?php } s ?>
</select>
</div>
<div class="pathways-inline-block">
<label class="">Date</label>
<div class="input-append date-picker" id="startdate">
<input id="start_date" class="dateISO" type="text" maxlength="200" data-format="yyyy-MM-dd" name="startdate" value="<?php
if (isset($_POST['go']))
echo $_POST['startdate'];
else
echo $startdate;
?>" style="width:90px" required="">
<span class="add-on">
<i class="icon-calendar" data-date-icon="icon-calendar" data-time-icon="icon-time"></i>
</span>
</div>
<label class="" >To</label>
<div class="input-append date-picker" id="enddate">
<input id="end_date" class="dateISO" type="text" maxlength="200" data-format="yyyy-MM-dd" name="enddate" value="<?php
if (isset($_POST['go']))
echo $_POST['enddate'];
else
echo $enddate;
?>" style="width:90px" required="">
<span class="add-on">
<i class="icon-calendar" data-date-icon="icon-calendar" data-time-icon="icon-time"></i>
</span>
</div>
</div>
<div class="pathways-inline-block">
<label>Student</label>
<select name="stun" id="stun" class="stun" style="width:170px">
<option value="ALL">ALL</option>
<?php $sth = $dbh->query("SELECT linking_id,`New_stu_ID` id,CONCAT(last_name, ' ', first_name) studentname,`ch_name`FROM `student` WHERE `actived`=1 and`deleted`=0 group by `New_stu_ID`,`Sem_yr`"); ?>
<?php while ($ResultSet = $sth->fetch(PDO::FETCH_ASSOC)) { ?>
<option value="<?= $ResultSet['studentname'] ?>"><?= $ResultSet['studentname'] ?></option>
<?php } ?>
</select>
</div>
<div class="pathways-inline-block">
<label>Staff Name</label>
<select name="staff_name" id="staff_name" class="staff_name" style="width: 200px">
<option value="ALL">ALL</option>
<?php $sth = $dbh->query("SELECT CONCAT(`last_name`,' ',`first_name`) staffname, `ch_name` , `staff_id` FROM `staff` WHERE `actived`=1 and `deleted`=0 group by `staff_id`"); ?>
<?php while ($ResultSet = $sth->fetch(PDO::FETCH_ASSOC)) { ?>
<option value="<?= $ResultSet['staffname'] ?>" ><?= $ResultSet['staffname'] ?></option>
<?php } ?>
</select>
</div>
<div class="pathways-inline-block">
<button class="btn" name="go" value="go" style="margin-left:30px" type="submit">GO</button>
<input type="hidden" name="staffid[]" value="">
</div>
</form>
</div>
<!-- date picker -->
<?php
if (isset($_POST['go'])) {
$program = NULL;
$event_code = NULL;
$subject = NULL;
$searchstudent = NULL;
$searchstaff = NULL;
$startdate = $_POST['startdate'];
$enddate = $_POST['enddate'];
if (!empty($_POST['event_code']))
$event_code = "e.event_code ='" . $_POST['event_code'] . "' and ";
if ($_POST['program'] != 'ALL')
$program = "p.program_code ='" . $_POST['program'] . "' and ";
if ($_POST['subject'] != 'ALL')
$subject = "sub.sub_code ='" . $_POST['subject'] . "' and ";
if ($_POST['staff_name'] != 'ALL')
$searchstaff = " CONCAT(s.last_name, ' ', s.first_name) = '" . $_POST['staff_name'] . "' and ";
if ($_POST['staff_name'] != "ALL" && $_POST['stun'] == 'ALL')
$searchstudent = " CONCAT(stu.last_name, ' ', stu.first_name) = 'no search' and ";
if ($_POST['stun'] != 'ALL')
$searchstudent = " CONCAT(stu.last_name, ' ', stu.first_name) = '" . $_POST['stun'] . "' and ";
if ($_POST['stun'] != 'ALL' && $_POST['staff_name'] == 'ALL')
$searchstaff = " CONCAT(s.last_name, ' ', s.first_name) = 'no search' and ";
//search data
?>
<form id="form" action="" method="POST">
<?php
for ($i = strtotime($startdate); $i <= strtotime($enddate); $i = $i + 86400) {
$hvrecord = false;
$today = date('Y-m-d', $i);
$search = "select date from lesson_attendance where deleted = 0 group by date";
$evdate = $dbh->query($search);
$evdate->setFetchMode(PDO::FETCH_OBJ);
while ($sd = $evdate->fetch()) {
if ($sd->date == $today)
$hvrecord = true;
}
?>
<table class="table table-striped table-bordered table-hover table-condensed">
<thead>
<tr>
<th >Event Code</th>
<th style="min-width:50px; width:50px">Program</th>
<th style="min-width:50px; width:50px">Subject </th>
<th style="min-width:50px; width:50px">RoomID</th>
<th style="min-width:130px; width:130px">Start - End Time </th>
<th style="min-width:150px; width:150px">Name</th>
<th style="min-width:50px; width:50px">Type</th>
<th style="min-width:75px; width:75px">In Time</th>
<th style="min-width:75px; width:75px">Out Time</th>
<th style="min-width:170px; width:170px">Attendance</th>
<th style="min-width:200px; width:200px">Reason(If Absent)</th>
</tr>
</thead>
<?php
if ($hvrecord == false) {
?>
<h5>Date: <?= $today ?></h5>
<tr><td colspan="10"><h5>No lesson</h5></td></tr></table>
<?php
}
if ($hvrecord) {
$searchlesson = "select lesson_id from lesson_attendance where deleted = 0 and date='$today' group by lesson_id";
$query1 = "select s.last_name as sln, s.first_name as sfn, date_format(le.start_time, '%h:%i') as lst, date_format(le.end_time, '%h:%i') as let, "
. "a.payroll_gened as apg, a.invoice_gened as aig, a.is_charge as aic, a.package_discount as apd, a.is_substitute as ais, a.rate_type as rate, a.attend_id as aid, a.lesson_id as alid, a.attendance as attend, a.in_time as it, a.out_time as ot, a.staff_id as id, a.reason_id as reid, "
. "le.room_id, e.event_code as ec, p.program_code as pc, sub.sub_code as sc "
. "from lesson_attendance a, staff s, student stu,event e, event_lesson l, program p, subject sub, lesson le "
. "where a.staff_id = s.root_id and a.date = '$today' and a.lesson_id = l.lesson_id and l.lesson_id = le.lesson_id and l.event_id = e.event_id and e.program_id = p.program_id and e.subject_id = sub.subject_id and "
. $program . $subject . $event_code . $searchstaff
. "a.deleted = 0 and s.deleted = 0 and l.deleted = 0 and e.deleted = 0 and p.deleted = 0 and sub.deleted = 0 group by attend_id";
$query2 = "select stu.last_name as stuln, stu.first_name as stufn, date_format(le.start_time, '%h:%i') as lst, date_format(le.end_time, '%h:%i') as let, "
. "a.attend_id as aid, a.lesson_id as alid, a.attendance as attend, a.in_time as it, a.out_time as ot, a.stu_linking_id as id, a.reason_id as reid, "
. "le.room_id, e.event_code as ec, p.program_code as pc, sub.sub_code as sc "
. "from lesson_attendance a, staff s, student stu,event e, event_lesson l, program p, subject sub, lesson le "
. "where a.stu_linking_id = stu.root_id and a.date = '$today' and a.lesson_id = l.lesson_id and l.lesson_id = le.lesson_id and l.event_id = e.event_id and e.program_id = p.program_id and e.subject_id = sub.subject_id and "
. $program . $subject . $event_code . $searchstudent
. "a.deleted = 0 and stu.deleted = 0 and l.deleted = 0 and e.deleted = 0 and p.deleted = 0 and sub.deleted = 0 group by attend_id";
?>
<h5>Date: <?= $today ?></h5>
<tbody>
<?php
$countlesson = 0;
$result = $dbh->query($searchlesson);
$result->setFetchMode(PDO::FETCH_OBJ);
$countstaff = 0;
$countstudent = 1;
while ($sl = $result->fetch()) {
$lid = $sl->lesson_id;
$result1 = $dbh->query($query1);
$result1->setFetchMode(PDO::FETCH_OBJ);
?>
<input type="hidden" name="lessonid_<?= $today ?>[]" value="<?= $lid ?>" >
<input type="hidden" name="startdate" value="<?= $startdate ?>">
<input type="hidden" name="enddate" value="<?= $enddate ?>">
<?php
while ($row1 = $result1->fetch()) {
if ($row1->alid == $lid) {
?>
<tr>
<input type="hidden" name="staffid_<?= $today ?>_<?= $lid ?>[]" value="<?= $row1->id ?>">
<input type="hidden" name="staid[]" value="<?= $row1->aid ?>">
<input type="hidden" name="rate_<?= $countstaff ?>_<?= $lid ?>" value="<?= $row1->rate ?>">
<input type="hidden" name="payroll_gened_<?= $countstaff ?>_<?= $lid ?>" value="<?= $row1->apg ?>">
<input type="hidden" name="invoice_gened_<?= $countstaff ?>_<?= $lid ?>" value="<?= $row1->aig ?>">
<input type="hidden" name="is_charge_<?= $countstaff ?>_<?= $lid ?>" value="<?= $row1->aic ?>">
<input type="hidden" name="package_discount_<?= $countstaff ?>_<?= $lid ?>" value="<?= $row1->apd ?>">
<input type="hidden" name="is_substitute_<?= $countstaff ?>_<?= $lid ?>" value="<?= $row1->ais ?>">
<td><?php echo $row1->ec ?></td>
<td><?php echo $row1->pc ?></td>
<td><?php echo $row1->sc ?></td>
<td><?php echo $row1->room_id ?></td>
<td><?php echo $row1->lst . " - " . $row1->let ?></td>
<td><?php echo $row1->sln . " " . $row1->sfn ?></td>
<td>Teacher</td>
<td>
<input id="start_time" type="text" class="time" name = "start_time_<?= $countstaff ?>_<?= $lid ?>[<?= $today ?>]" style = "width:45px" value="<?= $row1->it ?>">
</td>
<td>
<input id="end_time" type="text" class="time" name = "end_time_<?= $countstaff ?>_<?= $lid ?>[<?= $today ?>]" style = "width:45px" value="<?= $row1->ot ?>">
</td>
<td>
<div class="pathways-inline-block" style="margin-right:0px">
<label class="radio inline">
<input <?php if ($row1->attend == 1) { ?>checked <?php } ?> type="radio" id = "staffp<?= $countstaff ?><?= $today ?>" name="staffr_<?= $countstaff ?>_<?= $lid ?>[<?= $today ?>]" value="1"/>
Present
</label>
<label class="radio inline">
<input <?php if ($row1->attend == 0) { ?>checked <?php } ?>type="radio" id = "staffa<?= $countstaff ?><?= $today ?>" name="staffr_<?= $countstaff ?>_<?= $lid ?>[<?= $today ?>]" value="0"/>
Absent
</label>
</div>
</td>
<td>
<select id="reason" name="reason_<?= $countstaff ?>_<?= $lid ?>[<?= $today ?>]" class="input-medium" value="reason" >
<option value="0"> </option>
<?php
$query = "select reason_id, reason_name from reason ";
$resultr = $dbh->query($query);
$resultr->setFetchMode(PDO::FETCH_OBJ);
while ($rowr = $resultr->fetch()) {
?>
<option <?php if ($row1->reid == $rowr->reason_id) { ?> selected <?php } ?>value="<?= $rowr->reason_id ?>"><?= $rowr->reason_name ?></option>
<?php } ?>
</select>
</td>
</tr>
<?php
$countstaff +=2;
}
}
$result2 = $dbh->query($query2);
$result2->setFetchMode(PDO::FETCH_OBJ);
while ($row2 = $result2->fetch()) {
if ($row2->alid == $lid) {
?>
<tr>
<input type="hidden" name="stuid_<?= $today ?>_<?= $lid ?>[]" value="<?= $row2->id ?>">
<input type="hidden" name="stuaid[]" value="<?= $row2->aid ?>">
<input type="hidden" name="payroll_gened_<?= $countstudent ?>_<?= $lid ?>" value="<?= $row2->apg ?>">
<input type="hidden" name="invoice_gened_<?= $countstudent ?>_<?= $lid ?>" value="<?= $row2->aig ?>">
<input type="hidden" name="is_charge_<?= $countstudent ?>_<?= $lid ?>" value="<?= $row2->aic ?>">
<input type="hidden" name="package_discount_<?= $countstudent ?>_<?= $lid ?>" value="<?= $row2->apd ?>">
<input type="hidden" name="is_substitute_<?= $countstudent ?>_<?= $lid ?>" value="<?= $row2->ais ?>">
<td><?php echo $row2->ec ?></td>
<td><?php echo $row2->pc ?></td>
<td><?php echo $row2->sc ?></td>
<td><?php echo $row2->room_id ?></td>
<td><?php echo $row2->lst . " - " . $row2->let ?></td>
<td><?php echo $row2->stuln . " " . $row2->stufn ?></td>
<td>Student</td>
<td>
<input id="start_time" type="text" class="time" name = "start_time_<?= $countstudent ?>_<?= $lid ?>[<?= $today ?>]" style = "width:45px" value="<?= $row2->it ?>">
</td>
<td>
<input id="end_time" type="text" class="time" name = "end_time_<?= $countstudent ?>_<?= $lid ?>[<?= $today ?>]" style = "width:45px" value="<?= $row2->ot ?>">
</td>
<td>
<div class="pathways-inline-block" style="margin-right:0px">
<label class="radio inline">
<input <?php if ($row2->attend == 1) { ?>checked <?php } ?> type="radio" id = "stup<?= $countstudent ?><?= $today ?>" name="stur_<?= $countstudent ?>_<?= $lid ?>[<?= $today ?>]" value="1"/>
Present
</label>
<label class="radio inline">
<input <?php if ($row2->attend == 0) { ?>checked <?php } ?> type="radio" id = "stua<?= $countstudent ?><?= $today ?>" name="stur_<?= $countstudent ?>_<?= $lid ?>[<?= $today ?>]" value="0"/>
Absent
</label>
</div>
</td>
<td>
<select id="reason" name="reason_<?= $countstudent ?>_<?= $lid ?>[<?= $today ?>]" class="input-medium" value="reason" >
<option value="0"> </option>
<?php
$query = "select reason_id, reason_name from reason ";
$resultr = $dbh->query($query);
$resultr->setFetchMode(PDO::FETCH_OBJ);
while ($rowr = $resultr->fetch()) {
?>
<option <?php if ($row2->reid == $rowr->reason_id) { ?> selected <?php } ?>value="<?= $rowr->reason_id ?>"><?= $rowr->reason_name ?></option>
<?php } ?>
</select>
</td>
</tr>
<?php
$countstudent+=2;
}
}
$countlesson++;
}
?>
</tbody>
</table>
<?php
}
}
}
?>
<input type="submit" name="save" value="save" class="btn btn-danger">
</form>
</div> <!-- /container -->
</body>
</html>