{% extends 'base.html' %}

{% block content %}
    <div class='row'>
        <div class='col-lg-12'>
            <div class="card card-primary card-outline">
                <div class="card-header">
                    <h3 class="card-title">Message History</h3>
                </div>
                <div class="card-body">
                    {% include 'message_center/message_center_nav_tabs.html' %}
                    <div class="row">
                        <div class="col-lg-12">
                            <table class="table table-hover datatables-no-export">
                                <thead>
                                <tr>
                                    <th>Channel</th>
                                    <th>Status</th>
                                    <th>Subject</th>
                                    <th>Error</th>
                                    <th>Created</th>
                                </tr>
                                </thead>
                                <tbody>
                                {% for message in message_list %}
                                    <tr>
                                        <td>{{ message.channel }}</td>
                                        <td>{{ message.get_status_display }}</td>
                                        <td><u title="{{ message.message }}">{{ message.subject }}</u></td>
                                        <td>
                                            {% if message.error_message %}
                                                <u title="{{ message.error_message }}">Error code: {{ message.error_status_code|default_if_none:"" }}</u>
                                            {% endif %}
                                        </td>
                                        <td>{{ message.created }}</td>
                                    </tr>
                                {% endfor %}
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            <p class="small" style="text-align: right; font-style: italic">Showing messages sent in the last 30 days. Older messages are automatically removed.</p>
        </div>
    </div>
{% endblock %}
