Fab 3 лет назад
Родитель
Сommit
ae186b8de2
27 измененных файлов: 617 добавлений и 86 удалений
  1. +8
    -0
      ShopBundle/Context/SectionInterface.php
  2. +8
    -0
      ShopBundle/Context/SectionUtilsInterface.php
  3. +59
    -33
      ShopBundle/Controller/Backend/AdminController.php
  4. +17
    -0
      ShopBundle/Controller/Backend/OrderController.php
  5. +4
    -0
      ShopBundle/Controller/Frontend/CartController.php
  6. +14
    -9
      ShopBundle/Form/Backend/ProductFamily/ProductFamilyCategoriesType.php
  7. +17
    -17
      ShopBundle/Form/Backend/ProductFamily/ProductType.php
  8. +18
    -1
      ShopBundle/Model/OrderShop.php
  9. +25
    -5
      ShopBundle/Model/ProductCategory.php
  10. +31
    -1
      ShopBundle/Model/ProductFamily.php
  11. +172
    -0
      ShopBundle/Model/Section.php
  12. +4
    -0
      ShopBundle/Repository/OrderShopRepository.php
  13. +13
    -1
      ShopBundle/Repository/ProductCategoryRepository.php
  14. +18
    -1
      ShopBundle/Repository/ProductFamilyRepository.php
  15. +50
    -0
      ShopBundle/Repository/SectionRepository.php
  16. +4
    -0
      ShopBundle/Resources/public/js/backend/script/merchant/vuejs-merchant.js
  17. +9
    -0
      ShopBundle/Resources/public/js/backend/script/productfamily/vuejs-product-family.js
  18. +16
    -1
      ShopBundle/Resources/translations/lcshop.fr.yaml
  19. +3
    -1
      ShopBundle/Resources/views/backend/merchant/form.html.twig
  20. +18
    -0
      ShopBundle/Resources/views/backend/merchant/panel_lunch.html.twig
  21. +1
    -1
      ShopBundle/Resources/views/backend/productfamily/form.html.twig
  22. +23
    -4
      ShopBundle/Resources/views/backend/productfamily/panel_general.html.twig
  23. +16
    -6
      ShopBundle/Services/Order/OrderUtils.php
  24. +3
    -2
      ShopBundle/Services/Order/OrderUtilsCartTrait.php
  25. +19
    -2
      ShopBundle/Services/Order/OrderUtilsStockTrait.php
  26. +37
    -0
      ShopBundle/Services/SectionUtils.php
  27. +10
    -1
      ShopBundle/Services/UtilsManager.php

+ 8
- 0
ShopBundle/Context/SectionInterface.php Просмотреть файл

@@ -0,0 +1,8 @@
<?php

namespace Lc\ShopBundle\Context;

interface SectionInterface
{

}

+ 8
- 0
ShopBundle/Context/SectionUtilsInterface.php Просмотреть файл

@@ -0,0 +1,8 @@
<?php

namespace Lc\ShopBundle\Context;

interface SectionUtilsInterface
{

}

+ 59
- 33
ShopBundle/Controller/Backend/AdminController.php Просмотреть файл

@@ -42,10 +42,11 @@ class AdminController extends EasyAdminController
protected $merchantUtils;
protected $mailjetTransport;
protected $orderUtils;
protected $mailUtils ;
protected $mailUtils;
protected $translator;
protected $utilsProcess;
protected $session;
protected $sectionUtils;
protected $filtersForm = null;

public function __construct(Security $security, UserManagerInterface $userManager, EntityManagerInterface $em,
@@ -58,8 +59,9 @@ class AdminController extends EasyAdminController
$this->utils = $utilsManager->getUtils();
$this->merchantUtils = $utilsManager->getMerchantUtils();
$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->session = $session;
}
@@ -134,6 +136,21 @@ class AdminController extends EasyAdminController
$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 ($dqlFilter) $dqlFilter .= sprintf(' AND entity.status > = 0');
else $dqlFilter .= sprintf(' entity.status > = 0');
@@ -203,9 +220,9 @@ class AdminController extends EasyAdminController
} else {
$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()));
}else{
} else {
$queryBuilder->setParameter($field['property'], $filter);
}
}
@@ -226,6 +243,11 @@ class AdminController extends EasyAdminController
}
}

