1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
<?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); ?>
|