{% 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-6">
                {{ form_errors(form) }}
                {{ form_widget(form.search, {'attr': {'class': 'input-search'}}) }}
            </div>
            <div class="col">
                {{ macro.dropdown_search(form.category) }}
            </div>
            <div class="col">
                {{ macro.dropdown_search(form.thematic) }}
            </div>
            <div class="col">
                {{ macro.dropdown_search(form.territory) }}
            </div>
            <div class="col">
                {{ form_row(form.search_button, { 'label': 'Rechercher' }) }}
            </div>
        </div>
        {{ form_end(form) }}

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

            <div class="row">
                <div class="col">
                    <a href="" class="export export-excel" title="Exporter Excel">Exporter au format Excel</a>
                    <a href="" class="export export-pdf" title="Exporter au format PDF">Exporter au format PDF</a>
                </div>
            </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 %}