diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php index 5dae4c0ef..3fc975147 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php @@ -17,6 +17,7 @@ use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter; use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; +use Chill\PersonBundle\Export\Declarations as PersonDeclarations; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query; @@ -34,7 +35,6 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface public function buildForm(FormBuilderInterface $builder) { - // TODO: Implement buildForm() method. } public function getAllowedFormattersTypes(): array @@ -55,7 +55,7 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface public function getLabels($key, array $values, $data) { if ('export_avg_activity_duration' !== $key) { - throw new LogicException("the key {$key} is not used by this export"); + throw new \LogicException("the key {$key} is not used by this export"); } return static fn ($value) => '_header' === $value ? 'Average activities linked to an accompanying period duration' : $value; @@ -83,10 +83,12 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $qb = $this->repository->createQueryBuilder('activity') - ->join('activity.accompanyingPeriod', 'acp'); + $qb = $this->repository->createQueryBuilder('activity'); - $qb->select('AVG(activity.durationTime) as export_avg_activity_duration'); + $qb + ->join('activity.accompanyingPeriod', 'acp') + ->select('AVG(activity.durationTime) as export_avg_activity_duration') + ->andWhere($qb->expr()->isNotNull('activity.durationTime')); return $qb; } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php index 560ae8754..69533a09d 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php @@ -17,6 +17,7 @@ use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter; use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; +use Chill\PersonBundle\Export\Declarations as PersonDeclarations; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query; @@ -55,7 +56,7 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac public function getLabels($key, array $values, $data) { if ('export_avg_activity_visit_duration' !== $key) { - throw new LogicException("the key {$key} is not used by this export"); + throw new \LogicException("the key {$key} is not used by this export"); } return static fn ($value) => '_header' === $value ? 'Average activities linked to an accompanying period visit duration' : $value; @@ -83,10 +84,13 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $qb = $this->repository->createQueryBuilder('activity') - ->join('activity.accompanyingPeriod', 'acp'); + $qb = $this->repository->createQueryBuilder('activity'); - $qb->select('AVG(activity.travelTime) as export_avg_activity_visit_duration'); + $qb + ->join('activity.accompanyingPeriod', 'acp') + ->select('AVG(activity.travelTime) as export_avg_activity_visit_duration') + ->andWhere($qb->expr()->isNotNull('activity.travelTime')) + ; return $qb; } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php index 5c85046ae..e9dbaff29 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php @@ -17,6 +17,7 @@ use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter; use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; +use Chill\PersonBundle\Export\Declarations as PersonDeclarations; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query; @@ -55,7 +56,7 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface public function getLabels($key, array $values, $data) { if ('export_sum_activity_duration' !== $key) { - throw new LogicException("the key {$key} is not used by this export"); + throw new \LogicException("the key {$key} is not used by this export"); } return static fn ($value) => '_header' === $value ? 'Sum activities linked to an accompanying period duration' : $value; @@ -89,7 +90,8 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface $qb->join('activity.accompanyingPeriod', 'acp'); } - $qb->select('SUM(activity.durationTime) as export_sum_activity_duration'); + $qb->select('SUM(activity.durationTime) as export_sum_activity_duration') + ->andWhere($qb->expr()->isNotNull('activity.durationTime')); return $qb; } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php index af1a0c30a..d41994562 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php @@ -17,6 +17,7 @@ use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter; use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; +use Chill\PersonBundle\Export\Declarations as PersonDeclarations; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query; @@ -55,7 +56,7 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac public function getLabels($key, array $values, $data) { if ('export_sum_activity_visit_duration' !== $key) { - throw new LogicException("the key {$key} is not used by this export"); + throw new \LogicException("the key {$key} is not used by this export"); } return static fn ($value) => '_header' === $value ? 'Sum activities linked to an accompanying period visit duration' : $value; @@ -89,7 +90,8 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac $qb->join('activity.accompanyingPeriod', 'acp'); } - $qb->select('SUM(activity.travelTime) as export_sum_activity_visit_duration'); + $qb->select('SUM(activity.travelTime) as export_sum_activity_visit_duration') + ->andWhere($qb->expr()->isNotNull('activity.travelTime')); return $qb; } diff --git a/src/Bundle/ChillMainBundle/Export/ExportManager.php b/src/Bundle/ChillMainBundle/Export/ExportManager.php index df14a8ac8..ba15d0cc0 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportManager.php +++ b/src/Bundle/ChillMainBundle/Export/ExportManager.php @@ -536,8 +536,8 @@ class ExportManager . 'an ExportInterface.'); } - if (null === $centers || [] === $centers) { - // we want to try if at least one center is reachable + if (null === $centers || [] !== $centers) { + // we want to try if at least one center is reachabler return [] !== $this->authorizationHelper->getReachableCenters( $this->user, $role diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php index 240da475e..2343b2bab 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php @@ -16,6 +16,7 @@ use Chill\MainBundle\Form\Type\ChillDateType; use Chill\PersonBundle\Export\Declarations; use DateTime; use Doctrine\DBAL\Types\Types; +use Doctrine\ORM\Query\Expr; use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; @@ -39,39 +40,23 @@ class ChildrenNumberAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('composition', $qb->getAllAliases(), true)) { - $qb->join('household.compositions', 'composition'); + if (!in_array('composition_children', $qb->getAllAliases(), true)) { + $clause = $qb->expr()->andX( + $qb->expr()->lte('composition_children.startDate', ':ondate_composition_children'), + $qb->expr()->orX( + $qb->expr()->gt('composition_children.endDate', ':ondate_composition_children'), + $qb->expr()->isNull('composition_children.endDate') + ) + ); + + $qb->leftJoin('household.compositions', 'composition_children', Expr\Join::WITH, $clause); } - $qb->addSelect('composition.numberOfChildren AS childrennumber_aggregator'); + $qb + ->addSelect('composition_children.numberOfChildren AS childrennumber_aggregator') + ->addGroupBy('childrennumber_aggregator'); - $groupBy = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('childrennumber_aggregator'); - } else { - $qb->groupBy('childrennumber_aggregator'); - } - - // add date in where clause - $where = $qb->getDQLPart('where'); - - $clause = $qb->expr()->andX( - $qb->expr()->lte('composition.startDate', ':ondate'), - $qb->expr()->orX( - $qb->expr()->gt('composition.endDate', ':ondate'), - $qb->expr()->isNull('composition.endDate') - ) - ); - - if ($where instanceof Andx) { - $where->add($clause); - } else { - $where = $qb->expr()->andX($clause); - } - - $qb->add('where', $where); - $qb->setParameter('ondate', $data['on_date'], Types::DATE_MUTABLE); + $qb->setParameter('ondate_composition_children', $data['on_date'], Types::DATE_MUTABLE); } public function applyOn(): string @@ -93,12 +78,11 @@ class ChildrenNumberAggregator implements AggregatorInterface return 'Number of children'; } - return $this->translator->trans( - 'household_composition.numberOfChildren children in household', - [ - 'numberOfChildren' => $value, - ] - ); + if (null === $value) { + return ''; + } + + return $value; }; } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php index fdb18e951..7e10ea429 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php @@ -18,6 +18,7 @@ use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Repository\Household\HouseholdCompositionTypeRepository; use DateTime; use Doctrine\DBAL\Types\Types; +use Doctrine\ORM\Query\Expr; use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; @@ -44,39 +45,23 @@ class CompositionAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('composition', $qb->getAllAliases(), true)) { - $qb->join('household.compositions', 'composition'); + if (!in_array('composition_type', $qb->getAllAliases(), true)) { + $clause = $qb->expr()->andX( + $qb->expr()->lte('composition_type.startDate', ':ondate_composition_type'), + $qb->expr()->orX( + $qb->expr()->gt('composition_type.endDate', ':ondate_composition_type'), + $qb->expr()->isNull('composition_type.endDate') + ) + ); + + $qb->leftJoin('household.compositions', 'composition_type', Expr\Join::WITH, $clause); } - $qb->addSelect('IDENTITY(composition.householdCompositionType) AS composition_aggregator'); + $qb + ->addSelect('IDENTITY(composition_type.householdCompositionType) AS composition_aggregator') + ->addGroupBy('composition_aggregator'); - $groupBy = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('composition_aggregator'); - } else { - $qb->groupBy('composition_aggregator'); - } - - // add date in where clause - $where = $qb->getDQLPart('where'); - - $clause = $qb->expr()->andX( - $qb->expr()->lte('composition.startDate', ':ondate'), - $qb->expr()->orX( - $qb->expr()->gt('composition.endDate', ':ondate'), - $qb->expr()->isNull('composition.endDate') - ) - ); - - if ($where instanceof Andx) { - $where->add($clause); - } else { - $where = $qb->expr()->andX($clause); - } - - $qb->add('where', $where); - $qb->setParameter('ondate', $data['on_date'], Types::DATE_MUTABLE); + $qb->setParameter('ondate_composition_type', $data['on_date'], Types::DATE_MUTABLE); } public function applyOn(): string @@ -98,6 +83,10 @@ class CompositionAggregator implements AggregatorInterface return 'Composition'; } + if (null === $value) { + return ''; + } + $c = $this->typeRepository->find($value); return $this->translatableStringHelper->localize( diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php index 37d50bf51..fc96b9e6b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php @@ -40,7 +40,7 @@ final class ActionTypeAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('acpwsocialaction', $qb->getAllAliases(), true)) { - $qb->join('acpw.socialAction', 'acpwsocialaction'); + $qb->leftJoin('acpw.socialAction', 'acpwsocialaction'); } $qb->addSelect('acpwsocialaction.id as action_type_aggregator'); diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php index aeced53d7..48075c38b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php @@ -35,6 +35,10 @@ class GoalResultAggregator implements AggregatorInterface public function getLabels($key, array $values, $data) { return function ($value) use ($key): string { + if (null === $value) { + return ''; + } + switch ($key) { case 'goal_aggregator': @@ -107,25 +111,16 @@ class GoalResultAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('goal', $qb->getAllAliases(), true)) { - $qb->join('acpw.goals', 'goal'); + $qb->leftJoin('acpw.goals', 'goal'); } if (!in_array('goalresult', $qb->getAllAliases(), true)) { - $qb->join('goal.results', 'goalresult'); + $qb->leftJoin('goal.results', 'goalresult'); } $qb->addSelect('IDENTITY(goal.goal) as goal_aggregator'); $qb->addSelect('goalresult.id as result_aggregator'); - - $groupBy = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('goal_aggregator'); - } else { - $qb->groupBy('goal_aggregator'); - } - - $qb->addGroupBy('result_aggregator'); + $qb->addGroupBy('goal_aggregator')->addGroupBy('result_aggregator'); } /** @@ -135,4 +130,4 @@ class GoalResultAggregator implements AggregatorInterface { return Declarations::SOCIAL_WORK_ACTION_TYPE; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php index 054b0ab55..4b190e0a5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php @@ -38,7 +38,7 @@ final class ResultAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('result', $qb->getAllAliases(), true)) { - $qb->join('acpw.results', 'result'); + $qb->leftJoin('acpw.results', 'result'); } $qb->addSelect('result.id AS acpw_result_aggregator'); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php index 18ddbaea1..106084e4f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php @@ -106,8 +106,7 @@ class CountHousehold implements ExportInterface, GroupedExportInterface $qb->join('member.household', 'household'); } - - $qb->select('COUNT(DISTINCT member.household) AS export_result'); + $qb->select('COUNT(DISTINCT household.id) AS export_result'); return $qb; } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php index 3d00ed36b..1ca78d669 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/HouseholdFilters/CompositionFilter.php @@ -18,6 +18,7 @@ use Chill\PersonBundle\Entity\Household\HouseholdCompositionType; use Chill\PersonBundle\Export\Declarations; use DateTime; use Doctrine\DBAL\Types\Types; +use Doctrine\ORM\Query\Expr; use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; @@ -41,32 +42,24 @@ class CompositionFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('composition', $qb->getAllAliases(), true)) { - $qb->join('household.compositions', 'composition'); + if (!in_array('composition_type_filter', $qb->getAllAliases(), true)) { + $clause = + $qb->expr()->andX( + $qb->expr()->lte('composition_type_filter.startDate', ':ondate_composition_type_filter'), + $qb->expr()->orX( + $qb->expr()->gt('composition_type_filter.endDate', ':ondate_composition_type_filter'), + $qb->expr()->isNull('composition_type_filter.endDate') + ) + ); + + $qb->join('household.compositions', 'composition', Expr\Join::WITH, $clause); } - $where = $qb->getDQLPart('where'); + $whereClause = $qb->expr()->in('composition_type_filter.householdCompositionType', ':compositions'); - $clause = $qb->expr()->andX( - $qb->expr()->in('composition.householdCompositionType', ':compositions'), - $qb->expr()->andX( - $qb->expr()->lte('composition.startDate', ':ondate'), - $qb->expr()->orX( - $qb->expr()->gt('composition.endDate', ':ondate'), - $qb->expr()->isNull('composition.endDate') - ) - ) - ); - - if ($where instanceof Andx) { - $where->add($clause); - } else { - $where = $qb->expr()->andX($clause); - } - - $qb->add('where', $where); + $qb->andWhere($whereClause); $qb->setParameter('compositions', $data['accepted_composition']); - $qb->setParameter('ondate', $data['on_date'], Types::DATE_MUTABLE); + $qb->setParameter('ondate_composition_type_filter', $data['on_date'], Types::DATE_MUTABLE); } public function applyOn(): string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php index c96fd680f..2770ae82f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php @@ -56,10 +56,17 @@ class ResidentialAddressAtThirdpartyFilter implements FilterInterface } $where = $qb->getDQLPart('where'); + $clause = $qb->expr()->andX( $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) { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php index 482312143..7c07121e1 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Export\Filter\PersonFilters; use Chill\MainBundle\Export\FilterInterface; +use Chill\MainBundle\Form\Type\ChillDateType; use Chill\PersonBundle\Entity\Person\ResidentialAddress; use Chill\PersonBundle\Export\Declarations; use Doctrine\ORM\Query\Expr; @@ -36,7 +37,17 @@ class ResidentialAddressAtUserFilter implements FilterInterface } $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) { $where->add($clause); @@ -44,6 +55,7 @@ class ResidentialAddressAtUserFilter implements FilterInterface $where = $qb->expr()->andX($clause); } + $qb->setParameter('date', $data['date_calc']); $qb->add('where', $where); } @@ -54,7 +66,10 @@ class ResidentialAddressAtUserFilter implements FilterInterface 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') diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 557a6a24b..c94b4963d 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -339,8 +339,8 @@ Fields to include in export: Champs à inclure dans l'export Address valid at this date: Addresse valide à cette date List duplicates: Liste des doublons Create a list of duplicate people: Créer la liste des personnes détectées comme doublons. -Count people participating in an accompanying course by various parameters.: Nombre de personnes concernées par un parcours -Count people participating in an accompanying course: Nombre de personnes concernés par un parcours +Count people participating in an accompanying course: Nombre de personnes concernées par un parcours +Count people participating in an accompanying course by various parameters.: Compte le nombre de personnes concernées par un parcours Exports of accompanying courses: Exports des parcours d'accompagnement Count accompanying courses: Nombre de parcours