Browse Source

Nombre de commandes semaines passés

feature/export_comptable
Fab 4 years ago
parent
commit
5084925134
2 changed files with 3 additions and 41 deletions
  1. +1
    -37
      ShopBundle/Controller/Backend/ProductFamilyController.php
  2. +2
    -4
      ShopBundle/Resources/views/backend/productfamily/panel_stock.html.twig

+ 1
- 37
ShopBundle/Controller/Backend/ProductFamilyController.php View File

'entity' => $entity, 'entity' => $entity,
'delete_form' => $deleteForm->createView(), 'delete_form' => $deleteForm->createView(),
'sortableProductsField' => $sortableProductsField, 'sortableProductsField' => $sortableProductsField,
'totalProductOrdered' => $this->getTotalProductOrdered($entity)
'totalProductOrdered' => $this->orderUtils->getTotalProductOrderedLastWeeks($entity)
]; ];


return $this->executeDynamicMethod('render<EntityName>Template', ['edit', $this->entity['templates']['edit'], $parameters]); return $this->executeDynamicMethod('render<EntityName>Template', ['edit', $this->entity['templates']['edit'], $parameters]);
} }




public function getTotalProductOrdered($entity)
{
$orderShopRepo = $this->em->getRepository(OrderShopInterface::class);
$totalProductOrdered = array();
$currentWeekNumber = $this->orderUtils->getWeekNumberCurrentOrder();
$totalProductOrdered['total'][$currentWeekNumber +1] = 0;
$totalProductOrdered['total'][$currentWeekNumber ] = 0;

foreach ($entity->getProducts() as $product) {
//Les commandes sont ouvertes ont récupèrent les commandes en cours et celle de la semaine dernière
if ($this->orderUtils->isOpenSale()) {
$totalProductOrdered[$product->getId()][$currentWeekNumber +1] = $orderShopRepo->countValidOrderProductsOfWeekByProduct($currentWeekNumber +1, $product->getId());
$totalProductOrdered[$product->getId()][$currentWeekNumber] = $orderShopRepo->countValidOrderProductsOfWeekByProduct($currentWeekNumber, $product->getId());

if ($entity->getBehaviorCountStock() == ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE) {
$ratioByMeasure = $product->getQuantity() / $product->getUnitInherited()->getCoefficient();
$totalProductOrdered['total'][$currentWeekNumber +1] += $orderShopRepo->countValidOrderProductsOfWeekByProduct($currentWeekNumber +1, $product->getId()) * $ratioByMeasure;
$totalProductOrdered['total'][$currentWeekNumber] += $orderShopRepo->countValidOrderProductsOfWeekByProduct($currentWeekNumber, $product->getId()) * $ratioByMeasure;
} else {
$totalProductOrdered['total'][$currentWeekNumber +1] += $orderShopRepo->countValidOrderProductsOfWeekByProduct($currentWeekNumber+1, $product->getId());
$totalProductOrdered['total'][$currentWeekNumber] += $orderShopRepo->countValidOrderProductsOfWeekByProduct($currentWeekNumber, $product->getId());
}

} else {
$totalProductOrdered[$product->getId()][$currentWeekNumber +1] = $orderShopRepo->countValidOrderProductsOfWeekByProduct($currentWeekNumber+1, $product->getId());
if ($entity->getBehaviorCountStock() == ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE) {
$ratioByMeasure = $product->getQuantity() / $product->getUnitInherited()->getCoefficient();
$totalProductOrdered['total'][$currentWeekNumber+1] += $orderShopRepo->countValidOrderProductsOfWeekByProduct($currentWeekNumber+1, $product->getId()) * $ratioByMeasure;
}else{
$totalProductOrdered['total'][$currentWeekNumber+1] += $orderShopRepo->countValidOrderProductsOfWeekByProduct($currentWeekNumber+1, $product->getId());
}
}

}
return $totalProductOrdered;
}


} }



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

{{ form_help(form.availableQuantityDefault) }} {{ form_help(form.availableQuantityDefault) }}
</div> </div>
</div> </div>
<p v-show="behaviorCountStock == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY') }}' ">
{% for quantityProductsOrder in totalProductOrdered %}
{{ product_family_macros.total_order_product(quantityProductsOrder) }}
{% endfor %}
<p v-show="behaviorCountStock == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY') }}' || behaviorCountStock == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE') }}' ">
{{ product_family_macros.total_order_product_family(totalProductOrdered['total'], entity) }}
</p> </p>
</div> </div>



Loading…
Cancel
Save