{% extends 'Admin/layout.html.twig' %}

{% trans_default_domain 'form' %}

{% block body %}
    {% if is_granted('ROLE_ADMIN_FULL') %}
        <h1>Derniers inscrits</h1>
        <table class="tableBo">
            <thead>
                <tr>
                    <td>{{ 'form.date.creation.label'|trans }}</td>
                    <td>{{ 'form.firstname.label'|trans }}</td>
                    <td>{{ 'form.lastname.label'|trans }}</td>
                    <td>{{ 'form.type.label'|trans }}</td>
                    <td>{{ 'form.itdlc.demande.label'|transchoice(2) }}</td>
                    <td title="Concerne les opérations ouvertes seulement">{{ 'form.pee.demande.label'|transchoice(2) }}</td>
                    <td>{{ 'form.newsletter.label'|trans }}</td>
                </tr>
            </thead>
            <tbody>
                {% for user in users %}
                    <tr>
                        <td class="center">
                            <a href="{{ path('admin_user_edit', {'user':user.id}) }}">{{ user.created|date('d/m/Y') }}</a>
                        </td>
                        <td>
                            <a href="{{ path('admin_user_edit', {'user':user.id}) }}">
                                {% if user.firstname is defined %}
                                    {{ user.firstname }}
                                {% endif %}
                            </a>
                        </td>
                        <td>
                            <a href="{{ path('admin_user_edit', {'user':user.id}) }}">
                                {% if user.lastname is defined %}
                                    {{ user.lastname }}
                                {% endif %}
                            </a>
                        </td>
                        <td class="center">
                            <a href="{{ path('admin_user_edit', {'user':user.id}) }}">
                                {{ ('word.type.user.' ~ user.type ~ '.label')|trans({}, 'word') }}
                            </a>
                        </td>
                        <td class="center">{{ users_demandes_nb[user.id]['itdlc'] }}</td>
                        <td class="center">{{ users_demandes_nb[user.id]['pee'] }}</td>
                        <td class="center">
                            {% set icon_name = user.newsletter ? 'ok' : 'ko' %}
                            {% set icon_label = user.newsletter ? 'word.yes'|trans({}, 'word') : 'word.no'|trans({}, 'word') %}
                            <img class="icon" src="{{ asset('admin/images/screen/states/picto-' ~ icon_name ~ '.svg') }}" alt="{{ icon_label }}"/>
                        </td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    {% endif %}
{% endblock %}
