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

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

{% block content_before %}
		<!-- Page Heading/Breadcrumbs -->
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">{% trans 'Emails we have sent you'%}<h1>
            </div>
        </div>
        <!-- /.row -->
{% endblock %}
{% block content %}
		
        <table class="table table-striped table-hover">
            <thead>
                <tr>
                    <th>{% trans 'Email subject' %}</th>
                    <th>{% trans 'Date sent' %}</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.created_at|date('Y-m-d h:i')}}</td>
                    <td class="actions">
						<div class="pull-right">
							<a href="{{ 'api/client/email/delete'|link({'id' : email.id}) }}" data-api-reload="1" class="api btn btn-danger btn-sm"><i class="fa fa-trash"></i> {% trans 'Delete' %}</a>
							<a href="{{ 'email'|link }}/{{email.id}}" class="btn btn-primary btn-sm" ><i class="fa fa-search"></i> {% trans 'View' %}</a>
						</div>
					</td>
                </tr>
                {% else %}
                <tr>
                    <td colspan="4">{% trans 'The list is empty' %}</td>
                </tr>
                {% endfor %}
            </tbody>
        </table>

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

{% endblock %}
