trait SectionContextTrait | trait SectionContextTrait | ||||
{ | { | ||||
protected ?SectionInterface $section; | |||||
protected ?SectionInterface $section = null; | |||||
public function setSection(?SectionInterface $section) | public function setSection(?SectionInterface $section) | ||||
{ | { |
return $this->getTicketContainer() | return $this->getTicketContainer() | ||||
->getFactory() | ->getFactory() | ||||
->setSection($this->getSectionCurrent()) | ->setSection($this->getSectionCurrent()) | ||||
->setMerchant($this->getMerchantCurrent()) | |||||
->create(); | ->create(); | ||||
} | } | ||||
$actions = parent::configureActions($actions); | $actions = parent::configureActions($actions); | ||||
if(!$this->getSectionCurrent()) { | if(!$this->getSectionCurrent()) { | ||||
$actions->disable(ActionDefinition::NEW); | |||||
$actions->disable(ActionDefinition::NEW, ActionDefinition::EDIT, ActionDefinition::DUPLICATE,ActionDefinition::DUPLICATE_TO_OTHER_SECTION, ActionDefinition::DELETE); | |||||
}else{ | |||||
$actions->disable( ActionDefinition::EDIT, ActionDefinition::DUPLICATE,ActionDefinition::DUPLICATE_TO_OTHER_SECTION, ActionDefinition::DELETE); | |||||
} | } | ||||
return $actions; | return $actions; |
$fields['birthdate'], | $fields['birthdate'], | ||||
$fields['groupUsers'], | $fields['groupUsers'], | ||||
$fields['isSaleAlwaysOpen'], | $fields['isSaleAlwaysOpen'], | ||||
$fields['newsletters'] | |||||
$fields['newsletters'], | |||||
$fields['ticketTypesNotification'] | |||||
]; | ]; | ||||
if ($this->isGranted('ROLE_SUPER_ADMIN')) { | if ($this->isGranted('ROLE_SUPER_ADMIN')) { |
namespace Lc\CaracoleBundle\Definition\Field\User; | namespace Lc\CaracoleBundle\Definition\Field\User; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField; | |||||
use Lc\CaracoleBundle\Context\MerchantContextTrait; | use Lc\CaracoleBundle\Context\MerchantContextTrait; | ||||
use Lc\CaracoleBundle\Field\AssociationField; | use Lc\CaracoleBundle\Field\AssociationField; | ||||
use Lc\CaracoleBundle\Repository\Newsletter\NewsletterStore; | use Lc\CaracoleBundle\Repository\Newsletter\NewsletterStore; | ||||
use Lc\CaracoleBundle\Repository\User\GroupUserStore; | use Lc\CaracoleBundle\Repository\User\GroupUserStore; | ||||
use Lc\CaracoleBundle\Solver\Ticket\TicketSolver; | |||||
use Lc\SovBundle\Definition\Field\User\UserFieldDefinition as SovUserFieldDefinition; | use Lc\SovBundle\Definition\Field\User\UserFieldDefinition as SovUserFieldDefinition; | ||||
use Lc\SovBundle\Definition\RolesDefinition; | use Lc\SovBundle\Definition\RolesDefinition; | ||||
use Lc\SovBundle\Field\BooleanField; | use Lc\SovBundle\Field\BooleanField; | ||||
'birthdate', | 'birthdate', | ||||
'groupUsers', | 'groupUsers', | ||||
'isSaleAlwaysOpen', | 'isSaleAlwaysOpen', | ||||
'newsletters' | |||||
'newsletters', | |||||
'ticketTypesNotification' | |||||
]; | ]; | ||||
} | } | ||||
->setFormTypeOption('choice_label', function ($choice) { | ->setFormTypeOption('choice_label', function ($choice) { | ||||
return $choice->getTitle(). '['.$choice->getMerchant().']'; | return $choice->getTitle(). '['.$choice->getMerchant().']'; | ||||
}) | }) | ||||
->setSortable(true), | |||||
'ticketTypesNotification' => ChoiceField::new('ticketTypesNotification') | |||||
->setSortable(true) | ->setSortable(true) | ||||
->setFormTypeOption('expanded', false) | |||||
->setFormTypeOption('multiple', true) | |||||
->setChoices($this->translatorAdmin->transChoices( | |||||
TicketSolver::getTypeChoices(), | |||||
'Ticket', | |||||
'type' | |||||
)), | |||||
]); | ]); | ||||
} | } |
namespace Lc\CaracoleBundle\Factory\Ticket; | namespace Lc\CaracoleBundle\Factory\Ticket; | ||||
use Lc\CaracoleBundle\Context\MerchantContextTrait; | |||||
use Lc\CaracoleBundle\Context\SectionContextTrait; | use Lc\CaracoleBundle\Context\SectionContextTrait; | ||||
use Lc\SovBundle\Factory\Ticket\TicketFactory as SovTicketFactory; | use Lc\SovBundle\Factory\Ticket\TicketFactory as SovTicketFactory; | ||||
use Lc\SovBundle\Model\Ticket\TicketInterface; | use Lc\SovBundle\Model\Ticket\TicketInterface; | ||||
class TicketFactory extends SovTicketFactory | class TicketFactory extends SovTicketFactory | ||||
{ | { | ||||
use SectionContextTrait; | use SectionContextTrait; | ||||
use MerchantContextTrait; | |||||
public function create(): TicketInterface | public function create(): TicketInterface | ||||
{ | { | ||||
$ticket->setSection($this->section); | $ticket->setSection($this->section); | ||||
} | } | ||||
if(!is_null($this->merchant)) { | |||||
$ticket->setMerchant($this->merchant); | |||||
} | |||||
return $ticket; | return $ticket; | ||||
} | } | ||||
} | |||||
} |
namespace Lc\CaracoleBundle\Form\Ticket; | namespace Lc\CaracoleBundle\Form\Ticket; | ||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | ||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | use Lc\CaracoleBundle\Model\Section\SectionInterface; | ||||
use Lc\CaracoleBundle\Repository\Order\OrderShopStore; | use Lc\CaracoleBundle\Repository\Order\OrderShopStore; | ||||
use Lc\CaracoleBundle\Repository\Section\SectionStore; | |||||
use Lc\CaracoleBundle\Solver\Price\PriceSolver; | use Lc\CaracoleBundle\Solver\Price\PriceSolver; | ||||
use Lc\SovBundle\Component\FormComponent; | use Lc\SovBundle\Component\FormComponent; | ||||
use Lc\SovBundle\Doctrine\EntityManager; | use Lc\SovBundle\Doctrine\EntityManager; | ||||
protected FormComponent $formComponent; | protected FormComponent $formComponent; | ||||
protected OrderShopStore $orderShopStore; | protected OrderShopStore $orderShopStore; | ||||
protected PriceSolver $priceSolver; | protected PriceSolver $priceSolver; | ||||
protected SectionStore $sectionStore; | |||||
public function __construct( | public function __construct( | ||||
Security $security, | Security $security, | ||||
TicketSolver $ticketSolver, | TicketSolver $ticketSolver, | ||||
FormComponent $formComponent, | FormComponent $formComponent, | ||||
OrderShopStore $orderShopStore, | OrderShopStore $orderShopStore, | ||||
PriceSolver $priceSolver | |||||
PriceSolver $priceSolver, | |||||
SectionStore $sectionStore | |||||
) { | ) { | ||||
parent::__construct($entityManager, $translatorAdmin, $ticketSolver); | parent::__construct($entityManager, $translatorAdmin, $ticketSolver); | ||||
$this->formComponent = $formComponent; | $this->formComponent = $formComponent; | ||||
$this->orderShopStore = $orderShopStore; | $this->orderShopStore = $orderShopStore; | ||||
$this->priceSolver = $priceSolver; | $this->priceSolver = $priceSolver; | ||||
$this->sectionStore = $sectionStore; | |||||
} | } | ||||
public function buildForm(FormBuilderInterface $builder, array $options) | public function buildForm(FormBuilderInterface $builder, array $options) | ||||
{ | { | ||||
$isConnected = $this->security->getUser(); | $isConnected = $this->security->getUser(); | ||||
$entityName = $this->entityManager->getEntityName(TicketInterface::class); | |||||
$sectionList = $this->sectionStore->setMerchant($options['merchant'])->getOnline(); | |||||
$builder->add( | $builder->add( | ||||
'section', | 'section', | ||||
EntityType::class, | EntityType::class, | ||||
[ | [ | ||||
'label'=> 'Espace concerné', | |||||
'choices' => $sectionList, | |||||
'required' => false, | |||||
'placeholder'=> 'Je ne sais pas', | |||||
'class' => $this->entityManager->getEntityName(SectionInterface::class), | 'class' => $this->entityManager->getEntityName(SectionInterface::class), | ||||
] | ] | ||||
); | ); | ||||
[ | [ | ||||
'label' => 'Type', | 'label' => 'Type', | ||||
'choices' => $this->translatorAdmin->transChoices( | 'choices' => $this->translatorAdmin->transChoices( | ||||
$this->ticketSolver->getTypeChoices(), | |||||
TicketSolver::getTypeChoices(), | |||||
'Ticket', | 'Ticket', | ||||
'type' | 'type' | ||||
), | ), | ||||
$resolver->setDefaults( | $resolver->setDefaults( | ||||
[ | [ | ||||
'data_class' => $this->entityManager->getEntityName(TicketInterface::class), | 'data_class' => $this->entityManager->getEntityName(TicketInterface::class), | ||||
'merchant' => MerchantInterface::class, | |||||
] | ] | ||||
); | ); | ||||
} | } | ||||
} | |||||
} |
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | ||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | ||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | use Lc\CaracoleBundle\Model\Section\SectionInterface; | ||||
use Lc\SovBundle\Model\Ticket\TicketModel as SovTicketModel; | use Lc\SovBundle\Model\Ticket\TicketModel as SovTicketModel; | ||||
const TYPE_PRODUCT_ERROR = 'product-error'; | const TYPE_PRODUCT_ERROR = 'product-error'; | ||||
/** | /** | ||||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface", inversedBy="pages") | |||||
* @ORM\JoinColumn(nullable=false) | |||||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface") | |||||
* @ORM\JoinColumn(nullable=true) | |||||
*/ | */ | ||||
protected $section; | protected $section; | ||||
/** | |||||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface") | |||||
* @ORM\JoinColumn(nullable=false) | |||||
*/ | |||||
protected $merchant; | |||||
/** | /** | ||||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Order\OrderShopInterface", inversedBy="tickets") | * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Order\OrderShopInterface", inversedBy="tickets") | ||||
*/ | */ | ||||
protected $orderShop; | protected $orderShop; | ||||
public function getSection(): SectionInterface | |||||
public function getSection(): ? SectionInterface | |||||
{ | { | ||||
return $this->section; | return $this->section; | ||||
} | } | ||||
public function setSection(SectionInterface $section): self | |||||
public function setSection(? SectionInterface $section): self | |||||
{ | { | ||||
$this->section = $section; | $this->section = $section; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getMerchant(): MerchantInterface | |||||
{ | |||||
return $this->merchant; | |||||
} | |||||
public function setMerchant( MerchantInterface $merchant): self | |||||
{ | |||||
$this->merchant = $merchant; | |||||
return $this; | |||||
} | |||||
public function getOrderShop(): ?OrderShopInterface | public function getOrderShop(): ?OrderShopInterface | ||||
{ | { | ||||
return $this->orderShop; | return $this->orderShop; |
namespace Lc\CaracoleBundle\Repository\Ticket; | namespace Lc\CaracoleBundle\Repository\Ticket; | ||||
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait; | |||||
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait; | use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait; | ||||
use Lc\SovBundle\Repository\Ticket\TicketRepositoryQuery as SovTicketRepositoryQuery; | use Lc\SovBundle\Repository\Ticket\TicketRepositoryQuery as SovTicketRepositoryQuery; | ||||
class TicketRepositoryQuery extends SovTicketRepositoryQuery | class TicketRepositoryQuery extends SovTicketRepositoryQuery | ||||
{ | { | ||||
use SectionRepositoryQueryTrait; | use SectionRepositoryQueryTrait; | ||||
use MerchantRepositoryQueryTrait; | |||||
} | } |
namespace Lc\CaracoleBundle\Repository\Ticket; | namespace Lc\CaracoleBundle\Repository\Ticket; | ||||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | |||||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | use Lc\CaracoleBundle\Repository\SectionStoreTrait; | ||||
use Lc\CaracoleBundle\Repository\StoreTrait; | use Lc\CaracoleBundle\Repository\StoreTrait; | ||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | use Lc\SovBundle\Repository\RepositoryQueryInterface; | ||||
{ | { | ||||
use StoreTrait; | use StoreTrait; | ||||
use SectionStoreTrait; | use SectionStoreTrait; | ||||
use MerchantStoreTrait; | |||||
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | ||||
{ | { |