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

{% block content %}
    <div class="panel panel-default">
        <div class="panel-heading">
            Depôts
            <div class="pull-right">
                <div class="btn-group">
                    <a href="{{ path('admin_depot_new') }}" type="button" class="btn btn-default btn-xs">
                        Ajouter
                    </a>
                </div>
            </div>
        </div>
        <table class="table table-striped">
            <thead>
            <tr>
                <th>#</th>
                <th>Catégorie</th>
                <th>Nom</th>
                <th>Description</th>
                <th>Adresse</th>
                <th>Code Postal</th>
                <th>Ville</th>
                <th>Pays</th>
                <th>Action</th>
            </tr>
            </thead>
            <tbody>
            {% for item in items %}
                <tr>
                    <td>{{ loop.index }}</td>
                    <td>{% if item.category is not null %}{{ item.category.name }}{% endif %}</td>
                    <td>{{ item.name }}</td>
                    <td>{{ item.description | slice(0,50) }}</td>
                    <td>{{ item.address }}</td>
                    <td>{{ item.postal }}</td>
                    <td>{{ item.city }}</td>
                    <td>{{ item.country }}</td>
                    <td>
                        <a href="{{ path('admin_depot_edit', { id: item.id}) }}" class="btn btn-info btn-xs"
                           data-title="Editer le dépôt"><i
                                    class="fas fa-edit fa-2x" aria-hidden="true"></i></a>

                        <a href="{{ path('admin_depot_delete', { id: item.id }) }}"
                           class="confirm-deletable btn btn-danger btn-xs"
                           data-title="Supprimer le dépôt {{ item.name }}"><i class="fa fa-2x fa-trash"
                                                                              aria-hidden="true"></i></a>
                        {% if item.disabled == 0 %}
                            <a href="{{ path('admin_depot_disable', { id: item.id }) }}"
                               class=" btn btn-default btn-xs" data-toggle="tooltip"
                               title="Dépublier le dépôt {{ item.name }}"><i
                                        class="fas fa-circle fa-2x color_green"></i></a>
                        {% else %}
                            <a href="{{ path('admin_depot_enable', { id: item.id }) }}"
                               class=" btn btn-default btn-xs" data-toggle="tooltip"
                               title="Publier le dépôt {{ item.name }}"><i class="fas fa-circle fa-2x color_red"></i></a>
                        {% endif %}

                        {% if loop.first == false %}
                            <a href="{{ path('admin_depot_move_up', {id : item.id}) }}"
                               class="btn btn-default btn-xs" data-toggle="tooltip" title="Remonter le dépôt"><i
                                        class="fa fa-2x fa-arrow-up" aria-hidden="true"></i></a>
                        {% endif %}
                        {% if loop.last == false %}
                            <a href="{{ path('admin_depot_move_down', {id : item.id}) }}"
                               class=" btn btn-default btn-xs" data-toggle="tooltip" title="Descendre le dépôt"><i
                                        class="fa fa-2x fa-arrow-down" aria-hidden="true"></i></a>
                        {% endif %}

                    </td>
                </tr>
            {% endfor %}

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