{% extends "pretixcontrol/base.html" %}
{% load i18n %}
{% load bootstrap3 %}
{% load urlreplace %}
{% block title %}{% trans "Users" %}{% endblock %}
{% block content %}
    <h1>{% trans "Users" %}</h1>
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">{% trans "Filter" %}</h3>
        </div>
        <form class="panel-body filter-form" action="" method="get">
            <div class="row">
                <div class="col-md-6 col-sm-6 col-xs-12">
                    {% bootstrap_field filter_form.query %}
                </div>
                <div class="col-md-3 col-sm-6 col-xs-12">
                    {% bootstrap_field filter_form.status %}
                </div>
                <div class="col-md-3 col-sm-6 col-xs-12">
                    {% bootstrap_field filter_form.superuser %}
                </div>
            </div>
            <div class="text-right">
                <button class="btn btn-primary btn-lg" type="submit">
                    <span class="fa fa-filter"></span>
                    {% trans "Filter" %}
                </button>
            </div>
        </form>
    </div>
    <p>
        <a href="{% url "control:users.add" %}" class="btn btn-default">
            <span class="fa fa-plus"></span>
            {% trans "Create a new user" %}
        </a>
    </p>
    <table class="table table-condensed table-hover">
        <thead>
        <tr>
            <th>
                {% trans "E-mail address" %}
                <a href="?{% url_replace request 'ordering' '-email' %}"><i class="fa fa-caret-down"></i></a>
                <a href="?{% url_replace request 'ordering' 'email' %}"><i class="fa fa-caret-up"></i></a>
            </th>
            <th>
                {% trans "Full name" %}
                <a href="?{% url_replace request 'ordering' '-fullname' %}"><i class="fa fa-caret-down"></i></a>
                <a href="?{% url_replace request 'ordering' 'fullname' %}"><i class="fa fa-caret-up"></i></a>
            </th>
            <th>{% trans "Active" %}</th>
            <th>{% trans "Administrator" %}</th>
            <th></th>
        </tr>
        </thead>
        <tbody>
        {% for u in users %}
            <tr>
                <td><strong>
                    <a href="{% url "control:users.edit" id=u.pk %}">{{ u.email }}</a>
                </strong></td>
                <td>{{ u.fullname|default_if_none:"" }}</td>
                <td>{% if u.is_active %}<span class="fa fa-check-circle"></span>{% endif %}</td>
                <td>{% if u.is_staff %}<span class="fa fa-check-circle"></span>{% endif %}</td>
                <td class="text-right flip">
                    <a href="{% url "control:users.edit" id=u.id %}" class="btn btn-default btn-sm"><i class="fa fa-edit"></i></a>
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
    {% include "pretixcontrol/pagination.html" %}
{% endblock %}
