{% 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>{% trans "E-mail settings" %}</h1>

    <form action="" method="post" class="form-horizontal" enctype="multipart/form-data"
          mail-preview-url="{% url "control:organizer.settings.mail.preview" organizer=request.organizer.slug %}">
        {% csrf_token %}
        {% bootstrap_form_errors form %}
        <div class="tabbed-form">
            <fieldset>
                <legend>{% trans "General" %}</legend>
                <div class="form-group">
                    <label class="col-md-3 control-label">
                        {% trans "Sending method" %}
                    </label>
                    <div class="col-md-9 static-form-row-with-btn">
                        {% if request.organizer.settings.smtp_use_custom %}
                            {% trans "Custom SMTP server" %}: {{ request.organizer.settings.smtp_host }}
                        {% else %}
                            {% trans "System-provided email server" %}
                        {% endif %}
                        &nbsp;&nbsp;
                        <a href="{% url "control:organizer.settings.mail.setup" organizer=request.organizer.slug %}"
                           class="btn btn-default">
                            <span class="fa fa-edit"></span>
                            {% trans "Edit" %}
                        </a>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-3 control-label">
                        {% trans "Sender address" %}
                    </label>
                    <div class="col-md-9 static-form-row-with-btn">
                        {{ request.organizer.settings.mail_from }}
                        &nbsp;&nbsp;
                        <a href="{% url "control:organizer.settings.mail.setup" organizer=request.organizer.slug %}"
                           class="btn btn-default">
                            <span class="fa fa-edit"></span>
                            {% trans "Edit" %}
                        </a>
                    </div>
                </div>

                {% bootstrap_field form.mail_from_name layout="control" %}
                {% bootstrap_field form.mail_text_signature layout="control" %}
                {% bootstrap_field form.mail_bcc layout="control" %}
            </fieldset>
            <fieldset>
                <legend>{% trans "E-mail content" %}</legend>
                <div class="panel-group" id="questions_group">
                    {% blocktrans asvar title_customer_registration %}Customer account registration{% endblocktrans %}
                    {% include "pretixcontrol/event/mail_settings_fragment.html" with pid="customer_registration" title=title_customer_registration items="mail_subject_customer_registration,mail_text_customer_registration" %}

                    {% blocktrans asvar title_email_change %}Customer account email change{% endblocktrans %}
                    {% include "pretixcontrol/event/mail_settings_fragment.html" with pid="email_change" title=title_email_change items="mail_subject_customer_email_change,mail_text_customer_email_change" %}

                    {% blocktrans asvar title_reset %}Customer account password reset{% endblocktrans %}
                    {% include "pretixcontrol/event/mail_settings_fragment.html" with pid="reset" title=title_reset items="mail_subject_customer_reset,mail_text_customer_reset" %}
                </div>
            </fieldset>
        </div>
        <div class="form-group submit-group">
            <button type="submit" class="btn btn-primary btn-save">
                {% trans "Save" %}
            </button>
        </div>
    </form>
{% endblock %}
