Browse Source

Finalisation app ticket

packProduct
Fab 3 years ago
parent
commit
33b7639963
9 changed files with 68 additions and 13 deletions
  1. +1
    -1
      Context/SectionContextTrait.php
  2. +4
    -1
      Controller/Ticket/TicketAdminController.php
  3. +2
    -1
      Controller/User/UserAdminController.php
  4. +13
    -1
      Definition/Field/User/UserFieldDefinition.php
  5. +6
    -1
      Factory/Ticket/TicketFactory.php
  6. +14
    -4
      Form/Ticket/TicketFormType.php
  7. +24
    -4
      Model/Ticket/TicketModel.php
  8. +2
    -0
      Repository/Ticket/TicketRepositoryQuery.php
  9. +2
    -0
      Repository/Ticket/TicketStore.php

+ 1
- 1
Context/SectionContextTrait.php View File

@@ -6,7 +6,7 @@ use Lc\CaracoleBundle\Model\Section\SectionInterface;

trait SectionContextTrait
{
protected ?SectionInterface $section;
protected ?SectionInterface $section = null;

public function setSection(?SectionInterface $section)
{

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

@@ -16,6 +16,7 @@ abstract class TicketAdminController extends SovTicketAdminController
return $this->getTicketContainer()
->getFactory()
->setSection($this->getSectionCurrent())
->setMerchant($this->getMerchantCurrent())
->create();
}

@@ -32,7 +33,9 @@ abstract class TicketAdminController extends SovTicketAdminController
$actions = parent::configureActions($actions);

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;

+ 2
- 1
Controller/User/UserAdminController.php View File

@@ -70,7 +70,8 @@ abstract class UserAdminController extends SovUserAdminController
$fields['birthdate'],
$fields['groupUsers'],
$fields['isSaleAlwaysOpen'],
$fields['newsletters']
$fields['newsletters'],
$fields['ticketTypesNotification']
];

if ($this->isGranted('ROLE_SUPER_ADMIN')) {

+ 13
- 1
Definition/Field/User/UserFieldDefinition.php View File

@@ -2,10 +2,12 @@

namespace Lc\CaracoleBundle\Definition\Field\User;

use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
use Lc\CaracoleBundle\Context\MerchantContextTrait;
use Lc\CaracoleBundle\Field\AssociationField;
use Lc\CaracoleBundle\Repository\Newsletter\NewsletterStore;
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\RolesDefinition;
use Lc\SovBundle\Field\BooleanField;
@@ -39,7 +41,8 @@ class UserFieldDefinition extends SovUserFieldDefinition
'birthdate',
'groupUsers',
'isSaleAlwaysOpen',
'newsletters'
'newsletters',
'ticketTypesNotification'
];
}

@@ -61,7 +64,16 @@ class UserFieldDefinition extends SovUserFieldDefinition
->setFormTypeOption('choice_label', function ($choice) {
return $choice->getTitle(). '['.$choice->getMerchant().']';
})
->setSortable(true),
'ticketTypesNotification' => ChoiceField::new('ticketTypesNotification')
->setSortable(true)
->setFormTypeOption('expanded', false)
->setFormTypeOption('multiple', true)
->setChoices($this->translatorAdmin->transChoices(
TicketSolver::getTypeChoices(),
'Ticket',
'type'
)),

]);
}

+ 6
- 1
Factory/Ticket/TicketFactory.php View File

@@ -2,6 +2,7 @@

namespace Lc\CaracoleBundle\Factory\Ticket;

use Lc\CaracoleBundle\Context\MerchantContextTrait;
use Lc\CaracoleBundle\Context\SectionContextTrait;
use Lc\SovBundle\Factory\Ticket\TicketFactory as SovTicketFactory;
use Lc\SovBundle\Model\Ticket\TicketInterface;
@@ -9,6 +10,7 @@ use Lc\SovBundle\Model\Ticket\TicketInterface;
class TicketFactory extends SovTicketFactory
{
use SectionContextTrait;
use MerchantContextTrait;

public function create(): TicketInterface
{
@@ -18,6 +20,9 @@ class TicketFactory extends SovTicketFactory
$ticket->setSection($this->section);
}

if(!is_null($this->merchant)) {
$ticket->setMerchant($this->merchant);
}
return $ticket;
}
}
}

+ 14
- 4
Form/Ticket/TicketFormType.php View File

@@ -2,9 +2,11 @@

