{% extends "base.html.twig" %}

{% block title %}{{ parent() }} - Liste des utilisateurs{%  endblock %}
{% block titre %}Liste des utilisateurs{%  endblock %}

{% block body %}
    <p><a class="btn btn-primary" href="{{  path("admin_createuser") }}" role="button">Créer un utiliisateur</a></p>

    <table class="table table-bordered table-hover table-sm">
        <thead class="thead-dark">
        <tr>
            <th>En ligne</th>
            <th>Username</th>
            <th>Prénom</th>
            <th>Nom</th>
            <th>Mail</th>
            <th>Dernière connexion</th>
            {#<th>Test Mail</th>#}
            <th>Roles</th>
            <th>Activé</th>
            <th>Actions</th>
        </tr>
        </thead>
        <tbody>
        {% for user in users %}
            <tr>
                <td >
                    {% if user.activeNow %}
                        <i class="fa fa-user text-success"></i>
                    {% else %}
                        <i class="fa fa-user-o text-secondary"></i>
                    {% endif %}
                </td>
                <td>{{ user.username }}</td>
                <td>{{ user.prenom }}</td>
                <td>{{ user.nom }}</td>
                <td>{{ user.mail }}</td>
                <td>{{ user.lastActivity | date("d/m/Y H:i")}}</td>
                {#<td><a href="{{ path('admin_sendmailtest', {"id": user.id}) }}">Envoyer un mail test</a></td>#}
                <td>{% for role in user.roles %}<p>{{ role }}</p>{% endfor %}</td>
                <td>{{ user.enabled }}</td>
                <td>
                    {%  if user != app.user %}
                        <a href="{{ path('admin_deluser', {'id': user.id})  }}"><i class="fa fa-trash fa-lg text-danger"></i></a>
                    {%  endif %}
                    <a href="{{ path('admin_edituser', {'id': user.id})  }}"><i class="fa fa-edit fa-lg text-primary"></i></a>
                    <a href="{{ path('admin_edituseroptions', {'id': user.profile.id}) }}"><i class="fa fa-cog fa-lg"></i></a>
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>

{% endblock %}