Compare commits

...

21 Commits

Author SHA1 Message Date
26a5de9958 Merge branch 'issue178_169_export_calendars' of gitlab.com:Chill-Projet/chill-bundles into issue178_169_export_calendars 2023-11-16 12:03:43 +01:00
4e35bcbd93 Format yaml file back to they way it was before 2023-11-16 12:03:35 +01:00
7587472785 fix export.yaml file: remove quotes 2023-11-16 12:03:35 +01:00
9ba33f3df4 style fixes for tests 2023-11-16 12:03:35 +01:00
e0de10b7a8 Add tests for new exports calendar 2023-11-16 12:03:35 +01:00
33235d3541 php cs fixes 2023-11-16 12:03:35 +01:00
817ca7e148 add missing variables to two exports 2023-11-16 12:03:35 +01:00
382f275719 add translations 2023-11-16 12:03:35 +01:00
f78c1c0512 adjust logic for calendar exports linked to person 2023-11-16 12:03:35 +01:00
c3ced7fb6e add center filter to calendar exports linked to acp 2023-11-16 12:03:35 +01:00
96a9be39c3 reorganize exports calendar/ refactor config yaml 2023-11-16 12:03:35 +01:00
792ad394c8 Format yaml file back to they way it was before 2023-11-16 11:14:38 +01:00
a7141ef771 fix export.yaml file: remove quotes 2023-11-16 10:43:47 +01:00
bc638e5eb9 style fixes for tests 2023-11-15 16:38:57 +01:00
b0171e3093 Add tests for new exports calendar 2023-11-15 16:34:08 +01:00
b317daf779 php cs fixes 2023-11-15 16:20:10 +01:00
27bf2893d0 add missing variables to two exports 2023-11-15 16:19:43 +01:00
e2a12968ce add translations 2023-11-15 16:15:24 +01:00
fe9ce1a356 adjust logic for calendar exports linked to person 2023-11-15 15:58:41 +01:00
9c04212c45 add center filter to calendar exports linked to acp 2023-11-15 15:40:36 +01:00
85504d72c2 reorganize exports calendar/ refactor config yaml 2023-11-15 15:31:18 +01:00
11 changed files with 797 additions and 114 deletions

View File

@@ -9,7 +9,7 @@ declare(strict_types=1);
* the LICENSE file that was distributed with this source code. * the LICENSE file that was distributed with this source code.
*/ */
namespace Chill\CalendarBundle\Export\Export; namespace Chill\CalendarBundle\Export\Export\LinkedToAcp;
use Chill\CalendarBundle\Export\Declarations; use Chill\CalendarBundle\Export\Declarations;
use Chill\CalendarBundle\Repository\CalendarRepository; use Chill\CalendarBundle\Repository\CalendarRepository;
@@ -17,17 +17,25 @@ use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
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\Entity\AccompanyingPeriodParticipation;
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
use Chill\PersonBundle\Security\Authorization\PersonVoter; use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Exception\LogicException; use Symfony\Component\Validator\Exception\LogicException;
class CountCalendars implements ExportInterface, GroupedExportInterface class CountCalendars implements ExportInterface, GroupedExportInterface
{ {
private readonly bool $filterStatsByCenters;
public function __construct( public function __construct(
private readonly CalendarRepository $calendarRepository, private readonly CalendarRepository $calendarRepository,
) {} ParameterBagInterface $parameterBag,
) {
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder) public function buildForm(FormBuilderInterface $builder)
{ {
@@ -46,12 +54,12 @@ class CountCalendars implements ExportInterface, GroupedExportInterface
public function getDescription(): string public function getDescription(): string
{ {
return 'Count calendars by various parameters.'; return 'export.export.count_calendar_linked_to_acp.description';
} }
public function getGroup(): string public function getGroup(): string
{ {
return 'Exports of calendar'; return 'export.export.calendar_linked_to_acp.group';
} }
public function getLabels($key, array $values, $data) public function getLabels($key, array $values, $data)
@@ -78,7 +86,7 @@ class CountCalendars implements ExportInterface, GroupedExportInterface
public function getTitle(): string public function getTitle(): string
{ {
return 'Count calendars'; return 'export.export.count_calendar_linked_to_acp.title';
} }
public function getType(): string public function getType(): string
@@ -98,6 +106,19 @@ class CountCalendars implements ExportInterface, GroupedExportInterface
$qb->select('COUNT(cal.id) AS export_result'); $qb->select('COUNT(cal.id) AS export_result');
$qb->leftJoin('cal.accompanyingPeriod', 'acp'); $qb->leftJoin('cal.accompanyingPeriod', 'acp');
if ($this->filterStatsByCenters) {
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part
JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person)
WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers)
'
)
)
->setParameter('authorized_centers', $centers);
}
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
return $qb; return $qb;

