create 13 new export/filters/aggregators in Person and AsideActivity Bundles

* minor corrections on last commit
* modify related files (declaration, messages.fr, repository)
* yaml service declaration
This commit is contained in:
Mathieu Jaumotte 2022-10-28 16:26:11 +02:00 committed by Julien Fastré
parent 13d6e4587a
commit f751d2e9ab
21 changed files with 923 additions and 40 deletions

View File

@ -12,7 +12,7 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\Export\Aggregator;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\PersonBundle\Export\Declarations;
use Chill\ActivityBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
@ -31,7 +31,7 @@ class SentReceivedAggregator implements AggregatorInterface
public function applyOn(): string
{
return Declarations::ACP_TYPE;
return Declarations::ACTIVITY;
}
public function buildForm(FormBuilderInterface $builder)

View File

@ -0,0 +1,60 @@
<?php
declare(strict_types=1);
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\AsideActivityBundle\Export\Aggregator;
use Chill\MainBundle\Export\AggregatorInterface;
use ChillAsideActivityBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
class ByActivityTypeAggregator implements AggregatorInterface
{
public function addRole(): ?string
{
return null;
}
public function alterQuery(QueryBuilder $qb, $data)
{
$qb->addSelect('AS _aggregator')
->addGroupBy('_aggregator');
}
public function applyOn(): string
{
return Declarations::ASIDE_ACTIVITY_TYPE;
}
public function buildForm(FormBuilderInterface $builder)
{
// No form needed
}
public function getLabels($key, array $values, $data)
{
return function ($value): string {
if ('_header' === $value) {
return '';
}
};
}
public function getQueryKeys($data): array
{
return ['_aggregator'];
}
public function getTitle(): string
{
return 'Group by aside activity type';
}
}

View File

@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace ChillAsideActivityBundle\Export;
/**
* This class declare constants used for the export framework.
*/
abstract class Declarations
{
public const ASIDE_ACTIVITY_TYPE = 'aside_activity';
}

View File

@ -0,0 +1,111 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\AsideActivityBundle\Export\Export;
use Chill\AsideActivityBundle\Repository\AsideActivityRepository;
use Chill\MainBundle\Export\ExportInterface;
use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
use ChillAsideActivityBundle\Export\Declarations;
use Symfony\Component\Form\FormBuilderInterface;
use Doctrine\ORM\Query;
use LogicException;
class CountAsideActivity implements ExportInterface, GroupedExportInterface
{
private AsideActivityRepository $repository;
public function __construct(
AsideActivityRepository $repository
) {
$this->repository = $repository;
}
public function buildForm(FormBuilderInterface $builder)
{
// TODO: Implement buildForm() method.
}
public function getAllowedFormattersTypes(): array
{
return [FormatterInterface::TYPE_TABULAR];
}
public function getDescription(): string
{
return 'Count aside activities by various parameters.';
}
public function getGroup(): string
{
return 'Exports of aside activities';
}
public function getLabels($key, array $values, $data)
{
if ('export_result' !== $key) {
throw new LogicException("the key {$key} is not used by this export");
}
$labels = array_combine($values, $values);
$labels['_header'] = $this->getTitle();
return static function ($value) use ($labels) {
return $labels[$value];
};
}
public function getQueryKeys($data): array
{
return ['export_result'];
}
public function getResult($query, $data)
{
return $query->getQuery()->getResult(Query::HYDRATE_SCALAR);
}
public function getTitle(): string
{
return 'Count aside activities';
}
public function getType(): string
{
return Declarations::ASIDE_ACTIVITY_TYPE;
}
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
$qb = $this->repository->createQueryBuilder('aside');
$qb->andWhere();
$qb->select('COUNT() AS export_result');
return $qb;
}
public function requiredRole(): string
{
return '';
}
public function supportsModifiers(): array
{
return [];
}
}

View File

@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\AsideActivityBundle\Export\Filter;
use Chill\MainBundle\Export\FilterInterface;
use ChillAsideActivityBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
class ByActivityTypeFilter implements FilterInterface
{
public function addRole(): ?string
{
return null;
}
public function alterQuery(QueryBuilder $qb, $data)
{
$qb
->andWhere(
$qb->expr()->in('', ':')
)
->setParameter('', $data[]);
}
public function applyOn(): string
{
return Declarations::ASIDE_ACTIVITY_TYPE;
}
public function buildForm(FormBuilderInterface $builder)
{
$builder->add();
}
public function describeAction($data, $format = 'string'): array
{
return ['', [
]];
}
public function getTitle(): string
{
return 'Filter by aside activity type';
}
}

View File

