{% extends kimai_context.modalRequest ? 'form.html.twig' : 'base.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}

{% block main %}
    {% if stats.count > 1000 %}
        {{ widgets.alert('warning', ('export.warn_result_amount'|trans({'%count%': stats.count})), null, 'warning') }}
    {% endif %}
    {% set formEditTemplate = kimai_context.modalRequest ? 'default/_form_modal.html.twig' : 'default/_form.html.twig' %}
    {% set formOptions = {
        'title': 'export'|trans,
        'form': form,
        'back': path(route_back),
        'formStartOptions': {'attr': {'class': 'searchform', 'target': '_blank'}},
    } %}
    {% embed formEditTemplate with formOptions %}
        {% form_theme form 'form/search.html.twig' %}
        {% block modal_size %}{% endblock %}
        {% block form_body %}
            {% set orderHasError = form.orderBy.vars.errors|length > 0 or form.order.vars.errors|length > 0 %}
            {% set orderBy = form_widget(form.orderBy) %}
            {% set order = form_widget(form.order) %}
            {{ form_rest(form) }}
            <div class="row mb-3{% if orderHasError %} is-invalid{% endif %}">
                {{ form_label(form.orderBy) }}
                <div class="col-sm-4 col-xs-4">
                    {{ orderBy|raw }}
                    {{ form_errors(form.orderBy) }}
                </div>
                <div class="col-sm-4 col-xs-3">
                    {{ order|raw }}
                    {{ form_errors(form.order) }}
                </div>
            </div>
        {% endblock %}
        {% block submit_button %}
            <div class="btn-group pull-left" role="group">
            {% for exp in exporter %}
                <button id="export-btn-{{ exp.id }}" formtarget="_blank" type="submit" name="exporter" value="{{ exp.id }}" class="btn btn-primary" data-loading-text="{{ ('button.' ~ exp.id)|trans }}…">{{ ('button.' ~ exp.id)|trans }}</button>
            {% endfor %}
            </div>
        {% endblock %}
    {% endembed %}
{% endblock %}
