{% use 'bootstrap_3_layout.html.twig' %}

{% block collection_widget %}
    {% if prototype is defined %}
        {% set attr = attr|merge({'data-prototype': form_row(prototype)}) %}
        {% set attr = attr|merge({'data-prototype-name': prototype.vars.name}) %}
    {% endif %}
    {% set attr = attr|merge({'data-allow-add': allow_add ? 1 : 0}) %}
    {% set attr = attr|merge({'data-allow-remove': allow_delete ? 1 : 0 }) %}
    {% set attr = attr|merge({'data-name-prefix': full_name}) %}
    {{ block('form_widget') }}
{% endblock collection_widget %}

{% block product_variant_widget %}
    {% set variantCollapseId = form.vars.id ~ '_collapse' %}
    {% set variantHeadingId = form.vars.id ~ '_heading' %}
    {% set variantTitle = 'Nouvelle variante' %}
    {% if form.vars.data and form.vars.data.type %}
        {% if form.vars.data.type.info %}
            {% set variantTitle = form.vars.data.type.name ~ ' (' ~ form.vars.data.type.info ~ ')' %}
        {% else %}
            {% set variantTitle = form.vars.data.type.name %}
        {% endif %}
    {% endif %}
    <div class="panel panel-default product-variant-panel" data-variant-panel>
        <div class="panel-heading" id="{{ variantHeadingId }}">
            <h4 class="panel-title">
                <a class="collapsed product-variant-toggle"
                   data-toggle="collapse"
                   href="#{{ variantCollapseId }}"
                   style="display:block; margin:-10px -15px; padding:10px 15px;"
                   aria-expanded="false"
                   aria-controls="{{ variantCollapseId }}">
                    <span data-variant-title>{{ variantTitle }}</span>
                    <i class="fa fa-chevron-right pull-right" data-variant-chevron aria-hidden="true"></i>
                </a>
            </h4>
        </div>
        <div id="{{ variantCollapseId }}"
             class="panel-collapse collapse"
             data-variant-collapse
             aria-labelledby="{{ variantHeadingId }}">
            <div class="panel-body">
                <div class="row">
                    <div class="col-md-3">
                        <div class="col-md-12">
                            <div class="row">
                                {% if is_granted('ROLE_ADMIN') or is_granted('ROLE_PRODUCT') %}
                                    {{ form_row(form.type) }}
                                {% elseif form.vars.data is not null %}
                                    <h3>{{ form.vars.data.type.name }}</h3>
                                    <br/>
                                {% endif %}
                            </div>
                        </div>
                    </div>
                    <div class="col-md-3">
                        <div class="col-md-12">
                            <div class="row">
                                {% if is_granted('ROLE_ADMIN') or is_granted('ROLE_PRODUCT') %}
                                    {{ form_row(form.lot) }}
                                {% endif %}
                            </div>
                        </div>
                    </div>
                    <div class="col-md-3">
                        <div class="col-md-12">
                            <div class="row">
                                {% if is_granted('ROLE_ADMIN') or is_granted('ROLE_PRODUCT') %}
                                    {{ form_row(form.byDefault) }} {{ form_row(form.unPublished) }} {{ form_row(form.soldOut) }}
                                {% else %}
                                    {{ form_row(form.unPublished) }} {{ form_row(form.soldOut) }}
                                {% endif %}
                            </div>
                        </div>
                    </div>
                    <div class="col-md-3 actions">
                        {% if is_granted('ROLE_ADMIN') or is_granted('ROLE_PRODUCT') %}
                            <a href="#" class="collection-up btn btn-default"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
                            <a href="#" class="collection-down btn btn-default"><i class="fa fa-arrow-down"
                                                                                   aria-hidden="true"></i></a>
                            <a href="#" class="collection-remove btn btn-default"><i class="fa fa-trash" aria-hidden="true"></i></a>
                            {{ form_widget(form.position) }}
                        {% else %}
                            <a href="#" class="collection-up btn btn-default hidden"><i class="fa fa-arrow-up"
                                                                                        aria-hidden="true"></i></a>
                            <a href="#" class="collection-down btn btn-default hidden"><i class="fa fa-arrow-down"
                                                                                          aria-hidden="true"></i></a>
                            <a href="#" class="collection-remove btn btn-default hidden"><i class="fa fa-trash"
                                                                                            aria-hidden="true"></i></a>
                        {% endif %}
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <div id="{{ form.prices.vars.id }}">
                            <ul class="nav nav-tabs">
                                {% for price in form.prices.children | sort((a, b) => a.vars.data.group.position <=> b.vars.data.group.position) %}
                                    <li class="{% if loop.first %}active{% endif %}">
                                        <a href="#{{ price.vars.id }}" data-toggle="tab">{{ price.vars.data.group.name }}</a>
                                    </li>
                                {% endfor %}
                            </ul>
                            <div class="tab-content clearfix">
                                {% for price in form.prices.children | sort((a, b) => a.vars.data.group.position <=> b.vars.data.group.position) %}
                                    {{ form_widget(price) }}
                                {% endfor %}
                            </div>
                        </div>
                        <hr>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-4">
                        {{ form_row(form.stockAt) }}
                    </div>
                    <div class="col-md-4">
                        {{ form_row(form.stock) }}
                    </div>
                    <div class="col-md-4">
                        {% if form.vars.data and form.vars.data.stock  %}<strong>Vendu depuis {{ form.stockAt.vars.data|date('d-m-Y H:i')}} : </strong><br/>
                            {{ (form.vars.data)|saleSinceStockAt }}
                        {% endif %}
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}
{% block product_price_widget %}
    <div class="tab-pane {% if form.vars.data.group.position == '0' %}active{% endif %}" id="{{ form.vars.id }}">
        {{ form_widget(form) }}
    </div>
{% endblock %}
{% block assemblage_widget %}
    <div class="row">
        <div class="col-md-8">
            {{ form_widget(form) }}
        </div>
        <div class="col-md-4 actions">
            <a href="#" class="collection-up btn btn-default"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
            <a href="#" class="collection-down btn btn-default"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
            <a href="#" class="collection-remove btn btn-default"><i class="fa fa-trash" aria-hidden="true"></i></a>
        </div>
    </div>
{% endblock %}
{% block product_option_widget %}
    <div class="row d-flex">
        <div class="col-md-6">
            {{ form_row(form.translations) }}
        </div>
        <div class="col-md-2">
            {{ form_row(form.multiple) }}
        </div>
        <div class="col-md-4 actions align-middle">
            <a href="#" class="collection-up btn btn-default"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
            <a href="#" class="collection-down btn btn-default"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
            <a href="#" class="collection-remove btn btn-default"><i class="fa fa-trash" aria-hidden="true"></i></a>
        </div>
    </div>
{% endblock %}
{% block shop_config_multiple_widget %}
    <div class="row">
        <div class="col-md-1">
            {{ form_row(form.qtyOf) }}
        </div>
        <div class="col-md-1">
            {{ form_row(form.qtyAt) }}
        </div>
        <div class="col-md-2">
            {{ form_row(form.multiple) }}
        </div>
        <div class="col-md-2">
            {{ form_row(form.minimum) }}
        </div>
        <div class="col-md-2">
            {{ form_row(form.zones) }}
        </div>
        <div class="col-md-2">
            {{ form_row(form.types) }}
        </div>
        <div class="col-md-2 actions">
            <a href="#" class="collection-up btn btn-default"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
            <a href="#" class="collection-down btn btn-default"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
            <a href="#" class="collection-remove btn btn-default"><i class="fa fa-trash" aria-hidden="true"></i></a>
        </div>
    </div>
{% endblock %}
{% block image_widget %}
    <div class="row">
        <div class="col-md-8">
            <div class="row ">
                <div class="col-sm-12">
                    {% if form.vars.title %}
                        {{ form_row(form.title) }}
                    {% endif %}
                    {{ form_widget(form.file) }}
                </div>
            </div>
            {% if form.vars.data is not null %}
                {% if form.vars.data.path is not null %}
                    <img class="media-file"
                         src="{{ asset(form.vars.data.path) | imagine_filter('relative_widen_100_filter') }}"
                         data-id="{{ form.vars.data.id.__toString }}">
                {% endif %}
            {% endif %}
        </div>
        {% if form.parent.parent is not null %}
            <div class="col-md-4 actions">
                <a href="#" class="collection-up btn btn-default"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
                <a href="#" class="collection-down btn btn-default"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
                <a href="#" class="collection-remove btn btn-default"><i class="fa fa-trash" aria-hidden="true"></i></a>
            </div>
        {% else %}
            {% if form.vars.data is not null %}
                {% if form.vars.data.path is not null %}
                    <div class="col-md-4 actions">
                        <a href="#" class="remove-media btn btn-default" data-id="{{ form.vars.data.id.__toString }}"><i
                                    class="fa fa-trash" aria-hidden="true"></i></a>
                    </div>
                {% endif %}
            {% endif %}
        {% endif %}

    </div>
{% endblock %}
{% block room_widget %}
    <div class="row">
        <div class="col-md-8">
            <div class="panel panel-info">
                <div class="panel-heading">
                    Texte & Description
                </div>
                <div class="panel-body">
                    {{ form_row(form.translations) }}
                </div>
            </div>
        </div>
        <div class="col-md-4">
            <div class="panel panel-info">
                <div class="panel-heading">
                    Images
                </div>
                <div class="panel-body">
                    {{ form_row(form.images) }}
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12 actions">
            <a href="#" class="collection-up btn btn-default"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
            <a href="#" class="collection-down btn btn-default"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
            <a href="#" class="collection-remove btn btn-default"><i class="fa fa-trash" aria-hidden="true"></i></a>
        </div>
    </div>

