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

{% block meta_title %}{{email.subject}}{% endblock %}

{% block content_before %}
		<!-- Page Heading/Breadcrumbs -->
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">{{email.subject}}</h1>
				<ol class="breadcrumb">
					<li><a href="{{ 'email'|link }}">{% trans 'Emails we have sent you'%}</a></li>
					<li class="active">{{email.subject}}</li>
				</ol>
            </div>
        </div>
        <!-- /.row -->
{% endblock %}
{% block content %}

		<div class="panel panel-default">
			<div class="panel-heading">
				<ul class="list-inline">
					<li><strong>{% trans 'Sent' %}</strong> {{email.created_at|date('Y-m-d h:i')}}</li>
					<li><strong>{% trans 'From' %}</strong> {{email.sender}}</li>
					<li><strong>{% trans 'To' %}</strong> {{email.recipients}}</li>
					<li class="pull-right"><a href="{{ 'api/client/email/resend'|link({'id' : email.id}) }}" data-api-msg="{% trans 'Success' %}" class="api btn btn-info btn-sm"><i class="fa fa-repeat"></i> {% trans 'Resend' %}</a></li>
					<li class="pull-right"><a href="{{ 'api/client/email/delete'|link({'id' : email.id}) }}" data-api-redirect="{{ '/email'|link }}" class="api btn btn-danger btn-sm"><i class="fa fa-trash"></i> {% trans 'Delete' %}</a></li>
				</ul>
			</div>
			<div class="panel-body">
				{{email.content_html|raw}}
			</div>
		</div>
		<hr>
		
		<p class="text-center">
			<a class="btn btn-default" href="{{ '/email'|link }}"><i class="fa fa-arrow-left"></i> {% trans 'Back to emails' %}</a>
		</p>

{% endblock %}

{% block js %}
{% autoescape true js %}
<script type="text/javascript">
$(function() {
    $('#email-resend').click(function(e){
        e.preventDefault();
        bb.post(
            'client/email/resend',
            {id: {{email.id}} },
            function(result) {
                bb.msg('Email resent');
            }
        );
    });

    $('#email-delete').click(function(e){
        e.preventDefault();
        bb.post(
            'client/email/delete',
            {id: {{email.id}} },
            function(result) {
                bb.redirect('{{ 'email'|link }}');
            }
        );
    });
});
</script>
{% endautoescape %}
{% endblock %}