diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityReasonAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityReasonAggregator.php index b4d2f8e52..5c77159e3 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityReasonAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityReasonAggregator.php @@ -107,7 +107,7 @@ class ActivityReasonAggregator implements AggregatorInterface, ExportElementVali public function applyOn(): string { - return Declarations::ACTIVITY; + return Declarations::ACTIVITY_PERSON; } public function buildForm(FormBuilderInterface $builder) diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php index 8a5ce4d01..cedd2df8c 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php @@ -45,11 +45,19 @@ class ActivityTypeAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - // add select element - $qb->addSelect(sprintf('IDENTITY(activity.type) AS %s', self::KEY)); + if (!in_array('type', $qb->getAllAliases())) { + $qb->join('activity.activityType', 'type'); + } - // add the "group by" part - $qb->addGroupBy(self::KEY); + $qb->addSelect(sprintf('IDENTITY(activity.activityType) AS %s', self::KEY)); + + $groupby = $qb->getDQLPart('groupBy'); + + if (!empty($groupBy)) { + $qb->addGroupBy(self::KEY); + } else { + $qb->groupBy(self::KEY); + } } public function applyOn(): string diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php index 3cdeee0f9..be4149bf9 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php @@ -48,7 +48,7 @@ class ActivityUserAggregator implements AggregatorInterface public function applyOn(): string { - return Declarations::ACTIVITY; + return Declarations::ACTIVITY_PERSON; } public function buildForm(FormBuilderInterface $builder) diff --git a/src/Bundle/ChillActivityBundle/Export/Declarations.php b/src/Bundle/ChillActivityBundle/Export/Declarations.php index 76335415f..7a5b47028 100644 --- a/src/Bundle/ChillActivityBundle/Export/Declarations.php +++ b/src/Bundle/ChillActivityBundle/Export/Declarations.php @@ -17,4 +17,8 @@ namespace Chill\ActivityBundle\Export; abstract class Declarations { public const ACTIVITY = 'activity'; + + public const ACTIVITY_ACP = "activity_linked_to_acp"; + + public const ACTIVITY_PERSON = "activity_linked_to_person"; } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php new file mode 100644 index 000000000..1ae5d1830 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php @@ -0,0 +1,103 @@ +repository = $em->getRepository(Activity::class); + } + + public function buildForm(FormBuilderInterface $builder) + { + // TODO: Implement buildForm() method. + } + + public function getTitle(): string + { + return 'Average activity linked to an accompanying period duration'; + } + + public function getAllowedFormattersTypes(): array + { + return [FormatterInterface::TYPE_TABULAR]; + } + + public function getDescription(): string + { + return 'Average activities linked to an accompanying period duration by various parameters.'; + } + + 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"); + } + + return static fn ($value) => '_header' === $value ? 'Average activities linked to an accompanying period duration' : $value; + } + + public function getQueryKeys($data): array + { + return ['export_avg_activity_duration']; + } + + public function getResult($qb, $data) + { + return $qb->getQuery()->getResult(Query::HYDRATE_SCALAR); + } + + public function getType(): string + { + return Declarations::ACTIVITY; + } + + public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) + { + $qb = $this->repository->createQueryBuilder('activity') + ->join('activity.accompanyingPeriod', 'acp') + ; + + $qb->select('AVG(activity.durationTime) as export_avg_activity_duration'); + + return $qb; + } + + public function requiredRole(): Role + { + return new Role(ActivityStatsVoter::STATS); + } + + public function supportsModifiers(): array + { + return [ + Declarations::ACTIVITY, + Declarations::ACTIVITY_ACP, + //PersonDeclarations::ACP_TYPE, + ]; + } + + public function getGroup(): string + { + return 'Exports of activities linked to an accompanying period'; + } + +} \ No newline at end of file diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php new file mode 100644 index 000000000..b03378b16 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php @@ -0,0 +1,103 @@ +repository = $em->getRepository(Activity::class); + } + + public function buildForm(FormBuilderInterface $builder) + { + // TODO: Implement buildForm() method. + } + + public function getTitle(): string + { + return 'Average activity linked to an accompanying period visit duration'; + } + + public function getAllowedFormattersTypes(): array + { + return [FormatterInterface::TYPE_TABULAR]; + } + + public function getDescription(): string + { + return 'Average activities linked to an accompanying period visit duration by various parameters.'; + } + + 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"); + } + + return static fn ($value) => '_header' === $value ? 'Average activities linked to an accompanying period visit duration' : $value; + } + + public function getQueryKeys($data): array + { + return ['export_avg_activity_visit_duration']; + } + + public function getResult($qb, $data) + { + return $qb->getQuery()->getResult(Query::HYDRATE_SCALAR); + } + + public function getType(): string + { + return Declarations::ACTIVITY; + } + + public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) + { + $qb = $this->repository->createQueryBuilder('activity') + ->join('activity.accompanyingPeriod', 'acp') + ; + + $qb->select('AVG(activity.travelTime) as export_avg_activity_visit_duration'); + + return $qb; + } + + public function requiredRole(): Role + { + return new Role(ActivityStatsVoter::STATS); + } + + public function supportsModifiers(): array + { + return [ + Declarations::ACTIVITY, + Declarations::ACTIVITY_ACP, + //PersonDeclarations::ACP_TYPE, + ]; + } + + public function getGroup(): string + { + return 'Exports of activities linked to an accompanying period'; + } + +} \ No newline at end of file diff --git a/src/Bundle/ChillActivityBundle/Export/Export/CountActivityLinkedToACP.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php similarity index 62% rename from src/Bundle/ChillActivityBundle/Export/Export/CountActivityLinkedToACP.php rename to src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php index 91a2dd285..55c0a1974 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/CountActivityLinkedToACP.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php @@ -9,56 +9,58 @@ declare(strict_types=1); -namespace Chill\ActivityBundle\Export\Export; +namespace Chill\ActivityBundle\Export\Export\LinkedToACP; +use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Export\Declarations; -use Chill\ActivityBundle\Repository\ActivityRepository; 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; use LogicException; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Security\Core\Role\Role; -class CountActivityLinkedToACP implements ExportInterface, GroupedExportInterface +class CountActivity implements ExportInterface, GroupedExportInterface { - protected ActivityRepository $activityRepository; + protected EntityRepository $repository; public function __construct( - ActivityRepository $activityRepository + EntityManagerInterface $em ) { - $this->activityRepository = $activityRepository; + $this->repository = $em->getRepository(Activity::class); } public function buildForm(FormBuilderInterface $builder) { } - public function getAllowedFormattersTypes() + public function getAllowedFormattersTypes(): array { return [FormatterInterface::TYPE_TABULAR]; } - public function getDescription() + public function getDescription(): string { return 'Count activities linked to an accompanying period by various parameters.'; } public function getLabels($key, array $values, $data) { - if ('export_count_activity_acp' !== $key) { + if ('export_count_activity' !== $key) { throw new LogicException("the key {$key} is not used by this export"); } return static fn ($value) => '_header' === $value ? 'Number of activities linked to an accompanying period' : $value; } - public function getQueryKeys($data) + public function getQueryKeys($data): array { - return ['export_count_activity_acp']; + return ['export_count_activity']; } public function getResult($qb, $data) @@ -66,48 +68,43 @@ class CountActivityLinkedToACP implements ExportInterface, GroupedExportInterfac return $qb->getQuery()->getResult(Query::HYDRATE_SCALAR); } - public function getTitle() + public function getTitle(): string { return 'Count activities linked to an accompanying period'; } - public function getType() + public function getType(): string { return Declarations::ACTIVITY; } public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $centers = array_map(static fn ($el) => $el['center'], $acl); - - $qb = $this - ->activityRepository - ->createQueryBuilder('activity') - ->select('COUNT(activity.id) as export_count_activity_acp'); - - $qb->andWhere( - $qb->expr()->isNotNull('activity.accompanyingPeriod') - ); + $qb = $this->repository->createQueryBuilder('activity') + ->join('activity.accompanyingPeriod', 'acp') + ; + $qb->select('COUNT(activity.id) as export_count_activity'); + return $qb; } - public function requiredRole() + public function requiredRole(): Role { return new Role(ActivityStatsVoter::STATS); } - public function supportsModifiers() + public function supportsModifiers(): array { return [ Declarations::ACTIVITY, - //PersonDeclarations::PERSON_TYPE, + Declarations::ACTIVITY_ACP, //PersonDeclarations::ACP_TYPE, ]; } public function getGroup(): string { - return 'Exports of activities'; + return 'Exports of activities linked to an accompanying period'; } } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php new file mode 100644 index 000000000..3ab192702 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php @@ -0,0 +1,103 @@ +repository = $em->getRepository(Activity::class); + } + + public function buildForm(FormBuilderInterface $builder) + { + // TODO: Implement buildForm() method. + } + + public function getTitle(): string + { + return 'Sum activity linked to an accompanying period duration'; + } + + public function getAllowedFormattersTypes(): array + { + return [FormatterInterface::TYPE_TABULAR]; + } + + public function getDescription(): string + { + return 'Sum activities linked to an accompanying period duration by various parameters.'; + } + + 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"); + } + + return static fn ($value) => '_header' === $value ? 'Sum activities linked to an accompanying period duration' : $value; + } + + public function getQueryKeys($data): array + { + return ['export_sum_activity_duration']; + } + + public function getResult($qb, $data) + { + return $qb->getQuery()->getResult(Query::HYDRATE_SCALAR); + } + + public function getType(): string + { + return Declarations::ACTIVITY; + } + + public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) + { + $qb = $this->repository->createQueryBuilder('activity') + ->join('activity.accompanyingPeriod', 'acp') + ; + + $qb->select('SUM(activity.durationTime) as export_sum_activity_duration'); + + return $qb; + } + + public function requiredRole(): Role + { + return new Role(ActivityStatsVoter::STATS); + } + + public function supportsModifiers(): array + { + return [ + Declarations::ACTIVITY, + Declarations::ACTIVITY_ACP, + //PersonDeclarations::ACP_TYPE, + ]; + } + + public function getGroup(): string + { + return 'Exports of activities linked to an accompanying period'; + } + +} \ No newline at end of file diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php new file mode 100644 index 000000000..452fc4de7 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php @@ -0,0 +1,102 @@ +repository = $em->getRepository(Activity::class); + } + + public function buildForm(FormBuilderInterface $builder) + { + // TODO: Implement buildForm() method. + } + + public function getTitle(): string + { + return 'Sum activity linked to an accompanying period visit duration'; + } + + public function getAllowedFormattersTypes(): array + { + return [FormatterInterface::TYPE_TABULAR]; + } + + public function getDescription(): string + { + return 'Sum activities linked to an accompanying period visit duration by various parameters.'; + } + + 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"); + } + + return static fn ($value) => '_header' === $value ? 'Sum activities linked to an accompanying period visit duration' : $value; + } + + public function getQueryKeys($data): array + { + return ['export_sum_activity_visit_duration']; + } + + public function getResult($qb, $data) + { + return $qb->getQuery()->getResult(Query::HYDRATE_SCALAR); + } + + public function getType(): string + { + return Declarations::ACTIVITY; + } + + public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) + { + $qb = $this->repository->createQueryBuilder('activity') + ->join('activity.accompanyingPeriod', 'acp') + ; + + $qb->select('SUM(activity.travelTime) as export_sum_activity_visit_duration'); + + return $qb; + } + + public function requiredRole(): Role + { + return new Role(ActivityStatsVoter::STATS); + } + + public function supportsModifiers(): array + { + return [ + Declarations::ACTIVITY, + Declarations::ACTIVITY_ACP, + //PersonDeclarations::ACP_TYPE, + ]; + } + + public function getGroup(): string + { + return 'Exports of activities linked to an accompanying period'; + } +} \ No newline at end of file diff --git a/src/Bundle/ChillActivityBundle/Export/Export/CountActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php similarity index 83% rename from src/Bundle/ChillActivityBundle/Export/Export/CountActivity.php rename to src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php index 3834bc819..75d3122c3 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/CountActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php @@ -9,7 +9,7 @@ declare(strict_types=1); -namespace Chill\ActivityBundle\Export\Export; +namespace Chill\ActivityBundle\Export\Export\LinkedToPerson; use Chill\ActivityBundle\Repository\ActivityRepository; use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter; @@ -71,24 +71,25 @@ class CountActivity implements ExportInterface, GroupedExportInterface return 'Count activities linked to a person'; } - public function getType() + public function getType(): string { - return 'activity'; + return Declarations::ACTIVITY; } public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { $centers = array_map(static fn ($el) => $el['center'], $acl); - $qb = $this - ->activityRepository - ->createQueryBuilder('activity') - ->select('COUNT(activity.id) as export_count_activity') - ->join('activity.person', 'person'); + $qb = $this->activityRepository->createQueryBuilder('activity') + ->join('activity.person', 'person') + ; + + $qb->select('COUNT(activity.id) as export_count_activity'); $qb ->where($qb->expr()->in('person.center', ':centers')) - ->setParameter('centers', $centers); + ->setParameter('centers', $centers) + ; return $qb; } @@ -102,12 +103,13 @@ class CountActivity implements ExportInterface, GroupedExportInterface { return [ Declarations::ACTIVITY, + Declarations::ACTIVITY_PERSON, //PersonDeclarations::PERSON_TYPE, ]; } public function getGroup(): string { - return 'Exports of activities'; + return 'Exports of activities linked to a person'; } } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php similarity index 96% rename from src/Bundle/ChillActivityBundle/Export/Export/ListActivity.php rename to src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php index 773c4bee1..21a68fb93 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php @@ -9,7 +9,7 @@ declare(strict_types=1); -namespace Chill\ActivityBundle\Export\Export; +namespace Chill\ActivityBundle\Export\Export\LinkedToPerson; use Chill\ActivityBundle\Entity\ActivityReason; use Chill\ActivityBundle\Repository\ActivityRepository; @@ -97,7 +97,7 @@ class ListActivity implements ListInterface, GroupedExportInterface public function getDescription() { - return 'List activities description'; + return 'List activities linked to a person description'; } public function getLabels($key, array $values, $data) @@ -183,12 +183,12 @@ class ListActivity implements ListInterface, GroupedExportInterface public function getTitle() { - return 'List activities'; + return 'List activity linked to a person'; } - public function getType() + public function getType(): string { - return 'activity'; + return Declarations::ACTIVITY; } public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) @@ -279,12 +279,13 @@ class ListActivity implements ListInterface, GroupedExportInterface { return [ Declarations::ACTIVITY, + Declarations::ACTIVITY_PERSON, //PersonDeclarations::PERSON_TYPE, ]; } public function getGroup(): string { - return 'Exports of activities'; + return 'Exports of activities linked to a person'; } } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/StatActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php similarity index 87% rename from src/Bundle/ChillActivityBundle/Export/Export/StatActivityDuration.php rename to src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php index 5f02928c6..5fae246f8 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/StatActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php @@ -9,7 +9,7 @@ declare(strict_types=1); -namespace Chill\ActivityBundle\Export\Export; +namespace Chill\ActivityBundle\Export\Export\LinkedToPerson; use Chill\ActivityBundle\Repository\ActivityRepository; use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter; @@ -63,7 +63,7 @@ class StatActivityDuration implements ExportInterface, GroupedExportInterface public function getDescription() { if (self::SUM === $this->action) { - return 'Sum activities duration by various parameters.'; + return 'Sum activities linked to a person duration by various parameters.'; } } @@ -73,7 +73,7 @@ class StatActivityDuration implements ExportInterface, GroupedExportInterface throw new LogicException(sprintf('The key %s is not used by this export', $key)); } - $header = self::SUM === $this->action ? 'Sum of activities duration' : false; + $header = self::SUM === $this->action ? 'Sum activities linked to a person duration' : false; return static fn (string $value) => '_header' === $value ? $header : $value; } @@ -91,13 +91,13 @@ class StatActivityDuration implements ExportInterface, GroupedExportInterface public function getTitle() { if (self::SUM === $this->action) { - return 'Sum activity duration'; + return 'Sum activity linked to a person duration'; } } - public function getType() + public function getType(): string { - return 'activity'; + return Declarations::ACTIVITY; } public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) @@ -131,12 +131,13 @@ class StatActivityDuration implements ExportInterface, GroupedExportInterface { return [ Declarations::ACTIVITY, + Declarations::ACTIVITY_PERSON, //PersonDeclarations::PERSON_TYPE, ]; } public function getGroup(): string { - return 'Exports of activities'; + return 'Exports of activities linked to a person'; } } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php index 7a7fed3ee..4b20553af 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php @@ -13,11 +13,11 @@ namespace Chill\ActivityBundle\Export\Filter; use Chill\ActivityBundle\Export\Declarations; use Chill\MainBundle\Export\FilterInterface; +use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Form\Type\Export\FilterType; use DateTime; use Doctrine\ORM\Query\Expr; use Doctrine\ORM\QueryBuilder; -use Symfony\Component\Form\Extension\Core\Type\DateType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormError; use Symfony\Component\Form\FormEvent; @@ -65,29 +65,16 @@ class ActivityDateFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder) { - $builder->add( - 'date_from', - DateType::class, - [ + $builder + ->add('date_from', ChillDateType::class, [ 'label' => 'Activities after this date', 'data' => new DateTime(), - 'attr' => ['class' => 'datepicker'], - 'widget' => 'single_text', - 'format' => 'dd-MM-yyyy', - ] - ); - - $builder->add( - 'date_to', - DateType::class, - [ + ]) + ->add('date_to', ChillDateType::class, [ 'label' => 'Activities before this date', 'data' => new DateTime(), - 'attr' => ['class' => 'datepicker'], - 'widget' => 'single_text', - 'format' => 'dd-MM-yyyy', - ] - ); + ]) + ; $builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) { /** @var \Symfony\Component\Form\FormInterface $filterForm */ diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityReasonFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityReasonFilter.php index de6baac03..eef032818 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityReasonFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityReasonFilter.php @@ -82,7 +82,7 @@ class ActivityReasonFilter implements ExportElementValidatedInterface, FilterInt public function applyOn(): string { - return Declarations::ACTIVITY; + return Declarations::ACTIVITY_PERSON; } public function buildForm(FormBuilderInterface $builder) diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php index 9019bf3cd..665515cb1 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php @@ -69,32 +69,26 @@ class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInter public function buildForm(FormBuilderInterface $builder) { - $builder->add( - 'types', - EntityType::class, - [ - 'class' => ActivityType::class, - 'choice_label' => fn (ActivityType $type) => $this->translatableStringHelper->localize($type->getName()), - 'multiple' => true, - 'expanded' => false, - ] - ); + $builder->add('types', EntityType::class, [ + 'class' => ActivityType::class, + 'choice_label' => fn (ActivityType $type) => $this->translatableStringHelper->localize($type->getName()), + 'group_by' => fn (ActivityType $type) => $this->translatableStringHelper->localize($type->getCategory()->getName()), + 'multiple' => true, + 'expanded' => false, + ]); } public function describeAction($data, $format = 'string') { // collect all the reasons'name used in this filter in one array $reasonsNames = array_map( - fn (ActivityType $t): string => '"' . $this->translatableStringHelper->localize($t->getName()) . '"', + fn (ActivityType $t): string => $this->translatableStringHelper->localize($t->getName()), $this->activityTypeRepository->findBy(['id' => $data['types']->toArray()]) ); - return [ - 'Filtered by activity type: only %list%', - [ - '%list%' => implode(', ', $reasonsNames), - ], - ]; + return ['Filtered by activity type: only %list%', [ + '%list%' => implode(', ou ', $reasonsNames), + ]]; } public function getTitle() diff --git a/src/Bundle/ChillActivityBundle/config/services/export.yaml b/src/Bundle/ChillActivityBundle/config/services/export.yaml index 366c9c1b1..c6b0e9718 100644 --- a/src/Bundle/ChillActivityBundle/config/services/export.yaml +++ b/src/Bundle/ChillActivityBundle/config/services/export.yaml @@ -4,25 +4,45 @@ services: autoconfigure: true ## Indicators - chill.activity.export.count_activity: - class: Chill\ActivityBundle\Export\Export\CountActivity + chill.activity.export.count_activity_linked_to_person: + class: Chill\ActivityBundle\Export\Export\LinkedToPerson\CountActivity tags: - - { name: chill.export, alias: 'count_activity' } - + - { name: chill.export, alias: 'count_activity_linked_to_person' } + + chill.activity.export.sum_activity_duration_linked_to_person: + class: Chill\ActivityBundle\Export\Export\LinkedToPerson\StatActivityDuration + tags: + - { name: chill.export, alias: 'sum_activity_duration_linked_to_person' } + + chill.activity.export.list_activity_linked_to_person: + class: Chill\ActivityBundle\Export\Export\LinkedToPerson\ListActivity + tags: + - { name: chill.export, alias: 'list_activity_linked_to_person' } + chill.activity.export.count_activity_linked_to_acp: - class: Chill\ActivityBundle\Export\Export\CountActivityLinkedToACP + class: Chill\ActivityBundle\Export\Export\LinkedToACP\CountActivity tags: - { name: chill.export, alias: 'count_activity_linked_to_acp' } - chill.activity.export.sum_activity_duration: - class: Chill\ActivityBundle\Export\Export\StatActivityDuration + chill.activity.export.sum_activity_duration_linked_to_acp: + class: Chill\ActivityBundle\Export\Export\LinkedToACP\SumActivityDuration tags: - - { name: chill.export, alias: 'sum_activity_duration' } + - { name: chill.export, alias: 'sum_activity_duration_linked_to_acp' } - chill.activity.export.list_activity: - class: Chill\ActivityBundle\Export\Export\ListActivity + chill.activity.export.sum_activity_visit_duration_linked_to_acp: + class: Chill\ActivityBundle\Export\Export\LinkedToACP\SumActivityVisitDuration tags: - - { name: chill.export, alias: 'list_activity' } + - { name: chill.export, alias: 'sum_activity_visit_duration_linked_to_acp' } + + chill.activity.export.avg_activity_duration_linked_to_acp: + class: Chill\ActivityBundle\Export\Export\LinkedToACP\AvgActivityDuration + tags: + - { name: chill.export, alias: 'avg_activity_duration_linked_to_acp' } + + chill.activity.export.avg_activity_visit_duration_linked_to_acp: + class: Chill\ActivityBundle\Export\Export\LinkedToACP\AvgActivityVisitDuration + tags: + - { name: chill.export, alias: 'avg_activity_visit_duration_linked_to_acp' } ## Filters chill.activity.export.reason_filter: diff --git a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml index 9cc8d47af..f6bfafc41 100644 --- a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml @@ -203,23 +203,39 @@ Are you sure you want to remove the activity about "%name%" ?: Êtes-vous sûr d The activity has been successfully removed.: L'activité a été supprimée. # exports -Exports of activities: Exports des activités +Exports of activities linked to a person: Exports des activités liées à une personne Number of activities linked to a person: Nombre d'activités liées à une personne -Count activities linked to a person: Nombre d'activités liées à une personne +Count activities linked to a person: Nombre d'activités Count activities linked to a person by various parameters.: Compte le nombre d'activités enregistrées et liées à une personne en fonction de différents paramètres. -Sum activity duration: Total de la durée des activités -Sum activities duration by various parameters.: Additionne la durée des activités en fonction de différents paramètres. -List activities: Liste les activités -List activities description: Créer la liste des activités +Sum activity linked to a person duration: Durée des activités +Sum activities linked to a person duration: Durée des activités liés à un usager +Sum activities linked to a person duration by various parameters.: Additionne la durée des activités en fonction de différents paramètres. +List activity linked to a person: Liste les activités +List activities linked to a person: Liste des activités liés à un usager +List activities linked to a person description: Crée la liste des activités en fonction de différents paramètres. + +Exports of activities linked to an accompanying period: Exports des activités liées à un parcours Number of activities linked to an accompanying period: Nombre d'activités liées à un parcours -Count activities linked to an accompanying period: Nombre d'activités liées à un parcours +Count activities linked to an accompanying period: Nombre d'activités Count activities linked to an accompanying period by various parameters.: Compte le nombre d'activités enregistrées et liées à un parcours en fonction de différents paramètres. +Sum activity linked to an accompanying period duration: Somme de la durée des activités +Sum activities linked to an accompanying period duration: Somme de la durée des activités liées à un parcours +Sum activities linked to an accompanying period duration by various parameters.: Additionne la durée des activités en fonction de différents paramètres. +Sum activity linked to an accompanying period visit duration: Somme de la durée de déplacement des activités +Sum activities linked to an accompanying period visit duration: Somme de la durée de déplacement des activités liées à un parcours +Sum activities linked to an accompanying period visit duration by various parameters.: Additionne la durée de déplacement des activités en fonction de différents paramètres. +Average activity linked to an accompanying period duration: Moyenne de la durée des activités +Average activities linked to an accompanying period duration: Moyenne de la durée des activités liées à un parcours +Average activities linked to an accompanying period duration by various parameters.: Moyenne de la durée des activités en fonction de différents paramètres. +Average activity linked to an accompanying period visit duration: Moyenne de la durée de déplacement des activités +Average activities linked to an accompanying period visit duration: Moyenne de la durée de déplacement des activités liées à un parcours +Average activities linked to an accompanying period visit duration by various parameters.: Moyenne de la durée de déplacement des activités en fonction de différents paramètres. #filters -Filter by reason: Filtrer par sujet d'activité +Filter by reason: Filtrer les activités par sujet 'Filtered by reasons: only %list%': 'Filtré par sujet: seulement %list%' -'Filtered by activity type: only %list%': "Filtré par type d'activité: seulement %list%" -Filtered by date activity: Filtrer par date d'activité +'Filtered by activity type: only %list%': "Filtré par type d'activité: uniquement %list%" +Filtered by date activity: Filtrer les activités par date Activities after this date: Activités après cette date Activities before this date: Activités avant cette date "Filtered by date of activity: only between %date_from% and %date_to%": "Filtré par date de l'activité: uniquement entre %date_from% et %date_to%" @@ -231,7 +247,7 @@ Implied in an activity before this date: Impliqué dans une activité avant cett Filtered by person having an activity between %date_from% and %date_to% with reasons %reasons_name%: Filtré par personnes associées à une activité entre %date_from% et %date_to% avec les sujets %reasons_name% Activity reasons for those activities: Sujets de ces activités -Filter by activity type: Filtrer par type d'activité +Filter by activity type: Filtrer les activités par type #aggregators Activity type: Type d'activité @@ -240,9 +256,9 @@ By reason: Par sujet By category of reason: Par catégorie de sujet Reason's level: Niveau du sujet Group by reasons: Sujet d'activité -Aggregate by activity user: Grouper par utilisateur lié à l'activité -Aggregate by activity type: Grouper par type d'activité -Aggregate by activity reason: Grouper par sujet de l'activité +Aggregate by activity user: Grouper les activités par utilisateur +Aggregate by activity type: Grouper les activités par type +Aggregate by activity reason: Grouper les activités par sujet Last activities: Les dernières activités diff --git a/src/Bundle/ChillActivityBundle/translations/messages.nl.yaml b/src/Bundle/ChillActivityBundle/translations/messages.nl.yaml index d24eacf0a..0403e55ee 100644 --- a/src/Bundle/ChillActivityBundle/translations/messages.nl.yaml +++ b/src/Bundle/ChillActivityBundle/translations/messages.nl.yaml @@ -195,7 +195,7 @@ Number of activities: Nombre d'activités #filters Filter by reason: Filtrer par sujet d'activité 'Filtered by reasons: only %list%': 'Filtré par sujet: seulement %list%' -'Filtered by activity type: only %list%': "Filtré par type d'activity: seulement %list%" +'Filtered by activity type: only %list%': "Filtré par type d'activity: uniquement %list%" Filtered by date activity: Filtrer par date d'activité Activities after this date: Activités après cette date Activities before this date: Activités avant cette date diff --git a/src/Bundle/ChillMainBundle/Controller/ExportController.php b/src/Bundle/ChillMainBundle/Controller/ExportController.php index 5dcd158f6..a7404b879 100644 --- a/src/Bundle/ChillMainBundle/Controller/ExportController.php +++ b/src/Bundle/ChillMainBundle/Controller/ExportController.php @@ -86,6 +86,9 @@ class ExportController extends AbstractController { /** @var \Chill\MainBundle\Export\ExportManager $exportManager */ $exportManager = $this->exportManager; + + $export = $exportManager->getExport($alias); + $key = $request->query->get('key', null); [$dataCenters, $dataExport, $dataFormatter] = $this->rebuildData($key); @@ -100,7 +103,8 @@ class ExportController extends AbstractController $viewVariables = [ 'alias' => $alias, - 'export' => $exportManager->getExport($alias), + 'export' => $export, + 'export_group' => $this->getExportGroup($export), ]; if ($formater instanceof \Chill\MainBundle\Export\Formatter\CSVListFormatter) { @@ -316,6 +320,7 @@ class ExportController extends AbstractController 'form' => $form->createView(), 'export_alias' => $alias, 'export' => $export, + 'export_group' => $this->getExportGroup($export), ]); } @@ -371,6 +376,7 @@ class ExportController extends AbstractController [ 'form' => $form->createView(), 'export' => $export, + 'export_group' => $this->getExportGroup($export), ] ); } @@ -514,6 +520,7 @@ class ExportController extends AbstractController [ 'form' => $form->createView(), 'export' => $export, + 'export_group' => $this->getExportGroup($export), ] ); } @@ -565,4 +572,19 @@ class ExportController extends AbstractController throw new LogicException("the step {$step} is not defined."); } } + + private function getExportGroup($target): string + { + $exportManager = $this->exportManager; + + $groups = $exportManager->getExportsGrouped(true); + + foreach ($groups as $group => $array) { + foreach ($array as $alias => $export) { + if ($export === $target) { + return $group; + } + } + } + } } diff --git a/src/Bundle/ChillMainBundle/Resources/views/Export/download.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Export/download.html.twig index 505c22ab4..fa568d857 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Export/download.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Export/download.html.twig @@ -36,6 +36,11 @@ window.addEventListener("DOMContentLoaded", function(e) { {% block content %}
+
+ + {{ export_group|trans }} +
+