namespace Lc\CaracoleBundle\Form\Ticket;

use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Repository\Order\OrderShopStore;
use Lc\CaracoleBundle\Repository\Section\SectionStore;
use Lc\CaracoleBundle\Solver\Price\PriceSolver;
use Lc\SovBundle\Component\FormComponent;
use Lc\SovBundle\Doctrine\EntityManager;
@@ -29,6 +31,7 @@ class TicketFormType extends SovTicketFormType
protected FormComponent $formComponent;
protected OrderShopStore $orderShopStore;
protected PriceSolver $priceSolver;
protected SectionStore $sectionStore;

public function __construct(
Security $security,
@@ -37,7 +40,8 @@ class TicketFormType extends SovTicketFormType
TicketSolver $ticketSolver,
FormComponent $formComponent,
OrderShopStore $orderShopStore,
PriceSolver $priceSolver
PriceSolver $priceSolver,
SectionStore $sectionStore
) {
parent::__construct($entityManager, $translatorAdmin, $ticketSolver);

@@ -45,17 +49,22 @@ class TicketFormType extends SovTicketFormType
$this->formComponent = $formComponent;
$this->orderShopStore = $orderShopStore;
$this->priceSolver = $priceSolver;
$this->sectionStore = $sectionStore;
}

public function buildForm(FormBuilderInterface $builder, array $options)
{
$isConnected = $this->security->getUser();
$entityName = $this->entityManager->getEntityName(TicketInterface::class);

$sectionList = $this->sectionStore->setMerchant($options['merchant'])->getOnline();
$builder->add(
'section',
EntityType::class,
[
'label'=> 'Espace concerné',
'choices' => $sectionList,
'required' => false,
'placeholder'=> 'Je ne sais pas',
'class' => $this->entityManager->getEntityName(SectionInterface::class),
]
);
@@ -90,7 +99,7 @@ class TicketFormType extends SovTicketFormType
[
'label' => 'Type',
'choices' => $this->translatorAdmin->transChoices(
$this->ticketSolver->getTypeChoices(),
TicketSolver::getTypeChoices(),
'Ticket',
'type'
),
@@ -181,7 +190,8 @@ class TicketFormType extends SovTicketFormType
$resolver->setDefaults(
[
'data_class' => $this->entityManager->getEntityName(TicketInterface::class),
'merchant' => MerchantInterface::class,
]
);
}
}
}

+ 24
- 4
Model/Ticket/TicketModel.php View File

@@ -5,6 +5,7 @@ namespace Lc\CaracoleBundle\Model\Ticket;
use Doctrine\ORM\Mapping as ORM;
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface;
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\SovBundle\Model\Ticket\TicketModel as SovTicketModel;
@@ -18,28 +19,47 @@ abstract class TicketModel extends SovTicketModel implements FilterSectionInterf
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;

/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface")
* @ORM\JoinColumn(nullable=false)
*/
protected $merchant;

/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Order\OrderShopInterface", inversedBy="tickets")
*/
protected $orderShop;

public function getSection(): SectionInterface
public function getSection(): ? SectionInterface
{
return $this->section;
}

public function setSection(SectionInterface $section): self
public function setSection(? SectionInterface $section): self
{
$this->section = $section;

return $this;
}


public function getMerchant(): MerchantInterface
{
return $this->merchant;
}

public function setMerchant( MerchantInterface $merchant): self
{
$this->merchant = $merchant;

return $this;
}

public function getOrderShop(): ?OrderShopInterface
{
return $this->orderShop;

+ 2
- 0
Repository/Ticket/TicketRepositoryQuery.php View File

@@ -2,11 +2,13 @@

namespace Lc\CaracoleBundle\Repository\Ticket;

use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait;
use Lc\SovBundle\Repository\Ticket\TicketRepositoryQuery as SovTicketRepositoryQuery;

class TicketRepositoryQuery extends SovTicketRepositoryQuery
{
use SectionRepositoryQueryTrait;
use MerchantRepositoryQueryTrait;

}

+ 2
- 0
Repository/Ticket/TicketStore.php View File

@@ -2,6 +2,7 @@

namespace Lc\CaracoleBundle\Repository\Ticket;

use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\CaracoleBundle\Repository\StoreTrait;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
@@ -11,6 +12,7 @@ class TicketStore extends SovTicketStore
{
use StoreTrait;
use SectionStoreTrait;
use MerchantStoreTrait;

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{

Loading…
Cancel
Save