|
|
@@ -261,22 +261,6 @@ class ProductFamilyController extends AdminController |
|
|
|
$easyadmin = $this->request->attributes->get('easyadmin'); |
|
|
|
$entity = $easyadmin['item']; |
|
|
|
|
|
|
|
|
|
|
|
$orderShopRepo = $this->em->getRepository(OrderShopInterface::class); |
|
|
|
|
|
|
|
$totalProductOrdered = array(); |
|
|
|
foreach ($entity->getProducts() as $product) { |
|
|
|
$currentWeekNumber = $this->orderUtils->getWeekNumberCurrent(); |
|
|
|
//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] = $orderShopRepo->countValidOrderProductsOfWeekByProduct($currentWeekNumber, $product->getId()); |
|
|
|
$totalProductOrdered[$product->getId()][$currentWeekNumber - 1] = $orderShopRepo->countValidOrderProductsOfWeekByProduct($currentWeekNumber - 1, $product->getId()); |
|
|
|
} else { |
|
|
|
$totalProductOrdered[$product->getId()][$currentWeekNumber] = $orderShopRepo->countValidOrderProductsOfWeekByProduct($currentWeekNumber, $product->getId()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ($this->request->isXmlHttpRequest() && $property = $this->request->query->get('property')) { |
|
|
|
$newValue = 'true' === mb_strtolower($this->request->query->get('newValue')); |
|
|
|
$fieldsMetadata = $this->entity['list']['fields']; |
|
|
@@ -335,7 +319,7 @@ class ProductFamilyController extends AdminController |
|
|
|
'entity' => $entity, |
|
|
|
'delete_form' => $deleteForm->createView(), |
|
|
|
'sortableProductsField' => $sortableProductsField, |
|
|
|
'totalProductOrdered' => $totalProductOrdered |
|
|
|
'totalProductOrdered' => $this->getTotalProductOrdered($entity) |
|
|
|
]; |
|
|
|
|
|
|
|
return $this->executeDynamicMethod('render<EntityName>Template', ['edit', $this->entity['templates']['edit'], $parameters]); |
|
|
@@ -398,6 +382,21 @@ class ProductFamilyController extends AdminController |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getTotalProductOrdered($entity){ |
|
|
|
$orderShopRepo = $this->em->getRepository(OrderShopInterface::class); |
|
|
|
$totalProductOrdered = array(); |
|
|
|
foreach ($entity->getProducts() as $product) { |
|
|
|
$currentWeekNumber = $this->orderUtils->getWeekNumberCurrent(); |
|
|
|
//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] = $orderShopRepo->countValidOrderProductsOfWeekByProduct($currentWeekNumber, $product->getId()); |
|
|
|
$totalProductOrdered[$product->getId()][$currentWeekNumber - 1] = $orderShopRepo->countValidOrderProductsOfWeekByProduct($currentWeekNumber - 1, $product->getId()); |
|
|
|
} else { |
|
|
|
$totalProductOrdered[$product->getId()][$currentWeekNumber] = $orderShopRepo->countValidOrderProductsOfWeekByProduct($currentWeekNumber, $product->getId()); |
|
|
|
} |
|
|
|
} |
|
|
|
return $totalProductOrdered; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|