{% load compress %}
{% load staticfiles %}
{% load i18n %}
{% load statici18n %}
<!DOCTYPE html>
<html>
	<head>
		<title>{% block title %}{% endblock %}{% if url_name != "index" %} :: {% endif %}
            {{ settings.PRETIX_INSTANCE_NAME }}</title>
		{% compress css %}
    		<link rel="stylesheet" type="text/x-scss" href="{% static "pretixcontrol/scss/main.scss" %}" />
		{% endcompress %}
        {% if DEBUG %}
            <script type="text/javascript" src="{% url 'javascript-catalog' lang=request.LANGUAGE_CODE %}" async></script>
        {% else %}
            <script src="{% statici18n LANGUAGE_CODE %}" async></script>
        {% endif %}
		{% compress js %}
            <script type="text/javascript" src="{% static "jquery/js/jquery-2.1.1.min.js" %}"></script>
            <script type="text/javascript" src="{% static "js/jquery.formset.js" %}"></script>
            <script type="text/javascript" src="{% static "typeahead/typeahead.bundle.js" %}"></script>
            <script type="text/javascript" src="{% static "bootstrap/js/bootstrap.js" %}"></script>
            <script type="text/javascript" src="{% static "moment/moment-with-locales.js" %}"></script>
            <script type="text/javascript" src="{% static "datetimepicker/bootstrap-datetimepicker.js" %}"></script>
            <script type="text/javascript" src="{% static "charts/raphael-min.js" %}"></script>
            <script type="text/javascript" src="{% static "charts/morris.js" %}"></script>
            <script type="text/javascript" src="{% static "clipboard/clipboard.js" %}"></script>
            <script type="text/javascript" src="{% static "pretixcontrol/js/jquery.qrcode.min.js" %}"></script>
            <script type="text/javascript" src="{% static "pretixcontrol/js/clipboard.js" %}"></script>
            <script type="text/javascript" src="{% static "pretixcontrol/js/menu.js" %}"></script>
            <script type="text/javascript" src="{% static "pretixcontrol/js/sb-admin-2.js" %}"></script>
		    <script type="text/javascript" src="{% static "pretixcontrol/js/ui/main.js" %}"></script>
            <script type="text/javascript" src="{% static "pretixcontrol/js/ui/quota.js" %}"></script>
            <script type="text/javascript" src="{% static "pretixcontrol/js/ui/question.js" %}"></script>
            <script type="text/javascript" src="{% static "pretixcontrol/js/ui/mail.js" %}"></script>
            <script type="text/javascript" src="{% static "pretixbase/js/asynctask.js" %}"></script>
            <script type="text/javascript" src="{% static "pretixbase/js/asyncdownload.js" %}"></script>
		{% endcompress %}
        {{ html_head|safe }}
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="icon" href="{% static "pretixbase/img/favicon.ico" %}">
	</head>
	<body data-datetimeformat="{{ js_datetime_format }}" data-dateformat="{{ js_date_format }}" data-datetimelocale="{{ js_locale }}" data-payment-weekdays-disabled="{{ js_payment_weekdays_disabled }}">
        <div id="wrapper">
            <nav class="navbar navbar-inverse navbar-static-top" role="navigation">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle"
                            data-toggle="collapse" data-target=".navbar-nav-collapse">
                        <span class="sr-only">{% trans "Toggle navigation" %}</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <button type="button" class="navbar-toggle navbar-events"
                            data-toggle="collapse" data-target=".navbar-events-collapse">
                        <i class="fa fa-calendar"></i><span class="caret"></span>
                    </button>
                    <a class="navbar-brand" href="{% url "control:index" %}">
                        <img src="{% static "pretixbase/img/pretix-icon.svg" %}" />
                        {{ settings.PRETIX_INSTANCE_NAME }}
                    </a>
                </div>
                <ul class="nav navbar-nav navbar-top-links navbar-left hidden-xs">
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-calendar"></i>
                            {{ request.event }} <span class="caret"></span></a>
                        <ul class="dropdown-menu" role="menu">
                            <li><a href="{% url "control:events" %}">{% trans "Event overview" %}</a></li>
                            {% regroup request.user.events_cache by organizer as event_list %}
                            {% for g in event_list %}
                                <li class="dropdown-header">{{ g.grouper }}</li>
                                {% for e in g.list %}
                                    <li><a href="{% url "control:event.index" organizer=g.grouper.slug event=e.slug %}">{{ e.name }}</a></li>
                                {% endfor %}
                            {% endfor %}
                        </ul>
                    </li>
                </ul>
                <ul class="nav navbar-nav navbar-top-links navbar-right">
                    {% for nav in nav_topbar %}
                        <li {% if nav.children %}class="dropdown"{% endif %}>
                            <a href="{{ nav.url }}" title="{{ nav.title }}" {% if nav.active %}class="active"{% endif %}
                                    {% if nav.children %}class="dropdown-toggle" data-toggle="dropdown"{% endif %}>
                                {% if nav.icon %}
                                    <span class="fa fa-{{ nav.icon }}"></span>
                                    <span class="visible-xs-inline">{{ nav.label }}</span>
                                {% else %}
                                    {{ nav.label }}
                                {% endif %}
                            </a>
                            {% if nav.children %}
                                <ul class="dropdown-menu" role="menu">
                                    {% for item in nav.children %}
                                        <li>
                                            <a href="{{ item.url }}"
                                                    {% if item.active %}class="active"{% endif %}>
                                                {% if item.icon %}
                                                    <span class="fa fa-{{ item.icon }}"></span>
                                                {% endif %}
                                                {{ item.label|safe }}
                                            </a>
                                        </li>
                                    {% endfor %}
                                </ul>
                            {% endif %}
                        </li>
                    {% endfor %}

                    {% if warning_update_available %}
                        <li>
                            <a href="{% url 'control:global.update' %}" class="danger">
                                <i class="fa fa-bell"></i>
                            </a>
                        </li>
                    {% endif %}
                    <li>
                        <a href="{% url 'control:user.settings' %}" title="{% trans "Account Settings" %}" >
                            <i class="fa fa-user"></i> {{ request.user.get_full_name }}
                        </a>
                    </li>
                    <li>
                        <a href="{% url 'control:auth.logout' %}" title="{% trans "Log out" %}">
                            <i class="fa fa-sign-out"></i>
                            <span class="visible-xs-inline">{% trans "Log out" %}</span>
                        </a>
                    </li>
                </ul>
                <div class="navbar-default sidebar" role="navigation">
                    <div class="sidebar-nav navbar-events-collapse navbar-collapse hidden-sm hidden-md hidden-lg">
                        <ul class="nav">
                            <li><a href="{% url "control:events" %}">{% trans "Event overview" %}</a></li>
                            {% for e in request.user.events_cache %}
                                <li>
                                    <a href="{% url "control:event.index" organizer=e.organizer.slug event=e.slug %}">
                                        {{ e.name }}
                                    </a>
                                </li>
                            {% endfor %}
                        </ul>
                    </div>
                    <div class="sidebar-nav navbar-nav-collapse navbar-collapse">
                        <ul class="nav" id="side-menu">
                            {% block nav %}
                                <li>
                                    <a href="{% url 'control:index' %}" {% if url_name == "index" %}class="active"{% endif %}>
                                        <i class="fa fa-dashboard fa-fw"></i>
                                        {% trans "Dashboard" %}
                                    </a>
                                </li>
                                {% if request.user.is_superuser %}
                                    <li>
                                        <a href="{% url 'control:global.settings' %}"
                                                {% if "global.settings" in url_name %}class="active"{% endif %}>
                                            <i class="fa fa-wrench fa-fw"></i>
                                            {% trans "Global settings" %}
                                        </a>
                                    </li>
                                {% endif %}
                                <li>
                                    <a href="{% url 'control:events' %}" {% if "events" in url_name %}class="active"{% endif %}>
                                        <i class="fa fa-calendar fa-fw"></i>
                                        {% trans "Events" %}
                                    </a>
                                </li>
                                <li>
                                    <a href="{% url 'control:organizers' %}" {% if "organizer" in url_name %}class="active"{% endif %}>
                                        <i class="fa fa-users fa-fw"></i>
                                        {% trans "Organizers" %}
                                    </a>
                                </li>
                                {% for nav in nav_global %}
                                    <li>
                                        <a href="{{ nav.url }}" {% if nav.active %}class="active"{% endif %}
                                                {% if nav.children %}class="has-children"{% endif %}>
                                            {% if nav.icon %}
                                                <i class="fa fa-{{ nav.icon }} fa-fw"></i>
                                            {% endif %}
                                            {{ nav.label }}
                                        </a>
                                        {% if nav.children %}
                                            <a href="#" class="arrow">
                                                <span class="fa arrow"></span>
                                            </a>
                                            <ul class="nav nav-second-level">
                                                {% for item in nav.children %}
                                                    <li>
                                                        <a href="{{ item.url }}"
                                                                {% if item.active %}class="active"{% endif %}>
                                                            {{ item.label }}
                                                        </a>
                                                    </li>
                                                {% endfor %}
                                            </ul>
                                        {% endif %}
                                    </li>
                                {% endfor %}
                            {% endblock %}
                        </ul>
                    </div>
                </div>
            </nav>
            <div id="page-wrapper">
                <div class="container-fluid">
                    {% if messages %}
                        {% for message in messages %}
                            <div class="alert {{ message.tags }}">
                                {{ message }}
                            </div>
                        {% endfor %}
                    {% endif %}
                    {% if warning_update_check_active %}
                        <div class="alert alert-info">
                            <a href="{% url "control:global.update" %}">
                                {% blocktrans trimmed %}
                                    Starting with version 1.2.0, pretix automatically checks for updates in the background.
                                    During this check, anonymous data is transmitted to servers operated by pretix'
                                    developers. Click on this message to find out more, disable this feature or enter your
                                    email address to get notified via email if a new update arrives. This message will
                                    disappear once you clicked it.
                                {% endblocktrans %}
                            </a>
                        </div>
                    {% endif %}

                    {% if debug_warning %}
                        <div class="alert alert-danger">
                            {% trans "pretix is running in debug mode. For security reasons, please never run debug mode on a production instance." %}
                        </div>
                    {% endif %}

                    {% block content %}
                    {% endblock %}
                    <footer>
                        {% with "href='http://pretix.eu'" as a_attr %}
                            {% blocktrans trimmed %}
                                powered by <a {{ a_attr }}>pretix</a>
                            {% endblocktrans %}
                        {% endwith %}
                        {% if development_warning %}
                            <span class="text-warning">&middot; {% trans "running in development mode" %}</span>
                        {% endif %}
                    </footer>
                </div>
            </div>
        </div>
        <div id="ajaxerr">
        </div>
        <div id="loadingmodal">
            <i class="fa fa-cog big-rotating-icon"></i>
            <h1>{% trans "We are processing your request …" %}</h1>
            <p>
                {% trans "If this takes longer than a few minutes, please contact us." %}
            </p>
        </div>
	</body>
</html>
