{% extends 'admin/base.html.twig' %}

{% block title %}{{ 'trans.User list' | trans }}{% endblock %}

{% block body %}
<div class="mt-3">
    <div class="row no-gutters mb-2">
        <div class="col-md-6">
            <h1>{{ 'trans.User list' | trans }}</h1>
        </div>
        <div class="col-md-6">
            <div>
                <form method="get" class="mt-2 mt-md-0" role="search">
                    <div class="input-group">
                        <div class="input-group-prepend">
                            <div class="input-group-text"><i class="fas fa-search"></i></div>
                        </div>
                        <input
                                type="text"
                                name="query"
                                value="{{ app.request.query.get('query') }}"
                                class="form-control"
                                placeholder="user*@gmail.com  |  john@*  |  john@gm?il.com"
                        />
                        <button type="submit" class="btn btn-primary ml-1">{{ 'trans.Search' | trans }}</button>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <table class="table table-responsive-sm">
        <thead>
            <tr>
                <th class="mw-8-rem">{{ 'trans.Email' | trans }}</th>
                <th>{{ 'trans.Enabled' | trans }}</th>
                <th class="mw-8-rem">{{ 'trans.Registration date' | trans }}</th>
                <th class="mw-8-rem">{{ 'trans.Last login' | trans }}</th>
                <th></th>
            </tr>
        </thead>
        <tbody>
        {% for user in users %}
            <tr>
                <td>
                    <div>{{ 'trans.Email' | trans }}: <strong class="text-break">{{ user.email }}</strong></div>
                    <div class="text-break">{{ 'trans.Username' | trans }}: {{ user.username }}</div>
                </td>
                <td>
                    <span class="{{ user.enabled | boolGreenRedClass }}">
                        {{- user.enabled | boolText | trans -}}
                    </span>
                </td>
                <td>{{ user.registrationDate ? user.registrationDate | date : '' }}</td>
                <td>{{ user.lastLogin ? user.lastLogin | date : '' }}</td>
                <td class="text-right">
                    <a href="{{ path('app_admin_user_edit', {'id': user.id}) }}" class="btn btn-primary">
                        {{- 'trans.Edit' | trans -}}
                    </a>
                </td>
            </tr>
        {% else %}
            <tr>
                <td colspan="99">{{ 'trans.no records found' | trans }}</td>
            </tr>
        {% endfor %}
        </tbody>
    </table>

    {% include 'base/_pagination.html.twig' %}
</div>
{% endblock %}