{{ export.title|trans }}

{{ "Download export"|trans }}

diff --git a/src/Bundle/ChillMainBundle/Resources/views/Export/new.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Export/new.html.twig index 4ee857f00..8aac6c253 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Export/new.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Export/new.html.twig @@ -27,6 +27,11 @@ {% block content %}
+
+ + {{ export_group|trans }} +
+

{{ export.title|trans }}

{{ export.description|trans }}

diff --git a/src/Bundle/ChillMainBundle/Resources/views/Export/new_centers_step.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Export/new_centers_step.html.twig index 9adad67df..4a2d9ab9e 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Export/new_centers_step.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Export/new_centers_step.html.twig @@ -23,6 +23,11 @@ {% block content %}
+
+ + {{ export_group|trans }} +
+

{{ export.title|trans }}

{{ export.description|trans }}

diff --git a/src/Bundle/ChillMainBundle/Resources/views/Export/new_formatter_step.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Export/new_formatter_step.html.twig index 4854b1c9d..443816611 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Export/new_formatter_step.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Export/new_formatter_step.html.twig @@ -22,6 +22,11 @@ {% block content %}
+ +
+ + {{ export_group|trans }} +

{{ export.title|trans }}

diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php index 3c7a0e319..1e703754e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php @@ -128,6 +128,8 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface { return [ Declarations::EVAL_TYPE, + //Declarations::ACP_TYPE, + //Declarations::SOCIAL_WORK_ACTION_TYPE, ]; } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php index 9767c17ed..a43345ff3 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php @@ -130,6 +130,7 @@ class CountHousehold implements ExportInterface, GroupedExportInterface { return [ Declarations::HOUSEHOLD_TYPE, + //Declarations::ACP_TYPE ]; } diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index c18e6ce29..34cc1c8af 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -348,7 +348,7 @@ Accompanying courses duration: Durée moyenne des parcours Create an average of accompanying courses duration according to various filters: Moyenne de la durée des parcours en jours, selon différents filtres. Closingdate to apply: Date de fin à prendre en compte lorsque le parcours n'est pas clotûré -Exports of social work actions: Exports des actions d'accompangement +Exports of social work actions: Exports des actions d'accompagnement Count social work actions: Nombre d'actions d'accompagnement Count social work actions by various parameters: Compte le nombre d'actions d'accompagnement en fonction de différents filtres. @@ -359,7 +359,7 @@ Count evaluation by various parameters.: Compte le nombre d'évaluations selon d Exports of households: Exports des ménages Count households: Nombre de ménages -Count household by various parameters.: Compte le nombre de ménages selon différents filtres. +Count household by various parameters.: Compte le nombre de ménages impliqués dans un parcours selon différents filtres. ## filters Filter by person gender: Filtrer par genre de la personne @@ -433,6 +433,7 @@ Filter by user job: Filtrer les parcours par métier du référent Group by user job: Grouper les parcours par métier du référent Filter by social issue: Filtrer les parcours par problématiques sociales +Filter by scope: Filtrer par service Accepted socialissues: Problématiques sociales "Filtered by socialissues: only %socialissues%": "Filtré par problématique sociale: uniquement %socialissues%" Group by social issue: Grouper les parcours par problématiques sociales @@ -457,6 +458,10 @@ Evaluation: Évaluation "Filtered by evaluations: only %evals%": "Filtré par évaluation: uniquement %evals%" Group by evaluation: Grouper les parcours par évaluation +Group social work actions by action type: Grouper par type d'action +Group social work actions by goal: Grouper par objectif +Group social work actions by result: Grouper par résultat + Filter accompanying course by activity type: Filtrer les parcours par type d'activité Accepted activitytypes: Types d'activités "Filtered by activity types: only %activitytypes%": "Filtré par type d'activité: seulement %activitytypes%" @@ -539,10 +544,6 @@ Accepted agents: Agent traitant "Filtered by treating agent: only %agents%": "Filtré par agent traitant: uniquement %agents%" Group by treating agent: Grouper les actions par agent traitant -Group social work actions by action type: Grouper les actions par type d'action -Group social work actions by goal: Grouper par objectif -Group social work actions by result: Grouper par résultat - Filter by evaluation type: Filtrer les évaluations par type Accepted evaluationtype: Évaluations "Filtered by evaluation type: only %evals%": "Filtré par type d'évaluation: uniquement %evals%"