merge 111_exports

This commit is contained in:
Julie Lenaerts 2022-08-18 12:19:01 +02:00
commit 2bf5e934e9
26 changed files with 614 additions and 127 deletions

View File

@ -107,7 +107,7 @@ class ActivityReasonAggregator implements AggregatorInterface, ExportElementVali
public function applyOn(): string public function applyOn(): string
{ {
return Declarations::ACTIVITY; return Declarations::ACTIVITY_PERSON;
} }
public function buildForm(FormBuilderInterface $builder) public function buildForm(FormBuilderInterface $builder)

View File

@ -45,11 +45,19 @@ class ActivityTypeAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data) public function alterQuery(QueryBuilder $qb, $data)
{ {
// add select element if (!in_array('type', $qb->getAllAliases())) {
$qb->addSelect(sprintf('IDENTITY(activity.type) AS %s', self::KEY)); $qb->join('activity.activityType', 'type');
}
// add the "group by" part $qb->addSelect(sprintf('IDENTITY(activity.activityType) AS %s', self::KEY));
$qb->addGroupBy(self::KEY);
$groupby = $qb->getDQLPart('groupBy');
if (!empty($groupBy)) {
$qb->addGroupBy(self::KEY);
} else {
$qb->groupBy(self::KEY);
}
} }
public function applyOn(): string public function applyOn(): string

View File

@ -48,7 +48,7 @@ class ActivityUserAggregator implements AggregatorInterface
public function applyOn(): string public function applyOn(): string
{ {
return Declarations::ACTIVITY; return Declarations::ACTIVITY_PERSON;
} }
public function buildForm(FormBuilderInterface $builder) public function buildForm(FormBuilderInterface $builder)

View File

@ -17,4 +17,8 @@ namespace Chill\ActivityBundle\Export;
abstract class Declarations abstract class Declarations
{ {
public const ACTIVITY = 'activity'; public const ACTIVITY = 'activity';
public const ACTIVITY_ACP = "activity_linked_to_acp";
public const ACTIVITY_PERSON = "activity_linked_to_person";
} }

View File

@ -0,0 +1,103 @@
<?php
namespace Chill\ActivityBundle\Export\Export\LinkedToACP;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Declarations;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
use Chill\MainBundle\Export\ExportInterface;
use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
use Closure;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Role\Role;
class AvgActivityDuration implements ExportInterface, GroupedExportInterface
{
protected EntityRepository $repository;
public function __construct(
EntityManagerInterface $em
) {
$this->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';
}
}

View File

@ -0,0 +1,103 @@
<?php
namespace Chill\ActivityBundle\Export\Export\LinkedToACP;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Declarations;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
use Chill\MainBundle\Export\ExportInterface;
use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
use Closure;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Role\Role;
class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterface
{
protected EntityRepository $repository;
public function __construct(
EntityManagerInterface $em
) {
$this->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';
}
}

View File

