{% load i18n %}
{% load eventurl %}
{% include "pretixpresale/fragment_event_list_filter.html" with request=request %}
<ul class="list-unstyled">
{% for subev in subevent_list.subevent_list %}
    <li class="subevent-row">
        <a href="{% if request.GET.voucher %}{% eventurl event "presale:event.redeem" cart_namespace=cart_namespace %}?voucher={{ request.GET.voucher|urlencode }}&subevent={{ subev.pk }}{% else %}{% eventurl event "presale:event.index" subevent=subev.id cart_namespace=cart_namespace %}{% endif %}">
        <div class="row">
            <div class="col-md-6">
                <strong>{{ subev.name }}</strong>
            </div>
            <div class="col-md-4">
                <span class="fa fa-calendar" aria-hidden="true"></span>
                {{ subev.get_date_range_display_as_html }}
                {% if event.settings.show_times %}
                    <span data-time="{{ subev.date_from.isoformat }}" data-timezone="{{ event.timezone }}" data-time-short>
                        <span class="fa fa-clock-o" aria-hidden="true"></span>
                        <time datetime="{{ subev.date_from.isoformat }}">{{ subev.date_from|date:"TIME_FORMAT" }}</time>
                    </span>
                {% endif %}
            </div>
            <div class="col-md-2 text-right flip">
                {% if subev.presale_is_running and event.settings.event_list_availability %}
                    {% if subev.best_availability_state == 100 %}
                        {% if subev.best_availability_is_low %}
                            <span class="label label-success-warning">{% trans "Few tickets left" %}</span>
                        {% else %}
                            {% if subev.has_paid_item %}
                                <span class="label label-success">{% trans "Buy now" context "available_event_in_list" %}</span>
                            {% else %}
                                <span class="label label-success">{% trans "Book now" %}</span>
                            {% endif %}
                        {% endif %}
                    {% elif event.waiting_list_active and subev.best_availability_state >= 0 %}
                        <span class="label label-warning">{% trans "Waiting list" %}</span>
                    {% elif subev.best_availability_state == 20 %}
                        <span class="label label-danger">{% trans "Reserved" %}</span>
                    {% elif subev.best_availability_state < 20 %}
                        {% if subev.has_paid_item %}
                            <span class="label label-danger">{% trans "Sold out" %}</span>
                        {% else %}
                            <span class="label label-danger">{% trans "Fully booked" %}</span>
                        {% endif %}
                    {% endif %}
                {% elif subev.presale_is_running %}
                    <span class="label label-success">{% trans "Book now" %}</span>
                {% elif subev.presale_has_ended %}
                    <span class="label label-danger">{% trans "Sale over" %}</span>
                {% elif event.settings.presale_start_show_date %}
                    <span class="label label-warning">
                                    {% blocktrans trimmed with date=subev.effective_presale_start|date:"SHORT_DATE_FORMAT" %}
                                        Sale starts {{ date }}
                                    {% endblocktrans %}
                                </span>
                {% else %}
                    <span class="label label-warning">{% trans "Not yet on sale" %}</span>
                {% endif %}
            </div>
        </div>
        </a>
    </li>
{% endfor %}
</ul>
