{% 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="row">
            <div class="col-xs-12 col-lg-10">
                <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.imprint_url layout="control" %}
                        {% bootstrap_field sform.contact_mail layout="control" %}
                        {% bootstrap_field sform.organizer_info_text layout="control" %}
                        {% bootstrap_field sform.event_team_provisioning layout="control" %}
                        {% if sform.allowed_restricted_plugins %}
                            {% bootstrap_field sform.allowed_restricted_plugins layout="control" %}
                        {% endif %}
                    </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_logo_image_inherit 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" %}
                        {% bootstrap_field sform.meta_noindex layout="control" %}
                        <div class="form-group">
                            <label class="col-md-3 control-label">
                                {% trans "Footer links" %}<br>
                                <span class="optional">{% trans "Optional" %}</span>
                            </label>
                            <div class="col-md-9">
                                <p class="help-block">
                                    {% blocktrans trimmed %}
                                        These links will be shown in the footer of your ticket shop. You could
                                        for example link your terms of service here. Your contact address, imprint, and privacy
                                        policy will be linked automatically (if you configured them), so you do not need to add
                                        them here.
                                    {% endblocktrans %}
                                </p>
                                <p class="help-block">
                                    {% blocktrans trimmed %}
                                        The links you configure here will also be shown on all of your events.
                                    {% endblocktrans %}
                                </p>
                                <div class="formset" data-formset data-formset-prefix="{{ footer_links_formset.prefix }}">
                                    {{ footer_links_formset.management_form }}
                                    {% bootstrap_formset_errors footer_links_formset %}
                                    <div data-formset-body>
                                        {% for form in footer_links_formset %}
                                            <div class="row formset-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.label layout='inline' form_group_class="" %}
                                                </div>
                                                <div class="col-md-5">
                                                    {% bootstrap_field form.url layout='inline' form_group_class="" %}
                                                </div>
                                                <div class="col-md-2 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 formset-row" data-formset-form>
                                                <div class="sr-only">
                                                    {{ footer_links_formset.empty_form.id }}
                                                    {% bootstrap_field footer_links_formset.empty_form.DELETE form_group_class="" layout="inline" %}
                                                </div>
                                                <div class="col-md-5">
                                                    {% bootstrap_field footer_links_formset.empty_form.label layout='inline' form_group_class="" %}
                                                </div>
                                                <div class="col-md-5">
                                                    {% bootstrap_field footer_links_formset.empty_form.url layout='inline' form_group_class="" %}
                                                </div>
                                                <div class="col-md-2 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 link" %}</button>
                                    </p>
                                </div>
                            </div>
                        </div>
                    </fieldset>
                    <fieldset>
                        <legend>{% trans "Localization" %}</legend>
                        {% bootstrap_field sform.locales layout="control" %}
                        {% bootstrap_field sform.region layout="control" %}
                        {% bootstrap_field sform.timezone layout="control" %}
                    </fieldset>
                    <fieldset>
                        <legend>{% trans "Customer accounts" %}</legend>
                        {% bootstrap_field sform.customer_accounts layout="control" %}
                        {% bootstrap_field sform.customer_accounts_native layout="control" %}
                        {% bootstrap_field sform.customer_accounts_link_by_email layout="control" %}
                        {% bootstrap_field sform.name_scheme layout="control" %}
                        {% bootstrap_field sform.name_scheme_titles 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 id="tab-organizer-privacy">
                        <legend>{% trans "Privacy" %}</legend>
                        {% bootstrap_field sform.privacy_url layout="control" %}
                        <div class="alert alert-legal">
                            <p>
                                {% blocktrans trimmed %}
                                    Some jurisdictions, including the European Union, require user consent before you
                                    are allowed to use cookies or similar technology for analytics, tracking, payment,
                                    or similar purposes.
                                {% endblocktrans %}
                            </p>
                            <p>
                                {% blocktrans trimmed %}
                                    pretix itself only ever sets cookies that are required to provide the service
                                    requested by the user or to maintain an appropriate level of security. Therefore,
                                    cookies set by pretix itself do not require consent in all jurisdictions that we
                                    are aware of.
                                {% endblocktrans %}
                            </p>
                            <p>
                                {% blocktrans trimmed %}
                                    Therefore, the settings on this page will <strong>only</strong> have an affect
                                    if you use <strong>plugins</strong> that require additional cookies
                                    <strong>and</strong> participate in our cookie consent mechanism.
                                {% endblocktrans %}
                            </p>
                            <p>
                                <strong>{% blocktrans trimmed %}
                                    Ultimately, it is your responsibility to make sure you comply with all relevant
                                    laws. We try to help by providing these settings, but we cannot assume liability
                                    since we do not know the exact configuration of your pretix usage, the legal details
                                    in your specific jurisdiction, or the agreements you have with third parties such as
                                    payment or tracking providers.
                                {% endblocktrans %}</strong>
                            </p>
                        </div>
                        {% bootstrap_field sform.cookie_consent layout="control" %}
                        {% bootstrap_field sform.cookie_consent_dialog_title layout="control" %}
                        {% bootstrap_field sform.cookie_consent_dialog_text layout="control" %}
                        {% bootstrap_field sform.cookie_consent_dialog_text_secondary layout="control" %}
                        {% bootstrap_field sform.cookie_consent_dialog_button_yes layout="control" %}
                        {% bootstrap_field sform.cookie_consent_dialog_button_no layout="control" %}
                    </fieldset>
                    <fieldset>
                        <legend>{% trans "Reusable media" %}</legend>
                        {% bootstrap_field sform.reusable_media_active layout="control" %}
                        <div data-display-dependency="#{{ sform.reusable_media_active.id_for_label }}">

                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    <h4 class="panel-title">{% trans "Barcode media" %}</h4>
                                </div>
                                <div class="panel-body">
                                    <p class="help-block">
                                        {% blocktrans trimmed %}
                                            A "barcode medium" can be any printed or digital representation of a barcode.
                                            The medium will initially be created through the sale of a product that has a
                                            media policy requiring such a medium as well as a ticket or badge layout that
                                            includes the "Reusable Medium ID" as a QR code. Later, the same barcode may
                                            be re-used during the sale of a different product.
                                        {% endblocktrans %}
                                        {% blocktrans trimmed %}
                                            Barcode media can currently only be connected to tickets.
                                        {% endblocktrans %}
                                        {% blocktrans trimmed %}
                                            This subsequent reuse of the barcode is currently only supported during POS sales.
                                        {% endblocktrans %}
                                    </p>
                                    {% bootstrap_field sform.reusable_media_type_barcode layout="control" %}
                                    <div data-display-dependency="#{{ sform.reusable_media_type_barcode.id_for_label }}">
                                        {% bootstrap_field sform.reusable_media_type_barcode_identifier_length layout="control" %}
                                    </div>
                                </div>
                            </div>

                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    <h4 class="panel-title">{% trans "NFC UID-based" %}</h4>
                                </div>
                                <div class="panel-body">
                                    <p class="help-block">
                                        {% blocktrans trimmed %}
                                            This medium type can work with almost any type of NFC chip. With this
                                            option, only the UID of the NFC chip is used for identification.
                                        {% endblocktrans %}
                                        {% blocktrans trimmed %}
                                            NFC media can currently only be connected to gift cards.
                                        {% endblocktrans %}
                                    </p>
                                    <p class="help-block">
                                        <span class="fa fa-warning text-warning"></span>
                                        {% blocktrans trimmed %}
                                            This method does not provide a high level of protection against abuse since it
                                            is possible for malicious users to clone someone's chip with the same UID.
                                        {% endblocktrans %}
                                    </p>
                                    {% bootstrap_field sform.reusable_media_type_nfc_uid layout="control" %}
                                    <div data-display-dependency="#{{ sform.reusable_media_type_nfc_uid.id_for_label }}">
                                        {% bootstrap_field sform.reusable_media_type_nfc_uid_autocreate_giftcard layout="control" %}
                                        <div data-display-dependency="#{{ sform.reusable_media_type_nfc_uid_autocreate_giftcard.id_for_label }}">
                                            {% bootstrap_field sform.reusable_media_type_nfc_uid_autocreate_giftcard_currency layout="control" %}
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    <h4 class="panel-title">NFC Mifare Ultralight AES</h4>
                                </div>
                                <div class="panel-body">
                                    <p class="help-block">
                                        {% blocktrans trimmed %}
                                            This medium type works only with NFC chips of the type Mifare Ultralight AES
                                            made by NXP. This provides a higher level of security than other approaches, but
                                            requires all chips to be encoded prior to use.
                                        {% endblocktrans %}
                                        {% blocktrans trimmed %}
                                            NFC media can currently only be connected to gift cards.
                                        {% endblocktrans %}
                                    </p>
                                    {% bootstrap_field sform.reusable_media_type_nfc_mf0aes layout="control" %}
                                    <div data-display-dependency="#{{ sform.reusable_media_type_nfc_mf0aes.id_for_label }}">
                                        {% bootstrap_field sform.reusable_media_type_nfc_mf0aes_autocreate_giftcard layout="control" %}
                                        <div data-display-dependency="#{{ sform.reusable_media_type_nfc_mf0aes_autocreate_giftcard.id_for_label }}">
                                            {% bootstrap_field sform.reusable_media_type_nfc_mf0aes_autocreate_giftcard_currency layout="control" %}
                                        </div>
                                        {% bootstrap_field sform.reusable_media_type_nfc_mf0aes_random_uid layout="control" %}
                                    </div>
                                </div>
                            </div>
                        </div>
                    </fieldset>
                    <fieldset>
                        <legend>{% trans "Invoices" %}</legend>
                        {% bootstrap_field sform.invoice_regenerate_allowed layout="control" %}
                    </fieldset>
                </div>
                <div class="form-group submit-group">
                    <button type="submit" class="btn btn-primary btn-save">
                        {% trans "Save" %}
                    </button>
                </div>
            </div>
            <div class="col-xs-12 col-lg-2">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">
                            {% trans "Change history" %}
                        </h3>
                    </div>
                    {% include "pretixcontrol/includes/logs.html" with obj=organizer %}
                </div>
            </div>
        </div>
    </form>
{% endblock %}
