Browse Source

Gestion des stocks avancé

packProduct
Fabien Normand 3 years ago
parent
commit
7028bd6bf7
25 changed files with 225 additions and 192 deletions
  1. +0
    -1
      Builder/Product/ProductFamilyBuilder.php
  2. +47
    -0
      Builder/Product/ProductFamilySectionPropertyBuilder.php
  3. +13
    -6
      Container/Product/ProductFamilySectionPropertyContainer.php
  4. +5
    -1
      Controller/Order/OrderStatusAdminController.php
  5. +7
    -6
      Controller/Product/ProductCategoryAdminController.php
  6. +9
    -4
      Controller/Product/ProductFamilyAdminController.php
  7. +7
    -12
      Controller/Reduction/ReductionCartAdminController.php
  8. +7
    -15
      Controller/Reduction/ReductionCatalogAdminController.php
  9. +6
    -12
      Controller/Reduction/ReductionCreditAdminController.php
  10. +2
    -3
      Controller/Section/OpeningAdminController.php
  11. +8
    -16
      Controller/Section/SectionAdminController.php
  12. +4
    -6
      Controller/Site/NewsAdminController.php
  13. +3
    -7
      Controller/Site/PageAdminController.php
  14. +4
    -10
      Controller/Ticket/TicketAdminController.php
  15. +4
    -7
      Controller/User/GroupUserAdminController.php
  16. +57
    -59
      Controller/User/UserMerchantAdminController.php
  17. +3
    -4
      EventSubscriber/MerchantSectionPropertyEventSubscriber.php
  18. +7
    -4
      Factory/Product/ProductFamilyFactory.php
  19. +2
    -2
      Factory/Ticket/TicketFactory.php
  20. +9
    -3
      Factory/User/UserMerchantFactory.php
  21. +2
    -2
      Form/Section/SwitchSectionFormType.php
  22. +5
    -1
      Repository/Product/ProductFamilySectionPropertyRepositoryQuery.php
  23. +11
    -2
      Repository/Product/ProductFamilySectionPropertyStore.php
  24. +2
    -8
      Repository/Reduction/ReductionCatalogStore.php
  25. +1
    -1
      Resources/views/adminlte/layout.html.twig

+ 0
- 1
Builder/Product/ProductFamilyBuilder.php View File



namespace Lc\CaracoleBundle\Builder\Product; namespace Lc\CaracoleBundle\Builder\Product;



class ProductFamilyBuilder class ProductFamilyBuilder
{ {



+ 47
- 0
Builder/Product/ProductFamilySectionPropertyBuilder.php View File

<?php

namespace Lc\CaracoleBundle\Builder\Product;

use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Factory\Product\ProductFamilySectionPropertyFactory;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Repository\Product\ProductFamilySectionPropertyStore;

class ProductFamilySectionPropertyBuilder
{
protected EntityManagerInterface $entityManager;
protected ProductFamilySectionPropertyFactory $productFamilySectionPropertyFactory;
protected ProductFamilySectionPropertyStore $productFamilySectionPropertyStore;

public function __construct(
EntityManagerInterface $entityManager,
ProductFamilySectionPropertyFactory $productFamilySectionPropertyFactory,
ProductFamilySectionPropertyStore $productFamilySectionPropertyStore
) {
$this->entityManager = $entityManager;
$this->productFamilySectionPropertyFactory = $productFamilySectionPropertyFactory;
$this->productFamilySectionPropertyStore = $productFamilySectionPropertyStore;
}

public function enable(ProductFamilyInterface $productFamily, SectionInterface $section): void
{
$productFamilySectionProperty = $this->productFamilySectionPropertyStore
->setSection($section)
->getOneByProductFamily($productFamily);

if ($productFamilySectionProperty) {
if (!$productFamilySectionProperty->getStatus()) {
$productFamilySectionProperty->setStatus(1);
$this->entityManager->update($productFamilySectionProperty);
}
} else {
$productFamilySectionProperty = $this->productFamilySectionPropertyFactory->create($section, $productFamily);
$productFamilySectionProperty->setStatus(1);
$this->entityManager->create($productFamilySectionProperty);
}

$this->entityManager->flush();
}

}

+ 13
- 6
Container/Product/ProductFamilySectionPropertyContainer.php View File



use App\Definition\Field\Product\ProductFamilyFieldDefinition; use App\Definition\Field\Product\ProductFamilyFieldDefinition;
use Lc\CaracoleBundle\Builder\Product\ProductFamilyBuilder; use Lc\CaracoleBundle\Builder\Product\ProductFamilyBuilder;
use Lc\CaracoleBundle\Builder\Product\ProductFamilySectionPropertyBuilder;
use Lc\CaracoleBundle\Factory\Product\ProductFamilyFactory; use Lc\CaracoleBundle\Factory\Product\ProductFamilyFactory;
use Lc\CaracoleBundle\Factory\Product\ProductFamilySectionPropertyFactory; use Lc\CaracoleBundle\Factory\Product\ProductFamilySectionPropertyFactory;
use Lc\CaracoleBundle\Repository\Product\ProductFamilyRepositoryQuery; use Lc\CaracoleBundle\Repository\Product\ProductFamilyRepositoryQuery;
protected ProductFamilySectionPropertySolver $solver; protected ProductFamilySectionPropertySolver $solver;
protected ProductFamilySectionPropertyRepositoryQuery $repositoryQuery; protected ProductFamilySectionPropertyRepositoryQuery $repositoryQuery;
protected ProductFamilySectionPropertyStore $store; protected ProductFamilySectionPropertyStore $store;
protected ProductFamilySectionPropertyBuilder $builder;


public function __construct( public function __construct(
ProductFamilySectionPropertyFactory $factory,
ProductFamilySectionPropertySolver $solver,
ProductFamilySectionPropertyRepositoryQuery $repositoryQuery,
ProductFamilySectionPropertyStore $store
)
{
ProductFamilySectionPropertyFactory $factory,
ProductFamilySectionPropertySolver $solver,
ProductFamilySectionPropertyRepositoryQuery $repositoryQuery,
ProductFamilySectionPropertyStore $store,
ProductFamilySectionPropertyBuilder $builder
) {
$this->factory = $factory; $this->factory = $factory;
$this->solver = $solver; $this->solver = $solver;
$this->repositoryQuery = $repositoryQuery; $this->repositoryQuery = $repositoryQuery;
$this->store = $store; $this->store = $store;
$this->builder = $builder;
} }


public function getFactory(): ProductFamilySectionPropertyFactory public function getFactory(): ProductFamilySectionPropertyFactory
return $this->store; return $this->store;
} }


