Browse Source

Compléments de commande

feature/export_comptable
Guillaume 4 years ago
parent
commit
824a3c4bfd
2 changed files with 23 additions and 8 deletions
  1. +13
    -0
      ShopBundle/Repository/OrderShopRepository.php
  2. +10
    -8
      ShopBundle/Services/Order/OrderUtils.php

+ 13
- 0
ShopBundle/Repository/OrderShopRepository.php View File

$query->andWhere('e.user = :user')->setParameter('user', $params['user']) ; $query->andWhere('e.user = :user')->setParameter('user', $params['user']) ;
} }


if(isset($params['mergeComplementaryOrderShops'])) {
$query->andWhere('e.mainOrderShop IS NULL') ;
$query->leftJoin('e.complementaryOrderShops', 'complementaryOrderShops') ;

$query->leftJoin('complementaryOrderShops.orderStatus', 'complementaryOrderStatus');
$query->andWhere('complementaryOrderStatus.alias IN (:statusAliasValid)');
$query->setParameter('statusAliasValid', $this->statusAliasAsValid);
}

if(isset($params['excludeComplementaryOrderShops'])) {
$query->andWhere('e.mainOrderShop IS NULL') ;
}

if(isset($params['isOffCircuit'])) { if(isset($params['isOffCircuit'])) {
$query = $this->filterIsOffCircuit($query, true) ; $query = $this->filterIsOffCircuit($query, true) ;
} }

+ 10
- 8
ShopBundle/Services/Order/OrderUtils.php View File

} }




public function mergeOrderShops($orderShop1, $orderShop2)
public function mergeOrderShops($orderShop1, $orderShop2, $persist = true)
{ {
if ($orderShop1 && $orderShop2) { if ($orderShop1 && $orderShop2) {


foreach ($orderShop2->getOrderProducts() as $orderProduct) { foreach ($orderShop2->getOrderProducts() as $orderProduct) {
$this->addOrderProduct($orderShop1, $orderProduct); $this->addOrderProduct($orderShop1, $orderProduct);
$this->em->remove($orderProduct);

if($persist) {
$this->em->remove($orderProduct);
}
} }


$this->em->remove($orderShop2);
$this->em->persist($orderShop1);
$this->em->flush();
if($persist) {
$this->em->remove($orderShop2);
$this->em->persist($orderShop1);
$this->em->flush();
}


return $orderShop1; return $orderShop1;
} }
return $orderProductsByProductFamily; return $orderProductsByProductFamily;
} }





} }

Loading…
Cancel
Save