Преглед изворни кода

filter distribution

packProduct
Charly пре 3 година
родитељ
комит
3553cabad0
11 измењених фајлова са 232 додато и 51 уклоњено
  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 Прегледај датотеку

@@ -51,13 +51,13 @@ class OrderShopFieldDefinition extends AbstractFieldDefinition
{
return [
'id' => IntegerField::new('id', 'ID')->setSortable(true),
'userLastname' => TextareaField::new('user.lastname')->setSortable(true)
'userLastname' => TextareaField::new('user.lastname')
->setCustomOption('filter_fqcn', OrderShopUserLastnameFilter::class),
//->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),
//->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),
//->setTemplatePath('@LcShop/backend/default/field/user.html.twig'),
'total' => NumberField::new('total')

+ 2
- 1
Definition/Field/User/UserFieldDefinition.php Прегледај датотеку

@@ -47,6 +47,7 @@ class UserFieldDefinition extends SovUserFieldDefinition
'birthdate',
'countOrder',
'totalSpent',
'isSaleAlwaysOpen',
];
}

@@ -85,7 +86,7 @@ class UserFieldDefinition extends SovUserFieldDefinition
->setFormTypeOption('choice_label', function ($choice) {
return $choice->getTitle() . '[' . $choice->getMerchant() . ']';
})
->setSortable(true),
->setSortable(false),
'ticketTypesNotification' => ChoiceField::new('ticketTypesNotification')
->setSortable(true)
->setFormTypeOption('expanded', false)

+ 17
- 19
Definition/Field/User/UserMerchantFieldDefinition.php Прегледај датотеку

@@ -13,7 +13,6 @@ use Lc\CaracoleBundle\Field\Filter\User\UserMerchantLastnameFilter;
use Lc\SovBundle\Definition\Field\AbstractFieldDefinition;



class UserMerchantFieldDefinition extends AbstractFieldDefinition
{
use MerchantContextTrait;
@@ -21,36 +20,35 @@ class UserMerchantFieldDefinition extends AbstractFieldDefinition
public function configureIndex(): array
{
return [
'id',
'lastname',
'firstname',
'email',
'credit',
'id',
'lastname',
'firstname',
'email',
'credit',
];
}

public function configureForm(): array
{
return [
'user',
'user',
];
}

public function configureFields(): array
{

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 Прегледај датотеку

@@ -0,0 +1,45 @@
<?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 Прегледај датотеку

@@ -0,0 +1,45 @@
<?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 Прегледај датотеку

@@ -0,0 +1,45 @@
<?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 Прегледај датотеку

@@ -53,7 +53,11 @@ class OrderShopDistributionFilter
}
// On sépare le cycleNumber et Year
$cycleExplode = explode("a", $filteredValue);
$cycleNumber = $cycleExplode[0];
if (!empty($cycleExplode[0])) {
$cycleNumber = $cycleExplode[0];
} else {
$cycleNumber = 0;
}
if (isset($cycleExplode[1])) {
$year = $cycleExplode[1];
if (strlen($year) == 2) {

+ 1
- 1
Field/Filter/Order/OrderShopUserEmailFilter.php Прегледај датотеку

@@ -38,7 +38,7 @@ class OrderShopUserEmailFilter
public function applyFilter(RepositoryQueryInterface $repositoryQuery, FieldDto $fieldDto, $filteredValue = null)
{
if ($filteredValue !== null) {
$repositoryQuery->filterByDeliveryType('%'.$filteredValue.'%');
$repositoryQuery->filterByUserEmail('%'.$filteredValue.'%');
}
}


+ 0
- 3
Model/Config/UnitInterface.php Прегледај датотеку

@@ -11,9 +11,6 @@ use Lc\SovBundle\Doctrine\Extension\DevAliasTrait;
use Lc\SovBundle\Doctrine\Extension\TimestampableTrait;
use Lc\SovBundle\Model\User\UserInterface;

/**
* @ORM\MappedSuperclass
*/
interface UnitInterface
{
public function getCreatedBy(): ?UserInterface;

+ 58
- 14
Repository/Order/OrderProductRepositoryQuery.php Прегледај датотеку

@@ -19,6 +19,7 @@ class OrderProductRepositoryQuery extends AbstractRepositoryQuery
protected bool $isJoinProductFamily = false;
protected bool $isJoinOrderShop = false;
protected bool $isJoinOrderStatus = false;
protected bool $isJoinUser = false;

public function __construct(OrderProductRepository $repository, PaginatorInterface $paginator)
{
@@ -28,15 +29,15 @@ class OrderProductRepositoryQuery extends AbstractRepositoryQuery
public function filterByOrderShop(OrderShopInterface $orderShop): self
{
return $this
->andWhere('.orderShop = :orderShop')
->setParameter('orderShop', $orderShop);
->andWhere('.orderShop = :orderShop')
->setParameter('orderShop', $orderShop);
}

public function filterByProduct(ProductInterface $product): self
{
return $this
->andWhere('.product = :product')
->setParameter('product', $product);
->andWhere('.product = :product')
->setParameter('product', $product);
}

public function filterByUser(UserInterface $user): self
@@ -44,8 +45,35 @@ class OrderProductRepositoryQuery extends AbstractRepositoryQuery
$this->joinOrderShop();

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
@@ -60,15 +88,15 @@ class OrderProductRepositoryQuery extends AbstractRepositoryQuery
$this->joinOrderStatus();

return $this
->andWhere('orderStatus.alias IN (:alias)')
->setParameter('alias', $status);
->andWhere('orderStatus.alias IN (:alias)')
->setParameter('alias', $status);
}


public function selectCount(): self
{
return $this
->select('count(orderProduct.id) as total');
->select('count(orderProduct.id) as total');
}

public function joinProduct(): self
@@ -77,7 +105,7 @@ class OrderProductRepositoryQuery extends AbstractRepositoryQuery
$this->isJoinProduct = true;

return $this
->leftJoin('.product', 'product');
->leftJoin('.product', 'product');
}
return $this;
}
@@ -89,7 +117,7 @@ class OrderProductRepositoryQuery extends AbstractRepositoryQuery
$this->isJoinProductFamily = true;

return $this
->leftJoin('product.productFamily', 'productFamily');
->leftJoin('product.productFamily', 'productFamily');
}
return $this;
}
@@ -100,7 +128,22 @@ class OrderProductRepositoryQuery extends AbstractRepositoryQuery
$this->isJoinOrderShop = true;

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;
}
@@ -123,12 +166,13 @@ class OrderProductRepositoryQuery extends AbstractRepositoryQuery
$this->isJoinOrderStatus = true;

return $this
->leftJoin('orderShop.orderStatus', 'orderStatus');
->leftJoin('orderShop.orderStatus', 'orderStatus');
}
return $this;
}

public function filterByMerchant(MerchantInterface $merchant){
public function filterByMerchant(MerchantInterface $merchant)
{
$this->joinOrderShop();
$this->joinSection();
return $this->andWhere('section.merchant = :merchant')

+ 11
- 9
Resources/views/admin/order/field/distribution.html.twig Прегледај датотеку

@@ -1,11 +1,13 @@
{% 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 %}

{{ labelCycleType ~ distrubution.cycleNumber }}A{{ distrubution.year|slice(2,2) }}
{{ labelCycleType ~ distribution.cycleNumber }}A{{ distribution.year|slice(2,2) }}

Loading…
Откажи
Сачувај