public function getBuilder(): ProductFamilySectionPropertyBuilder
{
return $this->builder;
}
} }

+ 5
- 1
Controller/Order/OrderStatusAdminController.php View File



namespace Lc\CaracoleBundle\Controller\Order; namespace Lc\CaracoleBundle\Controller\Order;



use Lc\CaracoleBundle\Container\Order\OrderStatusContainer; use Lc\CaracoleBundle\Container\Order\OrderStatusContainer;
use Lc\CaracoleBundle\Controller\AbstractAdminController; use Lc\CaracoleBundle\Controller\AbstractAdminController;
use Lc\CaracoleBundle\Controller\AdminControllerTrait; use Lc\CaracoleBundle\Controller\AdminControllerTrait;
{ {
return $this->get(OrderStatusContainer::class)->getRepositoryQuery(); return $this->get(OrderStatusContainer::class)->getRepositoryQuery();
} }

public function createEntity(string $entityFqcn)
{
return $this->getOrderStatusContainer()->getFactory()->create();
}
} }

+ 7
- 6
Controller/Product/ProductCategoryAdminController.php View File

use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
use Lc\CaracoleBundle\Container\Product\ProductCategoryContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\CaracoleBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Field\CKEditorField; use Lc\SovBundle\Field\CKEditorField;
use Lc\SovBundle\Field\StatusField; use Lc\SovBundle\Field\StatusField;
use Lc\SovBundle\Field\ToggleField; use Lc\SovBundle\Field\ToggleField;