@ -9,56 +9,58 @@
declare(strict_types=1); 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\Export\Declarations;
use Chill\ActivityBundle\Repository\ActivityRepository;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter; use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\ExportInterface;
use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface; use Chill\MainBundle\Export\GroupedExportInterface;
use Chill\PersonBundle\Export\Declarations as PersonDeclarations; use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query; use Doctrine\ORM\Query;
use LogicException; use LogicException;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Role\Role; 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( public function __construct(
ActivityRepository $activityRepository EntityManagerInterface $em
) { ) {
$this->activityRepository = $activityRepository; $this->repository = $em->getRepository(Activity::class);
} }
public function buildForm(FormBuilderInterface $builder) public function buildForm(FormBuilderInterface $builder)
{ {
} }
public function getAllowedFormattersTypes() public function getAllowedFormattersTypes(): array
{ {
return [FormatterInterface::TYPE_TABULAR]; return [FormatterInterface::TYPE_TABULAR];
} }
public function getDescription() public function getDescription(): string
{ {
return 'Count activities linked to an accompanying period by various parameters.'; return 'Count activities linked to an accompanying period by various parameters.';
} }
public function getLabels($key, array $values, $data) 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"); 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; 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) public function getResult($qb, $data)
@ -66,48 +68,43 @@ class CountActivityLinkedToACP implements ExportInterface, GroupedExportInterfac
return $qb->getQuery()->getResult(Query::HYDRATE_SCALAR); return $qb->getQuery()->getResult(Query::HYDRATE_SCALAR);
} }
public function getTitle() public function getTitle(): string
{ {
return 'Count activities linked to an accompanying period'; return 'Count activities linked to an accompanying period';
} }
public function getType() public function getType(): string
{ {
return Declarations::ACTIVITY; return Declarations::ACTIVITY;
} }
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{ {
$centers = array_map(static fn ($el) => $el['center'], $acl); $qb = $this->repository->createQueryBuilder('activity')
->join('activity.accompanyingPeriod', 'acp')
$qb = $this ;
->activityRepository
->createQueryBuilder('activity')
->select('COUNT(activity.id) as export_count_activity_acp');
$qb->andWhere(
$qb->expr()->isNotNull('activity.accompanyingPeriod')
);
$qb->select('COUNT(activity.id) as export_count_activity');
return $qb; return $qb;
} }
public function requiredRole() public function requiredRole(): Role
{ {
return new Role(ActivityStatsVoter::STATS); return new Role(ActivityStatsVoter::STATS);
} }
public function supportsModifiers() public function supportsModifiers(): array
{ {
return [ return [
Declarations::ACTIVITY, Declarations::ACTIVITY,
//PersonDeclarations::PERSON_TYPE, Declarations::ACTIVITY_ACP,
//PersonDeclarations::ACP_TYPE, //PersonDeclarations::ACP_TYPE,
]; ];
} }
public function getGroup(): string public function getGroup(): string
{ {
return 'Exports of activities'; return 'Exports of activities linked to an accompanying period';
} }
} }

View File

@ -0,0 +1,103 @@
<?php
namespace Chill\ActivityBundle\Export\Export\LinkedToACP;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Declarations;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
use Chill\MainBundle\Export\ExportInterface;
use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
use Closure;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Role\Role;
class SumActivityDuration implements ExportInterface, GroupedExportInterface
{
protected EntityRepository $repository;
public function __construct(
EntityManagerInterface $em
) {
$this->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';
}
}

View File

@ -0,0 +1,102 @@
<?php
namespace Chill\ActivityBundle\Export\Export\LinkedToACP;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Declarations;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
use Chill\MainBundle\Export\ExportInterface;
use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
use Closure;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Role\Role;
class SumActivityVisitDuration implements ExportInterface, GroupedExportInterface
{
protected EntityRepository $repository;
public function __construct(
EntityManagerInterface $em
) {
$this->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';
}
}

View File

@ -9,7 +9,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace Chill\ActivityBundle\Export\Export; namespace Chill\ActivityBundle\Export\Export\LinkedToPerson;
use Chill\ActivityBundle\Repository\ActivityRepository; use Chill\ActivityBundle\Repository\ActivityRepository;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter; use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
@ -71,24 +71,25 @@ class CountActivity implements ExportInterface, GroupedExportInterface
return 'Count activities linked to a person'; 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 = []) public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{ {
$centers = array_map(static fn ($el) => $el['center'], $acl); $centers = array_map(static fn ($el) => $el['center'], $acl);
$qb = $this $qb = $this->activityRepository->createQueryBuilder('activity')
->activityRepository ->join('activity.person', 'person')
->createQueryBuilder('activity') ;
->select('COUNT(activity.id) as export_count_activity')
->join('activity.person', 'person'); $qb->select('COUNT(activity.id) as export_count_activity');
$qb $qb
->where($qb->expr()->in('person.center', ':centers')) ->where($qb->expr()->in('person.center', ':centers'))
->setParameter('centers', $centers); ->setParameter('centers', $centers)
;
return $qb; return $qb;
} }
@ -102,12 +103,13 @@ class CountActivity implements ExportInterface, GroupedExportInterface
{ {
return [ return [
Declarations::ACTIVITY, Declarations::ACTIVITY,
Declarations::ACTIVITY_PERSON,
//PersonDeclarations::PERSON_TYPE, //PersonDeclarations::PERSON_TYPE,
]; ];
} }
public function getGroup(): string public function getGroup(): string
{ {
return 'Exports of activities'; return 'Exports of activities linked to a person';
} }
} }

