|
|
|
|
|
|
|
|
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\AssociationField; |
|
|
|
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; |
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; |
|
|
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; |
|
|
use EasyCorp\Bundle\EasyAdminBundle\Filter\BooleanFilter; |
|
|
use EasyCorp\Bundle\EasyAdminBundle\Filter\BooleanFilter; |
|
|
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; |
|
|
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; |
|
|
|
|
|
|
|
|
$adminUrlGenerator = $this->get(AdminUrlGenerator::class); |
|
|
$adminUrlGenerator = $this->get(AdminUrlGenerator::class); |
|
|
|
|
|
|
|
|
$creditControllerFqcn = $context->getCrudControllers()->findCrudFqcnByEntityFqcn( |
|
|
$creditControllerFqcn = $context->getCrudControllers()->findCrudFqcnByEntityFqcn( |
|
|
$this->get(EntityManagerInterface::class)->getEntityName(CreditHistoryInterface::class) |
|
|
|
|
|
|
|
|
$this->get(EntityManagerInterface::class)->getEntityName(CreditHistoryInterface::class) |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
if ($entities) { |
|
|
if ($entities) { |
|
|
|
|
|
|
|
|
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) |
|
|
|
|
|
->set('userMerchantId', $entity->getInstance()->getId()) |
|
|
|
|
|
->generateUrl(); |
|
|
|
|
|
|
|
|
->setController($creditControllerFqcn) |
|
|
|
|
|
->set('userMerchantId', $entity->getInstance()->getId()) |
|
|
|
|
|
->generateUrl(); |
|
|
$action->setLinkUrl($url); |
|
|
$action->setLinkUrl($url); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$actions = parent::configureActions($actions); |
|
|
$actions = parent::configureActions($actions); |
|
|
|
|
|
|
|
|
$creditAction = Action::new('credit_history', false, 'fa fa-cash-register') |
|
|
$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); |
|
|
$actions->add(Crud::PAGE_INDEX, $creditAction); |
|
|
|
|
|
|
|
|
return $actions; |
|
|
return $actions; |
|
|
|
|
|
|
|
|
public function configureFields(string $pageName): iterable |
|
|
public function configureFields(string $pageName): iterable |
|
|
{ |
|
|
{ |
|
|
$fields = [ |
|
|
$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')) { |
|
|
if ($this->isGranted('ROLE_SUPER_ADMIN')) { |
|
|
|
|
|
|
|
|
public function configureFilters(Filters $filters): Filters |
|
|
public function configureFilters(Filters $filters): Filters |
|
|
{ |
|
|
{ |
|
|
return $filters |
|
|
return $filters |
|
|
->add(BooleanFilter::new('active')); |
|
|
|
|
|
|
|
|
->add(BooleanFilter::new('active')); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function new(AdminContext $context): Response |
|
|
public function new(AdminContext $context): Response |
|
|
|
|
|
|
|
|
$merchantResolver = $this->get(MerchantResolver::class); |
|
|
$merchantResolver = $this->get(MerchantResolver::class); |
|
|
|
|
|
|
|
|
$userMerchant = $this->get(UserMerchantContainer::class) |
|
|
$userMerchant = $this->get(UserMerchantContainer::class) |
|
|
->getFactory() |
|
|
|
|
|
->create($merchantResolver->getCurrent()); |
|
|
|
|
|
|
|
|
->getFactory() |
|
|
|
|
|
->create($merchantResolver->getCurrent()); |
|
|
|
|
|
|
|
|
$form = $this->createForm(UserMerchantFormType::class, $userMerchant); |
|
|
$form = $this->createForm(UserMerchantFormType::class, $userMerchant); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $this->redirect($url); |
|
|
return $this->redirect($url); |
|
|
} else { |
|
|
} 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( |
|
|
return $this->render( |
|
|
'@LcCaracole/admin/user/new_usermerchant.html.twig', |
|
|
|
|
|
[ |
|
|
|
|
|
'form' => $form->createView(), |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
'@LcCaracole/admin/user/new_usermerchant.html.twig', |
|
|
|
|
|
[ |
|
|
|
|
|
'form' => $form->createView(), |
|
|
|
|
|
] |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return $this->render( |
|
|
return $this->render( |
|
|
'@LcCaracole/admin/user/edit_usermerchant.html.twig', |
|
|
|
|
|
[ |
|
|
|
|
|
'form' => $form->createView(), |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
'@LcCaracole/admin/user/edit_usermerchant.html.twig', |
|
|
|
|
|
[ |
|
|
|
|
|
'form' => $form->createView(), |
|
|
|
|
|
] |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (!$this->isGranted( |
|
|
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); |
|
|
throw new ForbiddenActionException($context); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$options['action'] = $adminUrlGenerator |
|
|
$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(); |
|
|
$addCreditHistoryForm = $this->createForm(CreditHistoryFormType::class, null, $options)->createView(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $this->render( |
|
|
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, |
|
|
|
|
|
] |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|