mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
exports: ResidentialAddressAt ThirdParty/User Filter, improve query (issue637 et issue638)
This commit is contained in:
parent
78e00b8eba
commit
9f2ecff63e
@ -56,10 +56,17 @@ class ResidentialAddressAtThirdpartyFilter implements FilterInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$where = $qb->getDQLPart('where');
|
$where = $qb->getDQLPart('where');
|
||||||
|
|
||||||
$clause = $qb->expr()->andX(
|
$clause = $qb->expr()->andX(
|
||||||
$qb->expr()->isNotNull('resaddr.hostThirdParty'),
|
$qb->expr()->isNotNull('resaddr.hostThirdParty'),
|
||||||
$qb->expr()->between(':date', 'resaddr.startDate', 'resaddr.endDate'),
|
$qb->expr()->in('tpartycat.id', ':type'),
|
||||||
$qb->expr()->in('tpartycat.id', ':type')
|
$qb->expr()->orX(
|
||||||
|
$qb->expr()->between(':date', 'resaddr.startDate', 'resaddr.endDate'),
|
||||||
|
$qb->expr()->andX(
|
||||||
|
$qb->expr()->lte('resaddr.startDate', ':date'),
|
||||||
|
$qb->expr()->isNull('resaddr.endDate')
|
||||||
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($where instanceof Expr\Andx) {
|
if ($where instanceof Expr\Andx) {
|
||||||
|
@ -12,6 +12,7 @@ declare(strict_types=1);
|
|||||||
namespace Chill\PersonBundle\Export\Filter\PersonFilters;
|
namespace Chill\PersonBundle\Export\Filter\PersonFilters;
|
||||||
|
|
||||||
use Chill\MainBundle\Export\FilterInterface;
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
|
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||||
use Chill\PersonBundle\Entity\Person\ResidentialAddress;
|
use Chill\PersonBundle\Entity\Person\ResidentialAddress;
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
use Doctrine\ORM\Query\Expr;
|
use Doctrine\ORM\Query\Expr;
|
||||||
@ -36,7 +37,17 @@ class ResidentialAddressAtUserFilter implements FilterInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$where = $qb->getDQLPart('where');
|
$where = $qb->getDQLPart('where');
|
||||||
$clause = $qb->expr()->isNotNull('resaddr.hostPerson');
|
|
||||||
|
$clause = $qb->expr()->andX(
|
||||||
|
$qb->expr()->isNotNull('resaddr.hostPerson'),
|
||||||
|
$qb->expr()->orX(
|
||||||
|
$qb->expr()->between(':date', 'resaddr.startDate', 'resaddr.endDate'),
|
||||||
|
$qb->expr()->andX(
|
||||||
|
$qb->expr()->lte('resaddr.startDate', ':date'),
|
||||||
|
$qb->expr()->isNull('resaddr.endDate')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
if ($where instanceof Andx) {
|
if ($where instanceof Andx) {
|
||||||
$where->add($clause);
|
$where->add($clause);
|
||||||
@ -44,6 +55,7 @@ class ResidentialAddressAtUserFilter implements FilterInterface
|
|||||||
$where = $qb->expr()->andX($clause);
|
$where = $qb->expr()->andX($clause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$qb->setParameter('date', $data['date_calc']);
|
||||||
$qb->add('where', $where);
|
$qb->add('where', $where);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +66,10 @@ class ResidentialAddressAtUserFilter implements FilterInterface
|
|||||||
|
|
||||||
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
|
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
|
||||||
{
|
{
|
||||||
// No form needed unless validity date should be added ( not specified in doc as a parameter ).
|
$builder->add('date_calc', ChillDateType::class, [
|
||||||
|
'label' => 'Date during which residential address was valid',
|
||||||
|
'data' => new \DateTime('now'),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function describeAction($data, $format = 'string')
|
public function describeAction($data, $format = 'string')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user