{% extends "pretixcontrol/organizers/base.html" %}
{% load i18n %}
{% load urlreplace %}
{% load bootstrap3 %}
{% block inner %}
    <h1>{% trans "Teams" %}</h1>
    <p>
        {% trans "The list below shows all teams that exist within this organizer." %}
    </p>
    <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-xs-12">
                    {% bootstrap_field filter_form.query layout='inline' %}
                </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>
    <a href="{% url "control:organizer.team.add" organizer=request.organizer.slug %}" class="btn btn-default">
        <span class="fa fa-plus"></span>
        {% trans "Create a new team" %}
    </a>
    <table class="table table-condensed table-hover">
        <thead>
        <tr>
            <th>{% trans "Team name" %}
                <a href="?{% url_replace request 'ordering' '-name' %}"><i class="fa fa-caret-down"></i></a>
                <a href="?{% url_replace request 'ordering' 'name' %}"><i class="fa fa-caret-up"></i></a></th>
            <th>{% trans "Members" %}</th>
            <th>{% trans "Events" %}</th>
            <th></th>
        </tr>
        </thead>
        <tbody>
        {% for t in teams %}
            <tr>
                <td><strong>
                    <a href="{% url "control:organizer.team" organizer=request.organizer.slug team=t.id %}">
                        {{ t.name }}
                    </a>
                </strong></td>
                <td>
                    {{ t.memcount }}
                    {% if t.invcount %}
                        {% blocktrans trimmed with count=t.invcount %}
                            + {{ count }} invited
                        {% endblocktrans %}
                    {% endif %}
                </td>
                <td>
                    {% if t.all_events %}
                        {% trans "All" %}
                    {% else %}
                        {{ t.eventcount }}
                    {% endif %}
                </td>
                <td class="text-right flip">
                    <a href="{% url "control:organizer.team" organizer=request.organizer.slug team=t.id %}"
                            class="btn btn-default btn-sm"><i class="fa fa-list"></i></a>
                    <a href="{% url "control:organizer.team.edit" organizer=request.organizer.slug team=t.id %}"
                            class="btn btn-default btn-sm"><i class="fa fa-edit"></i></a>
                    <a href="{% url "control:organizer.team.delete" organizer=request.organizer.slug team=t.id %}"
                            class="btn btn-danger btn-sm"><i class="fa fa-trash"></i></a>
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
    {% include "pretixcontrol/pagination.html" %}
{% endblock %}
