{% extends 'base.html' %}
{% load static %}

{% block title %}Attendance Records - Rapha-Bethel BNPS{% endblock %}

{% block content %}
<div class="container-fluid">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h1 class="h3 mb-0 text-gray-800">Attendance Records</h1>
        <a href="{% url 'attendance:mark_attendance' %}" class="btn btn-primary">
            <i class="fas fa-plus"></i> Mark Attendance
        </a>
    </div>

    <div class="card shadow">
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-hover">
                    <thead>
                        <tr>
                            <th>Date</th>
                            <th>Student</th>
                            <th>Class</th>
                            <th>Status</th>
                            <th>Marked By</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for attendance in attendances %}
                        <tr>
                            <td>{{ attendance.date }}</td>
                            <td>{{ attendance.student }}</td>
                            <td>{{ attendance.school_class }}</td>
                            <td>
                                <span class="badge bg-{% if attendance.status == 'present' %}success{% elif attendance.status == 'absent' %}danger{% else %}warning{% endif %}">
                                    {{ attendance.get_status_display }}
                                </span>
                            </td>
                            <td>{{ attendance.marked_by.user.get_full_name|default:"System" }}</td>
                        </tr>
                        {% empty %}
                        <tr>
                            <td colspan="5" class="text-center">No attendance records found</td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
{% endblock %}