public function configureFields(string $pageName): iterable | public function configureFields(string $pageName): iterable | ||||
{ | { | ||||
yield IdField::new('id')->hideOnForm(); | |||||
yield ChoiceField::new('type')->setChoices( | |||||
array( | |||||
$this->translatorAdmin->transField( | |||||
'typeOptions.'.CreditHistoryModel::TYPE_CREDIT, | |||||
'CreditHistory' | |||||
) => CreditHistoryModel::TYPE_CREDIT, | |||||
$this->translatorAdmin->transField( | |||||
'typeOptions.'.CreditHistoryModel::TYPE_DEBIT, | |||||
'CreditHistory' | |||||
) => CreditHistoryModel::TYPE_DEBIT, | |||||
) | |||||
); | |||||
yield MoneyField::new('amount')->setCurrency('EUR'); | |||||
yield DateField::new('paidAt'); | |||||
yield ChoiceField::new('meanPayment')->setChoices( | |||||
array( | |||||
$this->translatorAdmin->transField( | |||||
'meanPaymentOptions.'.CreditHistoryModel::MEAN_PAYMENT_CASH, | |||||
'CreditHistory' | |||||
) => CreditHistoryModel::MEAN_PAYMENT_CASH, | |||||
$this->translatorAdmin->transField( | |||||
'meanPaymentOptions.'.CreditHistoryModel::MEAN_PAYMENT_CHEQUE, | |||||
'CreditHistory' | |||||
) => CreditHistoryModel::MEAN_PAYMENT_CHEQUE, | |||||
$this->translatorAdmin->transField( | |||||
'meanPaymentOptions.'.CreditHistoryModel::MEAN_PAYMENT_CREDIT, | |||||
'CreditHistory' | |||||
) => CreditHistoryModel::MEAN_PAYMENT_CREDIT, | |||||
$this->translatorAdmin->transField( | |||||
'meanPaymentOptions.'.CreditHistoryModel::MEAN_PAYMENT_CREDIT_CARD, | |||||
'CreditHistory' | |||||
) => CreditHistoryModel::MEAN_PAYMENT_CREDIT_CARD, | |||||
$this->translatorAdmin->transField( | |||||
'meanPaymentOptions.'.CreditHistoryModel::MEAN_PAYMENT_TRANSFER, | |||||
'CreditHistory' | |||||
) => CreditHistoryModel::MEAN_PAYMENT_TRANSFER, | |||||
) | |||||
);; | |||||
yield TextField::new('reference'); | |||||
yield TextField::new('comment'); | |||||
return [ | |||||
IdField::new('id')->hideOnForm(), | |||||
ChoiceField::new('type')->setChoices( | |||||
array( | |||||
$this->translatorAdmin->transField( | |||||
'typeOptions.'.CreditHistoryModel::TYPE_CREDIT, | |||||
'CreditHistory' | |||||
) => CreditHistoryModel::TYPE_CREDIT, | |||||
$this->translatorAdmin->transField( | |||||
'typeOptions.'.CreditHistoryModel::TYPE_DEBIT, | |||||
'CreditHistory' | |||||
) => CreditHistoryModel::TYPE_DEBIT, | |||||
) | |||||
), | |||||
MoneyField::new('amount')->setCurrency('EUR'), | |||||
DateField::new('paidAt'), | |||||
ChoiceField::new('meanPayment')->setChoices( | |||||
array( | |||||
$this->translatorAdmin->transField( | |||||
'meanPaymentOptions.'.CreditHistoryModel::MEAN_PAYMENT_CASH, | |||||
'CreditHistory' | |||||
) => CreditHistoryModel::MEAN_PAYMENT_CASH, | |||||
$this->translatorAdmin->transField( | |||||
'meanPaymentOptions.'.CreditHistoryModel::MEAN_PAYMENT_CHEQUE, | |||||
'CreditHistory' | |||||
) => CreditHistoryModel::MEAN_PAYMENT_CHEQUE, | |||||
$this->translatorAdmin->transField( | |||||
'meanPaymentOptions.'.CreditHistoryModel::MEAN_PAYMENT_CREDIT, | |||||
'CreditHistory' | |||||
) => CreditHistoryModel::MEAN_PAYMENT_CREDIT, | |||||
$this->translatorAdmin->transField( | |||||
'meanPaymentOptions.'.CreditHistoryModel::MEAN_PAYMENT_CREDIT_CARD, | |||||
'CreditHistory' | |||||
) => CreditHistoryModel::MEAN_PAYMENT_CREDIT_CARD, | |||||
$this->translatorAdmin->transField( | |||||
'meanPaymentOptions.'.CreditHistoryModel::MEAN_PAYMENT_TRANSFER, | |||||
'CreditHistory' | |||||
) => CreditHistoryModel::MEAN_PAYMENT_TRANSFER, | |||||
) | |||||
), | |||||
TextField::new('reference'), | |||||
TextField::new('comment'), | |||||
]; | |||||
} | } | ||||
public function createIndexQueryBuilder( | public function createIndexQueryBuilder( |
use EasyCorp\Bundle\EasyAdminBundle\Config\Action; | use EasyCorp\Bundle\EasyAdminBundle\Config\Action; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; | use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Filters; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore; | use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; | use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Event\AfterCrudActionEvent; | use EasyCorp\Bundle\EasyAdminBundle\Event\AfterCrudActionEvent; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Exception\InsufficientEntityPermissionException; | use EasyCorp\Bundle\EasyAdminBundle\Exception\InsufficientEntityPermissionException; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Factory\EntityFactory; | use EasyCorp\Bundle\EasyAdminBundle\Factory\EntityFactory; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\ArrayField; | use EasyCorp\Bundle\EasyAdminBundle\Field\ArrayField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Filter\BooleanFilter; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; | use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; | use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Security\Permission; | use EasyCorp\Bundle\EasyAdminBundle\Security\Permission; | ||||
if ($entities) { | if ($entities) { | ||||
foreach ($entities as $entity) { | foreach ($entities as $entity) { | ||||
foreach ($entity->getActions() as $action) { | foreach ($entity->getActions() as $action) { | ||||
if ($action->getName('credit_history')) { | |||||
if ($action->getName() == 'credit_history') { | |||||
$url = $adminUrlGenerator | $url = $adminUrlGenerator | ||||
->setController($creditControllerFqcn) | ->setController($creditControllerFqcn) | ||||
->set('userMerchantId', $entity->getInstance()->getId()) | ->set('userMerchantId', $entity->getInstance()->getId()) | ||||
public function configureFields(string $pageName): iterable | public function configureFields(string $pageName): iterable | ||||
{ | { | ||||
yield TextField::new('user.email'); | |||||
yield TextField::new('user.lastname'); | |||||
yield TextField::new('user.firstname'); | |||||
yield BooleanField::new('active'); | |||||
yield BooleanField::new('creditActive'); | |||||
$fields = [ | |||||
TextField::new('user.email'), | |||||
TextField::new('user.lastname'), | |||||
TextField::new('user.firstname'), | |||||
BooleanField::new('active'), | |||||
BooleanField::new('creditActive'), | |||||
AssociationField::new('user'), | |||||
]; | |||||
if ($this->isGranted('ROLE_SUPER_ADMIN')) { | if ($this->isGranted('ROLE_SUPER_ADMIN')) { | ||||
yield ArrayField::new('roles'); | |||||
$fields[] = ArrayField::new('roles'); | |||||
} | } | ||||
return $fields; | |||||
} | |||||
public function configureFilters(Filters $filters): Filters | |||||
{ | |||||
return $filters | |||||
->add(BooleanFilter::new('active')) | |||||
; | |||||
} | } | ||||
public function new(AdminContext $context): Response | public function new(AdminContext $context): Response |
*/ | */ | ||||
protected $orderShop; | protected $orderShop; | ||||
public function getChoicesType(): array | |||||
public function getTypeChoices(): array | |||||
{ | { | ||||
$choices = parent::getChoicesType(); | |||||
$choices = parent::getTypeChoices(); | |||||
$choicesProduct = [ | $choicesProduct = [ | ||||
'entity.Ticket.fields.typeOptions.' . TicketModel::TYPE_PRODUCT_UNAVAILABLE => TicketModel::TYPE_PRODUCT_UNAVAILABLE, | |||||
'entity.Ticket.fields.typeOptions.' . TicketModel::TYPE_PRODUCT_ERROR => TicketModel::TYPE_PRODUCT_ERROR | |||||
TicketModel::TYPE_PRODUCT_UNAVAILABLE, | |||||
TicketModel::TYPE_PRODUCT_ERROR | |||||
]; | ]; | ||||
return array_merge($choices, $choicesProduct); | return array_merge($choices, $choicesProduct); |