diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserJobAggregator.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserJobAggregator.php index a7a7e403e..6ea912eed 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserJobAggregator.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserJobAggregator.php @@ -14,23 +14,17 @@ namespace Chill\AsideActivityBundle\Export\Aggregator; use Chill\AsideActivityBundle\Export\Declarations; use Chill\MainBundle\Entity\User\UserJobHistory; use Chill\MainBundle\Export\AggregatorInterface; -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\TranslatableStringHelperInterface; -use Doctrine\ORM\Query\Expr; +use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; -use function in_array; - class ByUserJobAggregator implements AggregatorInterface { private const PREFIX = 'aside_act_agg_user_job'; public function __construct( - private readonly RollingDateConverter $rollingDateConverter, private readonly UserJobRepositoryInterface $userJobRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper ) {} @@ -49,23 +43,20 @@ class ByUserJobAggregator implements AggregatorInterface ->leftJoin( UserJobHistory::class, "{$p}_history", - Expr\Join::WITH, + Join::WITH, $qb->expr()->eq("{$p}_history.user", "{$p}_user") ) + // job_at based on aside.date ->andWhere( $qb->expr()->andX( - $qb->expr()->lte("{$p}_history.startDate", ":{$p}_at"), + $qb->expr()->lte("{$p}_history.startDate", "aside.date"), $qb->expr()->orX( $qb->expr()->isNull("{$p}_history.endDate"), - $qb->expr()->gt("{$p}_history.endDate", ":{$p}_at") + $qb->expr()->gt("{$p}_history.endDate", "aside.date") ) ) ) ->addSelect("IDENTITY({$p}_history.job) AS {$p}_select") - ->setParameter( - "{$p}_at", - $this->rollingDateConverter->convert($data['job_at']) - ) ->addGroupBy("{$p}_select"); } @@ -76,15 +67,11 @@ class ByUserJobAggregator implements AggregatorInterface public function buildForm(FormBuilderInterface $builder) { - $builder->add('job_at', PickRollingDateType::class, [ - 'label' => 'export.aggregator.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/ChillAsideActivityBundle/src/Export/Aggregator/ByUserScopeAggregator.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserScopeAggregator.php index 168d38433..3d55884b4 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserScopeAggregator.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserScopeAggregator.php @@ -14,12 +14,9 @@ namespace Chill\AsideActivityBundle\Export\Aggregator; use Chill\AsideActivityBundle\Export\Declarations; 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\RollingDateConverter; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; -use Doctrine\ORM\Query\Expr; +use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; @@ -28,7 +25,6 @@ class ByUserScopeAggregator implements AggregatorInterface private const PREFIX = 'aside_act_agg_user_scope'; public function __construct( - private readonly RollingDateConverter $rollingDateConverter, private readonly ScopeRepositoryInterface $scopeRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper ) {} @@ -47,23 +43,19 @@ class ByUserScopeAggregator implements AggregatorInterface ->leftJoin( UserScopeHistory::class, "{$p}_history", - Expr\Join::WITH, + Join::WITH, $qb->expr()->eq("{$p}_history.user", "{$p}_user") ) ->andWhere( $qb->expr()->andX( - $qb->expr()->lte("{$p}_history.startDate", ":{$p}_at"), + $qb->expr()->lte("{$p}_history.startDate", "aside.date"), $qb->expr()->orX( $qb->expr()->isNull("{$p}_history.endDate"), - $qb->expr()->gt("{$p}_history.endDate", ":{$p}_at") + $qb->expr()->gt("{$p}_history.endDate", "aside.date") ) ) ) ->addSelect("IDENTITY({$p}_history.scope) AS {$p}_select") - ->setParameter( - "{$p}_at", - $this->rollingDateConverter->convert($data['scope_at']) - ) ->addGroupBy("{$p}_select"); } @@ -74,15 +66,11 @@ class ByUserScopeAggregator implements AggregatorInterface public function buildForm(FormBuilderInterface $builder) { - $builder->add('scope_at', PickRollingDateType::class, [ - 'label' => 'export.aggregator.by_user_scope.Calc date', - 'required' => true, - ]); } public function getFormDefaultData(): array { - return ['scope_at' => new RollingDate(RollingDate::T_TODAY)]; + return []; } public function getLabels($key, array $values, $data) diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserJobFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserJobFilter.php index 867eca230..d76d6d126 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserJobFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserJobFilter.php @@ -16,9 +16,6 @@ use Chill\AsideActivityBundle\Export\Declarations; 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\Service\RollingDate\RollingDate; -use Chill\MainBundle\Service\RollingDate\RollingDateConverter; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; @@ -29,7 +26,6 @@ class ByUserJobFilter implements FilterInterface private const PREFIX = 'aside_act_filter_user_job'; public function __construct( - private readonly RollingDateConverter $rollingDateConverter, private readonly TranslatableStringHelperInterface $translatableStringHelper ) {} @@ -49,14 +45,14 @@ class ByUserJobFilter implements FilterInterface . "JOIN {$p}_act.agent {$p}_user " . "JOIN " . UserJobHistory::class . " {$p}_history WITH {$p}_history.user = {$p}_user " . "WHERE {$p}_act = aside " - . "AND {$p}_history.startDate <= :{$p}_at " - . "AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > :{$p}_at) " + // job_at based on aside.date + . "AND {$p}_history.startDate <= aside.date " + . "AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > aside.date) " . "AND {$p}_history.job IN ( :{$p}_jobs )" ) ) ->setParameters([ "{$p}_jobs" => $data["jobs"], - "{$p}_at" => $this->rollingDateConverter->convert($data["job_at"]) ]); } @@ -73,10 +69,6 @@ class ByUserJobFilter implements FilterInterface 'choice_label' => fn (UserJob $j) => $this->translatableStringHelper->localize($j->getLabel()), 'multiple' => true, 'expanded' => true, - ]) - ->add('job_at', PickRollingDateType::class, [ - 'label' => 'export.filter.by_user_job.Calc date', - 'required' => true ]); } @@ -97,7 +89,6 @@ class ByUserJobFilter implements FilterInterface { return [ 'jobs' => [], - 'job_at' => new RollingDate(RollingDate::T_TODAY) ]; } diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserScopeFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserScopeFilter.php index ce6905378..7df450bde 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserScopeFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserScopeFilter.php @@ -16,10 +16,7 @@ use Chill\AsideActivityBundle\Export\Declarations; 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\RollingDateConverter; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; @@ -30,7 +27,6 @@ class ByUserScopeFilter implements FilterInterface private const PREFIX = 'aside_act_filter_user_scope'; public function __construct( - private readonly RollingDateConverter $rollingDateConverter, private readonly ScopeRepositoryInterface $scopeRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper ) {} @@ -51,14 +47,14 @@ class ByUserScopeFilter implements FilterInterface . "JOIN {$p}_act.agent {$p}_user " . "JOIN " . UserScopeHistory::class . " {$p}_history WITH {$p}_history.user = {$p}_user " . "WHERE {$p}_act = aside " - . "AND {$p}_history.startDate <= :{$p}_at " - . "AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > :{$p}_at) " + // scope_at based on aside.date + . "AND {$p}_history.startDate <= aside.date " + . "AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > aside.date) " . "AND {$p}_history.scope IN ( :{$p}_scopes )" ) ) ->setParameters([ "{$p}_scopes" => $data["scopes"], - "{$p}_at" => $this->rollingDateConverter->convert($data["scope_at"]) ]); } @@ -76,10 +72,6 @@ class ByUserScopeFilter implements FilterInterface 'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize($s->getName()), 'multiple' => true, 'expanded' => true, - ]) - ->add('scope_at', PickRollingDateType::class, [ - 'label' => 'export.filter.by_user_scope.Calc date', - 'required' => true, ]); } @@ -100,7 +92,6 @@ class ByUserScopeFilter implements FilterInterface { return [ 'scopes' => [], - 'scope_at' => new RollingDate(RollingDate::T_TODAY) ]; } diff --git a/src/Bundle/ChillAsideActivityBundle/src/translations/messages.fr.yml b/src/Bundle/ChillAsideActivityBundle/src/translations/messages.fr.yml index fe895e223..0a324d2cd 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/translations/messages.fr.yml +++ b/src/Bundle/ChillAsideActivityBundle/src/translations/messages.fr.yml @@ -203,11 +203,9 @@ export: by_user_job: 'Filtered aside activities by user jobs: only %jobs%': "Filtré par métier des utilisateurs: uniquement %jobs%" Filter by user jobs: Filtrer les activités annexes par métier des utilisateurs - Calc date: Date de calcul du métier des utilisateurs by_user_scope: 'Filtered aside activities by user scope: only %scopes%': "Filtré par service des utilisateurs: uniquement %scopes%" Filter by user scope: Filtrer les activités annexes par service d'utilisateur - Calc date: Date de calcul du service des utilisateurs Filter by aside activity location: Filtrer les activités annexes par localisation 'Filtered by aside activity location: only %location%': "Filtré par localisation: uniquement %location%" aggregator: @@ -215,10 +213,8 @@ export: Aside activity type: Type d'activité annexe by_user_job: Aggregate by user job: Grouper les activités annexes par métier des utilisateurs - Calc date: Date de calcul du métier des utilisateurs by_user_scope: Aggregate by user scope: Grouper les activités annexes par service des utilisateurs - Calc date: Date de calcul du service des utilisateurs Aside activity location: Localisation des activités annexe Group by aside activity location: Grouper les activités annexes par localisation Aside activity localisation: Localisation