abstract class ProductCategoryAdminController extends AbstractAdminController abstract class ProductCategoryAdminController extends AbstractAdminController
{ {
use AdminControllerTrait;

public function getRepositoryQuery() :RepositoryQueryInterface public function getRepositoryQuery() :RepositoryQueryInterface
{ {
return $this->get(ProductCategoryContainer::class)->getRepositoryQuery();
return $this->getProductCategoryContainer()->getRepositoryQuery();
}

public function createEntity(string $entityFqcn)
{
return $this->getProductCategoryContainer()->getFactory()->create($this->getSectionCurrent());
} }


public function configureFields(string $pageName): iterable public function configureFields(string $pageName): iterable

+ 9
- 4
Controller/Product/ProductFamilyAdminController.php View File

use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
use Lc\CaracoleBundle\Container\Order\OrderShopContainer; use Lc\CaracoleBundle\Container\Order\OrderShopContainer;
use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer; use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Controller\AbstractAdminController;
use Lc\CaracoleBundle\Resolver\SectionResolver; use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Repository\RepositoryQueryInterface; use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;


abstract class ProductFamilyAdminController extends AbstractAdminController abstract class ProductFamilyAdminController extends AbstractAdminController
{ {
use AdminControllerTrait;



public function getRepositoryQuery() :RepositoryQueryInterface public function getRepositoryQuery() :RepositoryQueryInterface
{ {
return $this->get(ProductFamilyContainer::class)->getRepositoryQuery(); return $this->get(ProductFamilyContainer::class)->getRepositoryQuery();
} }


public function createEntity(string $entityFqcn)
{
return $this->getProductFamilyContainer()
->getFactory()
->create($this->getMerchantCurrent());
}


public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore
{ {
$responseParameters = parent::configureResponseParameters($responseParameters); $responseParameters = parent::configureResponseParameters($responseParameters);

+ 7
- 12
Controller/Reduction/ReductionCartAdminController.php View File



namespace Lc\CaracoleBundle\Controller\Reduction; namespace Lc\CaracoleBundle\Controller\Reduction;



use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Container\Reduction\ReductionCartContainer; use Lc\CaracoleBundle\Container\Reduction\ReductionCartContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Model\Config\TaxRateModel;
use Lc\CaracoleBundle\Model\Config\UnitModel;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Repository\RepositoryQueryInterface; use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Lc\CaracoleBundle\Controller\AbstractAdminController;


abstract class ReductionCartAdminController extends AbstractAdminController abstract class ReductionCartAdminController extends AbstractAdminController
{ {
use AdminControllerTrait;



public function getRepositoryQuery() :RepositoryQueryInterface public function getRepositoryQuery() :RepositoryQueryInterface
{ {
return $this->get(ReductionCartContainer::class)->getRepositoryQuery();
return $this->getReductionCartContainer()->getRepositoryQuery();
}

public function createEntity(string $entityFqcn)
{
return $this->getReductionCartContainer()->getFactory()->create($this->getSectionCurrent());
} }


} }

+ 7
- 15
Controller/Reduction/ReductionCatalogAdminController.php View File



namespace Lc\CaracoleBundle\Controller\Reduction; namespace Lc\CaracoleBundle\Controller\Reduction;



use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Container\Reduction\ReductionCatalogContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Model\Config\TaxRateModel;
use Lc\CaracoleBundle\Model\Config\UnitModel;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\CaracoleBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Repository\RepositoryQueryInterface; use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Lc\SovBundle\Translation\TranslatorAdmin;


abstract class ReductionCatalogAdminController extends AbstractAdminController abstract class ReductionCatalogAdminController extends AbstractAdminController
{ {
use AdminControllerTrait;


public function getRepositoryQuery() :RepositoryQueryInterface
public function getRepositoryQuery(): RepositoryQueryInterface
{ {
return $this->get(ReductionCatalogContainer::class)->getRepositoryQuery();
return $this->getReductionCatalogContainer()->getRepositoryQuery();
} }


public function createEntity(string $entityFqcn)
{
return $this->getReductionCatalogContainer()->getFactory()->create($this->getSectionCurrent());
}
} }

+ 6
- 12
Controller/Reduction/ReductionCreditAdminController.php View File



namespace Lc\CaracoleBundle\Controller\Reduction; namespace Lc\CaracoleBundle\Controller\Reduction;



use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Container\Reduction\ReductionCreditContainer; use Lc\CaracoleBundle\Container\Reduction\ReductionCreditContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Model\Config\TaxRateModel;
use Lc\CaracoleBundle\Model\Config\UnitModel;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\CaracoleBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Repository\RepositoryQueryInterface; use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Lc\SovBundle\Translation\TranslatorAdmin;


abstract class ReductionCreditAdminController extends AbstractAdminController abstract class ReductionCreditAdminController extends AbstractAdminController
{ {
use AdminControllerTrait;


public function getRepositoryQuery() :RepositoryQueryInterface public function getRepositoryQuery() :RepositoryQueryInterface
{ {
return $this->get(ReductionCreditContainer::class)->getRepositoryQuery(); return $this->get(ReductionCreditContainer::class)->getRepositoryQuery();
} }

public function createEntity(string $entityFqcn)
{
return $this->getReductionCreditContainer()->getFactory()->create($this->getSectionCurrent());
}
} }

+ 2
- 3
Controller/Section/OpeningAdminController.php View File



public function createEntity(string $entityFqcn) public function createEntity(string $entityFqcn)
{ {
return $this->get(OpeningContainer::class)
return $this->getOpeningContainer()
->getFactory() ->getFactory()
->create($this->get(SectionResolver::class)->getCurrent());
->create($this->getSectionCurrent());
} }

} }

+ 8
- 16
Controller/Section/SectionAdminController.php View File

use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Container\Section\SectionContainer; use Lc\CaracoleBundle\Container\Section\SectionContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Factory\Section\SectionFactory;
use Lc\CaracoleBundle\Form\Section\OpeningsFormType;
use Lc\CaracoleBundle\Controller\AbstractAdminController;
use Lc\CaracoleBundle\Model\Section\SectionModel; use Lc\CaracoleBundle\Model\Section\SectionModel;
use Lc\CaracoleBundle\Resolver\MerchantResolver; use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Field\BooleanField; use Lc\SovBundle\Field\BooleanField;
use Lc\SovBundle\Field\CKEditorField; use Lc\SovBundle\Field\CKEditorField;
use Lc\SovBundle\Field\StatusField; use Lc\SovBundle\Field\StatusField;
use Lc\SovBundle\Repository\RepositoryQueryInterface; use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\SessionFactory;
use Symfony\Component\Routing\Annotation\Route;


abstract class SectionAdminController extends AbstractAdminController abstract class SectionAdminController extends AbstractAdminController
{ {
use AdminControllerTrait;



public function getRepositoryQuery() :RepositoryQueryInterface public function getRepositoryQuery() :RepositoryQueryInterface
{ {
return $this->get(SectionContainer::class)->getRepositoryQuery(); return $this->get(SectionContainer::class)->getRepositoryQuery();
} }


public function createEntity(string $entityFqcn)
{
return $this->getSectionContainer()
->getFactory()
->create($this->getMerchantCurrent());
}

public function configureFields(string $pageName): iterable public function configureFields(string $pageName): iterable
{ {
return array_merge( return array_merge(
); );
} }


public function createEntity(string $entityFqcn)
{
return $this->get(SectionContainer::class)
->getFactory()
->create($this->get(MerchantResolver::class)->getCurrent());
}

} }

+ 4
- 6
Controller/Site/NewsAdminController.php View File



namespace Lc\CaracoleBundle\Controller\Site; namespace Lc\CaracoleBundle\Controller\Site;


use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\SovBundle\Container\Site\NewsContainer;
use Lc\CaracoleBundle\Controller\ControllerTrait;
use Lc\SovBundle\Controller\Site\NewsAdminController as SovNewsAdminController; use Lc\SovBundle\Controller\Site\NewsAdminController as SovNewsAdminController;


abstract class NewsAdminController extends SovNewsAdminController abstract class NewsAdminController extends SovNewsAdminController
{ {
use AdminControllerTrait;
use ControllerTrait;


public function createEntity(string $entityFqcn) public function createEntity(string $entityFqcn)
{ {
return $this->get(NewsContainer::class)
return $this->getNewsContainer()
->getFactory() ->getFactory()
->setSection($this->get(SectionResolver::class)->getCurrent())
->setSection($this->getSectionCurrent())
->create(); ->create();
} }
} }

+ 3
- 7
Controller/Site/PageAdminController.php View File



namespace Lc\CaracoleBundle\Controller\Site; namespace Lc\CaracoleBundle\Controller\Site;


use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Factory\Site\PageFactory;
use Lc\CaracoleBundle\Controller\ControllerTrait;
use Lc\CaracoleBundle\Resolver\SectionResolver; use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\SovBundle\Container\Site\PageContainer;
use Lc\SovBundle\Controller\Site\PageAdminController as SovPageAdminController; use Lc\SovBundle\Controller\Site\PageAdminController as SovPageAdminController;
use Lc\SovBundle\Repository\RepositoryQueryInterface;


abstract class PageAdminController extends SovPageAdminController abstract class PageAdminController extends SovPageAdminController
{ {
use AdminControllerTrait;

use ControllerTrait;


public function createEntity(string $entityFqcn) public function createEntity(string $entityFqcn)
{ {
return $this->getPageContainer() return $this->getPageContainer()
->getFactory() ->getFactory()
->setSection($this->get(SectionResolver::class)->getCurrent())
->setSection($this->getSectionCurrent())
->create(); ->create();
} }
} }

+ 4
- 10
Controller/Ticket/TicketAdminController.php View File



namespace Lc\CaracoleBundle\Controller\Ticket; namespace Lc\CaracoleBundle\Controller\Ticket;


use App\Entity\Ticket\Ticket;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\SovBundle\Container\Ticket\TicketContainer;
use Lc\CaracoleBundle\Controller\ControllerTrait;
use Lc\SovBundle\Controller\Ticket\TicketAdminController as SovTicketAdminController; use Lc\SovBundle\Controller\Ticket\TicketAdminController as SovTicketAdminController;
use Lc\CaracoleBundle\Factory\Ticket\TicketFactory;
use Lc\SovBundle\Repository\RepositoryQueryInterface;


abstract class TicketAdminController extends SovTicketAdminController abstract class TicketAdminController extends SovTicketAdminController
{ {
use AdminControllerTrait;
use ControllerTrait;


public function createEntity(string $entityFqcn) public function createEntity(string $entityFqcn)
{ {
return $this->get(TicketContainer::class)
return $this->getTicketContainer()
->getFactory() ->getFactory()
->setMerchant($this->get(MerchantResolver::class)->getCurrent())
->setSection($this->getSectionCurrent())
->create(); ->create();
} }

} }

+ 4
- 7
Controller/User/GroupUserAdminController.php View File



namespace Lc\CaracoleBundle\Controller\User; namespace Lc\CaracoleBundle\Controller\User;


use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Factory\User\GroupUserFactory;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\SovBundle\Container\User\GroupUserContainer;
use Lc\CaracoleBundle\Controller\ControllerTrait;
use Lc\SovBundle\Controller\User\GroupUserAdminController as SovGroupUserAdminController; use Lc\SovBundle\Controller\User\GroupUserAdminController as SovGroupUserAdminController;


abstract class GroupUserAdminController extends SovGroupUserAdminController abstract class GroupUserAdminController extends SovGroupUserAdminController
{ {
use AdminControllerTrait;
use ControllerTrait;


public function createEntity(string $entityFqcn) public function createEntity(string $entityFqcn)
{ {
return $this->get(GroupUserContainer::class)
return $this->getGroupUserContainer()
->getFactory() ->getFactory()
->setMerchant($this->get(MerchantResolver::class)->getCurrent())
->setMerchant($this->getMerchantCurrent())
->create(); ->create();
} }
} }

+ 57
- 59
Controller/User/UserMerchantAdminController.php View File



use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use EasyCorp\Bundle\EasyAdminBundle\Collection\EntityCollection; use EasyCorp\Bundle\EasyAdminBundle\Collection\EntityCollection;
use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection;
use EasyCorp\Bundle\EasyAdminBundle\Config\Action; use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Config\Filters; use EasyCorp\Bundle\EasyAdminBundle\Config\Filters;
use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore;
use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
use EasyCorp\Bundle\EasyAdminBundle\Event\AfterCrudActionEvent;
use EasyCorp\Bundle\EasyAdminBundle\Event\BeforeCrudActionEvent; use EasyCorp\Bundle\EasyAdminBundle\Event\BeforeCrudActionEvent;
use EasyCorp\Bundle\EasyAdminBundle\Exception\ForbiddenActionException; use EasyCorp\Bundle\EasyAdminBundle\Exception\ForbiddenActionException;
use EasyCorp\Bundle\EasyAdminBundle\Exception\InsufficientEntityPermissionException; use EasyCorp\Bundle\EasyAdminBundle\Exception\InsufficientEntityPermissionException;
use EasyCorp\Bundle\EasyAdminBundle\Factory\EntityFactory;
use EasyCorp\Bundle\EasyAdminBundle\Field\ArrayField; use EasyCorp\Bundle\EasyAdminBundle\Field\ArrayField;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
use EasyCorp\Bundle\EasyAdminBundle\Security\Permission; use EasyCorp\Bundle\EasyAdminBundle\Security\Permission;
use Lc\CaracoleBundle\Container\User\UserMerchantContainer; use Lc\CaracoleBundle\Container\User\UserMerchantContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Controller\ControllerTrait;
use Lc\CaracoleBundle\Definition\ActionDefinition; use Lc\CaracoleBundle\Definition\ActionDefinition;
use Lc\CaracoleBundle\Factory\User\UserFactory; use Lc\CaracoleBundle\Factory\User\UserFactory;
use Lc\CaracoleBundle\Factory\User\UserMerchantFactory;
use Lc\CaracoleBundle\Form\Credit\CreditHistoryFormType; use Lc\CaracoleBundle\Form\Credit\CreditHistoryFormType;
use Lc\CaracoleBundle\Form\User\UserMerchantFormType; use Lc\CaracoleBundle\Form\User\UserMerchantFormType;
use Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface; use Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface;
use Lc\SovBundle\Container\User\UserContainer; use Lc\SovBundle\Container\User\UserContainer;
use Lc\SovBundle\Controller\AbstractAdminController; use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Field\BooleanField; use Lc\SovBundle\Field\BooleanField;
use Lc\SovBundle\Field\ToggleField;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Repository\RepositoryQueryInterface; use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Lc\SovBundle\Translation\TranslatorAdmin; use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;


abstract class UserMerchantAdminController extends AbstractAdminController abstract class UserMerchantAdminController extends AbstractAdminController
{ {
use AdminControllerTrait;
use ControllerTrait;


public function getRepositoryQuery(): RepositoryQueryInterface
{
return $this->getUserMerchantContainer()->getRepositoryQuery();
}


public function getRepositoryQuery() :RepositoryQueryInterface
public function createEntity(string $entityFqcn)
{ {
return $this->get(UserMerchantContainer::class)->getRepositoryQuery();
return $this->getUserMerchantContainer()->getFactory()->createBase($this->getMerchantCurrent());
} }

public function overrideEntitiesActions(?EntityCollection $entities): void public function overrideEntitiesActions(?EntityCollection $entities): void
{ {
$context = $this->get(AdminContextProvider::class)->getContext(); $context = $this->get(AdminContextProvider::class)->getContext();
$adminUrlGenerator = $this->get(AdminUrlGenerator::class); $adminUrlGenerator = $this->get(AdminUrlGenerator::class);


$creditControllerFqcn = $context->getCrudControllers()->findCrudFqcnByEntityFqcn( $creditControllerFqcn = $context->getCrudControllers()->findCrudFqcnByEntityFqcn(
$this->get(EntityManagerInterface::class)->getEntityName(CreditHistoryInterface::class)
$this->get(EntityManagerInterface::class)->getEntityName(CreditHistoryInterface::class)
); );


if ($entities) { if ($entities) {
foreach ($entity->getActions() as $action) { foreach ($entity->getActions() as $action) {
if ($action->getName() == 'credit_history') { if ($action->getName() == 'credit_history') {
$url = $adminUrlGenerator $url = $adminUrlGenerator
->setController($creditControllerFqcn)
->set('userMerchantId', $entity->getInstance()->getId())
->generateUrl();
->setController($creditControllerFqcn)
->set('userMerchantId', $entity->getInstance()->getId())
->generateUrl();
$action->setLinkUrl($url); $action->setLinkUrl($url);
} }
} }
$actions = parent::configureActions($actions); $actions = parent::configureActions($actions);


$creditAction = Action::new('credit_history', false, 'fa fa-cash-register') $creditAction = Action::new('credit_history', false, 'fa fa-cash-register')
->linkToCrudAction('credit_history')
->setHtmlAttributes(
array(
'data-toggle' => 'tooltip',
'title' => $this->get(TranslatorAdmin::class)->transAction('credit'),
->linkToCrudAction('credit_history')
->setHtmlAttributes(
array(
'data-toggle' => 'tooltip',
'title' => $this->get(TranslatorAdmin::class)->transAction('credit'),
)
) )
)
->setCssClass('btn btn-sm btn-success');
->setCssClass('btn btn-sm btn-success');
$actions->add(Crud::PAGE_INDEX, $creditAction); $actions->add(Crud::PAGE_INDEX, $creditAction);


return $actions; return $actions;
public function configureFields(string $pageName): iterable public function configureFields(string $pageName): iterable
{ {
$fields = [ $fields = [
IntegerField::new('id')->onlyOnIndex()->setSortable(true),
TextField::new('user.lastname')->setSortable(true),
TextField::new('user.firstname')->setSortable(true),
TextField::new('user.email')->setSortable(true),
BooleanField::new('active')->setSortable(true),
BooleanField::new('creditActive')->hideOnIndex(),
AssociationField::new('user'),
IntegerField::new('id')->onlyOnIndex()->setSortable(true),
TextField::new('user.lastname')->setSortable(true),
TextField::new('user.firstname')->setSortable(true),
TextField::new('user.email')->setSortable(true),
BooleanField::new('active')->setSortable(true),
BooleanField::new('creditActive')->hideOnIndex(),
AssociationField::new('user'),
]; ];


if ($this->isGranted('ROLE_SUPER_ADMIN')) { if ($this->isGranted('ROLE_SUPER_ADMIN')) {
public function configureFilters(Filters $filters): Filters public function configureFilters(Filters $filters): Filters
{ {
return $filters return $filters
->add(BooleanFilter::new('active'));
->add(BooleanFilter::new('active'));
} }


public function new(AdminContext $context): Response public function new(AdminContext $context): Response
$merchantResolver = $this->get(MerchantResolver::class); $merchantResolver = $this->get(MerchantResolver::class);


$userMerchant = $this->get(UserMerchantContainer::class) $userMerchant = $this->get(UserMerchantContainer::class)
->getFactory()
->create($merchantResolver->getCurrent());
->getFactory()
->create($merchantResolver->getCurrent());


$form = $this->createForm(UserMerchantFormType::class, $userMerchant); $form = $this->createForm(UserMerchantFormType::class, $userMerchant);


$userMerchant->setUser($user); $userMerchant->setUser($user);
$entityManager->create($userMerchant); $entityManager->create($userMerchant);
$entityManager->flush(); $entityManager->flush();
$this->addFlashTranslator('success','created');
$this->addFlashTranslator('success', 'created');
$url = $this->get(AdminUrlGenerator::class)->setAction(ActionDefinition::INDEX)->generateUrl(); $url = $this->get(AdminUrlGenerator::class)->setAction(ActionDefinition::INDEX)->generateUrl();


return $this->redirect($url); return $this->redirect($url);


return $this->redirect($url); return $this->redirect($url);
} else { } else {
$this->addFlashTranslator('error','already_exist');
$this->addFlashTranslator('error', 'already_exist');
} }
} }
} }


return $this->render( return $this->render(
'@LcCaracole/admin/user/new_usermerchant.html.twig',
[
'form' => $form->createView(),
]
'@LcCaracole/admin/user/new_usermerchant.html.twig',
[
'form' => $form->createView(),
]
); );
} }


} }


return $this->render( return $this->render(
'@LcCaracole/admin/user/edit_usermerchant.html.twig',
[
'form' => $form->createView(),
]
'@LcCaracole/admin/user/edit_usermerchant.html.twig',
[
'form' => $form->createView(),
]
); );
} }


} }


