| 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/old20140414/Event/ |
Upload File : |
<?php include_once '../include/DBConnect.php'; ?>
<?php require_once 'Event_DetailForm_Activity_Save.php'; ?>
<?php ob_start(); ?>
<!DOCTYPE html>
<?php
$alert_lesson_staffcrash = false;
$alert_message = "";
if (isset($_POST['Detail_Save'])) {
foreach ($_COOKIE as $k => $a) {
setcookie($k, "", time() - 3600);
}
for ($i = 0; $i < sizeof($_POST['lesson_date']); $i++) {
for ($j = 0; $j < sizeof($_POST[$i . 'staff_id']); $j++) {
$sth2 = $dbh->query('SELECT Concat(last_name, " ",first_name, " ( ", ch_name," ) ") staff_name FROM `staff` WHERE root_id = ' . $_POST[$i . 'staff_id'][$j]);
$result = $sth2->fetch(PDO::FETCH_ASSOC);
$tmp_staff_name = $result['staff_name'];
$sth = $dbh->prepare("SELECT l.date,l.start_time,l.end_time,l.room_id,la.staff_id
FROM lesson_attendance la, lesson l WHERE la.actived = 1 and la.deleted = 0 and
l.actived = 1 and l.deleted = 0 and la.lesson_id = l.lesson_id and staff_id = ?
and l.date = ? and (
(? <= start_time and ? >= end_time ) or ( ? <= end_time and ? >= end_time ) or ( ? >= start_time and ? <= end_time ))");
$sth->bindParam(1, $_POST[$i . 'staff_id'][$j]);
$sth->bindParam(2, $_POST['lesson_date'][$i]);
$sth->bindParam(3, $_POST['start_time'][$i]);
$sth->bindParam(4, $_POST['end_time'][$i]);
$sth->bindParam(5, $_POST['start_time'][$i]);
$sth->bindParam(6, $_POST['end_time'][$i]);
$sth->bindParam(7, $_POST['start_time'][$i]);
$sth->bindParam(8, $_POST['end_time'][$i]);
$sth->execute();
if ($sth->rowcount() > 0) {
$alert_lesson_staffcrash = true;
while ($res = $sth->fetch(PDO::FETCH_ASSOC)) {
$alert_message = "Date : " . $res['date'] . " Time :" . $res['start_time'] . "~" . $res["end_time"] . " Staff Name : " . $tmp_staff_name;
}
}
}
}
}
if (isset($_POST['Detail_edit_Save'])) {
foreach ($_COOKIE as $k => $a) {
setcookie($k, "", time() - 3600);
}
for ($i = 0; $i < sizeof($_POST['lesson_date']); $i++) {
if (!isset($_POST[$i . 'staff_id'])) {
$alert_lesson_staffcrash = true;
$alert_message = "Please input staff data !!!";
} else
if (!isset($_POST[$i . 'student_id'])) {
$alert_lesson_staffcrash = true;
$alert_message = "Please input student data !!!";
} else
if (empty($_POST['lesson_id'][$i])) {
for ($j = 0; $j < sizeof($_POST[$i . 'staff_id']); $j++) {
$sth2 = $dbh->query('SELECT Concat(last_name, " ",first_name, " ( ", ch_name," ) ") staff_name FROM `staff` WHERE root_id = ' . $_POST[$i . 'staff_id'][$j]);
$result = $sth2->fetch(PDO::FETCH_ASSOC);
$tmp_staff_name = $result['staff_name'];
$sth = $dbh->prepare("SELECT l.date,l.start_time,l.end_time,l.room_id,la.staff_id
FROM lesson_attendance la, lesson l WHERE la.actived = 1 and la.deleted = 0 and
l.actived = 1 and l.deleted = 0 and la.lesson_id = l.lesson_id and staff_id = ?
and l.date = ? and (
(? <= start_time and ? >= end_time ) or ( ? <= end_time and ? >= end_time ) or ( ? >= start_time and ? <= end_time ))");
$sth->bindParam(1, $_POST[$i . 'staff_id'][$j]);
$sth->bindParam(2, $_POST['lesson_date'][$i]);
$sth->bindParam(3, $_POST['start_time'][$i]);
$sth->bindParam(4, $_POST['end_time'][$i]);
$sth->bindParam(5, $_POST['start_time'][$i]);
$sth->bindParam(6, $_POST['end_time'][$i]);
$sth->bindParam(7, $_POST['start_time'][$i]);
$sth->bindParam(8, $_POST['end_time'][$i]);
$sth->execute();
if ($sth->rowcount() > 0) {
$alert_lesson_staffcrash = true;
while ($res = $sth->fetch(PDO::FETCH_ASSOC)) {
$alert_message = "Date : " . $res['date'] . " Time :" . $res['start_time'] . "~" . $res["end_time"] . " Staff Name : " . $tmp_staff_name;
}
}
}
}
}
}
?>
<?php
if (!$alert_lesson_staffcrash) {
if (isset($_POST['Detail_edit_Save'])) {
if (isset($_POST['activity_title']))
SaveActivity($_POST, $_GET['event_id']);
for ($i = 0; $i < sizeof($_POST['lesson_date']); $i++) {
if (isset($_POST['hidden_checkbox'])) {
foreach ($_POST['hidden_checkbox'] as $hc) {
if ($hc == $_POST['lesson_id'][$i]) {
$dbh->query("UPDATE lesson_attendance SET lastupdate=now(),deleted=1 WHERE lesson_id=" . $hc . " and actived=1 and deleted=0");
$dbh->query("UPDATE lesson SET lastupdate=now(),deleted=1 WHERE lesson_id=" . $hc . " and actived=1 and deleted=0");
$dbh->query("UPDATE event_lesson SET lastupdate=now() ,deleted=1 WHERE lesson_id=" . $hc . " and actived=1 and deleted=0");
continue 2;
}
}
}
if (empty($_POST['lesson_id'][$i])) {
$sth = $dbh->prepare("INSERT INTO `lesson`(`createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`,
`room_id`, `date`, `start_time`, `end_time`, `upload_file`, `remarks`, `teaching_hr`)
VALUES (0,now(),0,now(),1,0,?,?,?,?,0,0,?)");
$sth->bindParam(1, $_POST['Room_id'][$i]);
$sth->bindParam(2, $_POST['lesson_date'][$i]);
$sth->bindParam(3, $_POST['start_time'][$i]);
$sth->bindParam(4, $_POST['end_time'][$i]);
$sth->bindParam(5, $_POST['teaching_hour'][$i]);
$sth->execute();
$sth = $dbh->query("select Max(lesson_id) id from lesson ");
$ResultSet = $sth->fetch(PDO::FETCH_ASSOC);
$lesson_id = $ResultSet['id'];
//$sth = $dbh->query("SELECT event_id FROM `event_lesson` WHERE lesson_id=" . $_POST['lesson_id'][($i - 1)] . " and actived=1 and deleted=0");
//$ResultSet = $sth->fetch(PDO::FETCH_ASSOC);
$event_id = $_GET['event_id'];
//SaveActivity($_POST, $event_id);
$sth = $dbh->query("INSERT INTO `event_lesson`(`event_id`, `createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `lesson_id`)
VALUES ('$event_id',0,now(),0,now(),1,0,'$lesson_id')");
// ### New for Leave App ### //
if (isset($_POST['action'])) {
$Save_page_state = $_POST["action"];
//$Save_page = "?leave_id=" . $_POST['leave_id'] . "&event_id=$event_id" . "&lesson_id=" . $_POST["action_lesson_id"] . "&makeup_lesson_id=" . $lesson_id . "&leave_lesson_id=" . $_POST["leave_lesson_id"] . "&action=$Save_page_state";
$Save_page = "?leave_id=" . $_POST['leave_id'] . "&event_id=$event_id" . "&lesson_id=" . $_POST["action_lesson_id"] . "&makeup_lesson_id=" . $lesson_id . "&action=$Save_page_state";
if (isset($_POST[$i . "for_make_lesson_date"])) {
$sql = "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`,state, `reason_id`,`make_up_lesson_id`)
VALUES (?,0,now(),0,now(),1,0,?,NULL,?,?,0,0,0,0,?,0,?,0,?,0,?)";
}
}
// ### New for Leave App ### //
} else {
$sth = $dbh->query('UPDATE `lesson_attendance` SET `lastupdate`=now(),`deleted`=1 WHERE `lesson_id`=' . $_POST['lesson_id'][$i] . ' ');
$sth = $dbh->query('UPDATE `lesson` SET `lastupby`=1,`lastupdate`=now(),`teaching_hr`=' . $_POST['teaching_hour'][$i] . ' WHERE lesson_id =' . $_POST['lesson_id'][$i]);
$sql = "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`,state, `reason_id`)
VALUES (?,0,now(),0,now(),1,0,?,NULL,?,?,0,0,0,?,?,0,?,?,?,0)";
if (isset($_POST['action'])) {
$Save_page_state = $_POST["action"];
$Save_page = "?leave_id=" . $_POST['leave_id'] . "&event_id=" . $_GET['event_id'] . "&lesson_id=" . $_POST["action_lesson_id"] . "&action=$Save_page_state";
if (isset($_POST[$i . "for_make_lesson_date"])) {
$sql = "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`,state, `reason_id`,`make_up_lesson_id`)
VALUES (?,0,now(),0,now(),1,0,?,NULL,?,?,0,0,0,?,?,0,?,?,?,0,?)";
}
}
}
for ($counter = 0; $counter < sizeof($_POST[$i . 'student_id']); $counter++) {
$arr1 = $_POST[$i . 'student_id'];
$arr2 = $_POST[$i . 'package_discount'];
if (!empty($_POST['lesson_id'][$i])) {
$sth2 = $dbh->query("select createdate,attendance,payroll_gened,invoice_gened,is_substitute,state,reason_id,make_up_lesson_id,make_up_lesson_id from lesson_attendance where actived = 1 and deleted = 1 and stu_linking_id = " . $_POST[$i . "student_id"][$counter] . " and lesson_id = " . $_POST['lesson_id'][$i] . " and createdate = (
select max(createdate) from lesson_attendance where actived = 1 and deleted = 1 and stu_linking_id = " . $_POST[$i . "student_id"][$counter] . " and lesson_id = " . $_POST['lesson_id'][$i] . "
)");
//$sth2->rowcount() == 0
while ($result_ForOldData = $sth2->fetch(PDO::FETCH_ASSOC)) {
$attendance = $result_ForOldData['attendance'];
$payroll_gened = $result_ForOldData['payroll_gened'];
$is_substitute = $result_ForOldData['is_substitute'];
$make = $result_ForOldData['make_up_lesson_id'];
}
$sth = $dbh->prepare($sql);
$sth->bindParam(1, $_POST['lesson_id'][$i]);
$sth->bindParam(2, $arr1[$counter]);
$sth->bindParam(3, $attendance);
$sth->bindparam(4, $_POST['lesson_date'][$i]);
$sth->bindParam(5, $payroll_gened);
$sth->bindParam(6, $_POST['invoice_gened'][$i]);
$sth->bindParam(7, $arr2[$counter]);
$sth->bindParam(8, $is_substitute);
$sth->bindParam(9, $_POST['lesson_state_' . $i][$counter]);
if (isset($_POST['action'])) {
if (isset($_POST[$i . "for_make_lesson_date"])) {
$sth->bindParam(10, $_POST[$i . 'for_make_lesson_date'][$counter]);
} else {
$sth->bindParam(10, $make);
}
}
$sth->execute();
} else {
$attendance = 2;
$payroll_gened = 0;
$is_substitute = 0;
$sth = $dbh->prepare($sql);
$sth->bindParam(1, $lesson_id);
$sth->bindParam(2, $arr1[$counter]);
$sth->bindParam(3, $attendance);
$sth->bindparam(4, $_POST['lesson_date'][$i]);
$sth->bindParam(5, $_POST['invoice_gened'][$i]);
$sth->bindParam(6, $arr2[$counter]);
$sth->bindParam(7, $_POST['lesson_state_' . $i][$counter]);
if (isset($_POST['action'])) {
$sth->bindParam(8, $_POST[$i . 'for_make_lesson_date'][$counter]);
}
$sth->execute();
}
}
for ($j = 0; $j < sizeof($_POST[$i . 'staff_id']); $j++) {
$arr2 = $_POST[$i . 'staff_id'];
$arr3 = $_POST[$i . 'staff_rate'];
$arr4 = $_POST[$i . 'Substitute'];
if (empty($_POST['lesson_id'][$i])) {
$attendance = 2;
$invoice_gened = 0;
$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 (?,0,now(),0,now(),1,0,NULL,?,?,?,0,0,?,?,?,1,0,?,0)");
$sth->bindParam(1, $lesson_id);
$sth->bindParam(2, $arr2[$j]);
$sth->bindParam(3, $attendance);
$sth->bindParam(4, $_POST['lesson_date'][$i]);
$sth->bindParam(5, $arr3[$j]);
$sth->bindParam(6, $_POST['payroll_gened'][$i]);
$sth->bindParam(7, $invoice_gened);
$sth->bindParam(8, $arr4[$j]);
$sth->execute();
} else {
$sth2 = $dbh->query("select createdate,attendance,payroll_gened,invoice_gened,is_substitute,state,reason_id,make_up_lesson_id,make_up_lesson_id from lesson_attendance "
. "where actived = 1 and deleted = 1 and stu_linking_id = " . $_POST[$i . "student_id"][$j] .
" and lesson_id = " . $_POST['lesson_id'][$i] . " and createdate = (
select max(createdate) from lesson_attendance where actived = 1 and deleted = 1 and stu_linking_id = " . $_POST[$i . "student_id"][$j] . " "
. "and lesson_id = " . $_POST['lesson_id'][$i] . "
)");
//$sth2->rowcount() == 0
while ($result_ForOldData = $sth2->fetch(PDO::FETCH_ASSOC)) {
$attendance = $result_ForOldData['attendance'];
$invoice_gened = $result_ForOldData['invoice_gened'];
$is_substitute = $result_ForOldData['is_substitute'];
}
$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 (?,0,now(),0,now(),1,0,NULL,?,?,?,0,0,?,?,?,1,0,?,0)");
$sth->bindParam(1, $_POST['lesson_id'][$i]);
$sth->bindParam(2, $arr2[$j]);
$sth->bindParam(3, $attendance);
$sth->bindParam(4, $_POST['lesson_date'][$i]);
$sth->bindParam(5, $arr3[$j]);
$sth->bindParam(6, $_POST['payroll_gened'][$i]);
$sth->bindParam(7, $invoice_gened);
$sth->bindParam(8, $arr4[$j]);
$sth->execute();
}
}
}
echo '<script>alert("Update Data Successful.");</script>';
if (!isset($Save_page_state) && !isset($_POST['action']))
header("Location: Event_List.php");
else {
if ($Save_page_state == 1 || $Save_page_state == 2)
echo "<script>location.href = \"../LeaveApplication/Staff_Approve.php$Save_page\";</script>";
else
echo "<script>location.href = \"../LeaveApplication/Student_Approve.php$Save_page\";</script>";
}
}
$staffrate = array("Monthly", "Teacher ( In House )", "Teacher ( Outside School )",
"Teacher Assistant ( In House )", "Teacher Assistant ( Outside School )", "Traveling", "Other");
//-----#################### ↓ lesson detail after add page #################### -----//
?>
<?php if (!isset($_GET['event_id'])) { ?>
<?php
$class_size = $_POST['class_size'];
$programme = $_POST['programme'];
$subject_id = $_POST['subject_id'];
$event_type = $_POST['event_type'];
$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;
}
if ($Programme_fee_type == 4) {
$primary_ind = $_POST['school_fee'];
$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;
}
$startdate = $_POST['start_date'];
$enddate = $_POST['End_date'];
$Rate = $_POST['Rate_select'];
$check_date = $_POST['check_date'];
$Room_ID = $_POST['Room_id'];
//-----#################### ↓ Generate code id #################### -----//
$sth = $dbh->query("SELECT `prog_short_form` FROM `program` WHERE program_id = " . $programme . " and actived = 1 and deleted=0 ");
$programe = $sth->fetch(PDO::FETCH_ASSOC);
$sth = $dbh->query("SELECT `sub_short_form` FROM `subject` WHERE actived = 1 and deleted = 0 and subject_id = " . $subject_id);
$subject = $sth->fetch(PDO::FETCH_ASSOC);
if (date("m", time()) >= 9) {
$NowDate = date("y", time()) . (date("y", time()) + 1);
} else {
$NowDate = (date("y", time()) - 1) . date("y", time());
}
$group = ($event_type == '0') ? "g" : "i";
$sth = $dbh->query("SELECT COUNT(*) countgroup FROM `event` WHERE actived=1 and deleted=0 and program_id=" . $programme . " and subject_id=" . $subject_id);
$ResultSet = $sth->fetch(PDO::FETCH_ASSOC);
if (($ResultSet['countgroup'] + 1) <= 9)
$count_event_group = '0' . ($ResultSet['countgroup'] + 1);
else
$count_event_group = ($ResultSet['countgroup'] + 1);
$code_id = $programe['prog_short_form'] . $subject['sub_short_form'] . $group . $NowDate . '-' . $count_event_group;
//-----#################### ↑ Generate code id #################### -----//
//-----#################### ↓ detail page after add is save #################### -----//
if (isset($_POST['Detail_Save'])) {
$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, $_POST['code_id']);
$sth->bindParam(2, $programme);
$sth->bindParam(3, $subject_id);
$sth->bindParam(4, $class_size);
$sth->bindParam(5, $Programme_fee_type);
$sth->bindParam(6, $_POST['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();
for ($i = 0; $i < sizeof($_POST['lesson_date']); $i++) {
$sth = $dbh->prepare("INSERT INTO `lesson`(`createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`,
`room_id`, `date`, `start_time`, `end_time`, `upload_file`, `remarks`, `teaching_hr`)
VALUES (0,now(),0,now(),1,0,?,?,?,?,0,0,?)");
$sth->bindParam(1, $_POST['Room_id'][$i]);
$sth->bindParam(2, $_POST['lesson_date'][$i]);
$sth->bindParam(3, $_POST['start_time'][$i]);
$sth->bindParam(4, $_POST['end_time'][$i]);
$sth->bindParam(5, $_POST['teaching_hour'][$i]);
$sth->execute();
$sth = $dbh->prepare("SELECT `lesson_id` FROM `lesson` WHERE `actived`=1 and`deleted`=0 and`room_id`=? and `date`=? and`start_time`=? and `end_time`=? and teaching_hr = ?");
$sth->bindParam(1, $_POST['Room_id'][$i]);
$sth->bindParam(2, $_POST['lesson_date'][$i]);
$sth->bindParam(3, $_POST['start_time'][$i]);
$sth->bindParam(4, $_POST['end_time'][$i]);
$sth->bindParam(5, $_POST['teaching_hour'][$i]);
$sth->execute();
$lesson_id = array();
while ($ResultSet = $sth->fetch(PDO::FETCH_ASSOC)) {
$lesson_id = $ResultSet;
}
$sth = $dbh->query("SELECT Max(`event_id`) e FROM `event` where `actived`=1 and `deleted`=0");
while ($ResultSet = $sth->fetch(PDO::FETCH_ASSOC)) {
$event_id = $ResultSet['e'];
}
foreach ($lesson_id as $les) {
$sth = $dbh->query("INSERT INTO `event_lesson`(`event_id`, `createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `lesson_id`)
VALUES ($event_id,1,now(),1,now(),1,0,$les)");
}
for ($j = 0; $j < sizeof($_POST[$i . 'staff_id']); $j++) {
$arr2 = $_POST[$i . 'staff_id'];
$arr3 = $_POST[$i . 'staff_rate'];
$arr4 = $_POST[$i . 'Substitute'];
$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 (?,0,now(),0,now(),1,0,NULL,?,2,?,0,0,?,0,0,1,0,?,NULL)");
$sth->bindParam(1, $lesson_id['lesson_id']);
$sth->bindParam(2, $arr2[$j]);
$sth->bindParam(3, $_POST['lesson_date'][$i]);
$sth->bindParam(4, $arr3[$j]);
$sth->bindParam(5, $arr4[$j]);
$sth->execute();
}
for ($k = 0; $k < sizeof($_POST[$i . 'student_id']); $k++) {
$arr1 = $_POST[$i . 'student_id'];
$arr5 = $_POST[$i . 'package_discount'];
$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`,state, `reason_id`)
VALUES (?,0,now(),0,now(),1,0,?,NULL,2,?,0,0,0,0,0,1,?,0,?,0)");
$sth->bindParam(1, $lesson_id['lesson_id']);
$sth->bindParam(2, $arr1[$k]);
$sth->bindParam(3, $_POST['lesson_date'][$i]);
$sth->bindParam(4, $arr5[$k]);
$sth->bindParam(5, $_POST['lesson_state_' . $i][$k]);
$sth->execute();
}
}
echo "<script>location.href = \"Event_Detail_ClearCookie.php\";</script>";
//userheader('Location: Event_List.php');
}
//-----#################### ↑ detail page after add is save #################### -----//
$alert = "";
$select_Day = array();
for ($i = 0; $i < sizeof($check_date); $i++) {
switch ($check_date[$i]) {
case 0:
array_push($select_Day, 'Mon');
break;
case 1:
array_push($select_Day, 'Tue');
break;
case 2:
array_push($select_Day, 'Wed');
break;
case 3:
array_push($select_Day, 'Thu');
break;
case 4:
array_push($select_Day, 'Fri');
break;
case 5:
array_push($select_Day, 'Sat');
break;
case 6:
array_push($select_Day, 'Sun');
break;
}
}
$lesson_date_Generate = array();
$length = ((strtotime($enddate) - strtotime($startdate)) / 3600 / 24 > 7 || (strtotime($enddate) - strtotime($startdate)) == 0 ) ? 7 : (strtotime($enddate) - strtotime($startdate)) / 3600 / 24 - 1;
for ($i = 0; $i < $length; $i++) {
for ($j = 0; $j < sizeof($select_Day); $j++) {
$start_time_checkdate = explode(":", $_POST['start_time'][$check_date[$j]]);
$end_time_checkdate = explode(":", $_POST['end_time'][$check_date[$j]]);
if (date("D", strtotime($startdate) + 60 * 60 * 24 * $i) == $select_Day[$j]) {
array_push($lesson_date_Generate, array(
strtotime($startdate) + 60 * 60 * 24 * $i,
mktime($start_time_checkdate[0], $start_time_checkdate[1]),
mktime($end_time_checkdate[0], $end_time_checkdate[1]),
$Room_ID[$check_date[$j]]
));
}
}
}
for ($i = 0; $i < sizeof($lesson_date_Generate); $i++) {
if ($lesson_date_Generate[$i][0] + 60 * 60 * 24 * 7 * $Rate > strtotime($enddate))
break;
array_push($lesson_date_Generate, array(
$lesson_date_Generate[$i][0] + 60 * 60 * 24 * 7 * $Rate,
$lesson_date_Generate[$i][1],
$lesson_date_Generate[$i][2],
$lesson_date_Generate[$i][3]
));
}
$alert_array = array();
$alert_str = "";
$sth = $dbh->query('SELECT `room_id`, `date`, `start_time`, `end_time`, teaching_hr FROM `lesson` WHERE `actived`=1 and `deleted`=0 order by date');
$lesson_date = array();
for ($i = 0; $i < sizeof($lesson_date_Generate); $i++) {
while ($ResultSet = $sth->fetch(PDO::FETCH_ASSOC)) {
$Resultset_start_time = explode(':', $ResultSet['start_time']);
$ResultSet_end_time = explode(':', $ResultSet['end_time']);
if ($lesson_date_Generate[$i][0] == strtotime($ResultSet['date']) && $lesson_date_Generate[$i][3] == $ResultSet['room_id']) {
$db_starttime = mktime($Resultset_start_time[0], $Resultset_start_time[1]);
$db_endtime = mktime($ResultSet_end_time[0], $ResultSet_end_time[1]);
$gen_starttime = $lesson_date_Generate[$i][1];
$gen_endtime = $lesson_date_Generate[$i][2];
/* S=db start time E=db end time ||=gen start/end time */
/* --- case 1 :( | S E | ) --- */
/* --- case 2 :( | S | E ) --- */
/* --- case 3 :( S | E | ) --- */
/* --- case 4 :( S | | E ) --- */
if ($db_starttime <= $gen_starttime && $db_endtime >= $gen_starttime) { // case 1, case 2
$alert = 'Date : ' . $ResultSet['date'] . ' Start Time : ' . date("H:i", $gen_starttime) . ' End Time : ' . date("H:i", $gen_endtime) . '\n';
array_push($alert_array, $alert);
continue 2;
}
if ($db_starttime <= $gen_endtime && $db_endtime >= $gen_endtime) { // case 3, case 1
$alert = 'Date : ' . $ResultSet['date'] . ' Start Time : ' . date("H:i", $gen_starttime) . ' End Time : ' . date("H:i", $gen_endtime) . '\n';
array_push($alert_array, $alert);
continue 2;
}
if ($db_starttime >= $gen_starttime && $db_endtime <= $gen_endtime) { // case 4
$alert = 'Date : ' . $ResultSet['date'] . ' Start Time : ' . date("H:i", $gen_starttime) . ' End Time : ' . date("H:i", $gen_endtime) . '\n';
array_push($alert_array, $alert);
continue 2;
}
}
}
array_push($lesson_date, array(date("Y/m/d", $lesson_date_Generate[$i][0]), date("H:i", $lesson_date_Generate[$i][1]), date("H:i", $lesson_date_Generate[$i][2]), $lesson_date_Generate[$i][3], "6" => (($lesson_date_Generate[$i][2] - $lesson_date_Generate[$i][1]) / 60)));
}
//-----#################### ↑ lesson detail after add page #################### -----//
} else {
$lesson_date = array();
$sth = $dbh->query("select `room_id`,`date`,`start_time`,`end_time`,`lesson_id`,teaching_hr,lesson_leave_status 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'], "6" => $ResultSet['teaching_hr'], "leave_status" => $ResultSet['lesson_leave_status']));
}
$sth = $dbh->query("SELECT lesson_id FROM lesson_attendance WHERE actived = 1 and deleted = 0 and payroll_gened = 1");
while ($result = $sth->fetch(PDO::FETCH_ASSOC)) {
foreach ($lesson_date as $k => $a) {
if ($result["lesson_id"] == $a[4]) {
$lesson_date[$k]["action_p"] = "payroll_gened";
}
}
}
$sth = $dbh->query("SELECT lesson_id FROM lesson_attendance WHERE actived = 1 and deleted = 0 and invoice_gened = 1");
while ($result = $sth->fetch(PDO::FETCH_ASSOC)) {
foreach ($lesson_date as $k => $a) {
if ($result["lesson_id"] == $a[4]) {
$lesson_date[$k]["action"] = "invoice_gened";
}
}
}
}
}
?>
<html>
<head>
<?php require_once '../include/head.php'; ?>
<?php require_once '../include/checkuser.php'; ?>
<?php require_once '../include/Nav_bar.php'; ?>
<script>
<?php if (isset($_GET['action'])) { ?>
$(function(){
$(".student_name").change(function(){
var student_id = $(this).val().split(',')[3];
var event_id_position = document.URL.search("event_id=");
var event_id = (document.URL.substring(event_id_position, document.URL.length).split('&')[0].split("=")[1])
$.get("Event_DetailFrom_ajax.php?event_id=" + event_id + "&root_id=" + student_id, student_date);
})
function student_date(res){
$(".stu_date").html(res);
}
});
<?php } ?>
var student_id, staff_id, row = 0, row_staff = 0, data = 0;
var staffrate = new Array("Monthly", "Teacher ( In House )", "Teacher ( Outside School )",
"Teacher Assistant ( In House )", "Teacher Assistant ( Outside School )", "Traveling", "Other");
var staffrate_Substitute = new Array("Monthly ( Substitute )", "Teacher ( In House ) ( Substitute )", "Teacher ( Outside School ) ( Substitute )",
"Teacher Assistant ( In House ) ( Substitute )", "Teacher Assistant ( Outside School ) ( Substitute )", "Traveling ( Substitute )", "Other ( Substitute )");
$.fn.modal.Constructor.prototype.enforceFocus = function() {};
$(function() {
$('#start_date_id').datetimepicker({autoclose: true, pickTime: false, startDate: new Date()});
$('#start_date_id').datetimepicker().on('changeDate', function(ev){
$('#start_date_id').datetimepicker('hide');
$('#start_time').focus();
});
$(".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(",");
});
data = $('#sizeof_lesson').val();
$('.timepicker_start').timepicker({'timeFormat': 'H:i', 'step': 5, 'minTime': '6:00', 'maxTime': '22:00', disableTextInput: false});
$('.timepicker_end').timepicker({'timeFormat': 'H:i', 'step': 5, 'minTime': '6:00', 'maxTime': '22:00', disableTextInput: false});
$('#contextForm').validate();
});
function adddate_staff(n, n1) {
row_staff++;
var rate = $('#Rate_staff_' + n).val();
var word = "";
if (document.getElementById('staff_lesson_only_' + n).checked == true) {
for (var j = 0; j < $('#staff_table_' + n + ' tr').length; j++) { // loop the tr in tbody
if ($('#staff_table_' + n + ' tr:nth-child(' + (j + 1) + ') td:nth-child(3) input').val() == staff_id[2]) {
return false;
}
}
if (rate.split(" ")[2] == 0){
var word = staffrate[rate.split(" ")[1]];
}
if (rate.split(" ")[2] == 1){
var word = staffrate_Substitute[rate.split(" ")[1]];
}
$('#staff_table_' + n).append(
'<tr>' +
'<td><button type="button" class="btn" onclick="delete_row_staff(this,' + n + ');"><i class="icon-remove"></i></button></td>' +
'<td>' + staff_id[0] + ' ( ' + staff_id[1] + ' ) ' +
' <td>' + word +
'<input type="hidden" name="' + n + 'staff_id[]" value="' + staff_id[2] + '"/>' +
'<input type="hidden" name="' + n + 'staff_rate[]" value="' + rate.split(" ")[1] + '"/>' +
'<input type="hidden" name="' + n + 'Substitute[]" value="' + rate.split(" ")[2] + '"/>' +
'</td>' +
'</tr>')
}
if (document.getElementById('staff_lesson_All_' + n).checked == true) {
adddataall_staff(n, n1);
}
}
function adddataall_staff(n, n1) {
n1 -= 1;
var rate = $('#Rate_staff_' + n).val();
var abort = false;
var word = "";
for (var i = n; i < data; i++) {
for (var j = 0; j < $('#staff_table_' + i + ' tr').length; j++) { // loop the tr in tbody
if ($('#staff_table_' + i + ' tr:nth-child(' + (j + 1) + ') td:nth-child(3) input').val() == staff_id[2]) {
abort = true;
}
}
if (abort == true)
continue;
if (rate.split(" ")[2] == 0){
var word = staffrate[rate.split(" ")[1]];
}
if (rate.split(" ")[2] == 1){
var word = staffrate_Substitute[rate.split(" ")[1]];
}
$('#staff_table_' + i).append(
'<tr>' +
'<td><button type="button" class="btn" onclick="delete_row_staff(this,' + i + ');"><i class="icon-remove"></i></button></td>' +
'<td>' + staff_id[0] + ' ( ' + staff_id[1] + ' ) ' +
' <td>' + word +
'<input type="hidden" name="' + i + 'staff_id[]" value="' + staff_id[2] + '"/>' +
'<input type="hidden" name="' + i + 'staff_rate[]" value="' + rate.split(" ")[1] + '"/>' +
'<input type="hidden" name="' + i + 'Substitute[]" value="' + rate.split(" ")[2] + '"/>' +
'</td>' +
'</tr>')
}
}
function adddate(n, n1) {
var package_discount = ($("#pack\\[" + n1 + "\\]").val());
<?php if (isset($_GET['action'])) { ?>
var stu_date = $('#stu_date\\[' + n1 + '\\]').val().split(',')[0];
var lesson_id = parseInt($('#stu_date\\[' + n1 + '\\]').val().split(',')[1]);
var first_lesson_id = parseInt($("#lesson_id\\[1\\]").val());
var the_row_of_thislesson = lesson_id - first_lesson_id;
for (var j = 0; j < $('#student_table_' + the_row_of_thislesson + ' tr').length; j++) { // loop the tr in tbody
if ($('#student_table_' + the_row_of_thislesson + ' tr:nth-child(' + (j + 1) + ') td:nth-child(2) input').val() == student_id[3]) {
if ($('#student_table_' + the_row_of_thislesson + ' tr:nth-child(' + (j + 1) + ') td:nth-child(3) select').val() != 3){
alert("Warning!!! 不需要補堂");
return false;
}
}
}
<?php } ?>
row++;
if (document.getElementById('lesson_only_' + n).checked == true) {
for (var j = 0; j < $('#student_table_' + n + ' tr').length; j++) { // loop the tr in tbody
if ($('#student_table_' + n + ' tr:nth-child(' + (j + 1) + ') td:nth-child(2) input').val() == student_id[3]) {
return false;
}
}
$('#student_table_' + n + ' ').append(
'<tr>' +
'<td><button type="button" class="btn" onclick="delete_row_student(this,' + n + ');"><i class="icon-remove"></i></button></td>' +
'<td>' + student_id[1] + ' ( ' + student_id[2] + ' ) <br/> ID : ' + student_id[0] +
'<input type="hidden" name="' + n + 'student_id[]" value="' + student_id[3] + '"/></td>' +
'<td style="padding-top: 10px;"> <select disabled style="width: 100%;" name="lesson_state_' + n + '[]"><option value="1">Normal Class</option><option value="2" <?php
if (isset($_GET['action'])) {
echo 'selected';
}
?>>Make-up Class</option><option value="3">Need make up</option><option value="4">Cancel</option><option value="5">Had make up</option></select></td>' +
'<td>' +
'<div class="input-prepend" style="margin-bottom: 1px;">' +
'<button class="btn" disabled>$</button>' +
'<input type="text" name="' + n + 'package_discount[]" value="' + package_discount + '" style="width: 150px;" onafterpaste="this.value=this.value.replace(/[^\\d]/g,\'\')" onkeyup="this.value=this.value.replace(/[^\\d]/g,\'\')">' +
'</div>' +
'</td>' +
<?php if (isset($_GET['action'])) { ?> '<td>' + stu_date + '<input type="hidden" name="' + n + 'for_make_lesson_date[]" value="' + lesson_id + '"/></td>' +<?php } ?>'</tr>');
}
if (document.getElementById('lesson_All_' + n).checked == true) {
adddataall(n);
}
}
function adddataall(n1) {
var package_discount = ($("#pack\\[" + (n1 + 1) + "\\]").val());
<?php if (isset($_GET['action'])) { ?>
var stu_date = $('#stu_date\\[' + (n1 + 1) + '\\]').val().split(',')[0];
var lesson_id = parseInt($('#stu_date\\[' + (n1 + 1) + '\\]').val().split(',')[1]);
var first_lesson_id = parseInt($("#lesson_id\\[1\\]").val());
var the_row_of_thislesson = lesson_id - first_lesson_id;
for (var j = 0; j < $('#student_table_' + the_row_of_thislesson + ' tr').length; j++) { // loop the tr in tbody
if ($('#student_table_' + the_row_of_thislesson + ' tr:nth-child(' + (j + 1) + ') td:nth-child(2) input').val() == student_id[3]) {
if ($('#student_table_' + the_row_of_thislesson + ' tr:nth-child(' + (j + 1) + ') td:nth-child(3) select').val() != 3){
alert("Warning!!!不需要補堂");
return false;
}
}
}
<?php } ?>
var abort = false;
for (var i = n1; i < data; i++) {
for (var j = 0; j < $('#student_table_' + i + ' tr').length; j++) { // loop the tr in tbody
if ($('#student_table_' + i + ' tr:nth-child(' + (j + 1) + ') td:nth-child(2) input').val() == student_id[3]) {
abort = true;
}
}
if (abort == true)
continue;
$('#student_table_' + i + ' ').append('<tr id="tr_' + row + '">' +
'<td><button type="button" class="btn" onclick="delete_row_student(this,' + i + ');"><i class="icon-remove"></i></button></td>' +
'<td>' + student_id[1] + ' ( ' + student_id[2] + ' ) <br/> ID : ' + student_id[0] +
'<input type="hidden" name="' + i + 'student_id[]" value="' + student_id[3] + '" /></td>' +
'<td style="padding-top: 10px;"> <select disabled style="width: 100%;" name="lesson_state_' + i + '[]"><option value="1">Normal Class</option><option value="2" <?php
if (isset($_GET['action'])) {
echo 'selected';
}
?>>Make-up Class</option><option value="3">Need make up</option><option value="4">Cancel</option><option value="5">Had make up</option></select></td>' +
'<td>' +
'<div class="input-prepend" style="margin-bottom: 1px;">' +
'<button class="btn" disabled>$</button>' +
'<input type="text" name="' + i + 'package_discount[]" value="' + package_discount + '" style="width: 150px;" onafterpaste="this.value=this.value.replace(/[^\\d]/g,\'\')" onkeyup="this.value=this.value.replace(/[^\\d]/g,\'\')">' +
'</div>' +
'</td>' +
<?php if (isset($_GET['action'])) { ?> '<td>' + stu_date + '<input type="hidden" name="' + i + 'for_make_lesson_date[]" value="' + lesson_id + '"/></td>' +<?php } ?>
'</tr>');
}
}
function checkradio(num, v) {
num -= 1;
<?php if (!isset($_GET['action'])) { ?>
document.getElementById('lesson_All_' + num).checked = true;
<?php } else { ?>document.getElementById('lesson_only_' + num).checked = true; <?php } ?>
}
function checkradio2(num, v) {
num -= 1;
document.getElementById('staff_lesson_All_' + num).checked = true;
}
function delete_row_student(e, tbody_id) {
if (document.getElementById('lesson_only_' + tbody_id).checked == true) {
$(e).parent().parent().remove();
}
if (document.getElementById('lesson_All_' + tbody_id).checked == true) {
delete_row_student_Aall(e, tbody_id);
}
}
function delete_row_student_Aall(e, tbody_id) {
var hidden_value = $(e).parent().next().children().next().val(); //use to compare the hidden value
for (var i = tbody_id; i < data; i++) {//loop the tbody of the model
for (var j = 0; j < $('#student_table_' + i + ' tr').length; j++) { // loop the tr in tbody
if ($('#student_table_' + i + ' tr:nth-child(' + (j + 1) + ') td:nth-child(2) input').val() == hidden_value) {
$('#student_table_' + i + ' tr:nth-child(' + (j + 1) + ')').remove();
}
}
}
}
function delete_row_staff(e, tbody_id) {
if (document.getElementById('staff_lesson_only_' + tbody_id).checked == true) {
$(e).parent().parent().remove();
}
if (document.getElementById('staff_lesson_All_' + tbody_id).checked == true) {
delete_row_staff_Aall(e, tbody_id);
}
}
function delete_row_staff_Aall(e, tbody_id) {
var hidden_value = $(e).parent().nextAll().children().val(); //use to compare the hidden value
for (var i = tbody_id; i < data; i++) {//loop the tbody of the model
for (var j = 0; j < $('#staff_table_' + i + ' tr').length; j++) { /* loop the tr in tbody */
if ($('#staff_table_' + i + ' tr:nth-child(' + (j + 1) + ') td:nth-child(3) input').val() == hidden_value) {
$('#staff_table_' + i + ' tr:nth-child(' + (j + 1) + ')').remove();
}
}
}
}
function delete_row_lesson(e, r) {
$(e).parent().parent().remove();
$('#staff_modal_' + r).remove();
$('#student_modal_' + r).remove();
}
function change_row_lesson(e, n) {
$(e).parent().parent().addClass("error");
document.getElementById(n + "_hidden_checkbox").checked = true;
}
function lesson_ADD(e) {
var lesson_date, starttime, endtime, roomid, sizeof_lesson;
data++;
lesson_date = $('#date').val();
starttime = $('#start_time').val();
endtime = $('#end_time').val();
roomid = $('#lesson_roomid').val();
sizeof_lesson = $('#sizeof_lesson').val();
if (lesson_date == "" || starttime == "" || endtime == "" || roomid == "") {
alert("Warning !!! \n Please input all data into the field. ");
$('#date').next().click();
return;
}
$.get("Event_DetailFrom_ajax.php?lesson_date=" + lesson_date + "&starttime=" + starttime + "&endtime=" + endtime + "&roomid=" + roomid + "&row=" + data + "&event_id=" + e, result)
}
function result(res) {
if (res == "1234") {
alert("Warning!!!\nThis lesson cannot add in the list");
} else {
$('#lesson_table').append(res);
}
}
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]]});
$(e).parent().next().next().next().next().children().focus();
}
//new
function add_student_label(){
for (var count = 0; count <= data; count++){
var student_name_array = new Array(), student_name_string = "";
var student_id_array = new Array();
var student_lesson_state = new Array();
var student_package = new Array();
var lesson_state = new Array("", "Normal Class", "Make-up Class");
var lesson_state = new Array("", "Normal Class", "Make-up Class", "Need make up", "Cancel", "Had make up");
var stu_date = new Array();
for (var j = 0; j < $('#student_table_' + count + ' tr').length; j++){
student_name_array.push($('#student_table_' + count + ' tr:nth-child(' + (j + 1) + ') td:nth-child(2)').html().split("<")[0]);
student_id_array.push($('#student_table_' + count + ' tr:nth-child(' + (j + 1) + ') td:nth-child(2)').html().split("<")[1].split(">")[1]);
student_lesson_state.push(($('#student_table_' + count + ' tr:nth-child(' + (j + 1) + ') td:nth-child(3) select').val()));
student_package.push(($('#student_table_' + count + ' tr:nth-child(' + (j + 1) + ') td:nth-child(4) input').val()));
stu_date.push(($('#student_table_' + count + ' tr:nth-child(' + (j + 1) + ') td:nth-child(5)').html() != ""? $('#student_table_' + count + ' tr:nth-child(' + (j + 1) + ') td:nth-child(5)').html():"None"));
}
for (var n = 0; n < student_name_array.length; n++){
student_name_string += (student_name_string == "")?(student_id_array[n] + " | " + student_name_array[n] + " | " + lesson_state[student_lesson_state[n]]) + " | Package Discount : $" + student_package[n] +<?php if (isset($_GET['action'])) { ?>" Makeup-class Date : " + stu_date[n] <?php
} else {
echo'""';
}
?> :'<br/>' + (student_id_array[n] + " | " + student_name_array[n] + " | " + lesson_state[student_lesson_state[n]]) + " | Package Discount : $" + student_package[n] + <?php if (isset($_GET['action'])) { ?>" Makeup-class Date : " + stu_date[n]<?php
} else {
echo'""';
}
?>;
}
$('#student_label_0' + count).html(student_name_string);
}
}
function add_staff_label(){
for (var count = 0; count <= data; count++){
var staff_name_array = new Array(), staff_name_string = "";
var staff_Rate_array = new Array();
for (var j = 0; j < $('#staff_table_' + count + ' tr').length; j++){
staff_Rate_array.push($('#staff_table_' + count + ' tr:nth-child(' + (j + 1) + ') td:nth-child(3)').html().split("<")[0]);
staff_name_array.push($('#staff_table_' + count + ' tr:nth-child(' + (j + 1) + ') td:nth-child(2)').html());
}
for (var n = 0; n < staff_name_array.length; n++){
staff_name_string += (staff_name_string == "")?(staff_Rate_array[n] + " | " + staff_name_array[n]):'<br/>' + (staff_Rate_array[n] + " | " + staff_name_array[n]);
}
$('#staff_label_0' + count).html(staff_name_string);
}
}
function Submit_onclick(){
$(".student_table").find("select").each(function(){
$(this).attr("disabled", false);
});
}
</script>
<?php if (isset($_GET['event_id'])) { ?>
<script>$(function(){ add_staff_label(); add_student_label(); });</script>
<?php } ?>
<?php
if ($alert_lesson_staffcrash) {
echo '
<script>
alert("Warning Lesson is crash!!! \n' . $alert_message . '");
location.href = "Event_List.php";
</script>';
}
?>
<style>
label{cursor: auto}
.modal {
width: 730px;
left: 45%;
}
.modal-stu {
width: 1000px;
left: 35%;
}
.table tbody tr.warning > td {
background-color: #f6ebae;
}
</style>
</head>
<body>
<?php
if (!empty($alert_array)) {
foreach ($alert_array as $k)
$alert_str.=$k;
echo '<script>alert("Warning Lesson is crash!!! \n' . $alert_str . '");</script>';
echo '<script>window.history.back()</script>';
}
?>
<!-- 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>
<li class="active">Event Detail</li>
</ul>
</div>
<div class="container-fluid pathways-container">
<h3>Detail</h3>
<?php
if (!empty($_POST)) {
setcookie("code_id", $code_id, time() + 3600);
setcookie("programme", $programme, time() + 3600);
setcookie("subject_id", $subject_id, time() + 3600);
setcookie("class_size", $class_size, time() + 3600);
setcookie("programme_fee", $_POST['programme_fee'], time() + 3600);
setcookie("primary_ind", $primary_ind, time() + 3600);
setcookie("primary_gp", $primary_gp, time() + 3600);
setcookie("secondary_ind", $secondary_ind, time() + 3600);
setcookie("secondary_gp", $secondary_gp, time() + 3600);
setcookie("primary_package_fee", $primary_package_fee, time() + 3600);
setcookie("secondary_package_fee", $secondary_package_fee, time() + 3600);
setcookie("primary_package_discount", $primary_package_discount, time() + 3600);
setcookie("secondary_package_discount", $secondary_package_discount, time() + 3600);
setcookie("event_type", $event_type, time() + 3600);
setcookie("startdate", $startdate, time() + 3600);
setcookie("enddate", $enddate, time() + 3600);
setcookie("Rate_select", $_POST['Rate_select'], time() + 3600);
setcookie("school_type", $school_type, time() + 3600);
foreach ($check_date as $k => $a) {
setcookie("checkdate" . $k, $check_date[$k], time() + 3600);
setcookie("starttime" . $k, $_POST['start_time'][$a]);
setcookie("endtime" . $k, $_POST['end_time'][$a]);
setcookie("roomid" . $k, $Room_ID[$a], time() + 3600);
}
}
?>
<form action="" method="post" autocomplete="off" id="contextForm">
<input type="hidden" name="code_id" value="<?= $code_id ?>"/>
<input type="hidden" name="programme" value="<?= $programme ?>"/>
<input type="hidden" name="subject_id" value="<?= $subject_id ?>"/>
<input type="hidden" name="class_size" value="<?= $class_size ?>"/>
<input type="hidden" name="programme_fee" value="<?= $_POST['programme_fee'] ?>"/>
<input type="hidden" name="primary_ind" value="<?= $primary_ind ?>"/>
<input type="hidden" name="primary_gp" value="<?= $primary_gp ?>"/>
<input type="hidden" name="secondary_ind" value="<?= $secondary_ind ?>"/>
<input type="hidden" name="secondary_gp" value="<?= $secondary_gp ?>"/>
<input type="hidden" name="primary_package_fee" value="<?= $primary_package_fee ?>"/>
<input type="hidden" name="secondary_package_fee" value="<?= $secondary_package_fee ?>"/>
<input type="hidden" name="primary_package_discount" value="<?= $primary_package_discount ?>"/>
<input type="hidden" name="secondary_package_discount" value="<?= $secondary_package_discount ?>"/>
<input type="hidden" name="school_type" value="<?= $school_type ?>"/>
<?php if (isset($_GET['action'])) { ?>
<input type="hidden" name="action_lesson_id" value="<?= $_GET['lesson_id'] ?>"/>
<input type="hidden" name="leave_id" value="<?= $_GET['leave_id'] ?>"/>
<input type="hidden" name="action" value="<?= $_GET['action'] ?>"/>
<?php } ?>
<div id="student_data"></div>
<div id="staff_data"></div>
<div style="margin: 0;padding: 5px 10px;background-color: #F7F7F7;border: 1px solid #E6E6E6;border-radius: 5px;box-shadow: 0 1px 2px rgba(0,0,0,.05);">
<table style="margin-top: 10px;">
<tr>
<td><label>Lesson Date </label></td>
<td style="width: 15px;"></td>
<td>
<div class="input-append date-picker" id="start_date_id">
<input id="date" class="dateISO" type="text" placeholder="Lesson Date" data-format="yyyy-MM-dd" value="" name="" 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: 30px;"></td>
<td><label>Start Time </label></td>
<td style="width: 15px;"></td>
<td><input style="width: 80px;" type="text" class="timepicker_start" id="start_time" name="start_time" onchange="limit_time(this);" /></td>
<td style="width: 30px;"></td>
<td><label>End Time </label></td>
<td style="width: 15px;"></td>
<td><input style="width: 80px;" type="text" class="timepicker_end" id="end_time" name="end_time" onchange="limit_time(this);" /></td>
<td style="width: 30px;"></td>
<td><label>Room</label></td>
<td style="width: 15px;"></td>
<?php $sth = $dbh->query('SELECT `room_ID`, `actived`, `deleted` FROM `venue` WHERE `actived`=1 and `deleted`=0 order by 1'); ?>
<?php $option = '<option value=""></option>'; ?>
<?php while ($ResultSet = $sth->fetch(PDO::FETCH_ASSOC)) { ?>
<?php $option .= "<option value=" . $ResultSet['room_id'] . ">" . $ResultSet['room_id'] . "</option>"; ?>
<?php } ?>
<td>
<select id="lesson_roomid" autocomplete="off"><?= $option ?></select>
</td>
<td style="width: 30px;"></td>
<td style="padding-bottom: 10px;"><a href="#" class="btn" onclick="lesson_ADD(<?= isset($_GET['event_id']) ? 1 : 0 ?>);"><i class="icon-plus" ></i> Add</a></td>
<td style="width: 30px;"></td>
</tr>
</table>
</div>
<div style="height: 15px;" ></div>
<table class="table table-striped table-bordered table-hover table-condensed">
<thead>
<tr>
<th style="width: 20px">Delete</th>
<th>Lesson Date</th>
<th>Start Time</th>
<th>End Time</th>
<th style="width: 10%;">Teaching Hour</th>
<th>Room</th>
<th style="width:30%;">Student</th>
<th style="width:30%;">Staff</th>
</tr>
</thead>
<tbody id="lesson_table">
<?php $counter = 0; ?>
<?php foreach ($lesson_date as $arr) { ?>
<?php $counter++; ?>
<?php
if (isset($_GET['action'])) {
if ($_GET['lesson_id'] == $arr[4])
echo '<tr class="warning">';
else
if ($arr['leave_status'] == 1)
echo'<tr class="success">';
}
?>
<?php if (!isset($_GET['event_id'])) { ?>
<td style="margin-left:auto;margin-right:auto;"><button type="button" class="btn" onclick="delete_row_lesson(this,<?= $counter ?>);"><i class="icon-remove"></i></button></td>
<?php } else { ?>
<td style="margin-left:auto;margin-right:auto;"><button type="button" class="btn" onclick="change_row_lesson(this,<?= $counter ?>);"><i class="icon-remove"></i></button></td>
<?php } ?>
<td><?= $arr[0] ?><input type="hidden" name="lesson_date[]" value="<?= $arr[0] ?>"/></td>
<td><?= $arr[1] ?><input type="hidden" name="start_time[]" value="<?= $arr[1] ?>"/></td>
<td><?= $arr[2] ?><input type="hidden" name="end_time[]" value="<?= $arr[2] ?>"/></td>
<!-- new -->
<td>
<input type="text" value="<?= $arr[6] ?>" style="margin-left: 1px;margin-right: 1px;width: 85%" name="teaching_hour[]" autocomplete="off" class="required" 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))"/>
(Minutes)
</td>
<!-- new -->
<td><?= $arr[3] ?><input type="hidden" name="Room_id[]" value="<?= $arr[3] ?>"/></td>
<?php if (isset($_REQUEST['event_id'])) { ?><td style="display: none"><input type="hidden" id="lesson_id[<?= $counter ?>]" name="lesson_id[]" value="<?= $arr[4] ?>"/></td> <?php } ?>
<td style="width: 100px;text-align: left;">
<input type="hidden" name="invoice_gened[]" value="<?= (isset($arr["action"])) ? (($arr["action"] == "invoice_gened") ? "1" : "0") : "0" ?>"/>
<button <?= (isset($arr["action"])) ? ($arr["action"] == "invoice_gened") ? "disabled" : "" : "" ?> class="btn" id="btn_student_<?= $counter ?>" data-backdrop="static" data-toggle="modal" data-target="#student_modal_<?= $counter ?>" onclick="checkradio(<?= $counter ?>);"><i class="icon-user"></i> Student</button>
<!--new-->
<label id="student_label_0<?= $counter - 1 ?>"></label>
</td>
<td style="width: 100px;text-align: left;">
<input type="hidden" name="payroll_gened[]" value="<?= (isset($arr["action_p"])) ? (($arr["action_p"] == "payroll_gened") ? "1" : "0") : "0" ?>"/>
<button <?= (isset($arr["action_p"])) ? ($arr["action_p"] == "payroll_gened") ? "disabled" : "" : "" ?> id="student_btn" class="btn" data-backdrop="static" data-toggle="modal" data-target="#staff_modal_<?= $counter ?>" onclick="checkradio2(<?= $counter ?>);"><i class="icon-leaf" ></i> Teacher</button>
<!--new-->
<label id="staff_label_0<?= $counter - 1 ?>"></label>
</td>
<td style="display: none;"><input type="checkbox" name="hidden_checkbox[]" id="<?= $counter ?>_hidden_checkbox" value="<?= $arr[4] ?>"/></td>
</tr>
<?php } ?>
</tbody>
</table>
<hr/>
<a <?= !isset($_GET['event_id']) ? "style=\"display: none\"" : "" ?><?= isset($_GET['action']) ? "style=\"display:none;\"" : "" ?> href="#activity_modal" data-toggle="modal" data-backdrop="static" class="btn" ><i class="icon-plus"></i> Add Activity Here</a>
<hr/>
<?php require 'Event_DetailForm_AddActivity.php'; ?>
<input style="float: right" onclick="Submit_onclick();" type="submit" value="Save" name="<?php if (!isset($_REQUEST['event_id'])) { ?>Detail_Save<?php } else { ?>Detail_edit_Save<?php } ?>" class="btn btn-danger"/>
<input style="float: left;" type="button" id="btn_back" class="btn btn-danger" onclick="history.back();" value="Back"/>
<input type="hidden" id="sizeof_lesson" value="<?= $counter ?>"/>
<!--############################################################################################################################################################################-->
<?php
for ($i = 0; $i < sizeof($lesson_date) + 10; $i++) {
?>
<div class="modal modal-stu fade" id="student_modal_<?= $i + 1 ?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<!--<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>-->
<h4 class="modal-title" id="myModalLabel">Student List</h4>
</div>
<div class="modal-body">
<div id="1" style="margin: 0;padding: 5px 10px;background-color: #F7F7F7;border: 1px solid #E6E6E6;border-radius: 5px;box-shadow: 0 1px 2px rgba(0,0,0,.05);">
<table style="width: 100%">
<tr>
<!-- Search Student ID -->
<td><label>Student Name</label></td>
<td style="width: 15px;"></td>
<td>
<select name="student_name" id="student_name" class="student_name" >
<option></option>
<?php $sth = $dbh->query("SELECT root_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['id'] ?>,<?= $ResultSet['studentname'] ?>,<?= $ResultSet['ch_name'] ?>,<?= $ResultSet['root_id'] ?>"><?= $ResultSet['studentname'] ?> ( <?= $ResultSet['ch_name'] ?> )</option>
<?php } ?>
</select>
</td>
<td style="width: 20%"><label style="padding-top: 5px;padding-left: 5px;">Package Discount</label></td>
<td>
<div class="input-prepend" style="margin-bottom: 1px;">
<button class="btn" disabled>$</button>
<input type="text" id="pack[<?= ($i + 1) ?>]" style="width: 150px;" onafterpaste="this.value=this.value.replace(/[^\d]/g,'')" onkeyup="this.value = this.value.replace(/[^\d]/g, '')" value="0">
</div>
</td>
<?php if (isset($_GET['action'])) { ?>
<td style="width: 15px;"><label>For Makeup-class</label></td>
<td style="width: 15px;"></td>
<td>
<select class="stu_date" id="stu_date[<?= ($i + 1) ?>]">
<option></option>
</select>
</td>
<?php } ?>
</tr>
<tr>
<td><label class="radio inline" style="margin-left: 0px;">All lesson<input <?= isset($_GET['action']) ? "disabled" : "" ?> type="radio" value="1" name="All_lesson" id="lesson_All_<?= $i ?>"/></label></td>
<td style="width: 15px;"></td>
<td><label class="radio inline" style="margin-left: 30px;">Only one lesson<input type="radio" value="0" name="All_lesson" id="lesson_only_<?= $i ?>"/></label></td>
<td style="width: 80px;"></td>
<td colspan="5" style="margin-top: 10px;text-align: right;"><a href="#1" class="btn"id="btn_addstudent" onclick="adddate(<?= $i ?>,<?= $i + 1 ?>);"><i class="icon-plus" ></i>Add</a></td>
</tr>
</table>
</div>
<br/>
<table class="table table-striped table-bordered table-hover table-condensed" id="mytable">
<thead>
<tr>
<th style="width: 5%;"></th>
<th>Student</th>
<th style="width: 20%">Lesson State</th>
<th style="width: 20%">Package Discount</th>
<?php if (isset($_GET['action'])) { ?><th style="width: 30%">For Make-up</th><?php } ?>
</tr>
</thead>
<tbody id="student_table_<?= $i ?>" class="student_table">
<?php if (isset($_REQUEST['event_id']) && isset($lesson_date[$i])) { ?>
<?php $sth = $dbh->query("SELECT root_id,`New_stu_ID` id,`ch_name`,CONCAT(`last_name`,' ',`first_name`) name, lesson_id, stu_linking_id,state,package_discount,make_up_lesson_id 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 =" . $lesson_date[$i][4] . " ) and lesson_attendance.deleted =0 and lesson_attendance.actived =1") ?>
<?php $counter = 0; ?>
<?php while ($ResultSet = $sth->fetch(PDO::FETCH_ASSOC)) { ?>
<tr>
<td><button type="button" class="btn" onclick="delete_row_student(this,<?= $i ?>);"><i class="icon-remove"></i></button></td>
<td><?= $ResultSet['name'] ?> ( <?= $ResultSet['ch_name'] ?> )<br/> ID : <?= $ResultSet['id'] ?>
<input type="hidden" name="<?= $i ?>student_id[]" value="<?= $ResultSet['root_id'] ?>"/></td>
<td style="padding-top: 10px;">
<select disabled style="width: 100%;" name="lesson_state_<?= $i ?>[]">
<option <?= ($ResultSet['state'] == 1) ? "selected" : "" ?> value="1">Normal Class</option>
<option <?= ($ResultSet['state'] == 2) ? "selected" : "" ?> value="2">Make-up Class</option>
<option <?= ($ResultSet['state'] == 3) ? "selected" : "" ?> value="3">Need make up</option>
<option <?= ($ResultSet['state'] == 4) ? "selected" : "" ?> value="4">Cancel</option>
<option <?= ($ResultSet['state'] == 5) ? "selected" : "" ?> value="5">Had make up</option>
</select>
</td>
<td>
<div class="input-prepend" style="margin-bottom: 1px;">
<button class="btn" disabled>$</button>
<input type="text" name="<?= $i ?>package_discount[]" style="width: 150px;text-align: right;" value="<?= number_format($ResultSet['package_discount'], 2) ?>" onafterpaste="this.value=this.value.replace(/[^\d]/g,'')" onkeyup="this.value = this.value.replace(/[^\d]/g, '')">
</div>
</td>
<?php if (isset($_GET['action'])) { ?>
<td>
<?php
if (isset($ResultSet['make_up_lesson_id'])) {
$sth_date = $dbh->query("select `date` from lesson where actived = 1 and deleted = 0 and lesson_id = " . $ResultSet['make_up_lesson_id']);
$result_date = $sth_date->fetch(PDO::FETCH_ASSOC);
echo $result_date['date'];
} else {
echo'';
}
?>
<input type="hidden" name="<?= $i ?>for_make_lesson_date[]" value="<?= $ResultSet['make_up_lesson_id'] ?>"/>
</td>
<?php } ?>
</tr>
<?php } ?>
<?php } ?>
</tbody>
</table>
</div>
<div style="height: 10px;"></div>
<div class="modal-footer">
<button type="button" class="btn" data-dismiss="modal" >Back</button>
<button type="button" class="btn btn-danger" data-dismiss="modal" onclick="add_student_label();">Comfirm</button>
</div>
</div>
</div>
</div>
<?php } ?>
<!--############################################################################################################################################################################-->
<?php for ($i = 0; $i < sizeof($lesson_date) + 10; $i++) { ?>
<div class="modal fade" id="staff_modal_<?= $i + 1 ?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<!--<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>-->
<h4 class="modal-title" id="myModalLabel">Staff List</h4>
</div>
<div class="modal-body">
<div id="2" style="margin: 0;padding: 5px 10px;background-color: #F7F7F7;border: 1px solid #E6E6E6;border-radius: 5px;box-shadow: 0 1px 2px rgba(0,0,0,.05);">
<table style="width: 100%">
<tr>
<!-- Search Staff ID -->
<td style="text-align: center"><label>Staff Name</label></td>
<td style="width: 10px;"></td>
<td><select name="staff_name" id="staff_name" class="staff_name" style="width: 200px;">
<option></option>
<?php $sth = $dbh->query("SELECT CONCAT(`last_name`,' ',`first_name`) staffname, `ch_name` , `root_id` FROM `staff` WHERE `actived`=1 and `deleted`=0 group by root_id"); ?>
<?php while ($ResultSet = $sth->fetch(PDO::FETCH_ASSOC)) { ?>
<option value="<?= $ResultSet['staffname'] ?>,<?= $ResultSet['ch_name'] ?>,<?= $ResultSet['root_id'] ?>" ><?= $ResultSet['staffname'] ?> ( <?= $ResultSet['ch_name'] ?> ) </option>
<?php } ?>
</select></td>
<td style="width: 10px;"></td>
<td><select id="Rate_staff_<?= $i ?>" name="Rate_staff" style="margin-top: 10px; width: 200px;">
<option value="Rate 0 0">Monthly</option>
<option value="Rate 0 1">Monthly ( Substitute )</option>
<option value="Rate 1 0">Teacher ( In House ) </option>
<option value="Rate 1 1">Teacher ( In House ) ( Substitute ) </option>
<option value="Rate 2 0">Teacher ( Outside School )</option>
<option value="Rate 2 1">Teacher ( Outside School ) ( Substitute ) </option>
<option value="Rate 3 0">Teacher Assistant ( In House ) </option>
<option value="Rate 3 1">Teacher Assistant ( In House ) ( Substitute ) </option>
<option value="Rate 4 0">Teacher Assistant ( Outside School )</option>
<option value="Rate 4 1">Teacher Assistant ( Outside School ) ( Substitute ) </option>
<option value="Rate 5 0">Traveling</option>
<option value="Rate 5 1">Traveling ( Substitute ) </option>
<option value="Rate 6 0">Other</option>
<option value="Rate 6 1">Other ( Substitute ) </option>
</select></td>
<!-- Add button -->
</tr>
<tr>
<td><label class="radio inline" style="margin-left: 0px;">All lesson<input type="radio" value="1" name="All_lesson" id="staff_lesson_All_<?= $i ?>"/></label></td>
<td style="width: 15px;"></td>
<td><label class="radio inline" style="margin-left: 30px;">Only one lesson<input type="radio" value="0" name="All_lesson" id="staff_lesson_only_<?= $i ?>"/></label></td>
<td></td>
<td style="float: right;margin-top: 10px;"><a href="#2" class="btn" id="btn_addstudent" onclick="adddate_staff(<?= $i ?>,<?= $i + 1 ?>);"><i class="icon-plus" ></i>Add</a></td>
</tr>
</table>
</div>
<br/>
<table class="table table-striped table-bordered table-hover table-condensed" id="mytable">
<thead>
<tr>
<th style="width: 20px"></th>
<th style="width: 200px">Staff Name</th>
<th>Rate</th>
</tr>
</thead>
<tbody id="staff_table_<?= $i ?>">
<?php if (isset($_REQUEST['event_id']) && isset($lesson_date[$i])) { ?>
<?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 = " . $lesson_date[$i][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)) { ?>
<tr>
<td><button type="button" class="btn" onclick="delete_row_staff(this,<?= $i ?>);"><i class="icon-remove"></i></button></td>
<td><?= $ResultSet['name'] ?> ( <?= $ResultSet['ch_name'] ?> )</td>
<td><?= $staffrate[(int) $ResultSet['rate_type']] ?><?= ($ResultSet['is_substitute'] == 1) ? " ( Substitute ) " : "" ?>
<input type="hidden" name="<?= $i ?>staff_id[]" value="<?= $ResultSet['staff_id'] ?>"/>
<input type="hidden" name="<?= $i ?>staff_rate[]" value="<?= (int) $ResultSet['rate_type'] ?>"/>
<input type="hidden" name="<?= $i ?>Substitute[]" value="<?= (int) $ResultSet['is_substitute'] ?>"/>
</td>
</tr>
<?php } ?>
<?php } ?>
</tbody>
</table>
</div>
<div style="height: 10px;"></div>
<div class="modal-footer">
<button type="button" class="btn" data-dismiss="modal">Back</button>
<button type="button" class="btn btn-danger" data-dismiss="modal" onclick="add_staff_label();">Confirm</button>
</div>
</div>
</div>
</div>
<?php } ?>
</form>
</div> <!-- /container -->
</body>
</html>