{% extends "/admin/menu_left_admin.html.twig" %}

{% block title %}Liste des entêtes {% endblock %}

{% block main %}
    {% if not entete is null and not entete.texte==''%}
        <div class="col-xs-12 p-0">
            <div class="bloc-base p-16">
                {{ entete.texte|raw }}
            </div>
        </div>
    {% endif %}
    <div class="row m-0">
        <div class="col-xs-12 p-16 background-white">
            <div class="table-responsive">
                <table id="myTable" class="display">
                    <thead class="background-orange">
                    <tr>
                        <th class="plr-8 ptb-16">Localisation</th>
                        <th class="plr-8 ptb-16">Description</th>
                        <th class="plr-8 ptb-16">Date de mise à jour</th>
                        <th class="plr-8 ptb-16">Utilisateur ayant mis à jour</th>
                        <th class="plr-8 ptb-16">Modifier</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for couple in entetesWithMail %}
                        <tr>
                            <td class="plr-8 ptb-24">{{ couple[1].localisation }}</td>
                            <td class="plr-8 ptb-24">{{ couple[2].descriptionWithoutHTML|slice(0,50) ~ (couple[2].descriptionWithoutHTML | length > 50 ? "...")}}</td>

                            {% if '30/11/-0001' not in couple[1].dateUpdate|date('d/m/Y') and couple[1].dateUpdate is not null %}
                                <td class="plr-8 ptb-24">{{ couple[1].dateUpdate ? couple[1].dateUpdate|date('d/m/Y') }}</td>
                            {% else %}
                                <td class="plr-8 ptb-24"></td>
                            {% endif %}

                            <td class="plr-8 ptb-24">{{ couple[0] }}</td>

                            {% if is_granted('ROLE_PREVIOUS_ADMIN') %}
                                <td class="plr-8 ptb-24 dtb-action">
                                    <a class="button-rond-xs align-middle" style="background-color: gray"><i class="fas fa-edit" style="color: white" title="Non accessible en consultation"></i></a>
                                </td>
                            {% else %}
                                <td class="plr-8 ptb-24 dtb-action">
                                    <a  href="{{ path('entete_update', {localisation : couple[1].localisation}) }}" class="button-rond-xs align-middle" title="Modifier"><i class="fas fa-edit"></i></a>
                                </td>
                            {% endif %}
                        </tr>
                    {% endfor %}

                    {% for  entete in entetesWithoutMail %}
                        <tr>
                            <td class="plr-8 ptb-24">{{ entete.localisation }}</td>
                            <td class="plr-8 ptb-24">{{ entete.description }}</td>
                            <td class="plr-8 ptb-24"> - </td>
                            <td class="plr-8 ptb-24">Cette entête n'a pas encore été modifiée.</td>

                            {% if is_granted('ROLE_PREVIOUS_ADMIN') %}
                                <td class="plr-8 ptb-24 dtb-action">
                                    <a class="button-rond-xs align-middle" style="background-color: gray"><i class="fas fa-edit" style="color: white" title="Non accessible en consultation"></i></a>
                                </td>
                            {% else %}
                                <td class="plr-8 ptb-24 dtb-action">
                                    <a href="{{ path('entete_update', {localisation : entete.localisation}) }}" class="button-rond-xs align-middle" title="Modifier"><i class="fas fa-edit"></i></a>
                                </td>
                            {% endif %}
                        </tr>
                    {% endfor %}

                    {# {% for e in entetes %}
                        <tr>
                            <td class="plr-8 ptb-24">{{ e.localisation }}</td>
                            <td class="plr-8 ptb-24">{{ e.description }}</td>
                            <td class="plr-8 ptb-24">{{ e.dateUpdate|date('d/m/Y') }}</td>
                            <td class="plr-8 ptb-24">{{ e.utilisateurUpdate }}</td>

                            {% if is_granted('ROLE_PREVIOUS_ADMIN') %}
                                <td class="plr-8 ptb-24 dtb-action">
                                    <a class="button-rond-xs align-middle" style="background-color: gray"><i class="fas fa-edit" style="color: white" title="Non accessible en consultation"></i></a>
                                </td>
                            {% else %}
                                <td class="plr-8 ptb-24 dtb-action">
                                    <a target="_blank" href="{{ path('entete_update', {localisation : e.localisation}) }}" class="button-rond-xs align-middle" title="Modifier"><i class="fas fa-edit"></i></a>
                                </td>
                            {% endif %}
                        </tr>
                    {% endfor %}#}
                    </tbody>
                </table>
            </div>
        </div>
    </div>





{% endblock %}