-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview_notices.php
More file actions
155 lines (137 loc) · 4.41 KB
/
view_notices.php
File metadata and controls
155 lines (137 loc) · 4.41 KB
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
<?php
session_start();
// Check if fname and lname are set in the session
if (!isset($_SESSION['fname']) || !isset($_SESSION['lname'])) {
header("Location: login.php");
exit();
}
// Database connection
$conn = new mysqli("localhost", "root", "", "erp");
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Filtering logic
$filter = '';
$whereClause = '';
if (isset($_GET['filter']) && ($_GET['filter'] === 'Teacher' || $_GET['filter'] === 'Admin')) {
$filter = $_GET['filter'];
$whereClause = "WHERE status = '$filter'";
}
// Fetch notices
$sql = "SELECT fname, lname, status, topic, content, date_time FROM notices $whereClause ORDER BY date_time DESC";
$result = $conn->query($sql);
$conn->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>::: Notices :::</title>
<style>
/* Frutiger Aero Styling */
body {
font-family: 'Segoe UI', Tahoma, sans-serif;
background: url("notices.png");
background-size: cover;
background-position: center;
background-repeat: no-repeat;
background-attachment: fixed;
color: #333;
margin: 0;
padding: 0;
}
h1 {
text-align: center;
color: #0078D7;
text-shadow: 1px 1px 5px rgba(0, 0, 0, 0.2);
margin-top: 20px;
}
form {
text-align: center;
margin: 20px 0;
}
form label {
font-weight: bold;
color: #246b9c;
}
form select {
padding: 8px;
border: 1px solid #bcd4e6;
border-radius: 8px;
background-color: white;
font-size: 16px;
color: #246b9c;
outline: none;
}
.notices-container {
display: flex;
flex-direction: column; /* Stack items vertically */
align-items: center; /* Center the cards horizontally */
gap: 20px; /* Space between the cards */
padding: 20px;
}
.notice-card {
background: white;
border-radius: 12px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
width: 90%; /* Take up most of the width for a vertical layout */
max-width: 500px;
padding: 20px;
display: flex;
flex-direction: column;
}
.notice-card h3 {
margin: 0;
color: #4fa3d5;
font-size: 20px;
}
.notice-card .meta {
font-size: 14px;
color: #777;
margin: 5px 0 15px;
}
.notice-card p {
font-size: 16px;
margin: 0;
color: #333;
}
.no-notices {
text-align: center;
font-size: 18px;
color: #dc3545;
padding: 20px;
}
</style>
</head>
<body>
<br>
<br>
<h1>Notices</h1>
<form method="GET" action="">
<label for="filter">Filter by:</label>
<select name="filter" id="filter" onchange="this.form.submit()">
<option value="">All</option>
<option value="Teacher" <?= $filter === 'Teacher' ? 'selected' : '' ?>>Teacher</option>
<option value="Admin" <?= $filter === 'Admin' ? 'selected' : '' ?>>Admin</option>
</select>
</form>
<div class="notices-container">
<?php if ($result->num_rows > 0): ?>
<?php while ($row = $result->fetch_assoc()): ?>
<div class="notice-card">
<h3><?= htmlspecialchars($row['topic']) ?></h3>
<div class="meta">
By <?= htmlspecialchars($row['fname'] . ' ' . $row['lname']) ?> (<?= htmlspecialchars($row['status']) ?>) <br>
<?= htmlspecialchars($row['date_time']) ?>
</div>
<p><?= nl2br(htmlspecialchars($row['content'])) ?></p>
</div>
<?php endwhile; ?>
<?php else: ?>
<p class="no-notices">No notices found.</p>
<?php endif; ?>
</div>
</body>
</html>