Bladeren bron

Système Filtres SovBundle

packProduct
Fab 3 jaren geleden
bovenliggende
commit
15ff04b2a2
3 gewijzigde bestanden met toevoegingen van 76 en 57 verwijderingen
  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 Bestand weergeven

@@ -91,52 +91,54 @@ abstract class CreditHistoryAdminController extends AbstractAdminController

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(

+ 24
- 7
Controller/User/UserMerchantAdminController.php Bestand weergeven

@@ -8,6 +8,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection;
use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Config\Filters;
use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore;
use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
use EasyCorp\Bundle\EasyAdminBundle\Event\AfterCrudActionEvent;
@@ -16,7 +17,9 @@ use EasyCorp\Bundle\EasyAdminBundle\Exception\ForbiddenActionException;
use EasyCorp\Bundle\EasyAdminBundle\Exception\InsufficientEntityPermissionException;
use EasyCorp\Bundle\EasyAdminBundle\Factory\EntityFactory;
use EasyCorp\Bundle\EasyAdminBundle\Field\ArrayField;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use EasyCorp\Bundle\EasyAdminBundle\Filter\BooleanFilter;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider;
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
use EasyCorp\Bundle\EasyAdminBundle\Security\Permission;
@@ -55,7 +58,8 @@ abstract class UserMerchantAdminController extends AbstractAdminController
if ($entities) {
foreach ($entities as $entity) {
foreach ($entity->getActions() as $action) {
if ($action->getName('credit_history')) {

if ($action->getName() == 'credit_history') {
$url = $adminUrlGenerator
->setController($creditControllerFqcn)
->set('userMerchantId', $entity->getInstance()->getId())
@@ -87,14 +91,27 @@ abstract class UserMerchantAdminController extends AbstractAdminController

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')) {
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

+ 4
- 4
Model/Ticket/TicketModel.php Bestand weergeven

@@ -27,12 +27,12 @@ abstract class TicketModel extends SovTicketModel implements FilterMerchantInter
*/
protected $orderShop;

public function getChoicesType(): array
public function getTypeChoices(): array
{
$choices = parent::getChoicesType();
$choices = parent::getTypeChoices();
$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);

Laden…
Annuleren
Opslaan