Explorar el Código

Finalisation tableau de bord + ticket

packProduct
Fab hace 3 años
padre
commit
0948559c24
Se han modificado 13 ficheros con 110 adiciones y 38 borrados
  1. +3
    -1
      Controller/AdminControllerTrait.php
  2. +23
    -2
      Controller/Ticket/TicketAdminController.php
  3. +1
    -0
      Definition/Field/FieldDefinitionTrait.php
  4. +3
    -0
      Definition/Field/PointSale/PointSaleFieldDefinition.php
  5. +14
    -1
      Definition/Field/Site/NewsFieldDefinition.php
  6. +33
    -12
      Definition/Field/Ticket/TicketFieldDefinition.php
  7. +1
    -0
      EventSubscriber/SettingEventSubscriber.php
  8. +3
    -1
      Factory/Site/NewsFactory.php
  9. +3
    -3
      Factory/Ticket/TicketFactory.php
  10. +18
    -16
      Form/Ticket/TicketFormType.php
  11. +1
    -1
      Repository/Newsletter/NewsletterStore.php
  12. +4
    -1
      Resolver/SectionResolver.php
  13. +3
    -0
      Resources/translations/admin.fr.yaml

+ 3
- 1
Controller/AdminControllerTrait.php Ver fichero

@@ -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(

+ 23
- 2
Controller/Ticket/TicketAdminController.php Ver fichero

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

+ 1
- 0
Definition/Field/FieldDefinitionTrait.php Ver fichero

@@ -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)
]);

+ 3
- 0
Definition/Field/PointSale/PointSaleFieldDefinition.php Ver fichero

@@ -7,6 +7,7 @@ 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,6 +53,8 @@ class PointSaleFieldDefinition extends AbstractFieldDefinition
return [
'id' => IntegerField::new('id')->setSortable(true)->onlyOnIndex(),
'title' => TextField::new('title')->setSortable(true),
'code' => TextField::new('code'),
'image' => ImageManagerField::new('image'),
'description' => CKEditorField::new('description'),
'status' => StatusField::new('status')->setSortable(true),
'address' => AddressField::new('address')

+ 14
- 1
Definition/Field/Site/NewsFieldDefinition.php Ver fichero

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

+ 33
- 12
Definition/Field/Ticket/TicketFieldDefinition.php Ver fichero

@@ -2,28 +2,49 @@

namespace Lc\CaracoleBundle\Definition\Field\Ticket;


use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
use Lc\CaracoleBundle\Definition\Field\FieldDefinitionTrait;
use Lc\CaracoleBundle\Repository\Section\SectionStore;
use Lc\CaracoleBundle\Solver\Ticket\TicketSolver;
use Lc\SovBundle\Definition\Field\Ticket\TicketFieldDefinition as SovTicketFieldDefinition;
use Lc\SovBundle\Translation\TranslatorAdmin;

class TicketFieldDefinition extends SovTicketFieldDefinition
{
use FieldDefinitionTrait;

protected SectionStore $sectionStore;

public function __construct(
TranslatorAdmin $translatorAdmin,
SectionStore $sectionStore
) {
parent::__construct($translatorAdmin);
$this->sectionStore = $sectionStore;
}


public function configureFields(): array
{
return array_merge(parent::configureFields(),[
'type' => ChoiceField::new('type')
->autocomplete()
->setChoices(
$this->translatorAdmin->transChoices(
TicketSolver::getTypeChoices(),
'Ticket',
'type'
)
),
return array_merge(parent::configureFields(), [
'type' => ChoiceField::new('type')
->autocomplete()
->setChoices(
$this->translatorAdmin->transChoices(
TicketSolver::getTypeChoices(),
'Ticket',
'type'
)
),
]);

}
public function configureIndex(): array
{
return $this->addSectionToFieldArrayIfOutOfSection($this->section, parent::configureIndex());
}

public function configureForm(): array
{
return array_merge(['section'], parent::configureForm());
}
}

+ 1
- 0
EventSubscriber/SettingEventSubscriber.php Ver fichero

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

+ 3
- 1
Factory/Site/NewsFactory.php Ver fichero

@@ -16,7 +16,9 @@ class NewsFactory extends SovNewsFactory
{
$news = parent::create();

$news->setSection($this->section);
if($this->section) {
$news->setSection($this->section);
}

return $news;
}

+ 3
- 3
Factory/Ticket/TicketFactory.php Ver fichero

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

+ 18
- 16
Form/Ticket/TicketFormType.php Ver fichero

@@ -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 .

+ 1
- 1
Repository/Newsletter/NewsletterStore.php Ver fichero

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

+ 4
- 1
Resolver/SectionResolver.php Ver fichero

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

+ 3
- 0
Resources/translations/admin.fr.yaml Ver fichero

@@ -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:

Cargando…
Cancelar
Guardar