Browse Source

Merge branch 'develop' of https://forge.laclic.fr/Laclic/CaracoleBundle into develop

packProduct
Guillaume 3 years ago
parent
commit
6299ab4ff0
4 changed files with 92 additions and 85 deletions
  1. +22
    -22
      Controller/PointSale/PointSaleAdminController.php
  2. +17
    -17
      Controller/Product/ProductCategoryAdminController.php
  3. +51
    -46
      Controller/User/UserMerchantAdminController.php
  4. +2
    -0
      Resources/translations/admin.fr.yaml

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

namespace Lc\CaracoleBundle\Controller\PointSale; namespace Lc\CaracoleBundle\Controller\PointSale;


use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\MoneyField;
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 Lc\CaracoleBundle\Container\PointSale\PointSaleContainer; use Lc\CaracoleBundle\Container\PointSale\PointSaleContainer;
use Lc\SovBundle\Controller\AbstractAdminController; use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Field\BooleanField; use Lc\SovBundle\Field\BooleanField;
use Lc\SovBundle\Field\StatusField; use Lc\SovBundle\Field\StatusField;
use Lc\SovBundle\Field\ToggleField;


abstract class PointSaleAdminController extends AbstractAdminController abstract class PointSaleAdminController extends AbstractAdminController
{ {


public function configureFields(string $pageName): iterable public function configureFields(string $pageName): iterable
{ {

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


public function createEntity(string $entityFqcn) public function createEntity(string $entityFqcn)
{ {
return $this->get(PointSaleContainer::class) return $this->get(PointSaleContainer::class)
->getFactory()
->create($this->get(MerchantResolver::class)->getCurrent());
->getFactory()
->create($this->get(MerchantResolver::class)->getCurrent());
} }
} }

+ 17
- 17
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 Lc\CaracoleBundle\Container\Order\OrderShopContainer;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
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\Translation\TranslatorAdmin;
use Lc\SovBundle\Field\ToggleField;


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


],
$this->getSeoPanel(),
$this->getConfPanel()
],
$this->getSeoPanel(),
$this->getConfPanel()
); );
} }



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



+ 2
- 0
Resources/translations/admin.fr.yaml View File

label_plurial: Points de vente label_plurial: Points de vente
fields: fields:
orderAmountMin: Montant minimum de commande orderAmountMin: Montant minimum de commande
isPublic: Public
isDepository: Dépôt


Address: Address:
fields: fields:

Loading…
Cancel
Save