{{ form_start(form, {"attr": {'@change' : 'formUpdated'}}) }}
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %}
{% import '@LcShop/backend/productfamily/macros.html.twig' as product_family_macros %}

{% set formValues = form.vars.value %}

<div id="lc-product-family-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">
                    <a :href="'#'+section.name" type="button"
                            v-if="(section.name == 'products' && activeProducts == true) || (section.name != 'products')"
                            :class="'btn '+((currentSection == section.name) ? 'btn btn-primary' : 'btn ')"
                            @click="changeSection(section)">
                        ${ section.nameDisplay }
                        <span v-if="section.name == 'products'">({{ form.products|length }})</span>
                        <span class="glyphicon glyphicon-triangle-bottom"></span>
                        <i class="fa fa-exclamation-circle invalid-form"></i>
                    </a>

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

        <script>
            window.mixinUnitValues = {
                unitsList: {{ getUnitsList()|json_encode|raw }}
            };
            window.mixinPriceValues = {
                taxRatesList: {{ getTaxRatesList()|json_encode|raw }}
            };
            window.appProductFamilyValues = {
                {% if formValues.title %}title: "{{ formValues.title }}",{% endif %}
                {% if form.behaviorCountStock.vars.value %}behaviorCountStock: "{{ form.behaviorCountStock.vars.value }}",{% endif %}
                {% if form.behaviorStockWeek.vars.value %}behaviorStockWeek: "{{ form.behaviorStockWeek.vars.value }}",{% endif %}
                {% if formValues.availableQuantity %}availableQuantity: "{{ formValues.availableQuantity }}",{% endif %}
                {% if formValues.availableQuantityDefault %}availableQuantityDefault: "{{ formValues.availableQuantityDefault }}",{% endif %}
                {% if formValues.propertyOrganicLabel %}propertyOrganicLabelActive: true,{% endif %}
                {% if formValues.propertyNoveltyExpirationDate %}propertyNoveltyExpirationDateActive: true,{% endif %}
                {% if formValues.typeExpirationDate %}typeExpirationDate: "{{ formValues.typeExpirationDate }}",{% endif %}
                {% if formValues.behaviorExpirationDate %}behaviorExpirationDate: "{{ formValues.behaviorExpirationDate }}",{% endif %}
                {% if formValues.propertyExpirationDate %}propertyExpirationDate: "{{ formValues.propertyExpirationDate }}",{% endif %}
                {% if formValues.activeProducts %}activeProducts: "{{ formValues.activeProducts }}",{% endif %}

            };
            multiplyingFactor = "{{ form.multiplyingFactor.vars.value }}"
            window.productUnitPriceValues = {
                {% if formValues.activeProducts %}activeProducts: "{{ formValues.activeProducts }}",{% endif %}
                {% if formValues.behaviorPrice %}behaviorPrice: "{{ formValues.behaviorPrice }}",{% endif %}
                {% if form.multiplyingFactor.vars.value %}multiplyingFactor: parseFloat(multiplyingFactor.replace(',', '.')),{% endif %}
                {% if formValues.unit %}unit: parseInt({{ formValues.unit.id }}),{% endif %}
                {% if formValues.quantity %}quantity: parseFloat({{ formValues.quantity }}),{% endif %}
                {% if formValues.taxRate %}taxRate: parseInt({{ formValues.taxRate.id }}),{% endif %}
                {% if formValues.price %}price: parseFloat({{ formValues.price }}).toFixed(3),{% endif %}
                {% if formValues.priceByRefUnit %}priceByRefUnit: parseFloat({{ formValues.priceByRefUnit }}).toFixed(3),{% endif %}
                {% if formValues.buyingPrice %}buyingPrice: parseFloat({{ formValues.buyingPrice }}).toFixed(3),{% endif %}
                {% if formValues.buyingPriceByRefUnit %}buyingPriceByRefUnit: parseFloat({{ formValues.buyingPriceByRefUnit }}).toFixed(3),{% endif %}
                {% if formValues.supplierTaxRate %}supplierTaxRate: parseInt({{ formValues.supplierTaxRate.id }}),{% endif %}
                {% if form.supplierTaxRate.vars.value != 0 %}differentSupplierTaxRate: true{% endif %}
            }
        </script>


        <div v-show="currentSection == 'general'" class="panel panel-default">
            {% include '@LcShop/backend/productfamily/panel_general.html.twig' %}

        </div>
        <div v-show="currentSection == 'price'" class="panel panel-default">
            {% include '@LcShop/backend/productfamily/panel_price.html.twig' %}

        </div>
        <div v-show="currentSection == 'products'" class="panel panel-default">
            {% include '@LcShop/backend/productfamily/panel_products.html.twig' %}
        </div>
        <div v-show="currentSection == 'stock'" class="panel panel-default">
            {% include '@LcShop/backend/productfamily/panel_stock.html.twig' %}
        </div>

        <div v-show="currentSection == 'property'" class="panel panel-default">
            {% include '@LcShop/backend/productfamily/panel_property.html.twig' %}
        </div>

        <div v-show="currentSection == 'reduction'" class="panel panel-default">
            {% include '@LcShop/backend/productfamily/panel_reduction.html.twig' %}
        </div>
        <div v-show="currentSection == 'seo'" class="panel panel-default">
            {% include '@LcShop/backend/productfamily/panel_seo.html.twig' %}
        </div>

        <div v-show="currentSection == 'note'" class="panel panel-default">
            <div class="row">
                {{ macros.startCard(12, 'ProductFamily.note', 'light') }}
                {{ form_row(form.note) }}
                {{ macros.endCard() }}
            </div>
        </div>
        {% if entity.note|striptags !="" %}
            <div class="row">
                {{ macros.startCard(12, 'ProductFamily.note', 'light') }}
                {{ entity.note|raw }}
                {{ macros.endCard() }}
            </div>
        {% endif %}

    </div>
    {{ form_widget(form.stayOnPage, {"attr": {"v-model": "stayOnPage"}}) }}


</div>
{{ form_end(form) }}




