|
|
@@ -331,7 +331,7 @@ class ProductFamilyController extends AdminController |
|
|
|
'entity' => $entity, |
|
|
|
'delete_form' => $deleteForm->createView(), |
|
|
|
'sortableProductsField' => $sortableProductsField, |
|
|
|
'totalProductOrdered' => $this->getTotalProductOrdered($entity) |
|
|
|
'totalProductOrdered' => $this->orderUtils->getTotalProductOrderedLastWeeks($entity) |
|
|
|
]; |
|
|
|
|
|
|
|
return $this->executeDynamicMethod('render<EntityName>Template', ['edit', $this->entity['templates']['edit'], $parameters]); |
|
|
@@ -413,42 +413,6 @@ class ProductFamilyController extends AdminController |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|