{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}

{% block meta_title %}{{ 'Emails'|trans }}{% endblock %}

{% block content %}
<div class="h-block">
    <div class="h-block-header">
        <div class="icon"><span class="big-light-icon i-email"></span></div>
        <h2>{{ 'Emails we have sent you'|trans }}</h2>
        <p>{{ 'Here you can track emails we have sent you'|trans }}</p>
    </div>
    <div class="block">
        <table>
            <thead>
                <tr>
                    <th>{{ 'Email subject'|trans }}</th>
                    <th>{{ 'To'|trans }}</th>
                    <th>{{ 'Date sent'|trans }}</th>
                    <th>&nbsp;</th>
                </tr>
            </thead>

            <tbody>
                {% set emails = client.email_get_list({"per_page":10, "page":request.page}) %}
                {% for i, email in emails.list %}
                <tr class="{{ cycle(['odd', 'even'], i) }}">
                    <td><a href="{{ 'email'|link }}/{{email.id}}">{{email.subject}}</a></td>
                    <td>{{ email.recipients }}</td>
                    <td>{{email.created_at|bb_date}}</td>
                    <td class="actions"><a class="bb-button" href="{{ 'email'|link }}/{{email.id}}"><span class="dark-icon i-drag"></span></a></td>
                </tr>
                {% else %}
                <tr>
                    <td colspan="4">{{ 'The list is empty'|trans }}</td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
</div>

{% include "partial_pagination.phtml" with {'list': emails} %}
{% endblock %}
