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

{% block content %}
    <div class="panel panel-default">
        <div class="panel-heading">
            Dégressivité
            <div class="pull-right">
                <div class="btn-group">
                    <a href="{{ path('admin_product_degressive_new') }}" type="button" class="btn btn-default btn-xs">
                        Ajouter
                    </a>
                </div>
            </div>
        </div>
        <table class="table table-striped dataTable">
            <thead>
            <tr>
                <th>#</th>
                <th>De</th>
                <th>A</th>
                <th>Type</th>
                <th>Produits</th>
                <th>Groupes</th>
                <th>Forfait</th>
                <th>Par bouteille</th>
                <th>Pourcentage</th>
                <th>Bouteille offerte</th>
                <th>Equivalence</th>
                <th>Action</th>
            </tr>
            </thead>
            <tfoot>
            <tr>
                <th>#</th>
                <th>De</th>
                <th>A</th>
                <th>Type</th>
                <th>Produits</th>
                <th>Groupes</th>
                <th>Forfait</th>
                <th>Par bouteille</th>
                <th>Pourcentage</th>
                <th>Bouteille offerte</th>
                <th>Equivalence</th>
                <th>Action</th>
            </tr>
            </tfoot>
            <tbody>

            {% for item in items %}
                <tr>
                    <td>{{ loop.index }}</td>
                    <td>{{ item.qtyOf }}</td>
                    <td>{{ item.qtyAt }}</td>
                    <td>
                        {% for type in item.types %}
                            <span class="label label-default">{{ type.name }} {% if type.info %}({{ type.info }}){% endif %}</span>
                        {% endfor %}
                    </td>
                    <td>
                        {% for product in item.products %}
                            <span class="label label-default">{{ product.name ? product.name|upper : '-' }}</span>
                        {% endfor %}
                    </td>
                    <td>
                        {% for group in item.groups %}
                            <span class="label label-default">{{ group.name }}</span>
                        {% endfor %}
                    </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>
                        {% if item.packagePercent is not null %}
                            {{ item.packagePercent * 100 }} %
                        {% endif %}
                    </td>
                    <td>
                        {% if item.qtyOfBottleOffered %}
                        {{ item.qtyOfBottleOffered }}
                        {% endif %}
                    </td>
                    <td>
                        {% if item.equivalency %}
                            Oui
                        {% else %}
                            Non
                        {% endif %}
                    </td>
                    <td>
                        <a href="{{ path('admin_product_degressive_edit', { id: item.id}) }}"
                           class="btn btn-info btn-xs"
                           data-toggle="tooltip" title="Editer la dégressivité"><i class="fas fa-edit fa-2x"></i></a>

                        <a href="{{ path('admin_product_degressive_delete', { id: item.id }) }}"
                           class="confirm-deletable btn btn-danger btn-xs"
                           data-toggle="tooltip" title="Supprimer la dégressivité"
                           data-title="Supprimer le prix">
                            <i class="fa fa-2x fa-trash"></i></a>
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
{% endblock %}
