Browse Source

Connexion via prestashop

feature/export_comptable
Fab 4 years ago
parent
commit
eb806fdcbe
2 changed files with 14 additions and 0 deletions
  1. +5
    -0
      ShopBundle/Form/Backend/ReductionCommon/UsersFilterType.php
  2. +9
    -0
      ShopBundle/Repository/UserRepository.php

+ 5
- 0
ShopBundle/Form/Backend/ReductionCommon/UsersFilterType.php View File

@@ -4,6 +4,7 @@ namespace Lc\ShopBundle\Form\Backend\ReductionCommon;

use Doctrine\ORM\EntityManagerInterface;

use Doctrine\ORM\EntityRepository;
use Lc\ShopBundle\Context\ReductionCatalogInterface;
use Lc\ShopBundle\Context\UserInterface;
use Lc\ShopBundle\Repository\GroupUserRepository;
@@ -42,6 +43,10 @@ class UsersFilterType extends AbstractType
$builder->add('users', EntityType::class, [
'class' => $userClass->name,
'required' => false,
'query_builder'=> function (EntityRepository $er) {
$query = $er->findByMerchantQuery()->leftJoin('e.groupUsers', 'groupUsers')->addSelect('groupUsers');
return $query;
},
'expanded' => false,
'multiple' => true,
'translation_domain'=>'lcshop',

+ 9
- 0
ShopBundle/Repository/UserRepository.php View File

@@ -2,6 +2,7 @@

namespace Lc\ShopBundle\Repository;

use Doctrine\ORM\QueryBuilder;
use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\UserInterface;

@@ -18,6 +19,14 @@ class UserRepository extends BaseRepository implements DefaultRepositoryInterfac
return UserInterface::class;
}

public function findByMerchantQuery() :QueryBuilder
{
return $this->createQueryBuilder('e')
->innerJoin('e.userMerchants', "userMerchants")
->andWhere('userMerchants.merchant = :currentMerchant')
->setParameter('currentMerchant', $this->merchantUtils->getMerchantCurrent()->getId()) ;
}

public function findAllByNewsletter($newsletter)
{
return $this->createQueryBuilder('e')

Loading…
Cancel
Save