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

{% block content %}
    <div class="panel panel-default">
        <div class="panel-heading">
            Méthode de livraison
            {% if is_granted('ROLE_ADMIN') %}
                <div class="pull-right">
                    <div class="btn-group">
                        <a href="{{ path('admin_delivery_method_new') }}" type="button" class="btn btn-default btn-xs">
                            Ajouter
                        </a>
                    </div>
                </div>
            {% endif %}
        </div>
        <div class="table-responsive">
            <table class="table table-bordered dataTable" width="100%" cellspacing="0">
                <thead>
                <tr>
                    <th>#</th>
                    <th>Nom</th>
                    <th>Catégorie</th>
                    <th>Prix (forfait)</th>
                    <th>Prix (bouteille)</th>
                    <th>Groupe</th>
                    <th>Département</th>
                    <th>Position</th>
                    <th></th>
                </tr>
                </thead>
                <tfoot>
                <tr>
                    <th>#</th>
                    <th>Nom</th>
                    <th>Catégorie</th>
                    <th>Prix (forfait)</th>
                    <th>Prix (bouteille)</th>
                    <th>Groupe</th>
                    <th>Département</th>
                    <th>Position</th>
                    <th></th>
                </tr>
                </tfoot>
                <tbody>
                {% for item in items %}
                    <tr>
                        <td>{{ loop.index }}</td>
                        <td>{{ item.name }}</td>
                        <td>{{ item.category.name }}</td>
                        <td>
                            {% if item.packagePrice is not null %}
                                {{ item.packagePrice / 100 }} €
                            {% endif %}
                        </td>
                        <td>
                            {% if item.bottlePrice is not null %}
                                {{ item.bottlePrice / 100 }} €
                            {% endif %}
                        </td>
                        <td>
                            {% for group in item.groups %}
                                <span class="label label-default">{{ group.name }}</span>
                            {% endfor %}
                        </td>
                        <td>
                            {% for county in item.counties %}
                                <span class="label label-default">{{ county.code }}</span>
                            {% endfor %}
                        </td>
                        <td>
                            {% if loop.first == false %}
                                <a href="{{ path('admin_delivery_method_move_up', {id : item.id}) }}"
                                   class="btn btn-default btn-xs" data-toggle="tooltip" title="Remonter la méthode"><i
                                            class="fa fa-2x fa-arrow-up" aria-hidden="true"></i></a>
                            {% endif %}
                            {% if loop.last == false %}
                                <a href="{{ path('admin_delivery_method_move_down', {id : item.id}) }}"
                                   class=" btn btn-default btn-xs" data-toggle="tooltip" title="Descendre la méthode"><i
                                            class="fa fa-2x fa-arrow-down" aria-hidden="true"></i></a>
                            {% endif %}
                        </td>
                        <td>
                            <a href="{{ path('admin_delivery_method_edit', { id: item.id}) }}"
                               class="btn btn-info btn-xs"
                               data-title="Editer la méthode"><i
                                        class="fas fa-edit fa-2x" aria-hidden="true"></i></a>
                            <a href="{{ path('admin_delivery_method_delete', { id: item.id }) }}"
                               class="confirm-deletable btn btn-danger btn-xs"
                               data-title="Supprimer la méthode {{ item.name }}"><i class="fa fa-2x fa-trash"
                                                                                    aria-hidden="true"></i></a>
                        </td>
                    </tr>
                {% endfor %}

                </tbody>
            </table>
        </div>
    </div>
{% endblock %}
