-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
393 lines (321 loc) · 13.4 KB
/
Copy pathindex.php
File metadata and controls
393 lines (321 loc) · 13.4 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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
<?php
function isMobileDevice() {
$ua = strtolower($_SERVER['HTTP_USER_AGENT'] ?? '');
return preg_match('/android|iphone|ipad|ipod|blackberry|windows phone|mobile/i', $ua);
}
if (isMobileDevice()) {
header("Location: nohref.php");
exit;
}
session_start();
require "config.php"; // ✅ FIX 1: PDO now exists
/* Total Students */
$totalStudents = $pdo->query("SELECT COUNT(*) FROM students")->fetchColumn();
/* Total Teachers */
$totalTeachers = $pdo->query("
SELECT COUNT(*) FROM users WHERE role = 'teacher'
")->fetchColumn();
/* Total Admins */
$totalAdmins = $pdo->query("
SELECT COUNT(*) FROM users WHERE role = 'admin'
")->fetchColumn();
/* Dismissed Students */
$dismissedStudents = $pdo->query("
SELECT COUNT(*) FROM students WHERE status = 'dismissed'
")->fetchColumn();
/* Total Users */
$totalUsers = $pdo->query("
SELECT COUNT(*) FROM users
")->fetchColumn();
/* -----------------------------------
ROLE-BASED REDIRECT (CLEAN)
------------------------------------ */
if (isset($_SESSION['id'], $_SESSION['role'])) {
if ($_SESSION['role'] === 'student') {
header("Location: student_dashboard.php");
exit;
}
if ($_SESSION['role'] === 'teacher') {
header("Location: teacher_dashboard.php");
exit;
}
}
/* Build user array */
$user = null;
if (isset($_SESSION["id"])) {
$user = [
"id" => $_SESSION["id"],
"full_name" => $_SESSION["fullname"],
"role" => $_SESSION["role"]
];
}
/* Popup only if logged out */
if (!$user) {
echo "<script>
window.onload = function() {
const popup = document.getElementById('welcomePopup');
const content = document.getElementById('pageContent');
if (popup) popup.style.display = 'flex';
if (content) content.classList.add('blurred');
};
</script>";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>School Management System</title>
<link rel="stylesheet" href="indext.css">
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
<style>
@media (max-width: 768px) {
body::before {
content: "🚫 This system is not accessible on mobile devices. Please use a desktop or laptop.";
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
font-size: 18px;
font-weight: bold;
text-align: center;
background: #fff;
color: #000;
padding: 20px;
}
body * {
display: none !important;
}
}
</style>
<script>
(function () {
const isMobileScreen = () => {
return (
/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i
.test(navigator.userAgent)
|| Math.min(screen.width, screen.height) < 768
);
};
if (isMobileScreen()) {
window.location.replace("nohref.php");
}
})();
</script>
</head>
<body>
<!-- POPUP WELCOME MESSAGE -->
<div class="popup" id="welcomePopup" style="display:none;">
<div class="popup-box">
<img src="logo.jpeg" class="logome">
<h2>👋 Welcome to PIEDELITE</h2>
<p>Next is Login to proceed and access your dashboard.</p>
<button onclick="openLogin()">Continue</button>
</div>
</div>
<!-- LOGIN POPUP -->
<div class="login-popup" id="loginPopup" style="display:none;">
<div class="login-box">
<h2>🔐 Login</h2>
<input type="text" id="loginUser" placeholder="Enter Username">
<input type="password" id="loginPass" placeholder="Enter Password">
<button id="loginBtn">Login</button>
</div>
</div>
<!-- ALL PAGE CONTENT (BLURS UNTIL LOGIN COMPLETE) -->
<div id="pageContent">
<!-- Sidebar -->
<aside class="sidebar slide-left">
<div class="sidebar-header">
<h2>PIEDELITE</h2>
</div>
<ul class="sidebar-menu">
<!-- USER PROFILE BOX -->
<div class="user-profile">
<img src="profile.jpg" alt="User" class="profile-img">
<h3 class="profile-name">
<?= $user ? htmlspecialchars($user['full_name']) : ""; ?>
</h3>
<p class="profile-role">
<?= $user ? strtoupper(htmlspecialchars($user['role'])) : ""; ?>
</p>
</div>
<?php if ($user && $user['role'] === 'admin'): ?>
<li><a href="create_user.php"><span>🏠</span> Create Users</a></li>
<?php endif; ?>
<li><a href="notices_admin.php"><span>📢</span> Notice Board</a></li>
<li><a href="admin_send_message.php"><span>💬</span> Messages</a></li>
<li><a href="student.php"><span>👨🎓</span> Students List</a></li>
<li><a href="teacher.php"><span>👨🎓</span> Teachers List</a></li>
<li><a href="users.php"><span>👥</span> All Users</a></li>
<li><a href="admin_view_department.php"><span>🏫</span> Departments</a></li>
<li><a href="admin_view_registration.php"><span>🏫</span> Registrations</a></li>
<li><a href="admin_view_attendance.php"><span>🏫</span> Attendance</a></li>
<li><a href="admin_notice_read.php"><span>🏫</span> Notice Read</a></li>
<li><a href="admin_view_level.php"><span>📊</span> Levels</a></li>
<li><a href="admin_view_courses.php"><span>📚</span> Courses</a></li>
<li><a href="admin_view_subjects.php"><span>📘</span> Subjects</a></li>
<li><a href="admin_view_assignment.php"><span>📝</span> Assignments</a></li>
<li><a href="admin_view_exams.php"><span>🧪</span> Exams</a></li>
<li><a href="admin_create_timetable.php"><span>🧪</span> Timetable</a></li>
<li><a href="admin_upload_resources.php"><span>📂</span> Course Resources</a></li>
<li><a href="payments/list.php"><span>💳</span> Payments</a></li>
<li></li>
<li></li>
<?php if (!$user): ?>
<li><a href="#" onclick="openLogin()"><span>🔐</span> Login</a></li>
<?php endif; ?>
</ul>
</aside>
<!-- Main Content -->
<main class="content fade-in">
<!-- Top Welcome Bar -->
<div class="top-bar slide-down">
<span>👋 Welcome,
<strong><?= $user ? htmlspecialchars($user['full_name']) : "Guest"; ?></strong>
</span>
<span class="admin-badge">
<?= $user ? strtoupper(htmlspecialchars($user['role'])) : "VISITOR"; ?>
</span>
<strong><span id="clock"></span></strong>
<?php if ($user): ?>
<button class="logout-btn" onclick="logoutUser()">Logout</button>
<?php endif; ?>
</div>
<!-- Header -->
<header class="header">
<h1>PIEDELITE</h1>
</header>
<!-- Hero Section -->
<section class="hero slide-up">
<div class="hero-text">
<h2>EXCELLENT, LEARNING, INNOVATIVE, TIME-BOUND AND EDUCATIONAL ADMINISTRATION</h2>
<p>Manage students, staff, results, assignments, academic records, and digital resources in one centralized platform.</p>
<?php if (!$user): ?>
<a href="#" onclick="openLogin()" class="cta-btn">Login to Continue</a>
<?php endif; ?>
</div>
</section>
<!-- Stats Section -->
<section class="stats-section slide-up">
<div class="stats-grid">
<div class="stat-card">
<i class="fa-solid fa-users icon"></i>
<div class="stat-info">
<h3>Enrolled Students</h3>
<span class="stat-number"><?= number_format($totalStudents) ?></span>
</div>
</div>
<div class="stat-card">
<i class="fa-solid fa-chalkboard-user icon"></i>
<div class="stat-info">
<h3>Active Teachers</h3>
<span class="stat-number"><?= number_format($totalTeachers) ?></span>
</div>
</div>
<div class="stat-card">
<i class="fa-solid fa-user-tie icon"></i>
<div class="stat-info">
<h3>System Admins</h3>
<span class="stat-number"><?= number_format($totalAdmins) ?></span>
</div>
</div>
<div class="stat-card">
<i class="fa-solid fa-user-slash icon"></i>
<div class="stat-info">
<h3>Dismissed Students</h3>
<span class="stat-number"><?= number_format($dismissedStudents) ?></span>
</div>
</div>
<div class="stat-card">
<i class="fa-solid fa-users-gear icon"></i>
<div class="stat-info">
<h3>ALL login Accounts</h3>
<span class="stat-number"><?= number_format($totalUsers) ?></span>
</div>
</div>
</div>
</section>
<!-- Features Section -->
<section class="features">
<h2>Main Features</h2>
<div class="features-grid slide-up">
<div class="feature-card slide-up">
<h3>📘 Digital Library</h3>
<p>Download books and course materials instantly.</p>
</div>
<div class="feature-card slide-up">
<h3>📑 PDF Repository</h3>
<p>Access all student and academic documents.</p>
</div>
<div class="feature-card slide-up">
<h3>📝 Assignments</h3>
<p>View, submit, and track assignment progress.</p>
</div>
<div class="feature-card slide-up">
<h3>🗓 Academic Calendar</h3>
<p>Stay updated with important school events.</p>
</div>
<div class="feature-card slide-up">
<h3>📬 Messaging System</h3>
<p>Communicate with staff & students.</p>
</div>
<div class="feature-card slide-up">
<h3>📢 Notice Board</h3>
<p>Receive important updates and announcements.</p>
</div>
</div>
</section>
<!-- PAYMENT SECTION -->
<section class="payment-section slide-up">
<h2>Payment Methods</h2>
<div class="payment-grid">
<div class="payment-card">
<h3>💳 Card Payment</h3>
<p>Pay using Visa, Mastercard, or Mobile Money cards securely.</p>
<button class="pay-btn">Proceed</button>
</div>
<div class="payment-card">
<h3>📱 Mobile Money</h3>
<p>MTN, Vodafone, AirtelTigo mobile payments supported.</p>
<button class="pay-btn">Proceed</button>
</div>
<div class="payment-card">
<h3>🏦 Bank Transfer</h3>
<p>Use direct bank deposit or transfer for fee payments.</p>
<button class="pay-btn">View Details</button>
</div>
</div>
</section>
<script>
const schoolStats = {
students: <?= (int)$totalStudents ?>,
teachers: <?= (int)$totalTeachers ?>,
admins: <?= (int)$totalAdmins ?>,
dismissed: <?= (int)$dismissedStudents ?>,
users: <?= (int)$totalUsers ?>
};
</script>
<!-- CHART SECTION -->
<section class="chart-section slide-up">
<h2 class="chart-title">School Record Overview</h2>
<div class="chart-card">
<canvas id="schoolChart"></canvas>
</div>
</section>
<!-- Footer -->
<footer>
<p>© 2025 Tertiary School Management System. All rights reserved.</p>
</footer>
</main>
</div> <!-- END pageContent -->
<!-- WHATSAPP FLOAT CHAT -->
<a href="https://wa.me/233537587242" class="whatsapp-float" target="_blank">💬</a>
<script>
window.userLoggedIn = <?= json_encode(!!$user); ?>;
</script>
<script src="index.js"></script>
</body>
</html>