Browse Source

Système Filtres SovBundle

packProduct
Fab 3 years ago
parent
commit
15ff04b2a2
3 changed files with 76 additions and 57 deletions
  1. +48
    -46
      Controller/Credit/CreditHistoryAdminController.php
  2. +24
    -7
      Controller/User/UserMerchantAdminController.php
  3. +4
    -4
      Model/Ticket/TicketModel.php

+ 48
- 46
Controller/Credit/CreditHistoryAdminController.php View File



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(

+ 24
- 7
Controller/User/UserMerchantAdminController.php View File

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

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

*/ */
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);

Loading…
Cancel
Save