//TODO déplacer dans LC
if($this->entity['name']== 'OrderShopLunch' || $this->entity['name']== 'OrderShopLunchDay'){
$queryBuilder->addOrderBy('entity.user', 'asc');
}

return $queryBuilder;
}

@@ -540,6 +562,7 @@ class AdminController extends EasyAdminController
$form->add($child->getName(), EntityType::class, array(
'class' => $this->em->getClassMetadata($passedOptions['class'])->getName(),
'label' => $passedOptions['label'],
'expanded' => isset($passedOptions['expanded']) ? $passedOptions['expanded'] : false,
'multiple' => isset($passedOptions['multiple']) ? $passedOptions['multiple'] : false,
'placeholder' => '--',
'translation_domain' => 'lcshop',
@@ -590,7 +613,7 @@ class AdminController extends EasyAdminController

$id = $this->request->query->get('id');
$easyadmin = $this->request->attributes->get('easyadmin');
$entity = $easyadmin['item'];
$entity = $easyadmin['item'];

if ($this->request->isXmlHttpRequest() && $property = $this->request->query->get('property')) {
$newValue = 'true' === mb_strtolower($this->request->query->get('newValue'));
@@ -635,65 +658,68 @@ class AdminController extends EasyAdminController
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');
$refererUrl = $this->request->query->get('referer', '');

$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);

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');
$hubAlias = $this->request->query->get('hub');
$refererUrl = $this->request->query->get('referer', '');
$user = $this->security->getUser() ;
$user = $this->security->getUser();

$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);
$this->em->persist($user);
$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);
}else{
return $this->redirect($hub->getMerchantConfig('url').substr($url,1));
} else {
return $this->redirect($hub->getMerchantConfig('url') . substr($url, 1));
}

}

+ 17
- 0
ShopBundle/Controller/Backend/OrderController.php Просмотреть файл

@@ -581,6 +581,23 @@ class OrderController extends AdminController
$id = $this->request->query->get('id');
$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', [
'action' => 'show',
'entity' => $entity,

+ 4
- 0
ShopBundle/Controller/Frontend/CartController.php Просмотреть файл

@@ -27,6 +27,8 @@ class CartController extends BaseController
protected $orderUtils ;
protected $userUtils ;
protected $priceUtils ;
protected $sectionUtils ;
protected $mailUtils ;
protected $router ;
protected $productFamilyRepository ;
protected $orderProductRepository ;
@@ -42,6 +44,8 @@ class CartController extends BaseController
$this->orderUtils = $utilsManager->getOrderUtils() ;
$this->userUtils = $utilsManager->getUserUtils() ;
$this->priceUtils = $utilsManager->getPriceUtils() ;
$this->sectionUtils = $utilsManager->getSectionUtils() ;
$this->mailUtils = $utilsManager->getMailUtils() ;
$this->router = $router ;
$this->productFamilyRepository = $this->em->getRepository($this->em->getClassMetaData(ProductFamilyInterface::class)->getName()) ;
$this->orderProductRepository = $this->em->getRepository($this->em->getClassMetaData(OrderProductInterface::class)->getName()) ;

+ 14
- 9
ShopBundle/Form/Backend/ProductFamily/ProductFamilyCategoriesType.php Просмотреть файл

