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