{% endblock %}
{% block trumbowyg_widget %}
    {% set attr = attr|merge({class: (attr.class|default('') ~ ' trumbowyg form-control')|trim}) %}
    {{ block('textarea_widget') }}
{% endblock %}

{% block file_media_widget %}
    <div class="row ">
        <div class="col-md-6">
            {{ form_widget(form.file) }}
        </div>
        <div class="col-md-3">
            {% if form.vars.data is not null %}
                {% if form.vars.data.path is not null %}
                    <a href="{{ asset(form.vars.data.path) | file_path }}" target="_blank"><i
                                class="media-file far fa-file-pdf fa-5x"
                                data-id="{{ form.vars.data.id.__toString }}"></i></a>
                {% endif %}
            {% endif %}
        </div>
        <div class="col-md-3">
            {% if form.vars.data is not null %}
                {% if form.vars.data.path is not null and form.vars.required == false %}
                    <a href="#" class="remove-media btn btn-default" data-id="{{ form.vars.data.id.__toString }}"><i
                                class="fa fa-trash" aria-hidden="true"></i></a>
                {% endif %}
            {% endif %}
        </div>
    </div>
    <div class="row ">
        <div class="col-sm-12">
            {% if form.vars.title %}
                {{ form_row(form.title) }}
            {% endif %}
        </div>
    </div>
{% endblock %}

