|
|
@@ -18,6 +18,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Exception\InsufficientEntityPermissionExcept |
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Factory\EntityFactory; |
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\ArrayField; |
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; |
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; |
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; |
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Filter\BooleanFilter; |
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; |
|
|
@@ -50,7 +51,7 @@ abstract class UserMerchantAdminController extends AbstractAdminController |
|
|
|
$adminUrlGenerator = $this->get(AdminUrlGenerator::class); |
|
|
|
|
|
|
|
$creditControllerFqcn = $context->getCrudControllers()->findCrudFqcnByEntityFqcn( |
|
|
|
$this->get(EntityManagerInterface::class)->getEntityName(CreditHistoryInterface::class) |
|
|
|
$this->get(EntityManagerInterface::class)->getEntityName(CreditHistoryInterface::class) |
|
|
|
); |
|
|
|
|
|
|
|
if ($entities) { |
|
|
@@ -58,9 +59,9 @@ abstract class UserMerchantAdminController extends AbstractAdminController |
|
|
|
foreach ($entity->getActions() as $action) { |
|
|
|
if ($action->getName() == 'credit_history') { |
|
|
|
$url = $adminUrlGenerator |
|
|
|
->setController($creditControllerFqcn) |
|
|
|
->set('userMerchantId', $entity->getInstance()->getId()) |
|
|
|
->generateUrl(); |
|
|
|
->setController($creditControllerFqcn) |
|
|
|
->set('userMerchantId', $entity->getInstance()->getId()) |
|
|
|
->generateUrl(); |
|
|
|
$action->setLinkUrl($url); |
|
|
|
} |
|
|
|
} |
|
|
@@ -73,14 +74,14 @@ abstract class UserMerchantAdminController extends AbstractAdminController |
|
|
|
$actions = parent::configureActions($actions); |
|
|
|
|
|
|
|
$creditAction = Action::new('credit_history', false, 'fa fa-cash-register') |
|
|
|
->linkToCrudAction('credit_history') |
|
|
|
->setHtmlAttributes( |
|
|
|
array( |
|
|
|
'data-toggle' => 'tooltip', |
|
|
|
'title' => $this->get(TranslatorAdmin::class)->transAction('credit'), |
|
|
|
) |
|
|
|
->linkToCrudAction('credit_history') |
|
|
|
->setHtmlAttributes( |
|
|
|
array( |
|
|
|
'data-toggle' => 'tooltip', |
|
|
|
'title' => $this->get(TranslatorAdmin::class)->transAction('credit'), |
|
|
|
) |
|
|
|
->setCssClass('btn btn-sm btn-success'); |
|
|
|
) |
|
|
|
->setCssClass('btn btn-sm btn-success'); |
|
|
|
$actions->add(Crud::PAGE_INDEX, $creditAction); |
|
|
|
|
|
|
|
return $actions; |
|
|
@@ -89,12 +90,13 @@ abstract class UserMerchantAdminController extends AbstractAdminController |
|
|
|
public function configureFields(string $pageName): iterable |
|
|
|
{ |
|
|
|
$fields = [ |
|
|
|
TextField::new('user.email'), |
|
|
|
TextField::new('user.lastname'), |
|
|
|
TextField::new('user.firstname'), |
|
|
|
BooleanField::new('active'), |
|
|
|
BooleanField::new('creditActive'), |
|
|
|
AssociationField::new('user'), |
|
|
|
IntegerField::new('id')->onlyOnIndex()->setSortable(true), |
|
|
|
TextField::new('user.lastname')->setSortable(true), |
|
|
|
TextField::new('user.firstname')->setSortable(true), |
|
|
|
TextField::new('user.email')->setSortable(true), |
|
|
|
BooleanField::new('active')->setSortable(true), |
|
|
|
BooleanField::new('creditActive')->hideOnIndex(), |
|
|
|
AssociationField::new('user'), |
|
|
|
]; |
|
|
|
|
|
|
|
if ($this->isGranted('ROLE_SUPER_ADMIN')) { |
|
|
@@ -107,7 +109,7 @@ abstract class UserMerchantAdminController extends AbstractAdminController |
|
|
|
public function configureFilters(Filters $filters): Filters |
|
|
|
{ |
|
|
|
return $filters |
|
|
|
->add(BooleanFilter::new('active')); |
|
|
|
->add(BooleanFilter::new('active')); |
|
|
|
} |
|
|
|
|
|
|
|
public function new(AdminContext $context): Response |
|
|
@@ -116,8 +118,8 @@ abstract class UserMerchantAdminController extends AbstractAdminController |
|
|
|
$merchantResolver = $this->get(MerchantResolver::class); |
|
|
|
|
|
|
|
$userMerchant = $this->get(UserMerchantContainer::class) |
|
|
|
->getFactory() |
|
|
|
->create($merchantResolver->getCurrent()); |
|
|
|
->getFactory() |
|
|
|
->create($merchantResolver->getCurrent()); |
|
|
|
|
|
|
|
$form = $this->createForm(UserMerchantFormType::class, $userMerchant); |
|
|
|
|
|
|
@@ -159,16 +161,19 @@ abstract class UserMerchantAdminController extends AbstractAdminController |
|
|
|
|
|
|
|
return $this->redirect($url); |
|
|
|
} else { |
|
|
|
$this->addFlash('error', $this->get(TranslatorAdmin::class)->trans('form.user_merchant.already_exist')); |
|
|
|
$this->addFlash( |
|
|
|
'error', |
|
|
|
$this->get(TranslatorAdmin::class)->trans('form.user_merchant.already_exist') |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return $this->render( |
|
|
|
'@LcCaracole/admin/user/new_usermerchant.html.twig', |
|
|
|
[ |
|
|
|
'form' => $form->createView(), |
|
|
|
] |
|
|
|
'@LcCaracole/admin/user/new_usermerchant.html.twig', |
|
|
|
[ |
|
|
|
'form' => $form->createView(), |
|
|
|
] |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
@@ -204,10 +209,10 @@ abstract class UserMerchantAdminController extends AbstractAdminController |
|
|
|
} |
|
|
|
|
|
|
|
return $this->render( |
|
|
|
'@LcCaracole/admin/user/edit_usermerchant.html.twig', |
|
|
|
[ |
|
|
|
'form' => $form->createView(), |
|
|
|
] |
|
|
|
'@LcCaracole/admin/user/edit_usermerchant.html.twig', |
|
|
|
[ |
|
|
|
'form' => $form->createView(), |
|
|
|
] |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
@@ -220,8 +225,8 @@ abstract class UserMerchantAdminController extends AbstractAdminController |
|
|
|
} |
|
|
|
|
|
|
|
if (!$this->isGranted( |
|
|
|
Permission::EA_EXECUTE_ACTION, |
|
|
|
['action' => Action::DETAIL, 'entity' => $context->getEntity()] |
|
|
|
Permission::EA_EXECUTE_ACTION, |
|
|
|
['action' => Action::DETAIL, 'entity' => $context->getEntity()] |
|
|
|
)) { |
|
|
|
throw new ForbiddenActionException($context); |
|
|
|
} |
|
|
@@ -230,25 +235,25 @@ abstract class UserMerchantAdminController extends AbstractAdminController |
|
|
|
} |
|
|
|
|
|
|
|
$options['action'] = $adminUrlGenerator |
|
|
|
->setController($context->getCrud()->getControllerFqcn()) |
|
|
|
->setAction('add_credit') |
|
|
|
->setEntityId($context->getEntity()->getInstance()->getId()) |
|
|
|
->set('userMerchant', 'niche') |
|
|
|
->generateUrl(); |
|
|
|
->setController($context->getCrud()->getControllerFqcn()) |
|
|
|
->setAction('add_credit') |
|
|
|
->setEntityId($context->getEntity()->getInstance()->getId()) |
|
|
|
->set('userMerchant', 'niche') |
|
|
|
->generateUrl(); |
|
|
|
$addCreditHistoryForm = $this->createForm(CreditHistoryFormType::class, null, $options)->createView(); |
|
|
|
|
|
|
|
|
|
|
|
return $this->render( |
|
|
|
'@LcCaracole/admin/credit/credit_detail.html.twig', |
|
|
|
[ |
|
|
|
'pageName' => Crud::PAGE_DETAIL, |
|
|
|
'entity' => $context->getEntity(), |
|
|
|
'batch_actions' => array(), |
|
|
|
'entities' => array(), |
|
|
|
'filters' => array(), |
|
|
|
'paginator' => array(), |
|
|
|
'add_credit_history_form' => $addCreditHistoryForm, |
|
|
|
] |
|
|
|
'@LcCaracole/admin/credit/credit_detail.html.twig', |
|
|
|
[ |
|
|
|
'pageName' => Crud::PAGE_DETAIL, |
|
|
|
'entity' => $context->getEntity(), |
|
|
|
'batch_actions' => array(), |
|
|
|
'entities' => array(), |
|
|
|
'filters' => array(), |
|
|
|
'paginator' => array(), |
|
|
|
'add_credit_history_form' => $addCreditHistoryForm, |
|
|
|
] |
|
|
|
); |
|
|
|
} |
|
|
|
|