{% extends 'templates/admin-layout.twig' %}

{% block scripts %}
    {{ parent() }}
    <script>
        $(function () {
            $('#userTable').DataTable({
                fixedHeader: true,
                responsive: true
            });
        });
    </script>
{% endblock %}

{% block content %}
    <div id="page-wrapper">
        <div id="content-wrapper">
            {% include "templates/partials/flash.twig" %}

            <div class="row" style="margin-bottom: 15px">
                <div class="col-xs-12">
                    <a href="{{ path_for('admin.users.new') }}" class="btn btn-default pull-right">New User <i class="fa fa-user-plus"></i></a>
                </div>
            </div>

            {% if users %}
                <table id="userTable" class="table table-striped table-bordered table-hover">
                    <thead>
                    <tr>
                        <th>ID</th>
                        <th>First Name</th>
                        <th>Last Name</th>
                        <th>E-Mail-Address</th>
                        <th>Actions</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for user in users %}
                        <tr>
                            <td>{{ user.id }}</td>
                            <td>{{ user.firstName }}</td>
                            <td>{{ user.lastName }}</td>
                            <td>{{ user.email }}</td>
                            <td>
                                <a href="{{ path_for('admin.users.edit', {id: user.id}) }}" class="btn btn-primary" title="Edit user">
                                    <i class="fa fa-pencil-square-o"></i>
                                </a>
                                <a href="{{ path_for('admin.users.resetPassword', {id: user.id}) }}" class="btn btn-warning" title="Reset password">
                                    <i class="fa fa-key"></i>
                                </a>
                                <a href="{{ path_for('admin.users.delete', {id: user.id}) }}" class="btn btn-danger" title="Delete user">
                                    <i class="fa fa-user-times"></i>
                                </a>
                            </td>
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>
            {% else %}
                <div class="alert alert-info alert-dismissable" style="text-align: center;" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    No Users found
                </div>
            {% endif %}
        </div>
    </div>
{% endblock %}