{% load i18n %}
{% load eventurl %}
{% if download_email_required %}
    <div class="panel panel-primary">
        <div class="panel-heading">
            <h3 class="panel-title">
                {% trans "Ticket download" %}
            </h3>
        </div>
        <div class="panel-body text-center">
            <h4>
                <span class="fa fa-envelope text-muted fa-2x" aria-hidden="true"></span><br><br>
                {% if event.settings.mail_attach_tickets %}
                    {% trans "Please check your email account, we've sent you your tickets." %}
                {% else %}
                    {% trans "Please check your email account, we've sent you an email." %}
                {% endif %}
            </h4>
            <p class="text-muted">
                {% if position_page %}
                    {% blocktrans trimmed %}
                        You can download your tickets right here as soon as the person who placed the order clicked the
                        link in the email they received to confirm the email address is valid.
                    {% endblocktrans %}
                {% elif not event.settings.mail_attach_tickets %}
                    {% blocktrans trimmed %}
                        If you click the link in our email, you will be able to download your tickets here.
                    {% endblocktrans %}
                {% else %}
                    {% blocktrans trimmed %}
                        If the email has no attachment, click the link in our email and you will be able to download
                        them from here.
                    {% endblocktrans %}
                {% endif %}
            </p>
        </div>
    </div>
{% elif can_download and download_buttons and order.count_positions and tickets_with_download  %}
    <div class="info-download">
        <h3 class="sr-only">{% trans "Ticket download" %}</h3>
        {% if tickets_with_download|length > 1 and can_download_multi %} {# never True on ticket page #}
            <div>
            {% for b in download_buttons %}
                {% if b.multi %}
                    <form action="{% eventurl event "presale:event.order.download.combined" secret=order.secret order=order.code output=b.identifier %}"
                          method="post" data-asynctask data-asynctask-download class="download-btn-form">
                        {% csrf_token %}
                        <button type="submit"
                                class="btn btn-lg {% if b.identifier == "pdf" %}btn-primary{% else %}btn-default{% endif %}">
                            <span class="fa {{ b.icon }}" aria-hidden="true"></span> {{ b.multi_text }}
                        </button>
                    </form>
                {% endif %}
            {% endfor %}
            </div>
            <p class="help-block">
                {% blocktrans trimmed %}
                Please have your ticket ready when entering the event.
                {% endblocktrans %}
            </p>
        {% elif tickets_with_download|length == 1 %}
            <div>
                {% for b in download_buttons %}
                    <form action="{% if position_page and tickets_with_download.0.addon_to %}{% eventurl event "presale:event.order.position.download" secret=tickets_with_download.0.addon_to.web_secret order=order.code output=b.identifier pid=tickets_with_download.0.pk position=tickets_with_download.0.addon_to.positionid %}{% elif position_page %}{% eventurl event "presale:event.order.position.download" secret=tickets_with_download.0.web_secret order=order.code output=b.identifier pid=tickets_with_download.0.pk position=tickets_with_download.0.positionid %}{% else %}{% eventurl event "presale:event.order.download" secret=order.secret order=order.code output=b.identifier position=tickets_with_download.0.pk %}{% endif %}"
                          method="post" data-asynctask data-asynctask-download
                          class="download-btn-form{% if b.javascript_required %} requirejs{% endif %}">
                        {% csrf_token %}
                        <button type="submit"
                                class="btn btn-lg {% if b.identifier == "pdf" %}btn-primary{% else %}btn-default{% endif %}">
                            <span class="fa {{ b.icon }}" aria-hidden="true"></span> {{ b.long_text }}
                        </button>
                    </form>
                {% endfor %}
            </div>
            <p class="help-block">
                {% blocktrans trimmed %}
                Please have your ticket ready when entering the event.
                {% endblocktrans %}
            </p>
        {% else %}
        <p class="text-muted">
            {% blocktrans trimmed %}
                Please have your ticket ready when entering the event.
            {% endblocktrans %}<br>
            {% blocktrans trimmed %}
                Download your tickets using the buttons below.
            {% endblocktrans %}
        </p>
        {% endif %}
    </div>
{% elif not can_download and plugins_allow_ticket_download and ticket_download_date %}
    {% if order.status == 'p' %}
        <div class="alert alert-info info-download">
            {% blocktrans trimmed with date=ticket_download_date|date:"SHORT_DATE_FORMAT" %}
                You will be able to download your tickets here starting on {{ date }}.
            {% endblocktrans %}
        </div>
    {% endif %}
{% endif %}
