{% do setAriane(1, 'État Statistique' | trad) %}

{% extends 'layout.twig' %}
{% block body %}
<section class="contenu">
    <h1 class="bs-col">{{ 'Etats Statistiques' | trad }}</h1>

    {{ ariane() }}

    <header class="bs-row">
        <h2 class="bs-col">{{ etatstat.DESCRIPT }}</h2>
        <div class="bs-col-auto">
            <button class="button principal mr-0" type="button" 
                onclick="exportEtatStat()"
            >{{ 'Exporter' | trad }}</button>
            <script>
function exportEtatStat() {
    ajaxSimple(
        {{ path('EtatStatistique.Tableau.export', {id: etatstat.CODETAT}) | json }},
        new FormData(document.getElementById('main_form')),
        () => {
            activePopupInfo(
                {{ 'Informations' | trad | json }},
                {{ "Votre document est en cours de téléchargement, vous allez recevoir un mail contenant votre document." | trad | json }},
                'modal_small'
            );
        }
    );
}
            </script>
        </div>
    </header>
    {% embed '@EtatStatistiques/Tableau/_gestable.twig' with {
        table: gestable,
        post: post,
        form_filter: form_filter,
        form_id: 'main_form'
    } only %}
{#______________________________________________________________________________
    Filter form #}
        {% block pre_form %}
            {% if form_filter is not empty %}
            <section class="box-form form-default">
                <div class="bs-row gutter-x-base">
                    {% for input in form_filter %}
                        <div class="bs-col-quarter">
                        {{ formInput(
                            input 
                            | setObj('bulle', true) 
                            | setObj('subjectIsPost', true),
                            post,
                            input.label
                        ) }}
                        </div>
                    {% endfor %}
                    <div class="bs-col ml-auto text-right">
                        <button type="submit" class="button principal btn_filtre">
                            {{ 'Filtrer' | trad }}
                        </button>
                    </div>
                </div>
            </section>
            {% endif %}
        {% endblock %}
{#______________________________________________________________________________
    Rupture #}
        {% block rupture %}
        <tr class="rupture1">
            {% for col in table.listCol %}
                {% set numOrd = rupture.mapTot[ col.name ] %}
                {% if numOrd is not null %}
                <td class="text-right">
                    {{ item[ '_Rupture_1_total' ~ numOrd ] | prix }}
                </td>
                {% elseif rupture.colLabelAlias == col.name %}
                    <td><strong>{{ rupture.label }}</strong></td>
                {% else %}
                    <td></td>
                {% endif %}
            {% endfor %}
        </tr>
        {% endblock %}
{#______________________________________________________________________________
    Overflow #}
        {% block pre_table %}<div style="overflow: auto; max-width:100%">{% endblock %}
        {% block post_table %}</div>{% endblock %}
    {% endembed %}
    {% if not etatstat.Requete.REQ_LIBRE | boolSql and gestable.listCol is empty %}
        <p class="error">
            {{- 'Aucune colonne n’a été définie' | trad -}}
        </p>
        {% elseif hasErrorSql %}
        <p class="error">
            {{- 'Une erreur SQL est survenue, si le problème persiste merci de contacter un administrateur' | trad -}}
        </p>
    {% endif %}
</section>
{% endblock %}