@@ -16,12 +16,12 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class ProductFamilyCategoriesType extends AbstractType
{
protected $em;
protected $productCategoryRepository ;
protected $productCategoryRepository;

public function __construct(EntityManagerInterface $entityManager, ProductCategoryRepository $productCategoryRepository)
{
$this->em = $entityManager;
$this->productCategoryRepository = $productCategoryRepository ;
$this->productCategoryRepository = $productCategoryRepository;
}

public function buildForm(FormBuilderInterface $builder, array $options)
@@ -34,20 +34,25 @@ class ProductFamilyCategoriesType extends AbstractType

foreach ($categories as $category) {
$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),
'required' => false,
'disabled'=>true,
'attr'=>[
'class'=>'none'
]
'disabled' => true,
'attr' => [
'class' => 'none',
'data-section' => $category->getSection()->getId()
],
]);
$childrenCategories = $this->productCategoryRepository->findAllByParent($category, true);
foreach ($childrenCategories as $children) {
$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),
'required' => false
'required' => false,
'attr' => [
'data-section' => $category->getSection()->getId()
],

]);
}
}

+ 17
- 17
ShopBundle/Form/Backend/ProductFamily/ProductType.php Просмотреть файл

@@ -29,6 +29,7 @@ class ProductType extends AbstractType
$this->em = $entityManager;
$this->utils = $utils;
}

public function buildForm(FormBuilderInterface $builder, array $options)
{

@@ -36,12 +37,11 @@ class ProductType extends AbstractType

$builder->add('title', TextType::class, array(
"required" => false
)) ;

));

