-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudentdashboard.php
More file actions
490 lines (427 loc) · 15.3 KB
/
studentdashboard.php
File metadata and controls
490 lines (427 loc) · 15.3 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
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
<?php
header('Content-Type: text/html; charset=UTF-8');
session_start();
require_once 'db_connect.php';
require_once 'session_helper.php';
requireStudent();
$user = getLoggedInUser();
$student_email = $user['email'];
$student_name = $user['name'];
$grade = $user['grade'];
$division = $user['division'];
$roll_no = $user['roll_no'];
$institute_id = $user['institute_id'];
$first_name = explode(' ', $student_name)[0];
// Attendance %
$att_q = mysqli_query($conn, "SELECT COUNT(*) as total, SUM(status='Present') as present FROM attendance WHERE student_email='$student_email' AND institute_id='$institute_id'");
$att = mysqli_fetch_assoc($att_q);
$total_classes = $att['total'] ?? 0;
$present = $att['present'] ?? 0;
$att_percent = $total_classes > 0 ? round(($present / $total_classes) * 100) : 0;
// Fees
$fees_q = mysqli_query($conn, "SELECT total_fees, paid_amount, pending_amount FROM fees WHERE student_email='$student_email' AND institute_id='$institute_id' ORDER BY created_at DESC LIMIT 1");
$fees = mysqli_fetch_assoc($fees_q);
// Today's Schedule
$today = date('l');
$schedule_q = mysqli_query($conn, "SELECT subject, time_from, time_to, teacher_email FROM schedule WHERE grade='$grade' AND division='$division' AND day_name='$today' AND institute_id='$institute_id' ORDER BY time_from ASC");
// Recent Notices
$notices_q = mysqli_query($conn, "SELECT title, message, date FROM notices WHERE (grade='$grade' OR grade IS NULL) AND institute_id='$institute_id' ORDER BY created_at DESC LIMIT 3");
// Language selection check
$lang_trigger_q = mysqli_query($conn, "SELECT id FROM language_selection WHERE student_email='$student_email' AND institute_id='$institute_id'");
$lang_already_selected = mysqli_num_rows($lang_trigger_q) > 0;
$show_language_btn = false;
if ($grade == 7 && !$lang_already_selected) {
$show_language_btn = true;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Student Dashboard</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f5f5f5;
}
/* Header */
.header {
background-color: #2c3e50;
height: 70px;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 30px;
color: white;
}
.header h1 {
font-size: 24px;
}
.user-section {
display: flex;
flex-direction: column;
align-items: flex-end;
}
.user-name {
font-size: 16px;
margin-bottom: 5px;
}
.logout-btn {
background-color: #e74c3c;
color: white;
border: none;
padding: 8px 24px;
border-radius: 5px;
cursor: pointer;
font-weight: bold;
font-size: 12px;
transition: background-color 0.3s;
}
.logout-btn:hover {
background-color: #c0392b;
}
/* Main Container */
.container {
display: flex;
min-height: calc(100vh - 70px);
}
/* Sidebar */
.sidebar {
width: 250px;
background-color: #ecf0f1;
padding: 20px 10px;
}
.menu-item {
background-color: #95a5a6;
color: white;
padding: 15px 20px;
margin-bottom: 10px;
border-radius: 8px;
cursor: pointer;
font-size: 16px;
transition: all 0.3s;
display: flex;
align-items: center;
gap: 10px;
text-decoration: none;
}
.menu-item:hover {
background-color: #7f8c8d;
transform: translateX(5px);
}
.menu-item.active {
background-color: #3498db;
}
/* Main Content */
.main-content {
flex: 1;
padding: 30px;
background-color: white;
}
.welcome-section h2 {
color: #2c3e50;
font-size: 28px;
margin-bottom: 10px;
}
.welcome-section p {
color: #7f8c8d;
font-size: 16px;
margin-bottom: 35px;
}
/* Stats Cards */
.stats-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
gap: 30px;
margin-bottom: 50px;
}
.stat-card {
border-radius: 10px;
padding: 30px;
color: white;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
transition: transform 0.3s;
}
.stat-card:hover {
transform: translateY(-5px);
}
.stat-card.attendance {
background-color: #3498db;
}
.stat-card.marks {
background-color: #27ae60;
}
.stat-card.fees {
background-color: #e67e22;
}
.stat-card h3 {
font-size: 20px;
margin-bottom: 20px;
}
.stat-value {
font-size: 48px;
font-weight: bold;
margin-bottom: 10px;
}
.stat-detail {
font-size: 14px;
opacity: 0.9;
}
/* Schedule Section */
.schedule-section {
margin-bottom: 40px;
}
.schedule-section h3 {
color: #2c3e50;
font-size: 22px;
margin-bottom: 20px;
}
.schedule-table {
width: 100%;
border-collapse: collapse;
background-color: white;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
border-radius: 5px;
overflow: hidden;
}
.schedule-table thead {
background-color: #ecf0f1;
}
.schedule-table th {
padding: 15px;
text-align: left;
color: #2c3e50;
font-weight: bold;
font-size: 14px;
}
.schedule-table td {
padding: 15px;
border-top: 1px solid #bdc3c7;
color: #34495e;
font-size: 14px;
}
.schedule-table tbody tr {
transition: background-color 0.2s;
}
.schedule-table tbody tr:hover {
background-color: #f8f9fa;
}
/* Notices Section */
.notices-section h3 {
color: #2c3e50;
font-size: 22px;
margin-bottom: 15px;
}
.notice-box {
background-color: #fff3cd;
border: 2px solid #ffc107;
border-radius: 5px;
padding: 15px;
color: #856404;
font-size: 14px;
margin-bottom: 10px;
}
/* Info card for unassigned division/roll */
.info-card {
background: #e3f2fd;
border-left: 4px solid #2196f3;
padding: 12px 15px;
border-radius: 6px;
margin-bottom: 20px;
font-size: 14px;
color: #1565c0;
}
/* Language selection button */
.lang-btn {
background: linear-gradient(135deg, #667eea, #764ba2);
color: white;
border: none;
padding: 12px 25px;
border-radius: 8px;
cursor: pointer;
font-size: 15px;
font-weight: bold;
margin-bottom: 20px;
display: inline-block;
text-decoration: none;
animation: pulse 2s infinite;
}
@keyframes pulse {
0%, 100% { box-shadow: 0 0 0 0 rgba(102,126,234,0.4); }
50% { box-shadow: 0 0 0 10px rgba(102,126,234,0); }
}
/* Responsive Design */
@media (max-width: 768px) {
.container {
flex-direction: column;
}
.sidebar {
width: 100%;
}
.stats-grid {
grid-template-columns: 1fr;
}
.header {
padding: 0 15px;
}
.header h1 {
font-size: 18px;
}
.main-content {
padding: 15px;
}
}
</style>
</head>
<body>
<!-- Header -->
<div class="header">
<h1>Student Dashboard</h1>
<div class="user-section">
<div class="user-name"><?php echo htmlspecialchars($student_name); ?></div>
<button class="logout-btn" onclick="window.location.href='logout.php'">Logout</button>
</div>
</div>
<!-- Main Container -->
<div class="container">
<!-- Sidebar -->
<div class="sidebar">
<a href="studentdashboard.php" class="menu-item active">
<span>🏠</span><span>Home</span>
</a>
<a href="studentattendancepage.php" class="menu-item">
<span>📊</span><span>View Attendance</span>
</a>
<a href="studentmarkspage.php" class="menu-item">
<span>📝</span><span>View Marks</span>
</a>
<a href="#" class="menu-item">
<span>💰</span><span>View Fees</span>
</a>
<a href="#" class="menu-item">
<span>📅</span><span>View Schedule</span>
</a>
<a href="#" class="menu-item">
<span>📢</span><span>View Notices</span>
</a>
<a href="resetpassword.php" class="menu-item">
<span>🔒</span><span>Reset Password</span>
</a>
</div>
<!-- Main Content -->
<div class="main-content">
<!-- Welcome Section -->
<div class="welcome-section">
<h2>Welcome, <?php echo htmlspecialchars($first_name); ?>! 👋</h2>
<p>
Grade: <?php echo $grade; ?> |
Division: <?php echo $division ? $division : 'Not Assigned Yet'; ?> |
Roll No: <?php echo $roll_no ? $roll_no : 'Not Assigned Yet'; ?>
</p>
</div>
<!-- Language Selection Button (only for Grade 7 if triggered) -->
<?php if ($show_language_btn): ?>
<a href="studentlanguageselection.php" class="lang-btn">
🌐 Select Your Language Subject for Grade 8 →
</a>
<?php endif; ?>
<!-- Info if division not assigned -->
<?php if (!$division): ?>
<div class="info-card">
📌 Your division and roll number will be assigned by your faculty shortly.
</div>
<?php endif; ?>
<!-- Stats Cards -->
<div class="stats-grid">
<div class="stat-card attendance">
<h3>Overall Attendance</h3>
<div class="stat-value"><?php echo $att_percent; ?>%</div>
<div class="stat-detail"><?php echo $present; ?> / <?php echo $total_classes; ?> classes</div>
</div>
<div class="stat-card fees">
<h3>Fees Status</h3>
<?php if ($fees): ?>
<div class="stat-value"><?php echo $fees['pending_amount'] > 0 ? 'Pending' : 'Paid ✓'; ?></div>
<div class="stat-detail">
Paid: ₹<?php echo number_format($fees['paid_amount']); ?> /
Total: ₹<?php echo number_format($fees['total_fees']); ?>
</div>
<?php else: ?>
<div class="stat-value" style="font-size:28px;">No Record</div>
<div class="stat-detail">No fees record found</div>
<?php endif; ?>
</div>
</div>
<!-- Today's Schedule -->
<div class="schedule-section">
<h3>📅 Today's Schedule (<?php echo $today; ?>)</h3>
<?php if (!$division): ?>
<p style="color:#7f8c8d;">Schedule will be available once your division is assigned.</p>
<?php else: ?>
<table class="schedule-table">
<thead>
<tr>
<th>Time</th>
<th>Subject</th>
<th>Teacher</th>
</tr>
</thead>
<tbody>
<?php if (mysqli_num_rows($schedule_q) > 0): ?>
<?php while ($row = mysqli_fetch_assoc($schedule_q)): ?>
<tr>
<td><?php echo $row['time_from'] . ' - ' . $row['time_to']; ?></td>
<td><?php echo htmlspecialchars($row['subject']); ?></td>
<td><?php echo htmlspecialchars($row['teacher_email']); ?></td>
</tr>
<?php endwhile; ?>
<?php else: ?>
<tr>
<td colspan="3" style="text-align:center; color:#7f8c8d; padding:20px;">No classes scheduled for today.</td>
</tr>
<?php endif; ?>
</tbody>
</table>
<?php endif; ?>
</div>
<!-- Recent Notices -->
<div class="notices-section">
<h3>📢 Recent Notices</h3>
<?php if (mysqli_num_rows($notices_q) > 0): ?>
<?php while ($notice = mysqli_fetch_assoc($notices_q)): ?>
<div class="notice-box">
📌 <strong><?php echo htmlspecialchars($notice['title']); ?></strong><br>
<?php echo htmlspecialchars($notice['message']); ?>
<br><small style="opacity:0.7;"><?php echo $notice['date']; ?></small>
</div>
<?php endwhile; ?>
<?php else: ?>
<div class="notice-box">📌 No notices at the moment.</div>
<?php endif; ?>
</div>
</div>
</div>
<script>
window.addEventListener('load', () => {
const statCards = document.querySelectorAll('.stat-card');
statCards.forEach((card, index) => {
setTimeout(() => {
card.style.opacity = '0';
card.style.transform = 'translateY(20px)';
card.style.transition = 'all 0.5s ease';
setTimeout(() => {
card.style.opacity = '1';
card.style.transform = 'translateY(0)';
}, 50);
}, index * 100);
});
});
</script>
</body>
</html>