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

<product-unit-price ref="productUnitPrice" inline-template key-form="productfamily">
    <div class="row">

        {{ macros.startCard(4, 'ProductFamily.parameters','light') }}
        <div class="col-12">
            {{ form_row(form.activeProducts, {"attr": {"v-model": 'activeProducts'}}) }}
        </div>
        <div class="col-12" v-show="activeProducts == true">
            {{ form_row(form.productsType) }}
            {{ form_row(form.quantityLabel) }}

            {{ form_row(form.behaviorAddToCart) }}
        </div>

        <div class="col-12 form-group" v-show="activeProducts == true">
            {{ form_label(form.behaviorPrice) }}
            {% for field in form.behaviorPrice %}
                {{ form_widget(field, {"attr" : {"v-model" : 'behaviorPrice'}}) }}
            {% endfor %}
        </div>
        {{ macros.endCard(true) }}


        {{ macros.startCard(0, 'ProductFamily.tax','light') }}
        <div class="col-12">
            {{ form_row(form.taxRate, {'attr': {'v-model':'taxRate'}}) }}
        </div>
        <div class="col-12">
            {{ form_row(form.differentSupplierTaxRate, {'attr': {'v-model':'differentSupplierTaxRate'}}) }}
        </div>
        <div class="col-12" v-show="differentSupplierTaxRate == true">
            {{ form_row(form.supplierTaxRate, {'attr': {'v-model':'supplierTaxRate'}}) }}
        </div>

        {{ macros.endCard() }}

        {{ macros.startCard(8, 'ProductFamily.priceAndUnit','light') }}


        <div class="col-12 field-unit-quantity">
            <div class="row">
                <div class="col-6">
                    {{ form_row(form.unit, {"attr":{'v-model': 'unit', '@change': "unitUpdated"}}) }}
                </div>

                <div class="col-6" v-show="behaviorPrice=='by-piece'">
                    <div class="form-group field-weight">
                        {{ form_label(form.quantity) }}
                        <div class="form-widget">
                            <div class="input-group">
                                {{ form_widget(form.quantity, {'attr' : {'v-model': 'quantity', '@change': "quantityUpdated"}}) }}
                                <div class="input-group-append">
                                    <span class="input-group-text">${ unitWording }</span>
                                </div>
                            </div>
                            {{ form_help(form.quantity) }}
                        </div>
                    </div>
                </div>
            </div>
        </div>

        {{ macros.priceField(form.buyingPrice, form.buyingPriceWithTax, 'buyingPrice', 'by-piece') }}

        {{ macros.priceField(form.buyingPriceByRefUnit, form.buyingPriceByRefUnitWithTax, 'buyingPriceByRefUnit', 'by-reference-unit') }}


        <div class="form-group field-price col-12">
            <div class="row">
                <div class="col-6">
                    <div class="form-widget">
                        {{ form_label(form.multiplyingFactor) }}
                        <div class="input-group multiplyingFactor">
                            {{ form_widget(form.multiplyingFactor, {'attr': {'v-model':'multiplyingFactor', '@change' : 'multiplyingFactorUpdated'}}) }}
                            <div class="input-group-append">
                                <span class="input-group-text">X</span>
                            </div>
                        </div>
                    </div>

                </div>
                <div class="col-6">
                    <div class="row">
                        <div class="col-12">
                            <label>Marge</label>
                        </div>
                        <div class="col-6">
                            <div class="form-widget">
                                <div class="input-group">
                                    <input class="form-control" disabled :value="productFamily.marginProfit">
                                    <div class="input-group-append">
                                        <span class="input-group-text">€</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-6">
                            <div class="form-widget">
                                <div class="input-group">
                                    <input class="form-control" disabled :value="productFamily.marginProfitPercent">
                                    <div class="input-group-append">
                                        <span class="input-group-text">%</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>


        {{ macros.priceField(form.price, form.priceWithTax, 'price', 'by-piece') }}
        {{ macros.priceField(form.priceByRefUnit, form.priceByRefUnitWithTax, 'priceByRefUnit', 'by-reference-unit') }}


        <div class="form-group field-reduction-apply col-12" v-show="reductionActive">
            <div class="row">
                <div class="col-12 align-content-center">
                    <h6>Réduction appliqué</h6>
                </div>
                <div class="col-6">
                    <div class="row">
                        <div class="col-12">
                            <label>Marge</label>
                        </div>
                        <div class="col-6">
                            <div class="form-widget">
                                <div class="input-group  text-danger">
                                    <input class="form-control text-danger" disabled :value="marginProfitWithReduction">
                                    <div class="input-group-append">
                                        <span class="input-group-text">€</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-6">
                            <div class="form-widget">
                                <div class="input-group">
                                    <input class="form-control text-danger" disabled
                                           :value="marginProfitPercentWithReduction">
                                    <div class="input-group-append">
                                        <span class="input-group-text">%</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-6">
                    <label>Prix de vente TTC</label>
                    <div class="form-widget">
                        <div class="input-group  text-danger">
                            <input class="form-control text-danger" disabled :value="finalPriceWithTaxAndReduction">
                            <div class="input-group-append">
                                <span class="input-group-text">€</span>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>


        {{ macros.endCard() }}

    </div>
</product-unit-price>
