{% extends '@CpCreationVitiCore/admin/base.html.twig' %}

{% block content %}
    <div class="panel panel-default">
        <div class="panel-heading">
            Emails transactionnels
            <div class="pull-right">
                <div class="btn-group">
                    <a href="{{ path('admin_transactional_email_new') }}" type="button" class="btn btn-default btn-xs">
                        Ajouter
                    </a>
                </div>
            </div>
        </div>
        <table class="table table-striped">
            <thead>
            <tr>
                <th>#</th>
                <th>Nom</th>
                <th>Action</th>
                <th>Délai</th>
                <th>Destinataire</th>
                <th>Template</th>
                <th>Etat</th>
                <th>Actions</th>
            </tr>
            </thead>
            <tbody>
            {% for item in items %}
                <tr {% if item.disabled == 1 %} class="danger" {% endif %}>
                    <td>{{ loop.index }}</td>
                    <td>{{ item.name }}</td>
                    <td>{{ item.triggerLabel }}</td>
                    <td>{{ item.delayDays }} jour{% if item.delayDays > 1 %}s{% endif %}</td>
                    <td>{{ item.recipientLabel }}</td>
                    <td>{{ item.templateCode ?: '-' }}</td>
                    <td>{% if item.disabled %}Désactivé{% else %}Actif{% endif %}</td>
                    <td>
                        <a href="{{ path('admin_transactional_email_edit', { id: item.id }) }}" class="btn btn-info btn-xs"
                           data-title="Editer l'email transactionnel">
                            <i class="fas fa-edit fa-2x" aria-hidden="true"></i>
                        </a>
                        <a href="{{ path('admin_transactional_email_delete', { id: item.id }) }}"
                           class="confirm-deletable btn btn-danger btn-xs"
                           data-title="Supprimer l'email transactionnel {{ item.name }}">
                            <i class="fa fa-2x fa-trash" aria-hidden="true"></i>
                        </a>
                        {% if item.disabled == 0 %}
                            <a href="{{ path('admin_transactional_email_disable', { id: item.id }) }}"
                               class="btn btn-default btn-xs" data-toggle="tooltip"
                               title="Désactiver l'email transactionnel {{ item.name }}">
                                <i class="fas fa-circle fa-2x color_green"></i>
                            </a>
                        {% else %}
                            <a href="{{ path('admin_transactional_email_enable', { id: item.id }) }}"
                               class="btn btn-default btn-xs" data-toggle="tooltip"
                               title="Activer l'email transactionnel {{ item.name }}">
                                <i class="fas fa-circle fa-2x color_red"></i>
                            </a>
                        {% endif %}
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
{% endblock %}
