{ | { | ||||
return [ | return [ | ||||
'id' => IntegerField::new('id', 'ID')->setSortable(true), | 'id' => IntegerField::new('id', 'ID')->setSortable(true), | ||||
'userLastname' => TextareaField::new('user.lastname')->setSortable(true) | |||||
'userLastname' => TextareaField::new('user.lastname') | |||||
->setCustomOption('filter_fqcn', OrderShopUserLastnameFilter::class), | ->setCustomOption('filter_fqcn', OrderShopUserLastnameFilter::class), | ||||
//->setTemplatePath('@LcShop/backend/default/field/textorempty.html.twig'), | //->setTemplatePath('@LcShop/backend/default/field/textorempty.html.twig'), | ||||
'userFirstname' => TextareaField::new('user.firstname')->setSortable(true) | |||||
'userFirstname' => TextareaField::new('user.firstname') | |||||
->setCustomOption('filter_fqcn', OrderShopUserFirstnameFilter::class), | ->setCustomOption('filter_fqcn', OrderShopUserFirstnameFilter::class), | ||||
//->setTemplatePath('@LcShop/backend/default/field/textorempty.html.twig'), | //->setTemplatePath('@LcShop/backend/default/field/textorempty.html.twig'), | ||||
'userEmail' => TextareaField::new('user.email')->setSortable(true) | |||||
'userEmail' => TextareaField::new('user.email') | |||||
->setCustomOption('filter_fqcn', OrderShopUserEmailFilter::class), | ->setCustomOption('filter_fqcn', OrderShopUserEmailFilter::class), | ||||
//->setTemplatePath('@LcShop/backend/default/field/user.html.twig'), | //->setTemplatePath('@LcShop/backend/default/field/user.html.twig'), | ||||
'total' => NumberField::new('total') | 'total' => NumberField::new('total') |
'birthdate', | 'birthdate', | ||||
'countOrder', | 'countOrder', | ||||
'totalSpent', | 'totalSpent', | ||||
'isSaleAlwaysOpen', | |||||
]; | ]; | ||||
} | } | ||||
->setFormTypeOption('choice_label', function ($choice) { | ->setFormTypeOption('choice_label', function ($choice) { | ||||
return $choice->getTitle() . '[' . $choice->getMerchant() . ']'; | return $choice->getTitle() . '[' . $choice->getMerchant() . ']'; | ||||
}) | }) | ||||
->setSortable(true), | |||||
->setSortable(false), | |||||
'ticketTypesNotification' => ChoiceField::new('ticketTypesNotification') | 'ticketTypesNotification' => ChoiceField::new('ticketTypesNotification') | ||||
->setSortable(true) | ->setSortable(true) | ||||
->setFormTypeOption('expanded', false) | ->setFormTypeOption('expanded', false) |
use Lc\SovBundle\Definition\Field\AbstractFieldDefinition; | use Lc\SovBundle\Definition\Field\AbstractFieldDefinition; | ||||
class UserMerchantFieldDefinition extends AbstractFieldDefinition | class UserMerchantFieldDefinition extends AbstractFieldDefinition | ||||
{ | { | ||||
use MerchantContextTrait; | use MerchantContextTrait; | ||||
public function configureIndex(): array | public function configureIndex(): array | ||||
{ | { | ||||
return [ | return [ | ||||
'id', | |||||
'lastname', | |||||
'firstname', | |||||
'email', | |||||
'credit', | |||||
'id', | |||||
'lastname', | |||||
'firstname', | |||||
'email', | |||||
'credit', | |||||
]; | ]; | ||||
} | } | ||||
public function configureForm(): array | public function configureForm(): array | ||||
{ | { | ||||
return [ | return [ | ||||
'user', | |||||
'user', | |||||
]; | ]; | ||||
} | } | ||||
public function configureFields(): array | public function configureFields(): array | ||||
{ | { | ||||
return [ | return [ | ||||
'id'=> IntegerField::new('id')->onlyOnIndex()->setSortable(true), | |||||
'lastname'=> TextField::new('user.lastname')->setSortable(true) | |||||
->setCustomOption('filter_fqcn', UserMerchantLastnameFilter::class), | |||||
'firstname'=> TextField::new('user.firstname')->setSortable(true) | |||||
->setCustomOption('filter_fqcn', UserMerchantFirstnameFilter::class), | |||||
'email'=> TextField::new('user.email')->setSortable(true) | |||||
->setCustomOption('filter_fqcn', UserMerchantEmailFilter::class), | |||||
'credit'=> NumberField::new('credit')->setSortable(true) | |||||
->setTemplatePath('@LcSov/adminlte/crud/field/amount.html.twig') | |||||
->setCustomOption('appendHtml', '€'), | |||||
'user'=> AssociationField::new('user'), | |||||
'id' => IntegerField::new('id')->onlyOnIndex()->setSortable(true), | |||||
'lastname' => TextField::new('user.lastname') | |||||
->setCustomOption('filter_fqcn', UserMerchantLastnameFilter::class), | |||||
'firstname' => TextField::new('user.firstname') | |||||
->setCustomOption('filter_fqcn', UserMerchantFirstnameFilter::class), | |||||
'email' => TextField::new('user.email') | |||||
->setCustomOption('filter_fqcn', UserMerchantEmailFilter::class), | |||||
'credit' => NumberField::new('credit')->setSortable(true) | |||||
->setTemplatePath('@LcSov/adminlte/crud/field/amount.html.twig') | |||||
->setCustomOption('appendHtml', '€'), | |||||
'user' => AssociationField::new('user'), | |||||
]; | ]; | ||||
} | } |
<?php | |||||
namespace Lc\CaracoleBundle\Field\Filter\Order; | |||||
use Doctrine\ORM\EntityRepository; | |||||
use Doctrine\ORM\QueryBuilder; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; | |||||
use Lc\SovBundle\Field\Filter\AssociationFilter; | |||||
use Lc\SovBundle\Field\Filter\FilterTrait; | |||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||||
use Symfony\Component\Form\Extension\Core\Type\TextType; | |||||
use Symfony\Component\Form\FormBuilderInterface; | |||||
/** | |||||
* @author La clic ! <contact@laclic.fr> | |||||
*/ | |||||
class OrderProductUserEmailFilter | |||||
{ | |||||
use FilterTrait; | |||||
public function buildProperty(FormBuilderInterface $builder, FieldDto $fieldDto, $options = array()) | |||||
{ | |||||
$builder->add( | |||||
$this->getFieldPropertySnake($fieldDto->getProperty()), | |||||
TextType::class, | |||||
array( | |||||
'required' => false, | |||||
'attr' => array( | |||||
'class' => ' input-sm', | |||||
'form' => 'filters-form', | |||||
), | |||||
) | |||||
); | |||||
} | |||||
public function applyFilter(RepositoryQueryInterface $repositoryQuery, FieldDto $fieldDto, $filteredValue = null) | |||||
{ | |||||
if ($filteredValue !== null) { | |||||
$repositoryQuery->filterByEmailUser('%'.$filteredValue.'%'); | |||||
} | |||||
} | |||||
} |
<?php | |||||
namespace Lc\CaracoleBundle\Field\Filter\Order; | |||||
use Doctrine\ORM\EntityRepository; | |||||
use Doctrine\ORM\QueryBuilder; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; | |||||
use Lc\SovBundle\Field\Filter\AssociationFilter; | |||||
use Lc\SovBundle\Field\Filter\FilterTrait; | |||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||||
use Symfony\Component\Form\Extension\Core\Type\TextType; | |||||
use Symfony\Component\Form\FormBuilderInterface; | |||||
/** | |||||
* @author La clic ! <contact@laclic.fr> | |||||
*/ | |||||
class OrderProductUserFirstnameFilter | |||||
{ | |||||
use FilterTrait; | |||||
public function buildProperty(FormBuilderInterface $builder, FieldDto $fieldDto, $options = array()) | |||||
{ | |||||
$builder->add( | |||||
$this->getFieldPropertySnake($fieldDto->getProperty()), | |||||
TextType::class, | |||||
array( | |||||
'required' => false, | |||||
'attr' => array( | |||||
'class' => ' input-sm', | |||||
'form' => 'filters-form', | |||||
), | |||||
) | |||||
); | |||||
} | |||||
public function applyFilter(RepositoryQueryInterface $repositoryQuery, FieldDto $fieldDto, $filteredValue = null) | |||||
{ | |||||
if ($filteredValue !== null) { | |||||
$repositoryQuery->filterByFirstnameUser('%'.$filteredValue.'%'); | |||||
} | |||||
} | |||||
} |
<?php | |||||
namespace Lc\CaracoleBundle\Field\Filter\Order; | |||||
use Doctrine\ORM\EntityRepository; | |||||
use Doctrine\ORM\QueryBuilder; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; | |||||
use Lc\SovBundle\Field\Filter\AssociationFilter; | |||||
use Lc\SovBundle\Field\Filter\FilterTrait; | |||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||||
use Symfony\Component\Form\Extension\Core\Type\TextType; | |||||
use Symfony\Component\Form\FormBuilderInterface; | |||||
/** | |||||
* @author La clic ! <contact@laclic.fr> | |||||
*/ | |||||
class OrderProductUserLastnameFilter | |||||
{ | |||||
use FilterTrait; | |||||
public function buildProperty(FormBuilderInterface $builder, FieldDto $fieldDto, $options = array()) | |||||
{ | |||||
$builder->add( | |||||
$this->getFieldPropertySnake($fieldDto->getProperty()), | |||||
TextType::class, | |||||
array( | |||||
'required' => false, | |||||
'attr' => array( | |||||
'class' => ' input-sm', | |||||
'form' => 'filters-form', | |||||
), | |||||
) | |||||
); | |||||
} | |||||
public function applyFilter(RepositoryQueryInterface $repositoryQuery, FieldDto $fieldDto, $filteredValue = null) | |||||
{ | |||||
if ($filteredValue !== null) { | |||||
$repositoryQuery->filterByLastnameUser('%'.$filteredValue.'%'); | |||||
} | |||||
} | |||||
} |
} | } | ||||
// On sépare le cycleNumber et Year | // On sépare le cycleNumber et Year | ||||
$cycleExplode = explode("a", $filteredValue); | $cycleExplode = explode("a", $filteredValue); | ||||
$cycleNumber = $cycleExplode[0]; | |||||
if (!empty($cycleExplode[0])) { | |||||
$cycleNumber = $cycleExplode[0]; | |||||
} else { | |||||
$cycleNumber = 0; | |||||
} | |||||
if (isset($cycleExplode[1])) { | if (isset($cycleExplode[1])) { | ||||
$year = $cycleExplode[1]; | $year = $cycleExplode[1]; | ||||
if (strlen($year) == 2) { | if (strlen($year) == 2) { |
public function applyFilter(RepositoryQueryInterface $repositoryQuery, FieldDto $fieldDto, $filteredValue = null) | public function applyFilter(RepositoryQueryInterface $repositoryQuery, FieldDto $fieldDto, $filteredValue = null) | ||||
{ | { | ||||
if ($filteredValue !== null) { | if ($filteredValue !== null) { | ||||
$repositoryQuery->filterByDeliveryType('%'.$filteredValue.'%'); | |||||
$repositoryQuery->filterByUserEmail('%'.$filteredValue.'%'); | |||||
} | } | ||||
} | } | ||||
use Lc\SovBundle\Doctrine\Extension\TimestampableTrait; | use Lc\SovBundle\Doctrine\Extension\TimestampableTrait; | ||||
use Lc\SovBundle\Model\User\UserInterface; | use Lc\SovBundle\Model\User\UserInterface; | ||||
/** | |||||
* @ORM\MappedSuperclass | |||||
*/ | |||||
interface UnitInterface | interface UnitInterface | ||||
{ | { | ||||
public function getCreatedBy(): ?UserInterface; | public function getCreatedBy(): ?UserInterface; |
protected bool $isJoinProductFamily = false; | protected bool $isJoinProductFamily = false; | ||||
protected bool $isJoinOrderShop = false; | protected bool $isJoinOrderShop = false; | ||||
protected bool $isJoinOrderStatus = false; | protected bool $isJoinOrderStatus = false; | ||||
protected bool $isJoinUser = false; | |||||
public function __construct(OrderProductRepository $repository, PaginatorInterface $paginator) | public function __construct(OrderProductRepository $repository, PaginatorInterface $paginator) | ||||
{ | { | ||||
public function filterByOrderShop(OrderShopInterface $orderShop): self | public function filterByOrderShop(OrderShopInterface $orderShop): self | ||||
{ | { | ||||
return $this | return $this | ||||
->andWhere('.orderShop = :orderShop') | |||||
->setParameter('orderShop', $orderShop); | |||||
->andWhere('.orderShop = :orderShop') | |||||
->setParameter('orderShop', $orderShop); | |||||
} | } | ||||
public function filterByProduct(ProductInterface $product): self | public function filterByProduct(ProductInterface $product): self | ||||
{ | { | ||||
return $this | return $this | ||||
->andWhere('.product = :product') | |||||
->setParameter('product', $product); | |||||
->andWhere('.product = :product') | |||||
->setParameter('product', $product); | |||||
} | } | ||||
public function filterByUser(UserInterface $user): self | public function filterByUser(UserInterface $user): self | ||||
$this->joinOrderShop(); | $this->joinOrderShop(); | ||||
return $this | return $this | ||||
->andWhere('orderShop.user = :user') | |||||
->setParameter('user', $user); | |||||
->andWhere('orderShop.user = :user') | |||||
->setParameter('user', $user); | |||||
} | |||||
public function filterByEmailUser(string $email): self | |||||
{ | |||||
$this->joinUser(); | |||||
return $this | |||||
->andWhere('user.email LIKE :email') | |||||
->setParameter('email', $email); | |||||
} | |||||
public function filterByFirstnameUser(string $firstname): self | |||||
{ | |||||
$this->joinUser(); | |||||
return $this | |||||
->andWhere('user.firstname LIKE :firstname') | |||||
->setParameter('firstname', $firstname); | |||||
} | |||||
public function filterByLastnameUser(string $lastname): self | |||||
{ | |||||
$this->joinUser(); | |||||
return $this | |||||
->andWhere('user.lastname LIKE :lastname') | |||||
->setParameter('lastname', $lastname); | |||||
} | } | ||||
public function filterBySection(SectionInterface $section): self | public function filterBySection(SectionInterface $section): self | ||||
$this->joinOrderStatus(); | $this->joinOrderStatus(); | ||||
return $this | return $this | ||||
->andWhere('orderStatus.alias IN (:alias)') | |||||
->setParameter('alias', $status); | |||||
->andWhere('orderStatus.alias IN (:alias)') | |||||
->setParameter('alias', $status); | |||||
} | } | ||||
public function selectCount(): self | public function selectCount(): self | ||||
{ | { | ||||
return $this | return $this | ||||
->select('count(orderProduct.id) as total'); | |||||
->select('count(orderProduct.id) as total'); | |||||
} | } | ||||
public function joinProduct(): self | public function joinProduct(): self | ||||
$this->isJoinProduct = true; | $this->isJoinProduct = true; | ||||
return $this | return $this | ||||
->leftJoin('.product', 'product'); | |||||
->leftJoin('.product', 'product'); | |||||
} | } | ||||
return $this; | return $this; | ||||
} | } | ||||
$this->isJoinProductFamily = true; | $this->isJoinProductFamily = true; | ||||
return $this | return $this | ||||
->leftJoin('product.productFamily', 'productFamily'); | |||||
->leftJoin('product.productFamily', 'productFamily'); | |||||
} | } | ||||
return $this; | return $this; | ||||
} | } | ||||
$this->isJoinOrderShop = true; | $this->isJoinOrderShop = true; | ||||
return $this | return $this | ||||
->leftJoin('.orderShop', 'orderShop'); | |||||
->leftJoin('.orderShop', 'orderShop'); | |||||
} | |||||
return $this; | |||||
} | |||||
public function joinUser(): self | |||||
{ | |||||
if (!$this->isJoinOrderShop) { | |||||
$this->joinOrderShop(); | |||||
} | |||||
if (!$this->isJoinUser) { | |||||
$this->isJoinUser = true; | |||||
return $this | |||||
->leftJoin('orderShop.user', 'user'); | |||||
} | } | ||||
return $this; | return $this; | ||||
} | } | ||||
$this->isJoinOrderStatus = true; | $this->isJoinOrderStatus = true; | ||||
return $this | return $this | ||||
->leftJoin('orderShop.orderStatus', 'orderStatus'); | |||||
->leftJoin('orderShop.orderStatus', 'orderStatus'); | |||||
} | } | ||||
return $this; | return $this; | ||||
} | } | ||||
public function filterByMerchant(MerchantInterface $merchant){ | |||||
public function filterByMerchant(MerchantInterface $merchant) | |||||
{ | |||||
$this->joinOrderShop(); | $this->joinOrderShop(); | ||||
$this->joinSection(); | $this->joinSection(); | ||||
return $this->andWhere('section.merchant = :merchant') | return $this->andWhere('section.merchant = :merchant') |
{% set distrubution = field.value %} | |||||
{% set cycleType = distrubution.cycleType %} | |||||
{% if cycleType == "day" %} | |||||
{% set labelCycleType = "J" %} | |||||
{% elseif cycleType == "week" %} | |||||
{% set labelCycleType = "S" %} | |||||
{% elseif cycleType == "month" %} | |||||
{% set labelCycleType = "M" %} | |||||
{% set distribution = field.value %} | |||||
{% if distribution %} | |||||
{% set cycleType = distribution.cycleType %} | |||||
{% if cycleType == "day" %} | |||||
{% set labelCycleType = "J" %} | |||||
{% elseif cycleType == "week" %} | |||||
{% set labelCycleType = "S" %} | |||||
{% elseif cycleType == "month" %} | |||||
{% set labelCycleType = "M" %} | |||||
{% endif %} | |||||
{% endif %} | {% endif %} | ||||
{{ labelCycleType ~ distrubution.cycleNumber }}A{{ distrubution.year|slice(2,2) }} | |||||
{{ labelCycleType ~ distribution.cycleNumber }}A{{ distribution.year|slice(2,2) }} |