Browse Source

[Backend] productFamilyStatitics

develop
Fab 3 years ago
parent
commit
419d777208
8 changed files with 139 additions and 42 deletions
  1. +0
    -1
      ShopBundle/Resources/public/css/backend/custom.css
  2. +55
    -1
      ShopBundle/Resources/public/js/backend/script/default/init-common.js
  3. +1
    -1
      ShopBundle/Resources/public/sass/backend/custom.scss
  4. +1
    -0
      ShopBundle/Resources/translations/lcshop.fr.yaml
  5. +3
    -0
      ShopBundle/Resources/views/backend/productfamily/edit.html.twig
  6. +39
    -24
      ShopBundle/Resources/views/backend/productfamily/macros.html.twig
  7. +27
    -15
      ShopBundle/Resources/views/backend/productfamily/panel_products.html.twig
  8. +13
    -0
      ShopBundle/Statistic/Statistic.php

+ 0
- 1
ShopBundle/Resources/public/css/backend/custom.css View File

@@ -805,7 +805,6 @@ table th .select2-container--default .select2-selection--single {

/* line 296, ../../sass/backend/custom.scss */
#lc-product-family-edit .btn-add-product {
margin: 20px 0;
float: right;
}


+ 55
- 1
ShopBundle/Resources/public/js/backend/script/default/init-common.js View File