$builder->add('quantity', NumberType::class, array(
'label' => 'Quantité',
'required'=>false,
'required' => false,
'attr' => [
'append_html' => 'g'
]
@@ -50,9 +50,9 @@ class ProductType extends AbstractType
$unitClass = $this->em->getClassMetadata(UnitInterface::class)->getName();

$builder->add('unit', EntityType::class, array(
'class'=> $unitClass,
'class' => $unitClass,
'data' => 0,
'required'=>false,
'required' => false,
'choice_attr' => function ($choice) {
return [
'data-unit-reference' => $choice->getUnitReference(),
@@ -75,7 +75,7 @@ class ProductType extends AbstractType

$builder->add('buyingPrice', NumberType::class, array(
'label' => 'Prix d\'achat',
'required'=>false
'required' => false
));

$builder->add('buyingPriceWithTax', NumberType::class, array(
@@ -86,7 +86,7 @@ class ProductType extends AbstractType

$builder->add('buyingPriceByRefUnit', NumberType::class, array(
'label' => 'Prix d\'achat',
'required'=>false
'required' => false
));

$builder->add('buyingPriceByRefUnitWithTax', NumberType::class, array(
@@ -96,12 +96,12 @@ class ProductType extends AbstractType
));
$builder->add('multiplyingFactor', NumberType::class, array(
'label' => 'Coefficiant de multiplication',
'mapped'=>false,
'required'=>false
'mapped' => false,
'required' => false
));

$builder->add('priceByRefUnit', NumberType::class, array(
'required'=>false
'required' => false
));

$builder->add('priceByRefUnitWithTax', NumberType::class, array(
@@ -126,19 +126,19 @@ class ProductType extends AbstractType
$builder->add('position', HiddenType::class);
$builder->add('status', HiddenType::class);
$builder->add('exportTitle', TextType::class, array(
'required' =>false
'required' => false
));
$builder->add('exportNote', TextType::class, array(
'required' =>false
'required' => false
));
$reductionCartClass = $this->em->getClassMetadata(ReductionCartInterface::class)->getName();
$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(),
));*/

}


+ 18
- 1
ShopBundle/Model/OrderShop.php Просмотреть файл

@@ -117,12 +117,17 @@ abstract class OrderShop extends AbstractEntity implements FilterMerchantInterfa
*/
protected $updatedBy;


/**
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\TicketInterface", mappedBy="orderShop")
*/
protected $tickets;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\SectionInterface", inversedBy="orderShops")
* @ORM\JoinColumn(nullable=false)
*/
protected $section;

public function __construct()
{
$this->orderStatusHistories = new ArrayCollection();
@@ -572,4 +577,16 @@ abstract class OrderShop extends AbstractEntity implements FilterMerchantInterfa
return false ;
}

public function getSection(): ?Section
{
return $this->section;
}

public function setSection(?Section $section): self
{
$this->section = $section;

return $this;
}

}

+ 25
- 5
ShopBundle/Model/ProductCategory.php Просмотреть файл

@@ -2,8 +2,6 @@

namespace Lc\ShopBundle\Model;

use App\Entity\Hub;
use App\Entity\ProductFamily;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@@ -34,7 +32,7 @@ abstract class ProductCategory extends AbstractDocumentEntity implements TreeInt
protected $childrens;

/**
* @ORM\ManyToMany(targetEntity="App\Entity\ProductFamily", mappedBy="productCategories")
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\ProductFamilyInterface", mappedBy="productCategories")
*/
protected $productFamilies;

@@ -43,6 +41,13 @@ abstract class ProductCategory extends AbstractDocumentEntity implements TreeInt
*/
protected $saleStatus;


/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\SectionInterface", inversedBy="productCategories")
* @ORM\JoinColumn(nullable=false)
*/
protected $section;

public function __construct()
{
$this->childrens = new ArrayCollection();
@@ -51,8 +56,10 @@ abstract class ProductCategory extends AbstractDocumentEntity implements TreeInt

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
@@ -176,4 +183,17 @@ abstract class ProductCategory extends AbstractDocumentEntity implements TreeInt

return $this;
}

public function getSection(): ?Section
{
return $this->section;
}

public function setSection(?Section $section): self
{
$this->section = $section;

return $this;
}

}

+ 31
- 1
ShopBundle/Model/ProductFamily.php Просмотреть файл

@@ -222,12 +222,16 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr
*/
protected $behaviorPrice;


/**
* @ORM\Column(type="boolean")
*/
protected $saleStatus;

/**
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\SectionInterface", inversedBy="productFamilies")
*/
protected $sections;

public function __construct()
{
$this->productCategories = new ArrayCollection();
@@ -857,4 +861,30 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr

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;
}
}

+ 172
- 0
ShopBundle/Model/Section.php Просмотреть файл

@@ -0,0 +1,172 @@
<?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;
}
}

+ 4
- 0
ShopBundle/Repository/OrderShopRepository.php Просмотреть файл

@@ -128,6 +128,10 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt
$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'])) {
$params['dateField'] = isset($params['dateField']) ? $params['dateField'] : 'validationDate';
}

+ 13
- 1
ShopBundle/Repository/ProductCategoryRepository.php Просмотреть файл

@@ -35,6 +35,13 @@ class ProductCategoryRepository extends BaseRepository implements DefaultReposit
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)
{
$query = $this->findByMerchantQuery()
@@ -48,7 +55,7 @@ class ProductCategoryRepository extends BaseRepository implements DefaultReposit
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->andWhere('e.parent = :idParentCategory');
@@ -62,6 +69,11 @@ class ProductCategoryRepository extends BaseRepository implements DefaultReposit
$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') ;

return $query->getQuery()->getResult();

+ 18
- 1
ShopBundle/Repository/ProductFamilyRepository.php Просмотреть файл

@@ -44,6 +44,7 @@ class ProductFamilyRepository extends BaseRepository implements DefaultRepositor
$query = $this->findByMerchantQuery() ;
$query = $this->joinRelations($query) ;
$query->andWhere('e.status = 1') ;
$query->orderBy('RAND()');
return $query->getQuery()->getResult() ;
}

@@ -75,7 +76,7 @@ class ProductFamilyRepository extends BaseRepository implements DefaultRepositor
$query->andWhere('e.status = 1');
$query->andWhere(':now <= e.propertyNoveltyExpirationDate')
->setParameter('now', new \DateTime()) ;
$query->orderBy('e.createdAt', 'DESC');
$query->orderBy('RAND()');