{% block a2lix_translations_widget %}
    {{ form_errors(form) }}

    <div class="a2lix_translations">
        <ul class="a2lix_translationsLocales nav nav-tabs" role="tablist">
            {% for translationsFields in form %}
                {% set locale = translationsFields.vars.name %}

                <li class="nav-item {% if app.request.locale == locale %}active{% endif %}">
                    <a href="#" class="nav-link {% if app.request.locale == locale %}active{% endif %}"
                       data-toggle="tab"
                       data-target=".{{ translationsFields.vars.id }}_a2lix_translationsFields-{{ locale }}" role="tab"
                       aria-expanded="true">
                        {{ translationsFields.vars.label|default(locale|humanize)|trans }}
                        {% if form.vars.default_locale == locale %}{{ '[Default]'|trans }}{% endif %}
                        {% if translationsFields.vars.required %}*{% endif %}
                    </a>
                </li>
            {% endfor %}
        </ul>

        <div class="a2lix_translationsFields tab-content">
            {% for translationsFields in form %}
                {% set locale = translationsFields.vars.name %}

                <div class="{{ translationsFields.vars.id }}_a2lix_translationsFields-{{ locale }} tab-pane {% if app.request.locale == locale %}active{% endif %} {% if not form.vars.valid %}sonata-ba-field-error{% endif %}"
                     role="tabpanel">
                    {{ form_errors(translationsFields) }}
                    {% if translationsFields.vars.required %}
                        {{ form_widget(translationsFields) }}
                    {% else %}
                        {% for translationField in translationsFields %}
                            {{ form_row(translationField, {'required': false}) }}
                        {% endfor %}
                    {% endif %}
                </div>
            {% endfor %}
        </div>
    </div>
{% endblock %}

{% block a2lix_translationsForms_widget %}
    {{ block('a2lix_translations_widget') }}
{% endblock %}
