{% extends "pretixcontrol/base.html" %}
{% load i18n %}
{% load bootstrap3 %}
{% load formset_tags %}
{% block custom_header %}
    {{ block.super }}
    <link type="text/css" rel="stylesheet" href="{% url "control:pdf.css" %}">
{% endblock %}
{% block title %}{% trans "Organizer" %}{% endblock %}
{% block content %}
    <h1>
        {% blocktrans with name=organizer.name %}Organizer settings{% endblocktrans %}
        {% if request.user.is_staff and staff_session %}
            <a href="{% url "control:organizer.delete" organizer=organizer.slug %}"
                    class="btn btn-danger hidden-print">
                <span class="fa fa-trash"></span>
            </a>
        {% endif %}
    </h1>

    <form action="" method="post" class="form-horizontal" enctype="multipart/form-data">
        {% csrf_token %}
        {% bootstrap_form_errors sform %}
        {% bootstrap_form_errors form %}
        <div class="tabbed-form">
            <fieldset>
                <legend>{% trans "General" %}</legend>
                {% bootstrap_field form.name layout="control" %}
                {% bootstrap_field form.slug layout="control" %}
                {% if form.domain %}
                    {% bootstrap_field form.domain layout="control" %}
                {% endif %}
                {% bootstrap_field sform.organizer_info_text layout="control" %}
                {% bootstrap_field sform.event_team_provisioning layout="control" %}
            </fieldset>
            <fieldset>
                <legend>{% trans "Organizer page" %}</legend>
                {% bootstrap_field sform.organizer_logo_image layout="control" %}
                {% bootstrap_field sform.organizer_logo_image_large layout="control" %}
                {% bootstrap_field sform.organizer_homepage_text layout="control" %}
                {% bootstrap_field sform.event_list_type layout="control" %}
                {% bootstrap_field sform.event_list_availability layout="control" %}
                {% bootstrap_field sform.organizer_link_back layout="control" %}
            </fieldset>
            <fieldset>
                <legend>{% trans "Localization" %}</legend>
                {% bootstrap_field sform.locales layout="control" %}
            </fieldset>
            <fieldset>
                <legend>{% trans "Shop design" %}</legend>
                <p class="help-block">
                    {% blocktrans trimmed %}
                        These settings will be used for the organizer page as well as for the default settings
                        for all events in this account that do not have their own design settings.
                    {% endblocktrans %}
                </p>
                {% bootstrap_field sform.primary_color layout="control" %}
                {% bootstrap_field sform.theme_color_success layout="control" %}
                {% bootstrap_field sform.theme_color_danger layout="control" %}
                {% bootstrap_field sform.theme_color_background layout="control" %}
                {% bootstrap_field sform.theme_round_borders layout="control" %}
                {% bootstrap_field sform.primary_font layout="control" %}
                {% bootstrap_field sform.favicon layout="control" %}
            </fieldset>
            <fieldset>
                <legend>{% trans "Gift cards" %}</legend>
                {% bootstrap_field sform.giftcard_expiry_years layout="control" %}
                {% bootstrap_field sform.giftcard_length layout="control" %}
            </fieldset>
            <fieldset>
                <legend>{% trans "Event metadata" %}</legend>
                <p>
                    {% blocktrans trimmed %}
                        You can here define a set of metadata properties (i.e. variables) that you can later set for your
                        events and re-use in places like ticket layouts. This is an useful timesaver if you create lots and
                        lots of events.
                    {% endblocktrans %}
                </p>
                <div class="formset" data-formset data-formset-prefix="{{ formset.prefix }}">
                    {{ formset.management_form }}
                    {% bootstrap_formset_errors formset %}
                    <div data-formset-body>
                        {% for form in formset %}
                            <div class="row" data-formset-form>
                                <div class="sr-only">
                                    {{ form.id }}
                                    {% bootstrap_field form.DELETE form_group_class="" layout="inline" %}
                                </div>
                                <div class="col-md-5">
                                    {% bootstrap_form_errors form %}
                                    {% bootstrap_field form.name layout='inline' form_group_class="" %}
                                </div>
                                <div class="col-md-5 col-lg-6">
                                    {% bootstrap_field form.default layout='inline' form_group_class="" %}
                                </div>
                                <div class="col-md-2 col-lg-1 text-right flip">
                                    <button type="button" class="btn btn-danger" data-formset-delete-button>
                                        <i class="fa fa-trash"></i></button>
                                </div>
                            </div>
                        {% endfor %}
                    </div>
                    <script type="form-template" data-formset-empty-form>
                        {% escapescript %}
                            <div class="row" data-formset-form>
                                <div class="sr-only">
                                    {{ formset.empty_form.id }}
                                    {% bootstrap_field formset.empty_form.DELETE form_group_class="" layout="inline" %}
                                </div>
                                <div class="col-md-5">
                                    {% bootstrap_field formset.empty_form.name layout='inline' form_group_class="" %}
                                </div>
                                <div class="col-md-5 col-lg-6">
                                    {% bootstrap_field formset.empty_form.default layout='inline' form_group_class="" %}
                                </div>
                                <div class="col-md-2 col-lg-1 text-right flip">
                                    <button type="button" class="btn btn-danger" data-formset-delete-button>
                                        <i class="fa fa-trash"></i></button>
                                </div>
                            </div>
                        {% endescapescript %}
                    </script>
                    <p>
                        <button type="button" class="btn btn-default" data-formset-add>
                            <i class="fa fa-plus"></i> {% trans "Add property" %}</button>
                    </p>
                </div>
            </fieldset>
        </div>
        <div class="form-group submit-group">
            <button type="submit" class="btn btn-primary btn-save">
                {% trans "Save" %}
            </button>
        </div>
    </form>
{% endblock %}
