Skip to content

Commit

Permalink
Prida do vyhledavani take vyhledavani podle jmena uvedeneho v billing…
Browse files Browse the repository at this point in the history
… nebo shipping adres, dale mimo stavajici vyhledavani podle emailu uzivatele prida vyhledavani podle emailu z objednavky. refs Sylius#5036
  • Loading branch information
divaska committed Feb 21, 2017
1 parent 58cb93b commit e224aa4
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions src/Sylius/Bundle/CoreBundle/Form/Type/Filter/OrderFilterType.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,31 @@ public function buildForm(FormBuilderInterface $builder, array $options)

// Concatenate user.firstname, ' ' and user.lastanme and put it in a LIKE %username% query
$qb
->leftJoin('o.shippingAddress', 'a')
->leftJoin('o.billingAddress', 'b')
->andWhere(
$qb->expr()->like(
$qb->expr()->concat(
$qb->expr()->concat('user.firstName', $qb->expr()->literal(' ')),
'user.lastName'
$qb->expr()->orX(
$qb->expr()->like(
$qb->expr()->concat(
$qb->expr()->concat('user.firstName', $qb->expr()->literal(' ')),
'user.lastName'
),
':username'
),
':username'
$qb->expr()->like(
$qb->expr()->concat(
$qb->expr()->concat('a.firstName', $qb->expr()->literal(' ')),
'a.lastName'
),
':username'
),
$qb->expr()->like(
$qb->expr()->concat(
$qb->expr()->concat('b.firstName', $qb->expr()->literal(' ')),
'b.lastName'
),
':username'
)
)
)
->setParameter('username', '%' . $values['value'] . '%');
Expand All @@ -226,7 +244,12 @@ public function buildForm(FormBuilderInterface $builder, array $options)
/** @var QueryBuilder $qb */
$qb = $filterQuery->getQueryBuilder();
$qb
->andWhere($qb->expr()->like('user.email', ':usermail'))
->andWhere(
$qb->expr()->orX(
$qb->expr()->like('user.email', ':usermail'),
$qb->expr()->like('o.email', ':usermail')
)
)
->setParameter('usermail', '%' . $values['value'] . '%');
return $qb;
},
Expand Down

0 comments on commit e224aa4

Please sign in to comment.