<?php | |||||
namespace Lc\ShopBundle\Context; | |||||
interface SectionInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\ShopBundle\Context; | |||||
interface SectionUtilsInterface | |||||
{ | |||||
} |
protected $merchantUtils; | protected $merchantUtils; | ||||
protected $mailjetTransport; | protected $mailjetTransport; | ||||
protected $orderUtils; | protected $orderUtils; | ||||
protected $mailUtils ; | |||||
protected $mailUtils; | |||||
protected $translator; | protected $translator; | ||||
protected $utilsProcess; | protected $utilsProcess; | ||||
protected $session; | protected $session; | ||||
protected $sectionUtils; | |||||
protected $filtersForm = null; | protected $filtersForm = null; | ||||
public function __construct(Security $security, UserManagerInterface $userManager, EntityManagerInterface $em, | public function __construct(Security $security, UserManagerInterface $userManager, EntityManagerInterface $em, | ||||
$this->utils = $utilsManager->getUtils(); | $this->utils = $utilsManager->getUtils(); | ||||
$this->merchantUtils = $utilsManager->getMerchantUtils(); | $this->merchantUtils = $utilsManager->getMerchantUtils(); | ||||
$this->orderUtils = $utilsManager->getOrderUtils();; | $this->orderUtils = $utilsManager->getOrderUtils();; | ||||
$this->mailUtils = $utilsManager->getMailUtils() ; | |||||
$this->utilsProcess = $utilsManager->getUtilsProcess() ; | |||||
$this->mailUtils = $utilsManager->getMailUtils(); | |||||
$this->utilsProcess = $utilsManager->getUtilsProcess(); | |||||
$this->sectionUtils = $utilsManager->getSectionUtils(); | |||||
$this->translator = $translator; | $this->translator = $translator; | ||||
$this->session = $session; | $this->session = $session; | ||||
} | } | ||||
$dqlFilter = sprintf(str_replace('currentMerchant', $this->getUser()->getMerchant()->getId(), $dqlFilter)); | $dqlFilter = sprintf(str_replace('currentMerchant', $this->getUser()->getMerchant()->getId(), $dqlFilter)); | ||||
} | } | ||||
if ($pos = strpos($dqlFilter, 'TODAYSTART')) { | |||||
$date = new \DateTime(); | |||||
$dqlFilter = sprintf(str_replace('TODAYSTART', $date->format('Y-m-d').' 00:00:00', $dqlFilter)); | |||||
} | |||||
if ($pos = strpos($dqlFilter, 'TODAYEND')) { | |||||
$date = new \DateTime(); | |||||
$dqlFilter = sprintf(str_replace('TODAYEND', $date->format('Y-m-d').' 23:59:59', $dqlFilter)); | |||||
} | |||||
if ($pos = strpos($dqlFilter, 'sectionLunch')) { | |||||
$dqlFilter = sprintf(str_replace('sectionLunch', $this->sectionUtils->getSection('lunch')->getId(), $dqlFilter)); | |||||
} else if ($pos = strpos($dqlFilter, 'sectionMarket')) { | |||||
$dqlFilter = sprintf(str_replace('sectionMarket', $this->sectionUtils->getSection('market')->getId(), $dqlFilter)); | |||||
} | |||||
if (new $entityClass instanceof StatusInterface && strpos($dqlFilter, 'entity.status') === false) { | if (new $entityClass instanceof StatusInterface && strpos($dqlFilter, 'entity.status') === false) { | ||||
if ($dqlFilter) $dqlFilter .= sprintf(' AND entity.status > = 0'); | if ($dqlFilter) $dqlFilter .= sprintf(' AND entity.status > = 0'); | ||||
else $dqlFilter .= sprintf(' entity.status > = 0'); | else $dqlFilter .= sprintf(' entity.status > = 0'); | ||||
} else { | } else { | ||||
$queryBuilder->andWhere('entity.' . $field['property'] . ' = :' . $field['property'] . ''); | $queryBuilder->andWhere('entity.' . $field['property'] . ' = :' . $field['property'] . ''); | ||||
} | } | ||||
if($filter instanceof TreeInterface && $filter->getParent() == null) { | |||||
if ($filter instanceof TreeInterface && $filter->getParent() == null) { | |||||
$queryBuilder->setParameter($field['property'], array_merge(array($filter), $filter->getChildrens()->toArray())); | $queryBuilder->setParameter($field['property'], array_merge(array($filter), $filter->getChildrens()->toArray())); | ||||
}else{ | |||||
} else { | |||||
$queryBuilder->setParameter($field['property'], $filter); | $queryBuilder->setParameter($field['property'], $filter); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
//TODO déplacer dans LC | |||||
if($this->entity['name']== 'OrderShopLunch' || $this->entity['name']== 'OrderShopLunchDay'){ | |||||
$queryBuilder->addOrderBy('entity.user', 'asc'); | |||||
} | |||||
return $queryBuilder; | return $queryBuilder; | ||||
} | } | ||||
$form->add($child->getName(), EntityType::class, array( | $form->add($child->getName(), EntityType::class, array( | ||||
'class' => $this->em->getClassMetadata($passedOptions['class'])->getName(), | 'class' => $this->em->getClassMetadata($passedOptions['class'])->getName(), | ||||
'label' => $passedOptions['label'], | 'label' => $passedOptions['label'], | ||||
'expanded' => isset($passedOptions['expanded']) ? $passedOptions['expanded'] : false, | |||||
'multiple' => isset($passedOptions['multiple']) ? $passedOptions['multiple'] : false, | 'multiple' => isset($passedOptions['multiple']) ? $passedOptions['multiple'] : false, | ||||
'placeholder' => '--', | 'placeholder' => '--', | ||||
'translation_domain' => 'lcshop', | 'translation_domain' => 'lcshop', | ||||
$id = $this->request->query->get('id'); | $id = $this->request->query->get('id'); | ||||
$easyadmin = $this->request->attributes->get('easyadmin'); | $easyadmin = $this->request->attributes->get('easyadmin'); | ||||
$entity = $easyadmin['item']; | |||||
$entity = $easyadmin['item']; | |||||
if ($this->request->isXmlHttpRequest() && $property = $this->request->query->get('property')) { | if ($this->request->isXmlHttpRequest() && $property = $this->request->query->get('property')) { | ||||
$newValue = 'true' === mb_strtolower($this->request->query->get('newValue')); | $newValue = 'true' === mb_strtolower($this->request->query->get('newValue')); | ||||
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 createNewEntity(){ | |||||
$idDuplicate = $this->request->query->get('duplicate', null); | |||||
if($idDuplicate){ | |||||
$easyadmin = $this->request->attributes->get('easyadmin'); | |||||
$entity= $this->em->getRepository($easyadmin['entity']['class'])->find($idDuplicate); | |||||
/* public function createNewEntity(){ | |||||
$idDuplicate = $this->request->query->get('duplicate', null); | |||||
if($idDuplicate){ | |||||
$easyadmin = $this->request->attributes->get('easyadmin'); | |||||
$entity= $this->em->getRepository($easyadmin['entity']['class'])->find($idDuplicate); | |||||
$newProductFamily = clone $entity ; | |||||
$this->em->persist($newProductFamily) ; | |||||
$this->em->flush() ; | |||||
}else{ | |||||
$entityFullyQualifiedClassName = $this->entity['class']; | |||||
$newProductFamily = clone $entity ; | |||||
$this->em->persist($newProductFamily) ; | |||||
$this->em->flush() ; | |||||
}else{ | |||||
$entityFullyQualifiedClassName = $this->entity['class']; | |||||
return new $entityFullyQualifiedClassName(); | |||||
} | |||||
return new $entityFullyQualifiedClassName(); | |||||
} | |||||
}*/ | |||||
}*/ | |||||
public function duplicateAction(){ | |||||
public function duplicateAction() | |||||
{ | |||||
$id = $this->request->query->get('id'); | $id = $this->request->query->get('id'); | ||||
$refererUrl = $this->request->query->get('referer', ''); | $refererUrl = $this->request->query->get('referer', ''); | ||||
$easyadmin = $this->request->attributes->get('easyadmin'); | $easyadmin = $this->request->attributes->get('easyadmin'); | ||||
$entity= $this->em->getRepository($easyadmin['entity']['class'])->find($id); | |||||
$entity = $this->em->getRepository($easyadmin['entity']['class'])->find($id); | |||||
$newEntity = $this->utilsProcess->duplicateEntity($entity); | $newEntity = $this->utilsProcess->duplicateEntity($entity); | ||||
return $this->redirectToRoute('easyadmin', ['entity' => $easyadmin['entity']['name'], 'action' => 'edit', 'id' =>$newEntity->getId(), 'referer' =>$refererUrl ]) ; | |||||
return $this->redirectToRoute('easyadmin', ['entity' => $easyadmin['entity']['name'], 'action' => 'edit', 'id' => $newEntity->getId(), 'referer' => $refererUrl]); | |||||
} | } | ||||
public function duplicateOtherHubAction(){ | |||||
public function duplicateOtherHubAction() | |||||
{ | |||||
$id = $this->request->query->get('id'); | $id = $this->request->query->get('id'); | ||||
$hubAlias = $this->request->query->get('hub'); | $hubAlias = $this->request->query->get('hub'); | ||||
$refererUrl = $this->request->query->get('referer', ''); | $refererUrl = $this->request->query->get('referer', ''); | ||||
$user = $this->security->getUser() ; | |||||
$user = $this->security->getUser(); | |||||
$easyadmin = $this->request->attributes->get('easyadmin'); | $easyadmin = $this->request->attributes->get('easyadmin'); | ||||
$entity= $this->em->getRepository($easyadmin['entity']['class'])->find($id); | |||||
$hub= $this->em->getRepository(MerchantInterface::class)->findOneByDevAlias($hubAlias); | |||||
$entity = $this->em->getRepository($easyadmin['entity']['class'])->find($id); | |||||
$hub = $this->em->getRepository(MerchantInterface::class)->findOneByDevAlias($hubAlias); | |||||
$newEntity = $this->utilsProcess->duplicateEntityToOtherHub($entity,$hub); | |||||
$newEntity = $this->utilsProcess->duplicateEntityToOtherHub($entity, $hub); | |||||
$user->setMerchant($hub); | $user->setMerchant($hub); | ||||
$this->em->persist($user); | $this->em->persist($user); | ||||
$this->em->flush(); | $this->em->flush(); | ||||
$redirectUrl = $this->generateUrl('easyadmin', ['entity' => $easyadmin['entity']['name'], 'action' => 'edit', 'id' =>$newEntity->getId(), 'referer' =>$refererUrl ]).'&hubredirection=true'; | |||||
$redirectUrl = $this->generateUrl('easyadmin', ['entity' => $easyadmin['entity']['name'], 'action' => 'edit', 'id' => $newEntity->getId(), 'referer' => $refererUrl]) . '&hubredirection=true'; | |||||
return $this->redirectToOtherHub($hub, $redirectUrl) ; | |||||
return $this->redirectToOtherHub($hub, $redirectUrl); | |||||
} | } | ||||
public function redirectToOtherHub($hub, $url){ | |||||
if(strpos($_SERVER['HTTP_HOST'], 'localhost')!==false){ | |||||
public function redirectToOtherHub($hub, $url) | |||||
{ | |||||
if (strpos($_SERVER['HTTP_HOST'], 'localhost') !== false) { | |||||
return $this->redirect($url); | return $this->redirect($url); | ||||
}else{ | |||||
return $this->redirect($hub->getMerchantConfig('url').substr($url,1)); | |||||
} else { | |||||
return $this->redirect($hub->getMerchantConfig('url') . substr($url, 1)); | |||||
} | } | ||||
} | } |
$id = $this->request->query->get('id'); | $id = $this->request->query->get('id'); | ||||
$entity = $this->request->query->get('entity'); | $entity = $this->request->query->get('entity'); | ||||
if ($this->request->isXmlHttpRequest() && $property = $this->request->query->get('property')) { | |||||
$newValue = 'true' === mb_strtolower($this->request->query->get('newValue')); | |||||
$fieldsMetadata = $this->entity['list']['fields']; | |||||
if($property == 'isGivenToCustomer'){ | |||||
$orderShop =$this->getOrderShopEntity(); | |||||
$orderShop->setIsGivenToCustomer($newValue); | |||||
$this->em->persist($orderShop); | |||||
$this->em->flush(); | |||||
$this->utils->addFlash('success', 'success.common.fieldChange'); | |||||
$response['flashMessages'] = $this->utils->getFlashMessages(); | |||||
return new Response(json_encode($response)); | |||||
} | |||||
} | |||||
return $this->redirectToRoute('easyadmin', [ | return $this->redirectToRoute('easyadmin', [ | ||||
'action' => 'show', | 'action' => 'show', | ||||
'entity' => $entity, | 'entity' => $entity, |
protected $orderUtils ; | protected $orderUtils ; | ||||
protected $userUtils ; | protected $userUtils ; | ||||
protected $priceUtils ; | protected $priceUtils ; | ||||
protected $sectionUtils ; | |||||
protected $mailUtils ; | |||||
protected $router ; | protected $router ; | ||||
protected $productFamilyRepository ; | protected $productFamilyRepository ; | ||||
protected $orderProductRepository ; | protected $orderProductRepository ; | ||||
$this->orderUtils = $utilsManager->getOrderUtils() ; | $this->orderUtils = $utilsManager->getOrderUtils() ; | ||||
$this->userUtils = $utilsManager->getUserUtils() ; | $this->userUtils = $utilsManager->getUserUtils() ; | ||||
$this->priceUtils = $utilsManager->getPriceUtils() ; | $this->priceUtils = $utilsManager->getPriceUtils() ; | ||||
$this->sectionUtils = $utilsManager->getSectionUtils() ; | |||||
$this->mailUtils = $utilsManager->getMailUtils() ; | |||||
$this->router = $router ; | $this->router = $router ; | ||||
$this->productFamilyRepository = $this->em->getRepository($this->em->getClassMetaData(ProductFamilyInterface::class)->getName()) ; | $this->productFamilyRepository = $this->em->getRepository($this->em->getClassMetaData(ProductFamilyInterface::class)->getName()) ; | ||||
$this->orderProductRepository = $this->em->getRepository($this->em->getClassMetaData(OrderProductInterface::class)->getName()) ; | $this->orderProductRepository = $this->em->getRepository($this->em->getClassMetaData(OrderProductInterface::class)->getName()) ; |
class ProductFamilyCategoriesType extends AbstractType | class ProductFamilyCategoriesType extends AbstractType | ||||
{ | { | ||||
protected $em; | protected $em; | ||||
protected $productCategoryRepository ; | |||||
protected $productCategoryRepository; | |||||
public function __construct(EntityManagerInterface $entityManager, ProductCategoryRepository $productCategoryRepository) | public function __construct(EntityManagerInterface $entityManager, ProductCategoryRepository $productCategoryRepository) | ||||
{ | { | ||||
$this->em = $entityManager; | $this->em = $entityManager; | ||||
$this->productCategoryRepository = $productCategoryRepository ; | |||||
$this->productCategoryRepository = $productCategoryRepository; | |||||
} | } | ||||
public function buildForm(FormBuilderInterface $builder, array $options) | public function buildForm(FormBuilderInterface $builder, array $options) | ||||
foreach ($categories as $category) { | foreach ($categories as $category) { | ||||
$builder->add('category_' . $category->getId(), CheckboxType::class, [ | $builder->add('category_' . $category->getId(), CheckboxType::class, [ | ||||
'label' => $category->getStatus() == 0 ? $category->getTitle() .' (hors ligne)': $category->getTitle() , | |||||
'label' => $category->getStatus() == 0 ? $category->getTitle() . ' (hors ligne)' : $category->getTitle(), | |||||
'data' => $currentProductCategories->contains($category), | 'data' => $currentProductCategories->contains($category), | ||||
'required' => false, | 'required' => false, | ||||
'disabled'=>true, | |||||
'attr'=>[ | |||||
'class'=>'none' | |||||
] | |||||
'disabled' => true, | |||||
'attr' => [ | |||||
'class' => 'none', | |||||
'data-section' => $category->getSection()->getId() | |||||
], | |||||
]); | ]); | ||||
$childrenCategories = $this->productCategoryRepository->findAllByParent($category, true); | $childrenCategories = $this->productCategoryRepository->findAllByParent($category, true); | ||||
foreach ($childrenCategories as $children) { | foreach ($childrenCategories as $children) { | ||||
$builder->add('category_children_' . $children->getId(), CheckboxType::class, [ | $builder->add('category_children_' . $children->getId(), CheckboxType::class, [ | ||||
'label' => $children->getStatus() == 0 ? $children->getTitle() .' (hors ligne)': $children->getTitle() , | |||||
'label' => $children->getStatus() == 0 ? $children->getTitle() . ' (hors ligne)' : $children->getTitle(), | |||||
'data' => $currentProductCategories->contains($children), | 'data' => $currentProductCategories->contains($children), | ||||
'required' => false | |||||
'required' => false, | |||||
'attr' => [ | |||||
'data-section' => $category->getSection()->getId() | |||||
], | |||||
]); | ]); | ||||
} | } | ||||
} | } |
$this->em = $entityManager; | $this->em = $entityManager; | ||||
$this->utils = $utils; | $this->utils = $utils; | ||||
} | } | ||||
public function buildForm(FormBuilderInterface $builder, array $options) | public function buildForm(FormBuilderInterface $builder, array $options) | ||||
{ | { | ||||
$builder->add('title', TextType::class, array( | $builder->add('title', TextType::class, array( | ||||
"required" => false | "required" => false | ||||
)) ; | |||||
)); | |||||
$builder->add('quantity', NumberType::class, array( | $builder->add('quantity', NumberType::class, array( | ||||
'label' => 'Quantité', | 'label' => 'Quantité', | ||||
'required'=>false, | |||||
'required' => false, | |||||
'attr' => [ | 'attr' => [ | ||||
'append_html' => 'g' | 'append_html' => 'g' | ||||
] | ] | ||||
$unitClass = $this->em->getClassMetadata(UnitInterface::class)->getName(); | $unitClass = $this->em->getClassMetadata(UnitInterface::class)->getName(); | ||||
$builder->add('unit', EntityType::class, array( | $builder->add('unit', EntityType::class, array( | ||||
'class'=> $unitClass, | |||||
'class' => $unitClass, | |||||
'data' => 0, | 'data' => 0, | ||||
'required'=>false, | |||||
'required' => false, | |||||
'choice_attr' => function ($choice) { | 'choice_attr' => function ($choice) { | ||||
return [ | return [ | ||||
'data-unit-reference' => $choice->getUnitReference(), | 'data-unit-reference' => $choice->getUnitReference(), | ||||
$builder->add('buyingPrice', NumberType::class, array( | $builder->add('buyingPrice', NumberType::class, array( | ||||
'label' => 'Prix d\'achat', | 'label' => 'Prix d\'achat', | ||||
'required'=>false | |||||
'required' => false | |||||
)); | )); | ||||
$builder->add('buyingPriceWithTax', NumberType::class, array( | $builder->add('buyingPriceWithTax', NumberType::class, array( | ||||
$builder->add('buyingPriceByRefUnit', NumberType::class, array( | $builder->add('buyingPriceByRefUnit', NumberType::class, array( | ||||
'label' => 'Prix d\'achat', | 'label' => 'Prix d\'achat', | ||||
'required'=>false | |||||
'required' => false | |||||
)); | )); | ||||
$builder->add('buyingPriceByRefUnitWithTax', NumberType::class, array( | $builder->add('buyingPriceByRefUnitWithTax', NumberType::class, array( | ||||
)); | )); | ||||
$builder->add('multiplyingFactor', NumberType::class, array( | $builder->add('multiplyingFactor', NumberType::class, array( | ||||
'label' => 'Coefficiant de multiplication', | 'label' => 'Coefficiant de multiplication', | ||||
'mapped'=>false, | |||||
'required'=>false | |||||
'mapped' => false, | |||||
'required' => false | |||||
)); | )); | ||||
$builder->add('priceByRefUnit', NumberType::class, array( | $builder->add('priceByRefUnit', NumberType::class, array( | ||||
'required'=>false | |||||
'required' => false | |||||
)); | )); | ||||
$builder->add('priceByRefUnitWithTax', NumberType::class, array( | $builder->add('priceByRefUnitWithTax', NumberType::class, array( | ||||
$builder->add('position', HiddenType::class); | $builder->add('position', HiddenType::class); | ||||
$builder->add('status', HiddenType::class); | $builder->add('status', HiddenType::class); | ||||
$builder->add('exportTitle', TextType::class, array( | $builder->add('exportTitle', TextType::class, array( | ||||
'required' =>false | |||||
'required' => false | |||||
)); | )); | ||||
$builder->add('exportNote', TextType::class, array( | $builder->add('exportNote', TextType::class, array( | ||||
'required' =>false | |||||
'required' => false | |||||
)); | )); | ||||
$reductionCartClass = $this->em->getClassMetadata(ReductionCartInterface::class)->getName(); | $reductionCartClass = $this->em->getClassMetadata(ReductionCartInterface::class)->getName(); | ||||
$reductionCartRepo = $this->em->getRepository(ReductionCartInterface::class); | $reductionCartRepo = $this->em->getRepository(ReductionCartInterface::class); | ||||
/* $builder->add('giftVoucherReductionCart', EntityType::class, array( | |||||
'required' =>false, | |||||
'class'=> $reductionCartClass, | |||||
'choices' => $reductionCartRepo->getOnlineReductionCart(), | |||||
));*/ | |||||
/* $builder->add('giftVoucherReductionCart', EntityType::class, array( | |||||
'required' =>false, | |||||
'class'=> $reductionCartClass, | |||||
'choices' => $reductionCartRepo->getOnlineReductionCart(), | |||||
));*/ | |||||
} | } | ||||
*/ | */ | ||||
protected $updatedBy; | protected $updatedBy; | ||||
/** | /** | ||||
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\TicketInterface", mappedBy="orderShop") | * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\TicketInterface", mappedBy="orderShop") | ||||
*/ | */ | ||||
protected $tickets; | protected $tickets; | ||||
/** | |||||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\SectionInterface", inversedBy="orderShops") | |||||
* @ORM\JoinColumn(nullable=false) | |||||
*/ | |||||
protected $section; | |||||
public function __construct() | public function __construct() | ||||
{ | { | ||||
$this->orderStatusHistories = new ArrayCollection(); | $this->orderStatusHistories = new ArrayCollection(); | ||||
return false ; | return false ; | ||||
} | } | ||||
public function getSection(): ?Section | |||||
{ | |||||
return $this->section; | |||||
} | |||||
public function setSection(?Section $section): self | |||||
{ | |||||
$this->section = $section; | |||||
return $this; | |||||
} | |||||
} | } |
namespace Lc\ShopBundle\Model; | namespace Lc\ShopBundle\Model; | ||||
use App\Entity\Hub; | |||||
use App\Entity\ProductFamily; | |||||
use Doctrine\Common\Collections\ArrayCollection; | use Doctrine\Common\Collections\ArrayCollection; | ||||
use Doctrine\Common\Collections\Collection; | use Doctrine\Common\Collections\Collection; | ||||
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
protected $childrens; | protected $childrens; | ||||
/** | /** | ||||
* @ORM\ManyToMany(targetEntity="App\Entity\ProductFamily", mappedBy="productCategories") | |||||
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\ProductFamilyInterface", mappedBy="productCategories") | |||||
*/ | */ | ||||
protected $productFamilies; | protected $productFamilies; | ||||
*/ | */ | ||||
protected $saleStatus; | protected $saleStatus; | ||||
/** | |||||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\SectionInterface", inversedBy="productCategories") | |||||
* @ORM\JoinColumn(nullable=false) | |||||
*/ | |||||
protected $section; | |||||
public function __construct() | public function __construct() | ||||
{ | { | ||||
$this->childrens = new ArrayCollection(); | $this->childrens = new ArrayCollection(); | ||||
public function __toString() | public function __toString() | ||||
{ | { | ||||
// TODO: Implement __toString() method. | |||||
return $this->getTitle(); | |||||
$parent = $this->getParent() ; | |||||
$title = $parent ? $parent->getTitle().' - ' : '' ; | |||||
$title .= $this->getTitle() ; | |||||
return $title ; | |||||
} | } | ||||
public function getParent(): ?self | public function getParent(): ?self | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getSection(): ?Section | |||||
{ | |||||
return $this->section; | |||||
} | |||||
public function setSection(?Section $section): self | |||||
{ | |||||
$this->section = $section; | |||||
return $this; | |||||
} | |||||
} | } |
*/ | */ | ||||
protected $behaviorPrice; | protected $behaviorPrice; | ||||
/** | /** | ||||
* @ORM\Column(type="boolean") | * @ORM\Column(type="boolean") | ||||
*/ | */ | ||||
protected $saleStatus; | protected $saleStatus; | ||||
/** | |||||
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\SectionInterface", inversedBy="productFamilies") | |||||
*/ | |||||
protected $sections; | |||||
public function __construct() | public function __construct() | ||||
{ | { | ||||
$this->productCategories = new ArrayCollection(); | $this->productCategories = new ArrayCollection(); | ||||
return $this; | return $this; | ||||
} | } | ||||
/** | |||||
* @return Collection|Section[] | |||||
*/ | |||||
public function getSections(): Collection | |||||
{ | |||||
return $this->sections; | |||||
} | |||||
public function addSection(Section $section): self | |||||
{ | |||||
if (!$this->sections->contains($section)) { | |||||
$this->sections[] = $section; | |||||
} | |||||
return $this; | |||||
} | |||||
public function removeSection(Section $section): self | |||||
{ | |||||
if ($this->sections->contains($section)) { | |||||
$this->sections->removeElement($section); | |||||
} | |||||
return $this; | |||||
} | |||||
} | } |
<?php | |||||
namespace Lc\ShopBundle\Model; | |||||
use App\Entity\Hub; | |||||
use Doctrine\Common\Collections\ArrayCollection; | |||||
use Doctrine\Common\Collections\Collection; | |||||
use Doctrine\ORM\Mapping as ORM; | |||||
use Lc\ShopBundle\Context\FilterMerchantInterface; | |||||
/** | |||||
* @ORM\MappedSuperclass() | |||||
*/ | |||||
abstract class Section extends AbstractDocumentEntity implements FilterMerchantInterface | |||||
{ | |||||
/** | |||||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface") | |||||
* @ORM\JoinColumn(nullable=false) | |||||
*/ | |||||
protected $merchant; | |||||
/** | |||||
* @ORM\Column(type="string", length=32) | |||||
*/ | |||||
protected $cycle; | |||||
const SECTION_CYCLE_DAY = 'day' ; | |||||
const SECTION_CYCLE_WEEK = 'week' ; | |||||
const SECTION_CYCLE_MONTH = 'month' ; | |||||
const SECTION_CYCLE_YEAR = 'year' ; | |||||
/** | |||||
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\ProductFamilyInterface", mappedBy="sections") | |||||
*/ | |||||
protected $productFamilies; | |||||
/** | |||||
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", mappedBy="section") | |||||
*/ | |||||
protected $orderShops; | |||||
/** | |||||
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\ProductCategoryInterface", mappedBy="section") | |||||
*/ | |||||
protected $productCategories; | |||||
public function __construct() | |||||
{ | |||||
$this->productFamilies = new ArrayCollection(); | |||||
$this->orderShops = new ArrayCollection(); | |||||
} | |||||
public function __toString() | |||||
{ | |||||
return $this->getTitle(); | |||||
} | |||||
public function getMerchant(): ?Hub | |||||
{ | |||||
return $this->merchant; | |||||
} | |||||
public function setMerchant(?Hub $merchant): self | |||||
{ | |||||
$this->merchant = $merchant; | |||||
return $this; | |||||
} | |||||
public function getCycle(): ?string | |||||
{ | |||||
return $this->cycle; | |||||
} | |||||
public function setCycle(string $cycle): self | |||||
{ | |||||
$this->cycle = $cycle; | |||||
return $this; | |||||
} | |||||
/** | |||||
* @return Collection|ProductFamily[] | |||||
*/ | |||||
public function getProductFamilies(): Collection | |||||
{ | |||||
return $this->productFamilies; | |||||
} | |||||
public function addProductFamily(ProductFamily $productFamily): self | |||||
{ | |||||
if (!$this->productFamilies->contains($productFamily)) { | |||||
$this->productFamilies[] = $productFamily; | |||||
$productFamily->addSection($this); | |||||
} | |||||
return $this; | |||||
} | |||||
public function removeProductFamily(ProductFamily $productFamily): self | |||||
{ | |||||
if ($this->productFamilies->contains($productFamily)) { | |||||
$this->productFamilies->removeElement($productFamily); | |||||
$productFamily->removeSection($this); | |||||
} | |||||
return $this; | |||||
} | |||||
/** | |||||
* @return Collection|OrderShop[] | |||||
*/ | |||||
public function getOrderShops(): Collection | |||||
{ | |||||
return $this->orderShops; | |||||
} | |||||
public function addOrderShop(OrderShop $orderShop): self | |||||
{ | |||||
if (!$this->orderShops->contains($orderShop)) { | |||||
$this->orderShops[] = $orderShop; | |||||
$orderShop->setSection($this); | |||||
} | |||||
return $this; | |||||
} | |||||
public function removeOrderShop(OrderShop $orderShop): self | |||||
{ | |||||
if ($this->orderShops->contains($orderShop)) { | |||||
$this->orderShops->removeElement($orderShop); | |||||
// set the owning side to null (unless already changed) | |||||
if ($orderShop->getSection() === $this) { | |||||
$orderShop->setSection(null); | |||||
} | |||||
} | |||||
return $this; | |||||
} | |||||
/** | |||||
* @return Collection|ProductCategory[] | |||||
*/ | |||||
public function getProductCategories(): Collection | |||||
{ | |||||
return $this->productCategories; | |||||
} | |||||
public function addProductCategory(ProductCategory $productCategory): self | |||||
{ | |||||
if (!$this->productCategories->contains($productCategory)) { | |||||
$this->productCategories[] = $productCategory; | |||||
$productCategory->setSection($this); | |||||
} | |||||
return $this; | |||||
} | |||||
public function removeProductCategory(ProductCategory $productCategory): self | |||||
{ | |||||
if ($this->productCategories->contains($productCategory)) { | |||||
$this->productCategories->removeElement($productCategory); | |||||
// set the owning side to null (unless already changed) | |||||
if ($productCategory->getSection() === $this) { | |||||
$productCategory->setSection(null); | |||||
} | |||||
} | |||||
return $this; | |||||
} | |||||
} |
$query->select( $params['select']); | $query->select( $params['select']); | ||||
} | } | ||||
if (isset($params['section'])) { | |||||
$query = $query->andWhere('e.section = :section')->setParameter('section', $params['section']); | |||||
} | |||||
if (isset($params['dateStart']) || isset($params['dateEnd'])) { | if (isset($params['dateStart']) || isset($params['dateEnd'])) { | ||||
$params['dateField'] = isset($params['dateField']) ? $params['dateField'] : 'validationDate'; | $params['dateField'] = isset($params['dateField']) ? $params['dateField'] : 'validationDate'; | ||||
} | } |
return $query->getQuery()->getOneOrNullResult() ; | return $query->getQuery()->getOneOrNullResult() ; | ||||
} | } | ||||
public function findOneByDevAlias($devAlias) | |||||
{ | |||||
$query = $this->findByMerchantQuery() ; | |||||
$query->andWhere('e.devAlias = :devAlias')->setParameter('devAlias',$devAlias) ; | |||||
return $query->getQuery()->getOneOrNullResult() ; | |||||
} | |||||
public function findAllParents($withOffline = false) | public function findAllParents($withOffline = false) | ||||
{ | { | ||||
$query = $this->findByMerchantQuery() | $query = $this->findByMerchantQuery() | ||||
return $query->getQuery()->getResult(); | return $query->getQuery()->getResult(); | ||||
} | } | ||||
public function findAllByParent($parentCategory, $withOffline = false, $withEmptyCategories = true) | |||||
public function findAllByParent($parentCategory, $withOffline = false, $withEmptyCategories = true, $filterBySpecificDay = false) | |||||
{ | { | ||||
$query = $this->createQueryBuilder('e'); | $query = $this->createQueryBuilder('e'); | ||||
$query->andWhere('e.parent = :idParentCategory'); | $query->andWhere('e.parent = :idParentCategory'); | ||||
$query->andWhere('pf.status = 1') ; | $query->andWhere('pf.status = 1') ; | ||||
} | } | ||||
if($filterBySpecificDay) { | |||||
$query->andWhere('e.displaySpecificDay IS NULL OR e.displaySpecificDay = :dayToday') ; | |||||
$query->setParameter('dayToday', date('N')) ; | |||||
} | |||||
$query->addOrderBy('e.position', 'ASC') ; | $query->addOrderBy('e.position', 'ASC') ; | ||||
return $query->getQuery()->getResult(); | return $query->getQuery()->getResult(); |
$query = $this->findByMerchantQuery() ; | $query = $this->findByMerchantQuery() ; | ||||
$query = $this->joinRelations($query) ; | $query = $this->joinRelations($query) ; | ||||
$query->andWhere('e.status = 1') ; | $query->andWhere('e.status = 1') ; | ||||
$query->orderBy('RAND()'); | |||||
return $query->getQuery()->getResult() ; | return $query->getQuery()->getResult() ; | ||||
} | } | ||||
$query->andWhere('e.status = 1'); | $query->andWhere('e.status = 1'); | ||||
$query->andWhere(':now <= e.propertyNoveltyExpirationDate') | $query->andWhere(':now <= e.propertyNoveltyExpirationDate') | ||||
->setParameter('now', new \DateTime()) ; | ->setParameter('now', new \DateTime()) ; | ||||
$query->orderBy('e.createdAt', 'DESC'); | |||||
$query->orderBy('RAND()'); | |||||
return $query->getQuery()->getResult() ; | return $query->getQuery()->getResult() ; | ||||
} | } | ||||
return $query->getQuery()->getResult() ; | return $query->getQuery()->getResult() ; | ||||
} | } | ||||
public function getProductFamiliesBySection($section, $maxResults = false, $sortField = 'productCategories.position', $sortDirection = 'ASC') | |||||
{ | |||||
$query = $this->findByMerchantQuery() ; | |||||
$query = $this->joinRelations($query) ; | |||||
$query->andWhere(':section MEMBER OF e.sections') | |||||
->setParameter('section', $section) ; | |||||
$query->leftJoin('e.productCategories', 'productCategories'); | |||||
if($sortField){ | |||||
$query->orderBy($sortField,$sortDirection); | |||||
} | |||||
if($maxResults) { | |||||
$query->setMaxResults($maxResults) ; | |||||
} | |||||
return $query->getQuery()->getResult() ; | |||||
} | |||||
} | } |
<?php | |||||
namespace Lc\ShopBundle\Repository; | |||||
use Lc\ShopBundle\Context\SectionInterface; | |||||
use Lc\ShopBundle\Context\DefaultRepositoryInterface; | |||||
/** | |||||
* @method SectionInterface|null find($id, $lockMode = null, $lockVersion = null) | |||||
* @method SectionInterface|null findOneBy(array $criteria, array $orderBy = null) | |||||
* @method SectionInterface[] findAll() | |||||
* @method SectionInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | |||||
*/ | |||||
class SectionRepository extends BaseRepository implements DefaultRepositoryInterface | |||||
{ | |||||
public function getInterfaceClass() | |||||
{ | |||||
return SectionInterface::class; | |||||
} | |||||
// /** | |||||
// * @return Address[] Returns an array of Address objects | |||||
// */ | |||||
/* | |||||
public function findByExampleField($value) | |||||
{ | |||||
return $this->createQueryBuilder('a') | |||||
->andWhere('a.exampleField = :val') | |||||
->setParameter('val', $value) | |||||
->orderBy('a.id', 'ASC') | |||||
->setMaxResults(10) | |||||
->getQuery() | |||||
->getResult() | |||||
; | |||||
} | |||||
*/ | |||||
/* | |||||
public function findOneBySomeField($value): ?Address | |||||
{ | |||||
return $this->createQueryBuilder('a') | |||||
->andWhere('a.exampleField = :val') | |||||
->setParameter('val', $value) | |||||
->getQuery() | |||||
->getOneOrNullResult() | |||||
; | |||||
} | |||||
*/ | |||||
} | |||||
{ | { | ||||
name: 'maintenance', | name: 'maintenance', | ||||
nameDisplay: 'Maintenance' | nameDisplay: 'Maintenance' | ||||
}, | |||||
{ | |||||
name: 'lunch', | |||||
nameDisplay: 'Repas du midi' | |||||
} | } | ||||
] | ] | ||||
}, window.addressValues, window.merchantPanelOrderValues); | }, window.addressValues, window.merchantPanelOrderValues); |
activeProducts: false, | activeProducts: false, | ||||
giftVoucherActive: false, | giftVoucherActive: false, | ||||
productsQuantityAsTitle: false, | productsQuantityAsTitle: false, | ||||
section: null, | |||||
formProducts: {}, | formProducts: {}, | ||||
currentSection: 'general', | currentSection: 'general', | ||||
sectionsArray: [ | sectionsArray: [ | ||||
} | } | ||||
} | } | ||||
this.sectionHasChanged(); | |||||
this.initLcSortableProductsList(); | this.initLcSortableProductsList(); | ||||
}); | }); | ||||
if (typeof this.$refs.productUnitPrice !== 'undefined') { | if (typeof this.$refs.productUnitPrice !== 'undefined') { | ||||
return this.$refs.productUnitPrice.behaviorPrice; | return this.$refs.productUnitPrice.behaviorPrice; | ||||
} | } | ||||
}, | |||||
sectionHasChanged: function (){ | |||||
$('.product-categories').find('.form-check-input:not(.none)').prop('disabled', true); | |||||
$('.product-categories').find('.form-check-input[data-section="'+this.section+'"]:not(.none)').prop('disabled', false); | |||||
} | } | ||||
}, | }, | ||||
watch: { | watch: { | ||||
title: function () { | title: function () { | ||||
this.updateChild() | this.updateChild() | ||||
}, | }, | ||||
section: function (){ | |||||
this.sectionHasChanged() | |||||
}, | |||||
propertyNoveltyExpirationDateActive: function () { | propertyNoveltyExpirationDateActive: function () { | ||||
if(!this.propertyNoveltyExpirationDateActive){ | if(!this.propertyNoveltyExpirationDateActive){ | ||||
this.propertyNoveltyExpirationDate = null; | this.propertyNoveltyExpirationDate = null; |
Statistic: | Statistic: | ||||
title: Statistiques | title: Statistiques | ||||
ProductFamily: | ProductFamily: | ||||
status: Espaces et statuts | |||||
addresses: Livraisons & facturation | addresses: Livraisons & facturation | ||||
main: Général | main: Général | ||||
products: Déclinaisons | products: Déclinaisons | ||||
email: Email | email: Email | ||||
delivery: Livraison | delivery: Livraison | ||||
maintenance: Maintenance | maintenance: Maintenance | ||||
lunch: Repas du midi | |||||
Address: | Address: | ||||
listLoopBesancon: Adresses de Besançon à spécifier (lat / long) | listLoopBesancon: Adresses de Besançon à spécifier (lat / long) | ||||
editStockNoQuantityDefault: "Le stock n'a pas été modifié pour le produit #%id% (Aucune quantité par défaut)" | editStockNoQuantityDefault: "Le stock n'a pas été modifié pour le produit #%id% (Aucune quantité par défaut)" | ||||
field: | field: | ||||
default: | default: | ||||
section: Espace | |||||
unit: Unité | unit: Unité | ||||
placeholder: Choisissez une option | placeholder: Choisissez une option | ||||
deliveryPointSale: Lieu de livraison | deliveryPointSale: Lieu de livraison | ||||
purchaseOrderEmailContent: "Contenu par défaut de l'email envoyé aux producteurs" | purchaseOrderEmailContent: "Contenu par défaut de l'email envoyé aux producteurs" | ||||
dateStart: Date de début | dateStart: Date de début | ||||
dateEnd: Date de fin | dateEnd: Date de fin | ||||
messageLunchOpen: Message (section ouverte) | |||||
messageLunchClosed: Message (section fermée) | |||||
displaySpecificDay: Disponible un jour spécifique | |||||
groupUsers: Groupes | |||||
ticketTypesNotification: Catégorie ticket | |||||
PointSale: | PointSale: | ||||
code: Code | code: Code | ||||
displayTotalWeightInPurchaseOrder: Afficher le poids total dans les bons de commande | displayTotalWeightInPurchaseOrder: Afficher le poids total dans les bons de commande | ||||
ProductFamily: | ProductFamily: | ||||
sections: Espace où le produit est vendu | |||||
taxRateInherited: Utiliser la TVA par défaut | taxRateInherited: Utiliser la TVA par défaut | ||||
activeProducts: Activer les déclinaisons | activeProducts: Activer les déclinaisons | ||||
productsType: Type de déclinaisons | productsType: Type de déclinaisons | ||||
quantityOrder: Quantité commandé | quantityOrder: Quantité commandé | ||||
quantityProduct: Quantité (en rapport à l'unité) | quantityProduct: Quantité (en rapport à l'unité) | ||||
unit: Unité | unit: Unité | ||||
OrderShopLunch: | |||||
deliveryTypeOptions: | |||||
point-sale: En ambassade | |||||
home: À domicile | |||||
OrderShop: | OrderShop: | ||||
hasReach: Étape atteinte | hasReach: Étape atteinte | ||||
deliveryTrucks: Véhicules de livraison | deliveryTrucks: Véhicules de livraison | ||||
days: Par jour | days: Par jour | ||||
week: Par semaine | week: Par semaine | ||||
month: Par mois | month: Par mois | ||||
User: | |||||
isSaleAlwaysOpen: Commandes toujours ouvertes | |||||
action: | action: | ||||
apply: Appliquer | apply: Appliquer | ||||
new: Créer %entity_label% | new: Créer %entity_label% | ||||
logout: Me déconnecter | logout: Me déconnecter | ||||
address: Adresse utilisateur | address: Adresse utilisateur | ||||
switch: Prendre la main | switch: Prendre la main | ||||
order: | order: | ||||
addOrderProduct: Ajouter un produit | addOrderProduct: Ajouter un produit | ||||
addReductionCart: Ajouter une réduction | addReductionCart: Ajouter une réduction |
<div v-show="currentSection == 'maintenance'" class="panel panel-default"> | <div v-show="currentSection == 'maintenance'" class="panel panel-default"> | ||||
{% include '@LcShop/backend/merchant/panel_maintenance.html.twig' %} | {% include '@LcShop/backend/merchant/panel_maintenance.html.twig' %} | ||||
</div> | </div> | ||||
<div v-show="currentSection == 'lunch'" class="panel panel-default"> | |||||
{% include '@LcShop/backend/merchant/panel_lunch.html.twig' %} | |||||
</div> | |||||
</div> | </div> | ||||
</div> | </div> |
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | |||||
<div class="row"> | |||||
<div class="col-8"> | |||||
{{ macros.card_start('Merchant.lunch','light') }} | |||||
{% if form.merchantConfigs['message-lunch-open'] is defined %} | |||||
<div class="col-12"> | |||||
{{ form_row(form.merchantConfigs['message-lunch-open']) }} | |||||
</div> | |||||
{% endif %} | |||||
{% if form.merchantConfigs['message-lunch-closed'] is defined %} | |||||
<div class="col-12"> | |||||
{{ form_row(form.merchantConfigs['message-lunch-closed']) }} | |||||
</div> | |||||
{% endif %} | |||||
{{ macros.card_end() }} | |||||
</div> | |||||
</div> |
{% import '@LcShop/backend/productfamily/macros.html.twig' as product_family_macros %} | {% import '@LcShop/backend/productfamily/macros.html.twig' as product_family_macros %} | ||||
{% set formValues = form.vars.value %} | {% set formValues = form.vars.value %} | ||||
<div id="lc-product-family-edit"> | <div id="lc-product-family-edit"> | ||||
<div class="card card-light"> | <div class="card card-light"> | ||||
<div class="lc-vue-js-container card-header p-0 border-bottom-0"> | <div class="lc-vue-js-container card-header p-0 border-bottom-0"> | ||||
{% if formValues.activeProducts %}activeProducts: "{{ formValues.activeProducts }}",{% endif %} | {% if formValues.activeProducts %}activeProducts: "{{ formValues.activeProducts }}",{% endif %} | ||||
{% if formValues.giftVoucherActive %}giftVoucherActive: "{{ formValues.giftVoucherActive }}",{% endif %} | {% if formValues.giftVoucherActive %}giftVoucherActive: "{{ formValues.giftVoucherActive }}",{% endif %} | ||||
{% if formValues.productsQuantityAsTitle %}productsQuantityAsTitle: {{ formValues.productsQuantityAsTitle }},{% endif %} | {% if formValues.productsQuantityAsTitle %}productsQuantityAsTitle: {{ formValues.productsQuantityAsTitle }},{% endif %} | ||||
{% if form.sections.vars.value %}section: {{ form.sections.vars.value[0] }},{% endif %} | |||||
}; | }; | ||||
multiplyingFactor = "{{ form.multiplyingFactor.vars.value }}" | multiplyingFactor = "{{ form.multiplyingFactor.vars.value }}" |
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | {% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | ||||
<div class="row"> | <div class="row"> | ||||
{{ macros.startCard(8, 'ProductFamily.main','light') }} | |||||
<div class="col-12"> | |||||
{{ macros.startCard(8, 'ProductFamily.status','light') }} | |||||
<div class="col-6"> | |||||
{{ form_row(form.status) }} | {{ form_row(form.status) }} | ||||
</div> | </div> | ||||
<div class="col-12"> | |||||
<div class="col-6"> | |||||
<label>Status de vente</label> | |||||
{{ form_row(form.saleStatus) }} | {{ form_row(form.saleStatus) }} | ||||
</div> | </div> | ||||
<div class="col-12"> | |||||
{{ form_label(form.sections) }} | |||||
{% for section in form.sections %} | |||||
<div class="form-check"> | |||||
<label class="form-check-label" for="{{ section.vars.id }}"> | |||||
<input v-model="section" type="radio" id="{{ section.vars.id }}" name="{{ section.vars.full_name }}" class="form-check-input" value="{{ section.vars.value }}" {{ section.vars.checked == true ? 'checked="checked"' : '' }}> | |||||
<span class="checkmark"></span> | |||||
{{ section.vars.label }} | |||||
</label> | |||||
</div> | |||||
{% endfor %} | |||||
{% do form.sections.setRendered %} | |||||
</div> | |||||
{{ macros.endCard() }} | |||||
{{ macros.startCard(8, 'ProductFamily.main','light') }} | |||||
<div class="col-12"> | <div class="col-12"> | ||||
{{ form_row(form.supplier) }} | {{ form_row(form.supplier) }} | ||||
</div> | </div> | ||||
<div class="col-12 product-categories"> | <div class="col-12 product-categories"> | ||||
{% for category in form.productCategories %} | {% for category in form.productCategories %} | ||||
<div class="field {{ category.vars.disabled ? 'parent' }}"> | |||||
<div class="field {{ category.vars.disabled ? 'parent' }}"> | |||||
{{ form_row(category) }} | {{ form_row(category) }} | ||||
</div> | </div> | ||||
use Lc\ShopBundle\Context\PriceUtilsInterface; | use Lc\ShopBundle\Context\PriceUtilsInterface; | ||||
use Lc\ShopBundle\Context\ProductFamilyUtilsInterface; | use Lc\ShopBundle\Context\ProductFamilyUtilsInterface; | ||||
use Lc\ShopBundle\Context\ReductionCreditInterface; | use Lc\ShopBundle\Context\ReductionCreditInterface; | ||||
use Lc\ShopBundle\Context\SectionInterface; | |||||
use Lc\ShopBundle\Context\SectionUtilsInterface; | |||||
use Lc\ShopBundle\Context\UserUtilsInterface; | use Lc\ShopBundle\Context\UserUtilsInterface; | ||||
use Lc\ShopBundle\Model\ProductFamily; | use Lc\ShopBundle\Model\ProductFamily; | ||||
use Lc\ShopBundle\Services\CreditUtils; | use Lc\ShopBundle\Services\CreditUtils; | ||||
use Lc\ShopBundle\Services\DocumentUtils; | use Lc\ShopBundle\Services\DocumentUtils; | ||||
use Lc\ShopBundle\Services\UserUtils; | use Lc\ShopBundle\Services\UserUtils; | ||||
use Lc\ShopBundle\Services\Utils; | use Lc\ShopBundle\Services\Utils; | ||||
use Lc\ShopBundle\Services\UtilsManager; | |||||
use Symfony\Component\Routing\RouterInterface; | use Symfony\Component\Routing\RouterInterface; | ||||
use Symfony\Component\Security\Core\Security; | use Symfony\Component\Security\Core\Security; | ||||
protected $utils; | protected $utils; | ||||
protected $creditUtils; | protected $creditUtils; | ||||
protected $router; | protected $router; | ||||
protected $sectionUtils ; | |||||
public function __construct(EntityManagerInterface $em, Security $security, RouterInterface $router, UserUtilsInterface $userUtils, | public function __construct(EntityManagerInterface $em, Security $security, RouterInterface $router, UserUtilsInterface $userUtils, | ||||
MerchantUtilsInterface $merchantUtils, PriceUtilsInterface $priceUtils, ProductFamilyUtilsInterface $productFamilyUtils, | MerchantUtilsInterface $merchantUtils, PriceUtilsInterface $priceUtils, ProductFamilyUtilsInterface $productFamilyUtils, | ||||
DocumentUtils $documentUtils, Utils $utils, CreditUtils $creditUtils) | |||||
DocumentUtils $documentUtils, Utils $utils, CreditUtils $creditUtils, SectionUtilsInterface $sectionUtils) | |||||
{ | { | ||||
$this->em = $em; | $this->em = $em; | ||||
$this->security = $security; | $this->security = $security; | ||||
$this->utils = $utils; | $this->utils = $utils; | ||||
$this->creditUtils = $creditUtils; | $this->creditUtils = $creditUtils; | ||||
$this->router = $router; | $this->router = $router; | ||||
$this->sectionUtils = $sectionUtils ; | |||||
} | } | ||||
public function createOrderShop($params) | public function createOrderShop($params) | ||||
{ | { | ||||
//TODO vérifier que l'utilisateur n'a pas déjà une commande en cours | //TODO vérifier que l'utilisateur n'a pas déjà une commande en cours | ||||
throw new \ErrorException('La commande doit être liée à un merchant.'); | throw new \ErrorException('La commande doit être liée à un merchant.'); | ||||
} | } | ||||
// pour le moment, à la création, on lie simplement la commande à la section "Marché" | |||||
$section = $this->sectionUtils->getSectionMarket() ; | |||||
if($section) { | |||||
$orderShop->setSection($section) ; | |||||
} | |||||
else { | |||||
throw new \ErrorException('La commande doit être liée à une section.'); | |||||
} | |||||
$orderShop = $this->changeOrderStatus('cart', $orderShop); | $orderShop = $this->changeOrderStatus('cart', $orderShop); | ||||
return $orderShop; | return $orderShop; | ||||
public function addOrderProduct($orderShop, $orderProductAdd, $persist = true) | public function addOrderProduct($orderShop, $orderProductAdd, $persist = true) | ||||
{ | { | ||||
$return = false; | $return = false; | ||||
if (!$orderShop) { | if (!$orderShop) { | ||||
$user = $this->security->getUser(); | $user = $this->security->getUser(); | ||||
$visitor = $this->userUtils->getVisitorCurrent(); | $visitor = $this->userUtils->getVisitorCurrent(); | ||||
$orderShop = $this->createOrderShop([ | $orderShop = $this->createOrderShop([ | ||||
'user' => $user, | 'user' => $user, | ||||
'visitor' => $visitor, | 'visitor' => $visitor, | ||||
'merchant' => $this->merchantUtils->getMerchantCurrent() | |||||
'merchant' => $this->merchantUtils->getMerchantCurrent(), | |||||
]); | ]); | ||||
} | } | ||||
namespace Lc\ShopBundle\Services\Order; | namespace Lc\ShopBundle\Services\Order; | ||||
use Lc\ShopBundle\Context\OrderShopInterface; | use Lc\ShopBundle\Context\OrderShopInterface; | ||||
use Lc\ShopBundle\Model\OrderStatus; | use Lc\ShopBundle\Model\OrderStatus; | ||||
} | } | ||||
if($createIfNotExist && !$orderShop) { | if($createIfNotExist && !$orderShop) { | ||||
$merchant = $this->merchantUtils->getMerchantCurrent() ; | |||||
$orderShop = $this->createOrderShop([ | $orderShop = $this->createOrderShop([ | ||||
'user' => $user, | 'user' => $user, | ||||
'visitor' => $visitor, | 'visitor' => $visitor, | ||||
'merchant' => $this->merchantUtils->getMerchantCurrent() | |||||
'merchant' => $merchant, | |||||
]); | ]); | ||||
} | } | ||||
} | } | ||||
$allCategoriesSalesOff = true; | $allCategoriesSalesOff = true; | ||||
$unavailableSpecificDay = false; | |||||
foreach ($product->getProductFamily()->getProductCategories() as $category){ | foreach ($product->getProductFamily()->getProductCategories() as $category){ | ||||
if($category->getParent()) { | if($category->getParent()) { | ||||
if($category->getSaleStatus() && $category->getParent()->getSaleStatus()) | if($category->getSaleStatus() && $category->getParent()->getSaleStatus()) | ||||
$allCategoriesSalesOff = false; | $allCategoriesSalesOff = false; | ||||
} | } | ||||
else { | else { | ||||
if($category->getSaleStatus()) $allCategoriesSalesOff = false; | |||||
if($category->getSaleStatus()) { | |||||
$allCategoriesSalesOff = false; | |||||
} | |||||
} | } | ||||
// specific day | |||||
$displaySpecificDay = $category->getDisplaySpecificDay() ; | |||||
if($displaySpecificDay && $displaySpecificDay != date('N')) { | |||||
$unavailableSpecificDay = true; | |||||
} | |||||
} | |||||
if($allCategoriesSalesOff) { | |||||
return false; | |||||
} | |||||
if($unavailableSpecificDay) { | |||||
return false; | |||||
} | } | ||||
if($allCategoriesSalesOff) return false; | |||||
return true ; | return true ; | ||||
} | } |
<?php | |||||
namespace Lc\ShopBundle\Services ; | |||||
use Doctrine\ORM\EntityManagerInterface; | |||||
use Http\Discovery\Exception\NotFoundException; | |||||
use Lc\ShopBundle\Context\MerchantUtilsInterface; | |||||
use Lc\ShopBundle\Context\SectionInterface; | |||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | |||||
class SectionUtils | |||||
{ | |||||
protected $em ; | |||||
protected $merchantUtils ; | |||||
protected $sectionRepository ; | |||||
public function __construct(EntityManagerInterface $em, MerchantUtilsInterface $merchantUtils) | |||||
{ | |||||
$this->em = $em ; | |||||
$this->sectionRepository = $this->em->getRepository($this->em->getClassMetadata(SectionInterface::class)->getName()) ; | |||||
$this->merchantUtils = $merchantUtils ; | |||||
} | |||||
public function getSection($devAlias) | |||||
{ | |||||
$section = $this->sectionRepository->findOneBy([ | |||||
'merchant' => $this->merchantUtils->getMerchantCurrent(), | |||||
'devAlias' => $devAlias | |||||
]) ; | |||||
if(!$section) { | |||||
throw new NotFoundException('La section '.$devAlias.' est introuvable') ; | |||||
} | |||||
return $section ; | |||||
} | |||||
} |
use Lc\ShopBundle\Context\OrderUtilsInterface; | use Lc\ShopBundle\Context\OrderUtilsInterface; | ||||
use Lc\ShopBundle\Context\PriceUtilsInterface; | use Lc\ShopBundle\Context\PriceUtilsInterface; | ||||
use Lc\ShopBundle\Context\ProductFamilyUtilsInterface; | use Lc\ShopBundle\Context\ProductFamilyUtilsInterface; | ||||
use Lc\ShopBundle\Context\SectionUtilsInterface; | |||||
use Lc\ShopBundle\Context\Services\StatisticsUtilsInterface; | use Lc\ShopBundle\Context\Services\StatisticsUtilsInterface; | ||||
use Lc\ShopBundle\Context\UserUtilsInterface; | use Lc\ShopBundle\Context\UserUtilsInterface; | ||||
use League\Flysystem\Util; | use League\Flysystem\Util; | ||||
protected $ticketUtils ; | protected $ticketUtils ; | ||||
protected $statisticsUtils; | protected $statisticsUtils; | ||||
protected $pointLocationUtils ; | protected $pointLocationUtils ; | ||||
protected $sectionUtils ; | |||||
public function __construct( | public function __construct( | ||||
Utils $utils, | Utils $utils, | ||||
MailUtils $mailUtils, | MailUtils $mailUtils, | ||||
TicketUtils $ticketUtils, | TicketUtils $ticketUtils, | ||||
PointLocationUtils $pointLocationUtils, | PointLocationUtils $pointLocationUtils, | ||||
UtilsProcess $utilsProcess | |||||
UtilsProcess $utilsProcess, | |||||
SectionUtilsInterface $sectionUtils | |||||
) | ) | ||||
{ | { | ||||
$this->utils = $utils ; | $this->utils = $utils ; | ||||
$this->ticketUtils = $ticketUtils ; | $this->ticketUtils = $ticketUtils ; | ||||
$this->pointLocationUtils = $pointLocationUtils ; | $this->pointLocationUtils = $pointLocationUtils ; | ||||
$this->utilsProcess = $utilsProcess ; | $this->utilsProcess = $utilsProcess ; | ||||
$this->sectionUtils = $sectionUtils ; | |||||
} | } | ||||
public function getUtils(): Utils | public function getUtils(): Utils | ||||
return $this->utilsProcess ; | return $this->utilsProcess ; | ||||
} | } | ||||
public function getSectionUtils(): SectionUtilsInterface | |||||
{ | |||||
return $this->sectionUtils ; | |||||
} | |||||
} | } |