Merge branch '111_exports_suite' of gitlab.com:Chill-Projet/chill-bundles into 111_exports_suite

This commit is contained in:
Julie Lenaerts 2022-11-02 13:14:50 +01:00
commit f40aa89d08
5 changed files with 77 additions and 23 deletions

View File

@ -48,6 +48,9 @@ class SentReceivedAggregator implements AggregatorInterface
} }
switch ($value) { switch ($value) {
case null:
return '';
case 'sent': case 'sent':
return 'is sent'; return 'is sent';

View File

@ -54,8 +54,6 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
public function buildMenu($menuId, MenuItem $menu, array $parameters) public function buildMenu($menuId, MenuItem $menu, array $parameters)
{ {
$user = $this->tokenStorage->getToken()->getUser();
if ($this->authorizationChecker->isGranted('ROLE_USER')) { if ($this->authorizationChecker->isGranted('ROLE_USER')) {
$menu->addChild('My calendar list', [ $menu->addChild('My calendar list', [
'route' => 'chill_calendar_calendar_list', 'route' => 'chill_calendar_calendar_list',

View File

@ -13,9 +13,9 @@ namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters;
use Chill\MainBundle\Entity\UserJob; use Chill\MainBundle\Entity\UserJob;
use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Repository\UserJobRepositoryInterface;
use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Export\Declarations;
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;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
@ -25,10 +25,14 @@ class CreatorJobFilter implements FilterInterface
{ {
private TranslatableStringHelper $translatableStringHelper; private TranslatableStringHelper $translatableStringHelper;
private UserJobRepositoryInterface $userJobRepository;
public function __construct( public function __construct(
TranslatableStringHelper $translatableStringHelper TranslatableStringHelper $translatableStringHelper,
UserJobRepositoryInterface $userJobRepository
) { ) {
$this->translatableStringHelper = $translatableStringHelper; $this->translatableStringHelper = $translatableStringHelper;
$this->userJobRepository = $userJobRepository;
} }
public function addRole(): ?string public function addRole(): ?string
@ -42,17 +46,9 @@ class CreatorJobFilter implements FilterInterface
$qb->join('acp.createdBy', 'acp_creator'); $qb->join('acp.createdBy', 'acp_creator');
} }
$where = $qb->getDQLPart('where'); $qb
$clause = $qb->expr()->in('acp_creator.userJob', ':creator_job'); ->andWhere($qb->expr()->in('acp_creator.userJob', ':creator_job'))
->setParameter('creator_job', $data['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']);
} }
public function applyOn(): string public function applyOn(): string
@ -64,6 +60,7 @@ class CreatorJobFilter implements FilterInterface
{ {
$builder->add('creator_job', EntityType::class, [ $builder->add('creator_job', EntityType::class, [
'class' => UserJob::class, 'class' => UserJob::class,
'choices' => $this->userJobRepository->findAllActive(),
'choice_label' => function (UserJob $j) { 'choice_label' => function (UserJob $j) {
return $this->translatableStringHelper->localize( return $this->translatableStringHelper->localize(
$j->getLabel() $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), '%jobs%' => implode(', ', $creatorJobs),
]]; ]];
} }

View File

@ -12,8 +12,12 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters; namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters;
use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Export\Declarations;
use DateTimeImmutable;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
class HasTemporaryLocationFilter implements FilterInterface class HasTemporaryLocationFilter implements FilterInterface
@ -26,10 +30,25 @@ class HasTemporaryLocationFilter implements FilterInterface
public function alterQuery(QueryBuilder $qb, $data) public function alterQuery(QueryBuilder $qb, $data)
{ {
$qb $qb
->andWhere( ->join('acp.locationHistories', 'acp_having_temporarily_location')
$qb->expr()->in('', ':') ->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('', $data[]); ->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 public function applyOn(): string
@ -39,13 +58,44 @@ class HasTemporaryLocationFilter implements FilterInterface
public function buildForm(FormBuilderInterface $builder) 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 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 public function getTitle(): string

View File

@ -1021,6 +1021,12 @@ export:
Computation date for referrer: Date à laquelle le référent était actif Computation date for referrer: Date à laquelle le référent était actif
by_referrer: by_referrer:
Computation date for referrer: Date à laquelle le référent était actif 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: list:
person_with_acp: person_with_acp:
List peoples having an accompanying period: Liste des personnes ayant un parcours d'accompagnement List peoples having an accompanying period: Liste des personnes ayant un parcours d'accompagnement