{% extends 'membersmessaging/layouts/membersmessaging.twig' %}

{% block content %}

    <ul class="breadcrumbs el">
        <li><a href="{{ route('admin.messaging.index') }}">Home</a> /</li>
        <li class="end">All Templates</li>
    </ul>

    <h1>Edit template</h1>

    {% include 'membersmessaging/admin/widgets/tabnav.twig' %}

    {% include 'membersmessaging/admin/widgets/flash.twig' %}

    {% if totalnumrows > 0 %}
        <table class="manage-items">
            <thead>
            <tr>
                <th class="center">ID</th>
                <th>Category</th>
                <th>Name</th>
                <th>Text</th>
                <th></th>
            </tr>
            </thead>
            <tbody class="tabular">
            {% for template in templates %}
                <tr id="rorder-{{ template.id }}">
                    <td>{{ template.id|e }}</td>
                    <td>{{ template.category }}</td>
                    <td>{{ template.name|e }}</td>
                    <td>{{ template.text|striptags|e }}</td>
                    <td>
                        <a class="view-message" href="{{ route('admin.messaging.edit_template', template.id) }}"><i
                                    class="fa fa-pencil"></i> Edit Template</a>
                        <form action="{{ route('admin.messaging.delete_template', {'id': template.id}) }}"
                              method="POST"
                              style="display:inline;"
                              onsubmit="return confirm('Are you sure you want to remove this template?');">

                            <input type="hidden" name="_token" value="{{ csrf_token }}">
                            <input type="hidden" name="_method" value="DELETE">

                            <button type="submit" class="delete-message alert"
                                    title="Are you sure you want to remove this template?">
                                <i class="fa fa-remove"></i>
                                Delete Template
                            </button>
                        </form>
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    {% else %}
        <p>There are no templates</p>
    {% endif %}


{% endblock %}