View File

@ -9,7 +9,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace Chill\ActivityBundle\Export\Export; namespace Chill\ActivityBundle\Export\Export\LinkedToPerson;
use Chill\ActivityBundle\Entity\ActivityReason; use Chill\ActivityBundle\Entity\ActivityReason;
use Chill\ActivityBundle\Repository\ActivityRepository; use Chill\ActivityBundle\Repository\ActivityRepository;
@ -97,7 +97,7 @@ class ListActivity implements ListInterface, GroupedExportInterface
public function getDescription() public function getDescription()
{ {
return 'List activities description'; return 'List activities linked to a person description';
} }
public function getLabels($key, array $values, $data) public function getLabels($key, array $values, $data)
@ -183,12 +183,12 @@ class ListActivity implements ListInterface, GroupedExportInterface
public function getTitle() 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 = []) public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
@ -279,12 +279,13 @@ class ListActivity implements ListInterface, GroupedExportInterface
{ {
return [ return [
Declarations::ACTIVITY, Declarations::ACTIVITY,
Declarations::ACTIVITY_PERSON,
//PersonDeclarations::PERSON_TYPE, //PersonDeclarations::PERSON_TYPE,
]; ];
} }
public function getGroup(): string public function getGroup(): string
{ {
return 'Exports of activities'; return 'Exports of activities linked to a person';
} }
} }

View File

@ -9,7 +9,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace Chill\ActivityBundle\Export\Export; namespace Chill\ActivityBundle\Export\Export\LinkedToPerson;
use Chill\ActivityBundle\Repository\ActivityRepository; use Chill\ActivityBundle\Repository\ActivityRepository;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter; use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
@ -63,7 +63,7 @@ class StatActivityDuration implements ExportInterface, GroupedExportInterface
public function getDescription() public function getDescription()
{ {
if (self::SUM === $this->action) { 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)); 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; return static fn (string $value) => '_header' === $value ? $header : $value;
} }
@ -91,13 +91,13 @@ class StatActivityDuration implements ExportInterface, GroupedExportInterface
public function getTitle() public function getTitle()
{ {
if (self::SUM === $this->action) { 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 = []) public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
@ -131,12 +131,13 @@ class StatActivityDuration implements ExportInterface, GroupedExportInterface
{ {
return [ return [
Declarations::ACTIVITY, Declarations::ACTIVITY,
Declarations::ACTIVITY_PERSON,
//PersonDeclarations::PERSON_TYPE, //PersonDeclarations::PERSON_TYPE,
]; ];
} }
public function getGroup(): string public function getGroup(): string
{ {
return 'Exports of activities'; return 'Exports of activities linked to a person';
} }
} }

View File

