{% block pageContent %}
<div class="pageContent">
    <h3>Assiduites et justificatifs de <span class="rouge">{{sem}}</span> </h3>
    {% include "assiduites/widgets/tableau_base.j2" %}

    <h4>Assiduité :</h4>
    <span class="iconline">
        <a class="icon filter" onclick="filterAssi()"></a>
        <a class="icon download" onclick="downloadAssi()"></a>
    </span>
    {% include "assiduites/widgets/tableau_assi.j2" %}
    <h4>Justificatifs :</h4>
    <span class="iconline">
        <a class="icon filter" onclick="filterJusti()"></a>
        <a class="icon download" onclick="downloadJusti()"></a>
    </span>
    {% include "assiduites/widgets/tableau_justi.j2" %}

</div>
<script>
    const formsemestre_id = {{ formsemestre_id }};

    function getFormSemestreAssiduites(action) {
        const path = getUrl() + `/api/assiduites/formsemestre/${formsemestre_id}`
        async_get(
            path,
            (data, status) => {
                if (action) {
                    action(data)
                } else {
                    assiduiteCallBack(data);
                }
            },
            (data, status) => {
                console.error(data, status)
                errorAlert();
            }
        )
    }

    function getFormSemestreJustificatifs(action) {
        const path = getUrl() + `/api/justificatifs/formsemestre/${formsemestre_id}`
        async_get(
            path,
            (data, status) => {
                if (action) {
                    action(data)
                } else {
                    justificatifCallBack(data);
                }
            },
            (data, status) => {
                console.error(data, status)
                errorAlert();
            }
        )
    }

    function getAssi(action) {
        try { getFormSemestreAssiduites(action) } catch (_) { }
    }

    function getJusti(action) {
        try { getFormSemestreJustificatifs(action) } catch (_) { }
    }

    window.addEventListener('load', () => {

        filterJustificatifs = {
            "columns": [
                "etudid",
                "entry_date",
                "date_debut",
                "date_fin",
                "etat",
                "raison",
                "fichier"
            ],
            "filters": {
            }
        }
        filterAssiduites = {
            columns: [
                "etudid", "entry_date", "date_debut", "date_fin", "etat", "moduleimpl_id", "est_just"
            ],
            "filters": {
            }
        }

        loadAll();
    })

</script>
{% endblock pageContent %}