@@ -5,7 +5,8 @@ jQuery(document).ready(function () {
initNotice();
initBtnEditReminder();
initBtnWriteToUser();
initCollectionWidget()
initCollectionWidget();
initBtnShowTotalOrderProduct();
$('form').on('focus', 'input[type=number]', function (e) {
$(this).on('wheel.disableScroll', function (e) {
e.preventDefault()
@@ -358,3 +359,56 @@ function resetNumItemsCollectionField($collectionWidget){
resetNumItemsCollectionField($collectionWidget);
});
}


function initBtnShowTotalOrderProduct(){
log( $('.lc-show-total-order-product'));
$('.lc-show-total-order-product').on('click', function (){
$btn = $(this);
var url = $(this).data('url');
$('#modal-total-order').remove();
$.ajax({
url: url,
method: "POST",
dataType: "json",
success: function (response) {
$('body').append(response.data);
$('#modal-total-order').modal('show');
initModalTotalOrderProduct(response.statistics);
}
});
});
}

function initModalTotalOrderProduct(statistics) {
chart = drawTotalOrderProduct(statistics)
}

function drawTotalOrderProduct(statictics) {
log(statictics);
var options = {
bezierCurve : false,
tooltips: {
callbacks: {
label: (item) => item.yLabel ,
},
},
};

chart = new Chart(document.getElementById("chart"), {
"type": "line",
"data": {
"labels": Object.values(statictics.label),
"datasets": [{
"label": "Total commandés/semaines ( En moyenne :"+statictics.total_average+')',
"data": Object.values(statictics.total),
"fill": false,
"borderColor": "rgb(75, 192, 192)",
"lineTension": 0.1
}]
},
"options": options
});
return chart;
}


+ 1
- 1
ShopBundle/Resources/public/sass/backend/custom.scss View File

@@ -293,7 +293,7 @@ table th .select2-container--default .select2-selection--single{padding:0.3rem 0
#lc-product-family-edit .products-collection-table th:last-child{border-right: 1px solid #dee2e6;}
#lc-product-family-edit .products-collection-table td{border-left: 1px solid #dee2e6; text-align: center; font-size: 13px; border-bottom: 1px solid #dee2e6;}
#lc-product-family-edit .products-collection-table td:last-child{border-right: 1px solid #dee2e6; white-space: nowrap; }
#lc-product-family-edit .btn-add-product {margin: 20px 0; float: right;}
#lc-product-family-edit .btn-add-product {float: right;}
#lc-product-family-edit .inherited {color: #888; font-style: italic; font-weight: initial;}
#lc-product-family-edit .products-collection-table td .value {min-width: 80%; margin: auto; min-height: 35px; cursor: pointer;}
#lc-product-family-edit .products-collection-table td .modal {text-align: left;}

+ 1
- 0
ShopBundle/Resources/translations/lcshop.fr.yaml View File

@@ -546,6 +546,7 @@ action:
product:
editStock: Gérer les stocks
editProductFamily: Éditer le produit
totalOrder: Afficher plus de semaines
user:
account: Mon compte
logout: Me déconnecter

+ 3
- 0
ShopBundle/Resources/views/backend/productfamily/edit.html.twig View File

@@ -17,6 +17,9 @@

<script src="{{ asset('bundles/lcshop/js/backend/plugin/daterange/moment.min.js')}}"></script>
<script src="{{ asset('bundles/lcshop/js/backend/plugin/daterange/daterangepicker.js')}}"></script>
<script src="{{ asset('bundles/lcshop/js/backend/plugin/chartjs/Chart.min.js') }}"></script>


{% endblock %}

{% block script_javascript %}

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

@@ -5,47 +5,58 @@
<span class="text-success"><i class="fa fa-calendar"></i> {{ weekNumber }}</span>
<span class="text-info"><i class="fa fa-shopping-basket"></i>
<strong>
{{ weekNumberQuantity is null ? 0 : weekNumberQuantity}}
{{ weekNumberQuantity is null ? 0 : weekNumberQuantity }}
</strong>
</span>
<br />
<br/>
{% endfor %}
{% endmacro total_order_product %}


{% macro total_order_product_family(totalProductOrdered, productFamily,forceByMeasure = false) %}
{% for weekNumber, weekNumberQuantity in totalProductOrdered %}
<span class="text-success"><i class="fa fa-calendar"></i> {{ weekNumber }}</span>
<span class="text-info"><i class="fa fa-shopping-basket"></i>
<button type="button" data-product-family="{{ productFamily.id }}" class="lc-show-total-order-product btn btn-sm"
data-toggle="tooltip" title="{{ 'action.product.totalOrder'|trans }}"
data-url="{{ path('easyadmin', { action: 'showTotalOrder', entity: 'ProductFamily', id: productFamily.id }) }}">
{% for weekNumber, weekNumberQuantity in totalProductOrdered %}
<span class="text-success"><i class="fa fa-calendar"></i> {{ weekNumber }}</span>
<span class="text-info"><i class="fa fa-shopping-basket"></i>
<strong>
{{ weekNumberQuantity is null ? 0 : weekNumberQuantity}}
{% if productFamily and (productFamily.behaviorCountStock== constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE') or forceByMeasure)%}
{{ weekNumberQuantity is null ? 0 : weekNumberQuantity }}
{% if productFamily and (productFamily.behaviorCountStock== constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE') or forceByMeasure) %}
{{ productFamily.unit.unitReference }}
{% endif %}
</strong>
</span>
<br />
{% endfor %}
<br/>
{% endfor %}
</button>

{% endmacro total_order_product_family %}




{% macro product_field(colspan, field, field_name, field_display = false, display_suffix="",attr="") %}

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

<td {{ attr|raw }} colspan="{{ colspan }}" class="{{ field_name }}">
<div class="value" v-show="{{ field_name }}Inherited == false" @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 }}">
{% verbatim %}{{ {% endverbatim %}{{ field_display }} {% verbatim %}}}{% endverbatim %}{{ display_suffix }}
{% if field_name == 'priceWithTax' %}
<br />
<span class="text-danger" v-show="productFamily.reductionActive">{% verbatim %}{{ finalPriceWithTaxAndReduction }}{% endverbatim %}€</span>
<br/>
<span class="text-danger"
v-show="productFamily.reductionActive">{% verbatim %}{{ finalPriceWithTaxAndReduction }}{% endverbatim %}€</span>
{% endif %}
</div>
<div v-else class="inherited">
{% verbatim %}{{ productFamily.{% endverbatim %}{{ field_display }} {% verbatim %}}}{% endverbatim %}{{ display_suffix }}
{% if field_name == 'priceWithTax' %}
<br />
<span class="text-danger" v-show="productFamily.reductionActive">{% verbatim %}{{ finalPriceWithTaxAndReduction }}{% endverbatim %}€</span>
<br/>
<span class="text-danger"
v-show="productFamily.reductionActive">{% verbatim %}{{ finalPriceWithTaxAndReduction }}{% endverbatim %}€</span>
{% endif %}

</div>
@@ -76,7 +87,8 @@
{{ _self.product_field(3, product.buyingPrice, 'buyingPrice',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 class="buyingPrice" colspan="3" v-show="productFamily.behaviorPrice == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') }}'">
<td class="buyingPrice" colspan="3"
v-show="productFamily.behaviorPrice == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') }}'">
{% verbatim %}{{ finalBuyingPrice }}{% endverbatim %}€
</td>

@@ -85,12 +97,15 @@
{{ _self.product_field(3, product.priceByRefUnitWithTax, 'priceByRefUnitWithTax',false, '€', 'v-show="productFamily.behaviorPrice == \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') ~ '\'"') }}


<td class="price" colspan="3" v-show="productFamily.behaviorPrice == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') }}'">
<td class="price" colspan="3"
v-show="productFamily.behaviorPrice == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') }}'">
{% verbatim %}{{ finalPrice }}{% endverbatim %}€
</td>
<td class="priceWithTax" colspan="3" v-show="productFamily.behaviorPrice == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') }}'">
<td class="priceWithTax" colspan="3"
v-show="productFamily.behaviorPrice == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') }}'">
{% verbatim %}{{ finalPriceWithTax }}{% endverbatim %}€
<span class="text-danger" v-show="productFamily.reductionActive">{% verbatim %}{{ finalPriceWithTaxAndReduction }}{% endverbatim %}€</span>
<span class="text-danger"
v-show="productFamily.reductionActive">{% verbatim %}{{ finalPriceWithTaxAndReduction }}{% endverbatim %}€</span>
</td>

{{ _self.product_field(3, product.price, 'price', false, '€', 'v-show="productFamily.behaviorPrice == \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') ~ '\'"') }}
@@ -98,11 +113,11 @@

<td colspan="2" v-show="productFamily.giftVoucherActive!= true">
<span v-if="productFamily.reductionActive" class="text-danger">
{% verbatim %}{{ marginProfitWithReduction }}{% endverbatim %}€<br />
{% verbatim %}{{ marginProfitWithReduction }}{% endverbatim %}€<br/>
{% verbatim %}{{ marginProfitPercentWithReduction }}{% endverbatim %}%
</span>
<span v-else>
{% verbatim %}{{ marginProfit }}{% endverbatim %}€<br />
{% verbatim %}{{ marginProfit }}{% endverbatim %}€<br/>
{% verbatim %}{{ marginProfitPercent }}{% endverbatim %}%
</span>
</td>
@@ -113,18 +128,18 @@
{{ _self.product_field(2, product.availableQuantityDefault, 'availableQuantityDefault',false, '', 'v-show="productFamily.behaviorCountStock== \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT') ~ '\' && productFamily.behaviorStockWeek!= \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_STOCK_WEEK_NON_RENEWABLE') ~ '\'"') }}


<td colspan="2">
<td colspan="2">

{{ _self.total_order_product(totalProductOrdered) }}

</td>

{# <td colspan="4" v-show="productFamily.giftVoucherActive== true">
{# <td colspan="4" v-show="productFamily.giftVoucherActive== true">

{{ form_row(product.giftVoucherReductionCart, {"label": false, "attr" : {'v-model' : 'giftVoucherReductionCart', ':required': 'status ==1 && productFamily.giftVoucherActive'}}) }}

</td>#}
<td colspan="3">
</td> #}
<td colspan="3">
<button type="button" class="btn-sm btn-info" @click="modalProductForm()">
<i class="fa fa-edit"></i>
</button>

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

@@ -6,14 +6,14 @@
<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" style="margin-bottom: 20px;"
:data-index="formProducts.length"
data-prototype="{{ product_family_macros.product_row(form.products.vars.prototype)|e('html_attr') }}">
<thead>
<tr>
<th>
</th>
<th colspan="4" class="string" v-show="productsQuantityAsTitle == false">
<th colspan="4" class="string" v-show="productsQuantityAsTitle == false">
Titre
<button v-on:click="emptyProductsField('title');"
class="btn btn-empty-field" type="button"><i class="fa fa-undo"></i></button>
@@ -43,7 +43,8 @@

<th colspan="3" class="price main-info">
PA HT
<button v-show="productFamily.behaviorPrice == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') }}'" v-on:click="emptyProductsField('buyingPrice');"
<button v-show="productFamily.behaviorPrice == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') }}'"
v-on:click="emptyProductsField('buyingPrice');"
class="btn btn-empty-field" type="button"><i class="fa fa-undo"></i></button>
</th>
<th colspan="3" class="price"
@@ -75,15 +76,17 @@
<th colspan="3" class="price">
{# v-show="getBehaviorPrice() =='{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') }}'"> #}
PV HT
<button v-show="productFamily.behaviorPrice == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') }}'" v-on:click="emptyProductsField('price');"
<button v-show="productFamily.behaviorPrice == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') }}'"
v-on:click="emptyProductsField('price');"
class="btn btn-empty-field" type="button"><i class="fa fa-undo"></i></button>
</th>
<th colspan="3" class="price main-info">
PV TTC
<button v-show="productFamily.behaviorPrice == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') }}'" v-on:click="emptyProductsField('priceWithTax');"
<button v-show="productFamily.behaviorPrice == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') }}'"
v-on:click="emptyProductsField('priceWithTax');"
class="btn btn-empty-field" type="button"><i class="fa fa-undo"></i></button>
</th>
<th colspan="2" v-show="giftVoucherActive!= true">
<th colspan="2" v-show="giftVoucherActive!= true">
Marge HT
</th>

@@ -108,10 +111,10 @@
<th colspan="2">
Semaine / Commandés
</th>
{#<th colspan="4"
{# <th colspan="4"
v-show="giftVoucherActive== true">
Réduction "Bon cadeaux"
</th>#}
</th> #}
<th colspan="3" class="">
Action
</th>
@@ -176,7 +179,7 @@
<th colspan="3" class="price main-info">
${productFamily.priceWithTax}
</th>
<th colspan="2" class="price" v-show="giftVoucherActive!= true">
<th colspan="2" class="price" v-show="giftVoucherActive!= true">
${productFamily.marginProfit}€<br/>
${productFamily.marginProfitPercent}%
</td>
@@ -194,9 +197,9 @@
</th>
<th colspan="2">
</th>
{#<th colspan="4"
{# <th colspan="4"
v-show="giftVoucherActive== true">
</th>#}
</th> #}
<th colspan="3" class="">

</th>
@@ -204,12 +207,20 @@
</table>


<div class="col-12">
<div class="row" style="margin: 0 25px">

<div class="col-3 form-group">
{{ form_widget(form.productsQuantityAsTitle, {"attr":{'v-model' : 'productsQuantityAsTitle'}}) }}
</div>
<div class="col-3 form-group"></div>
<div class="col-6 form-group float-right">
<button type="button" class="add_tag_link btn-add-product btn btn-default" @click="addProductForm"><span
class="fa fa-plus"></span> Ajouter une déclinaison
</button>
</div>

<div class="col-12">

{{ form_row(form.productsQuantityAsTitle, {"attr":{'v-model' : 'productsQuantityAsTitle'}}) }}
<p>
<strong>Aide à l'utilisation - Raccourci clavier</strong>
<ul>
@@ -221,8 +232,9 @@
</ul>
</p>
</div>
</div>

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

{{ macros.endCard() }}
</div>
@@ -249,7 +261,7 @@
{% if product.vars.value.availableQuantity %}availableQuantity: parseInt({{ product.vars.value.availableQuantity }}),{% endif %}
{% if product.vars.value.availableQuantityDefault %}availableQuantityDefault: parseInt({{ product.vars.value.availableQuantityDefault }}),{% endif %}
{% if product.vars.value.propertyExpirationDate %}propertyExpirationDate: "{{ product.vars.value.propertyExpirationDate }}",{% endif %}
{#{% if product.vars.value.giftVoucherReductionCart %}giftVoucherReductionCart: {{ product.vars.value.giftVoucherReductionCart.id }},{% endif %}#}
{# {% if product.vars.value.giftVoucherReductionCart %}giftVoucherReductionCart: {{ product.vars.value.giftVoucherReductionCart.id }},{% 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 }}';

+ 13
- 0
ShopBundle/Statistic/Statistic.php View File

@@ -0,0 +1,13 @@
<?php


namespace Lc\ShopBundle\Statistic;


class Statistic
{
public function get(){

}

}

Loading…
Cancel
Save