if (!$this->isGranted( if (!$this->isGranted(
Permission::EA_EXECUTE_ACTION,
['action' => ActionDefinition::DETAIL, 'entity' => $context->getEntity()]
Permission::EA_EXECUTE_ACTION,
['action' => ActionDefinition::DETAIL, 'entity' => $context->getEntity()]
)) { )) {
throw new ForbiddenActionException($context); throw new ForbiddenActionException($context);
} }
} }


$options['action'] = $adminUrlGenerator $options['action'] = $adminUrlGenerator
->setController($context->getCrud()->getControllerFqcn())
->setAction('add_credit')
->setEntityId($context->getEntity()->getInstance()->getId())
->set('userMerchant', 'niche')
->generateUrl();
->setController($context->getCrud()->getControllerFqcn())
->setAction('add_credit')
->setEntityId($context->getEntity()->getInstance()->getId())
->set('userMerchant', 'niche')
->generateUrl();
$addCreditHistoryForm = $this->createForm(CreditHistoryFormType::class, null, $options)->createView(); $addCreditHistoryForm = $this->createForm(CreditHistoryFormType::class, null, $options)->createView();




return $this->render( return $this->render(
'@LcCaracole/admin/credit/credit_detail.html.twig',
[
'pageName' => Crud::PAGE_DETAIL,
'entity' => $context->getEntity(),
'batch_actions' => array(),
'entities' => array(),
'filters' => array(),
'paginator' => array(),
'add_credit_history_form' => $addCreditHistoryForm,
]
'@LcCaracole/admin/credit/credit_detail.html.twig',
[
'pageName' => Crud::PAGE_DETAIL,
'entity' => $context->getEntity(),
'batch_actions' => array(),
'entities' => array(),
'filters' => array(),
'paginator' => array(),
'add_credit_history_form' => $addCreditHistoryForm,
]
); );
} }