return $query->getQuery()->getResult() ;
}
@@ -122,7 +123,23 @@ class ProductFamilyRepository extends BaseRepository implements DefaultRepositor
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() ;
}


}

+ 50
- 0
ShopBundle/Repository/SectionRepository.php Просмотреть файл

@@ -0,0 +1,50 @@
<?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()
;
}
*/
}


+ 4
- 0
ShopBundle/Resources/public/js/backend/script/merchant/vuejs-merchant.js Просмотреть файл

@@ -38,6 +38,10 @@ appOrder = new Vue({
{
name: 'maintenance',
nameDisplay: 'Maintenance'
},
{
name: 'lunch',
nameDisplay: 'Repas du midi'
}
]
}, window.addressValues, window.merchantPanelOrderValues);

+ 9
- 0
ShopBundle/Resources/public/js/backend/script/productfamily/vuejs-product-family.js Просмотреть файл

@@ -426,6 +426,7 @@ $(window).on('load', function () {
activeProducts: false,
giftVoucherActive: false,
productsQuantityAsTitle: false,
section: null,
formProducts: {},
currentSection: 'general',
sectionsArray: [
@@ -487,6 +488,7 @@ $(window).on('load', function () {
}

}
this.sectionHasChanged();
this.initLcSortableProductsList();
});

@@ -583,12 +585,19 @@ $(window).on('load', function () {
if (typeof this.$refs.productUnitPrice !== 'undefined') {
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: {
title: function () {
this.updateChild()
},
section: function (){
this.sectionHasChanged()
},
propertyNoveltyExpirationDateActive: function () {
if(!this.propertyNoveltyExpirationDateActive){
this.propertyNoveltyExpirationDate = null;

+ 16
- 1
ShopBundle/Resources/translations/lcshop.fr.yaml Просмотреть файл

@@ -31,6 +31,7 @@ group:
Statistic:
title: Statistiques
ProductFamily:
status: Espaces et statuts
addresses: Livraisons & facturation
main: Général
products: Déclinaisons
@@ -85,6 +86,7 @@ group:
email: Email
delivery: Livraison
maintenance: Maintenance
lunch: Repas du midi
Address:
listLoopBesancon: Adresses de Besançon à spécifier (lat / long)

@@ -160,6 +162,7 @@ error:
editStockNoQuantityDefault: "Le stock n'a pas été modifié pour le produit #%id% (Aucune quantité par défaut)"
field:
default:
section: Espace
unit: Unité
placeholder: Choisissez une option
deliveryPointSale: Lieu de livraison
@@ -289,6 +292,11 @@ field:
purchaseOrderEmailContent: "Contenu par défaut de l'email envoyé aux producteurs"
dateStart: Date de début
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:
code: Code
@@ -301,6 +309,7 @@ field:
displayTotalWeightInPurchaseOrder: Afficher le poids total dans les bons de commande

ProductFamily:
sections: Espace où le produit est vendu
taxRateInherited: Utiliser la TVA par défaut
activeProducts: Activer les déclinaisons
productsType: Type de déclinaisons
@@ -417,6 +426,10 @@ field:
quantityOrder: Quantité commandé
quantityProduct: Quantité (en rapport à l'unité)
unit: Unité
OrderShopLunch:
deliveryTypeOptions:
point-sale: En ambassade
home: À domicile
OrderShop:
hasReach: Étape atteinte
deliveryTrucks: Véhicules de livraison
@@ -491,7 +504,8 @@ field:
days: Par jour
week: Par semaine
month: Par mois

User:
isSaleAlwaysOpen: Commandes toujours ouvertes
action:
apply: Appliquer
new: Créer %entity_label%
@@ -524,6 +538,7 @@ action:
logout: Me déconnecter
address: Adresse utilisateur
switch: Prendre la main

order:
addOrderProduct: Ajouter un produit
addReductionCart: Ajouter une réduction

+ 3
- 1
ShopBundle/Resources/views/backend/merchant/form.html.twig Просмотреть файл

@@ -45,7 +45,9 @@
<div v-show="currentSection == 'maintenance'" class="panel panel-default">
{% include '@LcShop/backend/merchant/panel_maintenance.html.twig' %}
</div>

<div v-show="currentSection == 'lunch'" class="panel panel-default">
{% include '@LcShop/backend/merchant/panel_lunch.html.twig' %}
</div>
</div>

</div>

+ 18
- 0
ShopBundle/Resources/views/backend/merchant/panel_lunch.html.twig Просмотреть файл

@@ -0,0 +1,18 @@
{% 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>

+ 1
- 1
ShopBundle/Resources/views/backend/productfamily/form.html.twig Просмотреть файл

@@ -3,7 +3,6 @@
{% import '@LcShop/backend/productfamily/macros.html.twig' as product_family_macros %}

{% set formValues = form.vars.value %}

<div id="lc-product-family-edit">
<div class="card card-light">
<div class="lc-vue-js-container card-header p-0 border-bottom-0">
@@ -50,6 +49,7 @@
{% if formValues.activeProducts %}activeProducts: "{{ formValues.activeProducts }}",{% endif %}
{% if formValues.giftVoucherActive %}giftVoucherActive: "{{ formValues.giftVoucherActive }}",{% 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 }}"

+ 23
- 4
ShopBundle/Resources/views/backend/productfamily/panel_general.html.twig Просмотреть файл

@@ -3,13 +3,32 @@
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %}

<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) }}
</div>
<div class="col-12">
<div class="col-6">
<label>Status de vente</label>
{{ form_row(form.saleStatus) }}
</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">
{{ form_row(form.supplier) }}
</div>
@@ -41,7 +60,7 @@
<div class="col-12 product-categories">
{% for category in form.productCategories %}

<div class="field {{ category.vars.disabled ? 'parent' }}">
<div class="field {{ category.vars.disabled ? 'parent' }}">
{{ form_row(category) }}
</div>


+ 16
- 6
ShopBundle/Services/Order/OrderUtils.php Просмотреть файл

@@ -13,12 +13,15 @@ use Lc\ShopBundle\Context\OrderStatusHistoryInterface;
use Lc\ShopBundle\Context\PriceUtilsInterface;
use Lc\ShopBundle\Context\ProductFamilyUtilsInterface;
use Lc\ShopBundle\Context\ReductionCreditInterface;
use Lc\ShopBundle\Context\SectionInterface;
use Lc\ShopBundle\Context\SectionUtilsInterface;
use Lc\ShopBundle\Context\UserUtilsInterface;
use Lc\ShopBundle\Model\ProductFamily;
use Lc\ShopBundle\Services\CreditUtils;
use Lc\ShopBundle\Services\DocumentUtils;
use Lc\ShopBundle\Services\UserUtils;
use Lc\ShopBundle\Services\Utils;
use Lc\ShopBundle\Services\UtilsManager;
use Symfony\Component\Routing\RouterInterface;

use Symfony\Component\Security\Core\Security;
@@ -45,10 +48,11 @@ class OrderUtils
protected $utils;
protected $creditUtils;
protected $router;
protected $sectionUtils ;

public function __construct(EntityManagerInterface $em, Security $security, RouterInterface $router, UserUtilsInterface $userUtils,
MerchantUtilsInterface $merchantUtils, PriceUtilsInterface $priceUtils, ProductFamilyUtilsInterface $productFamilyUtils,
DocumentUtils $documentUtils, Utils $utils, CreditUtils $creditUtils)
DocumentUtils $documentUtils, Utils $utils, CreditUtils $creditUtils, SectionUtilsInterface $sectionUtils)
{
$this->em = $em;
$this->security = $security;
@@ -64,10 +68,9 @@ class OrderUtils
$this->utils = $utils;
$this->creditUtils = $creditUtils;
$this->router = $router;
$this->sectionUtils = $sectionUtils ;
}



public function createOrderShop($params)
{
//TODO vérifier que l'utilisateur n'a pas déjà une commande en cours
@@ -93,6 +96,15 @@ class OrderUtils
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);

return $orderShop;
@@ -100,10 +112,8 @@ class OrderUtils

public function addOrderProduct($orderShop, $orderProductAdd, $persist = true)
{

$return = false;


if (!$orderShop) {
$user = $this->security->getUser();
$visitor = $this->userUtils->getVisitorCurrent();
@@ -111,7 +121,7 @@ class OrderUtils
$orderShop = $this->createOrderShop([
'user' => $user,
'visitor' => $visitor,
'merchant' => $this->merchantUtils->getMerchantCurrent()
'merchant' => $this->merchantUtils->getMerchantCurrent(),
]);
}


+ 3
- 2
ShopBundle/Services/Order/OrderUtilsCartTrait.php Просмотреть файл

@@ -2,7 +2,6 @@

namespace Lc\ShopBundle\Services\Order;


use Lc\ShopBundle\Context\OrderShopInterface;
use Lc\ShopBundle\Model\OrderStatus;

@@ -64,10 +63,12 @@ trait OrderUtilsCartTrait
}

if($createIfNotExist && !$orderShop) {
$merchant = $this->merchantUtils->getMerchantCurrent() ;

$orderShop = $this->createOrderShop([
'user' => $user,
'visitor' => $visitor,
'merchant' => $this->merchantUtils->getMerchantCurrent()
'merchant' => $merchant,
]);
}


+ 19
- 2
ShopBundle/Services/Order/OrderUtilsStockTrait.php Просмотреть файл

@@ -65,16 +65,33 @@ trait OrderUtilsStockTrait
}

$allCategoriesSalesOff = true;
$unavailableSpecificDay = false;

foreach ($product->getProductFamily()->getProductCategories() as $category){
if($category->getParent()) {
if($category->getSaleStatus() && $category->getParent()->getSaleStatus())
$allCategoriesSalesOff = false;
}
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 ;
}

+ 37
- 0
ShopBundle/Services/SectionUtils.php Просмотреть файл

@@ -0,0 +1,37 @@
<?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 ;
}
}

