|
|
|
|
|
|
|
|
namespace Lc\CaracoleBundle\Definition\Field\User; |
|
|
namespace Lc\CaracoleBundle\Definition\Field\User; |
|
|
|
|
|
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField; |
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField; |
|
|
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; |
|
|
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; |
|
|
|
|
|
|
|
|
protected GroupUserStore $groupUserStore; |
|
|
protected GroupUserStore $groupUserStore; |
|
|
protected NewsletterStore $newsletterStore; |
|
|
protected NewsletterStore $newsletterStore; |
|
|
|
|
|
|
|
|
public function __construct(TranslatorAdmin $translatorAdmin, RolesDefinition $rolesDefinition, GroupUserStore $groupUserStore, NewsletterStore $newsletterStore) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
public function __construct( |
|
|
|
|
|
TranslatorAdmin $translatorAdmin, |
|
|
|
|
|
RolesDefinition $rolesDefinition, |
|
|
|
|
|
GroupUserStore $groupUserStore, |
|
|
|
|
|
NewsletterStore $newsletterStore |
|
|
|
|
|
) { |
|
|
parent::__construct($translatorAdmin, $rolesDefinition); |
|
|
parent::__construct($translatorAdmin, $rolesDefinition); |
|
|
|
|
|
|
|
|
$this->groupUserStore = $groupUserStore; |
|
|
$this->groupUserStore = $groupUserStore; |
|
|
$this->newsletterStore = $newsletterStore; |
|
|
$this->newsletterStore = $newsletterStore; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function configureIndex(): array |
|
|
|
|
|
{ |
|
|
|
|
|
return [ |
|
|
|
|
|
'id', |
|
|
|
|
|
'gender', |
|
|
|
|
|
'lastname', |
|
|
|
|
|
'firstname', |
|
|
|
|
|
'email', |
|
|
|
|
|
'groupUsers', |
|
|
|
|
|
'birthdate', |
|
|
|
|
|
'countOrder', |
|
|
|
|
|
'totalSpent', |
|
|
|
|
|
]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public function configureForm(): array |
|
|
public function configureForm(): array |
|
|
{ |
|
|
{ |
|
|
return [ |
|
|
return [ |
|
|
'gender', |
|
|
|
|
|
'lastname', |
|
|
|
|
|
'firstname', |
|
|
|
|
|
'email', |
|
|
|
|
|
'phone', |
|
|
|
|
|
'birthdate', |
|
|
|
|
|
'groupUsers', |
|
|
|
|
|
'isSaleAlwaysOpen', |
|
|
|
|
|
'newsletters', |
|
|
|
|
|
'ticketTypesNotification' |
|
|
|
|
|
|
|
|
'gender', |
|
|
|
|
|
'lastname', |
|
|
|
|
|
'firstname', |
|
|
|
|
|
'email', |
|
|
|
|
|
'phone', |
|
|
|
|
|
'birthdate', |
|
|
|
|
|
'groupUsers', |
|
|
|
|
|
'isSaleAlwaysOpen', |
|
|
|
|
|
'newsletters', |
|
|
|
|
|
'ticketTypesNotification', |
|
|
]; |
|
|
]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$groupUsers = $this->groupUserStore->setMerchant($this->merchant)->getAll(); |
|
|
$groupUsers = $this->groupUserStore->setMerchant($this->merchant)->getAll(); |
|
|
$newsletters = $this->newsletterStore->getAll(); |
|
|
$newsletters = $this->newsletterStore->getAll(); |
|
|
|
|
|
|
|
|
return array_merge(parent::configureFields(),[ |
|
|
|
|
|
'isSaleAlwaysOpen' => BooleanField::new('isSaleAlwaysOpen'), |
|
|
|
|
|
'newsletters' => AssociationField::new('newsletters') |
|
|
|
|
|
->setFormTypeOption('choices', $newsletters) |
|
|
|
|
|
->setFormTypeOption('choice_label', function ($choice) { |
|
|
|
|
|
return $choice->getTitle(). '['.$choice->getSection()->getMerchant().']'; |
|
|
|
|
|
}) |
|
|
|
|
|
->setSortable(true), |
|
|
|
|
|
'groupUsers' => AssociationField::new('groupUsers') |
|
|
|
|
|
->setFormTypeOption('choices', $groupUsers) |
|
|
|
|
|
->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' |
|
|
|
|
|
)), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return array_merge(parent::configureFields(), [ |
|
|
|
|
|
'isSaleAlwaysOpen' => BooleanField::new('isSaleAlwaysOpen'), |
|
|
|
|
|
'newsletters' => AssociationField::new('newsletters') |
|
|
|
|
|
->setFormTypeOption('choices', $newsletters) |
|
|
|
|
|
->setFormTypeOption('choice_label', function ($choice) { |
|
|
|
|
|
return $choice->getTitle() . '[' . $choice->getSection()->getMerchant() . ']'; |
|
|
|
|
|
}) |
|
|
|
|
|
->setSortable(true), |
|
|
|
|
|
'groupUsers' => AssociationField::new('groupUsers') |
|
|
|
|
|
->setFormTypeOption('choices', $groupUsers) |
|
|
|
|
|
->setTemplatePath('@LcSov/adminlte/crud/field/association_many.html.twig') |
|
|
|
|
|
->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' |
|
|
|
|
|
) |
|
|
|
|
|
), |
|
|
|
|
|
'countOrder' => NumberField::new('countOrder') |
|
|
|
|
|
->setFormTypeOption('mapped', false) |
|
|
|
|
|
->setCustomOption('filter', false) |
|
|
|
|
|
->setTemplatePath('@LcCaracole/admin/user/field/count_order.html.twig'), |
|
|
|
|
|
'totalSpent' => NumberField::new('totalSpent') |
|
|
|
|
|
->setFormTypeOption('mapped', false) |
|
|
|
|
|
->setCustomOption('filter', false) |
|
|
|
|
|
->setTemplatePath('@LcCaracole/admin/user/field/total_spent.html.twig'), |
|
|
]); |
|
|
]); |
|
|
} |
|
|
} |
|
|
|
|
|
|