View File

@@ -9,7 +9,7 @@ declare(strict_types=1);
* the LICENSE file that was distributed with this source code. * the LICENSE file that was distributed with this source code.
*/ */
namespace Chill\CalendarBundle\Export\Export; namespace Chill\CalendarBundle\Export\Export\LinkedToAcp;
use Chill\CalendarBundle\Export\Declarations; use Chill\CalendarBundle\Export\Declarations;
use Chill\CalendarBundle\Repository\CalendarRepository; use Chill\CalendarBundle\Repository\CalendarRepository;
@@ -17,14 +17,24 @@ use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
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\Entity\AccompanyingPeriodParticipation;
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Doctrine\ORM\Query; use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface
{ {
public function __construct(private readonly CalendarRepository $calendarRepository) {} private readonly bool $filterStatsByCenters;
public function __construct(
private readonly CalendarRepository $calendarRepository,
ParameterBagInterface $parameterBag,
) {
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder): void public function buildForm(FormBuilderInterface $builder): void
{ {
@@ -43,12 +53,12 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface
public function getDescription(): string public function getDescription(): string
{ {
return 'Get the average of calendar duration according to various filters'; return 'export.export.avg_duration_calendar_linked_to_acp.description';
} }
public function getGroup(): string public function getGroup(): string
{ {
return 'Exports of calendar'; return 'export.export.calendar_linked_to_acp.group';
} }
public function getLabels($key, array $values, $data) public function getLabels($key, array $values, $data)
@@ -75,7 +85,7 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface
public function getTitle(): string public function getTitle(): string
{ {
return 'Average calendar duration'; return 'export.export.avg_duration_calendar_linked_to_acp.title';
} }
public function getType(): string public function getType(): string
@@ -85,11 +95,26 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder
{ {
$centers = array_map(static fn ($el) => $el['center'], $acl);
$qb = $this->calendarRepository->createQueryBuilder('cal'); $qb = $this->calendarRepository->createQueryBuilder('cal');
$qb->select('AVG(cal.endDate - cal.startDate) AS export_result'); $qb->select('AVG(cal.endDate - cal.startDate) AS export_result');
$qb->join('cal.accompanyingPeriod', 'acp'); $qb->join('cal.accompanyingPeriod', 'acp');
if ($this->filterStatsByCenters) {
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part
JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person)
WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers)
'
)
)
->setParameter('authorized_centers', $centers);
}
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
return $qb; return $qb;

View File

@@ -9,7 +9,7 @@ declare(strict_types=1);
* the LICENSE file that was distributed with this source code. * the LICENSE file that was distributed with this source code.
*/ */
namespace Chill\CalendarBundle\Export\Export; namespace Chill\CalendarBundle\Export\Export\LinkedToAcp;
use Chill\CalendarBundle\Export\Declarations; use Chill\CalendarBundle\Export\Declarations;
use Chill\CalendarBundle\Repository\CalendarRepository; use Chill\CalendarBundle\Repository\CalendarRepository;
@@ -17,14 +17,24 @@ use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
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\Entity\AccompanyingPeriodParticipation;
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Doctrine\ORM\Query; use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface
{ {
public function __construct(private readonly CalendarRepository $calendarRepository) {} private readonly bool $filterStatsByCenters;
public function __construct(
private readonly CalendarRepository $calendarRepository,
ParameterBagInterface $parameterBag,
) {
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder): void public function buildForm(FormBuilderInterface $builder): void
{ {
@@ -43,12 +53,12 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface
public function getDescription(): string public function getDescription(): string
{ {
return 'Get the sum of calendar durations according to various filters'; return 'export.export.sum_duration_calendar_linked_to_acp.description';
} }
public function getGroup(): string public function getGroup(): string
{ {
return 'Exports of calendar'; return 'export.export.calendar_linked_to_acp.group';
} }
public function getLabels($key, array $values, $data) public function getLabels($key, array $values, $data)
@@ -75,7 +85,7 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface
public function getTitle(): string public function getTitle(): string
{ {
return 'Sum of calendar durations'; return 'export.export.sum_duration_calendar_linked_to_acp.description';
} }
public function getType(): string public function getType(): string
@@ -85,11 +95,26 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder
{ {
$centers = array_map(static fn ($el) => $el['center'], $acl);
$qb = $this->calendarRepository->createQueryBuilder('cal'); $qb = $this->calendarRepository->createQueryBuilder('cal');
$qb->select('SUM(cal.endDate - cal.startDate) AS export_result'); $qb->select('SUM(cal.endDate - cal.startDate) AS export_result');
$qb->join('cal.accompanyingPeriod', 'acp'); $qb->join('cal.accompanyingPeriod', 'acp');
if ($this->filterStatsByCenters) {
$qb
->andWhere(
$qb->expr()->exists(
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part
JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person)
WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers)
'
)
)
->setParameter('authorized_centers', $centers);
}
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
return $qb; return $qb;

View File

@@ -0,0 +1,137 @@
<?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\CalendarBundle\Export\Export\LinkedToPerson;
use Chill\CalendarBundle\Export\Declarations;
use Chill\CalendarBundle\Repository\CalendarRepository;
use Chill\MainBundle\Export\ExportInterface;
use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Exception\LogicException;
class CountCalendars implements ExportInterface, GroupedExportInterface
{
private readonly bool $filterStatsByCenters;
public function __construct(
private readonly CalendarRepository $calendarRepository,
ParameterBagInterface $parameterBag,
) {
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder)
{
// No form necessary
}
public function getFormDefaultData(): array
{
return [];
}
public function getAllowedFormattersTypes(): array
{
return [FormatterInterface::TYPE_TABULAR];
}
public function getDescription(): string
{
return 'export.export.count_calendar_linked_to_person.description';
}
public function getGroup(): string
{
return 'export.export.calendar_linked_to_person.group';
}
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 fn ($value) => $labels[$value];
}
public function getQueryKeys($data): array
{
return ['export_result'];
}
public function getResult($query, $data)
{
return $query->getQuery()->getResult(AbstractQuery::HYDRATE_SCALAR);
}
public function getTitle(): string
{
return 'export.export.count_calendar_linked_to_person.title';
}
public function getType(): string
{
return Declarations::CALENDAR_TYPE;
}
/**
* Initiate the query.
*/
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder
{
$centers = array_map(static fn ($el) => $el['center'], $acl);
$qb = $this->calendarRepository->createQueryBuilder('cal');
$qb->select('COUNT(cal.id) AS export_result');
$qb->leftJoin('cal.person', 'person');
if ($this->filterStatsByCenters) {
$qb
->join('person.centerHistory', 'centerHistory')
->where(
$qb->expr()->andX(
$qb->expr()->lte('centerHistory.startDate', 'cal.startDate'),
$qb->expr()->orX(
$qb->expr()->isNull('centerHistory.endDate'),
$qb->expr()->gt('centerHistory.endDate', 'cal.endDate')
)
)
)
->andWhere($qb->expr()->in('centerHistory.center', ':centers'))
->setParameter('centers', $centers);
}
return $qb;
}
public function requiredRole(): string
{
// which role should we give here?
return PersonVoter::STATS;
}
public function supportsModifiers(): array
{
return [
Declarations::CALENDAR_TYPE,
];
}
}

View File

@@ -0,0 +1,132 @@
<?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\CalendarBundle\Export\Export\LinkedToPerson;
use Chill\CalendarBundle\Export\Declarations;
use Chill\CalendarBundle\Repository\CalendarRepository;
use Chill\MainBundle\Export\ExportInterface;
use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface;
class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface
{
private readonly bool $filterStatsByCenters;
public function __construct(
private readonly CalendarRepository $calendarRepository,
ParameterBagInterface $parameterBag,
) {
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder): void
{
// no form needed
}
public function getFormDefaultData(): array
{
return [];
}
public function getAllowedFormattersTypes(): array
{
return [FormatterInterface::TYPE_TABULAR];
}
public function getDescription(): string
{
return 'export.export.stat_calendar_avg_duration_linked_to_person.description';
}
public function getGroup(): string
{
return 'export.export.calendar_linked_to_person.group';
}
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 fn ($value) => $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 'export.export.stat_calendar_avg_duration_linked_to_person.title';
}
public function getType(): string
{
return Declarations::CALENDAR_TYPE;
}
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder
{
$centers = array_map(static fn ($el) => $el['center'], $acl);
$qb = $this->calendarRepository->createQueryBuilder('cal');
$qb->select('AVG(cal.endDate - cal.startDate) AS export_result');
$qb->join('cal.person', 'person');
if ($this->filterStatsByCenters) {
$qb
->join('person.centerHistory', 'centerHistory')
->where(
$qb->expr()->andX(
$qb->expr()->lte('centerHistory.startDate', 'cal.startDate'),
$qb->expr()->orX(
$qb->expr()->isNull('centerHistory.endDate'),
$qb->expr()->gt('centerHistory.endDate', 'cal.endDate')
)
)
)
->andWhere($qb->expr()->in('centerHistory.center', ':centers'))
->setParameter('centers', $centers);
}
return $qb;
}
public function requiredRole(): string
{
return AccompanyingPeriodVoter::STATS;
}
public function supportsModifiers(): array
{
return [
Declarations::CALENDAR_TYPE,
];
}
}

View File

@@ -0,0 +1,132 @@
<?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\CalendarBundle\Export\Export\LinkedToPerson;
use Chill\CalendarBundle\Export\Declarations;
use Chill\CalendarBundle\Repository\CalendarRepository;
use Chill\MainBundle\Export\ExportInterface;
use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface;
class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface
{
private readonly bool $filterStatsByCenters;
public function __construct(
private readonly CalendarRepository $calendarRepository,
ParameterBagInterface $parameterBag,
) {
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder): void
{
// no form needed
}
public function getFormDefaultData(): array
{
return [];
}
public function getAllowedFormattersTypes(): array
{
return [FormatterInterface::TYPE_TABULAR];
}
public function getDescription(): string
{
return 'export.export.stat_calendar_sum_duration_linked_to_person.description';
}
public function getGroup(): string
{
return 'export.export.calendar_linked_to_person.group';
}
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 fn ($value) => $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 'export.export.stat_calendar_sum_duration_linked_to_person.title';
}
public function getType(): string
{
return Declarations::CALENDAR_TYPE;
}
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder
{
$centers = array_map(static fn ($el) => $el['center'], $acl);
$qb = $this->calendarRepository->createQueryBuilder('cal');
$qb->select('SUM(cal.endDate - cal.startDate) AS export_result');
$qb->join('cal.person', 'person');
if ($this->filterStatsByCenters) {
$qb
->join('person.centerHistory', 'centerHistory')
->where(
$qb->expr()->andX(
$qb->expr()->lte('centerHistory.startDate', 'cal.startDate'),
$qb->expr()->orX(
$qb->expr()->isNull('centerHistory.endDate'),
$qb->expr()->gt('centerHistory.endDate', 'cal.endDate')
)
)
)
->andWhere($qb->expr()->in('centerHistory.center', ':centers'))
->setParameter('centers', $centers);
}
return $qb;
}
public function requiredRole(): string
{
return AccompanyingPeriodVoter::STATS;
}
public function supportsModifiers(): array
{
return [
Declarations::CALENDAR_TYPE,
];
}
}

View File

@@ -1,118 +1,139 @@
services: services:
## Indicators ## Indicators
chill.calendar.export.count_calendars: chill.calendar.export.count_calendars_linked_to_acp:
class: Chill\CalendarBundle\Export\Export\CountCalendars class: Chill\CalendarBundle\Export\Export\LinkedToAcp\CountCalendars
autowire: true autowire: true
autoconfigure: true autoconfigure: true
tags: tags:
- { name: chill.export, alias: count_calendars } - { name: chill.export, alias: count_calendars_linked_to_acp }
chill.calendar.export.average_duration_calendars: chill.calendar.export.average_duration_calendars_linked_to_acp:
class: Chill\CalendarBundle\Export\Export\StatCalendarAvgDuration class: Chill\CalendarBundle\Export\Export\LinkedToAcp\StatCalendarAvgDuration
autowire: true autowire: true
autoconfigure: true autoconfigure: true
tags: tags:
- { name: chill.export, alias: average_duration_calendars } - { name: chill.export, alias: average_duration_calendars_linked_to_acp }
chill.calendar.export.sum_duration_calendars: chill.calendar.export.sum_duration_calendars_linked_to_acp:
class: Chill\CalendarBundle\Export\Export\StatCalendarSumDuration class: Chill\CalendarBundle\Export\Export\LinkedToAcp\StatCalendarSumDuration
autowire: true autowire: true
autoconfigure: true autoconfigure: true
tags: tags:
- { name: chill.export, alias: sum_duration_calendars } - { name: chill.export, alias: sum_duration_calendars_linked_to_acp }
## Filters chill.calendar.export.count_calendars_linked_to_person:
class: Chill\CalendarBundle\Export\Export\LinkedToPerson\CountCalendars
autowire: true
autoconfigure: true
tags:
- { name: chill.export, alias: count_calendars_linked_to_person }
chill.calendar.export.agent_filter: chill.calendar.export.average_duration_calendars_linked_to_person:
class: Chill\CalendarBundle\Export\Filter\AgentFilter class: Chill\CalendarBundle\Export\Export\LinkedToPerson\StatCalendarAvgDuration
autowire: true autowire: true
autoconfigure: true autoconfigure: true
tags: tags:
- { name: chill.export_filter, alias: agent_filter } - { name: chill.export, alias: average_duration_calendars_linked_to_person }
chill.calendar.export.job_filter: chill.calendar.export.sum_duration_calendars_linked_to_person:
class: Chill\CalendarBundle\Export\Filter\JobFilter class: Chill\CalendarBundle\Export\Export\LinkedToPerson\StatCalendarSumDuration
autowire: true autowire: true
autoconfigure: true autoconfigure: true
tags: tags:
- { name: chill.export_filter, alias: job_filter } - { name: chill.export, alias: sum_duration_calendars_linked_to_person }
chill.calendar.export.scope_filter: ## Filters
class: Chill\CalendarBundle\Export\Filter\ScopeFilter
autowire: true
autoconfigure: true
tags:
- { name: chill.export_filter, alias: scope_filter }
chill.calendar.export.between_dates_filter: chill.calendar.export.agent_filter:
class: Chill\CalendarBundle\Export\Filter\BetweenDatesFilter class: Chill\CalendarBundle\Export\Filter\AgentFilter
autowire: true autowire: true
autoconfigure: true autoconfigure: true
tags: tags:
- { name: chill.export_filter, alias: between_dates_filter } - { name: chill.export_filter, alias: agent_filter }
chill.calendar.export.calendar_range_filter: chill.calendar.export.job_filter:
class: Chill\CalendarBundle\Export\Filter\CalendarRangeFilter class: Chill\CalendarBundle\Export\Filter\JobFilter
autowire: true autowire: true
autoconfigure: true autoconfigure: true
tags: tags:
- { name: chill.export_filter, alias: calendar_range_filter } - { name: chill.export_filter, alias: job_filter }
## Aggregator chill.calendar.export.scope_filter:
class: Chill\CalendarBundle\Export\Filter\ScopeFilter
autowire: true
autoconfigure: true
tags:
- { name: chill.export_filter, alias: scope_filter }
chill.calendar.export.agent_aggregator: chill.calendar.export.between_dates_filter:
class: Chill\CalendarBundle\Export\Aggregator\AgentAggregator class: Chill\CalendarBundle\Export\Filter\BetweenDatesFilter
autowire: true autowire: true
autoconfigure: true autoconfigure: true
tags: tags:
- { name: chill.export_aggregator, alias: agent_aggregator } - { name: chill.export_filter, alias: between_dates_filter }
chill.calendar.export.job_aggregator: chill.calendar.export.calendar_range_filter:
class: Chill\CalendarBundle\Export\Aggregator\JobAggregator class: Chill\CalendarBundle\Export\Filter\CalendarRangeFilter
autowire: true autowire: true
autoconfigure: true autoconfigure: true
tags: tags:
- { name: chill.export_aggregator, alias: job_aggregator } - { name: chill.export_filter, alias: calendar_range_filter }
chill.calendar.export.scope_aggregator: ## Aggregator
class: Chill\CalendarBundle\Export\Aggregator\ScopeAggregator
autowire: true
autoconfigure: true
tags:
- { name: chill.export_aggregator, alias: scope_aggregator }
chill.calendar.export.location_type_aggregator: chill.calendar.export.agent_aggregator:
class: Chill\CalendarBundle\Export\Aggregator\LocationTypeAggregator class: Chill\CalendarBundle\Export\Aggregator\AgentAggregator
autowire: true autowire: true
autoconfigure: true autoconfigure: true
tags: tags:
- { name: chill.export_aggregator, alias: location_type_aggregator } - { name: chill.export_aggregator, alias: agent_aggregator }
chill.calendar.export.location_aggregator: chill.calendar.export.job_aggregator:
class: Chill\CalendarBundle\Export\Aggregator\LocationAggregator class: Chill\CalendarBundle\Export\Aggregator\JobAggregator
autowire: true autowire: true
autoconfigure: true autoconfigure: true
tags: tags:
- { name: chill.export_aggregator, alias: location_aggregator } - { name: chill.export_aggregator, alias: job_aggregator }
chill.calendar.export.cancel_reason_aggregator: chill.calendar.export.scope_aggregator:
class: Chill\CalendarBundle\Export\Aggregator\CancelReasonAggregator class: Chill\CalendarBundle\Export\Aggregator\ScopeAggregator
autowire: true autowire: true
autoconfigure: true autoconfigure: true
tags: tags:
- { name: chill.export_aggregator, alias: cancel_reason_aggregator } - { name: chill.export_aggregator, alias: scope_aggregator }
chill.calendar.export.month_aggregator: chill.calendar.export.location_type_aggregator:
class: Chill\CalendarBundle\Export\Aggregator\MonthYearAggregator class: Chill\CalendarBundle\Export\Aggregator\LocationTypeAggregator
autowire: true autowire: true
autoconfigure: true autoconfigure: true
tags: tags:
- { name: chill.export_aggregator, alias: month_aggregator } - { name: chill.export_aggregator, alias: location_type_aggregator }
chill.calendar.export.urgency_aggregator: chill.calendar.export.location_aggregator:
class: Chill\CalendarBundle\Export\Aggregator\UrgencyAggregator class: Chill\CalendarBundle\Export\Aggregator\LocationAggregator
autowire: true autowire: true
autoconfigure: true autoconfigure: true
tags: tags:
- { name: chill.export_aggregator, alias: urgency_aggregator } - { name: chill.export_aggregator, alias: location_aggregator }
chill.calendar.export.cancel_reason_aggregator:
class: Chill\CalendarBundle\Export\Aggregator\CancelReasonAggregator
autowire: true
autoconfigure: true
tags:
- { name: chill.export_aggregator, alias: cancel_reason_aggregator }
chill.calendar.export.month_aggregator:
class: Chill\CalendarBundle\Export\Aggregator\MonthYearAggregator
autowire: true
autoconfigure: true
tags:
- { name: chill.export_aggregator, alias: month_aggregator }
chill.calendar.export.urgency_aggregator:
class: Chill\CalendarBundle\Export\Aggregator\UrgencyAggregator
autowire: true
autoconfigure: true
tags:
- { name: chill.export_aggregator, alias: urgency_aggregator }

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\CalendarBundle\Tests\Export\Export;
use Chill\CalendarBundle\Export\Declarations;
use Chill\CalendarBundle\Export\Export\LinkedToAcp\CountCalendars as CountCalendarsLinkedToAcp;
use Chill\CalendarBundle\Export\Export\LinkedToPerson\CountCalendars as CountCalendarsLinkedToPerson;
use Chill\CalendarBundle\Repository\CalendarRepository;
use Chill\MainBundle\Test\Export\AbstractExportTest;
/**
* @internal
*
* @coversNothing
*/
class CountCalendarsTest extends AbstractExportTest
{
protected function setUp(): void
{
self::bootKernel();
}
public function getExport()
{
$repository = self::$container->get(CalendarRepository::class);
yield new CountCalendarsLinkedToAcp($repository, $this->getParameters(true));
yield new CountCalendarsLinkedToAcp($repository, $this->getParameters(false));
yield new CountCalendarsLinkedToPerson($repository, $this->getParameters(true));
yield new CountCalendarsLinkedToPerson($repository, $this->getParameters(false));
}
public function getFormData()
{
return [];
}
public function getModifiersCombination()
{
return [
[
Declarations::CALENDAR_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\CalendarBundle\Tests\Export\Export;
use Chill\CalendarBundle\Export\Declarations;
use Chill\CalendarBundle\Export\Export\LinkedToAcp\StatCalendarAvgDuration as StatCalendarAvgDurationLinkedToAcp;
use Chill\CalendarBundle\Export\Export\LinkedToPerson\StatCalendarAvgDuration as StatCalendarAvgDurationLinkedToPerson;
use Chill\CalendarBundle\Repository\CalendarRepository;
use Chill\MainBundle\Test\Export\AbstractExportTest;
/**
* @internal
*
* @coversNothing
*/
class StatCalendarAvgDurationTest extends AbstractExportTest
{
protected function setUp(): void
{
self::bootKernel();
}
public function getExport()
{
$repository = self::$container->get(CalendarRepository::class);
yield new StatCalendarAvgDurationLinkedToAcp($repository, $this->getParameters(true));
yield new StatCalendarAvgDurationLinkedToAcp($repository, $this->getParameters(false));
yield new StatCalendarAvgDurationLinkedToPerson($repository, $this->getParameters(true));
yield new StatCalendarAvgDurationLinkedToPerson($repository, $this->getParameters(false));
}
public function getFormData()
{
return [];
}
public function getModifiersCombination()
{
return [
[
Declarations::CALENDAR_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\CalendarBundle\Tests\Export\Export;
use Chill\CalendarBundle\Export\Declarations;
use Chill\CalendarBundle\Export\Export\LinkedToAcp\StatCalendarSumDuration as StatCalendarSumDurationLinkedToAcp;
use Chill\CalendarBundle\Export\Export\LinkedToPerson\StatCalendarSumDuration as StatCalendarSumDurationLinkedToPerson;
use Chill\CalendarBundle\Repository\CalendarRepository;
use Chill\MainBundle\Test\Export\AbstractExportTest;
/**
* @internal
*
* @coversNothing
*/
class StatCalendarSumDurationTest extends AbstractExportTest
{
protected function setUp(): void
{
self::bootKernel();
}
public function getExport()
{
$repository = self::$container->get(CalendarRepository::class);
yield new StatCalendarSumDurationLinkedToAcp($repository, $this->getParameters(true));
yield new StatCalendarSumDurationLinkedToAcp($repository, $this->getParameters(false));
yield new StatCalendarSumDurationLinkedToPerson($repository, $this->getParameters(true));
yield new StatCalendarSumDurationLinkedToPerson($repository, $this->getParameters(false));
}
public function getFormData()
{
return [];
}
public function getModifiersCombination()
{
return [
[
Declarations::CALENDAR_TYPE,
]];
}
}

View File

@@ -112,6 +112,31 @@ Group calendars by month and year: Grouper les rendez-vous par mois et année
Group calendars by urgency: Grouper les rendez-vous par urgent ou non Group calendars by urgency: Grouper les rendez-vous par urgent ou non
export: export:
export:
calendar_linked_to_person:
group: Exports des rendez-vous liés à un usager
calendar_linked_to_acp:
group: Exports des rendez-vous liés à un parcours
stat_calendar_sum_duration_linked_to_person:
title: Somme de la durée des rendez-vous
description: Additionne la durée des rendez-vous en fonction de différents paramètres.
stat_calendar_avg_duration_linked_to_person:
title: Moyenne de la durée des rendez-vous
description: Moyenne de la durée des rendez-vous en fonction de différents paramètres.
count_calendar_linked_to_person:
title: Nombre des rendez-vous
description: Compte le nombre des rendez-vous enregistrés et liés à un usager en fonction de différents paramètres.
count_calendar_linked_to_acp:
title: Nombre des rendez-vous
description: Compte le nombre des rendez-vous enregistrés et liées à un parcours en fonction de différents paramètres.
avg_duration_calendar_linked_to_acp:
title: Moyenne de la durée des rendez-vous
description: Moyenne de la durée des rendez-vous en fonction de différents paramètres.
sum_duration_calendar_linked_to_acp:
title: Somme de la durée des rendez-vous
description: Additionne la durée des rendez-vous en fonction de différents paramètres.
aggregator.calendar: aggregator.calendar:
agent_job: agent_job:
Group calendars by agent job: Grouper les rendez-vous par métier de l'agent Group calendars by agent job: Grouper les rendez-vous par métier de l'agent