+ 3
- 4
EventSubscriber/MerchantSectionPropertyEventSubscriber.php View File



public function setMerchantAndSectionProperties(EntityManagerEvent $event) public function setMerchantAndSectionProperties(EntityManagerEvent $event)
{ {
$entity = $event->getEntity();
// @TODO : toujours d'actualité ?
/*$entity = $event->getEntity();
$entityRepository = $this->em->getRepository(get_class($entity)); $entityRepository = $this->em->getRepository(get_class($entity));


if ($entity instanceof FilterSectionInterface) { if ($entity instanceof FilterSectionInterface) {


if ($entity instanceof FilterMultipleMerchantsInterface) { if ($entity instanceof FilterMultipleMerchantsInterface) {
$this->setMultipleMerchantProperty($entity, $entityRepository); $this->setMultipleMerchantProperty($entity, $entityRepository);
}


}*/
} }


private function setSectionProperty($entity) private function setSectionProperty($entity)

+ 7
- 4
Factory/Product/ProductFamilyFactory.php View File



class ProductFamilyFactory extends AbstractFactory class ProductFamilyFactory extends AbstractFactory
{ {

public function create(SectionInterface $section): ProductFamilyInterface
public function create(MerchantInterface $merchant): ProductFamilyInterface
{ {
$productFamily = new ProductFamily(); $productFamily = new ProductFamily();


$productFamily->setSection($section);
$productFamilySectionPropertyFactory = new ProductFamilySectionPropertyFactory();

foreach($merchant->getSections() as $section) {
$productFamilySectionProperty = $productFamilySectionPropertyFactory->create($section, $productFamily);
$productFamily->addProductFamilySectionProperty($productFamilySectionProperty);
}


return $productFamily; return $productFamily;
} }

} }

