{% extends 'Admin/layout.html.twig' %}

{% block javascripts %}
    <script>
        $(function() {
            $('.fancybox').fancybox({
                'maxHeight': '90%',
                'padding': 0
            });
        });
    </script>
{% endblock %}

{% block body %}
    {{ knp_menu_render('actions_testimonials') }}

    {# Formulaire de recherche #}
    <form action="{{ path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')) }}" class="search-admin" method="get">
        <fieldset>
            <div class="search-fields">
                <p>
                    <label for="form_search_witness">{{ 'form.testimonial.witness.label'|trans({}, 'form') }}</label>
                    <input id="form_search_witness" name="witness" type="text" value="{{ search_witness }}">
                </p>
            </div>
        </fieldset>
        <p>
            <input class="btn" type="submit" value="{{ 'action.search'|trans({}, 'action') }}" />
        </p>
    </form>

    <table class="tableBo">
            <thead>
                <tr>
                    <td>{{ 'form.testimonial.witness.label'|trans({}, 'form') }}</td>
                    <td>{{ 'form.testimonial.occupation.label'|trans({}, 'form') }}</td>
                    <td>{{ 'form.testimonial.content.label'|trans({}, 'form') }}</td>
                    <td>{{ 'form.testimonial.created.label'|trans({}, 'form') }}</td>
                    <td colspan="3">{{ 'word.actions'|trans({}, 'word') }}</td>
                </tr>
            </thead>
            <tbody>
                {% for testimonial in testimonials %}
                    <tr class="delete-element-container">
                        <td><a href="{{ path('admin_testimonial_edit', {'id':testimonial.id}) }}">{{ testimonial.witness|striptags|raw }}</a></td>
                        <td><a href="{{ path('admin_testimonial_edit', {'id':testimonial.id}) }}">{{ testimonial.occupation|striptags|raw }}</a></td>
                        <td><a href="{{ path('admin_testimonial_edit', {'id':testimonial.id}) }}">{{ testimonial.content|striptags|truncate(50, '…')|raw }}</a></td>
                        <td><a href="{{ path('admin_testimonial_edit', {'id':testimonial.id}) }}">{{ testimonial.created|date("d/m/Y") }}</a></td>
                        <td class="action">
                            <a class="edit" href="{{ path('admin_testimonial_edit', {'id':testimonial.id}) }}">
                                <span>{{ 'action.edit.label'|trans({}, 'action') }}</span>
                            </a>
                        </td>
                        <td class="action">
                            <label for="testimonial-{{ testimonial.id }}-active">Actif</label>    
                            <input
                                {% if testimonial.isactive %} checked="checked"{% endif %}
                                id="testimonial-{{ testimonial.id }}-active"
                                class="input-active"
                                data-url="{{ path('admin_testimonial_actif')}}"
                                type="checkbox"
                                value="{{ testimonial.id }}"
                            />
                            <span class="checkbox"></span>
                        </td>
                        <td class="action">
                            <a class="delete-element" href="{{ path('admin_testimonial_delete', {'id':testimonial.id}) }}">
                                <span>{{ 'action.delete.label'|trans({}, 'action') }}</span>
                            </a>
                        </td>
                    </tr>
                {% else %}
                    <tr>
                        <td colspan="7"></td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>

    {{ include('Admin/Paginator/pagination.html.twig', {pages:nb_pages}) }}
{% endblock %}
