{% extends "orga/mails/base.html" %}
{% load i18n %}
{% load url_replace %}

{% block mail_content %}
    <legend>
        <span>
            {{ page_obj.paginator.count }}
            {% blocktrans trimmed count count=page_obj.paginator.count %}
                pending mail
            {% plural %}
                pending mails
            {% endblocktrans %}
        </span>
    </legend>
    <div class="submit-group">
        <span>
            {% include "common/search_form.html" %}
        </span>
        <span>
            <a href="{{ request.event.orga_urls.send_outbox }}">
                <button class="btn btn-lg btn-success">{% trans "Send all" %}</button>
            </a>
            <a href="{{ request.event.orga_urls.purge_outbox }}">
                <button class="btn btn-lg btn-danger">{% trans "Discard all" %}</button>
            </a>
        </span>
    </div>
    <table class="table table-sm table-hover table-responsive-md">
        <thead>
            <tr>
                <th>
                    {% trans "Subject" %}
                    <a href="?{% url_replace request 'sort' '-subject' %}"><i class="fa fa-caret-down"></i></a>
                    <a href="?{% url_replace request 'sort' 'subject' %}"><i class="fa fa-caret-up"></i></a>
                </th>
                <th>
                    {% trans "To" %}
                    <a href="?{% url_replace request 'sort' '-to' %}"><i class="fa fa-caret-down"></i></a>
                    <a href="?{% url_replace request 'sort' 'to' %}"><i class="fa fa-caret-up"></i></a>
                </th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            {% for mail in mails %}
            <tr>
                <td>
                    <a href="{{ mail.urls.base }}">
                        {{ mail.subject }}
                    </a>
                </td>
                <td>
                    {{ mail.to }}
                </td>
                <td class="text-right">
                    <a href="{{ mail.urls.send }}"
                        title="{% trans "send" %}"
                        class="btn btn-sm btn-success">
                        <i class="fa fa-mail-forward"></i>
                    </a>
                    <a href="{{ mail.urls.edit }}"
                        title="{% trans "edit" %}"
                        class="btn btn-sm btn-info">
                        <i class="fa fa-edit"></i>
                    </a>
                    <a href="{{ mail.urls.delete }}"
                        title="{% trans "delete" %}"
                        class="btn btn-sm btn-danger">
                        <i class="fa fa-trash"></i>
                    </a>
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
    {% include "orga/pagination.html" %}
{% endblock %}
