Browse Source

Merge branch 'develop' of https://gitea.laclic.fr/Laclic/LcShopBundle into develop

feature/export_comptable
Guillaume 4 years ago
parent
commit
08b4b9b3cf
7 changed files with 546 additions and 516 deletions
  1. +1
    -1
      ShopBundle/Resources/public/js/backend/script/default/utils.js
  2. +0
    -23
      ShopBundle/Resources/public/js/backend/script/productfamily/init-edit.js
  3. +512
    -447
      ShopBundle/Resources/public/js/backend/script/productfamily/vuejs-product-family.js
  4. +18
    -30
      ShopBundle/Resources/views/backend/productfamily/advanced_edition.html.twig
  5. +2
    -2
      ShopBundle/Resources/views/backend/productfamily/form.html.twig
  6. +4
    -4
      ShopBundle/Resources/views/backend/productfamily/macros.html.twig
  7. +9
    -9
      ShopBundle/Resources/views/backend/productfamily/panel_products.html.twig

+ 1
- 1
ShopBundle/Resources/public/js/backend/script/default/utils.js View File

} }


function getMarginPercent(price, buyingPrice){ function getMarginPercent(price, buyingPrice){
return parseFloat(((price - buyingPrice) / buyingPrice) * 100).toFixed(2);
return parseFloat(((price - buyingPrice) / price) * 100).toFixed(2);
} }


function applyReductionPercent(price, percentage) function applyReductionPercent(price, percentage)

+ 0
- 23
ShopBundle/Resources/public/js/backend/script/productfamily/init-edit.js View File

jQuery(document).ready(function () {
initLcSortableProductsList();
});

function initLcSortableProductsList() {
if ($('.lc-sortable-products').length > 0) {
$('.lc-sortable-products tbody').sortable({
placeholder: "ui-state-highlight"
});
$('.lc-sortable-products tbody').on("sortupdate", function (event, ui) {
updateSortableProducts();
});
}
}


function updateSortableProducts() {
if ($('.lc-sortable-products').length > 0) {
$('.lc-sortable-products tr.lc-draggable').each(function (index, li) {
$(li).find('.field-position').val(index);
});
}
}

+ 512
- 447
ShopBundle/Resources/public/js/backend/script/productfamily/vuejs-product-family.js
File diff suppressed because it is too large
View File


+ 18
- 30
ShopBundle/Resources/views/backend/productfamily/advanced_edition.html.twig View File

}; };
window.appProductFamilyValues = {}; window.appProductFamilyValues = {};
window.productUnitPriceValues = {}; window.productUnitPriceValues = {};
window.productForm ={};
window.formProductTemplate = {};

</script> </script>


<ul id="product-family-advanced-types-list"> <ul id="product-family-advanced-types-list">
</product-unit-price> </product-unit-price>





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

