{% extends "base.html" %}

{% block content %}
    {% include "statistiques/stat-form.html" %}
    {% include "statistiques/stat-tabs.html" with active="age" %}

    <div class="row">
        <div class="col">
            <p class="fw-bold mt-3">
                Répartition des enfants suivis (dès demande jusqu'à la fin d’accompagnement) par âge. L’âge est calculé à la date médiane entre la demande et la fin du suivi.
            </p>

            <table class="table table-sm table-hover stat_table">
                <thead>
                    <tr><th class="left">Âge</th>
                        {% for month in months %}<th>{{ month }}</th>{% endfor %}
                        <th>Total</th>
                    </tr>
                </thead>
                <tbody>
                    <tr><td colspan="{{ months|length|add:3 }}" style="background-color: #eee;">
                        <h3>Âges</h3>
                    </td></tr>
                    {% for age, stats in ages.items %}
                    <tr>
                        <td>{{ age }}</td>
                        {% for month in months %}<td class="num">{{ stats|get_item:month }}</td>{% endfor %}
                        <td class="num">{{ stats.total }}</td>
                    </tr>
                    {% endfor %}
                    <tr>
                        <td>Âge moyen</td>
                        {% for month in months %}<td class="num">{{ means|get_item:month }}</td>{% endfor %}
                        <td class="num">{{ means.total }}</td>
                    </tr>
                </tbody>
            </table>
            <div class="text-end">
                <a href=".?{% param_replace %}&export=1"><img class="icon-ui" src="{% static 'ficons/xlsx.svg' %}"></a>
            </div>
        </div>
    </div>
{% endblock %}
