{% extends 'frontend/carto.html.twig' %}
{% import 'frontend/macro.html.twig' as macro %}

{% block carto %}
    <div id="carto-liste">
        <h1 class="title-liste">La liste simple... et rêvolutionnaire !</h1>
        {{ form_start(form, { 'attr' : { 'class': 'form-search' }}) }}
        <div class="row">
            <div class="col-12 col-sm-6">
                {{ form_errors(form) }}
                {{ form_widget(form.search, {'attr': {'class': 'input-search'}}) }}
            </div>
            <div class="col-6 col-sm">
                {{ macro.dropdown_search(form.category) }}
            </div>
            <div class="col-6 col-sm">
                {{ macro.dropdown_search(form.thematic) }}
            </div>
            <div class="col-6 col-sm col-territory">
                {{ macro.dropdown_search(form.territory) }}
            </div>
            <div class="col-6 col-sm">
                {{ form_row(form.search_button, { 'label': 'Rechercher' }) }}
            </div>
        </div>
        <div class="row">
            <div class="col">
                {{ form_widget(form.export_excel, { 'label': 'Exporter au format Excel' }) }}
                {{ form_widget(form.export_pdf, { 'label': 'Exporter au format PDF' }) }}
            </div>
        </div>
        {{ form_end(form) }}

        {% if resultArray %}
            <div class="navigation">
                {{ knp_pagination_render(resultArray) }}
            </div>

            <table class="table-search">
                <thead>
                <tr>
                    <th>Catégorie</th>
                    <th>Thématique</th>
                    <th>Contribution</th>
                    <th>Lieu</th>
                </tr>
                </thead>
                <tbody>
                {% for result in resultArray %}
                    <tr>
                        <td>
                            {{ result }}
                        </td>
                        <td>
                            {{ result.thematic }}
                        </td>
                        <td>
                            {{ result.subthematic }}
                        </td>
                        <td>
                            {% if result.individualData is not empty %}
                                {{ result.individualData.territory }}
                            {% elseif result.collectifData is not empty %}
                                {{ result.collectifData.territory }}
                            {% endif %}
                        </td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        {% endif %}
    </div>
{% endblock %}