{% extends (mode == 'ajax') ? "ajax.html.twig" : "page.html.twig" %}

{% block content %}
        <div class="ui top attached accordion-styled header">
            {{ _T("Headers") }}
        </div>
        <div class="ui bottom attached accordion-styled segment">
            <div class="ui basic segments form">
                <div class="ui segment">
                    <div class="inline field">
                        <label>{{ _T("From:") }}</label>
                        <span>{{ sender }}</span>
                    </div>
                </div>
                <div class="ui segment">
                    <div class="inline field">
                        <label>{{ _T("To:") }}</label>
                        <div class="ui horizontal bulleted link list">
    {% for recipient in recipients %}
        {% if recipient.email is null and recipient.hasParent() %}
            {% set email = recipient.parent.email %}
        {% else %}
            {% set email = recipient.email %}
        {% endif %}
                            <a href="mailto:{{ email }}" class="item">{{ recipient.sname }} &lt;{{ email }}&gt;</a>
    {% endfor %}
                        </div>
                    </div>
                </div>
                <div class="ui segment">
                    <div class="inline field">
                        <label>{{ _T("Subject:") }}</label>
                        <span>{{ mailing.subject }}</span>
                    </div>
                </div>
                <div class="ui segment">
                    <div class="inline field">
                        <label>{{ _T("Attachments:") }}</label>
                        <div class="ui horizontal bulleted link list">
    {% for attachment in attachments %}
                            <a target="_blank" href="{{ url_for("previewAttachment", {"id": mailing_id, "pos": loop.index}) }}" class="item"><i class="ui paperclip icon"></i>{{ attachment.getFileName() }}</a>
    {% else %}
                            <span class="item">-</span>
    {% endfor %}
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="ui top attached accordion-styled header">
            {{ _T("Mail body") }}
        </div>
        <div class="ui bottom attached accordion-styled segment">
    {% if mailing.html %}
            {{ mailing.message }}
    {% else %}
            <pre>{{ mailing.wrapped_message|escape }}</pre>
    {% endif %}
        </div>
{% endblock %}