{#{% import _self as formMacros %}#}
<div class="row">
{{ macros.startCard(12, 'ProductFamily.products', 'light', true) }}

<table class="table datagrid sortable lc-sortable-products products-collection-table" <table class="table datagrid sortable lc-sortable-products products-collection-table"
:data-index="formProductArray.length"
data-prototype="{{ product_family_macros.product_row(form.products.vars.prototype)|e('html_attr') }}">
:data-index="formProducts.length"
data-prototype="{{ product_family_macros.product_row(advancedType.products.vars.prototype)|e('html_attr') }}">
<thead> <thead>
<tr> <tr>
<th> <th>
</thead> </thead>
<tbody class="products-collection"> <tbody class="products-collection">


<template v-for="(formProduct, key) in formProductArray">
<product-form ref="productForm" v-bind:product-family="productFamily" :template="formProduct"
:key-form="key"></product-form>
<template>
<product-form v-for="(formProduct, blop) in formProducts" v-bind:key="formProductKey[blop]"
:key-form="formProductKey[blop]" ref="productForm" v-bind:product-family="productFamily"
:template="formProduct"></product-form>
</template> </template>

</tbody> </tbody>
<tfoot> <tfoot>
<th> <th>
${productFamily.priceWithTax} ${productFamily.priceWithTax}
</th> </th>
<th colspan="2" class="price"> <th colspan="2" class="price">
${productFamily.marginProfit}€<br />
${productFamily.marginProfit}€<br/>
${productFamily.marginProfitPercent}% ${productFamily.marginProfitPercent}%
</td> </td>




<div class="clearfix"></div> <div class="clearfix"></div>


{{ macros.endCard() }}
</div>
{% do form.products.setRendered %}

{% do advancedType.products.setRendered %}
<script> <script>
window.productForm = new Array();
window.formProductTemplate = new Array();
window.productForm[{{ i }}] ={};
window.formProductTemplate[{{ i }}] = {};

{% for keyForm,y in sortableProductsField[i] %}
{% set product = advancedType.products[y] %}


{% for keyForm,i in sortableProductsField %}
{% set product = form.products[i] %}


window.productForm[{{ i }}][{{ keyForm }}] = { window.productForm[{{ i }}][{{ keyForm }}] = {
{% if product.vars.value.position %}position: "{{ product.vars.value.position }}",{% endif %}
{% if product.vars.value.title %}title: "{{ product.vars.value.title }}",{% endif %} {% if product.vars.value.title %}title: "{{ product.vars.value.title }}",{% endif %}
{% if product.vars.value.quantity %}quantity: "{{ product.vars.value.quantity }}",{% endif %} {% if product.vars.value.quantity %}quantity: "{{ product.vars.value.quantity }}",{% endif %}
{% if product.vars.value.unit %}unit: {{ product.vars.value.unit.id }},{% endif %} {% if product.vars.value.unit %}unit: {{ product.vars.value.unit.id }},{% endif %}
{% if product.vars.value.propertyExpirationDate %}propertyExpirationDate: "{{ product.vars.value.propertyExpirationDate }}",{% endif %} {% if product.vars.value.propertyExpirationDate %}propertyExpirationDate: "{{ product.vars.value.propertyExpirationDate }}",{% endif %}
{#{% if product.vars.value.expirationDate %}expirationDate: "{{ product.vars.value.expirationDate|date('d/m/Y') }}"{% endif %}#} {#{% if product.vars.value.expirationDate %}expirationDate: "{{ product.vars.value.expirationDate|date('d/m/Y') }}"{% endif %}#}
}; };
window.formProductTemplate[{{ keyForm }}] = '{{ product_family_macros.product_row(product, totalProductOrdered[product.vars.value.id])|replace({"\n":' ', "\r":' ', "'" : "\\'"})|raw }}';
window.formProductTemplate[{{ i }}][{{ keyForm }}] = '{{ product_family_macros.product_row(product, totalProductOrdered[i][product.vars.value.id])|replace({"\n":' ', "\r":' ', "'" : "\\'"})|raw }}';
{% endfor %} {% endfor %}


</script> </script>






{{ form_end(advancedType) }} {{ form_end(advancedType) }}
</div> </div>
</li> </li>

+ 2
- 2
ShopBundle/Resources/views/backend/productfamily/form.html.twig View File

<div class="lc-vue-js-container card-header p-0 border-bottom-0"> <div class="lc-vue-js-container card-header p-0 border-bottom-0">
<ul class="nav nav-tabs" id="nav-params"> <ul class="nav nav-tabs" id="nav-params">
<li class="nav-item" v-for="section in sectionsArray"> <li class="nav-item" v-for="section in sectionsArray">
<button type="button"
<a :href="'#'+section.name" type="button"
v-if="(section.name == 'products' && activeProducts == true) || (section.name != 'products')" v-if="(section.name == 'products' && activeProducts == true) || (section.name != 'products')"
:class="'btn '+((currentSection == section.name) ? 'btn btn-primary' : 'btn ')" :class="'btn '+((currentSection == section.name) ? 'btn btn-primary' : 'btn ')"
@click="changeSection(section)"> @click="changeSection(section)">
<span v-if="section.name == 'products'">({{ form.products|length }})</span> <span v-if="section.name == 'products'">({{ form.products|length }})</span>
<span class="glyphicon glyphicon-triangle-bottom"></span> <span class="glyphicon glyphicon-triangle-bottom"></span>
<i class="fa fa-exclamation-circle invalid-form"></i> <i class="fa fa-exclamation-circle invalid-form"></i>
</button>
</a>


</li> </li>
</ul> </ul>

+ 4
- 4
ShopBundle/Resources/views/backend/productfamily/macros.html.twig View File

{% if field_display == false %}{% set field_display = field_name %}{% endif %} {% if field_display == false %}{% set field_display = field_name %}{% endif %}


<td {{ attr|raw }} colspan="{{ colspan }}" class="{{ field_name }}"> <td {{ attr|raw }} colspan="{{ colspan }}" class="{{ field_name }}">
<div class="value" v-show="{{ field_name }}Inherited == false" v-on:click="setFocusOnField('{{ field_name }}Inherited', keyForm)">
<div class="value" v-show="{{ field_name }}Inherited == false" @click="setFocusOnField('{{ field_name }}Inherited', keyForm)">
<div v-if="{{ field_name }}"> <div v-if="{{ field_name }}">
{% verbatim %}{{ {% endverbatim %}{{ field_display }} {% verbatim %}}}{% endverbatim %}{{ display_suffix }} {% verbatim %}{{ {% endverbatim %}{{ field_display }} {% verbatim %}}}{% endverbatim %}{{ display_suffix }}
{% if field_name == 'priceWithTax' %} {% if field_name == 'priceWithTax' %}
{% macro product_row(product, totalProductOrdered) %} {% macro product_row(product, totalProductOrdered) %}


<tr class="lc-draggable"> <tr class="lc-draggable">
<td><i class="fa fa-fw fa-sort"></i></td>
<td>{% verbatim %}{{keyForm}}{% endverbatim %}<i class="fa fa-fw fa-sort"></i></td>
{{ _self.product_field(4, product.title, 'title') }} {{ _self.product_field(4, product.title, 'title') }}
{{ _self.product_field(2, product.quantity, 'quantity') }} {{ _self.product_field(2, product.quantity, 'quantity') }}
{{ _self.product_field(2, product.unit, 'unit', 'unitWording') }} {{ _self.product_field(2, product.unit, 'unit', 'unitWording') }}
{{ _self.product_field(3, product.buyingPriceWithTax, 'buyingPriceWithTax',false, '€', 'v-show="productFamily.behaviorPrice == \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') ~ '\'"') }} {{ _self.product_field(3, product.buyingPriceWithTax, 'buyingPriceWithTax',false, '€', 'v-show="productFamily.behaviorPrice == \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') ~ '\'"') }}


