{% extends "pretixpresale/organizers/base.html" %}
{% load i18n %}
{% load icon %}
{% load rich_text %}
{% load eventurl %}
{% load urlreplace %}
{% block title %}
    {% blocktrans trimmed with month=date|date:"F Y" %}
        Events in {{ month }}
    {% endblocktrans %}
{% endblock %}
{% block content %}
    {% if organizer_homepage_text %}
        <div class="blank-after">
            {{ organizer_homepage_text | rich_text }}
        </div>
    {% endif %}
    <div class="blank-after text-left flip">
        {% include "pretixpresale/fragment_calendar_nav.html" with date=date request=request style="calendar" %}
    </div>
    <div class="panel panel-default">
        <div class="panel-heading">
            <h2 class="panel-title">
                <strong>
                {% blocktrans trimmed with month=date|date:"F Y" %}
                    Events in {{ month }}
                {% endblocktrans %}
                </strong>
            </h2>
        </div>
        {% if filter_form.fields %}
            <div class="panel-subhead">
                {% include "pretixpresale/fragment_event_list_filter.html" with request=request %}
            </div>
        {% endif %}
        <div class="panel-body">
            <nav aria-label="{% trans "calendar navigation" %}">
                <ul class="row calendar-nav">
                    <li class="text-left flip">
                        {% if has_before %}
                            <a href="?{% url_replace request "date" before|date:"Y-m" %}"
                               class="btn btn-default" data-save-scrollpos aria-label="{{ before|date:"F Y" }}">
                                {% icon "arrow-left" %}
                                <span class="hidden-xs">{{ before|date:"F Y" }}</span>
                            </a>
                        {% endif %}
                    </li>
                    <li class="text-center">
                        <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 %}
                            <fieldset>
                                <legend class="sr-only">{% trans "Select a month to display" %}</legend>
                                <div>
                                    <label for="calendar-input-date">{% trans "Month" %}</label>
                                </div>
                                <div class="input-group">
                                    <select name="date" class="form-control" id="calendar-input-date">
                                    {% for y in years %}
                                        <optgroup label="{{ y }}">
                                        {% for m in months %}
                                            <option value="{{ y }}-{{ m|date:"m" }}" {% if m.month == date.month and y == date.year %}selected{% endif %}>{{ m|date:"F" }} {{ y }}</option>
                                        {% endfor %}
                                        </optgroup>
                                    {% endfor %}
                                    </select>
                                    <span class="input-group-btn">
                                        <button type="submit" class="btn btn-default" aria-label="{% trans "Show month" %}">
                                            {% icon "chevron-right" %}
                                        </button>
                                    </span>
                                </div>
                            </fieldset>
                        </form>
                    </li>
                    <li class="text-right flip">
                        {% if has_after %}
                            <a href="?{% url_replace request "date" after|date:"Y-m" %}"
                               class="btn btn-default" data-save-scrollpos aria-label="{{ after|date:"F Y" }}">
                                <span class="hidden-xs">{{ after|date:"F Y" }}</span>
                                {% icon "arrow-right" %}
                            </a>
                        {% endif %}
                    </li>
                </ul>
            </nav>
            {% include "pretixpresale/fragment_calendar.html" with show_avail=request.organizer.settings.event_list_availability %}
        </div>
    </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 %}
