This repository has been archived by the owner on May 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
overdue.php
190 lines (153 loc) · 4.99 KB
/
overdue.php
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<?php
session_start();
if(!isset($_SESSION['loggedin'])){
header('Location: login.php');
exit();
}
if ($_SESSION['username'] != 'administrator'){
header('Location: index.php?adminonly=1');
}
?>
<!DOCTYPE html>
<html>
<?php
include('header.php')
?>
<body class="form-v8 loggedin" id="fade">
<div id="loader">
<div class="loader"><div></div><div></div><div></div><div></div></div>
</div>
<?php
include('adminNavbar.php');
include('serverconnect.php');
?>
<div class="content">
<div style="height: 63px; opacity: 0; padding: 0; margin: 0" ></div>
<div id="sentAlert" style="color: red;" class="name">Notification & Email sent to the user</div>
<div style="padding-top: 0;">
<h2 style="padding-bottom: 10px; margin-bottom: 20px">Overdue</h2>
<?php $results = mysqli_query($db, "SELECT * FROM EqManage.equipment inner join EqManage.categories on equipment.category = categories.id"); ?>
<table width="100%" id="table">
<thead>
<tr>
<th scope="col">User ID</th>
<th scope="col">Equipment</th>
<th scope="col">Qty</th>
<th scope="col">Note</th>
<th scope="col">Check Out Date</th>
<th scope="col">Expected Return Date</th>
<th scope="col">Request ID</th>
<th scope="col">Notify</th>
<th scope="col">Return</th>
</tr>
</thead>
<tbody id="table2">
<?php include('fetchOverdueTable.php') ?>
</tbody>
</table>
</div>
</div>
<div id="returnModal2" class="modal" style="display: none">
<!-- Modal content -->
<div class="modal-content" style="min-width: 600px; width: fit-content">
<div onclick="closeModal()"><span class="close" data-dismiss="modal" onclick="closeModal()" style="float: left; margin-bottom: 10px">×</span></div>
<div class="select-style" style="width:80%; margin: auto;" align="center">
<div id="overdueReturnDiv">
<?php include('overdueReturn.php') ?>
</div>
</div>
</div>
</div>
<?php
if ($_SESSION['username'] == 'administrator'){
include ('adminModal.php');
}
?>
<script>
var sentAlert = document.getElementById("sentAlert");
sentAlert.style.display = "none";
function loadTable(){
$("#table2").load("fetchOverdueTable.php");
}
setInterval(function () {
loadTable();
},1500);
$('#returnEqSelect').val('20');
$('#returnStudentSelect').val('2');
$('#returnSelect').val('102');
//
//
// var returnbtn = document.getElementById("confirmReturnBtn");
//
// // Get the <span> element that closes the modal
var returnspan2 = document.getElementsByClassName("close")[0];
var returnmodal2 = document.getElementById("returnModal2");
// // When the user clicks on the button, open the modal
// returnbtn.onclick = function() {
// returnmodal.style.display = "block";
// };
returnspan2.onclick = function() {
returnmodal2.style.display = "none";
}
function closeModal() {
console.log("test");
returnmodal2.style.display = "none";
}
function confirmReturn(id){
$.ajax({
url: "overdueReturn.php",
type: "POST",
async: false,
data: {
"id": id
},
success:function (data) {
$("#overdueReturnDiv").html(data);
var returnmodal2 = document.getElementById("returnModal2");
returnmodal2.style.display = "block";
}
})
}
function overdueReturn(id) {
document.getElementById("overdueReturn").setAttribute("value", "...");
$.ajax({
url: "adminReturn.php",
type: "POST",
async: false,
data: {
"rqID": id,
},
success: function (data) {
console.log(data);
setTimeout(() => {
document.getElementById("overdueReturn").setAttribute("value", "Return successful");
}, 1000);
setTimeout(() => {
$("#table2").load("fetchOverdueTable.php");
var returnmodal2 = document.getElementById("returnModal2");
returnmodal2.style.display = "none";
console.log("reloaded");
}, 2000);
// pipe(eqID,userID,checkoutID)
}
});
}
function showMessage() {
waitAlert.style.display = "block";
}
function notifyOverdue(id) {
$.ajax({
url: "notifyOverdue.php",
type: "POST",
async: false,
data: {
"notify": 1,
"id":id
},
success: function (data) {
console.log(data);
sentAlert.style.display = "block";
}
});
}
</script>