@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\AsideActivityBundle\Export\Filter;
use Chill\MainBundle\Export\FilterInterface;
use ChillAsideActivityBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
class ByDateFilter implements FilterInterface
{
public function addRole(): ?string
{
return null;
}
public function alterQuery(QueryBuilder $qb, $data)
{
$qb
->andWhere(
$qb->expr()->in('', ':')
)
->setParameter('', $data[]);
}
public function applyOn(): string
{
return Declarations::ASIDE_ACTIVITY_TYPE;
}
public function buildForm(FormBuilderInterface $builder)
{
$builder->add();
}
public function describeAction($data, $format = 'string'): array
{
return ['', [
]];
}
public function getTitle(): string
{
return 'Filter by aside activity date';
}
}

View File

@ -12,46 +12,20 @@ declare(strict_types=1);
namespace Chill\AsideActivityBundle\Repository;
use Chill\AsideActivityBundle\Entity\AsideActivity;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\Persistence\ObjectRepository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
final class AsideActivityRepository implements ObjectRepository
/**
* @method AsideActivity|null find($id, $lockMode = null, $lockVersion = null)
* @method AsideActivity|null findOneBy(array $criteria, array $orderBy = null)
* @method AsideActivity[] findAll()
* @method AsideActivity[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
final class AsideActivityRepository extends ServiceEntityRepository
{
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
public function __construct(ManagerRegistry $registry)
{
$this->repository = $entityManager->getRepository(AsideActivity::class);
}
public function find($id): ?AsideActivity
{
return $this->repository->find($id);
}
/**
* @return AsideActivity[]
*/
public function findAll(): array
{
return $this->repository->findAll();
}
/**
* @param mixed|null $limit
* @param mixed|null $offset
*
* @return AsideActivity[]
*/
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
{
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
}
public function findOneBy(array $criteria): ?AsideActivity
{
return $this->repository->findOneBy($criteria);
parent::__construct($registry, AsideActivity::class);
}
public function getClassName(): string

View File

@ -20,3 +20,33 @@ services:
resource: "../Controller"
autowire: true
autoconfigure: true
## Exports
# indicators
Chill\AsideActivityBundle\Export\Export\CountAsideActivity:
autowire: true
autoconfigure: true
tags:
- { name: chill.export, alias: count_asideactivity }
# filters
Chill\AsideActivityBundle\Export\Filter\ByDateFilter:
autowire: true
autoconfigure: true
tags:
- { name: chill.export_filter, alias: asideactivity_bydate_filter }
Chill\AsideActivityBundle\Export\Filter\ByActivityTypeFilter:
autowire: true
autoconfigure: true
tags:
- { name: chill.export_filter, alias: asideactivity_activitytype_filter }
# aggregators
Chill\AsideActivityBundle\Export\Aggregator\ByActivityTypeAggregator:
autowire: true
autoconfigure: true
tags:
- { name: chill.export_aggregator, alias: asideactivity_activitytype_aggregator }

View File

@ -166,3 +166,10 @@ Aside activities: Activités annexes
Aside activity types: Types d'activités annexes
Aside activity type configuration: Configuration des categories d'activités annexes
Aside activity configuration: Configuration des activités annexes
# exports
Count aside activities: Nombre d'activités annexes
Count aside activities by various parameters.: Compte le nombre d'activités annexes selon divers critères
Filter by aside activity date: Filtrer les activités annexes par date
Filter by aside activity type: Filtrer les activités annexes par type d'activité
Group by aside activity type: Grouper les activités annexes par type d'activité

View File

@ -0,0 +1,60 @@
<?php
declare(strict_types=1);
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\PersonBundle\Export\Aggregator\EvaluationAggregators;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
class ByEndDateAggregator implements AggregatorInterface
{
public function addRole(): ?string
{
return null;
}
public function alterQuery(QueryBuilder $qb, $data)
{
$qb->addSelect('AS _aggregator')
->addGroupBy('_aggregator');
}
public function applyOn(): string
{
return Declarations::EVAL_TYPE;
}
public function buildForm(FormBuilderInterface $builder)
{
// No form needed
}
public function getLabels($key, array $values, $data)
{
return function ($value): string {
if ('_header' === $value) {
return '';
}
};
}
public function getQueryKeys($data): array
{
return ['_aggregator'];
}
public function getTitle(): string
{
return 'Group by end date evaluations';
}
}

View File

