-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreset_locker_check.php
69 lines (51 loc) · 2.27 KB
/
reset_locker_check.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
<?php
// Include the database connection
include 'password.php';
include 'db.php';
include 'templates/header.php';
// Check if the user is logged in
if (isset($_COOKIE['logged_in_' . DB_NAME]) && $_COOKIE['logged_in_' . DB_NAME] == 'true') {
header('Location: login.php');
exit;
}
$db = get_db_connection();
// Initialize variables for feedback
$message = "";
$rows_updated = 0;
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['ignore_recent_checks'])) {
// SQL statement to update ignore_check to true for checks within the last 6 days
$sql = "UPDATE checks SET ignore_check = true WHERE check_date >= NOW() - INTERVAL 6 DAY";
$stmt = $db->prepare($sql);
$stmt->execute();
$rows_updated = $stmt->rowCount();
$message = "Updated $rows_updated rows to ignore recent checks.";
} elseif (isset($_POST['reset_ignore_recent_checks'])) {
// SQL statement to reset ignore_check to false for checks within the last 6 days
$sql = "UPDATE checks SET ignore_check = false WHERE check_date >= NOW() - INTERVAL 6 DAY";
$stmt = $db->prepare($sql);
$stmt->execute();
$rows_updated = $stmt->rowCount();
$message = "Reset ignore recent checks for $rows_updated rows.";
}
}
?>
<h1>Reset Locker Checks</h1>
<h2>This page allows you to ignore recent checks so that the main page will show all lockers as red.</h2>
<h2>This can be useful if locker checks have been completed during the week</h2>
<h3>You can either choose to ignore all checks performed within the last 6 days, or reset this status.</h3>
<form method="POST" action="">
<div class="button-container" style="margin-top: 20px;">
<button type="submit" name="ignore_recent_checks" class="button touch-button">Ignore Recent Checks</button>
<button type="submit" name="reset_ignore_recent_checks" class="button touch-button">Reset Ignore Recent Checks</button>
</div>
</form>
<?php if (!empty($message)): ?>
<p><?php echo htmlspecialchars($message); ?></p>
<?php endif; ?>
<div class="button-container" style="margin-top: 20px;">
<a href="admin.php" class="button touch-button">Admin Page</a>
</div>
<?php include 'templates/footer.php'; ?>
</body>
</html>