public function configureResponseParametersDisableShowAllSections(KeyValueStore $responseParameters) | public function configureResponseParametersDisableShowAllSections(KeyValueStore $responseParameters) | ||||
{ | { | ||||
$responseParameters->set('replace_content_with_message', "Vous devez sélectionner une section pour afficher ces données."); | |||||
if($this->getSectionCurrent() == null) { | |||||
$responseParameters->set('replace_content_with_message', "Vous devez sélectionner une section pour afficher ces données."); | |||||
} | |||||
} | } | ||||
public function createIndexRepositoryQuery( | public function createIndexRepositoryQuery( |
namespace Lc\CaracoleBundle\Controller\Ticket; | namespace Lc\CaracoleBundle\Controller\Ticket; | ||||
use Lc\CaracoleBundle\Controller\ControllerTrait; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; | |||||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||||
use Lc\CaracoleBundle\Definition\ActionDefinition; | |||||
use Lc\SovBundle\Controller\Ticket\TicketAdminController as SovTicketAdminController; | use Lc\SovBundle\Controller\Ticket\TicketAdminController as SovTicketAdminController; | ||||
abstract class TicketAdminController extends SovTicketAdminController | abstract class TicketAdminController extends SovTicketAdminController | ||||
{ | { | ||||
use ControllerTrait; | |||||
use AdminControllerTrait; | |||||
public function createEntity(string $entityFqcn) | public function createEntity(string $entityFqcn) | ||||
{ | { | ||||
->setSection($this->getSectionCurrent()) | ->setSection($this->getSectionCurrent()) | ||||
->create(); | ->create(); | ||||
} | } | ||||
public function configureFields(string $pageName): iterable | |||||
{ | |||||
return $this->getTicketContainer()->getFieldDefinition() | |||||
->setMerchant($this->getMerchantCurrent()) | |||||
->setSection($this->getSectionCurrent()) | |||||
->getFields($pageName); | |||||
} | |||||
public function configureActions(Actions $actions): Actions | |||||
{ | |||||
$actions = parent::configureActions($actions); | |||||
if(!$this->getSectionCurrent()) { | |||||
$actions->disable(ActionDefinition::NEW); | |||||
} | |||||
return $actions; | |||||
} | |||||
} | } |
return array_merge(parent::configureFieldsBase(), [ | return array_merge(parent::configureFieldsBase(), [ | ||||
'section' => AssociationField::new('section') | 'section' => AssociationField::new('section') | ||||
->setRequired(true) | |||||
->setTemplatePath('@LcCaracole/admin/section/field/section.html.twig') | ->setTemplatePath('@LcCaracole/admin/section/field/section.html.twig') | ||||
->setFormTypeOption('choices', $sectionArray) | ->setFormTypeOption('choices', $sectionArray) | ||||
]); | ]); |
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | ||||
use Lc\CaracoleBundle\Field\Address\AddressField; | use Lc\CaracoleBundle\Field\Address\AddressField; | ||||
use Lc\SovBundle\Definition\Field\AbstractFieldDefinition; | use Lc\SovBundle\Definition\Field\AbstractFieldDefinition; | ||||
use Lc\SovBundle\Field\CKEditorField; | |||||
use Lc\SovBundle\Field\ImageManagerField; | |||||
use Lc\SovBundle\Field\StatusField; | use Lc\SovBundle\Field\StatusField; | ||||
class PointSaleFieldDefinition extends AbstractFieldDefinition | class PointSaleFieldDefinition extends AbstractFieldDefinition | ||||
return [ | return [ | ||||
'id' => IntegerField::new('id')->setSortable(true)->onlyOnIndex(), | 'id' => IntegerField::new('id')->setSortable(true)->onlyOnIndex(), | ||||
'title' => TextField::new('title')->setSortable(true), | 'title' => TextField::new('title')->setSortable(true), | ||||
'description' => TextEditorField::new('description'), | |||||
'code' => TextField::new('code'), | |||||
'image' => ImageManagerField::new('image'), | |||||
'description' => CKEditorField::new('description'), | |||||
'status' => StatusField::new('status')->setSortable(true), | 'status' => StatusField::new('status')->setSortable(true), | ||||
'address' => AddressField::new('address') | 'address' => AddressField::new('address') | ||||
->setRequired(true), | ->setRequired(true), |
namespace Lc\CaracoleBundle\Definition\Field\Site; | namespace Lc\CaracoleBundle\Definition\Field\Site; | ||||
use Lc\CaracoleBundle\Definition\Field\FieldDefinitionTrait; | use Lc\CaracoleBundle\Definition\Field\FieldDefinitionTrait; | ||||
use Lc\CaracoleBundle\Repository\Newsletter\NewsletterStore; | |||||
use Lc\CaracoleBundle\Repository\Section\SectionStore; | use Lc\CaracoleBundle\Repository\Section\SectionStore; | ||||
use Lc\SovBundle\Definition\Field\Site\NewsFieldDefinition as SovNewsFieldDefinition; | use Lc\SovBundle\Definition\Field\Site\NewsFieldDefinition as SovNewsFieldDefinition; | ||||
use Lc\SovBundle\Translation\TranslatorAdmin; | use Lc\SovBundle\Translation\TranslatorAdmin; | ||||
use FieldDefinitionTrait; | use FieldDefinitionTrait; | ||||
protected SectionStore $sectionStore; | protected SectionStore $sectionStore; | ||||
protected NewsletterStore $newsletterStore; | |||||
public function __construct(TranslatorAdmin $translatorAdmin, SectionStore $sectionStore) | |||||
public function __construct(TranslatorAdmin $translatorAdmin, SectionStore $sectionStore, NewsletterStore $newsletterStore) | |||||
{ | { | ||||
parent::__construct($translatorAdmin); | parent::__construct($translatorAdmin); | ||||
$this->sectionStore = $sectionStore; | $this->sectionStore = $sectionStore; | ||||
$this->newsletterStore = $newsletterStore; | |||||
} | } | ||||
public function configureIndex(): array | public function configureIndex(): array | ||||
{ | { | ||||
return array_merge(['section'], parent::configurePanelMain()); | return array_merge(['section'], parent::configurePanelMain()); | ||||
} | } | ||||
public function configureFields(): array | |||||
{ | |||||
$fieldArray = parent::configureFields(); | |||||
$newsletterArray = $this->newsletterStore->setSection($this->section)->get(); | |||||
$fieldArray['newsletter']->setFormTypeOption('choices', $newsletterArray); | |||||
return $fieldArray; | |||||
} | |||||
} | } |
<?php | |||||
namespace Lc\CaracoleBundle\Definition\Field\Ticket; | |||||
use Lc\CaracoleBundle\Definition\Field\FieldDefinitionTrait; | |||||
use Lc\CaracoleBundle\Repository\Section\SectionStore; | |||||
use Lc\SovBundle\Definition\Field\Ticket\TicketFieldDefinition as SovTicketFieldDefinition; | |||||
use Lc\SovBundle\Solver\Ticket\TicketSolver; | |||||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||||
class TicketFieldDefinition extends SovTicketFieldDefinition | |||||
{ | |||||
use FieldDefinitionTrait; | |||||
protected SectionStore $sectionStore; | |||||
public function __construct(TranslatorAdmin $translatorAdmin, TicketSolver $ticketSolver, SectionStore $sectionStore) | |||||
{ | |||||
parent::__construct($translatorAdmin, $ticketSolver); | |||||
$this->sectionStore = $sectionStore; | |||||
} | |||||
public function configureIndex(): array | |||||
{ | |||||
return $this->addSectionToFieldArrayIfOutOfSection($this->section, parent::configureIndex()); | |||||
} | |||||
public function configureForm(): array | |||||
{ | |||||
return array_merge(['section'], parent::configureForm()); | |||||
} | |||||
} |
{ | { | ||||
if($entities) { | if($entities) { | ||||
foreach ($entities as $entity) { | foreach ($entities as $entity) { | ||||
foreach ($settings as $category => $settingList) { | foreach ($settings as $category => $settingList) { | ||||
foreach ($settingList as $settingName => $setting) { | foreach ($settingList as $settingName => $setting) { | ||||
$entitySetting = $this->settingSolver->getSetting($entity, $settingName); | $entitySetting = $this->settingSolver->getSetting($entity, $settingName); |
{ | { | ||||
$news = parent::create(); | $news = parent::create(); | ||||
$news->setSection($this->section); | |||||
if($this->section) { | |||||
$news->setSection($this->section); | |||||
} | |||||
return $news; | return $news; | ||||
} | } |
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\CaracoleBundle\Model\Merchant\MerchantInterface; | |||||
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; | ||||
{ | { | ||||
$ticket = parent::create(); | $ticket = parent::create(); | ||||
$ticket->setSection($this->section); | |||||
if(!is_null($this->section)) { | |||||
$ticket->setSection($this->section); | |||||
} | |||||
return $ticket; | return $ticket; | ||||
} | } |
namespace Lc\CaracoleBundle\Form\Ticket; | namespace Lc\CaracoleBundle\Form\Ticket; | ||||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | ||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||||
use Lc\CaracoleBundle\Repository\Order\OrderShopStore; | use Lc\CaracoleBundle\Repository\Order\OrderShopStore; | ||||
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; | ||||
use Lc\SovBundle\Model\Ticket\TicketInterface; | use Lc\SovBundle\Model\Ticket\TicketInterface; | ||||
use Lc\SovBundle\Model\User\UserInterface; | |||||
use Lc\SovBundle\Solver\Ticket\TicketSolver; | use Lc\SovBundle\Solver\Ticket\TicketSolver; | ||||
use Lc\SovBundle\Translation\TranslatorAdmin; | use Lc\SovBundle\Translation\TranslatorAdmin; | ||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | use Symfony\Bridge\Doctrine\Form\Type\EntityType; | ||||
use Symfony\Component\Form\AbstractType; | |||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | ||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType; | |||||
use Symfony\Component\Form\Extension\Core\Type\EmailType; | use Symfony\Component\Form\Extension\Core\Type\EmailType; | ||||
use Symfony\Component\Form\Extension\Core\Type\FileType; | use Symfony\Component\Form\Extension\Core\Type\FileType; | ||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType; | |||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType; | use Symfony\Component\Form\Extension\Core\Type\TextareaType; | ||||
use Symfony\Component\Form\Extension\Core\Type\TextType; | use Symfony\Component\Form\Extension\Core\Type\TextType; | ||||
use Symfony\Component\Form\FormBuilderInterface; | use Symfony\Component\Form\FormBuilderInterface; | ||||
use Symfony\Component\OptionsResolver\OptionsResolver; | use Symfony\Component\OptionsResolver\OptionsResolver; | ||||
use Symfony\Component\Security\Core\Security; | use Symfony\Component\Security\Core\Security; | ||||
use Symfony\Component\Validator\Constraints\File; | use Symfony\Component\Validator\Constraints\File; | ||||
use Lc\SovBundle\Form\Ticket\TicketFormType as SovTicketFormType; | |||||
class TicketFormType extends AbstractType | |||||
class TicketFormType extends SovTicketFormType | |||||
{ | { | ||||
protected Security $security; | protected Security $security; | ||||
protected EntityManager $entityManager; | |||||
protected TranslatorAdmin $translatorAdmin; | |||||
protected TicketSolver $ticketSolver; | |||||
protected FormComponent $formComponent; | protected FormComponent $formComponent; | ||||
protected OrderShopStore $orderShopStore; | protected OrderShopStore $orderShopStore; | ||||
protected PriceSolver $priceSolver; | protected PriceSolver $priceSolver; | ||||
OrderShopStore $orderShopStore, | OrderShopStore $orderShopStore, | ||||
PriceSolver $priceSolver | PriceSolver $priceSolver | ||||
) { | ) { | ||||
parent::__construct($entityManager, $translatorAdmin, $ticketSolver); | |||||
$this->security = $security; | $this->security = $security; | ||||
$this->entityManager = $entityManager; | |||||
$this->translatorAdmin = $translatorAdmin; | |||||
$this->ticketSolver = $ticketSolver; | |||||
$this->formComponent = $formComponent; | $this->formComponent = $formComponent; | ||||
$this->orderShopStore = $orderShopStore; | $this->orderShopStore = $orderShopStore; | ||||
$this->priceSolver = $priceSolver; | $this->priceSolver = $priceSolver; | ||||
$isConnected = $this->security->getUser(); | $isConnected = $this->security->getUser(); | ||||
$entityName = $this->entityManager->getEntityName(TicketInterface::class); | $entityName = $this->entityManager->getEntityName(TicketInterface::class); | ||||
$builder->add( | |||||
'section', | |||||
EntityType::class, | |||||
[ | |||||
'class' => $this->entityManager->getEntityName(SectionInterface::class), | |||||
] | |||||
); | |||||
if (!$isConnected) { | if (!$isConnected) { | ||||
$builder->add( | $builder->add( | ||||
'visitorFirstname', | 'visitorFirstname', | ||||
'placeholder' => '-- Choisissez une commande --', | 'placeholder' => '-- Choisissez une commande --', | ||||
'required' => false, | 'required' => false, | ||||
'choice_label' => function ($orderShop, $key, $value) { | 'choice_label' => function ($orderShop, $key, $value) { | ||||
$dateString = ''; | |||||
$dateObject = $orderShop->getValidationDate() ? $orderShop->getValidationDate( | |||||
) : $orderShop->getCreatedAt(); | |||||
$dateString = '' ; | |||||
$dateObject = $orderShop->getValidationDate() ? $orderShop->getValidationDate() : $orderShop->getCreatedAt(); | |||||
if($orderShop->getValidationDate()) { | |||||
$dateString .= 'du '.$dateObject->format('d/m/Y').' ' ; | |||||
if ($orderShop->getValidationDate()) { | |||||
$dateString .= 'du ' . $dateObject->format('d/m/Y') . ' '; | |||||
} | } | ||||
return 'Commande ' . $dateString . | return 'Commande ' . $dateString . |
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | ||||
{ | { | ||||
$query->filterBySection($this->section); | |||||
$this->addFilterBySectionOptionnal($query); | |||||
$query->filterIsOnlineAndOffline(); | $query->filterIsOnlineAndOffline(); | ||||
return $query; | return $query; | ||||
} | } |
$requestAttributesArray = $this->requestStack->getMainRequest()->attributes->all(); | $requestAttributesArray = $this->requestStack->getMainRequest()->attributes->all(); | ||||
// admin | // admin | ||||
if (isset($requestAttributesArray['easyadmin_context'])) { | |||||
if (isset($requestAttributesArray['_firewall_context']) && $requestAttributesArray['_firewall_context'] == 'security.firewall.map.context.admin') { | |||||
//dump($requestAttributesArray); | |||||
if (!$this->isCachedSection) { | if (!$this->isCachedSection) { | ||||
$currentAdminSection = null; | $currentAdminSection = null; | ||||
$userMerchant = $this->merchantResolver->getUserMerchant(); | $userMerchant = $this->merchantResolver->getUserMerchant(); | ||||
} | } | ||||
} // front | } // front | ||||
else { | else { | ||||
dump('front'); | |||||
dump($requestAttributesArray); | |||||
if($this->section === null) { | if($this->section === null) { | ||||
$merchantCurrent = $this->merchantResolver->getCurrent(); | $merchantCurrent = $this->merchantResolver->getCurrent(); | ||||
$sectionStore = $this->sectionStore->setMerchant($merchantCurrent); | $sectionStore = $this->sectionStore->setMerchant($merchantCurrent); |
isPublic: Publique | isPublic: Publique | ||||
isDepository: Dépôt | isDepository: Dépôt | ||||
deliveryPrice: Montant de la livraison | deliveryPrice: Montant de la livraison | ||||
code: Code | |||||
code_help: Code utilisé pour retrouver l'ambassade dans le tunnel de commande (Non sensible à la casse) | |||||
image: Image | |||||
Address: | Address: | ||||
fields: | fields: |