File size: 3,369 Bytes
58668c3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
{% extends "base.html" %}
{% block content %}
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem;">
    <h2>πŸ‘¨β€πŸŽ“ Students</h2>
    <a href="{{ url_for('add_student') }}" class="btn btn-success">+ Add Student</a>
</div>

<!-- Search Bar -->
<div class="card" style="margin-bottom: 1.5rem; padding: 1rem;">
    <form method="GET" action="{{ url_for('students') }}" style="display: flex; gap: 1rem; align-items: center;">
        <input type="text" 
               name="q" 
               value="{{ search_query or '' }}" 
               placeholder="πŸ” Search by Student ID or Name..." 
               style="flex: 1; padding: 0.75rem; border: 1px solid #d1d5db; border-radius: 6px; font-size: 1rem;">
        <button type="submit" class="btn" style="padding: 0.75rem 1.5rem;">Search</button>
        {% if search_query %}
        <a href="{{ url_for('students') }}" class="btn" style="padding: 0.75rem 1.5rem; background: #6b7280;">Clear</a>
        {% endif %}
    </form>
    {% if search_query %}
    <div style="margin-top: 0.5rem; color: #6b7280; font-size: 0.9rem;">
        Found {{ students|length }} student(s) matching "{{ search_query }}"
    </div>
    {% endif %}
</div>
<div class="card">
    <table>
        <tr>
            <th>Student ID</th>
            <th>Name</th>
            <th>Email</th>
            <th>Department</th>
            <th>Contact</th>
            <th>Issued Books</th>
            <th>Actions</th>
        </tr>
        {% for student in students %}
        <tr>
            <td>{{ student.id }}</td>
            <td>
                <a href="{{ url_for('view_student', student_id=student.id) }}" 
                   style="color: #2563eb; text-decoration: none; font-weight: 600;">
                    {{ student.name }}
                </a>
            </td>
            <td>{{ student.email }}</td>
            <td>{{ student.department }}</td>
            <td>{{ student.contact }}</td>
            <td>
                {% set issues = student_issues.get(student.id, []) %}
                {% if issues %}
                    <span style="color: #2563eb; font-weight: 600;">{{ issues|length }} active book(s)</span>
                    <div style="margin-top: 0.5rem; font-size: 0.85rem; color: #6b7280;">
                        {% for issue in issues %}
                        <div style="padding: 0.25rem 0;">
                            πŸ“š {{ issue.book_id }}
                            {% if issue.is_overdue() %}
                            <span style="color: red; font-weight: bold;">⚠ Overdue</span>
                            {% endif %}
                        </div>
                        {% endfor %}
                    </div>
                {% else %}
                    <span style="color: #9ca3af;">No active books</span>
                {% endif %}
            </td>
            <td>
                <a href="{{ url_for('edit_student', student_id=student.id) }}" class="btn">Edit</a>
                <form method="POST" action="{{ url_for('delete_student', student_id=student.id) }}" style="display: inline;">
                    <button type="submit" class="btn btn-danger" onclick="return confirm('Delete?')">Delete</button>
                </form>
            </td>
        </tr>
        {% endfor %}
    </table>
</div>
{% endblock %}