{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% import "macro_functions.phtml" as mf %}
{% block meta_title %}Emails sent to clients{% endblock %}
{% set active_menu = 'activity' %}

{% block content %}
<div class="widget first">
    <div class="head"><h5 class="iFrames">{% trans 'Sent emails' %}</h5></div>

{{ mf.table_search }}
<table class="tableStatic wide">
    <thead>
        <tr>
            <td>{% trans 'To' %}</td>
            <td>{% trans 'From' %}</td>
            <td>{% trans 'Subject' %}</td>
            <td>{% trans 'Date' %}</td>
            <td style="width: 13%">&nbsp;</td>
        </tr>
    </thead>

    <tbody>
    {% set emails = admin.email_email_get_list({"per_page":30, "page":request.page}|merge(request)) %}
    {% for i, email in emails.list %}
    <tr>
        <td>{{ email.recipients }}</td>
        <td>{{ email.sender }}</td>
        <td>{{ email.subject|truncate(40) }}</td>
        <td>{{ email.created_at|date('Y-m-d') }}</td>
        <td class="actions">
            <a class="bb-button btn14" href="{{ '/email'|alink }}/{{email.id}}"><img src="images/icons/dark/pencil.png" alt=""></a>
            <a class="bb-button btn14 bb-rm-tr api-link" data-api-redirect="email/history" data-api-confirm="Are you sure?"  href="admin/email/email_delete?id={{email.id}}"><img src="images/icons/dark/trash.png" alt=""></a>
        </td>
    </tr>
    </tbody>

    {% else %}
    <tbody>
        <tr>
            <td colspan="7">
                {% trans 'The list is empty' %}
            </td>
        </tr>
    </tbody>
    {% endfor %}

    {% if emails.pages > 1 %}
    <tfoot>
        <tr>
            <td colspan="7">
                {% include "partial_pagination.phtml" with {'list': emails, 'url':'email/history'} %}
            </td>
        </tr>
    </tfoot>
    {% endif %}
</table>

</div>

{% endblock %}
