{{ form_start(form) }}

{% import '@LcShop/backend/default/block/macros.html.twig' as macros %}

{% set formValues = form.vars.value %}
<div id="lc-reduction-cart-edit">
    <div class="card card-light">
        <div class="lc-vue-js-container card-header p-0 border-bottom-0">
            <ul class="nav nav-tabs" id="nav-params">
                <li class="nav-item" v-for="section in sectionsArray">
                    <button type="button"
                            :class="'btn '+((currentSection == section.name) ? 'btn btn-primary' : 'btn ')"
                            @click="changeSection(section)">
                        ${ section.nameDisplay }
                        <span class="glyphicon glyphicon-triangle-bottom"></span>
                        <i class="fa fa-exclamation-circle invalid-form"></i>
                    </button>

                </li>
            </ul>
        </div>
    </div>
    <div class="form ">

        <script>
            window.reductionCartCodesUsed = {{ list_reduction_codes()|json_encode|raw }};
            window.reductionCartValues = {
                {% if formValues.permanent is not null and formValues.permanent == false %}reductionPermanent: false,{% endif %}
                {% if formValues.behaviorTaxRate %}reductionBehaviorTaxRate: '{{ formValues.behaviorTaxRate }}',{% endif %}
                {% if formValues.value %}reductionValue: parseFloat({{ formValues.value }}),{% endif %}
                {% if formValues.unit %}reductionUnit: "{{ formValues.unit }}",{% endif %}
                {% if formValues.appliedTo %}reductionAppliedTo: "{{ formValues.appliedTo }}",{% endif %}
                {% if formValues.groupUsers is not empty %}reductionGroupUsersActive: true,{% endif %}
                {% if formValues.groupUsers is not empty %}reductionGroupUsers: {{ formValues.groupUsers|json_encode }},{% endif %}
                {% if formValues.users is not empty %}reductionUsersActive: true,{% endif %}
                {% if formValues.users is not empty %}reductionUsers: {{ formValues.users|json_encode }},{% endif %}
                {% if formValues.pointSales is not empty %}reductionPointSalesActive: true,{% endif %}
                {% if formValues.pointSales is not empty %}reductionPointSales: {{ formValues.pointSales|json_encode }},{% endif %}
                {% if formValues.deliveryZones is not empty %}reductionDeliveryZonesActive: true,{% endif %}
                {% if formValues.deliveryZones is not empty %}reductionDeliveryZones: {{ formValues.deliveryZones|json_encode }},{% endif %}
                {% if formValues.deliverySlots is not empty %}reductionDeliverySlotsActive: true,{% endif %}
                {% if formValues.deliverySlots is not empty %}reductionDeliverySlots: {{ formValues.deliverySlots|json_encode }},{% endif %}
                {% if formValues.uncombinables is not empty or formValues.uncombinableTypes %}reductionCombinable: true,{% endif %}
                {% if formValues.uncombinables is not empty %}reductionUncombinables: {{ formValues.uncombinables|json_encode }},{% endif %}
                {% if formValues.uncombinableTypes is not empty %}reductionUncombinableTypes: {{ formValues.uncombinableTypes|json_encode }},{% endif %}
             }
        </script>


        <div v-show="currentSection == 'info'" class="panel panel-default">
            {% include '@LcShop/backend/reductioncart/panel_info.html.twig' %}
        </div>
        <div v-show="currentSection == 'conditions'" class="panel panel-default">
            {% include '@LcShop/backend/reductioncart/panel_conditions.html.twig' %}
        </div>
        <div v-show="currentSection == 'actions'" class="panel panel-default">
            {% include '@LcShop/backend/reductioncart/panel_actions.html.twig' %}
        </div>
    </div>
</div>
{{ form_end(form) }}