+ 10
- 1
ShopBundle/Services/UtilsManager.php Просмотреть файл

@@ -8,6 +8,7 @@ use Lc\ShopBundle\Context\MerchantUtilsInterface;
use Lc\ShopBundle\Context\OrderUtilsInterface;
use Lc\ShopBundle\Context\PriceUtilsInterface;
use Lc\ShopBundle\Context\ProductFamilyUtilsInterface;
use Lc\ShopBundle\Context\SectionUtilsInterface;
use Lc\ShopBundle\Context\Services\StatisticsUtilsInterface;
use Lc\ShopBundle\Context\UserUtilsInterface;
use League\Flysystem\Util;
@@ -27,6 +28,7 @@ class UtilsManager
protected $ticketUtils ;
protected $statisticsUtils;
protected $pointLocationUtils ;
protected $sectionUtils ;

public function __construct(
Utils $utils,
@@ -41,7 +43,8 @@ class UtilsManager
MailUtils $mailUtils,
TicketUtils $ticketUtils,
PointLocationUtils $pointLocationUtils,
UtilsProcess $utilsProcess
UtilsProcess $utilsProcess,
SectionUtilsInterface $sectionUtils
)
{
$this->utils = $utils ;
@@ -57,6 +60,7 @@ class UtilsManager
$this->ticketUtils = $ticketUtils ;
$this->pointLocationUtils = $pointLocationUtils ;
$this->utilsProcess = $utilsProcess ;
$this->sectionUtils = $sectionUtils ;
}

public function getUtils(): Utils
@@ -124,4 +128,9 @@ class UtilsManager
return $this->utilsProcess ;
}

public function getSectionUtils(): SectionUtilsInterface
{
return $this->sectionUtils ;
}

}

Загрузка…
Отмена
Сохранить