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

{% block title %}Leave Requests - 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">Leave Requests</h1>
        <a href="{% url 'staff:leave_add' %}" class="btn btn-primary">
            <i class="fas fa-plus"></i> Request Leave
        </a>
    </div>

    <div class="card shadow">
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-hover">
                    <thead>
                        <tr>
                            <th>Staff</th>
                            <th>Leave Type</th>
                            <th>Start Date</th>
                            <th>End Date</th>
                            <th>Days</th>
                            <th>Status</th>
                            <th>Actions</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for leave in leaves %}
                        <tr>
                            <td>{{ leave.staff.user.get_full_name }}</td>
                            <td>{{ leave.get_leave_type_display }}</td>
                            <td>{{ leave.start_date }}</td>
                            <td>{{ leave.end_date }}</td>
                            <td>{{ leave.days_requested }}</td>
                            <td>
                                <span class="badge bg-{% if leave.status == 'approved' %}success{% elif leave.status == 'pending' %}warning{% else %}danger{% endif %}">
                                    {{ leave.get_status_display }}
                                </span>
                            </td>
                            <td>
                                <a href="{% url 'staff:leave_detail' leave.pk %}" class="btn btn-sm btn-info">
                                    <i class="fas fa-eye"></i>
                                </a>
                            </td>
                        </tr>
                        {% empty %}
                        <tr>
                            <td colspan="7" class="text-center">No leave requests found</td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
{% endblock %}