File size: 19,117 Bytes
9e7b45f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Admin Attendance Reports</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <style>
        :root {
            --sidebar-width: 280px;
            --primary-color: #6c5ce7;
            --card-bg: #f5f6fa;
            --text-color: #333333;
            --sidebar-bg: #f8f9fa;
            --input-border: #e0e0e0;
            --panel-bg: #ffffff;
            --panel-border: #e9ecef;
        }
        body.dark {
            --card-bg: #23272f;
            --text-color: #e0e0e0;
            --sidebar-bg: #181c24;
            --input-border: #333;
            --panel-bg: #111827;
            --panel-border: #1f2937;
        }
        body { background: var(--sidebar-bg); color: var(--text-color); }
        .sidebar {
            position: fixed;
            left: 0;
            top: 0;
            width: var(--sidebar-width);
            height: 100vh;
            background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
            padding: 24px 20px;
            box-shadow: 2px 0 20px rgba(0, 0, 0, 0.08);
            border-right: 1px solid rgba(0, 0, 0, 0.06);
            z-index: 1200;
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }
        body.dark .sidebar {
            background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
            box-shadow: 2px 0 20px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.2);
            border-right-color: rgba(255, 255, 255, 0.1);
        }
        .sidebar-brand { display:flex; align-items:center; gap:10px; padding:6px 0 16px 0; margin-bottom:8px; }
        .sidebar-brand img { width:42px; height:42px; object-fit:contain; flex:0 0 auto; }
        .sidebar-brand .brand-text { display:flex; flex-direction:column; line-height:1.1; }
        .sidebar-brand .brand-title { font-weight:900; letter-spacing:0.2px; font-size:16px; color:var(--text-color); }
        .sidebar-brand .brand-title .accent { color:var(--primary-color); }
        .sidebar-brand .brand-subtitle { margin:0; font-size:12px; font-weight:600; color:rgba(85, 96, 112, 0.9); margin-top:3px; }
        body.dark .sidebar-brand .brand-subtitle { color:rgba(219, 234, 254, 0.85); }
        .profile-section { padding: 20px 0 24px 0; border-bottom: 1px solid rgba(0, 0, 0, 0.08); margin-bottom: 24px; }
        body.dark .profile-section { border-bottom-color: rgba(255, 255, 255, 0.1); }
        .profile-header-row { display: flex; align-items: center; gap: 16px; }
        .profile-photo { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; border: 3px solid rgba(255, 255, 255, 0.9); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); transition: all 0.3s ease; flex-shrink: 0; }
        .profile-photo:hover { transform: translateY(-2px); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18); }
        body.dark .profile-photo { border-color: rgba(255, 255, 255, 0.2); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3); }
        .profile-info { display: flex; flex-direction: column; gap: 0; }
        .profile-name { font-size: 18px; font-weight: 700; color: var(--text-color); margin: 0; letter-spacing: 0.3px; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .profile-email { font-size: 11px; font-weight: 500; color: #666; margin: 4px 0 0 0; letter-spacing: 0.1px; word-break: break-all; line-height: 1.3; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        body.dark .profile-email { color: #aaa; }
        @media (max-width: 992px) { .profile-email { display: none; } }
        .nav-link { display:flex; align-items:center; gap:10px; padding:12px 14px; border-radius:12px; color: var(--text-color); text-decoration:none; transition: all 0.2s ease; }
        .nav-link:hover { background: rgba(108, 92, 231, 0.08); color: var(--primary-color); }
        .nav-link.active { background: linear-gradient(135deg, var(--primary-color) 0%, #a29bfe 100%); color:#fff; box-shadow: 0 4px 16px rgba(108, 92, 231, 0.24); }
        .main-content { margin-left: var(--sidebar-width); padding: 24px; transition: margin-left 0.3s ease; }
        .main-header { position: sticky; top: 0; z-index: 100; background: var(--sidebar-bg); padding: 8px 0; }
        .sidebar-toggle {
            display: none;
            align-items: center;
            justify-content: center;
            width: 42px;
            height: 42px;
            border-radius: 12px;
            border: 1px solid rgba(0,0,0,0.1);
            background: #fff;
            box-shadow: 0 4px 12px rgba(0,0,0,0.08);
        }
        body.dark .sidebar-toggle { background: #2d3436; border-color: #333; color: #e0e0e0; }

        .sidebar-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.45);
            z-index: 1100;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s ease;
        }
        .sidebar-overlay.show { opacity: 1; pointer-events: auto; }
        .filter-card, .table-card { background:#fff; border:1px solid #e9ecef; border-radius:14px; padding:16px; box-shadow:0 6px 20px rgba(0,0,0,0.04); }
        .filter-card, .table-card { background: var(--panel-bg); border:1px solid var(--panel-border); }
        .stat-pill { padding: 10px 14px; border-radius: 12px; background: #eef5ff; color: #0f5ea8; font-weight: 600; border: 1px solid #dbe7ff; }
        .stat-pill.danger { background: #fff1f2; color: #b42318; border-color: #ffdadd; }
        @media (max-width: 992px) {
            .sidebar { transform: translateX(-100%); box-shadow: none; }
            .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.18); }
            .main-content { margin-left:0; padding:16px; }
            .sidebar-toggle { display: inline-flex; }
        }
    </style>
</head>
<body>
    <div class="sidebar-overlay" id="sidebarOverlay"></div>
    <div class="sidebar">
        <div class="sidebar-brand">
            <img src="{{ url_for('static', filename='img/logo.svg') }}" alt="Facemark Pro logo">
            <div class="brand-text">
                <div class="brand-title"><span>FaceMark</span><span class="accent">Pro</span></div>
                <p class="brand-subtitle">Your face is your Attendance</p>
            </div>
        </div>
        <div class="profile-section">
            <div class="profile-header-row">
                <a href="{{ url_for('faculty.profile') }}" style="display:inline-block;">
                    <img src="{{ photo_path }}" alt="Profile Photo" class="profile-photo">
                </a>
                <div class="profile-info">
                    <h5 class="profile-name">{{ faculty|title }}</h5>
                    <p class="profile-email">{{ email }}</p>
                </div>
            </div>
        </div>
        <div class="nav-links">
            <ul style="list-style:none; padding:0; margin:0; display:flex; flex-direction:column; gap:8px;">
                <li><a href="{{ url_for('admin.dashboard') }}" class="nav-link"><i class="fas fa-home"></i> Dashboard</a></li>
                <li><a href="{{ url_for('admin.manage_faculty') }}" class="nav-link"><i class="fas fa-chalkboard-teacher"></i> Faculty</a></li>
                <li><a href="{{ url_for('admin.manage_students') }}" class="nav-link"><i class="fas fa-user-graduate"></i> Students</a></li>
                <li><a href="{{ url_for('admin.manage_faces') }}" class="nav-link"><i class="fas fa-camera"></i> Face Reg.</a></li>
                <li><a href="{{ url_for('admin.reports') }}" class="nav-link active"><i class="fas fa-chart-line"></i> Reports</a></li>
                <li><a href="{{ url_for('faculty.dashboard') }}" class="nav-link" style="color:#0984e3;"><i class="fas fa-arrow-left"></i> Back to Faculty Dashboard</a></li>
                <li style="margin-top: 14px; border-top: 1px solid rgba(0,0,0,0.08); padding-top:10px;"><a href="{{ url_for('faculty.logout') }}" class="nav-link" style="color:#ff6b6b;"><i class="fas fa-sign-out-alt"></i> Logout</a></li>
            </ul>
        </div>
    </div>

    <div class="main-content">
        <div class="main-header d-flex flex-wrap justify-content-between align-items-center mb-3">
            <div class="d-flex align-items-center gap-2">
                <button class="sidebar-toggle" id="sidebarToggle" aria-label="Toggle navigation"><i class="fas fa-bars"></i></button>
                <div>
                    <h3 class="mb-1">Attendance Reports</h3>
                    <div class="text-muted">Combine any subject/class; default range is today.</div>
                </div>
            </div>
            <div class="d-flex gap-2">
                <form method="get" class="d-inline">
                    <input type="hidden" name="start_date" value="{{ start_date }}">
                    <input type="hidden" name="end_date" value="{{ end_date }}">
                    <input type="hidden" name="subject" value="{{ selected_subject }}">
                    <input type="hidden" name="branch" value="{{ selected_branch }}">
                    <input type="hidden" name="semester" value="{{ selected_semester }}">
                    <input type="hidden" name="section" value="{{ selected_section }}">
                    <input type="hidden" name="faculty_email" value="{{ selected_faculty }}">
                    <input type="hidden" name="student_roll" value="{{ student_roll }}">
                    <input type="hidden" name="export" value="csv">
                    <button class="btn btn-outline-primary"><i class="fas fa-file-csv"></i> Export CSV</button>
                </form>
                <form method="get" class="d-inline">
                    <input type="hidden" name="start_date" value="{{ start_date }}">
                    <input type="hidden" name="end_date" value="{{ end_date }}">
                    <input type="hidden" name="subject" value="{{ selected_subject }}">
                    <input type="hidden" name="branch" value="{{ selected_branch }}">
                    <input type="hidden" name="semester" value="{{ selected_semester }}">
                    <input type="hidden" name="section" value="{{ selected_section }}">
                    <input type="hidden" name="faculty_email" value="{{ selected_faculty }}">
                    <input type="hidden" name="student_roll" value="{{ student_roll }}">
                    <input type="hidden" name="export" value="pdf">
                    <button class="btn btn-outline-secondary"><i class="fas fa-file-pdf"></i> Export PDF</button>
                </form>
            </div>
        </div>

        <div class="filter-card mb-4">
            <form method="get" class="row g-3">
                <div class="col-md-3">
                    <label class="form-label">Start Date</label>
                    <input type="date" class="form-control" name="start_date" value="{{ start_date }}">
                </div>
                <div class="col-md-3">
                    <label class="form-label">End Date</label>
                    <input type="date" class="form-control" name="end_date" value="{{ end_date }}">
                </div>
                <div class="col-md-3">
                    <label class="form-label">Subject</label>
                    <select class="form-select" name="subject">
                        <option value="">All subjects</option>
                        {% for subj in subject_options %}
                        <option value="{{ subj }}" {% if subj == selected_subject %}selected{% endif %}>{{ subj }}</option>
                        {% endfor %}
                    </select>
                </div>
                <div class="col-md-3">
                    <label class="form-label">Faculty</label>
                    <select class="form-select" name="faculty_email">
                        <option value="">All faculty</option>
                        {% for f in faculty_options %}
                        <option value="{{ f.email }}" {% if f.email == selected_faculty %}selected{% endif %}>{{ f.name }} ({{ f.email }})</option>
                        {% endfor %}
                    </select>
                </div>
                <div class="col-md-3">
                    <label class="form-label">Branch</label>
                    <select class="form-select" name="branch">
                        <option value="">All branches</option>
                        {% for b in branch_options %}
                        <option value="{{ b }}" {% if b == selected_branch %}selected{% endif %}>{{ b }}</option>
                        {% endfor %}
                    </select>
                </div>
                <div class="col-md-3">
                    <label class="form-label">Semester</label>
                    <select class="form-select" name="semester">
                        <option value="">All semesters</option>
                        {% for sem in semester_options %}
                        <option value="{{ sem }}" {% if sem|string == selected_semester %}selected{% endif %}>{{ sem }}</option>
                        {% endfor %}
                    </select>
                </div>
                <div class="col-md-3">
                    <label class="form-label">Section</label>
                    <select class="form-select" name="section">
                        <option value="">All sections</option>
                        {% for sec in section_options %}
                        <option value="{{ sec }}" {% if sec == selected_section %}selected{% endif %}>{{ sec }}</option>
                        {% endfor %}
                    </select>
                </div>
                <div class="col-md-3">
                    <label class="form-label">Student (Roll No)</label>
                    <input type="text" class="form-control" name="student_roll" value="{{ student_roll }}" placeholder="Optional">
                </div>
                <div class="col-12 d-flex justify-content-end">
                    <button class="btn btn-primary"><i class="fas fa-filter"></i> Apply Filters</button>
                </div>
            </form>
        </div>

        <div class="d-flex flex-wrap gap-2 mb-3">
            <span class="stat-pill">Present: {{ totals.total_present }}</span>
            <span class="stat-pill danger">Absent: {{ totals.total_absent }}</span>
        </div>

        <div class="table-card mb-4">
            <div class="d-flex justify-content-between align-items-center mb-2">
                <h5 class="mb-0">Summary</h5>
                <small class="text-muted">{{ start_date }} to {{ end_date }}</small>
            </div>
            {% if summary_rows %}
            <div class="table-responsive">
                <table class="table table-sm align-middle">
                    <thead class="table-light">
                        <tr>
                            <th>Roll No</th>
                            <th>Name</th>
                            <th>Branch</th>
                            <th>Sem</th>
                            <th>Sec</th>
                            <th class="text-center">Present</th>
                            <th class="text-center">Absent</th>
                            <th class="text-center">%</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for row in summary_rows %}
                        <tr>
                            <td>{{ row.roll_no }}</td>
                            <td>{{ row.name }}</td>
                            <td>{{ row.branch }}</td>
                            <td>{{ row.semester }}</td>
                            <td>{{ row.section }}</td>
                            <td class="text-center">{{ row.present }}</td>
                            <td class="text-center">{{ row.absent }}</td>
                            <td class="text-center">{{ '%.1f'|format(row.percentage) }}</td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
            {% else %}
            <div class="text-muted">No attendance records in this range.</div>
            {% endif %}
        </div>

        {% if student_roll and detail_rows %}
        <div class="table-card">
            <div class="d-flex justify-content-between align-items-center mb-2">
                <h5 class="mb-0">Detail for {{ student_roll }}</h5>
                <small class="text-muted">Dates within range</small>
            </div>
            <div class="table-responsive">
                <table class="table table-sm align-middle">
                    <thead class="table-light">
                        <tr>
                            <th>Date</th>
                            <th>Subject</th>
                            <th>Status</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for d in detail_rows %}
                        <tr>
                            <td>{{ d.date }}</td>
                            <td>{{ d.subject }}</td>
                            <td>
                                {% if d.status == 'Present' %}
                                <span class="badge bg-success">Present</span>
                                {% else %}
                                <span class="badge bg-danger">Absent</span>
                                {% endif %}
                            </td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
        {% endif %}
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <script>
        const sidebar = document.querySelector('.sidebar');
        const overlay = document.getElementById('sidebarOverlay');
        const toggleBtn = document.getElementById('sidebarToggle');
        const navLinks = document.querySelectorAll('.sidebar .nav-link');
        const closeSidebar = () => {
            sidebar.classList.remove('open');
            overlay.classList.remove('show');
            document.body.classList.remove('no-scroll');
        };
        toggleBtn?.addEventListener('click', () => {
            const open = sidebar.classList.toggle('open');
            overlay.classList.toggle('show', open);
            document.body.classList.toggle('no-scroll', open);
        });
        overlay?.addEventListener('click', closeSidebar);
        navLinks.forEach(link => link.addEventListener('click', closeSidebar));
        window.addEventListener('resize', () => { if (window.innerWidth >= 992) closeSidebar(); });
    </script>
</body>
</html>