{% extends "pretixcontrol/event/base.html" %}
{% load i18n %}
{% load bootstrap3 %}
{% block title %}{% trans "Voucher tags" %}{% endblock %}
{% block content %}
    <h1>{% trans "Voucher tags" %}</h1>
    <p>
        {% blocktrans trimmed %}
            If you add a "tag" to a voucher, you can here see statistics on their usage.
        {% endblocktrans %}
    </p>
    {% if request.event.has_subevents %}
        <div class="row filter-form">
            <form class="" action="" method="get">
                    <div class="col-lg-2 col-sm-3 col-xs-6">
                        {% bootstrap_field filter_form.subevent layout='inline' %}
                    </div>
                <div class="col-lg-1 col-sm-6 col-xs-6">
                    <button class="btn btn-primary btn-block" type="submit">
                        <span class="fa fa-filter"></span>
                        <span class="hidden-md">
                                {% trans "Filter" %}
                            </span>
                    </button>
                </div>
            </form>
        </div>
    {% endif %}
    {% if tags|length == 0 %}
        <div class="empty-collection">
            <p>
                {% blocktrans trimmed %}
                    You haven't added any tags to vouchers yet.
                {% endblocktrans %}
            </p>
        </div>
    {% else %}
        <div class="table-responsive">
            <table class="table table-hover table-condensed">
                <thead>
                <tr>
                    <th>{% trans "Tag" %}</th>
                    <th>{% trans "Redeemed vouchers" %}</th>
                </tr>
                </thead>
                <tbody>
                {% for t in tags %}
                    <tr>
                        <td>
                            <strong>
                            {% if t.tag %}
                                <a href="{% url "control:event.vouchers" organizer=request.event.organizer.slug event=request.event.slug %}?tag={{ '"'|add:t.tag|add:'"'|urlencode }}">
                                    {{ t.tag }}
                                </a>
                            {% else %}
                                <a href="{% url "control:event.vouchers" organizer=request.event.organizer.slug event=request.event.slug %}?tag={{ '<>'|urlencode }}">
                                    {% trans "Empty tag" %}
                                </a>
                            {% endif %}
                            </strong> <small>({{ t.redeemed }} / {{ t.total }})</small>
                        </td>
                        <td>
                            <div class="progress">
                                <div class="progress-bar progress-bar-{{ t.percentage }}">
                                </div>
                            </div>
                        </td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>
    {% endif %}
{% endblock %}