<td colspan="3" v-show="productFamily.behaviorPrice == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') }}'"> <td colspan="3" v-show="productFamily.behaviorPrice == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') }}'">
{% verbatim %}{{ buyingPriceWithTax }}{% endverbatim %}€
{% verbatim %}{{ buyingPriceValue }}{% endverbatim %}€
</td> </td>


{{ _self.product_field(3, product.multiplyingFactor, 'multiplyingFactor') }} {{ _self.product_field(3, product.multiplyingFactor, 'multiplyingFactor') }}


</td> </td>
<td colspan="2"> <td colspan="2">
<button type="button" class="btn-remove-product btn-sm btn-info" @click="modalProductForm()">
<button type="button" class="btn-sm btn-info" @click="modalProductForm()">
<i class="fa fa-edit"></i> <i class="fa fa-edit"></i>
</button> </button>
<button type="button" class="btn-remove-product btn-sm btn-danger" @click="deleteProductForm()"> <button type="button" class="btn-remove-product btn-sm btn-danger" @click="deleteProductForm()">

+ 9
- 9
ShopBundle/Resources/views/backend/productfamily/panel_products.html.twig View File

{{ macros.startCard(12, 'ProductFamily.products', 'light', true) }} {{ macros.startCard(12, 'ProductFamily.products', 'light', true) }}


<table class="table datagrid sortable lc-sortable-products products-collection-table" <table class="table datagrid sortable lc-sortable-products products-collection-table"
:data-index="formProductArray.length"
:data-index="formProducts.length"
data-prototype="{{ product_family_macros.product_row(form.products.vars.prototype)|e('html_attr') }}"> data-prototype="{{ product_family_macros.product_row(form.products.vars.prototype)|e('html_attr') }}">
<thead> <thead>
<tr> <tr>
PA TTC / ${ getUnitReference() } PA TTC / ${ getUnitReference() }
</th> </th>


<th colspan="3" class="price"
v-show="getBehaviorPrice() =='{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') }}'">
<th colspan="3" class="price">
PA HT PA HT
</th> </th>
<th colspan="3" class="price">
<th colspan="3" class="price"
v-show="getBehaviorPrice() =='{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') }}'">
PA TTC PA TTC
</th> </th>
<th colspan="3" class=""> <th colspan="3" class="">
<tbody class="products-collection"> <tbody class="products-collection">


<template> <template>
<product-form v-for="(formProduct, blop) in formProductArray" v-bind:key="formProductKey[blop]"
:key-form="formProductKey[blop]" ref="productForm" v-bind:product-family="productFamily"
<product-form v-for="(formProduct, blop) in formProducts" v-bind:key="blop"
:key-form="blop" ref="productForm" v-bind:product-family="productFamily"
:template="formProduct"></product-form> :template="formProduct"></product-form>
</template> </template>
</tbody> </tbody>
${productFamily.buyingPriceByRefUnitWithTax} ${productFamily.buyingPriceByRefUnitWithTax}
</th> </th>


<th colspan="3" class="price"
v-show="getBehaviorPrice() =='{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') }}'">
<th colspan="3" class="price">
${productFamily.buyingPrice} ${productFamily.buyingPrice}
</th> </th>
<th colspan="3" class="price">
<th colspan="3" class="price"
v-show="getBehaviorPrice() =='{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') }}'">
${productFamily.buyingPriceWithTax} ${productFamily.buyingPriceWithTax}
</th> </th>
<th colspan="3" class=""> <th colspan="3" class="">

Loading…
Cancel
Save