@@ -52,7 +52,9 @@ trait AdminControllerTrait | |||
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( |
@@ -2,12 +2,14 @@ | |||
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; | |||
abstract class TicketAdminController extends SovTicketAdminController | |||
{ | |||
use ControllerTrait; | |||
use AdminControllerTrait; | |||
public function createEntity(string $entityFqcn) | |||
{ | |||
@@ -16,4 +18,23 @@ abstract class TicketAdminController extends SovTicketAdminController | |||
->setSection($this->getSectionCurrent()) | |||
->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; | |||
} | |||
} |
@@ -18,6 +18,7 @@ trait FieldDefinitionTrait | |||
return array_merge(parent::configureFieldsBase(), [ | |||
'section' => AssociationField::new('section') | |||
->setRequired(true) | |||
->setTemplatePath('@LcCaracole/admin/section/field/section.html.twig') | |||
->setFormTypeOption('choices', $sectionArray) | |||
]); |
@@ -7,6 +7,8 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||
use Lc\CaracoleBundle\Field\Address\AddressField; | |||
use Lc\SovBundle\Definition\Field\AbstractFieldDefinition; | |||
use Lc\SovBundle\Field\CKEditorField; | |||
use Lc\SovBundle\Field\ImageManagerField; | |||
use Lc\SovBundle\Field\StatusField; | |||
class PointSaleFieldDefinition extends AbstractFieldDefinition | |||
@@ -52,7 +54,9 @@ class PointSaleFieldDefinition extends AbstractFieldDefinition | |||
return [ | |||
'id' => IntegerField::new('id')->setSortable(true)->onlyOnIndex(), | |||
'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), | |||
'address' => AddressField::new('address') | |||
->setRequired(true), |
@@ -3,6 +3,7 @@ | |||
namespace Lc\CaracoleBundle\Definition\Field\Site; | |||
use Lc\CaracoleBundle\Definition\Field\FieldDefinitionTrait; | |||
use Lc\CaracoleBundle\Repository\Newsletter\NewsletterStore; | |||
use Lc\CaracoleBundle\Repository\Section\SectionStore; | |||
use Lc\SovBundle\Definition\Field\Site\NewsFieldDefinition as SovNewsFieldDefinition; | |||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||
@@ -12,11 +13,13 @@ class NewsFieldDefinition extends SovNewsFieldDefinition | |||
use FieldDefinitionTrait; | |||
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); | |||
$this->sectionStore = $sectionStore; | |||
$this->newsletterStore = $newsletterStore; | |||
} | |||
public function configureIndex(): array | |||
@@ -28,4 +31,14 @@ class NewsFieldDefinition extends SovNewsFieldDefinition | |||
{ | |||
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; | |||
} | |||
} |
@@ -0,0 +1,32 @@ | |||
<?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()); | |||
} | |||
} |
@@ -78,6 +78,7 @@ class SettingEventSubscriber implements EventSubscriberInterface | |||
{ | |||
if($entities) { | |||
foreach ($entities as $entity) { | |||
foreach ($settings as $category => $settingList) { | |||
foreach ($settingList as $settingName => $setting) { | |||
$entitySetting = $this->settingSolver->getSetting($entity, $settingName); |
@@ -16,7 +16,9 @@ class NewsFactory extends SovNewsFactory | |||
{ | |||
$news = parent::create(); | |||
$news->setSection($this->section); | |||
if($this->section) { | |||
$news->setSection($this->section); | |||
} | |||
return $news; | |||
} |
@@ -2,9 +2,7 @@ | |||
namespace Lc\CaracoleBundle\Factory\Ticket; | |||
use Lc\CaracoleBundle\Context\MerchantContextTrait; | |||
use Lc\CaracoleBundle\Context\SectionContextTrait; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\SovBundle\Factory\Ticket\TicketFactory as SovTicketFactory; | |||
use Lc\SovBundle\Model\Ticket\TicketInterface; | |||
@@ -16,7 +14,9 @@ class TicketFactory extends SovTicketFactory | |||
{ | |||
$ticket = parent::create(); | |||
$ticket->setSection($this->section); | |||
if(!is_null($this->section)) { | |||
$ticket->setSection($this->section); | |||
} | |||
return $ticket; | |||
} |
@@ -3,34 +3,29 @@ | |||
namespace Lc\CaracoleBundle\Form\Ticket; | |||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\CaracoleBundle\Repository\Order\OrderShopStore; | |||
use Lc\CaracoleBundle\Solver\Price\PriceSolver; | |||
use Lc\SovBundle\Component\FormComponent; | |||
use Lc\SovBundle\Doctrine\EntityManager; | |||
use Lc\SovBundle\Model\Ticket\TicketInterface; | |||
use Lc\SovBundle\Model\User\UserInterface; | |||
use Lc\SovBundle\Solver\Ticket\TicketSolver; | |||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||
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\CollectionType; | |||
use Symfony\Component\Form\Extension\Core\Type\EmailType; | |||
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\TextType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||
use Symfony\Component\Security\Core\Security; | |||
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 EntityManager $entityManager; | |||
protected TranslatorAdmin $translatorAdmin; | |||
protected TicketSolver $ticketSolver; | |||
protected FormComponent $formComponent; | |||
protected OrderShopStore $orderShopStore; | |||
protected PriceSolver $priceSolver; | |||
@@ -44,10 +39,9 @@ class TicketFormType extends AbstractType | |||
OrderShopStore $orderShopStore, | |||
PriceSolver $priceSolver | |||
) { | |||
parent::__construct($entityManager, $translatorAdmin, $ticketSolver); | |||
$this->security = $security; | |||
$this->entityManager = $entityManager; | |||
$this->translatorAdmin = $translatorAdmin; | |||
$this->ticketSolver = $ticketSolver; | |||
$this->formComponent = $formComponent; | |||
$this->orderShopStore = $orderShopStore; | |||
$this->priceSolver = $priceSolver; | |||
@@ -58,6 +52,14 @@ class TicketFormType extends AbstractType | |||
$isConnected = $this->security->getUser(); | |||
$entityName = $this->entityManager->getEntityName(TicketInterface::class); | |||
$builder->add( | |||
'section', | |||
EntityType::class, | |||
[ | |||
'class' => $this->entityManager->getEntityName(SectionInterface::class), | |||
] | |||
); | |||
if (!$isConnected) { | |||
$builder->add( | |||
'visitorFirstname', | |||
@@ -113,12 +115,12 @@ class TicketFormType extends AbstractType | |||
'placeholder' => '-- Choisissez une commande --', | |||
'required' => false, | |||
'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 . |
@@ -21,7 +21,7 @@ class NewsletterStore extends SovNewsletterStore | |||
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | |||
{ | |||
$query->filterBySection($this->section); | |||
$this->addFilterBySectionOptionnal($query); | |||
$query->filterIsOnlineAndOffline(); | |||
return $query; | |||
} |
@@ -44,7 +44,8 @@ class SectionResolver | |||
$requestAttributesArray = $this->requestStack->getMainRequest()->attributes->all(); | |||
// admin | |||
if (isset($requestAttributesArray['easyadmin_context'])) { | |||
if (isset($requestAttributesArray['_firewall_context']) && $requestAttributesArray['_firewall_context'] == 'security.firewall.map.context.admin') { | |||
//dump($requestAttributesArray); | |||
if (!$this->isCachedSection) { | |||
$currentAdminSection = null; | |||
$userMerchant = $this->merchantResolver->getUserMerchant(); | |||
@@ -72,6 +73,8 @@ class SectionResolver | |||
} | |||
} // front | |||
else { | |||
dump('front'); | |||
dump($requestAttributesArray); | |||
if($this->section === null) { | |||
$merchantCurrent = $this->merchantResolver->getCurrent(); | |||
$sectionStore = $this->sectionStore->setMerchant($merchantCurrent); |
@@ -82,6 +82,9 @@ entity: | |||
isPublic: Publique | |||
isDepository: Dépôt | |||
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: | |||
fields: |