foreach ($entity->getActions() as $action){ | foreach ($entity->getActions() as $action){ | ||||
if($action->getName() == ActionDefinition::SWITCH_USER){ | if($action->getName() == ActionDefinition::SWITCH_USER){ | ||||
$sectionDefault = $this->getSectionContainer()->getStore()->setMerchant($this->getMerchantCurrent())->getOneDefault(); | $sectionDefault = $this->getSectionContainer()->getStore()->setMerchant($this->getMerchantCurrent())->getOneDefault(); | ||||
dump($sectionDefault); | |||||
$url = $this->generateUrl($this->getParameter('lc_sov.homepage_route'), array('_switch_user' => $entity->getInstance()->getEmail(), 'section'=> $sectionDefault->getSlug())); | $url = $this->generateUrl($this->getParameter('lc_sov.homepage_route'), array('_switch_user' => $entity->getInstance()->getEmail(), 'section'=> $sectionDefault->getSlug())); | ||||
$action->setLinkUrl($url); | $action->setLinkUrl($url); | ||||
} | } |
namespace Lc\CaracoleBundle\Generator; | namespace Lc\CaracoleBundle\Generator; | ||||
use App\Solver\Order\OrderShopSolver; | |||||
use Lc\CaracoleBundle\Definition\SectionSettingDefinition; | use Lc\CaracoleBundle\Definition\SectionSettingDefinition; | ||||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | ||||
use Lc\CaracoleBundle\Model\Section\SectionModel; | use Lc\CaracoleBundle\Model\Section\SectionModel; | ||||
class OrderReferenceGenerator | class OrderReferenceGenerator | ||||
{ | { | ||||
protected SettingSolver $settingSolver; | protected SettingSolver $settingSolver; | ||||
protected OrderShopSolver $orderShopSolver; | |||||
public function __construct(SettingSolver $settingSolver) | |||||
public function __construct(SettingSolver $settingSolver, OrderShopSolver $orderShopSolver) | |||||
{ | { | ||||
$this->settingSolver = $settingSolver; | $this->settingSolver = $settingSolver; | ||||
$this->orderShopSolver= $orderShopSolver; | |||||
} | } | ||||
public function buildReference(OrderShopInterface $orderShop): string | public function buildReference(OrderShopInterface $orderShop): string | ||||
{ | { | ||||
$complementaryIndex = null; | |||||
if ($orderShop->getMainOrderShop()) { | |||||
$complementaryIndex = 0; | |||||
foreach ($orderShop->getMainOrderShop()->getComplementaryOrderShops() as $complementaryOrder) { | |||||
if ($this->orderShopSolver->isValid($complementaryOrder)) $complementaryIndex++; | |||||
} | |||||
$orderShop = $complementaryOrder->getMainOrderShop(); | |||||
} | |||||
switch ($orderShop->getSection()->getCycleType()) { | switch ($orderShop->getSection()->getCycleType()) { | ||||
case SectionModel::CYCLE_TYPE_DAY: | case SectionModel::CYCLE_TYPE_DAY: | ||||
return $this->buildReferenceCycleDay($orderShop); | |||||
$reference = $this->buildReferenceCycleDay($orderShop); | |||||
break; | |||||
case SectionModel::CYCLE_TYPE_WEEK: | case SectionModel::CYCLE_TYPE_WEEK: | ||||
return $this->buildReferenceCycleWeek($orderShop); | |||||
$reference = $this->buildReferenceCycleWeek($orderShop,); | |||||
break; | |||||
case SectionModel::CYCLE_TYPE_MONTH: | case SectionModel::CYCLE_TYPE_MONTH: | ||||
return $this->buildReferenceCycleMonth($orderShop); | |||||
$reference = $this->buildReferenceCycleMonth($orderShop); | |||||
break; | |||||
case SectionModel::CYCLE_TYPE_YEAR: | case SectionModel::CYCLE_TYPE_YEAR: | ||||
return $this->buildReferenceCycleYear($orderShop); | |||||
$reference = $this->buildReferenceCycleYear($orderShop); | |||||
break; | |||||
default: | |||||
$reference = 'C' . $orderShop->getId(); | |||||
break; | |||||
} | } | ||||
return 'C' . $orderShop->getId(); | |||||
if($complementaryIndex){ | |||||
$reference = $reference.'C'.$this->numberPad($complementaryIndex, 1); | |||||
} | |||||
return $reference; | |||||
} | } | ||||
public function buildReferenceCycleDay(OrderShopInterface $orderShop): string | public function buildReferenceCycleDay(OrderShopInterface $orderShop): string |
namespace Lc\CaracoleBundle\Repository\Order; | namespace Lc\CaracoleBundle\Repository\Order; | ||||
use Knp\Component\Pager\PaginatorInterface; | use Knp\Component\Pager\PaginatorInterface; | ||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | ||||
use Lc\CaracoleBundle\Model\Product\ProductInterface; | use Lc\CaracoleBundle\Model\Product\ProductInterface; | ||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | use Lc\CaracoleBundle\Model\Section\SectionInterface; | ||||
{ | { | ||||
protected bool $isJoinProduct = false; | protected bool $isJoinProduct = false; | ||||
protected bool $isJoinSection = false; | |||||
protected bool $isJoinProductFamily = false; | protected bool $isJoinProductFamily = false; | ||||
protected bool $isJoinOrderShop = false; | protected bool $isJoinOrderShop = false; | ||||
protected bool $isJoinOrderStatus = false; | protected bool $isJoinOrderStatus = false; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function joinSection(): self | |||||
{ | |||||
if (!$this->isJoinSection) { | |||||
$this->isJoinSection = true; | |||||
return $this | |||||
->leftJoin('orderShop.section', 'section'); | |||||
} | |||||
return $this; | |||||
} | |||||
public function joinOrderStatus(): self | public function joinOrderStatus(): self | ||||
{ | { | ||||
$this->joinOrderShop(); | $this->joinOrderShop(); | ||||
} | } | ||||
return $this; | return $this; | ||||
} | } | ||||
public function filterByMerchant(MerchantInterface $merchant){ | |||||
$this->joinOrderShop(); | |||||
$this->joinSection(); | |||||
return $this->andWhere('section.merchant = :merchant') | |||||
->setParameter('merchant', $merchant); | |||||
} | |||||
} | } |
namespace Lc\CaracoleBundle\Repository\Product; | namespace Lc\CaracoleBundle\Repository\Product; | ||||
use Knp\Component\Pager\PaginatorInterface; | use Knp\Component\Pager\PaginatorInterface; | ||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | ||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | ||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | use Lc\CaracoleBundle\Model\Section\SectionInterface; | ||||
class ProductRepositoryQuery extends AbstractRepositoryQuery | class ProductRepositoryQuery extends AbstractRepositoryQuery | ||||
{ | { | ||||
protected bool $isJoinProductFamily =false; | protected bool $isJoinProductFamily =false; | ||||
protected bool $isJoinSections =false; | |||||
protected bool $isJoinProductFamilySectionProperties =false; | protected bool $isJoinProductFamilySectionProperties =false; | ||||
public function __construct(ProductRepository $repository, PaginatorInterface $paginator) | public function __construct(ProductRepository $repository, PaginatorInterface $paginator) | ||||
return $this; | return $this; | ||||
} | } | ||||
public function filterByMerchantViaSection(MerchantInterface $merchant) | |||||
{ | |||||
$this->joinProductFamilySectionProperties(false); | |||||
$this->joinSections(false); | |||||
$this->andWhereMerchant('section', $merchant); | |||||
$this->andWhere('productFamilySectionProperties.status = 1'); | |||||
} | |||||
public function joinSections(bool $addSelect = true): self | |||||
{ | |||||
if (!$this->isJoinSections) { | |||||
$this->isJoinSections = true; | |||||
$this->leftJoin('productFamilySectionProperties.section', 'section'); | |||||
if ($addSelect) { | |||||
$this->addSelect('section'); | |||||
} | |||||
} | |||||
return $this; | |||||
} | |||||
public function joinProductFamilySectionProperties(bool $addSelect = true): self | public function joinProductFamilySectionProperties(bool $addSelect = true): self | ||||
{ | { | ||||
$this->joinProductFamily(); | $this->joinProductFamily(); | ||||
$this->leftJoin('productFamily.productFamilySectionProperties', 'productFamilySectionProperties'); | $this->leftJoin('productFamily.productFamilySectionProperties', 'productFamilySectionProperties'); | ||||
if ($addSelect) { | if ($addSelect) { | ||||
$this->addSelect('productFamilySectionProperties'); | |||||
//NB : Ici le select est en commentaire car si il est actif doctrine n'hydrate pas correectement ProductFamilySectionProperties (si filtre sur section les ProductFamilySectionProperties des autres sections ne sont pas chargé et ça peut être problématique pr la gestion des stocks) | |||||
//$this->addSelect('productFamilySectionProperties'); | |||||
} | } | ||||
} | } | ||||
return $this; | return $this; |
namespace Lc\CaracoleBundle\Repository\Product; | namespace Lc\CaracoleBundle\Repository\Product; | ||||
use App\Solver\Product\ProductFamilySectionPropertySolver; | use App\Solver\Product\ProductFamilySectionPropertySolver; | ||||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | |||||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | use Lc\CaracoleBundle\Repository\SectionStoreTrait; | ||||
use Lc\CaracoleBundle\Repository\AbstractStore; | use Lc\CaracoleBundle\Repository\AbstractStore; | ||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | use Lc\SovBundle\Repository\RepositoryQueryInterface; | ||||
class ProductStore extends AbstractStore | class ProductStore extends AbstractStore | ||||
{ | { | ||||
use SectionStoreTrait; | use SectionStoreTrait; | ||||
use MerchantStoreTrait; | |||||
protected ProductRepositoryQuery $query; | protected ProductRepositoryQuery $query; | ||||
protected ProductFamilySectionPropertySolver $productFamilySectionPropertySolver; | protected ProductFamilySectionPropertySolver $productFamilySectionPropertySolver; | ||||
public function filtersDefault($query):RepositoryQueryInterface | public function filtersDefault($query):RepositoryQueryInterface | ||||
{ | { | ||||
$this->addFilterBySectionOptionnal($query); | $this->addFilterBySectionOptionnal($query); | ||||
$this->addFilterByMerchantViaSectionOptionnal($query); | |||||
$query->filterIsOnlineAndOffline(); | $query->filterIsOnlineAndOffline(); | ||||
return $query; | return $query; | ||||
//findProductByAvailabilitiesNegative | //findProductByAvailabilitiesNegative | ||||
public function getByAvailabilitiesNegative(ProductRepositoryQuery $query = null): array | public function getByAvailabilitiesNegative(ProductRepositoryQuery $query = null): array | ||||
{ | { | ||||
$query = $this->createQuery($query); | |||||
$query->joinProductFamily(); | |||||
$query = $this->createDefaultQuery($query); | |||||
$query->filterIsOnline(); | $query->filterIsOnline(); | ||||
$query->filterAvailableQuantityNegative(); | $query->filterAvailableQuantityNegative(); | ||||
$query->groupBy('productFamily.id'); | $query->groupBy('productFamily.id'); | ||||
public function getByAvailabilitiesSupplierNegative(ProductRepositoryQuery $query = null): array | public function getByAvailabilitiesSupplierNegative(ProductRepositoryQuery $query = null): array | ||||
{ | { | ||||
$query = $this->createQuery($query); | |||||
$query = $this->createDefaultQuery($query); | |||||
$query->joinProductFamily(); | $query->joinProductFamily(); | ||||
$query->filterIsOnline(); | $query->filterIsOnline(); | ||||
$query->filterAvailableQuantitySupplierNegative(); | $query->filterAvailableQuantitySupplierNegative(); |
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | ||||
{ | { | ||||
$this->addFilterBySectionOptionnal($query); | $this->addFilterBySectionOptionnal($query); | ||||
$this->addFilterByMerchantOptionnal($query); | |||||
return $query; | return $query; | ||||
} | } | ||||
new TwigFunction('merchant_current', [$this, 'getMerchantCurrent']), | new TwigFunction('merchant_current', [$this, 'getMerchantCurrent']), | ||||
new TwigFunction('user_merchant_current', [$this, 'getUserMerchantCurrent']), | new TwigFunction('user_merchant_current', [$this, 'getUserMerchantCurrent']), | ||||
new TwigFunction('section_current', [$this, 'getSectionCurrent']), | new TwigFunction('section_current', [$this, 'getSectionCurrent']), | ||||
new TwigFunction('section_default', [$this, 'getSectionDefault']), | |||||
new TwigFunction('section_current_default', [$this, 'getSectionCurrentDefault']), | new TwigFunction('section_current_default', [$this, 'getSectionCurrentDefault']), | ||||
new TwigFunction('section_current_visited', [$this, 'getSectionCurrentVisited']), | new TwigFunction('section_current_visited', [$this, 'getSectionCurrentVisited']), | ||||
new TwigFunction('is_out_of_sections', [$this, 'isOutOfSections']), | new TwigFunction('is_out_of_sections', [$this, 'isOutOfSections']), | ||||
return $this->sectionResolver->getCurrent(); | return $this->sectionResolver->getCurrent(); | ||||
} | } | ||||
public function getSectionDefault(): ?SectionInterface | |||||
{ | |||||
return $this->sectionStore->setMerchant($this->merchantResolver->getCurrent())->getOneDefault(); | |||||
} | |||||
public function getSectionCurrentDefault(): ?SectionInterface | public function getSectionCurrentDefault(): ?SectionInterface | ||||
{ | { | ||||
return $this->sectionResolver->getCurrent(true); | return $this->sectionResolver->getCurrent(true); |