{% extends "pretixcontrol/items/base.html" %}
{% load i18n %}
{% load bootstrap3 %}
{% load urlreplace %}
{% block title %}{% trans "Check-in lists" %}{% endblock %}
{% block inside %}
    <h1>{% trans "Check-in lists" %}</h1>
    <p>
        {% blocktrans trimmed %}
            You can create check-in lists that you can use e.g. at the entrance of your event to track who is coming
            and if they actually bought a ticket. You can do this process by printing out the list on paper, using this
            web interface or by using one of our mobile or desktop apps to automatically scan tickets.
        {% endblocktrans %}
    </p>
    <p>
        {% blocktrans trimmed %}
            You can create multiple check-in lists to separate multiple parts of your event, for example if you have
            separate entries for multiple ticket types. Different check-in lists are completely independent: If a ticket
            shows up on two lists, it is valid once on every list. This might be useful if you run a festival with
            festival passes that allow access to every or multiple performances as well as tickets only valid for single
            performances.
        {% endblocktrans %}
    </p>
    <p>
        {% blocktrans trimmed %}
            If you have the appropriate organizer-level permissions, you can connect new devices to your account and
            use them to validate tickets. Since the devices are connected on the organizer level, you do not have to
            create a new device for every event but can reuse them over and over again.
        {% endblocktrans %}
    </p>
    {% if request.event.has_subevents %}
        <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">
                    {% if filter_form.subevent %}
                        <div class="col-md-12 col-sm-12 col-xs-12">
                            {% bootstrap_field filter_form.subevent %}
                        </div>
                    {% endif %}
                </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>
    {% endif %}
    {% if checkinlists|length == 0 %}
        <div class="empty-collection">
            <p>
                {% if request.GET.subevent %}
                    {% trans "Your search did not match any check-in lists." %}
                {% else %}
                    {% blocktrans trimmed %}
                        You haven't created any check-in lists yet.
                    {% endblocktrans %}
                {% endif %}
            </p>

            {% if "can_change_event_settings" in request.eventpermset %}
                <a href="{% url "control:event.orders.checkinlists.add" organizer=request.event.organizer.slug event=request.event.slug %}"
                   class="btn btn-primary btn-lg"><i class="fa fa-plus"></i> {% trans "Create a new check-in list" %}
                </a>
            {% endif %}
            {% if can_change_organizer_settings %}
                <a href="{% url "control:organizer.devices" organizer=request.organizer.slug %}"
                   class="btn btn-default btn-lg"><i class="fa fa-tablet"></i> {% trans "Connected devices" %}</a>
            {% endif %}
        </div>
    {% else %}
        <p>
            {% if "can_change_event_settings" in request.eventpermset %}
                <a href="{% url "control:event.orders.checkinlists.add" organizer=request.event.organizer.slug event=request.event.slug %}"
                   class="btn btn-default"><i class="fa fa-plus"></i> {% trans "Create a new check-in list" %}</a>
            {% endif %}
            {% if can_change_organizer_settings %}
                <a href="{% url "control:organizer.devices" organizer=request.organizer.slug %}"
                   class="btn btn-default"><i class="fa fa-tablet"></i> {% trans "Connected devices" %}</a>
            {% endif %}
        </p>
        <div class="table-responsive">
            <table class="table table-hover table-quotas">
                <thead>
                <tr>
                    <th>
                        {% trans "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 "Checked in" %}</th>
                    {% if request.event.has_subevents %}
                        <th>
                            {% trans "Date" context "subevent" %}
                            <a href="?{% url_replace request 'ordering' '-subevent' %}"><i class="fa fa-caret-down"></i></a>
                            <a href="?{% url_replace request 'ordering' 'subevent' %}"><i class="fa fa-caret-up"></i></a>
                        </th>
                    {% endif %}
                    <th class="iconcol">{% trans "Automated check-in" %}</th>
                    <th>{% trans "Products" %}</th>
                    <th class="action-col-2"></th>
                </tr>
                </thead>
                <tbody>
                {% for cl in checkinlists %}
                    <tr>
                        <td>
                            <strong><a
                                    href="{% url "control:event.orders.checkinlists.show" organizer=request.event.organizer.slug event=request.event.slug list=cl.id %}">{{ cl.name }}</a></strong>
                        </td>
                        <td>
                            <div class="quotabox availability">
                                <div class="progress">
                                    <div class="progress-bar progress-bar-success progress-bar-{{ cl.percent }}">
                                    </div>
                                </div>
                                <div class="numbers">
                                    {{ cl.checkin_count|default_if_none:"0" }} /
                                    {{ cl.position_count|default_if_none:"0" }}
                                </div>
                            </div>
                        </td>
                        {% if request.event.has_subevents %}
                            {% if cl.subevent %}
                                <td>
                                    {{ cl.subevent.name }} – {{ cl.subevent.get_date_range_display }}
                                    {{ cl.subevent.date_from|date:"TIME_FORMAT" }}
                                </td>
                            {% else %}
                                <td>
                                    <em>{% trans "All" %}</em>
                                </td>
                            {% endif %}
                        {% endif %}
                        <td>
                            {% for channel in cl.auto_checkin_sales_channels %}
                                <span class="fa fa-{{ channel.icon }} text-muted"
                                      data-toggle="tooltip" title="{% trans channel.verbose_name %}"></span>
                            {% endfor %}
                        </td>
                        <td>
                            {% if cl.all_products %}
                                <em>{% trans "All" %}</em>
                            {% else %}
                                <ul>
                                    {% for item in cl.limit_products.all %}
                                        <li>
                                            <a href="{% url "control:event.item" organizer=request.event.organizer.slug event=request.event.slug item=item.id %}">{{ item }}</a>
                                        </li>
                                    {% endfor %}
                                </ul>
                            {% endif %}
                        </td>
                        <td class="text-right flip">
                            <a href="{% url "control:event.orders.checkinlists.show" organizer=request.event.organizer.slug event=request.event.slug list=cl.id %}"
                               class="btn btn-default btn-sm"><i class="fa fa-eye"></i></a>
                            {% if "can_change_event_settings" in request.eventpermset %}
                                <a href="{% url "control:event.orders.checkinlists.add" organizer=request.event.organizer.slug event=request.event.slug %}?copy_from={{ cl.id }}"
                                   class="btn btn-sm btn-default" title="{% trans "Clone" %}" data-toggle="tooltip">
                                    <span class="fa fa-copy"></span>
                                </a>
                                <a href="{% url "control:event.orders.checkinlists.simulator" organizer=request.event.organizer.slug event=request.event.slug list=cl.id %}"
                                   title="{% trans "Check-in simulator" %}" data-toggle="tooltip"
                                   class="btn btn-default btn-sm"><i class="fa fa-flask"></i></a>
                                <a href="{% url "control:event.orders.checkinlists.edit" organizer=request.event.organizer.slug event=request.event.slug list=cl.id %}"
                                   class="btn btn-default btn-sm"><i class="fa fa-wrench"></i></a>
                                <a href="{% url "control:event.orders.checkinlists.delete" organizer=request.event.organizer.slug event=request.event.slug list=cl.id %}"
                                   class="btn btn-danger btn-sm"><i class="fa fa-trash"></i></a>
                            {% endif %}
                        </td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>
    {% endif %}
    {% include "pretixcontrol/pagination.html" %}
{% endblock %}
