{% extends 'base.html' %}
{% block title %}Discounts - Rapha-Bethel BNPS{% endblock %}
{% block content %}
<div class="container-fluid">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <div><h1 class="h3 mb-0">Discounts</h1><p class="text-muted">Manage fee discounts and waivers</p></div>
        <div class="btn-group">
            <a href="{% url 'finance:discount_add' %}" class="btn btn-primary"><i class="fas fa-plus me-2"></i>Add Discount</a>
            <a href="{% url 'finance:student_discount_add' %}" class="btn btn-outline-primary"><i class="fas fa-user-tag me-2"></i>Apply to Student</a>
        </div>
    </div>
    <div class="card shadow">
        <div class="card-body p-0">
            <table class="table table-hover mb-0">
                <thead class="table-dark"><tr><th>Name</th><th>Type</th><th>Value</th><th>Applies To</th><th>Active</th></tr></thead>
                <tbody>
                    {% for discount in discounts %}
                    <tr>
                        <td><div class="fw-bold">{{ discount.name }}</div><small class="text-muted">{{ discount.name_fr }}</small></td>
                        <td><span class="badge bg-info">{{ discount.get_discount_type_display }}</span></td>
                        <td class="fw-bold">{% if discount.discount_type == 'percentage' %}{{ discount.value }}%{% else %}{{ discount.value|floatformat:0 }} XAF{% endif %}</td>
                        <td>{{ discount.get_applies_to_display }}</td>
                        <td>{% if discount.is_active %}<span class="badge bg-success">Active</span>{% else %}<span class="badge bg-secondary">Inactive</span>{% endif %}</td>
                    </tr>
                    {% empty %}
                    <tr><td colspan="5" class="text-center py-4 text-muted"><i class="fas fa-tags fa-2x mb-2 d-block"></i>No discounts defined yet.</td></tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
</div>
{% endblock %}
