forked from Jmurrietasmith/EqManage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetchTodayCheckout.php
57 lines (48 loc) · 1.48 KB
/
fetchTodayCheckout.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
<?php
session_start();
if(!isset($_SESSION['loggedin'])){
header('Location: login.php');
exit();
}
if ($_SESSION['username'] != 'administrator'){
header('Location: index.php?adminonly=1');
}
include('serverconnect.php');
$query = mysqli_query($db, "Select * from EqManage.log");
$query2 = mysqli_query($db, "Select * from EqManage.requests");
$today = date("Y-m-d H:i:s");
$todayExplode = explode(" ", $today);
//echo $todayExplode[0];
$monthago = date('Y-m-d', strtotime('now - 1 month'));
//echo $monthago;
$overdue = 0;
$checkoutToday = 0;
$pendingRQ = 0;
$checkoutMonth = 0;
// echo $today;
while ($row = mysqli_fetch_array($query)) {
$returnDate = $row['expectedReturnDate'];
$checkoutDate = $row['checkoutDate'];
$checkoutDateExplode = explode(" ", $checkoutDate);
// echo "<p>'$returnDate'</p>";
if (strtotime($returnDate) < strtotime($today)) {
$overdue++;
}
if (strtotime($checkoutDateExplode[0]) == strtotime($todayExplode[0])) {
$checkoutToday++;
}
if (strtotime($checkoutDateExplode[0]) >= strtotime($monthago)) {
$checkoutMonth++;
}
};
while ($row = mysqli_fetch_array($query2)) {
$state = $row['state'];
if ($state == null) {
$pendingRQ++;
}
}
//echo "Overdue: ", $overdue;
//echo " Checked out today: ", $checkoutToday;
//echo " Pending requests: ", $pendingRQ;
//echo " Checked out this month", $checkoutMonth;
echo "<h3 class=\"card-title\">",$checkoutToday,"</h3>";