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

{% block content %}
    <div class="panel panel-default">
        <div class="panel-heading">
            Code Remise
            <div class="pull-right">
                <div class="btn-group">
                    <a href="{{ path('admin_promo_new') }}" type="button" class="btn btn-default btn-xs">
                        Ajouter
                    </a>
                </div>
            </div>
        </div>
        <table class="table table-striped">
            <thead>
            <tr>
                <th>#</th>
                <th>Code</th>
                <th>Remise</th>
                <th>Début</th>
                <th>Fin</th>
                <th>Utilisé</th>
                <th>Max Par client</th>
                <th>Max</th>
                <th>Auto</th>
                <th>Publier</th>
                <th>Action</th>
            </tr>
            </thead>
            <tbody>
            {% for item in items %}
                <tr>
                    <td>{{ loop.index }}</td>
                    <td>{{ item.title }}</td>
                    <td>{% if item.percent %}{{ (item.percent * 100)| number_format(2) }} %{% else %}{{ (item.amount / 100)| number_format(2) }}{% endif %}</td>
                    <td>{{ item.beginAt | date('d-m-Y H:i') }}</td>
                    <td>{{ item.endAt | date('d-m-Y H:i') }}</td>
                    <td>{{ item.count }}</td>
                    <td>{{ item.maxCountByCustomer }}</td>
                    <td>{% if item.maxCount %}{{ item.maxCount }}{% else %}-{% endif %}</td>
                    <td>{% if item.auto %}Oui{% else %}Non{% endif %}</td>
                    <td>
                        {% if item.disabled %}
                            <a href="{{ path('admin_promo_enable', { id: item.id}) }}" data-toggle="tooltip" title="Activer le code remise {{ item.title }}">
                                <i class="fas fa-circle fa-2x color_red"></i>
                            </a>
                        {% else %}
                            <a href="{{ path('admin_promo_disable', { id: item.id}) }}" data-toggle="tooltip" title="Désactiver le code remise {{ item.title }}">
                                <i class="fas fa-circle fa-2x color_green"></i>
                            </a>
                        {% endif %}
                    </td>
                    <td>
                        <a href="{{ path('admin_promo_edit', { id: item.id}) }}" class="btn btn-info btn-xs"
                           data-toggle="tooltip" title="Editer le code remise {{ item.title }}"><i
                                    class="fas fa-edit fa-2x"></i></a>

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