{#
 * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
 <info@champs-libres.coop> / <http://www.champs-libres.coop>
 *
 * This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 *  License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
#}

{% extends "@ChillMain/layout.html.twig" %}

{% block title %}{{ export.title|trans }}{% endblock %}

{% block content %}
    <div class="col-md-10">

        {{ include('@ChillMain/Export/_breadcrumb.html.twig') }}

        <h1>{{ export.title|trans }}</h1>

        <p>{{ export.description|trans }}</p>

        {{ form_start(form) }}

        <section class="center mb-4">

            <h2>{{ 'Pick centers'|trans }}</h2>

            <p>{{ 'The export will contains only data from the picked centers.'|trans }}
                {{ 'This will eventually restrict your possibilities in filtering the data.'|trans }}</p>

            <h3 class="m-3">{{ 'Center'|trans }}</h3>

            {{ form_widget(form.centers.centers) }}

            <div class="mb-3 mt-3">
                <input id="toggle-check-all" class="btn btn-misc" type= "button" onclick='uncheckAll(this)' value="{{ 'uncheck all centers'|trans|e('html_attr') }}"/>
            </div>

            {% if form.centers.regroupments is defined %}
                <h3 class="m-3">{{ 'Pick aggregated centers'|trans }}</h3>
                {{ form_widget(form.centers.regroupments) }}
            {% endif %}
        </section>

        <p>{{ form_widget(form.submit, { 'attr' : { 'class' : 'btn btn-action btn-create' }, 'label' : 'Go to export options' } ) }}</p>

        {{ form_end(form) }}

    </div>
{% endblock content %}

{% block js %}

    <script>
        const uncheckAll = () => {
            const allCenters = document.getElementsByName('centers[centers][]');
            allCenters.forEach(checkbox => checkbox.checked = false)
        }
    </script>

{% endblock js %}
