diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/CreatorJobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/CreatorJobAggregator.php index 50c4e6f9b..707f2a36a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/CreatorJobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/CreatorJobAggregator.php @@ -13,13 +13,11 @@ namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators; use Chill\MainBundle\Entity\User\UserJobHistory; use Chill\MainBundle\Export\AggregatorInterface; -use Chill\MainBundle\Form\Type\PickRollingDateType; use Chill\MainBundle\Repository\UserJobRepository; -use Chill\MainBundle\Service\RollingDate\RollingDate; -use Chill\MainBundle\Service\RollingDate\RollingDateConverter; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Export\Declarations; use Doctrine\ORM\Query\Expr; +use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; @@ -28,7 +26,6 @@ class CreatorJobAggregator implements AggregatorInterface private const PREFIX = 'acp_agg_creator_job'; public function __construct( - private readonly RollingDateConverter $rollingDateConverter, private readonly UserJobRepository $jobRepository, private readonly TranslatableStringHelper $translatableStringHelper ) {} @@ -43,27 +40,35 @@ class CreatorJobAggregator implements AggregatorInterface $p = self::PREFIX; $qb - ->leftJoin("acp.createdBy", "{$p}_user") ->leftJoin( - UserJobHistory::class, - "{$p}_history", - Expr\Join::WITH, - $qb->expr()->eq("{$p}_history.user", "{$p}_user") - ) - ->andWhere( + "acp.userHistories", "{$p}_userHistory", + Join::WITH, $qb->expr()->andX( - $qb->expr()->lte("{$p}_history.startDate", ":{$p}_at"), - $qb->expr()->orX( - $qb->expr()->isNull("{$p}_history.endDate"), - $qb->expr()->gt("{$p}_history.endDate", ":{$p}_at") + $qb->expr()->eq("{$p}_userHistory.accompanyingPeriod", "acp.id"), + $qb->expr()->andX( + $qb->expr()->gte("COALESCE(acp.endDate, CURRENT_TIMESTAMP)", "{$p}_userHistory.startDate"), + $qb->expr()->orX( + $qb->expr()->isNull("{$p}_userHistory.endDate"), + $qb->expr()->lt("COALESCE(acp.endDate, CURRENT_TIMESTAMP)", "{$p}_userHistory.endDate") + ) ) ) ) - ->addSelect("IDENTITY({$p}_history.job) AS {$p}_select") - ->setParameter( - "{$p}_at", - $this->rollingDateConverter->convert($data['job_at']) + ->leftJoin( + UserJobHistory::class,"{$p}_jobHistory", + Expr\Join::WITH, + $qb->expr()->andX( + $qb->expr()->eq("{$p}_jobHistory.user", "{$p}_userHistory.createdBy"), // et si il est null ? + $qb->expr()->andX( + $qb->expr()->lte("{$p}_jobHistory.startDate", "{$p}_userHistory.startDate"), + $qb->expr()->orX( + $qb->expr()->isNull("{$p}_jobHistory.endDate"), + $qb->expr()->gt("{$p}_jobHistory.endDate", "{$p}_userHistory.startDate") + ) + ) + ) ) + ->addSelect("IDENTITY({$p}_jobHistory.job) AS {$p}_select") ->addGroupBy("{$p}_select"); } @@ -74,15 +79,11 @@ class CreatorJobAggregator implements AggregatorInterface public function buildForm(FormBuilderInterface $builder) { - $builder->add('job_at', PickRollingDateType::class, [ - 'label' => 'export.aggregator.course.by_creator_job.Calc date', - 'required' => true - ]); } public function getFormDefaultData(): array { - return ['job_at' => new RollingDate(RollingDate::T_TODAY)]; + return []; } public function getLabels($key, array $values, $data) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php index abd9feffb..743144fbf 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php @@ -13,13 +13,10 @@ namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators; use Chill\MainBundle\Entity\User\UserScopeHistory; use Chill\MainBundle\Export\AggregatorInterface; -use Chill\MainBundle\Form\Type\PickRollingDateType; use Chill\MainBundle\Repository\ScopeRepositoryInterface; -use Chill\MainBundle\Service\RollingDate\RollingDate; -use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\PersonBundle\Export\Declarations; -use Doctrine\ORM\Query\Expr; +use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\QueryBuilder; use LogicException; use Symfony\Component\Form\FormBuilderInterface; @@ -31,7 +28,6 @@ readonly class ReferrerScopeAggregator implements AggregatorInterface public function __construct( private ScopeRepositoryInterface $scopeRepository, private TranslatableStringHelperInterface $translatableStringHelper, - private RollingDateConverterInterface $rollingDateConverter ) {} public function addRole(): ?string @@ -44,40 +40,35 @@ readonly class ReferrerScopeAggregator implements AggregatorInterface $p = self::PREFIX; $qb - ->leftJoin("acp.userHistories", "{$p}_userHistory") - ->leftJoin("{$p}_userHistory.user", "{$p}_user") ->leftJoin( - UserScopeHistory::class, - "{$p}_scopeHistory", - Expr\Join::WITH, - $qb->expr()->eq("{$p}_scopeHistory.user", "{$p}_user") - ) - ->andWhere( - $qb->expr()->orX( - $qb->expr()->isNull("{$p}_userHistory"), + "acp.userHistories", "{$p}_userHistory", + Join::WITH, + $qb->expr()->andX( + $qb->expr()->eq("{$p}_userHistory.accompanyingPeriod", "acp.id"), $qb->expr()->andX( - $qb->expr()->lte("{$p}_userHistory.startDate", ":{$p}_date_calc"), + $qb->expr()->gte("COALESCE(acp.endDate, CURRENT_TIMESTAMP)", "{$p}_userHistory.startDate"), $qb->expr()->orX( $qb->expr()->isNull("{$p}_userHistory.endDate"), - $qb->expr()->gt("{$p}_userHistory.endDate", ":{$p}_date_calc") + $qb->expr()->lt("COALESCE(acp.endDate, CURRENT_TIMESTAMP)", "{$p}_userHistory.endDate") ) ) ) ) - ->andWhere( + ->leftJoin( + UserScopeHistory::class,"{$p}_scopeHistory", + Join::WITH, $qb->expr()->andX( - $qb->expr()->lte("{$p}_scopeHistory.startDate", ":{$p}_date_calc"), - $qb->expr()->orX( - $qb->expr()->isNull("{$p}_scopeHistory.endDate"), - $qb->expr()->gt("{$p}_scopeHistory.endDate", ":{$p}_date_calc") + $qb->expr()->eq("{$p}_scopeHistory.user", "{$p}_userHistory.user"), + $qb->expr()->andX( + $qb->expr()->lte("{$p}_scopeHistory.startDate", "{$p}_userHistory.startDate"), + $qb->expr()->orX( + $qb->expr()->isNull("{$p}_scopeHistory.endDate"), + $qb->expr()->gt("{$p}_scopeHistory.endDate", "{$p}_userHistory.startDate") + ) ) ) ) - ->setParameter( - "{$p}_date_calc", - $this->rollingDateConverter->convert($data['date_calc']) - ) - ->addSelect("IDENTITY({$p}_scopeHistory.scope) AS {$p}_select") + ->addSelect("IDENTITY({$p}_sh.scope) AS {$p}_select") ->addGroupBy("{$p}_select"); } @@ -88,16 +79,11 @@ readonly class ReferrerScopeAggregator implements AggregatorInterface public function buildForm(FormBuilderInterface $builder) { - $builder - ->add('date_calc', PickRollingDateType::class, [ - 'label' => 'export.aggregator.course.by_user_scope.Computation date for referrer', - 'required' => true, - ]) - ; } + public function getFormDefaultData(): array { - return ['date_calc' => new RollingDate(RollingDate::T_TODAY)]; + return []; } public function getLabels($key, array $values, $data) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregator.php index 65b2dc38b..76612cac2 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregator.php @@ -13,13 +13,10 @@ namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators; use Chill\MainBundle\Entity\User\UserJobHistory; use Chill\MainBundle\Export\AggregatorInterface; -use Chill\MainBundle\Form\Type\PickRollingDateType; use Chill\MainBundle\Repository\UserJobRepository; -use Chill\MainBundle\Service\RollingDate\RollingDate; -use Chill\MainBundle\Service\RollingDate\RollingDateConverter; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Export\Declarations; -use Doctrine\ORM\Query\Expr; +use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; @@ -28,7 +25,6 @@ final readonly class UserJobAggregator implements AggregatorInterface private const PREFIX = 'acp_agg_user_job'; public function __construct( - private RollingDateConverter $rollingDateConverter, private UserJobRepository $jobRepository, private TranslatableStringHelper $translatableStringHelper ) {} @@ -43,27 +39,35 @@ final readonly class UserJobAggregator implements AggregatorInterface $p = self::PREFIX; $qb - ->leftJoin("acp.user", "{$p}_user") ->leftJoin( - UserJobHistory::class, - "{$p}_history", - Expr\Join::WITH, - $qb->expr()->eq("{$p}_history.user", "{$p}_user") - ) - ->andWhere( + "acp.userHistories", "{$p}_userHistory", + Join::WITH, $qb->expr()->andX( - $qb->expr()->lte("{$p}_history.startDate", ":{$p}_at"), - $qb->expr()->orX( - $qb->expr()->isNull("{$p}_history.endDate"), - $qb->expr()->gt("{$p}_history.endDate", ":{$p}_at") + $qb->expr()->eq("{$p}_userHistory.accompanyingPeriod", "acp.id"), + $qb->expr()->andX( + $qb->expr()->gte("COALESCE(acp.endDate, CURRENT_TIMESTAMP)", "{$p}_userHistory.startDate"), + $qb->expr()->orX( + $qb->expr()->isNull("{$p}_userHistory.endDate"), + $qb->expr()->lt("COALESCE(acp.endDate, CURRENT_TIMESTAMP)", "{$p}_userHistory.endDate") + ) ) ) ) - ->addSelect("IDENTITY({$p}_history.job) AS {$p}_select") - ->setParameter( - "{$p}_at", - $this->rollingDateConverter->convert($data['job_at']) + ->leftJoin( + UserJobHistory::class, "{$p}_jobHistory", + Join::WITH, + $qb->expr()->andX( + $qb->expr()->eq("{$p}_jobHistory.user", "{$p}_userHistory.user"), + $qb->expr()->andX( + $qb->expr()->lte("{$p}_jobHistory.startDate", "{$p}_userHistory.startDate"), + $qb->expr()->orX( + $qb->expr()->isNull("{$p}_jobHistory.endDate"), + $qb->expr()->gt("{$p}_jobHistory.endDate", "{$p}_userHistory.startDate") + ) + ) + ) ) + ->addSelect("IDENTITY({$p}_jobHistory.job) AS {$p}_select") ->addGroupBy("{$p}_select"); } @@ -74,16 +78,11 @@ final readonly class UserJobAggregator implements AggregatorInterface public function buildForm(FormBuilderInterface $builder) { - $builder - ->add('job_at', PickRollingDateType::class, [ - 'label' => 'export.aggregator.course.by_user_job.Calc date', - 'required' => true - ]); } public function getFormDefaultData(): array { - return ['job_at' => new RollingDate(RollingDate::T_TODAY)]; + return []; } public function getLabels($key, array $values, $data) diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php index f9b652eeb..29eed0a68 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php @@ -14,10 +14,7 @@ namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters; use Chill\MainBundle\Entity\User\UserJobHistory; use Chill\MainBundle\Entity\UserJob; use Chill\MainBundle\Export\FilterInterface; -use Chill\MainBundle\Form\Type\PickRollingDateType; use Chill\MainBundle\Repository\UserJobRepositoryInterface; -use Chill\MainBundle\Service\RollingDate\RollingDate; -use Chill\MainBundle\Service\RollingDate\RollingDateConverter; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Export\Declarations; use Doctrine\ORM\Query\Expr\Join; @@ -30,7 +27,6 @@ class CreatorJobFilter implements FilterInterface private const PREFIX = 'acp_filter_creator_job'; public function __construct( - private readonly RollingDateConverter $rollingDateConverter, private readonly TranslatableStringHelper $translatableStringHelper, private readonly UserJobRepositoryInterface $userJobRepository ) {} @@ -45,26 +41,37 @@ class CreatorJobFilter implements FilterInterface $p = self::PREFIX; $qb - ->join("acp.createdBy", "{$p}_user") - ->leftJoin( - UserJobHistory::class, - "{$p}_history", + ->join( + "acp.userHistories", "{$p}_userHistory", Join::WITH, - $qb->expr()->eq("{$p}_history.user", "{$p}_user") - ) - ->andWhere( $qb->expr()->andX( - $qb->expr()->lte("{$p}_history.startDate", ":{$p}_at"), - $qb->expr()->orX( - $qb->expr()->isNull("{$p}_history.endDate"), - $qb->expr()->gt("{$p}_history.endDate", ":{$p}_at") + $qb->expr()->eq("{$p}_userHistory.accompanyingPeriod", "acp.id"), + $qb->expr()->andX( + $qb->expr()->gte("COALESCE(acp.endDate, CURRENT_TIMESTAMP)", "{$p}_userHistory.startDate"), + $qb->expr()->orX( + $qb->expr()->isNull("{$p}_userHistory.endDate"), + $qb->expr()->lt("COALESCE(acp.endDate, CURRENT_TIMESTAMP)", "{$p}_userHistory.endDate") + ) + ) + ) + ) + ->leftJoin( + UserJobHistory::class,"{$p}_history", + Join::WITH, + $qb->expr()->andX( + $qb->expr()->eq("{$p}_history.user", "{$p}_userHistory.createdBy"), + $qb->expr()->andX( + $qb->expr()->lte("{$p}_history.startDate", "{$p}_userHistory.startDate"), + $qb->expr()->orX( + $qb->expr()->isNull("{$p}_history.endDate"), + $qb->expr()->gt("{$p}_history.endDate", "{$p}_userHistory.startDate") + ) ) ) ) ->andWhere($qb->expr()->in("{$p}_history.job", ":{$p}_jobs")) ->setParameters([ "{$p}_jobs" => $data["creator_job"], - "{$p}_at" => $this->rollingDateConverter->convert($data["job_at"]) ]); } @@ -85,10 +92,6 @@ class CreatorJobFilter implements FilterInterface 'multiple' => true, 'expanded' => true, 'label' => 'Job', - ]) - ->add('job_at', PickRollingDateType::class, [ - 'label' => 'export.filter.course.creator_job.Calc date', - 'required' => true ]); } @@ -111,7 +114,6 @@ class CreatorJobFilter implements FilterInterface { return [ 'creator_job' => [], - 'job_at' => new RollingDate(RollingDate::T_TODAY) ]; } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserJobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserJobFilter.php index 56c16fd73..215b48677 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserJobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserJobFilter.php @@ -14,13 +14,10 @@ namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters; use Chill\MainBundle\Entity\User\UserJobHistory; use Chill\MainBundle\Entity\UserJob; use Chill\MainBundle\Export\FilterInterface; -use Chill\MainBundle\Form\Type\PickRollingDateType; use Chill\MainBundle\Repository\UserJobRepositoryInterface; -use Chill\MainBundle\Service\RollingDate\RollingDate; -use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Export\Declarations; -use Doctrine\ORM\Query\Expr; +use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; @@ -32,7 +29,6 @@ class UserJobFilter implements FilterInterface public function __construct( private readonly TranslatableStringHelper $translatableStringHelper, private readonly UserJobRepositoryInterface $userJobRepository, - private readonly RollingDateConverterInterface $rollingDateConverter ) {} public function addRole(): ?string @@ -45,38 +41,37 @@ class UserJobFilter implements FilterInterface $p = self::PREFIX; $qb - ->leftJoin("acp.userHistories", "{$p}_userHistory") - ->leftJoin("{$p}_userHistory.user", "{$p}_user") ->leftJoin( - UserJobHistory::class, - "{$p}_jobHistory", - Expr\Join::WITH, - $qb->expr()->eq("{$p}_jobHistory.user", "{$p}_user") - ) - ->andWhere( + "acp.userHistories", "{$p}_userHistory", + Join::WITH, $qb->expr()->andX( - $qb->expr()->lte("{$p}_userHistory.startDate", ":{$p}_date"), - $qb->expr()->orX( - $qb->expr()->isNull("{$p}_userHistory" . ".endDate"), - $qb->expr()->gt("{$p}_userHistory.endDate", ":{$p}_date") + $qb->expr()->eq("{$p}_userHistory.accompanyingPeriod", "acp.id"), + $qb->expr()->andX( + $qb->expr()->gte("COALESCE(acp.endDate, CURRENT_TIMESTAMP)", "{$p}_userHistory.startDate"), + $qb->expr()->orX( + $qb->expr()->isNull("{$p}_userHistory.endDate"), + $qb->expr()->lt("COALESCE(acp.endDate, CURRENT_TIMESTAMP)", "{$p}_userHistory.endDate") + ) ) ) ) - ->andWhere( + ->leftJoin( + UserJobHistory::class, "{$p}_jobHistory", + Join::WITH, $qb->expr()->andX( - $qb->expr()->lte("{$p}_jobHistory.startDate", ":{$p}_date"), - $qb->expr()->orX( - $qb->expr()->isNull("{$p}_jobHistory" . ".endDate"), - $qb->expr()->gt("{$p}_jobHistory.endDate", ":{$p}_date") + $qb->expr()->eq("{$p}_jobHistory.user", "{$p}_userHistory.user"), + $qb->expr()->andX( + $qb->expr()->lte("{$p}_jobHistory.startDate", "{$p}_userHistory.startDate"), + $qb->expr()->orX( + $qb->expr()->isNull("{$p}_jobHistory" . ".endDate"), + $qb->expr()->gt("{$p}_jobHistory.endDate", "{$p}_userHistory.startDate") + ) ) ) ) - ->andWhere( - $qb->expr()->in("{$p}_jobHistory.job", ":{$p}_job") - ) + ->andWhere($qb->expr()->in("{$p}_jobHistory.job", ":{$p}_job")) ->setParameters([ "{$p}_job" => $data["jobs"], - "{$p}_date" => $this->rollingDateConverter->convert($data["date_calc"]) ]) ; } @@ -96,10 +91,6 @@ class UserJobFilter implements FilterInterface 'expanded' => true, 'choice_label' => fn (UserJob $job) => $this->translatableStringHelper->localize($job->getLabel()), 'label' => 'Job', - ]) - ->add('date_calc', PickRollingDateType::class, [ - 'label' => 'export.filter.course.by_user_job.Computation date for referrer', - 'required' => true, ]); } @@ -122,7 +113,6 @@ class UserJobFilter implements FilterInterface { return [ 'jobs' => [], - 'date_calc' => new RollingDate(RollingDate::T_TODAY) ]; } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserScopeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserScopeFilter.php index 1d2ccf839..789019eb5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserScopeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserScopeFilter.php @@ -14,13 +14,10 @@ namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters; use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Entity\User\UserScopeHistory; use Chill\MainBundle\Export\FilterInterface; -use Chill\MainBundle\Form\Type\PickRollingDateType; use Chill\MainBundle\Repository\ScopeRepositoryInterface; -use Chill\MainBundle\Service\RollingDate\RollingDate; -use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Export\Declarations; -use Doctrine\ORM\Query\Expr; +use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; @@ -32,7 +29,6 @@ class UserScopeFilter implements FilterInterface public function __construct( private readonly ScopeRepositoryInterface $scopeRepository, private readonly TranslatableStringHelper $translatableStringHelper, - private readonly RollingDateConverterInterface $rollingDateConverter ) {} public function addRole(): ?string @@ -45,38 +41,37 @@ class UserScopeFilter implements FilterInterface $p = self::PREFIX; $qb - ->join("acp.userHistories", "{$p}_userHistory") - ->join("{$p}_userHistory.user", "{$p}_user") ->join( - UserScopeHistory::class, - "{$p}_scopeHistory", - Expr\Join::WITH, - $qb->expr()->eq("{$p}_scopeHistory", "{$p}_user") - ) - ->andWhere( + "acp.userHistories", "{$p}_userHistory", + Join::WITH, $qb->expr()->andX( - $qb->expr()->lte("{$p}_userHistory.startDate", ":{$p}_date"), - $qb->expr()->orX( - $qb->expr()->isNull("{$p}_userHistory.endDate"), - $qb->expr()->gt("{$p}_userHistory.endDate", ":{$p}_date") + $qb->expr()->eq("{$p}_userHistory.accompanyingPeriod", "acp.id"), + $qb->expr()->andX( + $qb->expr()->gte("COALESCE(acp.endDate, CURRENT_TIMESTAMP)", "{$p}_userHistory.startDate"), + $qb->expr()->orX( + $qb->expr()->isNull("{$p}_userHistory.endDate"), + $qb->expr()->lt("COALESCE(acp.endDate, CURRENT_TIMESTAMP)", "{$p}_userHistory.endDate") + ) ) ) ) - ->andWhere( + ->join( + UserScopeHistory::class, "{$p}_scopeHistory", + Join::WITH, $qb->expr()->andX( - $qb->expr()->lte("{$p}_scopeHistory.startDate", ":{$p}_date"), - $qb->expr()->orX( - $qb->expr()->isNull("{$p}_scopeHistory.endDate"), - $qb->expr()->gt("{$p}_scopeHistory.endDate", ":{$p}_date") + $qb->expr()->eq("{$p}_scopeHistory.user", "{$p}_userHistory.user"), + $qb->expr()->andX( + $qb->expr()->lte("{$p}_scopeHistory.startDate", "{$p}_userHistory.startDate"), + $qb->expr()->orX( + $qb->expr()->isNull("{$p}_scopeHistory.endDate"), + $qb->expr()->gt("{$p}_scopeHistory.endDate", "{$p}_userHistory.startDate") + ) ) ) ) - ->andWhere( - $qb->expr()->in("{$p}_scopeHistory.scope", ":{$p}_scopes") - ) + ->andWhere($qb->expr()->in("{$p}_scopeHistory.scope", ":{$p}_scopes")) ->setParameters([ "{$p}_scopes" => $data["scopes"], - "{$p}_date" => $this->rollingDateConverter->convert($data["date_calc"]) ]) ; } @@ -95,10 +90,6 @@ class UserScopeFilter implements FilterInterface 'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize($s->getName()), 'multiple' => true, 'expanded' => true, - ]) - ->add('date_calc', PickRollingDateType::class, [ - 'label' => 'export.filter.course.by_user_scope.Computation date for referrer', - 'required' => true, ]); } @@ -121,7 +112,6 @@ class UserScopeFilter implements FilterInterface { return [ 'scopes' => [], - 'date_calc' => new RollingDate(RollingDate::T_TODAY) ]; } diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index fadfbdc51..639de0443 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -1012,11 +1012,9 @@ export: Computation date for referrer: Date à laquelle le référent était actif by_user_scope: Group course by referrer's scope: Grouper les parcours par service du référent - Computation date for referrer: Date à laquelle le référent était actif Referrer's scope: Service du référent de parcours by_user_job: Group by user job: Grouper les parcours par métier du référent - Calc date: Date de calcul du métier du référent duration: day: Durée du parcours en jours week: Durée du parcours en semaines @@ -1027,7 +1025,6 @@ export: by_creator_job: Creator's job: Métier du créateur Group by creator job: Grouper les parcours par métier du créateur - Calc date: Date de calcul du métier du créateur by_user_working: title: Grouper les parcours par intervenant user: Intervenant @@ -1124,7 +1121,6 @@ export: date_to: Statuts acquis avant cette date 'Filtered by steps: only %step% and between %date_from% and %date_to%': 'Filtré par statut: seulement %step%, entre %date_from% et %date_to%' by_user_scope: - Computation date for referrer: Date à laquelle le référent était actif Filter by user scope: Filtrer les parcours par service du référent "Filtered by user main scope: only %scope%": "Filtré par service du référent: uniquement %scope%" by_referrer: @@ -1137,11 +1133,9 @@ export: creator_job: Filter by creator job: Filtrer les parcours par métier du créateur 'Filtered by creator job: only %jobs%': "Filtré par métier du créateur: uniquement %jobs%" - Calc date: Date de calcul du métier du créateur by_user_job: Filter by user job: Filtrer les parcours par métier du référent "Filtered by user job: only %job%": "Filtré par métier du référent: uniquement %job%" - Computation date for referrer: Date à laquelle le référent était actif work: start_between_dates: