diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php index 2a6dec7f7..24000096f 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php @@ -48,6 +48,9 @@ class SentReceivedAggregator implements AggregatorInterface } switch ($value) { + case null: + return ''; + case 'sent': return 'is sent'; diff --git a/src/Bundle/ChillCalendarBundle/Menu/UserMenuBuilder.php b/src/Bundle/ChillCalendarBundle/Menu/UserMenuBuilder.php index 9da2f4ffd..90743d1ba 100644 --- a/src/Bundle/ChillCalendarBundle/Menu/UserMenuBuilder.php +++ b/src/Bundle/ChillCalendarBundle/Menu/UserMenuBuilder.php @@ -54,8 +54,6 @@ class UserMenuBuilder implements LocalMenuBuilderInterface public function buildMenu($menuId, MenuItem $menu, array $parameters) { - $user = $this->tokenStorage->getToken()->getUser(); - if ($this->authorizationChecker->isGranted('ROLE_USER')) { $menu->addChild('My calendar list', [ 'route' => 'chill_calendar_calendar_list', diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php index 71fe3250f..c8b7ccc55 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php @@ -13,9 +13,9 @@ namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters; use Chill\MainBundle\Entity\UserJob; use Chill\MainBundle\Export\FilterInterface; +use Chill\MainBundle\Repository\UserJobRepositoryInterface; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Export\Declarations; -use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; @@ -25,10 +25,14 @@ class CreatorJobFilter implements FilterInterface { private TranslatableStringHelper $translatableStringHelper; + private UserJobRepositoryInterface $userJobRepository; + public function __construct( - TranslatableStringHelper $translatableStringHelper + TranslatableStringHelper $translatableStringHelper, + UserJobRepositoryInterface $userJobRepository ) { $this->translatableStringHelper = $translatableStringHelper; + $this->userJobRepository = $userJobRepository; } public function addRole(): ?string @@ -42,17 +46,9 @@ class CreatorJobFilter implements FilterInterface $qb->join('acp.createdBy', 'acp_creator'); } - $where = $qb->getDQLPart('where'); - $clause = $qb->expr()->in('acp_creator.userJob', ':creator_job'); - - if ($where instanceof Andx) { - $where->add($clause); - } else { - $where = $qb->expr()->andX($clause); - } - - $qb->add('where', $where); - $qb->setParameter('creator_job', $data['creator_job']); + $qb + ->andWhere($qb->expr()->in('acp_creator.userJob', ':creator_job')) + ->setParameter('creator_job', $data['creator_job']); } public function applyOn(): string @@ -64,6 +60,7 @@ class CreatorJobFilter implements FilterInterface { $builder->add('creator_job', EntityType::class, [ 'class' => UserJob::class, + 'choices' => $this->userJobRepository->findAllActive(), 'choice_label' => function (UserJob $j) { return $this->translatableStringHelper->localize( $j->getLabel() @@ -84,7 +81,7 @@ class CreatorJobFilter implements FilterInterface ); } - return ['Filtered by creator job: only %jobs%', [ + return ['export.filter.course.creator_job.Filtered by creator job: only %jobs%', [ '%jobs%' => implode(', ', $creatorJobs), ]]; } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasTemporaryLocationFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasTemporaryLocationFilter.php index b674f1881..2ae1ad2a0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasTemporaryLocationFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasTemporaryLocationFilter.php @@ -12,8 +12,12 @@ declare(strict_types=1); namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters; use Chill\MainBundle\Export\FilterInterface; +use Chill\MainBundle\Form\Type\ChillDateType; use Chill\PersonBundle\Export\Declarations; +use DateTimeImmutable; use Doctrine\ORM\QueryBuilder; +use LogicException; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\FormBuilderInterface; class HasTemporaryLocationFilter implements FilterInterface @@ -26,10 +30,25 @@ class HasTemporaryLocationFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { $qb - ->andWhere( - $qb->expr()->in('', ':') - ) - ->setParameter('', $data[]); + ->join('acp.locationHistories', 'acp_having_temporarily_location') + ->andWhere('acp_having_temporarily_location.startDate <= :acp_having_temporarily_location_date + AND (acp_having_temporarily_location.endDate IS NULL OR acp_having_temporarily_location.endDate > :acp_having_temporarily_location_date)') + ->setParameter('acp_having_temporarily_location_date', $data['calc_date']); + + switch ($data['having_temporarily']) { + case true: + $qb->andWhere('acp_having_temporarily_location.addressLocation IS NOT NULL'); + + break; + + case false: + $qb->andWhere('acp_having_temporarily_location.personLocation IS NOT NULL'); + + break; + + default: + throw new LogicException('value not supported'); + } } public function applyOn(): string @@ -39,13 +58,44 @@ class HasTemporaryLocationFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder) { - //$builder->add(); + $builder + ->add('having_temporarily', ChoiceType::class, [ + 'choices' => [ + 'export.filter.course.having_temporarily.Having a temporarily location' => true, + 'export.filter.course.having_temporarily.Having a person\'s location' => false, + ], + 'choice_label' => static function ($choice) { + switch ($choice) { + case true: + return 'export.filter.course.having_temporarily.Having a temporarily location'; + + case false: + return 'export.filter.course.having_temporarily.Having a person\'s location'; + + default: + throw new LogicException('this choice is not supported'); + } + }, + ]) + ->add('calc_date', ChillDateType::class, [ + 'label' => 'export.filter.course.having_temporarily.Calculation date', + 'input' => 'datetime_immutable', + 'data' => new DateTimeImmutable(), + ]); } public function describeAction($data, $format = 'string'): array { - return ['', [ - ]]; + switch ($data['having_temporarily']) { + case true: + return ['export.filter.course.having_temporarily.Having a temporarily location', []]; + + case false: + return ['export.filter.course.having_temporarily.Having a person\'s location', []]; + + default: + throw new LogicException('value not supported'); + } } public function getTitle(): string diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 134a97414..4a284e7bd 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -1021,6 +1021,12 @@ export: Computation date for referrer: Date à laquelle le référent était actif by_referrer: Computation date for referrer: Date à laquelle le référent était actif + having_temporarily: + Having a temporarily location: Ayant une localisation temporaire + Having a person's location: Ayant une localisation auprès d'un usager + Calculation date: Date de la localisation + creator_job: + 'Filtered by creator job: only %jobs%': 'Filtré par métier du créateur: seulement %jobs%' list: person_with_acp: List peoples having an accompanying period: Liste des personnes ayant un parcours d'accompagnement