{% extends "pretixcontrol/event/base.html" %}
{% load i18n %}
{% load bootstrap3 %}
{% block title %}{% trans "Send out emails" %}{% endblock %}
{% block content %}
    <h1>{% trans "Send out emails" %}</h1>
    {% block inner %}
        <form class="form-horizontal" method="post" action="" enctype="multipart/form-data">
            {% csrf_token %}
            {% bootstrap_field form.recipients layout='horizontal' %}
            {% bootstrap_field form.sendto layout='horizontal' %}
            {% if form.subevent %}
                {% bootstrap_field form.subevent layout='horizontal' %}
                {% bootstrap_field form.subevents_from layout='horizontal' %}
                {% bootstrap_field form.subevents_to layout='horizontal' %}
            {% endif %}
            {% bootstrap_field form.items layout='horizontal' %}
            <div class="row">
                <div class="col-md-9 col-md-offset-3">
                    <div class="panel-group">
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <label data-toggle="collapse" data-target="#checkin_filter">
                                    {{ form.filter_checkins }} {{ form.filter_checkins.label }}
                                </label>
                            </div>
                            <div id="checkin_filter" class="panel-body panel-collapse collapse {% if form.filter_checkins.value %} in {% else %} out {% endif %}">
                                {% bootstrap_field form.not_checked_in layout='horizontal' %}
                                {% bootstrap_field form.checkin_lists layout='horizontal' %}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            {% bootstrap_field form.subject layout='horizontal' %}
            {% bootstrap_field form.message layout='horizontal' %}
            {% bootstrap_field form.attachment layout='horizontal' %}
            {% if request.method == "POST" %}
            <fieldset>
            <legend>{% trans "E-mail preview" %}</legend>
                <div class="tab-pane mail-preview-group">
                    {% for locale, out in output.items %}
                        <div lang="{{ locale }}" class="mail-preview">
                            <strong>{{ out.subject|safe }}</strong><br><br>
                            {{ out.html|safe }}
                        </div>
                    {% endfor %}
                </div>
            </fieldset>
            {% endif %}
            <div class="form-group submit-group">
                <button type="submit" class="btn btn-default btn-save pull-left" name="action" value="preview">
                {% trans "Preview email" %}
                </button>
                <button type="submit" class="btn btn-primary btn-save">
                    {% trans "Send" %}
                </button>
            </div>
        </form>
    {% endblock %}
{% endblock %}
