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

{% block content %}
    <div class="panel panel-default">
        <div class="panel-heading">
            Actualités
            <div class="pull-right">
                <div class="btn-group">
                    <a href="{{ path('admin_news_new') }}" type="button" class="btn btn-default btn-xs">
                        Ajouter
                    </a>
                </div>
            </div>
        </div>
        <table class="table table-striped">
            <thead>
            <tr>
                <th>#</th>
                <th></th>
                <th>Date</th>
                <th>Titre</th>
                <th>Texte</th>
                <th>Publié</th>
                <th>Action</th>
            </tr>
            </thead>
            <tbody>
            {% for item in items %}
                <tr>
                    <td>{{ loop.index }}</td>
                    <td> {% if item.images is not empty %}
                            {% if item.images|length > 0 %}
                                <img src="{{ asset(item.images[0].image.path) | imagine_filter('relative_widen_20_filter') }}"/>
                            {% endif %}
                        {% elseif item.video is not null %}
                            <i class="fab fa-youtube"></i>
                        {% endif %}
                    </td>
                    <td>{{ item.eventAt|date('d-m-Y H:i') }}</td>
                    <td>{{ item.title }} {{ item.title2 }}</td>
                    <td>
                        {{ item.text | slice(0,100)| striptags }}
                    </td>
                    <td>
                        {% if item.disabled == 0 %}
                            <i class="fas fa-circle fa-2x color_green"></i>
                        {% else %}
                            <i class="fas fa-circle fa-2x color_red"></i>
                        {% endif %}
                    </td>
                    <td>
                        <a href="{{ path('admin_news_edit', { id: item.id}) }}" class="btn btn-info btn-xs"
                           data-toggle="tooltip" title="Editer la news {{ item.title }}"><i
                                    class="fas fa-edit fa-2x"></i></a>

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