@ -13,11 +13,11 @@ namespace Chill\ActivityBundle\Export\Filter;
use Chill\ActivityBundle\Export\Declarations; use Chill\ActivityBundle\Export\Declarations;
use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Form\Type\Export\FilterType; use Chill\MainBundle\Form\Type\Export\FilterType;
use DateTime; use DateTime;
use Doctrine\ORM\Query\Expr; use Doctrine\ORM\Query\Expr;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormError; use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvent;
@ -65,29 +65,16 @@ class ActivityDateFilter implements FilterInterface
public function buildForm(FormBuilderInterface $builder) public function buildForm(FormBuilderInterface $builder)
{ {
$builder->add( $builder
'date_from', ->add('date_from', ChillDateType::class, [
DateType::class,
[
'label' => 'Activities after this date', 'label' => 'Activities after this date',
'data' => new DateTime(), 'data' => new DateTime(),
'attr' => ['class' => 'datepicker'], ])
'widget' => 'single_text', ->add('date_to', ChillDateType::class, [
'format' => 'dd-MM-yyyy',
]
);
$builder->add(
'date_to',
DateType::class,
[
'label' => 'Activities before this date', 'label' => 'Activities before this date',
'data' => new DateTime(), 'data' => new DateTime(),
'attr' => ['class' => 'datepicker'], ])
'widget' => 'single_text', ;
'format' => 'dd-MM-yyyy',
]
);
$builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) { $builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
/** @var \Symfony\Component\Form\FormInterface $filterForm */ /** @var \Symfony\Component\Form\FormInterface $filterForm */

View File

@ -82,7 +82,7 @@ class ActivityReasonFilter implements ExportElementValidatedInterface, FilterInt
public function applyOn(): string public function applyOn(): string
{ {
return Declarations::ACTIVITY; return Declarations::ACTIVITY_PERSON;
} }
public function buildForm(FormBuilderInterface $builder) public function buildForm(FormBuilderInterface $builder)

View File

@ -69,32 +69,26 @@ class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInter
public function buildForm(FormBuilderInterface $builder) public function buildForm(FormBuilderInterface $builder)
{ {
$builder->add( $builder->add('types', EntityType::class, [
'types', 'class' => ActivityType::class,
EntityType::class, 'choice_label' => fn (ActivityType $type) => $this->translatableStringHelper->localize($type->getName()),
[ 'group_by' => fn (ActivityType $type) => $this->translatableStringHelper->localize($type->getCategory()->getName()),
'class' => ActivityType::class, 'multiple' => true,
'choice_label' => fn (ActivityType $type) => $this->translatableStringHelper->localize($type->getName()), 'expanded' => false,
'multiple' => true, ]);
'expanded' => false,
]
);
} }
public function describeAction($data, $format = 'string') public function describeAction($data, $format = 'string')
{ {
// collect all the reasons'name used in this filter in one array // collect all the reasons'name used in this filter in one array
$reasonsNames = array_map( $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()]) $this->activityTypeRepository->findBy(['id' => $data['types']->toArray()])
); );
return [ return ['Filtered by activity type: only %list%', [
'Filtered by activity type: only %list%', '%list%' => implode(', ou ', $reasonsNames),
[ ]];
'%list%' => implode(', ', $reasonsNames),
],
];
} }
public function getTitle() public function getTitle()

View File

@ -4,25 +4,45 @@ services:
autoconfigure: true autoconfigure: true
## Indicators ## Indicators
chill.activity.export.count_activity: chill.activity.export.count_activity_linked_to_person:
class: Chill\ActivityBundle\Export\Export\CountActivity class: Chill\ActivityBundle\Export\Export\LinkedToPerson\CountActivity
tags: 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: chill.activity.export.count_activity_linked_to_acp:
class: Chill\ActivityBundle\Export\Export\CountActivityLinkedToACP class: Chill\ActivityBundle\Export\Export\LinkedToACP\CountActivity
tags: tags:
- { name: chill.export, alias: 'count_activity_linked_to_acp' } - { name: chill.export, alias: 'count_activity_linked_to_acp' }
chill.activity.export.sum_activity_duration: chill.activity.export.sum_activity_duration_linked_to_acp:
class: Chill\ActivityBundle\Export\Export\StatActivityDuration class: Chill\ActivityBundle\Export\Export\LinkedToACP\SumActivityDuration
tags: tags:
- { name: chill.export, alias: 'sum_activity_duration' } - { name: chill.export, alias: 'sum_activity_duration_linked_to_acp' }
chill.activity.export.list_activity: chill.activity.export.sum_activity_visit_duration_linked_to_acp:
class: Chill\ActivityBundle\Export\Export\ListActivity class: Chill\ActivityBundle\Export\Export\LinkedToACP\SumActivityVisitDuration
tags: 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 ## Filters
chill.activity.export.reason_filter: chill.activity.export.reason_filter:

View File

