Преглед изворни кода

[Backend] Afficahge statistique produit

develop
Fabien Normand пре 2 година
родитељ
комит
949f74546a
4 измењених фајлова са 0 додато и 143 уклоњено
  1. +0
    -18
      Controller/Product/ProductFamilyAdminController.php
  2. +0
    -7
      Resources/views/admin/product/field/product_family_sales.html.twig
  3. +0
    -24
      Resources/views/admin/product/macro/product_family_macro.html.twig
  4. +0
    -94
      Resources/views/admin/product/modal/show_products_sales_statistic.html.twig

+ 0
- 18
Controller/Product/ProductFamilyAdminController.php Прегледај датотеку

@@ -51,22 +51,4 @@ abstract class ProductFamilyAdminController extends AbstractAdminController
return $responseParameters;
}

public function showSalesStatistic(AdminContext $context)
{
$productFamily = $context->getEntity()->getInstance();

$currentSection = $this->get(SectionResolver::class)->getCurrent();
$productsSalesStatistic = $this->get(OrderShopContainer::class)->getBuilder()->getProductsSalesStatistic($currentSection, $productFamily, 16);
$parameters = array(
'productFamily' => $productFamily,
'productsSalesStatistic' => $productsSalesStatistic
);

//TODO flashMessages ???
$response['flashMessages'] = [];//$this->utils->getFlashMessages();
$response['data'] = $this->render('@LcCaracole/admin/product/modal/show_products_sales_statistic.html.twig', $parameters)->getContent();
$response['statistics'] = $productsSalesStatistic;
return new Response(json_encode($response));
}

}

+ 0
- 7
Resources/views/admin/product/field/product_family_sales.html.twig Прегледај датотеку

@@ -1,7 +0,0 @@
{# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #}

{% import '@LcCaracole/admin/product/macro/product_family_macro.html.twig' as pfm %}
{% set section_current = section_container.resolver.getCurrent() %}
{% if section_current %}
{{ pfm.product_family_sales_statistic(order_shop_container.builder.getProductsSalesStatistic(section_current, entity.instance, 2), entity.instance) }}
{% endif %}

+ 0
- 24
Resources/views/admin/product/macro/product_family_macro.html.twig Прегледај датотеку

@@ -1,28 +1,4 @@
{% extends '@LcCaracole/admin/product/macro/product_family_macro.html.twig' %}

{% macro product_family_sales_statistic(productsSalesStatistic, productFamily) %}
{% if productsSalesStatistic and productsSalesStatistic|length %}
<button type="button" data-product-family="{{ productFamily.id }}"
class="lc-show-products-sales-statistic btn btn-sm"
data-toggle="tooltip" title="{{ 'showHistorySales'|sov_trans_admin_action }}"
data-url="{{ ea_url({crudAction : 'showSalesStatistic', entityId: productFamily.id }) }}">
{% for key, weekNumberQuantity in productsSalesStatistic['data']['total_sales']['data'] %}
<span class="text-success">
<i class="fa fa-calendar"></i>
{{ productsSalesStatistic['label'][key] }}</span>
<span class="text-info"><i class="fa fa-shopping-basket"></i>
<strong>
{{ weekNumberQuantity is null ? 0 : weekNumberQuantity }}
{% if productFamily and (productFamily.behaviorDisplaySale== constant('App\\Entity\\Product\\ProductFamily::BEHAVIOR_DISPLAY_SALE_BY_MEASURE')) %}
{{ productFamily.unit.unitReference }}
{% endif %}
</strong>
</span>
<br/>
{% endfor %}
</button>
{% endif %}
{% endmacro product_family_sales_statistic %}

{% macro autoresize_field(field) %}
<tr>

+ 0
- 94
Resources/views/admin/product/modal/show_products_sales_statistic.html.twig Прегледај датотеку

@@ -1,94 +0,0 @@
{% embed "@LcSov/adminlte/embed/modal.twig" %}
{% import '@LcCaracole/admin/product/macro/product_family_macro.html.twig' as pfm %}

{% block size %}modal-xl{% endblock %}
{% block id %}modal-products-sales-statistic{% endblock %}
{% block title %}Total ventes/semaines : {{ productFamily.title }}{% endblock %}

{% block body %}
<div class="row">
<div class="col-10">
{{ _self.btn_pss(productsSalesStatistic, productFamily, 'Global', 'total_sales') }}
{% if productFamily.activeProducts %}
{% for product in productFamily.products %}
{% if product.status >= 0 %}
{{ _self.btn_pss(productsSalesStatistic, productFamily, product.title , product.id ) }}
{% endif %}
{% endfor %}
{% endif %}

</div>

<div class="col-2">
<h5>Stock actuel</h5>
{% include 'admin/product/field/product_family_available_quantity.html.twig' with {item:productFamily, value: productFamily.availableQuantity} %}
</div>


<div class="col-12">
{{ _self.table_pss(productsSalesStatistic, productFamily, 'total_sales') }}
{% for product in productFamily.products %}
{% if product.status >= 0 %}
{{ _self.table_pss(productsSalesStatistic, productFamily, product.id) }}
{% endif %}
{% endfor %}
</div>
<div class="col-12">
<canvas id="chart"></canvas>
</div>

</div>
{% endblock %}

{% block footer %}{% endblock %}

{% macro btn_pss(productsSalesStatistic,productFamily, label, propertyName) %}
<button style="margin-bottom: 10px;" type="button" data-property-name="{{ propertyName }}"
class="btn btn-sm btn-primary btn-products-sales-statistic">
{{ label }} <br/>
{{ productsSalesStatistic['data'][propertyName]['average_period'] }}
{% if propertyName== 'total_sales' and productFamily and (productFamily.behaviorDisplaySale== constant('Lc\\CaracoleBundle\\Model\\Product\\ProductFamilyModel::BEHAVIOR_DISPLAY_SALE_BY_MEASURE')) %}
{{ productFamily.unit.unitReference }}
{% endif %}
<br/>
<small>(en moyenne)</small>
</button>
{% endmacro btn_pss %}

{% macro table_pss(productsSalesStatistic, productFamily, propertyName) %}
<div style="margin:20px 0;" class="table-products-sales-statistic" id="table-products-sales-statistic-{{ propertyName }}">

<table class="table table-bordered table-striped">
<tbody>
<tr>
<th class="text-success">
<i class="fa fa-calendar"></i> Semaine
</th>
{% for weekNumber, weekNumberQuantity in productsSalesStatistic['data'][propertyName]['data'] %}
<td class="text-success align-right">
{{ weekNumber }}
</td>
{% endfor %}
</tr>
<tr>
<th class="text-info">
<i class="fa fa-shopping-basket"></i> Commandés
</th>
{% for weekNumber, weekNumberQuantity in productsSalesStatistic['data'][propertyName]['data'] %}
<td class="text-info align-right">
<strong>
{{ weekNumberQuantity is null ? 0 : weekNumberQuantity }}
{% if propertyName== 'total_sales' and productFamily and (productFamily.behaviorDisplaySale== constant('Lc\\CaracoleBundle\\Model\\Product\\ProductFamilyModel::BEHAVIOR_DISPLAY_SALE_BY_MEASURE')) %}
{{ productFamily.unit.unitReference }}
{% endif %}
</strong>
</td>
{% endfor %}
</tr>

</tbody>
</table>
</div>
{% endmacro table_pss %}
{% endembed %}


Loading…
Откажи
Сачувај