@ -0,0 +1,60 @@
<?php
declare(strict_types=1);
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\PersonBundle\Export\Aggregator\EvaluationAggregators;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
class ByMaxDateAggregator implements AggregatorInterface
{
public function addRole(): ?string
{
return null;
}
public function alterQuery(QueryBuilder $qb, $data)
{
$qb->addSelect('AS _aggregator')
->addGroupBy('_aggregator');
}
public function applyOn(): string
{
return Declarations::EVAL_TYPE;
}
public function buildForm(FormBuilderInterface $builder)
{
// No form needed
}
public function getLabels($key, array $values, $data)
{
return function ($value): string {
if ('_header' === $value) {
return '';
}
};
}
public function getQueryKeys($data): array
{
return ['_aggregator'];
}
public function getTitle(): string
{
return 'Group by max date evaluations';
}
}

View File

@ -0,0 +1,60 @@
<?php
declare(strict_types=1);
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\PersonBundle\Export\Aggregator\EvaluationAggregators;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
class ByStartDateAggregator implements AggregatorInterface
{
public function addRole(): ?string
{
return null;
}
public function alterQuery(QueryBuilder $qb, $data)
{
$qb->addSelect('AS _aggregator')
->addGroupBy('_aggregator');
}
public function applyOn(): string
{
return Declarations::EVAL_TYPE;
}
public function buildForm(FormBuilderInterface $builder)
{
// No form needed
}
public function getLabels($key, array $values, $data)
{
return function ($value): string {
if ('_header' === $value) {
return '';
}
};
}
public function getQueryKeys($data): array
{
return ['_aggregator'];
}
public function getTitle(): string
{
return 'Group by start date evaluations';
}
}

View File

@ -0,0 +1,60 @@
<?php
declare(strict_types=1);
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
class CurrentActionAggregator implements AggregatorInterface
{
public function addRole(): ?string
{
return null;
}
public function alterQuery(QueryBuilder $qb, $data)
{
$qb->addSelect('AS _aggregator')
->addGroupBy('_aggregator');
}
public function applyOn(): string
{
return Declarations::SOCIAL_WORK_ACTION_TYPE;
}
public function buildForm(FormBuilderInterface $builder)
{
// No form needed
}
public function getLabels($key, array $values, $data)
{
return function ($value): string {
if ('_header' === $value) {
return '';
}
};
}
public function getQueryKeys($data): array
{
return ['_aggregator'];
}
public function getTitle(): string
{
return 'Group by current actions';
}
}

View File

@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\PersonBundle\Export\Filter\EvaluationFilters;
use Chill\MainBundle\Export\FilterInterface;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
class ByEndDateFilter implements FilterInterface
{
public function addRole(): ?string
{
return null;
}
public function alterQuery(QueryBuilder $qb, $data)
{
$qb
->andWhere(
$qb->expr()->in('', ':')
)
->setParameter('', $data[]);
}
public function applyOn(): string
{
return Declarations::EVAL_TYPE;
}
public function buildForm(FormBuilderInterface $builder)
{
$builder->add();
}
public function describeAction($data, $format = 'string'): array
{
return ['', [
]];
}
public function getTitle(): string
{
return 'Filter by end date evaluations';
}
}

View File

@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\PersonBundle\Export\Filter\EvaluationFilters;
use Chill\MainBundle\Export\FilterInterface;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
class ByMaxDateFilter implements FilterInterface
{
public function addRole(): ?string
{
return null;
}
public function alterQuery(QueryBuilder $qb, $data)
{
$qb
->andWhere(
$qb->expr()->in('', ':')
)
->setParameter('', $data[]);
}
public function applyOn(): string
{
return Declarations::EVAL_TYPE;
}
public function buildForm(FormBuilderInterface $builder)
{
$builder->add();
}
public function describeAction($data, $format = 'string'): array
{
return ['', [
]];
}
public function getTitle(): string
{
return 'Filter by max date evaluations';
}
}

View File

@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\PersonBundle\Export\Filter\EvaluationFilters;
use Chill\MainBundle\Export\FilterInterface;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
class ByStartDateFilter implements FilterInterface
{
public function addRole(): ?string
{
return null;
}
public function alterQuery(QueryBuilder $qb, $data)
{
$qb
->andWhere(
$qb->expr()->in('', ':')
)
->setParameter('', $data[]);
}
public function applyOn(): string
{
return Declarations::EVAL_TYPE;
}
public function buildForm(FormBuilderInterface $builder)
{
$builder->add();
}
public function describeAction($data, $format = 'string'): array
{
return ['', [
]];
}
public function getTitle(): string
{
return 'Filter by start date evaluations';
}
}

View File

@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\PersonBundle\Export\Filter\EvaluationFilters;
use Chill\MainBundle\Export\FilterInterface;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
class CurrentEvaluationsFilter implements FilterInterface
{
public function addRole(): ?string
{
return null;
}
public function alterQuery(QueryBuilder $qb, $data)
{
$qb
->andWhere(
$qb->expr()->in('', ':')
)
->setParameter('', $data[]);
}
public function applyOn(): string
{
return Declarations::EVAL_TYPE;
}
public function buildForm(FormBuilderInterface $builder)
{
$builder->add();
}
public function describeAction($data, $format = 'string'): array
{
return ['', [
]];
}
public function getTitle(): string
{
return 'Filter by current evaluations';
}
}

