{% extends "base.html" %}

{% block title %}Statistiques{% endblock %}

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

    <div class="row">
        <div class="col">
            <table class="table table-sm table-hover stat_table">
                <thead>
                    <tr><th></th>{% for month in months %}<th>{{ month }}</th>{% endfor %}<th>Total</th></tr>
                </thead>
                <tbody>
                    <tr>
                        <td colspan="{{ months|length|add:2 }}" class="app_line">
                            <h3>Familles</h3>
                            <small><em>{{ familles.total_familles }} familles prise en compte sur la période choisie</em></small>
                        </td>
                    </tr>
                    <tr>
                        <td>Total familles (évaluation et/ou accomp.)</td>
                        {% for month in months %}<td class="num">{{ familles.familles_total|get_item:month }}</td>{% endfor %}
                        <td class="num">{{ familles.familles_total.total }}</td>
                    </tr>
                    <tr>
                        <td>Total enfants suivis (évaluation et/ou accomp.)</td>
                        {% for month in months %}<td class="num">{{ familles.enfants_total|get_item:month }}</td>{% endfor %}
                        <td class="num">{{ familles.enfants_total.total }}</td>
                    </tr>
                    <tr>
                        <td>Familles évaluées</td>
                        {% for month in months %}<td class="num">{{ familles.familles_evaluees|get_item:month }}</td>{% endfor %}
                        <td class="num">{{ familles.familles_evaluees.total }}</td>
                    </tr>
                    <tr>
                        <td>Enfants évalués</td>
                        {% for month in months %}<td class="num">{{ familles.enfants_evalues|get_item:month }}</td>{% endfor %}
                        <td class="num">{{ familles.enfants_evalues.total }}</td>
                    </tr>
                    <tr>
                        <td>Enfants non suivis de familles évaluées</td>
                        {% for month in months %}<td class="num">{{ familles.enfants_evalues_non_suivis|get_item:month }}</td>{% endfor %}
                        <td class="num">{{ familles.enfants_evalues_non_suivis.total }}</td>
                    </tr>
                    <tr>
                        <td>Familles évaluées sans aboutir à un suivi</td>
                        {% for month in months %}<td class="num">{{ familles.familles_eval_sans_suivi|get_item:month }}</td>{% endfor %}
                        <td class="num">{{ familles.familles_eval_sans_suivi.total }}</td>
                    </tr>
                    <tr>
                        <td>Familles suivies</td>
                        {% for month in months %}<td class="num">{{ familles.familles_suivies|get_item:month }}</td>{% endfor %}
                        <td class="num">{{ familles.familles_suivies.total }}</td>
                    </tr>
                    <tr>
                        <td>Enfants suivis</td>
                        {% for month in months %}<td class="num">{{ familles.enfants_suivis|get_item:month }}</td>{% endfor %}
                        <td class="num">{{ familles.enfants_suivis.total }}</td>
                    </tr>
                    <tr>
                        <td>Enfants non suivis de familles suivies</td>
                        {% for month in months %}<td class="num">{{ familles.enfants_suivis_non_suivis|get_item:month }}</td>{% endfor %}
                        <td class="num">{{ familles.enfants_suivis_non_suivis.total }}</td>
                    </tr>
                    <tr>
                        <td>dont Familles d’accueil</td>
                        {% for month in months %}<td class="num">{{ familles.familles_accueil|get_item:month }}</td>{% endfor %}
                        <td class="num">{{ familles.familles_accueil.total }}</td>
                    </tr>
                    <tr>
                        <td>dont Familles déjà suivies</td>
                        {% for month in months %}<td class="num">{{ familles.familles_connues|get_item:month }}</td>{% endfor %}
                        <td class="num">{{ familles.familles_connues.total }}</td>
                    </tr>
                    <tr>
                        <td>Demandes prioritaires</td>
                        {% for month in months %}<td class="num">{{ familles.prioritaires|get_item:month }}</td>{% endfor %}
                        <td class="num">{{ familles.prioritaires.total }}</td>
                    </tr>
                    <tr>
                        <td>Rendez-vous manqués</td>
                        {% for month in months %}<td class="num">{{ familles.rdv_manques|get_item:month }}</td>{% endfor %}
                        <td class="num">{{ familles.rdv_manques.total }}</td>
                    </tr>
                    <tr>
                        <td colspan="{{ months|length|add:1 }}">Durée moyenne entre demande et début de suivi</td>
                        <td class="num">{{ familles.duree_attente.moyenne.days }} jours</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 %}