@ -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. The activity has been successfully removed.: L'activité a été supprimée.
# exports # 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 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. 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 activity linked to a person duration: 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. Sum activities linked to a person duration: Durée des activités liés à un usager
List activities: Liste les activités 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 activities description: Créer la liste des activités 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 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. 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 #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 reasons: only %list%': 'Filtré par sujet: seulement %list%'
'Filtered by activity type: only %list%': "Filtré par type d'activité: seulement %list%" 'Filtered by activity type: only %list%': "Filtré par type d'activité: uniquement %list%"
Filtered by date activity: Filtrer par date d'activité Filtered by date activity: Filtrer les activités par date
Activities after this date: Activités après cette date Activities after this date: Activités après cette date
Activities before this date: Activités avant 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%" "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% 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 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 #aggregators
Activity type: Type d'activité Activity type: Type d'activité
@ -240,9 +256,9 @@ By reason: Par sujet
By category of reason: Par catégorie de sujet By category of reason: Par catégorie de sujet
Reason's level: Niveau du sujet Reason's level: Niveau du sujet
Group by reasons: Sujet d'activité Group by reasons: Sujet d'activité
Aggregate by activity user: Grouper par utilisateur lié à l'activité Aggregate by activity user: Grouper les activités par utilisateur
Aggregate by activity type: Grouper par type d'activité Aggregate by activity type: Grouper les activités par type
Aggregate by activity reason: Grouper par sujet de l'activité Aggregate by activity reason: Grouper les activités par sujet
Last activities: Les dernières activités Last activities: Les dernières activités

View File

@ -195,7 +195,7 @@ Number of activities: Nombre d'activités
#filters #filters
Filter by reason: Filtrer par sujet d'activité Filter by reason: Filtrer par sujet d'activité
'Filtered by reasons: only %list%': 'Filtré par sujet: seulement %list%' '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é Filtered by date activity: Filtrer par date d'activité
Activities after this date: Activités après cette date Activities after this date: Activités après cette date
Activities before this date: Activités avant cette date Activities before this date: Activités avant cette date

View File

@ -86,6 +86,9 @@ class ExportController extends AbstractController
{ {
/** @var \Chill\MainBundle\Export\ExportManager $exportManager */ /** @var \Chill\MainBundle\Export\ExportManager $exportManager */
$exportManager = $this->exportManager; $exportManager = $this->exportManager;
$export = $exportManager->getExport($alias);
$key = $request->query->get('key', null); $key = $request->query->get('key', null);
[$dataCenters, $dataExport, $dataFormatter] = $this->rebuildData($key); [$dataCenters, $dataExport, $dataFormatter] = $this->rebuildData($key);
@ -100,7 +103,8 @@ class ExportController extends AbstractController
$viewVariables = [ $viewVariables = [
'alias' => $alias, 'alias' => $alias,
'export' => $exportManager->getExport($alias), 'export' => $export,
'export_group' => $this->getExportGroup($export),
]; ];
if ($formater instanceof \Chill\MainBundle\Export\Formatter\CSVListFormatter) { if ($formater instanceof \Chill\MainBundle\Export\Formatter\CSVListFormatter) {
@ -316,6 +320,7 @@ class ExportController extends AbstractController
'form' => $form->createView(), 'form' => $form->createView(),
'export_alias' => $alias, 'export_alias' => $alias,
'export' => $export, 'export' => $export,
'export_group' => $this->getExportGroup($export),
]); ]);
} }
@ -371,6 +376,7 @@ class ExportController extends AbstractController
[ [
'form' => $form->createView(), 'form' => $form->createView(),
'export' => $export, 'export' => $export,
'export_group' => $this->getExportGroup($export),
] ]
); );
} }
@ -514,6 +520,7 @@ class ExportController extends AbstractController
[ [
'form' => $form->createView(), 'form' => $form->createView(),
'export' => $export, 'export' => $export,
'export_group' => $this->getExportGroup($export),
] ]
); );
} }
@ -565,4 +572,19 @@ class ExportController extends AbstractController
throw new LogicException("the step {$step} is not defined."); 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;
}
}
}
}
} }

