Browse Source

Crud PointSale

ideas
Guillaume 3 years ago
parent
commit
1ed7790286
6 changed files with 58 additions and 7 deletions
  1. +6
    -0
      Controller/AdminControllerTrait.php
  2. +1
    -1
      Controller/Merchant/MerchantAdminController.php
  3. +37
    -0
      Controller/PointSale/PointSaleAdminController.php
  4. +0
    -1
      Controller/Section/SectionAdminController.php
  5. +7
    -5
      Repository/PointSale/PointSaleRepository.php
  6. +7
    -0
      Resources/translations/admin.fr.yaml

+ 6
- 0
Controller/AdminControllerTrait.php View File

use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection; use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection;
use EasyCorp\Bundle\EasyAdminBundle\Collection\FilterCollection; use EasyCorp\Bundle\EasyAdminBundle\Collection\FilterCollection;
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface;
use Lc\CaracoleBundle\Doctrine\Extension\FilterMultipleMerchantsInterface;
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface;
use Lc\CaracoleBundle\Factory\User\UserMerchantFactory; use Lc\CaracoleBundle\Factory\User\UserMerchantFactory;
use Lc\CaracoleBundle\Resolver\MerchantResolver; use Lc\CaracoleBundle\Resolver\MerchantResolver;
$queryBuilder->setParameter('merchant', $this->get('merchant_resolver')->getCurrent()); $queryBuilder->setParameter('merchant', $this->get('merchant_resolver')->getCurrent());
} }


if ($this->isInstanceOf(FilterMultipleMerchantsInterface::class)) {
$queryBuilder->andWhere(':merchant MEMBER OF entity.merchants');
$queryBuilder->setParameter('merchant', $this->get('merchant_resolver')->getCurrent());
}

if ($this->isInstanceOf(FilterSectionInterface::class)) { if ($this->isInstanceOf(FilterSectionInterface::class)) {
$queryBuilder->andWhere('entity.section = :section'); $queryBuilder->andWhere('entity.section = :section');
$queryBuilder->setParameter('section', $this->get('section_resolver')->getCurrent()); $queryBuilder->setParameter('section', $this->get('section_resolver')->getCurrent());

+ 1
- 1
Controller/Merchant/MerchantAdminController.php View File



FormField::addPanel('address'), FormField::addPanel('address'),
AddressField::new('address') AddressField::new('address')
->setRequired(true),
], ],
$panel $panel
); );

+ 37
- 0
Controller/PointSale/PointSaleAdminController.php View File

<?php

namespace Lc\CaracoleBundle\Controller\PointSale;

use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Field\Address\AddressField;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Field\StatusField;

abstract class PointSaleAdminController extends AbstractAdminController
{
use AdminControllerTrait;

public function configureFields(string $pageName): iterable
{
$panel = parent::configureFields($pageName);

return array_merge(
[
FormField::addPanel('general'),
TextField::new('title'),
NumberField::new('orderAmountMin')
->setCustomOption('appendHtml','€')
->hideOnIndex(),
StatusField::new('status'),
FormField::addPanel('address'),
AddressField::new('address')
->setRequired(true)
],
$panel
);
}

}

+ 0
- 1
Controller/Section/SectionAdminController.php View File



namespace Lc\CaracoleBundle\Controller\Section; namespace Lc\CaracoleBundle\Controller\Section;


use Doctrine\ORM\EntityManagerInterface;
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField; use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;

+ 7
- 5
Repository/PointSale/PointSaleRepository.php View File



namespace Lc\CaracoleBundle\Repository\PointSale; namespace Lc\CaracoleBundle\Repository\PointSale;


use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Lc\CaracoleBundle\Repository\RepositoryTrait;
use Lc\SovBundle\Repository\AbstractRepository;
use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface; use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface;


/** /**
* @method PointSaleInterface[] findAll() * @method PointSaleInterface[] findAll()
* @method PointSaleInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) * @method PointSaleInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/ */
class PointSaleRepository extends ServiceEntityRepository
class PointSaleRepository extends AbstractRepository
{ {
public function __construct(ManagerRegistry $registry)
use RepositoryTrait;

public function getInterfaceClass()
{ {
parent::__construct($registry, PointSaleInterface::class);
return PointSaleInterface::class;
} }
} }

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



menu: menu:
pointsale: Points de vente
setting: Paramètres setting: Paramètres
setting_merchant: Marchand setting_merchant: Marchand
setting_section: Section setting_section: Section
address: Adresse address: Adresse
merchant: Marchand merchant: Marchand
taxRate: Règle de taxe taxRate: Règle de taxe
PointSale:
label: Point de vente
label_plurial: Points de vente
fields:
orderAmountMin: Montant minimum de commande

Address: Address:
fields: fields:
type: Type type: Type

Loading…
Cancel
Save