Browse Source

listing

packProduct
Charly 3 years ago
parent
commit
f81de8c38b
3 changed files with 65 additions and 63 deletions
  1. +6
    -6
      Controller/PointSale/PointSaleAdminController.php
  2. +8
    -11
      Controller/Product/ProductCategoryAdminController.php
  3. +51
    -46
      Controller/User/UserMerchantAdminController.php

+ 6
- 6
Controller/PointSale/PointSaleAdminController.php View File

return array_merge( return array_merge(
[ [
FormField::addPanel('general'), FormField::addPanel('general'),
IntegerField::new('id')->onlyOnIndex(),
TextField::new('title'),
MoneyField::new('orderAmountMin')->setCurrency('EUR'),
IntegerField::new('id')->onlyOnIndex()->setSortable(true),
TextField::new('title')->setSortable(true),
MoneyField::new('orderAmountMin')->setCurrency('EUR')->setSortable(true),
NumberField::new('deliveryPrice') NumberField::new('deliveryPrice')
->setCustomOption('appendHtml', '€') ->setCustomOption('appendHtml', '€')
->hideOnIndex(), ->hideOnIndex(),
StatusField::new('status'),
ToggleField::new('isPublic'),
ToggleField::new('isDepository'),
StatusField::new('status')->setSortable(true),
ToggleField::new('isPublic')->setSortable(true),
ToggleField::new('isDepository')->setSortable(true),
FormField::addPanel('address'), FormField::addPanel('address'),
AddressField::new('address') AddressField::new('address')
->setRequired(true) ->setRequired(true)

+ 8
- 11
Controller/Product/ProductCategoryAdminController.php View File



namespace Lc\CaracoleBundle\Controller\Product; namespace Lc\CaracoleBundle\Controller\Product;


//use Lc\CaracoleBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
use Lc\CaracoleBundle\Container\Order\OrderShopContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait; use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Field\Address\AddressField;
use Lc\CaracoleBundle\Repository\Reduction\ReductionCatalogStore;
use Lc\SovBundle\Controller\AbstractAdminController; use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Field\BooleanField;
use Lc\SovBundle\Field\CKEditorField; use Lc\SovBundle\Field\CKEditorField;
use Lc\SovBundle\Field\StatusField; use Lc\SovBundle\Field\StatusField;
use Lc\SovBundle\Field\ToggleField; use Lc\SovBundle\Field\ToggleField;
use Lc\SovBundle\Translation\TranslatorAdmin;


abstract class ProductCategoryAdminController extends AbstractAdminController abstract class ProductCategoryAdminController extends AbstractAdminController
{ {
return array_merge( return array_merge(
[ [
FormField::addPanel('general'), FormField::addPanel('general'),
TextField::new('title'),
NumberField::new('position')->hideOnForm(),
IntegerField::new('id')->onlyOnIndex()->setSortable(true),
TextField::new('title')->setSortable(true),
NumberField::new('position')->hideOnForm()->setSortable(true),
AssociationField::new('parent')->hideOnIndex(), AssociationField::new('parent')->hideOnIndex(),
DateTimeField::new('createdAt')->setFormat('short'),
DateTimeField::new('createdAt')->setFormat('short')->setSortable(true),
CKEditorField::new('description')->hideOnIndex(), CKEditorField::new('description')->hideOnIndex(),
ToggleField::new('saleStatus'),
StatusField::new('status'),
StatusField::new('status')->setSortable(true),
ToggleField::new('saleStatus')->setSortable(true),
ToggleField::new('isEligibleTicketRestaurant')->setSortable(true),


], ],
$this->getSeoPanel(), $this->getSeoPanel(),

+ 51
- 46
Controller/User/UserMerchantAdminController.php View File

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,
]
); );
} }



Loading…
Cancel
Save