View File

@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\PersonBundle\Export\Filter\SocialWorkFilters;
use Chill\MainBundle\Export\FilterInterface;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
class CurrentActionFilter implements FilterInterface
{
public function addRole(): ?string
{
return null;
}
public function alterQuery(QueryBuilder $qb, $data)
{
$qb
->andWhere(
$qb->expr()->in('', ':')
)
->setParameter('', $data[]);
}
public function applyOn(): string
{
return Declarations::SOCIAL_WORK_ACTION_TYPE;
}
public function buildForm(FormBuilderInterface $builder)
{
$builder->add();
}
public function describeAction($data, $format = 'string'): array
{
return ['', [
]];
}
public function getTitle(): string
{
return 'Filter by current actions';
}
}

View File

@ -23,6 +23,31 @@ services:
tags:
- { name: chill.export_filter, alias: accompanyingcourse_maxdate_filter }
Chill\PersonBundle\Export\Filter\EvaluationFilters\ByStartDateFilter:
autowire: true
autoconfigure: true
tags:
- { name: chill.export_filter, alias: evaluation_bystartdate_filter }
Chill\PersonBundle\Export\Filter\EvaluationFilters\ByEndDateFilter:
autowire: true
autoconfigure: true
tags:
- { name: chill.export_filter, alias: evaluation_byenddate_filter }
Chill\PersonBundle\Export\Filter\EvaluationFilters\ByMaxDateFilter:
autowire: true
autoconfigure: true
tags:
- { name: chill.export_filter, alias: evaluation_bymaxdate_filter }
Chill\PersonBundle\Export\Filter\EvaluationFilters\CurrentEvaluationsFilter:
autowire: true
autoconfigure: true
tags:
- { name: chill.export_filter, alias: evaluation_currentevaluations_filter }
## Aggregators
chill.person.export.aggregator_evaluationtype:
class: Chill\PersonBundle\Export\Aggregator\EvaluationAggregators\EvaluationTypeAggregator
@ -30,4 +55,21 @@ services:
autoconfigure: true
tags:
- { name: chill.export_aggregator, alias: accompanyingcourse_evaluationtype_aggregator }
Chill\PersonBundle\Export\Aggregator\EvaluationAggregators\ByStartDateAggregator:
autowire: true
autoconfigure: true
tags:
- { name: chill.export_aggregator, alias: evaluation_bystartdate_aggregator }
Chill\PersonBundle\Export\Aggregator\EvaluationAggregators\ByEndDateAggregator:
autowire: true
autoconfigure: true
tags:
- { name: chill.export_aggregator, alias: evaluation_byenddate_aggregator }
Chill\PersonBundle\Export\Aggregator\EvaluationAggregators\ByMaxDateAggregator:
autowire: true
autoconfigure: true
tags:
- { name: chill.export_aggregator, alias: evaluation_bymaxdate_aggregator }

View File

@ -37,6 +37,8 @@ services:
tags:
- { name: chill.export_filter, alias: social_work_actions_treatingagent_filter }
Chill\PersonBundle\Export\Filter\SocialWorkFilters\CurrentActionFilter:
## AGGREGATORS
chill.person.export.aggregator_action_type:
class: Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ActionTypeAggregator
@ -86,3 +88,5 @@ services:
autoconfigure: true
tags:
- { name: chill.export_aggregator, alias: social_work_actions_goal_result_aggregator }
Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\CurrentActionAggregator:

View File

@ -559,6 +559,16 @@ Group by number of actions: Grouper les parcours par nombre dactions
Filter by creator: Filtrer les parcours par créateur
Filter by creator job: Filtrer les parcours par métier du créateur
Group by creator job: Grouper les parcours par métier du créateur
Filter by current actions: Filtrer les actions en cours
Group by current actions: Grouper les actions en cours
Filter by start date evaluations: Filtrer les évaluations par date de début
Filter by end date evaluations: Filtrer les évaluations par date de fin
Filter by max date evaluations: Filtrer les évaluations par date d'échéance
Filter by current evaluations: Filtrer les évaluations en cours
Group by start date evaluations: Grouper les évaluations par semaine/mois/année de la date de début
Group by end date evaluations: Grouper les évaluations par semaine/mois/année de la date de fin
Group by max date evaluations: Grouper les évaluations par semaine/mois/année de la date d'échéance
## social actions filters/aggr
Filter by treating agent scope: Filtrer les actions par service de l'agent traitant