{% extends "pretixpresale/organizers/base.html" %}
{% load i18n %}
{% load rich_text %}
{% load eventurl %}
{% load urlreplace %}
{% block title %}{% trans "Event overview" %}{% endblock %}
{% block content %}
    {% if organizer_homepage_text %}
        <div>
            {{ organizer_homepage_text | rich_text }}
        </div>
    {% endif %}
    <h3>{{ date|date:"F Y" }}</h3>
    <form class="form-inline" method="get" id="monthselform"
          action="{% eventurl request.organizer "presale:organizer.index" %}">
        {% for f, v in request.GET.items %}
            {% if f != "date" %}
                <input type="hidden" name="{{ f }}" value="{{ v }}">
            {% endif %}
        {% endfor %}
        <div class="row">
            <div class="col-md-4 col-sm-6 col-xs-12 text-left flip">
                {% include "pretixpresale/fragment_calendar_nav.html" with date=date request=request style="week" %}
            </div>
            <div class="col-md-4 col-sm-4 col-xs-8 text-center">
                <select name="date" class="form-control" aria-label="{% trans "Select week to show" %}">
                {% for weeks_per_year in weeks %}
                    <optgroup label="{{ weeks_per_year.0.0.year }}">
                    {% for w in weeks_per_year %}
                        <option value="{{ w.0.isocalendar.0 }}-W{{ w.0.isocalendar.1 }}"
                                {% if w.0.isocalendar.0 == date.isocalendar.0 and w.0.isocalendar.1 == date.isocalendar.1 %}selected{% endif %}>
                                {{ w.0|date:week_format }}
                            ({{ w.0|date:short_month_day_format }} – {{ w.1|date:short_month_day_format }})
                        </option>
                    {% endfor %}
                    </optgroup>
                {% endfor %}
                </select>
                <button type="submit" class="js-hidden btn btn-default">
                    {% trans "Go" %}
                </button>
            </div>
            <div class="col-md-4 col-sm-2 col-xs-4 text-right flip">
                {% if has_before %}
                    <a href="?{% url_replace request "date" before|date:"o-\WW" %}"
                       class="btn btn-default" data-save-scrollpos aria-label="{{ before|date:week_format }}">
                        <span class="fa fa-arrow-left" aria-hidden="true"></span>
                        <span class="hidden-sm hidden-xs">{{ before|date:week_format }}</span>
                    </a>
                {% endif %}
                {% if has_after %}
                    <a href="?{% url_replace request "date" after|date:"o-\WW" %}"
                       class="btn btn-default" data-save-scrollpos aria-label="{{ after|date:week_format }}">
                        <span class="hidden-sm hidden-xs">{{ after|date:week_format }}</span>
                        <span class="fa fa-arrow-right" aria-hidden="true"></span>
                    </a>
                {% endif %}
            </div>
        </div>
    </form>
    {% include "pretixpresale/fragment_event_list_filter.html" with request=request %}
    {% include "pretixpresale/fragment_week_calendar.html" with show_avail=request.organizer.settings.event_list_availability %}
    <div class="col-sm-12 visible-sm visible-xs text-center">
        {% if has_before %}
            <a href="?{% url_replace request "date" before|date:"o-\WW" %}"
               class="btn btn-default">
                <span class="fa fa-arrow-left" aria-hidden="true"></span>
                {{ before|date:week_format }}
            </a>
        {% endif %}
        {% if has_after %}
            <a href="?{% url_replace request "date" after|date:"o-\WW" %}"
               class="btn btn-default">
                {{ after|date:week_format }}
                <span class="fa fa-arrow-right" aria-hidden="true"></span>
            </a>
        {% endif %}
    </div>

    {% if multiple_timezones %}
        <div class="alert alert-info">
            {% blocktrans trimmed %}
                Note that the events in this view are in different timezones.
            {% endblocktrans %}
        </div>
    {% endif %}
{% endblock %}