View File

@ -36,6 +36,11 @@ window.addEventListener("DOMContentLoaded", function(e) {
{% block content %} {% block content %}
<div class="col-md-10"> <div class="col-md-10">
<h6>
<i class="fa fa-folder-open-o fa-fw"></i>
{{ export_group|trans }}
</h6>
<h1>{{ export.title|trans }}</h1> <h1>{{ export.title|trans }}</h1>
<h2>{{ "Download export"|trans }}</h2> <h2>{{ "Download export"|trans }}</h2>

View File

@ -27,6 +27,11 @@
{% block content %} {% block content %}
<div class="col-md-10"> <div class="col-md-10">
<h6>
<i class="fa fa-folder-open-o fa-fw"></i>
{{ export_group|trans }}
</h6>
<h1>{{ export.title|trans }}</h1> <h1>{{ export.title|trans }}</h1>
<p>{{ export.description|trans }}</p> <p>{{ export.description|trans }}</p>

View File

@ -23,6 +23,11 @@
{% block content %} {% block content %}
<div class="col-md-10"> <div class="col-md-10">
<h6>
<i class="fa fa-folder-open-o fa-fw"></i>
{{ export_group|trans }}
</h6>
<h1>{{ export.title|trans }}</h1> <h1>{{ export.title|trans }}</h1>
<p>{{ export.description|trans }}</p> <p>{{ export.description|trans }}</p>

View File

@ -22,6 +22,11 @@
{% block content %} {% block content %}
<div class="col-md-10"> <div class="col-md-10">
<h6>
<i class="fa fa-folder-open-o fa-fw"></i>
{{ export_group|trans }}
</h6>
<h1>{{ export.title|trans }}</h1> <h1>{{ export.title|trans }}</h1>

View File

@ -128,6 +128,8 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface
{ {
return [ return [
Declarations::EVAL_TYPE, Declarations::EVAL_TYPE,
//Declarations::ACP_TYPE,
//Declarations::SOCIAL_WORK_ACTION_TYPE,
]; ];
} }

View File

@ -130,6 +130,7 @@ class CountHousehold implements ExportInterface, GroupedExportInterface
{ {
return [ return [
Declarations::HOUSEHOLD_TYPE, Declarations::HOUSEHOLD_TYPE,
//Declarations::ACP_TYPE
]; ];
} }

View File

@ -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. 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é 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: 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. 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 Exports of households: Exports des ménages
Count households: Nombre de 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 ## filters
Filter by person gender: Filtrer par genre de la personne 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 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 social issue: Filtrer les parcours par problématiques sociales
Filter by scope: Filtrer par service
Accepted socialissues: Problématiques sociales Accepted socialissues: Problématiques sociales
"Filtered by socialissues: only %socialissues%": "Filtré par problématique sociale: uniquement %socialissues%" "Filtered by socialissues: only %socialissues%": "Filtré par problématique sociale: uniquement %socialissues%"
Group by social issue: Grouper les parcours par problématiques sociales 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%" "Filtered by evaluations: only %evals%": "Filtré par évaluation: uniquement %evals%"
Group by evaluation: Grouper les parcours par évaluation 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é Filter accompanying course by activity type: Filtrer les parcours par type d'activité
Accepted activitytypes: Types d'activités Accepted activitytypes: Types d'activités
"Filtered by activity types: only %activitytypes%": "Filtré par type d'activité: seulement %activitytypes%" "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%" "Filtered by treating agent: only %agents%": "Filtré par agent traitant: uniquement %agents%"
Group by treating agent: Grouper les actions par agent traitant 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 Filter by evaluation type: Filtrer les évaluations par type
Accepted evaluationtype: Évaluations Accepted evaluationtype: Évaluations
"Filtered by evaluation type: only %evals%": "Filtré par type d'évaluation: uniquement %evals%" "Filtered by evaluation type: only %evals%": "Filtré par type d'évaluation: uniquement %evals%"