{% extends 'base.html' %}
{% load static %}
{% block title %}Term {{ term }} Financial Report{% 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">Term {{ term }} Financial Report</h1><p class="text-muted">{{ year }}/{{ year|add:1 }} Academic Year &bull; {{ start_date }} to {{ end_date }}</p></div>
        <a href="{% url 'reports:financial_report' %}" class="btn btn-outline-secondary"><i class="fas fa-arrow-left me-2"></i>Back</a>
    </div>
    <div class="row mb-4">
        <div class="col-md-4"><div class="card border-left-primary shadow h-100 py-2"><div class="card-body"><div class="text-xs font-weight-bold text-primary text-uppercase mb-1">Total Invoiced</div><div class="h4 fw-bold">{{ total_invoiced|floatformat:0 }} XAF</div></div></div></div>
        <div class="col-md-4"><div class="card border-left-success shadow h-100 py-2"><div class="card-body"><div class="text-xs font-weight-bold text-success text-uppercase mb-1">Collected</div><div class="h4 fw-bold">{{ total_collected|floatformat:0 }} XAF</div></div></div></div>
        <div class="col-md-4"><div class="card border-left-warning shadow h-100 py-2"><div class="card-body"><div class="text-xs font-weight-bold text-warning text-uppercase mb-1">Outstanding</div><div class="h4 fw-bold">{{ outstanding|floatformat:0 }} XAF</div></div></div></div>
    </div>
    <div class="card shadow">
        <div class="card-body">
            <div class="progress mb-2" style="height:20px;">
                {% if total_invoiced > 0 %}
                <div class="progress-bar bg-success" style="width:{% widthratio total_collected total_invoiced 100 %}%" title="Collected">
                    {% widthratio total_collected total_invoiced 100 %}% Collected
                </div>
                {% endif %}
            </div>
            <p class="text-muted text-center">{{ total_collected|floatformat:0 }} XAF collected out of {{ total_invoiced|floatformat:0 }} XAF invoiced</p>
        </div>
    </div>
</div>
{% endblock %}
