| 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/LeaveApplication/delete/ |
Upload File : |
<?php
include_once '../../include/DBConnect.php';
include '../CheckFollowUpAction.php';
$Leave_Assistant = new LeaveAssistant($dbh);
if ($_POST) {
$score = $_POST['Data'];
$UpdateLeaveRecordID = $_POST['Data'];
$Target = $_POST['Target'];
$query = "SELECT `lesson_id` FROM `leave_lesson` WHERE `leave_id` = '$UpdateLeaveRecordID'";
$result = $dbh->prepare($query);
$result->execute();
$Related_Lesson_IDs = $result->fetchAll();
// while ($ResultSet = $result->fetch(PDO::FETCH_ASSOC)) {
foreach ($Related_Lesson_IDs as $RLID) {
$UpdateLesson_ID = $RLID['lesson_id'];
$Leave_Assistant->undoOneLesson($UpdateLesson_ID);
}
#### Final Checking of attendance, after delete leave record ####
foreach ($Related_Lesson_IDs as $RLID) {
$checking_lesson_id = $RLID['lesson_id'];
if ($Target > 0 && $Target != NULL) {
$Leave_Assistant->UpdateLessonStateForStudent($checking_lesson_id, $Target);
## UpDate student attendance record ##
$query = "UPDATE `lesson_attendance` SET `attendance`=2 WHERE `actived`=1 and `deleted`=0 and `stu_linking_id`='$Target'
and `lesson_id`='$checking_lesson_id'";
$sth = $dbh->prepare($query);
$sth->execute();
} else {
## Update attendance(state = 1) where student have not leave record ##
$Leave_Assistant->UpdateLessonStateNoOtherLeave($checking_lesson_id);
## UpDate staff attendance record ##
$query = "UPDATE `lesson_attendance` SET `attendance`=2 WHERE `staff_id` >0 and `actived`=1 and `deleted`=0 and
`lesson_id`='$checking_lesson_id' and `staff_id`=(SELECT `staff_id` FROM `leave_app` WHERE `actived`=1 and
`deleted`=0 and `staff_id`>0 and `leave_id`='$UpdateLeaveRecordID')";
$sth = $dbh->prepare($query);
$sth->execute();
}
}
$deleted = 1;
$sth = $dbh->prepare("UPDATE `leave_app` SET `deleted`= '$deleted' WHERE `leave_id` = '$UpdateLeaveRecordID'");
$sth->execute();
// }
if ($sth)
$message = "1 record UPDATED";
else
$message = "Error";
$Array = array(
"1" => $message,
"2" => $score * 2,
"3" => $score * 3,
"4" => $score * 4,
"5" => $UpdateLeaveRecordID
);
$Arrays[] = $Array;
}
echo json_encode($Arrays);
?>