mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
GeographicalUnit Filter: add join clauses
This commit is contained in:
parent
d907357748
commit
841eb57144
@ -17,6 +17,7 @@ use Chill\MainBundle\Form\Type\ChillDateType;
|
|||||||
use Chill\PersonBundle\Export\Declarations;
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Doctrine\DBAL\Types\Types;
|
use Doctrine\DBAL\Types\Types;
|
||||||
|
use Doctrine\ORM\Query\Expr;
|
||||||
use Doctrine\ORM\Query\Expr\Andx;
|
use Doctrine\ORM\Query\Expr\Andx;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
@ -41,8 +42,23 @@ class GeographicalUnitStatFilter implements FilterInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
|
if (!in_array('location', $qb->getAllAliases(), true)) {
|
||||||
|
$qb->join('acp.administrativeLocation', 'location');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!in_array('address', $qb->getAllAliases(), true)) {
|
||||||
|
$qb->join('location.address', 'address');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!in_array('geounit', $qb->getAllAliases(), true)) {
|
||||||
|
$qb->join(GeographicalUnit::class, 'geounit', Expr\Join::WITH, 'ST_CONTAINS(address.point, geounit.geom) = TRUE');
|
||||||
|
}
|
||||||
|
|
||||||
$where = $qb->getDQLPart('where');
|
$where = $qb->getDQLPart('where');
|
||||||
$clause = $qb->expr()->eq(1, 1);
|
$clause = $qb->expr()->andX(
|
||||||
|
$qb->expr()->eq($x, ':date'),
|
||||||
|
$qb->expr()->in($x, ':loctype')
|
||||||
|
);
|
||||||
|
|
||||||
if ($where instanceof Andx) {
|
if ($where instanceof Andx) {
|
||||||
$where->add($clause);
|
$where->add($clause);
|
||||||
|
@ -44,12 +44,12 @@ services:
|
|||||||
tags:
|
tags:
|
||||||
- { name: chill.export_filter, alias: accompanyingcourse_step_filter }
|
- { name: chill.export_filter, alias: accompanyingcourse_step_filter }
|
||||||
|
|
||||||
#chill.person.export.filter_geographicalunitstat:
|
chill.person.export.filter_geographicalunitstat:
|
||||||
# class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\GeographicalUnitStatFilter
|
class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\GeographicalUnitStatFilter
|
||||||
# autowire: true
|
autowire: true
|
||||||
# autoconfigure: true
|
autoconfigure: true
|
||||||
# tags:
|
tags:
|
||||||
# - { name: chill.export_filter, alias: accompanyingcourse_geographicalunitstat_filter }
|
- { name: chill.export_filter, alias: accompanyingcourse_geographicalunitstat_filter }
|
||||||
|
|
||||||
chill.person.export.filter_socialaction:
|
chill.person.export.filter_socialaction:
|
||||||
class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\SocialActionFilter
|
class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\SocialActionFilter
|
||||||
@ -171,12 +171,12 @@ services:
|
|||||||
tags:
|
tags:
|
||||||
- { name: chill.export_aggregator, alias: accompanyingcourse_step_aggregator }
|
- { name: chill.export_aggregator, alias: accompanyingcourse_step_aggregator }
|
||||||
|
|
||||||
#chill.person.export.aggregator_geographicalunitstat:
|
chill.person.export.aggregator_geographicalunitstat:
|
||||||
# class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\GeographicalUnitStatAggregator
|
class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\GeographicalUnitStatAggregator
|
||||||
# autowire: true
|
autowire: true
|
||||||
# autoconfigure: true
|
autoconfigure: true
|
||||||
# tags:
|
tags:
|
||||||
# - { name: chill.export_aggregator, alias: accompanyingcourse_geographicalunitstat_aggregator }
|
- { name: chill.export_aggregator, alias: accompanyingcourse_geographicalunitstat_aggregator }
|
||||||
|
|
||||||
chill.person.export.aggregator_socialaction:
|
chill.person.export.aggregator_socialaction:
|
||||||
class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\SocialActionAggregator
|
class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\SocialActionAggregator
|
||||||
|
Loading…
x
Reference in New Issue
Block a user