mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-11-04 03:08:25 +00:00 
			
		
		
		
	Compare commits
	
		
			21 Commits
		
	
	
		
			2.12.1
			...
			issue178_1
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 26a5de9958 | |||
| 4e35bcbd93 | |||
| 7587472785 | |||
| 9ba33f3df4 | |||
| e0de10b7a8 | |||
| 33235d3541 | |||
| 817ca7e148 | |||
| 382f275719 | |||
| f78c1c0512 | |||
| c3ced7fb6e | |||
| 96a9be39c3 | |||
| 792ad394c8 | |||
| a7141ef771 | |||
| bc638e5eb9 | |||
| b0171e3093 | |||
| b317daf779 | |||
| 27bf2893d0 | |||
| e2a12968ce | |||
| fe9ce1a356 | |||
| 9c04212c45 | |||
| 85504d72c2 | 
@@ -9,7 +9,7 @@ declare(strict_types=1);
 | 
			
		||||
 * 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\Repository\CalendarRepository;
 | 
			
		||||
@@ -17,17 +17,25 @@ use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
 | 
			
		||||
use Chill\MainBundle\Export\ExportInterface;
 | 
			
		||||
use Chill\MainBundle\Export\FormatterInterface;
 | 
			
		||||
use Chill\MainBundle\Export\GroupedExportInterface;
 | 
			
		||||
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
 | 
			
		||||
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
 | 
			
		||||
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)
 | 
			
		||||
    {
 | 
			
		||||
@@ -46,12 +54,12 @@ class CountCalendars implements ExportInterface, GroupedExportInterface
 | 
			
		||||
 | 
			
		||||
    public function getDescription(): string
 | 
			
		||||
    {
 | 
			
		||||
        return 'Count calendars by various parameters.';
 | 
			
		||||
        return 'export.export.count_calendar_linked_to_acp.description';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getGroup(): string
 | 
			
		||||
    {
 | 
			
		||||
        return 'Exports of calendar';
 | 
			
		||||
        return 'export.export.calendar_linked_to_acp.group';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getLabels($key, array $values, $data)
 | 
			
		||||
@@ -78,7 +86,7 @@ class CountCalendars implements ExportInterface, GroupedExportInterface
 | 
			
		||||
 | 
			
		||||
    public function getTitle(): string
 | 
			
		||||
    {
 | 
			
		||||
        return 'Count calendars';
 | 
			
		||||
        return 'export.export.count_calendar_linked_to_acp.title';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getType(): string
 | 
			
		||||
@@ -98,6 +106,19 @@ class CountCalendars implements ExportInterface, GroupedExportInterface
 | 
			
		||||
        $qb->select('COUNT(cal.id) AS export_result');
 | 
			
		||||
        $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);
 | 
			
		||||
 | 
			
		||||
        return $qb;
 | 
			
		||||
@@ -9,7 +9,7 @@ declare(strict_types=1);
 | 
			
		||||
 * 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\Repository\CalendarRepository;
 | 
			
		||||
@@ -17,14 +17,24 @@ use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
 | 
			
		||||
use Chill\MainBundle\Export\ExportInterface;
 | 
			
		||||
use Chill\MainBundle\Export\FormatterInterface;
 | 
			
		||||
use Chill\MainBundle\Export\GroupedExportInterface;
 | 
			
		||||
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
 | 
			
		||||
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
 | 
			
		||||
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
 | 
			
		||||
{
 | 
			
		||||
    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
 | 
			
		||||
    {
 | 
			
		||||
@@ -43,12 +53,12 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface
 | 
			
		||||
 | 
			
		||||
    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
 | 
			
		||||
    {
 | 
			
		||||
        return 'Exports of calendar';
 | 
			
		||||
        return 'export.export.calendar_linked_to_acp.group';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getLabels($key, array $values, $data)
 | 
			
		||||
@@ -75,7 +85,7 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface
 | 
			
		||||
 | 
			
		||||
    public function getTitle(): string
 | 
			
		||||
    {
 | 
			
		||||
        return 'Average calendar duration';
 | 
			
		||||
        return 'export.export.avg_duration_calendar_linked_to_acp.title';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getType(): string
 | 
			
		||||
@@ -85,11 +95,26 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface
 | 
			
		||||
 | 
			
		||||
    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.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);
 | 
			
		||||
 | 
			
		||||
        return $qb;
 | 
			
		||||
@@ -9,7 +9,7 @@ declare(strict_types=1);
 | 
			
		||||
 * 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\Repository\CalendarRepository;
 | 
			
		||||
@@ -17,14 +17,24 @@ use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
 | 
			
		||||
use Chill\MainBundle\Export\ExportInterface;
 | 
			
		||||
use Chill\MainBundle\Export\FormatterInterface;
 | 
			
		||||
use Chill\MainBundle\Export\GroupedExportInterface;
 | 
			
		||||
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
 | 
			
		||||
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
 | 
			
		||||
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
 | 
			
		||||
{
 | 
			
		||||
    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
 | 
			
		||||
    {
 | 
			
		||||
@@ -43,12 +53,12 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface
 | 
			
		||||
 | 
			
		||||
    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
 | 
			
		||||
    {
 | 
			
		||||
        return 'Exports of calendar';
 | 
			
		||||
        return 'export.export.calendar_linked_to_acp.group';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getLabels($key, array $values, $data)
 | 
			
		||||
@@ -75,7 +85,7 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface
 | 
			
		||||
 | 
			
		||||
    public function getTitle(): string
 | 
			
		||||
    {
 | 
			
		||||
        return 'Sum of calendar durations';
 | 
			
		||||
        return 'export.export.sum_duration_calendar_linked_to_acp.description';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getType(): string
 | 
			
		||||
@@ -85,11 +95,26 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface
 | 
			
		||||
 | 
			
		||||
    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.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);
 | 
			
		||||
 | 
			
		||||
        return $qb;
 | 
			
		||||
@@ -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,
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -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,
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -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,
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,118 +1,139 @@
 | 
			
		||||
services:
 | 
			
		||||
 | 
			
		||||
  ## Indicators
 | 
			
		||||
  chill.calendar.export.count_calendars:
 | 
			
		||||
    class: Chill\CalendarBundle\Export\Export\CountCalendars
 | 
			
		||||
    autowire: true
 | 
			
		||||
    autoconfigure: true
 | 
			
		||||
    tags:
 | 
			
		||||
      - { name: chill.export, alias: count_calendars }
 | 
			
		||||
    ## Indicators
 | 
			
		||||
    chill.calendar.export.count_calendars_linked_to_acp:
 | 
			
		||||
        class: Chill\CalendarBundle\Export\Export\LinkedToAcp\CountCalendars
 | 
			
		||||
        autowire: true
 | 
			
		||||
        autoconfigure: true
 | 
			
		||||
        tags:
 | 
			
		||||
            - { name: chill.export, alias: count_calendars_linked_to_acp }
 | 
			
		||||
 | 
			
		||||
  chill.calendar.export.average_duration_calendars:
 | 
			
		||||
    class: Chill\CalendarBundle\Export\Export\StatCalendarAvgDuration
 | 
			
		||||
    autowire: true
 | 
			
		||||
    autoconfigure: true
 | 
			
		||||
    tags:
 | 
			
		||||
      - { name: chill.export, alias: average_duration_calendars }
 | 
			
		||||
    chill.calendar.export.average_duration_calendars_linked_to_acp:
 | 
			
		||||
        class: Chill\CalendarBundle\Export\Export\LinkedToAcp\StatCalendarAvgDuration
 | 
			
		||||
        autowire: true
 | 
			
		||||
        autoconfigure: true
 | 
			
		||||
        tags:
 | 
			
		||||
            - { name: chill.export, alias: average_duration_calendars_linked_to_acp }
 | 
			
		||||
 | 
			
		||||
  chill.calendar.export.sum_duration_calendars:
 | 
			
		||||
    class: Chill\CalendarBundle\Export\Export\StatCalendarSumDuration
 | 
			
		||||
    autowire: true
 | 
			
		||||
    autoconfigure: true
 | 
			
		||||
    tags:
 | 
			
		||||
      - { name: chill.export, alias: sum_duration_calendars }
 | 
			
		||||
    chill.calendar.export.sum_duration_calendars_linked_to_acp:
 | 
			
		||||
        class: Chill\CalendarBundle\Export\Export\LinkedToAcp\StatCalendarSumDuration
 | 
			
		||||
        autowire: true
 | 
			
		||||
        autoconfigure: true
 | 
			
		||||
        tags:
 | 
			
		||||
            - { 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:
 | 
			
		||||
    class: Chill\CalendarBundle\Export\Filter\AgentFilter
 | 
			
		||||
    autowire: true
 | 
			
		||||
    autoconfigure: true
 | 
			
		||||
    tags:
 | 
			
		||||
      - { name: chill.export_filter, alias: agent_filter }
 | 
			
		||||
    chill.calendar.export.average_duration_calendars_linked_to_person:
 | 
			
		||||
        class: Chill\CalendarBundle\Export\Export\LinkedToPerson\StatCalendarAvgDuration
 | 
			
		||||
        autowire: true
 | 
			
		||||
        autoconfigure: true
 | 
			
		||||
        tags:
 | 
			
		||||
            - { name: chill.export, alias: average_duration_calendars_linked_to_person }
 | 
			
		||||
 | 
			
		||||
  chill.calendar.export.job_filter:
 | 
			
		||||
    class: Chill\CalendarBundle\Export\Filter\JobFilter
 | 
			
		||||
    autowire: true
 | 
			
		||||
    autoconfigure: true
 | 
			
		||||
    tags:
 | 
			
		||||
      - { name: chill.export_filter, alias: job_filter }
 | 
			
		||||
    chill.calendar.export.sum_duration_calendars_linked_to_person:
 | 
			
		||||
        class: Chill\CalendarBundle\Export\Export\LinkedToPerson\StatCalendarSumDuration
 | 
			
		||||
        autowire: true
 | 
			
		||||
        autoconfigure: true
 | 
			
		||||
        tags:
 | 
			
		||||
            - { name: chill.export, alias: sum_duration_calendars_linked_to_person }
 | 
			
		||||
 | 
			
		||||
  chill.calendar.export.scope_filter:
 | 
			
		||||
    class: Chill\CalendarBundle\Export\Filter\ScopeFilter
 | 
			
		||||
    autowire: true
 | 
			
		||||
    autoconfigure: true
 | 
			
		||||
    tags:
 | 
			
		||||
      - { name: chill.export_filter, alias: scope_filter }
 | 
			
		||||
    ## Filters
 | 
			
		||||
 | 
			
		||||
  chill.calendar.export.between_dates_filter:
 | 
			
		||||
    class: Chill\CalendarBundle\Export\Filter\BetweenDatesFilter
 | 
			
		||||
    autowire: true
 | 
			
		||||
    autoconfigure: true
 | 
			
		||||
    tags:
 | 
			
		||||
      - { name: chill.export_filter, alias: between_dates_filter }
 | 
			
		||||
    chill.calendar.export.agent_filter:
 | 
			
		||||
        class: Chill\CalendarBundle\Export\Filter\AgentFilter
 | 
			
		||||
        autowire: true
 | 
			
		||||
        autoconfigure: true
 | 
			
		||||
        tags:
 | 
			
		||||
            - { name: chill.export_filter, alias: agent_filter }
 | 
			
		||||
 | 
			
		||||
  chill.calendar.export.calendar_range_filter:
 | 
			
		||||
      class: Chill\CalendarBundle\Export\Filter\CalendarRangeFilter
 | 
			
		||||
      autowire: true
 | 
			
		||||
      autoconfigure: true
 | 
			
		||||
      tags:
 | 
			
		||||
          - { name: chill.export_filter, alias: calendar_range_filter }
 | 
			
		||||
    chill.calendar.export.job_filter:
 | 
			
		||||
        class: Chill\CalendarBundle\Export\Filter\JobFilter
 | 
			
		||||
        autowire: true
 | 
			
		||||
        autoconfigure: true
 | 
			
		||||
        tags:
 | 
			
		||||
            - { 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:
 | 
			
		||||
    class: Chill\CalendarBundle\Export\Aggregator\AgentAggregator
 | 
			
		||||
    autowire: true
 | 
			
		||||
    autoconfigure: true
 | 
			
		||||
    tags:
 | 
			
		||||
      - { name: chill.export_aggregator, alias: agent_aggregator }
 | 
			
		||||
    chill.calendar.export.between_dates_filter:
 | 
			
		||||
        class: Chill\CalendarBundle\Export\Filter\BetweenDatesFilter
 | 
			
		||||
        autowire: true
 | 
			
		||||
        autoconfigure: true
 | 
			
		||||
        tags:
 | 
			
		||||
            - { name: chill.export_filter, alias: between_dates_filter }
 | 
			
		||||
 | 
			
		||||
  chill.calendar.export.job_aggregator:
 | 
			
		||||
    class: Chill\CalendarBundle\Export\Aggregator\JobAggregator
 | 
			
		||||
    autowire: true
 | 
			
		||||
    autoconfigure: true
 | 
			
		||||
    tags:
 | 
			
		||||
      - { name: chill.export_aggregator, alias: job_aggregator }
 | 
			
		||||
    chill.calendar.export.calendar_range_filter:
 | 
			
		||||
        class: Chill\CalendarBundle\Export\Filter\CalendarRangeFilter
 | 
			
		||||
        autowire: true
 | 
			
		||||
        autoconfigure: true
 | 
			
		||||
        tags:
 | 
			
		||||
            - { name: chill.export_filter, alias: calendar_range_filter }
 | 
			
		||||
 | 
			
		||||
  chill.calendar.export.scope_aggregator:
 | 
			
		||||
    class: Chill\CalendarBundle\Export\Aggregator\ScopeAggregator
 | 
			
		||||
    autowire: true
 | 
			
		||||
    autoconfigure: true
 | 
			
		||||
    tags:
 | 
			
		||||
      - { name: chill.export_aggregator, alias: scope_aggregator }
 | 
			
		||||
    ## Aggregator
 | 
			
		||||
 | 
			
		||||
  chill.calendar.export.location_type_aggregator:
 | 
			
		||||
    class: Chill\CalendarBundle\Export\Aggregator\LocationTypeAggregator
 | 
			
		||||
    autowire: true
 | 
			
		||||
    autoconfigure: true
 | 
			
		||||
    tags:
 | 
			
		||||
      - { name: chill.export_aggregator, alias: location_type_aggregator }
 | 
			
		||||
    chill.calendar.export.agent_aggregator:
 | 
			
		||||
        class: Chill\CalendarBundle\Export\Aggregator\AgentAggregator
 | 
			
		||||
        autowire: true
 | 
			
		||||
        autoconfigure: true
 | 
			
		||||
        tags:
 | 
			
		||||
            - { name: chill.export_aggregator, alias: agent_aggregator }
 | 
			
		||||
 | 
			
		||||
  chill.calendar.export.location_aggregator:
 | 
			
		||||
    class: Chill\CalendarBundle\Export\Aggregator\LocationAggregator
 | 
			
		||||
    autowire: true
 | 
			
		||||
    autoconfigure: true
 | 
			
		||||
    tags:
 | 
			
		||||
      - { name: chill.export_aggregator, alias: location_aggregator }
 | 
			
		||||
    chill.calendar.export.job_aggregator:
 | 
			
		||||
        class: Chill\CalendarBundle\Export\Aggregator\JobAggregator
 | 
			
		||||
        autowire: true
 | 
			
		||||
        autoconfigure: true
 | 
			
		||||
        tags:
 | 
			
		||||
            - { name: chill.export_aggregator, alias: job_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.scope_aggregator:
 | 
			
		||||
        class: Chill\CalendarBundle\Export\Aggregator\ScopeAggregator
 | 
			
		||||
        autowire: true
 | 
			
		||||
        autoconfigure: true
 | 
			
		||||
        tags:
 | 
			
		||||
            - { name: chill.export_aggregator, alias: scope_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.location_type_aggregator:
 | 
			
		||||
        class: Chill\CalendarBundle\Export\Aggregator\LocationTypeAggregator
 | 
			
		||||
        autowire: true
 | 
			
		||||
        autoconfigure: true
 | 
			
		||||
        tags:
 | 
			
		||||
            - { name: chill.export_aggregator, alias: location_type_aggregator }
 | 
			
		||||
 | 
			
		||||
  chill.calendar.export.urgency_aggregator:
 | 
			
		||||
      class: Chill\CalendarBundle\Export\Aggregator\UrgencyAggregator
 | 
			
		||||
      autowire: true
 | 
			
		||||
      autoconfigure: true
 | 
			
		||||
      tags:
 | 
			
		||||
          - { name: chill.export_aggregator, alias: urgency_aggregator }
 | 
			
		||||
    chill.calendar.export.location_aggregator:
 | 
			
		||||
        class: Chill\CalendarBundle\Export\Aggregator\LocationAggregator
 | 
			
		||||
        autowire: true
 | 
			
		||||
        autoconfigure: true
 | 
			
		||||
        tags:
 | 
			
		||||
            - { 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 }
 | 
			
		||||
 
 | 
			
		||||
@@ -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,
 | 
			
		||||
            ]];
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -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,
 | 
			
		||||
            ]];
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -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,
 | 
			
		||||
            ]];
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -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
 | 
			
		||||
 | 
			
		||||
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:
 | 
			
		||||
        agent_job:
 | 
			
		||||
            Group calendars by agent job: Grouper les rendez-vous par métier de l'agent
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user