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

{% block content %}
    <div class="panel panel-default">
        <div class="panel-heading">
            Les codes partenaires
            {% if is_granted('ROLE_ADMIN') or is_granted('ROLE_PRICE_CODE') %}
                <div class="pull-right">
                    <div class="btn-group">
                        <a href="{{ path('admin_product_price_code_new') }}" type="button"
                           class="btn btn-default btn-xs">
                            Ajouter
                        </a>
                    </div>
                </div>
            {% endif %}
        </div>
        <table class="table table-striped">
            <thead>
            <tr>
                <th>#</th>
                <th>Code</th>
                <th>Groupe</th>
                <th>Action</th>
            </tr>
            </thead>
            <tbody>

            {% for item in items %}
                <tr>
                    <td>{{ loop.index }}</td>
                    <td>{{ item.code }}</td>
                    <td>{{ item.group.name }}</td>
                    <td>
                        <a href="{{ path('admin_product_price_code_edit', { id: item.id}) }}"
                           class="btn btn-info btn-xs"
                           data-toggle="tooltip" title="Editer le code"><i class="fas fa-edit fa-2x"></i></a>
                        {% if is_granted('ROLE_ADMIN') or is_granted('ROLE_PRICE_CODE') %}
                            <a href="{{ path('admin_product_price_code_delete', { id: item.id }) }}"
                               class="confirm-deletable btn btn-danger btn-xs"
                               data-toggle="tooltip" title="Supprimer le code {{ item.code }}"
                               data-title="Supprimer le code {{ item.code }}">
                                <i class="fa fa-2x fa-trash"></i></a>
                        {% endif %}
                        {% if item.disabled == 0 %}
                            <a href="#"
                               class=" btn btn-default btn-xs" data-toggle="tooltip"
                               title=""><i
                                        class="fas fa-circle fa-2x color_green"></i></a>
                        {% else %}
                            <a href="#"
                               class=" btn btn-default btn-xs" data-toggle="tooltip"
                               title=""><i class="fas fa-circle fa-2x color_red"></i></a>
                        {% endif %}
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
{% endblock %}
