{% extends 'admin/base.html.twig' %}

{% block title %}{{ 'trans.Execute action on filtered listings' | trans }}{% endblock %}

{% block body %}
    <div class="container mt-3">
        <h1>{{ 'trans.Execute action on filtered listings' | trans }}</h1>

        <div class="alert alert-warning">
            <h3 class="text-danger">{{ 'trans.IMPORTANT!' | trans }}</h3>

            <div>{{ 'trans.Make sure you execute action on correctly filtered listings' | trans }}</div>
        </div>

        <div class="alert alert-danger">
            {{~ 'trans.Number of listings changed by this action would be:' | trans -}}
            {{- ' ' -}}
            {{- affectedCount | thousandsSeparate -}}

            {%- if affectedPercentage > 1 -%}
                {{- '(' -}}{{- affectedPercentage | round -}}{{- '% ' -}}{{- 'trans.of all' | trans -}}{{- ')' -}}
            {%- endif -%}

            {% if affectedPercentage > 80 %}
                <h1 class="text-danger">
                    {{- 'trans.This action will be executed on %percentage%% of listings (almost every listing), are you REALLY sure you want to execute it?' | trans({'%percentage%': affectedPercentage}) -}}
                </h1>
            {% endif %}
        </div>

        <div>
            {{ form_start(form) }}
            {{ form_widget(form) }}

            <button
                    data-confirm-message="{{ 'trans.Execute action on %number% of listings?' | trans({'%number%': affectedCount | thousandsSeparate}) }}"
                    class="btn btn-danger js__confirm"
            >
                {{- 'trans.Execute action on filtered listings' | trans -}}
            </button>
            <span class="badge badge-warning align-middle">
                {{- 'trans.changes:' | trans -}}
                {{- ' ' -}}
                {{- affectedCount | thousandsSeparate -}}
                {{- ' ' -}}
                {%- if affectedPercentage > 1 -%}
                    {{- '(' -}}{{- affectedPercentage | round -}}{{- '% ' -}}{{- 'trans.of all' | trans -}}{{- ')' -}}
                {%- endif -%}
            </span>
            {{ form_end(form) }}
        </div>
    </div>
{% endblock %}

{% block js %}
    {{ encore_entry_link_tags('admin_listing_execute_on_filtered') }}
    {{ encore_entry_script_tags('admin_listing_execute_on_filtered') }}
{% endblock js %}