+ 2
- 2
Factory/Ticket/TicketFactory.php View File



class TicketFactory extends SovTicketFactory class TicketFactory extends SovTicketFactory
{ {
use MerchantContextTrait;
use SectionContextTrait;


public function create(): TicketInterface public function create(): TicketInterface
{ {
$ticket = parent::create(); $ticket = parent::create();


$ticket->setMerchant($this->merchant);
$ticket->setSection($this->section);


return $ticket; return $ticket;
} }

+ 9
- 3
Factory/User/UserMerchantFactory.php View File



class UserMerchantFactory extends AbstractFactory class UserMerchantFactory extends AbstractFactory
{ {
// createUserMerchant
public function create(MerchantInterface $merchant, UserInterface $user = null): UserMerchantInterface
public function createBase(MerchantInterface $merchant): UserMerchantInterface
{ {
$userMerchant = new UserMerchant(); $userMerchant = new UserMerchant();

$userMerchant->setMerchant($merchant); $userMerchant->setMerchant($merchant);

return $userMerchant;
}

// createUserMerchant
public function create(MerchantInterface $merchant, UserInterface $user = null): UserMerchantInterface
{
$userMerchant = $this->createBase($merchant);
$userMerchant->setUser($user); $userMerchant->setUser($user);


return $userMerchant; return $userMerchant;

+ 2
- 2
Form/Section/SwitchSectionFormType.php View File

$styleButton = ''; $styleButton = '';
$classButton = 'btn-section'; $classButton = 'btn-section';
if ($section == $currentSection) { if ($section == $currentSection) {
$classButton .= ' btn-section-current';
$styleButton = 'color: white; background-color: ' . $currentSection->getColor() . ';';
$classButton .= ' btn-section-current section-'.$currentSection->getDevAlias();
//$styleButton = 'color: white; background-color: ' . $currentSection->getColor() . ';';
} }


$builder->add( $builder->add(

+ 5
- 1
Repository/Product/ProductFamilySectionPropertyRepositoryQuery.php View File

namespace Lc\CaracoleBundle\Repository\Product; namespace Lc\CaracoleBundle\Repository\Product;


use Knp\Component\Pager\PaginatorInterface; use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait; use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait;
use Lc\SovBundle\Repository\AbstractRepositoryQuery; use Lc\SovBundle\Repository\AbstractRepositoryQuery;


parent::__construct($repository, 'pfsp', $paginator); parent::__construct($repository, 'pfsp', $paginator);
} }



public function filterByProductFamily(ProductFamilyInterface $productFamily): self
{
return $this->andWhereEqual('productFamily', $productFamily);
}


} }

+ 11
- 2
Repository/Product/ProductFamilySectionPropertyStore.php View File



namespace Lc\CaracoleBundle\Repository\Product; namespace Lc\CaracoleBundle\Repository\Product;


use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Repository\SectionStoreTrait; use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\SovBundle\Repository\AbstractRepository;
use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface; use Lc\SovBundle\Repository\RepositoryQueryInterface;


class ProductFamilySectionPropertyStore extends AbstractRepository
class ProductFamilySectionPropertyStore extends AbstractStore
{ {
use SectionStoreTrait; use SectionStoreTrait;




public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{ {
$this->addFilterBySectionRequired($query);
return $query; return $query;
} }


{ {
return $query; return $query;
} }

public function getOneByProductFamily(ProductFamilyInterface $productFamily, $query = null)
{
$query = $this->createDefaultQuery($query);
$query->filterByProductFamily($productFamily);
return $query->findOne();
}
} }

+ 2
- 8
Repository/Reduction/ReductionCatalogStore.php View File



public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{ {
if($this->section) {
$query->filterBySection($this->section);
}
$this->addFilterBySectionOptionnal($query);
$query->filterIsOnlineAndOffline(); $query->filterIsOnlineAndOffline();
return $query; return $query;
} }
return $query; return $query;
} }



public function getByProductFamily(ProductFamilyInterface $productFamily, $query = null) public function getByProductFamily(ProductFamilyInterface $productFamily, $query = null)
{ {
$query = $this->createDefaultQuery($query); $query = $this->createDefaultQuery($query);

$query
->filterProductFamily($productFamily);

$query->filterProductFamily($productFamily);
return $query->findOne(); return $query->findOne();
} }
} }

+ 1
- 1
Resources/views/adminlte/layout.html.twig View File

{% set section_current = section_current() %} {% set section_current = section_current() %}
{% set is_display_switch_section = display_switch_section is defined and display_switch_section %} {% set is_display_switch_section = display_switch_section is defined and display_switch_section %}


<nav class="carac navbar navbar-expand navbar-light main-header{% if is_display_switch_section %} display-section-switch{% endif %}" {% if is_display_switch_section %}style="border-color: {{ section_current.color }};"{% endif %}>
<nav class="carac navbar navbar-expand navbar-light main-header{% if is_display_switch_section %} display-section-switch section-{{ section_current.devAlias }}{% endif %}">


{% if is_display_switch_section %} {% if is_display_switch_section %}
<ul class="navbar-nav left"> <ul class="navbar-nav left">

Loading…
Cancel
Save