{% extends "base.html" %}

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

    <div class="row">
        <div class="col">
            <table class="table table-sm table-hover stat_table">
                <thead>
                    <tr><th class="left">Motif d’annonce</th>
                        {% for month in months %}<th>{{ month }}</th>{% endfor %}
                        <th>Total</th>
                    </tr>
                </thead>
                <tbody>
                    {% for motif, stats in data.ann.items %}
                    <tr>
                        <td>{{ motif }}</td>
                        {% for month in months %}<td class="num">{{ stats|get_item:month }}</td>{% endfor %}
                        <td class="num">{{ stats.total }}</td>
                    </tr>
                    {% endfor %}
                </tbody>

                <thead>
                    <tr><th class="left">Service annonceur</th>
                        {% for month in months %}<th>{{ month }}</th>{% endfor %}
                        <th>Total</th>
                    </tr>
                </thead>
                <tbody>
                    {% for service, stats in data.orient.items %}
                    <tr>
                        <td>{{ service }}</td>
                        {% for month in months %}<td class="num">{{ stats|get_item:month }}</td>{% endfor %}
                        <td class="num">{{ stats.total }}</td>
                    </tr>
                    {% endfor %}
                </tbody>

                <thead>
                    <tr><th class="left">Motif de fin d’évaluation ou d’accompagnement</th>
                        {% for month in months %}<th>{{ month }}</th>{% endfor %}
                        <th>Total</th>
                    </tr>
                </thead>
                <tbody>
                    <tr class="subdiv2"><td>Abandon avant évaluation</td></tr>
                    {% for motif, stats in data.fin_preeval.items %}
                    <tr>
                        <td>{{ motif }}</td>
                        {% for month in months %}<td class="num">{{ stats|get_item:month }}</td>{% endfor %}
                        <td class="num">{{ stats.total }}</td>
                    </tr>
                    {% endfor %}
                    <tr class="subdiv2"><td>Abandon après évaluation</td></tr>
                    {% for motif, stats in data.fin_posteval.items %}
                    <tr>
                        <td>{{ motif }}</td>
                        {% for month in months %}<td class="num">{{ stats|get_item:month }}</td>{% endfor %}
                        <td class="num">{{ stats.total }}</td>
                    </tr>
                    {% endfor %}
                    <tr class="subdiv2"><td>Fin de l'accompagnement</td></tr>
                    {% for motif, stats in data.fin_postacc.items %}
                    <tr>
                        <td>{{ motif }}</td>
                        {% for month in months %}<td class="num">{{ stats|get_item:month }}</td>{% endfor %}
                        <td class="num">{{ stats.total }}</td>
                    </tr>
                    {% endfor %}
                    <tr class="subdiv2"><td>Total</td></tr>
                    {% for motif, stats in data.fin_total.items %}
                    <tr>
                        <td>{{ motif }}</td>
                        {% for month in months %}<td class="num">{{ stats|get_item:month }}</td>{% endfor %}
                        <td class="num">{{ stats.total }}</td>
                    </tr>
                    {% endfor %}
                </tbody>

                <thead>
                    <tr><th class="left">Provenance</th>
                        {% for month in months %}<th>{{ month }}</th>{% endfor %}
                        <th>Total</th>
                    </tr>
                </thead>
                <tbody>
                    {% for prov, stats in data.prov.items %}
                    <tr>
                        <td>{{ prov }}</td>
                        {% for month in months %}<td class="num">{{ stats|get_item:month }}</td>{% endfor %}
                        <td class="num">{{ stats.total }}</td>
                    </tr>
                    {% endfor %}
                </tbody>

                <thead>
                    <tr><th class="left">Destination</th>
                        {% for month in months %}<th>{{ month }}</th>{% endfor %}
                        <th>Total</th>
                    </tr>
                </thead>
                <tbody>
                    {% for dest, stats in data.dest.items %}
                    <tr>
                        <td>{{ dest }}</td>
                        {% for month in months %}<td class="num">{{ stats|get_item:month }}</td>{% endfor %}
                        <td class="num">{{ stats.total }}</td>
                    </tr>
                    {% endfor %}
                </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 %}
