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

{% block title %}Admin Bereich - Userverwaltung{% endblock %}

{% block body %}    
    <h1>Admin - Userverwaltung</h1>
    <div class="new-user">
        <a href="{{ path('admin_add_user') }}" class="btn">Neuen Benutzer anlegen</a>
    </div>
    <div class="listing">
        <ul>
            {% for user in users %}
            <li data-userid="{{ user.id }}" data-username="{{ user.firstname }} {{ user.lastname }}"{% if not user.active %} class="inactive"{% endif %}>
                <div class="listing--header">
                    <h3>{{ user.firstname }} {{ user.lastname }}{% if not user.active %} (inaktiv){% endif %}</h3>
                    <div class="buttons">
                        <div class="pdfs">
                            {% set i = 1 %}
                            {% set cntWorksheets = user.worksheets|length %}
                            {% for worksheet in user.worksheets %}
                                <a href="{{ path('admin_user_worksheet', {'userWorksheetId': worksheet.id}) }}" title="Arbeitskarte abgeschlossen am: {{ worksheet.creationDate | date("d.m.Y H:i") }}" {{ i == cntWorksheets ? 'class="latest"' : '' }}></a>
                                {% set i = i + 1 %}
                            {% endfor %}
                        </div>
                        <button class="btn" data-js="listing--opener">Details bearbeiten</button>
                        <button class="btn" data-js="listing--password">Passwort erneut senden</button>
                    </div>
                </div>
                <div class="listing--details">
                    <div class="listing--details-inside">
                        {% include 'snippets/listing-form.html.twig' with {
                            data: {
                                'user': user
                            }
                        } %}
                    </div>
                </div>
            </li>
{#                {{ dump(user) }}#}
            {% endfor %}
        </ul>
    </div>
{% endblock %}
