瀏覽代碼

Mis à jour import & correctif

packProduct
Fabien Normand 3 年之前
父節點
當前提交
5d1d30586d
共有 7 個檔案被更改,包括 189 行新增4 行删除
  1. +1
    -1
      Builder/Order/OrderShopBuilder.php
  2. +9
    -3
      Definition/Field/Order/OrderShopFieldDefinition.php
  3. +45
    -0
      Field/Filter/Order/OrderShopUserEmailFilter.php
  4. +45
    -0
      Field/Filter/Order/OrderShopUserFirstnameFilter.php
  5. +45
    -0
      Field/Filter/Order/OrderShopUserLastnameFilter.php
  6. +37
    -0
      Repository/Order/OrderShopRepositoryQuery.php
  7. +7
    -0
      Repository/Product/ProductCategoryStore.php

+ 1
- 1
Builder/Order/OrderShopBuilder.php 查看文件

@@ -434,7 +434,7 @@ class OrderShopBuilder
{
$documentFactory = new DocumentFactory();

$document = $documentFactory->create($orderShop->getSection(), DocumentModel::TYPE_INVOICE);
$document = $documentFactory->create($orderShop->getSection()->getMerchant(), DocumentModel::TYPE_INVOICE);

$this->documentBuilder->initFromOrderShop($document, $orderShop);
return $document;

+ 9
- 3
Definition/Field/Order/OrderShopFieldDefinition.php 查看文件

@@ -11,6 +11,9 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Context\MerchantContextTrait;
use Lc\CaracoleBundle\Definition\Field\AbstractFieldDefinition;
use Lc\CaracoleBundle\Field\AssociationField;
use Lc\CaracoleBundle\Field\Filter\Order\OrderShopUserEmailFilter;
use Lc\CaracoleBundle\Field\Filter\Order\OrderShopUserFirstnameFilter;
use Lc\CaracoleBundle\Field\Filter\Order\OrderShopUserLastnameFilter;
use Lc\CaracoleBundle\Repository\Section\SectionStore;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Component\Form\Extension\Core\Type\TextType;
@@ -41,11 +44,14 @@ class OrderShopFieldDefinition extends AbstractFieldDefinition
{
return [
'id' => IntegerField::new('id', 'ID')->setSortable(true),
'userLastname' => TextareaField::new('user.lastname')->setSortable(true),
'userLastname' => TextareaField::new('user.lastname')->setSortable(true)
->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')->setSortable(true)
->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')->setSortable(true)
->setCustomOption('filter_fqcn', OrderShopUserEmailFilter::class),
//->setTemplatePath('@LcShop/backend/default/field/user.html.twig'),
'total' => NumberField::new('total')
->setTemplatePath('@LcCaracole/admin/order/field/total.html.twig'),

+ 45
- 0
Field/Filter/Order/OrderShopUserEmailFilter.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 OrderShopUserEmailFilter
{
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->filterByUserEmail('%'.$filteredValue.'%');
}
}

}

+ 45
- 0
Field/Filter/Order/OrderShopUserFirstnameFilter.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 OrderShopUserFirstnameFilter
{
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->filterByUserFirstname('%'.$filteredValue.'%');
}
}

}

+ 45
- 0
Field/Filter/Order/OrderShopUserLastnameFilter.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 OrderShopUserLastnameFilter
{
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->filterByUserLastname('%'.$filteredValue.'%');
}
}

}

+ 37
- 0
Repository/Order/OrderShopRepositoryQuery.php 查看文件

@@ -26,6 +26,7 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
protected bool $isJoinOrderReductionCarts = false;
protected bool $isJoinOrderStatus = false;
protected bool $isJoinMerchant = false;
protected bool $isJoinUser = false;
protected bool $isJoinComplementaryOrderShops = false;
protected bool $isJoinDeliveryPointSale = false;

@@ -84,6 +85,17 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
->select('count(DISTINCT(r.id)) as total');
}

public function joinUser(): self
{
if (!$this->isJoinUser) {
$this->isJoinUser = true;

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

public function filterByUser(UserInterface $user): self
{
return $this
@@ -91,6 +103,31 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
->setParameter('user', $user);
}

public function filterByUserEmail(string $email): self
{
$this->joinUser();
return $this
->andWhere('user.email LIKE :email')
->setParameter('email', $email);
}

public function filterByUserLastname(string $lastname): self
{
$this->joinUser();
return $this
->andWhere('user.lastname LIKE :lastname')
->setParameter('lastname', $lastname);
}


public function filterByUserFirstname(string $firstname): self
{
$this->joinUser();
return $this
->andWhere('user.firstname LIKE :firstname')
->setParameter('firstname', $firstname);
}

public function filterByAlias(array $status): self
{
$this->joinOrderStatus();

+ 7
- 0
Repository/Product/ProductCategoryStore.php 查看文件

@@ -41,4 +41,11 @@ class ProductCategoryStore extends AbstractStore
$query->filterIsParent();
return $query->findOne();
}

public function getAllByDevAlias(string $devAlias): array
{
$query = $this->createDefaultQuery();
$query->filterByDevAlias($devAlias);
return $query->find();
}
}

Loading…
取消
儲存