Ver código fonte

filter distribution

packProduct
Charly 3 anos atrás
pai
commit
3553cabad0
11 arquivos alterados com 232 adições e 51 exclusões
  1. +3
    -3
      Definition/Field/Order/OrderShopFieldDefinition.php
  2. +2
    -1
      Definition/Field/User/UserFieldDefinition.php
  3. +17
    -19
      Definition/Field/User/UserMerchantFieldDefinition.php
  4. +45
    -0
      Field/Filter/Order/OrderProductUserEmailFilter.php
  5. +45
    -0
      Field/Filter/Order/OrderProductUserFirstnameFilter.php
  6. +45
    -0
      Field/Filter/Order/OrderProductUserLastnameFilter.php
  7. +5
    -1
      Field/Filter/Order/OrderShopDistributionFilter.php
  8. +1
    -1
      Field/Filter/Order/OrderShopUserEmailFilter.php
  9. +0
    -3
      Model/Config/UnitInterface.php
  10. +58
    -14
      Repository/Order/OrderProductRepositoryQuery.php
  11. +11
    -9
      Resources/views/admin/order/field/distribution.html.twig

+ 3
- 3
Definition/Field/Order/OrderShopFieldDefinition.php Ver arquivo

{ {
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')

+ 2
- 1
Definition/Field/User/UserFieldDefinition.php Ver arquivo

'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)

+ 17
- 19
Definition/Field/User/UserMerchantFieldDefinition.php Ver arquivo

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'),


]; ];
} }

+ 45
- 0
Field/Filter/Order/OrderProductUserEmailFilter.php Ver arquivo

<?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.'%');
}
}

}

+ 45
- 0
Field/Filter/Order/OrderProductUserFirstnameFilter.php Ver arquivo

<?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.'%');
}
}

}

+ 45
- 0
Field/Filter/Order/OrderProductUserLastnameFilter.php Ver arquivo

<?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.'%');
}
}

}

+ 5
- 1
Field/Filter/Order/OrderShopDistributionFilter.php Ver arquivo

} }
// 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) {

+ 1
- 1
Field/Filter/Order/OrderShopUserEmailFilter.php Ver arquivo

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.'%');
} }
} }



+ 0
- 3
Model/Config/UnitInterface.php Ver arquivo

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;

+ 58
- 14
Repository/Order/OrderProductRepositoryQuery.php Ver arquivo

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')

+ 11
- 9
Resources/views/admin/order/field/distribution.html.twig Ver arquivo

{% 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) }}

Carregando…
Cancelar
Salvar