mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-11-03 18:58:24 +00:00 
			
		
		
		
	Compare commits
	
		
			15 Commits
		
	
	
		
			2.10.4
			...
			68-feature
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 2fc6e18d0f | |||
| 
						 | 
					80ea4bbdd2 | ||
| 
						 | 
					801c693ef9 | ||
| 
						 | 
					c1c9562e67 | ||
| 
						 | 
					b9e580af9a | ||
| 
						 | 
					790c7f6724 | ||
| 
						 | 
					1be91bb392 | ||
| 
						 | 
					93f39ebe5b | ||
| 
						 | 
					176c3c0e27 | ||
| 
						 | 
					59cd8466be | ||
| 
						 | 
					ef9e872394 | ||
| 
						 | 
					51a46ab5d7 | ||
| 
						 | 
					191b416c6c | ||
| 6028efdc7c | |||
| 
						 | 
					60c9e037a6 | 
@@ -1,20 +0,0 @@
 | 
			
		||||
## v2.10.0 - 2023-10-24
 | 
			
		||||
### Feature
 | 
			
		||||
* ([#172](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/172)) [export] Add a filter "grouping accompanying period by opening date" and "grouping accompanying period by closing date"
 | 
			
		||||
* ([#172](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/172)) [export] add a filter and aggregator on accompanying period work: group/filter by handling third party
 | 
			
		||||
* ([#172](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/172)) [export] add a filter and aggregator on activites: group/filter activities by people participating to the activities
 | 
			
		||||
* ([#172](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/172)) [export] add a grouping on accompanying period export: group by activity type associated to at least one activity within the accompanying period
 | 
			
		||||
* [export] sort filters and aggregators by title
 | 
			
		||||
* ([#179](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/179)) [export] create a parameter that will force to skip the filtering by center (ACL) when generating an export
 | 
			
		||||
### Fixed
 | 
			
		||||
* ([#177](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/177)) [export] fix date range selection on filter and grouping "by status of the course at date", on accompanying periods
 | 
			
		||||
 | 
			
		||||
### Résumé francophone des changements
 | 
			
		||||
 | 
			
		||||
- Ajout d'un regroupement sur les parcours: par date de cloture et d'ouverture;
 | 
			
		||||
- Ajouter d'un filtre et regroupement par tiers traitant sur les actions d'accompagnement;
 | 
			
		||||
- ajout d'un filtre et regroupement par usager participant sur les échanges
 | 
			
		||||
- ajout d'un regroupement: par type d'activité associé au parcours;
 | 
			
		||||
- trie les filtre et regroupements par ordre alphabétique dans els exports
 | 
			
		||||
- ajout d'un paramètre qui permet de désactiver le filtre par centre dans les exports
 | 
			
		||||
- correction de l'interface de date dans les filtres et regroupements "par statut du parcours à la date"
 | 
			
		||||
@@ -1,3 +0,0 @@
 | 
			
		||||
## v2.10.1 - 2023-10-24
 | 
			
		||||
### Fixed
 | 
			
		||||
* Fix export controller when generating an export without any data in session 
 | 
			
		||||
@@ -1,3 +0,0 @@
 | 
			
		||||
## v2.10.2 - 2023-10-26
 | 
			
		||||
### Fixed
 | 
			
		||||
* ([#175](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/175)) Use injection of translator instead of ->get(). 
 | 
			
		||||
@@ -1,3 +0,0 @@
 | 
			
		||||
## v2.10.3 - 2023-10-26
 | 
			
		||||
### Fixed
 | 
			
		||||
* ([#175](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/175)) Replace old method of getting translator with injection of translatorInterface 
 | 
			
		||||
@@ -1,3 +0,0 @@
 | 
			
		||||
## v2.10.4 - 2023-10-26
 | 
			
		||||
### Fixed
 | 
			
		||||
* Fix null value constraint errors when merging relationships in doubles 
 | 
			
		||||
							
								
								
									
										37
									
								
								CHANGELOG.md
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								CHANGELOG.md
									
									
									
									
									
								
							@@ -6,43 +6,6 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
 | 
			
		||||
and is generated by [Changie](https://github.com/miniscruff/changie).
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## v2.10.4 - 2023-10-26
 | 
			
		||||
### Fixed
 | 
			
		||||
* Fix null value constraint errors when merging relationships in doubles 
 | 
			
		||||
 | 
			
		||||
## v2.10.3 - 2023-10-26
 | 
			
		||||
### Fixed
 | 
			
		||||
* ([#175](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/175)) Replace old method of getting translator with injection of translatorInterface 
 | 
			
		||||
 | 
			
		||||
## v2.10.2 - 2023-10-26
 | 
			
		||||
### Fixed
 | 
			
		||||
* ([#175](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/175)) Use injection of translator instead of ->get(). 
 | 
			
		||||
 | 
			
		||||
## v2.10.1 - 2023-10-24
 | 
			
		||||
### Fixed
 | 
			
		||||
* Fix export controller when generating an export without any data in session 
 | 
			
		||||
 | 
			
		||||
## v2.10.0 - 2023-10-24
 | 
			
		||||
### Feature
 | 
			
		||||
* ([#172](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/172)) [export] Add a filter "grouping accompanying period by opening date" and "grouping accompanying period by closing date"
 | 
			
		||||
* ([#172](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/172)) [export] add a filter and aggregator on accompanying period work: group/filter by handling third party
 | 
			
		||||
* ([#172](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/172)) [export] add a filter and aggregator on activites: group/filter activities by people participating to the activities
 | 
			
		||||
* ([#172](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/172)) [export] add a grouping on accompanying period export: group by activity type associated to at least one activity within the accompanying period
 | 
			
		||||
* [export] sort filters and aggregators by title
 | 
			
		||||
* ([#179](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/179)) [export] create a parameter that will force to skip the filtering by center (ACL) when generating an export
 | 
			
		||||
### Fixed
 | 
			
		||||
* ([#177](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/177)) [export] fix date range selection on filter and grouping "by status of the course at date", on accompanying periods
 | 
			
		||||
 | 
			
		||||
### Résumé francophone des changements
 | 
			
		||||
 | 
			
		||||
- Ajout d'un regroupement sur les parcours: par date de cloture et d'ouverture;
 | 
			
		||||
- Ajouter d'un filtre et regroupement par tiers traitant sur les actions d'accompagnement;
 | 
			
		||||
- ajout d'un filtre et regroupement par usager participant sur les échanges
 | 
			
		||||
- ajout d'un regroupement: par type d'activité associé au parcours;
 | 
			
		||||
- trie les filtre et regroupements par ordre alphabétique dans els exports
 | 
			
		||||
- ajout d'un paramètre qui permet de désactiver le filtre par centre dans les exports
 | 
			
		||||
- correction de l'interface de date dans les filtres et regroupements "par statut du parcours à la date"
 | 
			
		||||
 | 
			
		||||
## v2.9.2 - 2023-10-17
 | 
			
		||||
### Fixed
 | 
			
		||||
* Fix possible null values in string's entities 
 | 
			
		||||
 
 | 
			
		||||
@@ -31,7 +31,9 @@
 | 
			
		||||
    "typescript": "^4.7.2",
 | 
			
		||||
    "vue-loader": "^17.0.0",
 | 
			
		||||
    "webpack": "^5.75.0",
 | 
			
		||||
    "webpack-cli": "^5.0.1"
 | 
			
		||||
    "webpack-cli": "^5.0.1",
 | 
			
		||||
      "chart.js": "^4.2.1",
 | 
			
		||||
      "vue-chartjs": "^5.2.0"
 | 
			
		||||
  },
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "@fullcalendar/core": "^6.1.4",
 | 
			
		||||
 
 | 
			
		||||
@@ -1,122 +0,0 @@
 | 
			
		||||
<?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\ActivityBundle\Export\Aggregator\ACPAggregators;
 | 
			
		||||
 | 
			
		||||
use Chill\ActivityBundle\Entity\Activity;
 | 
			
		||||
use Chill\ActivityBundle\Entity\ActivityType;
 | 
			
		||||
use Chill\ActivityBundle\Repository\ActivityTypeRepositoryInterface;
 | 
			
		||||
use Chill\MainBundle\Export\AggregatorInterface;
 | 
			
		||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
 | 
			
		||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
 | 
			
		||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
 | 
			
		||||
use Chill\PersonBundle\Export\Declarations;
 | 
			
		||||
use Doctrine\ORM\Query\Expr\Join;
 | 
			
		||||
use Doctrine\ORM\QueryBuilder;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
final readonly class ByActivityTypeAggregator implements AggregatorInterface
 | 
			
		||||
{
 | 
			
		||||
    private const PREFIX = 'acp_by_activity_type_agg';
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private RollingDateConverterInterface $rollingDateConverter,
 | 
			
		||||
        private ActivityTypeRepositoryInterface $activityTypeRepository,
 | 
			
		||||
        private TranslatableStringHelperInterface $translatableStringHelper,
 | 
			
		||||
    ) {}
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder)
 | 
			
		||||
    {
 | 
			
		||||
        $builder
 | 
			
		||||
            ->add('after_date', PickRollingDateType::class, [
 | 
			
		||||
                'required' => false,
 | 
			
		||||
                'label' => 'export.aggregator.acp.by_activity_type.after_date',
 | 
			
		||||
            ])
 | 
			
		||||
            ->add('before_date', PickRollingDateType::class, [
 | 
			
		||||
                'required' => false,
 | 
			
		||||
                'label' => 'export.aggregator.acp.by_activity_type.before_date',
 | 
			
		||||
            ]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getFormDefaultData(): array
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
            'before_date' => null,
 | 
			
		||||
            'after_date' => null,
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getLabels($key, array $values, mixed $data)
 | 
			
		||||
    {
 | 
			
		||||
        return function (null|int|string $value): string {
 | 
			
		||||
            if ('_header' === $value) {
 | 
			
		||||
                return 'export.aggregator.acp.by_activity_type.activity_type';
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if ('' === $value || null === $value || null === $activityType = $this->activityTypeRepository->find($value)) {
 | 
			
		||||
                return '';
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return $this->translatableStringHelper->localize($activityType->getName());
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getQueryKeys($data)
 | 
			
		||||
    {
 | 
			
		||||
        return [self::PREFIX.'_actype_id'];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getTitle()
 | 
			
		||||
    {
 | 
			
		||||
        return 'export.aggregator.acp.by_activity_type.title';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function addRole(): ?string
 | 
			
		||||
    {
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function alterQuery(QueryBuilder $qb, $data)
 | 
			
		||||
    {
 | 
			
		||||
        $p = self::PREFIX;
 | 
			
		||||
 | 
			
		||||
        // we make a left join, with acp having at least one activity of the given type
 | 
			
		||||
        $exists = 'EXISTS (SELECT 1 FROM '.Activity::class." {$p}_activity WHERE {$p}_activity.accompanyingPeriod = acp AND {$p}_activity.activityType = {$p}_activity_type";
 | 
			
		||||
 | 
			
		||||
        if (null !== $data['after_date']) {
 | 
			
		||||
            $exists .= " AND {$p}_activity.date > :{$p}_after_date";
 | 
			
		||||
            $qb->setParameter("{$p}_after_date", $this->rollingDateConverter->convert($data['after_date']));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (null !== $data['before_date']) {
 | 
			
		||||
            $exists .= " AND {$p}_activity.date < :{$p}_before_date";
 | 
			
		||||
            $qb->setParameter("{$p}_before_date", $this->rollingDateConverter->convert($data['before_date']));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $exists .= ')';
 | 
			
		||||
 | 
			
		||||
        $qb->leftJoin(
 | 
			
		||||
            ActivityType::class,
 | 
			
		||||
            "{$p}_activity_type",
 | 
			
		||||
            Join::WITH,
 | 
			
		||||
            $exists
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        $qb
 | 
			
		||||
            ->addSelect("{$p}_activity_type.id AS {$p}_actype_id")
 | 
			
		||||
            ->addGroupBy("{$p}_actype_id");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function applyOn()
 | 
			
		||||
    {
 | 
			
		||||
        return Declarations::ACP_TYPE;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -73,6 +73,7 @@ class DateAggregator implements AggregatorInterface
 | 
			
		||||
            'choices' => self::CHOICES,
 | 
			
		||||
            'multiple' => false,
 | 
			
		||||
            'expanded' => true,
 | 
			
		||||
            'empty_data' => self::DEFAULT_CHOICE,
 | 
			
		||||
        ]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,78 +0,0 @@
 | 
			
		||||
<?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\ActivityBundle\Export\Aggregator;
 | 
			
		||||
 | 
			
		||||
use Chill\ActivityBundle\Export\Declarations;
 | 
			
		||||
use Chill\ActivityBundle\Tests\Export\Aggregator\PersonsAggregatorTest;
 | 
			
		||||
use Chill\MainBundle\Export\AggregatorInterface;
 | 
			
		||||
use Chill\PersonBundle\Export\Helper\LabelPersonHelper;
 | 
			
		||||
use Doctrine\ORM\QueryBuilder;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @see PersonsAggregatorTest
 | 
			
		||||
 */
 | 
			
		||||
final readonly class PersonsAggregator implements AggregatorInterface
 | 
			
		||||
{
 | 
			
		||||
    private const PREFIX = 'act_persons_agg';
 | 
			
		||||
 | 
			
		||||
    public function __construct(private LabelPersonHelper $labelPersonHelper) {}
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder)
 | 
			
		||||
    {
 | 
			
		||||
        // nothing to add here
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getFormDefaultData(): array
 | 
			
		||||
    {
 | 
			
		||||
        return [];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getLabels($key, array $values, mixed $data)
 | 
			
		||||
    {
 | 
			
		||||
        if ($key !== self::PREFIX.'_pid') {
 | 
			
		||||
            throw new \UnexpectedValueException('this key should not be handled: '.$key);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $this->labelPersonHelper->getLabel($key, $values, 'export.aggregator.activity.by_persons.Persons');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getQueryKeys($data)
 | 
			
		||||
    {
 | 
			
		||||
        return [self::PREFIX.'_pid'];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getTitle()
 | 
			
		||||
    {
 | 
			
		||||
        return 'export.aggregator.activity.by_persons.Group activity by persons';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function addRole(): ?string
 | 
			
		||||
    {
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function alterQuery(QueryBuilder $qb, $data)
 | 
			
		||||
    {
 | 
			
		||||
        $p = self::PREFIX;
 | 
			
		||||
 | 
			
		||||
        $qb
 | 
			
		||||
            ->leftJoin('activity.persons', "{$p}_p")
 | 
			
		||||
            ->addSelect("{$p}_p.id AS {$p}_pid")
 | 
			
		||||
            ->addGroupBy("{$p}_pid");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function applyOn()
 | 
			
		||||
    {
 | 
			
		||||
        return Declarations::ACTIVITY;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -11,8 +11,8 @@ declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Chill\ActivityBundle\Export\Export\LinkedToACP;
 | 
			
		||||
 | 
			
		||||
use Chill\ActivityBundle\Entity\Activity;
 | 
			
		||||
use Chill\ActivityBundle\Export\Declarations;
 | 
			
		||||
use Chill\ActivityBundle\Repository\ActivityRepository;
 | 
			
		||||
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
 | 
			
		||||
use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
 | 
			
		||||
use Chill\MainBundle\Export\ExportInterface;
 | 
			
		||||
@@ -21,19 +21,19 @@ use Chill\MainBundle\Export\GroupedExportInterface;
 | 
			
		||||
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
 | 
			
		||||
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
 | 
			
		||||
use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
use Doctrine\ORM\EntityRepository;
 | 
			
		||||
use Doctrine\ORM\Query;
 | 
			
		||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
class AvgActivityDuration implements ExportInterface, GroupedExportInterface
 | 
			
		||||
{
 | 
			
		||||
    private readonly bool $filterStatsByCenters;
 | 
			
		||||
    protected EntityRepository $repository;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private readonly ActivityRepository $activityRepository,
 | 
			
		||||
        ParameterBagInterface $parameterBag,
 | 
			
		||||
        EntityManagerInterface $em,
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
 | 
			
		||||
        $this->repository = $em->getRepository(Activity::class);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder) {}
 | 
			
		||||
@@ -91,25 +91,23 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface
 | 
			
		||||
    {
 | 
			
		||||
        $centers = array_map(static fn ($el) => $el['center'], $acl);
 | 
			
		||||
 | 
			
		||||
        $qb = $this->activityRepository->createQueryBuilder('activity');
 | 
			
		||||
        $qb = $this->repository->createQueryBuilder('activity');
 | 
			
		||||
 | 
			
		||||
        $qb
 | 
			
		||||
            ->join('activity.accompanyingPeriod', 'acp')
 | 
			
		||||
            ->select('AVG(activity.durationTime) as export_avg_activity_duration')
 | 
			
		||||
            ->andWhere($qb->expr()->isNotNull('activity.durationTime'));
 | 
			
		||||
 | 
			
		||||
        if ($this->filterStatsByCenters) {
 | 
			
		||||
            $qb
 | 
			
		||||
                ->andWhere(
 | 
			
		||||
                    $qb->expr()->exists(
 | 
			
		||||
                        'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part
 | 
			
		||||
        $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);
 | 
			
		||||
        }
 | 
			
		||||
            )
 | 
			
		||||
            ->setParameter('authorized_centers', $centers);
 | 
			
		||||
 | 
			
		||||
        AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -24,21 +24,16 @@ use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
use Doctrine\ORM\EntityRepository;
 | 
			
		||||
use Doctrine\ORM\Query;
 | 
			
		||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterface
 | 
			
		||||
{
 | 
			
		||||
    protected EntityRepository $repository;
 | 
			
		||||
 | 
			
		||||
    private readonly bool $filterStatsByCenters;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        EntityManagerInterface $em,
 | 
			
		||||
        ParameterBagInterface $parameterBag,
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->repository = $em->getRepository(Activity::class);
 | 
			
		||||
        $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder)
 | 
			
		||||
@@ -106,18 +101,16 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac
 | 
			
		||||
            ->select('AVG(activity.travelTime) as export_avg_activity_visit_duration')
 | 
			
		||||
            ->andWhere($qb->expr()->isNotNull('activity.travelTime'));
 | 
			
		||||
 | 
			
		||||
        if ($this->filterStatsByCenters) {
 | 
			
		||||
            $qb
 | 
			
		||||
                ->andWhere(
 | 
			
		||||
                    $qb->expr()->exists(
 | 
			
		||||
                        'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part
 | 
			
		||||
        $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);
 | 
			
		||||
        }
 | 
			
		||||
            )
 | 
			
		||||
            ->setParameter('authorized_centers', $centers);
 | 
			
		||||
 | 
			
		||||
        AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -24,21 +24,16 @@ use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
use Doctrine\ORM\EntityRepository;
 | 
			
		||||
use Doctrine\ORM\Query;
 | 
			
		||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
class CountActivity implements ExportInterface, GroupedExportInterface
 | 
			
		||||
{
 | 
			
		||||
    protected EntityRepository $repository;
 | 
			
		||||
 | 
			
		||||
    private readonly bool $filterStatsByCenters;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        EntityManagerInterface $em,
 | 
			
		||||
        ParameterBagInterface $parameterBag,
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->repository = $em->getRepository(Activity::class);
 | 
			
		||||
        $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder) {}
 | 
			
		||||
@@ -100,18 +95,16 @@ class CountActivity implements ExportInterface, GroupedExportInterface
 | 
			
		||||
            ->createQueryBuilder('activity')
 | 
			
		||||
            ->join('activity.accompanyingPeriod', 'acp');
 | 
			
		||||
 | 
			
		||||
        if ($this->filterStatsByCenters) {
 | 
			
		||||
            $qb
 | 
			
		||||
                ->andWhere(
 | 
			
		||||
                    $qb->expr()->exists(
 | 
			
		||||
                        'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part
 | 
			
		||||
        $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);
 | 
			
		||||
        }
 | 
			
		||||
            )
 | 
			
		||||
            ->setParameter('authorized_centers', $centers);
 | 
			
		||||
 | 
			
		||||
        AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -22,21 +22,11 @@ use Chill\MainBundle\Export\Helper\TranslatableStringExportLabelHelper;
 | 
			
		||||
use Chill\MainBundle\Export\ListInterface;
 | 
			
		||||
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
class ListActivity implements ListInterface, GroupedExportInterface
 | 
			
		||||
{
 | 
			
		||||
    private readonly bool $filterStatsByCenters;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private readonly ListActivityHelper $helper,
 | 
			
		||||
        private readonly EntityManagerInterface $entityManager,
 | 
			
		||||
        private readonly TranslatableStringExportLabelHelper $translatableStringExportLabelHelper,
 | 
			
		||||
        ParameterBagInterface $parameterBag,
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
 | 
			
		||||
    }
 | 
			
		||||
    public function __construct(private readonly ListActivityHelper $helper, private readonly EntityManagerInterface $entityManager, private readonly TranslatableStringExportLabelHelper $translatableStringExportLabelHelper) {}
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder)
 | 
			
		||||
    {
 | 
			
		||||
@@ -117,27 +107,21 @@ class ListActivity implements ListInterface, GroupedExportInterface
 | 
			
		||||
            ->join('activity.accompanyingPeriod', 'acp')
 | 
			
		||||
            ->leftJoin('acp.participations', 'acppart')
 | 
			
		||||
            ->leftJoin('acppart.person', 'person')
 | 
			
		||||
            ->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL');
 | 
			
		||||
 | 
			
		||||
        if ($this->filterStatsByCenters) {
 | 
			
		||||
            $qb
 | 
			
		||||
                ->andWhere(
 | 
			
		||||
                    $qb->expr()->exists(
 | 
			
		||||
                        'SELECT 1
 | 
			
		||||
            ->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL')
 | 
			
		||||
            ->andWhere(
 | 
			
		||||
                $qb->expr()->exists(
 | 
			
		||||
                    'SELECT 1
 | 
			
		||||
                    FROM '.PersonCenterHistory::class.' acl_count_person_history
 | 
			
		||||
                    WHERE acl_count_person_history.person = person
 | 
			
		||||
                    AND acl_count_person_history.center IN (:authorized_centers)
 | 
			
		||||
                    '
 | 
			
		||||
                    )
 | 
			
		||||
                )
 | 
			
		||||
                ->setParameter('authorized_centers', $centers);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $qb
 | 
			
		||||
            )
 | 
			
		||||
            // some grouping are necessary
 | 
			
		||||
            ->addGroupBy('acp.id')
 | 
			
		||||
            ->addOrderBy('activity.date')
 | 
			
		||||
            ->addOrderBy('activity.id');
 | 
			
		||||
            ->addOrderBy('activity.id')
 | 
			
		||||
            ->setParameter('authorized_centers', $centers);
 | 
			
		||||
 | 
			
		||||
        $this->helper->addSelect($qb);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -24,20 +24,16 @@ use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
use Doctrine\ORM\EntityRepository;
 | 
			
		||||
use Doctrine\ORM\Query;
 | 
			
		||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
class SumActivityDuration implements ExportInterface, GroupedExportInterface
 | 
			
		||||
{
 | 
			
		||||
    protected EntityRepository $repository;
 | 
			
		||||
    private readonly bool $filterStatsByCenters;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        EntityManagerInterface $em,
 | 
			
		||||
        ParameterBagInterface $parameterBag,
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->repository = $em->getRepository(Activity::class);
 | 
			
		||||
        $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder)
 | 
			
		||||
@@ -105,18 +101,16 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface
 | 
			
		||||
        $qb->select('SUM(activity.durationTime) as export_sum_activity_duration')
 | 
			
		||||
            ->andWhere($qb->expr()->isNotNull('activity.durationTime'));
 | 
			
		||||
 | 
			
		||||
        if ($this->filterStatsByCenters) {
 | 
			
		||||
            $qb
 | 
			
		||||
                ->andWhere(
 | 
			
		||||
                    $qb->expr()->exists(
 | 
			
		||||
                        'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part
 | 
			
		||||
        $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);
 | 
			
		||||
        }
 | 
			
		||||
            )
 | 
			
		||||
            ->setParameter('authorized_centers', $centers);
 | 
			
		||||
 | 
			
		||||
        AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -24,20 +24,16 @@ use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
use Doctrine\ORM\EntityRepository;
 | 
			
		||||
use Doctrine\ORM\Query;
 | 
			
		||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
class SumActivityVisitDuration implements ExportInterface, GroupedExportInterface
 | 
			
		||||
{
 | 
			
		||||
    protected EntityRepository $repository;
 | 
			
		||||
    private readonly bool $filterStatsByCenters;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        EntityManagerInterface $em,
 | 
			
		||||
        ParameterBagInterface $parameterBag,
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->repository = $em->getRepository(Activity::class);
 | 
			
		||||
        $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder)
 | 
			
		||||
@@ -105,18 +101,16 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac
 | 
			
		||||
        $qb->select('SUM(activity.travelTime) as export_sum_activity_visit_duration')
 | 
			
		||||
            ->andWhere($qb->expr()->isNotNull('activity.travelTime'));
 | 
			
		||||
 | 
			
		||||
        if ($this->filterStatsByCenters) {
 | 
			
		||||
            $qb
 | 
			
		||||
                ->andWhere(
 | 
			
		||||
                    $qb->expr()->exists(
 | 
			
		||||
                        'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part
 | 
			
		||||
        $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);
 | 
			
		||||
        }
 | 
			
		||||
            )
 | 
			
		||||
            ->setParameter('authorized_centers', $centers);
 | 
			
		||||
 | 
			
		||||
        AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -19,19 +19,11 @@ use Chill\MainBundle\Export\FormatterInterface;
 | 
			
		||||
use Chill\MainBundle\Export\GroupedExportInterface;
 | 
			
		||||
use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
 | 
			
		||||
use Doctrine\ORM\Query;
 | 
			
		||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
class CountActivity implements ExportInterface, GroupedExportInterface
 | 
			
		||||
{
 | 
			
		||||
    private readonly bool $filterStatsByCenters;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private readonly ActivityRepository $activityRepository,
 | 
			
		||||
        ParameterBagInterface $parameterBag,
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
 | 
			
		||||
    }
 | 
			
		||||
    public function __construct(protected ActivityRepository $activityRepository) {}
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder) {}
 | 
			
		||||
 | 
			
		||||
@@ -90,25 +82,23 @@ class CountActivity implements ExportInterface, GroupedExportInterface
 | 
			
		||||
 | 
			
		||||
        $qb = $this->activityRepository
 | 
			
		||||
            ->createQueryBuilder('activity')
 | 
			
		||||
            ->join('activity.person', 'person');
 | 
			
		||||
            ->join('activity.person', 'person')
 | 
			
		||||
            ->join('person.centerHistory', 'centerHistory');
 | 
			
		||||
 | 
			
		||||
        $qb->select('COUNT(activity.id) as export_count_activity');
 | 
			
		||||
 | 
			
		||||
        if ($this->filterStatsByCenters) {
 | 
			
		||||
            $qb
 | 
			
		||||
                ->join('person.centerHistory', 'centerHistory')
 | 
			
		||||
                ->where(
 | 
			
		||||
                    $qb->expr()->andX(
 | 
			
		||||
                        $qb->expr()->lte('centerHistory.startDate', 'activity.date'),
 | 
			
		||||
                        $qb->expr()->orX(
 | 
			
		||||
                            $qb->expr()->isNull('centerHistory.endDate'),
 | 
			
		||||
                            $qb->expr()->gt('centerHistory.endDate', 'activity.date')
 | 
			
		||||
                        )
 | 
			
		||||
        $qb
 | 
			
		||||
            ->where(
 | 
			
		||||
                $qb->expr()->andX(
 | 
			
		||||
                    $qb->expr()->lte('centerHistory.startDate', 'activity.date'),
 | 
			
		||||
                    $qb->expr()->orX(
 | 
			
		||||
                        $qb->expr()->isNull('centerHistory.endDate'),
 | 
			
		||||
                        $qb->expr()->gt('centerHistory.endDate', 'activity.date')
 | 
			
		||||
                    )
 | 
			
		||||
                )
 | 
			
		||||
                ->andWhere($qb->expr()->in('centerHistory.center', ':centers'))
 | 
			
		||||
                ->setParameter('centers', $centers);
 | 
			
		||||
        }
 | 
			
		||||
            )
 | 
			
		||||
            ->andWhere($qb->expr()->in('centerHistory.center', ':centers'))
 | 
			
		||||
            ->setParameter('centers', $centers);
 | 
			
		||||
 | 
			
		||||
        return $qb;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,6 @@ use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
 | 
			
		||||
use Doctrine\DBAL\Exception\InvalidArgumentException;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
use Doctrine\ORM\Query;
 | 
			
		||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
 | 
			
		||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
use Symfony\Component\Validator\Constraints\Callback;
 | 
			
		||||
@@ -45,17 +44,8 @@ class ListActivity implements ListInterface, GroupedExportInterface
 | 
			
		||||
        'person_lastname',
 | 
			
		||||
        'person_id',
 | 
			
		||||
    ];
 | 
			
		||||
    private readonly bool $filterStatsByCenters;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        protected EntityManagerInterface $entityManager,
 | 
			
		||||
        protected TranslatorInterface $translator,
 | 
			
		||||
        protected TranslatableStringHelperInterface $translatableStringHelper,
 | 
			
		||||
        private readonly ActivityRepository $activityRepository,
 | 
			
		||||
        ParameterBagInterface $parameterBag,
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
 | 
			
		||||
    }
 | 
			
		||||
    public function __construct(protected EntityManagerInterface $entityManager, protected TranslatorInterface $translator, protected TranslatableStringHelperInterface $translatableStringHelper, private readonly ActivityRepository $activityRepository) {}
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder)
 | 
			
		||||
    {
 | 
			
		||||
@@ -198,22 +188,20 @@ class ListActivity implements ListInterface, GroupedExportInterface
 | 
			
		||||
 | 
			
		||||
        $qb
 | 
			
		||||
            ->from('ChillActivityBundle:Activity', 'activity')
 | 
			
		||||
            ->join('activity.person', 'actperson');
 | 
			
		||||
            ->join('activity.person', 'actperson')
 | 
			
		||||
            ->join('actperson.centerHistory', 'centerHistory');
 | 
			
		||||
 | 
			
		||||
        if ($this->filterStatsByCenters) {
 | 
			
		||||
            $qb->join('actperson.centerHistory', 'centerHistory');
 | 
			
		||||
            $qb->where(
 | 
			
		||||
                $qb->expr()->andX(
 | 
			
		||||
                    $qb->expr()->lte('centerHistory.startDate', 'activity.date'),
 | 
			
		||||
                    $qb->expr()->orX(
 | 
			
		||||
                        $qb->expr()->isNull('centerHistory.endDate'),
 | 
			
		||||
                        $qb->expr()->gt('centerHistory.endDate', 'activity.date')
 | 
			
		||||
                    )
 | 
			
		||||
        $qb->where(
 | 
			
		||||
            $qb->expr()->andX(
 | 
			
		||||
                $qb->expr()->lte('centerHistory.startDate', 'activity.date'),
 | 
			
		||||
                $qb->expr()->orX(
 | 
			
		||||
                    $qb->expr()->isNull('centerHistory.endDate'),
 | 
			
		||||
                    $qb->expr()->gt('centerHistory.endDate', 'activity.date')
 | 
			
		||||
                )
 | 
			
		||||
            )
 | 
			
		||||
                ->andWhere($qb->expr()->in('centerHistory.center', ':centers'))
 | 
			
		||||
                ->setParameter('centers', $centers);
 | 
			
		||||
        }
 | 
			
		||||
        )
 | 
			
		||||
            ->andWhere($qb->expr()->in('centerHistory.center', ':centers'))
 | 
			
		||||
            ->setParameter('centers', $centers);
 | 
			
		||||
 | 
			
		||||
        foreach ($this->fields as $f) {
 | 
			
		||||
            if (\in_array($f, $data['fields'], true)) {
 | 
			
		||||
 
 | 
			
		||||
@@ -20,7 +20,6 @@ use Chill\MainBundle\Export\FormatterInterface;
 | 
			
		||||
use Chill\MainBundle\Export\GroupedExportInterface;
 | 
			
		||||
use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
 | 
			
		||||
use Doctrine\ORM\Query;
 | 
			
		||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -31,21 +30,17 @@ use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
class StatActivityDuration implements ExportInterface, GroupedExportInterface
 | 
			
		||||
{
 | 
			
		||||
    final public const SUM = 'sum';
 | 
			
		||||
    private readonly bool $filterStatsByCenters;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param string $action the stat to perform
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private readonly ActivityRepository $activityRepository,
 | 
			
		||||
        ParameterBagInterface $parameterBag,
 | 
			
		||||
        /**
 | 
			
		||||
         * The action for this report.
 | 
			
		||||
         */
 | 
			
		||||
        protected string $action = 'sum'
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
 | 
			
		||||
    }
 | 
			
		||||
    ) {}
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder) {}
 | 
			
		||||
 | 
			
		||||
@@ -124,23 +119,21 @@ class StatActivityDuration implements ExportInterface, GroupedExportInterface
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $qb->select($select)
 | 
			
		||||
            ->join('activity.person', 'person');
 | 
			
		||||
            ->join('activity.person', 'person')
 | 
			
		||||
            ->join('person.centerHistory', 'centerHistory');
 | 
			
		||||
 | 
			
		||||
        if ($this->filterStatsByCenters) {
 | 
			
		||||
            $qb
 | 
			
		||||
                ->join('person.centerHistory', 'centerHistory')
 | 
			
		||||
                ->where(
 | 
			
		||||
                    $qb->expr()->andX(
 | 
			
		||||
                        $qb->expr()->lte('centerHistory.startDate', 'activity.date'),
 | 
			
		||||
                        $qb->expr()->orX(
 | 
			
		||||
                            $qb->expr()->isNull('centerHistory.endDate'),
 | 
			
		||||
                            $qb->expr()->gt('centerHistory.endDate', 'activity.date')
 | 
			
		||||
                        )
 | 
			
		||||
        $qb
 | 
			
		||||
            ->where(
 | 
			
		||||
                $qb->expr()->andX(
 | 
			
		||||
                    $qb->expr()->lte('centerHistory.startDate', 'activity.date'),
 | 
			
		||||
                    $qb->expr()->orX(
 | 
			
		||||
                        $qb->expr()->isNull('centerHistory.endDate'),
 | 
			
		||||
                        $qb->expr()->gt('centerHistory.endDate', 'activity.date')
 | 
			
		||||
                    )
 | 
			
		||||
                )
 | 
			
		||||
                ->andWhere($qb->expr()->in('centerHistory.center', ':centers'))
 | 
			
		||||
                ->setParameter('centers', $centers);
 | 
			
		||||
        }
 | 
			
		||||
            )
 | 
			
		||||
            ->andWhere($qb->expr()->in('centerHistory.center', ':centers'))
 | 
			
		||||
            ->setParameter('centers', $centers);
 | 
			
		||||
 | 
			
		||||
        return $qb;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,87 +0,0 @@
 | 
			
		||||
<?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\ActivityBundle\Export\Filter;
 | 
			
		||||
 | 
			
		||||
use Chill\ActivityBundle\Export\Declarations;
 | 
			
		||||
use Chill\ActivityBundle\Tests\Export\Filter\PersonsFilterTest;
 | 
			
		||||
use Chill\MainBundle\Export\FilterInterface;
 | 
			
		||||
use Chill\PersonBundle\Form\Type\PickPersonDynamicType;
 | 
			
		||||
use Chill\PersonBundle\Templating\Entity\PersonRenderInterface;
 | 
			
		||||
use Doctrine\ORM\QueryBuilder;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @see PersonsFilterTest
 | 
			
		||||
 */
 | 
			
		||||
final readonly class PersonsFilter implements FilterInterface
 | 
			
		||||
{
 | 
			
		||||
    private const PREFIX = 'act_persons_filter';
 | 
			
		||||
 | 
			
		||||
    public function __construct(private PersonRenderInterface $personRender) {}
 | 
			
		||||
 | 
			
		||||
    public function addRole(): ?string
 | 
			
		||||
    {
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function alterQuery(QueryBuilder $qb, $data)
 | 
			
		||||
    {
 | 
			
		||||
        $p = self::PREFIX;
 | 
			
		||||
 | 
			
		||||
        $orX = $qb->expr()->orX();
 | 
			
		||||
 | 
			
		||||
        foreach (array_values($data['accepted_persons']) as $key => $person) {
 | 
			
		||||
            $orX->add($qb->expr()->isMemberOf(":{$p}_p_{$key}", 'activity.persons'));
 | 
			
		||||
            $qb->setParameter(":{$p}_p_{$key}", $person);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $qb->andWhere($orX);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function applyOn()
 | 
			
		||||
    {
 | 
			
		||||
        return Declarations::ACTIVITY;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder)
 | 
			
		||||
    {
 | 
			
		||||
        $builder->add('accepted_persons', PickPersonDynamicType::class, [
 | 
			
		||||
            'multiple' => true,
 | 
			
		||||
            'label' => 'export.filter.activity.by_persons.persons taking part on the activity',
 | 
			
		||||
        ]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getFormDefaultData(): array
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
            'accepted_persons' => [],
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function describeAction($data, $format = 'string')
 | 
			
		||||
    {
 | 
			
		||||
        $users = [];
 | 
			
		||||
 | 
			
		||||
        foreach ($data['accepted_persons'] as $u) {
 | 
			
		||||
            $users[] = $this->personRender->renderString($u, []);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return ['export.filter.activity.by_persons.Filtered activity by persons: only %persons%', [
 | 
			
		||||
            '%persons%' => implode(', ', $users),
 | 
			
		||||
        ]];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getTitle(): string
 | 
			
		||||
    {
 | 
			
		||||
        return 'export.filter.activity.by_persons.Filter activity by persons';
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -23,8 +23,8 @@ use Symfony\Contracts\Translation\TranslatorInterface;
 | 
			
		||||
class SentReceivedFilter implements FilterInterface
 | 
			
		||||
{
 | 
			
		||||
    private const CHOICES = [
 | 
			
		||||
        'export.filter.activity.by_sent_received.is sent' => Activity::SENTRECEIVED_SENT,
 | 
			
		||||
        'export.filter.activity.by_sent_received.is received' => Activity::SENTRECEIVED_RECEIVED,
 | 
			
		||||
        'is sent' => Activity::SENTRECEIVED_SENT,
 | 
			
		||||
        'is received' => Activity::SENTRECEIVED_RECEIVED,
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
    private const DEFAULT_CHOICE = Activity::SENTRECEIVED_SENT;
 | 
			
		||||
@@ -64,7 +64,6 @@ class SentReceivedFilter implements FilterInterface
 | 
			
		||||
            'multiple' => false,
 | 
			
		||||
            'expanded' => true,
 | 
			
		||||
            'empty_data' => self::DEFAULT_CHOICE,
 | 
			
		||||
            'label' => 'export.filter.activity.by_sent_received.Sent or received',
 | 
			
		||||
        ]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -21,9 +21,9 @@ use Doctrine\ORM\QueryBuilder;
 | 
			
		||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
class CreatorScopeFilter implements FilterInterface
 | 
			
		||||
class UserScopeFilter implements FilterInterface
 | 
			
		||||
{
 | 
			
		||||
    private const PREFIX = 'acp_act_filter_creator_scope';
 | 
			
		||||
    private const PREFIX = 'acp_act_filter_user_scope';  // creator ? cfr translation
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private readonly TranslatableStringHelper $translatableStringHelper
 | 
			
		||||
@@ -39,7 +39,7 @@ class CreatorScopeFilter implements FilterInterface
 | 
			
		||||
        $p = self::PREFIX;
 | 
			
		||||
 | 
			
		||||
        $qb
 | 
			
		||||
            ->leftJoin('activity.createdBy', "{$p}_user")
 | 
			
		||||
            ->leftJoin('activity.user', "{$p}_user")  // createdBy ? cfr translation
 | 
			
		||||
            ->leftJoin(
 | 
			
		||||
                UserScopeHistory::class,
 | 
			
		||||
                "{$p}_history",
 | 
			
		||||
@@ -1,87 +0,0 @@
 | 
			
		||||
<?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\ActivityBundle\Tests\Export\Aggregator\ACPAggregators;
 | 
			
		||||
 | 
			
		||||
use Chill\ActivityBundle\Export\Aggregator\ACPAggregators\ByActivityTypeAggregator;
 | 
			
		||||
use Chill\ActivityBundle\Repository\ActivityTypeRepositoryInterface;
 | 
			
		||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
 | 
			
		||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
 | 
			
		||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
 | 
			
		||||
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
 | 
			
		||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @internal
 | 
			
		||||
 *
 | 
			
		||||
 * @coversNothing
 | 
			
		||||
 */
 | 
			
		||||
class ByActivityTypeAggregatorTest extends AbstractAggregatorTest
 | 
			
		||||
{
 | 
			
		||||
    private RollingDateConverterInterface $rollingDateConverter;
 | 
			
		||||
    private ActivityTypeRepositoryInterface $activityTypeRepository;
 | 
			
		||||
    private TranslatableStringHelperInterface $translatableStringHelper;
 | 
			
		||||
 | 
			
		||||
    protected function setUp(): void
 | 
			
		||||
    {
 | 
			
		||||
        parent::setUp();
 | 
			
		||||
 | 
			
		||||
        self::bootKernel();
 | 
			
		||||
        $this->rollingDateConverter = self::$container->get(RollingDateConverterInterface::class);
 | 
			
		||||
        $this->activityTypeRepository = self::$container->get(ActivityTypeRepositoryInterface::class);
 | 
			
		||||
        $this->translatableStringHelper = self::$container->get(TranslatableStringHelperInterface::class);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getAggregator()
 | 
			
		||||
    {
 | 
			
		||||
        return new ByActivityTypeAggregator(
 | 
			
		||||
            $this->rollingDateConverter,
 | 
			
		||||
            $this->activityTypeRepository,
 | 
			
		||||
            $this->translatableStringHelper,
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getFormData()
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
            [
 | 
			
		||||
                'after_date' => null,
 | 
			
		||||
                'before_date' => null,
 | 
			
		||||
            ],
 | 
			
		||||
            [
 | 
			
		||||
                'after_date' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START),
 | 
			
		||||
                'before_date' => null,
 | 
			
		||||
            ],
 | 
			
		||||
            [
 | 
			
		||||
                'after_date' => null,
 | 
			
		||||
                'before_date' => new RollingDate(RollingDate::T_TODAY),
 | 
			
		||||
            ],
 | 
			
		||||
            [
 | 
			
		||||
                'after_date' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START),
 | 
			
		||||
                'before_date' => new RollingDate(RollingDate::T_TODAY),
 | 
			
		||||
            ],
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getQueryBuilders()
 | 
			
		||||
    {
 | 
			
		||||
        self::bootKernel();
 | 
			
		||||
 | 
			
		||||
        $em = self::$container->get(EntityManagerInterface::class);
 | 
			
		||||
 | 
			
		||||
        return [
 | 
			
		||||
            $em->createQueryBuilder()
 | 
			
		||||
                ->select('count(distinct acp.id)')
 | 
			
		||||
                ->from(AccompanyingPeriod::class, 'acp'),
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,60 +0,0 @@
 | 
			
		||||
<?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\ActivityBundle\Tests\Export\Aggregator;
 | 
			
		||||
 | 
			
		||||
use Chill\ActivityBundle\Entity\Activity;
 | 
			
		||||
use Chill\ActivityBundle\Export\Aggregator\PersonsAggregator;
 | 
			
		||||
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
 | 
			
		||||
use Chill\PersonBundle\Export\Helper\LabelPersonHelper;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @internal
 | 
			
		||||
 *
 | 
			
		||||
 * @coversNothing
 | 
			
		||||
 */
 | 
			
		||||
class PersonsAggregatorTest extends AbstractAggregatorTest
 | 
			
		||||
{
 | 
			
		||||
    private LabelPersonHelper $labelPersonHelper;
 | 
			
		||||
 | 
			
		||||
    protected function setUp(): void
 | 
			
		||||
    {
 | 
			
		||||
        parent::setUp();
 | 
			
		||||
        self::bootKernel();
 | 
			
		||||
        $this->labelPersonHelper = self::$container->get(LabelPersonHelper::class);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getAggregator()
 | 
			
		||||
    {
 | 
			
		||||
        return new PersonsAggregator($this->labelPersonHelper);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getFormData()
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
            [],
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getQueryBuilders()
 | 
			
		||||
    {
 | 
			
		||||
        self::bootKernel();
 | 
			
		||||
 | 
			
		||||
        $em = self::$container->get(EntityManagerInterface::class);
 | 
			
		||||
 | 
			
		||||
        return [
 | 
			
		||||
            $em->createQueryBuilder()
 | 
			
		||||
                ->select('count(activity.id)')
 | 
			
		||||
                ->from(Activity::class, 'activity'),
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -12,7 +12,6 @@ declare(strict_types=1);
 | 
			
		||||
namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToACP;
 | 
			
		||||
 | 
			
		||||
use Chill\ActivityBundle\Export\Export\LinkedToACP\AvgActivityDuration;
 | 
			
		||||
use Chill\ActivityBundle\Repository\ActivityRepository;
 | 
			
		||||
use Chill\MainBundle\Test\Export\AbstractExportTest;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -22,17 +21,18 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
 | 
			
		||||
 */
 | 
			
		||||
final class AvgActivityDurationTest extends AbstractExportTest
 | 
			
		||||
{
 | 
			
		||||
    private AvgActivityDuration $export;
 | 
			
		||||
 | 
			
		||||
    protected function setUp(): void
 | 
			
		||||
    {
 | 
			
		||||
        self::bootKernel();
 | 
			
		||||
 | 
			
		||||
        $this->export = self::$container->get('chill.activity.export.avg_activity_duration_linked_to_acp');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getExport()
 | 
			
		||||
    {
 | 
			
		||||
        $activityRepository = self::$container->get(ActivityRepository::class);
 | 
			
		||||
 | 
			
		||||
        yield new AvgActivityDuration($activityRepository, $this->getParameters(true));
 | 
			
		||||
        yield new AvgActivityDuration($activityRepository, $this->getParameters(false));
 | 
			
		||||
        return $this->export;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getFormData(): array
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,6 @@ namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToACP;
 | 
			
		||||
 | 
			
		||||
use Chill\ActivityBundle\Export\Export\LinkedToACP\AvgActivityVisitDuration;
 | 
			
		||||
use Chill\MainBundle\Test\Export\AbstractExportTest;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @internal
 | 
			
		||||
@@ -22,17 +21,18 @@ use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
 */
 | 
			
		||||
final class AvgActivityVisitDurationTest extends AbstractExportTest
 | 
			
		||||
{
 | 
			
		||||
    private AvgActivityVisitDuration $export;
 | 
			
		||||
 | 
			
		||||
    protected function setUp(): void
 | 
			
		||||
    {
 | 
			
		||||
        self::bootKernel();
 | 
			
		||||
 | 
			
		||||
        $this->export = self::$container->get('chill.activity.export.avg_activity_visit_duration_linked_to_acp');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getExport()
 | 
			
		||||
    {
 | 
			
		||||
        $em = self::$container->get(EntityManagerInterface::class);
 | 
			
		||||
 | 
			
		||||
        yield new AvgActivityVisitDuration($em, $this->getParameters(true));
 | 
			
		||||
        yield new AvgActivityVisitDuration($em, $this->getParameters(false));
 | 
			
		||||
        return $this->export;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getFormData(): array
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,6 @@ namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToACP;
 | 
			
		||||
 | 
			
		||||
use Chill\ActivityBundle\Export\Export\LinkedToACP\CountActivity;
 | 
			
		||||
use Chill\MainBundle\Test\Export\AbstractExportTest;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @internal
 | 
			
		||||
@@ -22,17 +21,18 @@ use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
 */
 | 
			
		||||
final class CountActivityTest extends AbstractExportTest
 | 
			
		||||
{
 | 
			
		||||
    private CountActivity $export;
 | 
			
		||||
 | 
			
		||||
    protected function setUp(): void
 | 
			
		||||
    {
 | 
			
		||||
        self::bootKernel();
 | 
			
		||||
 | 
			
		||||
        $this->export = self::$container->get('chill.activity.export.count_activity_linked_to_acp');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getExport()
 | 
			
		||||
    {
 | 
			
		||||
        $em = self::$container->get(EntityManagerInterface::class);
 | 
			
		||||
 | 
			
		||||
        yield new CountActivity($em, $this->getParameters(true));
 | 
			
		||||
        yield new CountActivity($em, $this->getParameters(false));
 | 
			
		||||
        return $this->export;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getFormData(): array
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,6 @@ namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToACP;
 | 
			
		||||
 | 
			
		||||
use Chill\ActivityBundle\Export\Export\LinkedToACP\SumActivityDuration;
 | 
			
		||||
use Chill\MainBundle\Test\Export\AbstractExportTest;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @internal
 | 
			
		||||
@@ -22,17 +21,18 @@ use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
 */
 | 
			
		||||
final class SumActivityDurationTest extends AbstractExportTest
 | 
			
		||||
{
 | 
			
		||||
    private SumActivityDuration $export;
 | 
			
		||||
 | 
			
		||||
    protected function setUp(): void
 | 
			
		||||
    {
 | 
			
		||||
        self::bootKernel();
 | 
			
		||||
 | 
			
		||||
        $this->export = self::$container->get('chill.activity.export.sum_activity_duration_linked_to_acp');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getExport()
 | 
			
		||||
    {
 | 
			
		||||
        $em = self::$container->get(EntityManagerInterface::class);
 | 
			
		||||
 | 
			
		||||
        yield new SumActivityDuration($em, $this->getParameters(true));
 | 
			
		||||
        yield new SumActivityDuration($em, $this->getParameters(false));
 | 
			
		||||
        return $this->export;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getFormData(): array
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,6 @@ namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToACP;
 | 
			
		||||
 | 
			
		||||
use Chill\ActivityBundle\Export\Export\LinkedToACP\SumActivityVisitDuration;
 | 
			
		||||
use Chill\MainBundle\Test\Export\AbstractExportTest;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @internal
 | 
			
		||||
@@ -33,10 +32,7 @@ final class SumActivityVisitDurationTest extends AbstractExportTest
 | 
			
		||||
 | 
			
		||||
    public function getExport()
 | 
			
		||||
    {
 | 
			
		||||
        $em = self::$container->get(EntityManagerInterface::class);
 | 
			
		||||
 | 
			
		||||
        yield new SumActivityVisitDuration($em, $this->getParameters(true));
 | 
			
		||||
        yield new SumActivityVisitDuration($em, $this->getParameters(false));
 | 
			
		||||
        return $this->export;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getFormData(): array
 | 
			
		||||
 
 | 
			
		||||
@@ -12,7 +12,6 @@ declare(strict_types=1);
 | 
			
		||||
namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToPerson;
 | 
			
		||||
 | 
			
		||||
use Chill\ActivityBundle\Export\Export\LinkedToPerson\CountActivity;
 | 
			
		||||
use Chill\ActivityBundle\Repository\ActivityRepository;
 | 
			
		||||
use Chill\MainBundle\Test\Export\AbstractExportTest;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -22,17 +21,18 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
 | 
			
		||||
 */
 | 
			
		||||
final class CountActivityTest extends AbstractExportTest
 | 
			
		||||
{
 | 
			
		||||
    private CountActivity $export;
 | 
			
		||||
 | 
			
		||||
    protected function setUp(): void
 | 
			
		||||
    {
 | 
			
		||||
        self::bootKernel();
 | 
			
		||||
 | 
			
		||||
        $this->export = self::$container->get('chill.activity.export.count_activity_linked_to_person');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getExport()
 | 
			
		||||
    {
 | 
			
		||||
        $activityRepository = self::$container->get(ActivityRepository::class);
 | 
			
		||||
 | 
			
		||||
        yield new CountActivity($activityRepository, $this->getParameters(true));
 | 
			
		||||
        yield new CountActivity($activityRepository, $this->getParameters(false));
 | 
			
		||||
        return $this->export;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getFormData(): array
 | 
			
		||||
 
 | 
			
		||||
@@ -12,12 +12,8 @@ declare(strict_types=1);
 | 
			
		||||
namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToPerson;
 | 
			
		||||
 | 
			
		||||
use Chill\ActivityBundle\Export\Export\LinkedToPerson\ListActivity;
 | 
			
		||||
use Chill\ActivityBundle\Repository\ActivityRepository;
 | 
			
		||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
 | 
			
		||||
use Chill\MainBundle\Test\Export\AbstractExportTest;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
use Prophecy\PhpUnit\ProphecyTrait;
 | 
			
		||||
use Symfony\Contracts\Translation\TranslatorInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @internal
 | 
			
		||||
@@ -28,12 +24,14 @@ final class ListActivityTest extends AbstractExportTest
 | 
			
		||||
{
 | 
			
		||||
    use ProphecyTrait;
 | 
			
		||||
 | 
			
		||||
    private readonly ListActivity $export;
 | 
			
		||||
    private ListActivity $export;
 | 
			
		||||
 | 
			
		||||
    protected function setUp(): void
 | 
			
		||||
    {
 | 
			
		||||
        self::bootKernel();
 | 
			
		||||
 | 
			
		||||
        $this->export = self::$container->get('chill.activity.export.list_activity_linked_to_person');
 | 
			
		||||
 | 
			
		||||
        $request = $this->prophesize()
 | 
			
		||||
            ->willExtend(\Symfony\Component\HttpFoundation\Request::class);
 | 
			
		||||
 | 
			
		||||
@@ -45,26 +43,7 @@ final class ListActivityTest extends AbstractExportTest
 | 
			
		||||
 | 
			
		||||
    public function getExport()
 | 
			
		||||
    {
 | 
			
		||||
        $em = self::$container->get(EntityManagerInterface::class);
 | 
			
		||||
        $translator = self::$container->get(TranslatorInterface::class);
 | 
			
		||||
        $translatableStringHelper = self::$container->get(TranslatableStringHelperInterface::class);
 | 
			
		||||
        $activityRepository = self::$container->get(ActivityRepository::class);
 | 
			
		||||
 | 
			
		||||
        yield new ListActivity(
 | 
			
		||||
            $em,
 | 
			
		||||
            $translator,
 | 
			
		||||
            $translatableStringHelper,
 | 
			
		||||
            $activityRepository,
 | 
			
		||||
            $this->getParameters(true)
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        yield new ListActivity(
 | 
			
		||||
            $em,
 | 
			
		||||
            $translator,
 | 
			
		||||
            $translatableStringHelper,
 | 
			
		||||
            $activityRepository,
 | 
			
		||||
            $this->getParameters(false)
 | 
			
		||||
        );
 | 
			
		||||
        return $this->export;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getFormData()
 | 
			
		||||
 
 | 
			
		||||
@@ -12,7 +12,6 @@ declare(strict_types=1);
 | 
			
		||||
namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToPerson;
 | 
			
		||||
 | 
			
		||||
use Chill\ActivityBundle\Export\Export\LinkedToPerson\StatActivityDuration;
 | 
			
		||||
use Chill\ActivityBundle\Repository\ActivityRepository;
 | 
			
		||||
use Chill\MainBundle\Test\Export\AbstractExportTest;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -24,18 +23,18 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
 | 
			
		||||
 */
 | 
			
		||||
final class StatActivityDurationTest extends AbstractExportTest
 | 
			
		||||
{
 | 
			
		||||
    private readonly StatActivityDuration $export;
 | 
			
		||||
    private StatActivityDuration $export;
 | 
			
		||||
 | 
			
		||||
    protected function setUp(): void
 | 
			
		||||
    {
 | 
			
		||||
        self::bootKernel();
 | 
			
		||||
 | 
			
		||||
        $this->export = self::$container->get('chill.activity.export.sum_activity_duration_linked_to_person');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getExport()
 | 
			
		||||
    {
 | 
			
		||||
        $activityRepository = self::$container->get(ActivityRepository::class);
 | 
			
		||||
        yield new StatActivityDuration($activityRepository, $this->getParameters(true), 'sum');
 | 
			
		||||
        yield new StatActivityDuration($activityRepository, $this->getParameters(false), 'sum');
 | 
			
		||||
        return $this->export;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getFormData(): array
 | 
			
		||||
 
 | 
			
		||||
@@ -1,72 +0,0 @@
 | 
			
		||||
<?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\ActivityBundle\Tests\Export\Filter;
 | 
			
		||||
 | 
			
		||||
use Chill\ActivityBundle\Entity\Activity;
 | 
			
		||||
use Chill\ActivityBundle\Export\Filter\PersonsFilter;
 | 
			
		||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
 | 
			
		||||
use Chill\PersonBundle\Entity\Person;
 | 
			
		||||
use Chill\PersonBundle\Templating\Entity\PersonRenderInterface;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @internal
 | 
			
		||||
 *
 | 
			
		||||
 * @coversNothing
 | 
			
		||||
 */
 | 
			
		||||
class PersonsFilterTest extends AbstractFilterTest
 | 
			
		||||
{
 | 
			
		||||
    private PersonRenderInterface $personRender;
 | 
			
		||||
 | 
			
		||||
    protected function setUp(): void
 | 
			
		||||
    {
 | 
			
		||||
        parent::setUp();
 | 
			
		||||
        self::bootKernel();
 | 
			
		||||
        $this->personRender = self::$container->get(PersonRenderInterface::class);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getFilter()
 | 
			
		||||
    {
 | 
			
		||||
        return new PersonsFilter($this->personRender);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getFormData()
 | 
			
		||||
    {
 | 
			
		||||
        self::bootKernel();
 | 
			
		||||
        $em = self::$container->get(EntityManagerInterface::class);
 | 
			
		||||
 | 
			
		||||
        $persons = $em->createQuery('SELECT p FROM '.Person::class.' p ')
 | 
			
		||||
            ->setMaxResults(2)
 | 
			
		||||
            ->getResult();
 | 
			
		||||
 | 
			
		||||
        self::ensureKernelShutdown();
 | 
			
		||||
 | 
			
		||||
        return [
 | 
			
		||||
            [
 | 
			
		||||
                'accepted_persons' => $persons,
 | 
			
		||||
            ],
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getQueryBuilders()
 | 
			
		||||
    {
 | 
			
		||||
        self::bootKernel();
 | 
			
		||||
 | 
			
		||||
        $em = self::$container->get(EntityManagerInterface::class);
 | 
			
		||||
 | 
			
		||||
        yield $em->createQueryBuilder()
 | 
			
		||||
            ->select('count(activity.id)')
 | 
			
		||||
            ->from(Activity::class, 'activity');
 | 
			
		||||
 | 
			
		||||
        self::ensureKernelShutdown();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -12,7 +12,7 @@ declare(strict_types=1);
 | 
			
		||||
namespace Chill\ActivityBundle\Tests\Export\Filter;
 | 
			
		||||
 | 
			
		||||
use Chill\ActivityBundle\Entity\Activity;
 | 
			
		||||
use Chill\ActivityBundle\Export\Filter\CreatorScopeFilter;
 | 
			
		||||
use Chill\ActivityBundle\Export\Filter\UserScopeFilter;
 | 
			
		||||
use Chill\MainBundle\Entity\Scope;
 | 
			
		||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
@@ -22,15 +22,15 @@ use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
 *
 | 
			
		||||
 * @coversNothing
 | 
			
		||||
 */
 | 
			
		||||
final class CreatorScopeFilterTest extends AbstractFilterTest
 | 
			
		||||
final class UserScopeFilterTest extends AbstractFilterTest
 | 
			
		||||
{
 | 
			
		||||
    private CreatorScopeFilter $filter;
 | 
			
		||||
    private UserScopeFilter $filter;
 | 
			
		||||
 | 
			
		||||
    protected function setUp(): void
 | 
			
		||||
    {
 | 
			
		||||
        self::bootKernel();
 | 
			
		||||
 | 
			
		||||
        $this->filter = self::$container->get(CreatorScopeFilter::class);
 | 
			
		||||
        $this->filter = self::$container->get(UserScopeFilter::class);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getFilter()
 | 
			
		||||
@@ -109,10 +109,8 @@ services:
 | 
			
		||||
        tags:
 | 
			
		||||
            - { name: chill.export_filter, alias: 'activity_user_filter' }
 | 
			
		||||
 | 
			
		||||
    Chill\ActivityBundle\Export\Filter\CreatorScopeFilter:
 | 
			
		||||
    Chill\ActivityBundle\Export\Filter\UserScopeFilter:
 | 
			
		||||
        tags:
 | 
			
		||||
            # WARNING: for backward compatibility reason, the alias is named with userscope. Changing this will
 | 
			
		||||
            # affect all saved exports (unless we write a migration for that)
 | 
			
		||||
            - { name: chill.export_filter, alias: 'activity_userscope_filter' }
 | 
			
		||||
 | 
			
		||||
    Chill\ActivityBundle\Export\Filter\UsersJobFilter:
 | 
			
		||||
@@ -202,15 +200,3 @@ services:
 | 
			
		||||
    Chill\ActivityBundle\Export\Aggregator\SentReceivedAggregator:
 | 
			
		||||
        tags:
 | 
			
		||||
            - { name: chill.export_aggregator, alias: activity_sentreceived_aggregator }
 | 
			
		||||
 | 
			
		||||
    Chill\ActivityBundle\Export\Filter\PersonsFilter:
 | 
			
		||||
        tags:
 | 
			
		||||
            - { name: chill.export_filter, alias: activity_by_persons_filter }
 | 
			
		||||
 | 
			
		||||
    Chill\ActivityBundle\Export\Aggregator\PersonsAggregator:
 | 
			
		||||
        tags:
 | 
			
		||||
            - { name: chill.export_aggregator, alias: activity_by_persons_aggregator }
 | 
			
		||||
 | 
			
		||||
    Chill\ActivityBundle\Export\Aggregator\ACPAggregators\ByActivityTypeAggregator:
 | 
			
		||||
        tags:
 | 
			
		||||
            - { name: chill.export_aggregator, alias: acp_by_activity_type_aggregator }
 | 
			
		||||
 
 | 
			
		||||
@@ -275,7 +275,7 @@ Filter activity by linked socialaction: Filtrer les échanges par action liée
 | 
			
		||||
'Filtered activity by linked socialaction: only %actions%': "Filtré par action liée: uniquement %actions%"
 | 
			
		||||
Filter activity by linked socialissue: Filtrer les échanges par problématique liée
 | 
			
		||||
'Filtered activity by linked socialissue: only %issues%': "Filtré par problématique liée: uniquement %issues%"
 | 
			
		||||
Filter activity by user: Filtrer les échanges par utilisateur principal
 | 
			
		||||
Filter activity by user: Filtrer les échanges par créateur
 | 
			
		||||
Filter activity by users: Filtrer les échanges par utilisateur participant
 | 
			
		||||
Filter activity by creator: Filtrer les échanges par créateur de l'échange
 | 
			
		||||
'Filtered activity by user: only %users%': "Filtré par référent: uniquement %users%"
 | 
			
		||||
@@ -359,10 +359,10 @@ export:
 | 
			
		||||
                Filter by users job: Filtrer les échanges par métier d'au moins un utilisateur participant
 | 
			
		||||
                'Filtered activity by users job: only %jobs%': 'Filtré par métier d''au moins un utilisateur participant: seulement %jobs%'
 | 
			
		||||
            by_users_scope:
 | 
			
		||||
                Filter by users scope: Filtrer les échanges par service d'au moins un utilisateur participant
 | 
			
		||||
                Filter by users scope: Filtrer les échanges par services d'au moins un utilisateur participant
 | 
			
		||||
                'Filtered activity by users scope: only %scopes%': 'Filtré par service d''au moins un utilisateur participant: seulement %scopes%'
 | 
			
		||||
            course_having_activity_between_date:
 | 
			
		||||
                Title: Filtrer les parcours ayant reçu un échange entre deux dates
 | 
			
		||||
                Title: Filtre les parcours ayant reçu un échange entre deux dates
 | 
			
		||||
                Receiving an activity after: Ayant reçu un échange après le
 | 
			
		||||
                Receiving an activity before: Ayant reçu un échange avant le
 | 
			
		||||
            acp_by_activity_type:
 | 
			
		||||
@@ -372,27 +372,13 @@ export:
 | 
			
		||||
                Implied in an activity before this date: Impliqué dans un échange avant cette date
 | 
			
		||||
                Activity reasons for those activities: Sujets de ces échanges
 | 
			
		||||
                if no reasons: Si aucun sujet n'est coché, tous les sujets seront pris en compte
 | 
			
		||||
                title: Filtrer les usagers ayant été associés à un échange au cours de la période
 | 
			
		||||
                title: Filtrer les personnes ayant été associés à un échange au cours de la période
 | 
			
		||||
                date mismatch: La date de fin de la période doit être supérieure à la date du début
 | 
			
		||||
            by_creator_scope:
 | 
			
		||||
                Filter activity by user scope: Filtrer les échanges par service du créateur de l'échange
 | 
			
		||||
                'Filtered activity by user scope: only %scopes%': "Filtré par service du créateur: uniquement %scopes%"
 | 
			
		||||
            by_persons:
 | 
			
		||||
                Filter activity by persons: Filtrer les échanges par usager participant
 | 
			
		||||
                'Filtered activity by persons: only %persons%': 'Échanges filtrés par usagers participants: seulement %persons%'
 | 
			
		||||
                persons taking part on the activity: Usagers participants à l'échange
 | 
			
		||||
            by_sent_received:
 | 
			
		||||
                Sent or received: Envoyé ou reçu
 | 
			
		||||
                is sent: envoyé
 | 
			
		||||
                is received: reçu
 | 
			
		||||
 | 
			
		||||
    aggregator:
 | 
			
		||||
        acp:
 | 
			
		||||
            by_activity_type:
 | 
			
		||||
                title: Grouper les parcours par type d'échange
 | 
			
		||||
                after_date: Uniquement échanges après cette date
 | 
			
		||||
                before_date: Uniquement échanges avant cette date
 | 
			
		||||
                activity_type: Types d'échange
 | 
			
		||||
        activity:
 | 
			
		||||
            by_sent_received:
 | 
			
		||||
                Sent or received: Envoyé ou reçu
 | 
			
		||||
@@ -414,9 +400,6 @@ export:
 | 
			
		||||
            by_creator_job:
 | 
			
		||||
                Group activity by creator job: Grouper les échanges par service du créateur de l'échange
 | 
			
		||||
                Calc date: Date de calcul du service du créateur de l'échange
 | 
			
		||||
            by_persons:
 | 
			
		||||
                Group activity by persons: Grouper les échanges par usager participant
 | 
			
		||||
                Persons: Usagers participants
 | 
			
		||||
 | 
			
		||||
generic_doc:
 | 
			
		||||
    filter:
 | 
			
		||||
 
 | 
			
		||||
@@ -25,9 +25,7 @@ use Symfony\Component\Validator\Exception\LogicException;
 | 
			
		||||
 | 
			
		||||
class CountCalendars implements ExportInterface, GroupedExportInterface
 | 
			
		||||
{
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private readonly CalendarRepository $calendarRepository,
 | 
			
		||||
    ) {}
 | 
			
		||||
    public function __construct(private readonly CalendarRepository $calendarRepository) {}
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder)
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -18,15 +18,12 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
 | 
			
		||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
 | 
			
		||||
use Symfony\Component\HttpFoundation\Request;
 | 
			
		||||
use Symfony\Component\Routing\Annotation\Route;
 | 
			
		||||
use Symfony\Contracts\Translation\TranslatorInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Class CustomFieldController.
 | 
			
		||||
 */
 | 
			
		||||
class CustomFieldController extends AbstractController
 | 
			
		||||
{
 | 
			
		||||
    public function __construct(private readonly TranslatorInterface $translator) {}
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Creates a new CustomField entity.
 | 
			
		||||
     *
 | 
			
		||||
@@ -43,13 +40,13 @@ class CustomFieldController extends AbstractController
 | 
			
		||||
            $em->persist($entity);
 | 
			
		||||
            $em->flush();
 | 
			
		||||
 | 
			
		||||
            $this->addFlash('success', $this->translator
 | 
			
		||||
            $this->addFlash('success', $this->get('translator')
 | 
			
		||||
                ->trans('The custom field has been created'));
 | 
			
		||||
 | 
			
		||||
            return $this->redirectToRoute('customfieldsgroup_show', ['id' => $entity->getCustomFieldsGroup()->getId()]);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $this->addFlash('error', $this->translator
 | 
			
		||||
        $this->addFlash('error', $this->get('translator')
 | 
			
		||||
            ->trans('The custom field form contains errors'));
 | 
			
		||||
 | 
			
		||||
        return $this->render('@ChillCustomFields/CustomField/new.html.twig', [
 | 
			
		||||
@@ -133,13 +130,13 @@ class CustomFieldController extends AbstractController
 | 
			
		||||
        if ($editForm->isSubmitted() && $editForm->isValid()) {
 | 
			
		||||
            $em->flush();
 | 
			
		||||
 | 
			
		||||
            $this->addFlash('success', $this->translator
 | 
			
		||||
            $this->addFlash('success', $this->get('translator')
 | 
			
		||||
                ->trans('The custom field has been updated'));
 | 
			
		||||
 | 
			
		||||
            return $this->redirectToRoute('customfield_edit', ['id' => $id]);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $this->addFlash('error', $this->translator
 | 
			
		||||
        $this->addFlash('error', $this->get('translator')
 | 
			
		||||
            ->trans('The custom field form contains errors'));
 | 
			
		||||
 | 
			
		||||
        return $this->render('@ChillCustomFields/CustomField/edit.html.twig', [
 | 
			
		||||
 
 | 
			
		||||
@@ -118,7 +118,7 @@ class EventController extends AbstractController
 | 
			
		||||
 | 
			
		||||
                $this->addFlash(
 | 
			
		||||
                    'success',
 | 
			
		||||
                    $this->translator
 | 
			
		||||
                    $this->get('translator')
 | 
			
		||||
                        ->trans('The event has been sucessfully removed')
 | 
			
		||||
                );
 | 
			
		||||
 | 
			
		||||
@@ -249,7 +249,7 @@ class EventController extends AbstractController
 | 
			
		||||
            $em->persist($entity);
 | 
			
		||||
            $em->flush();
 | 
			
		||||
 | 
			
		||||
            $this->addFlash('success', $this->translator
 | 
			
		||||
            $this->addFlash('success', $this->get('translator')
 | 
			
		||||
                ->trans('The event was created'));
 | 
			
		||||
 | 
			
		||||
            return $this->redirectToRoute('chill_event__event_show', ['event_id' => $entity->getId()]);
 | 
			
		||||
@@ -364,7 +364,7 @@ class EventController extends AbstractController
 | 
			
		||||
        if ($editForm->isValid()) {
 | 
			
		||||
            $em->flush();
 | 
			
		||||
 | 
			
		||||
            $this->addFlash('success', $this->translator
 | 
			
		||||
            $this->addFlash('success', $this->get('translator')
 | 
			
		||||
                ->trans('The event was updated'));
 | 
			
		||||
 | 
			
		||||
            return $this->redirectToRoute('chill_event__event_edit', ['event_id' => $event_id]);
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,6 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
 | 
			
		||||
use Symfony\Component\Form\FormInterface;
 | 
			
		||||
use Symfony\Component\HttpFoundation\Request;
 | 
			
		||||
use Symfony\Component\HttpFoundation\Response;
 | 
			
		||||
use Symfony\Contracts\Translation\TranslatorInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Class ParticipationController.
 | 
			
		||||
@@ -33,7 +32,7 @@ class ParticipationController extends AbstractController
 | 
			
		||||
    /**
 | 
			
		||||
     * ParticipationController constructor.
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct(private readonly LoggerInterface $logger, private readonly TranslatorInterface $translator) {}
 | 
			
		||||
    public function __construct(private readonly LoggerInterface $logger) {}
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/event/participation/create", name="chill_event_participation_create")
 | 
			
		||||
@@ -178,7 +177,7 @@ class ParticipationController extends AbstractController
 | 
			
		||||
 | 
			
		||||
            $em->flush();
 | 
			
		||||
 | 
			
		||||
            $this->addFlash('success', $this->translator->trans(
 | 
			
		||||
            $this->addFlash('success', $this->get('translator')->trans(
 | 
			
		||||
                'The participations were created'
 | 
			
		||||
            ));
 | 
			
		||||
 | 
			
		||||
@@ -212,7 +211,7 @@ class ParticipationController extends AbstractController
 | 
			
		||||
            $em->persist($participation);
 | 
			
		||||
            $em->flush();
 | 
			
		||||
 | 
			
		||||
            $this->addFlash('success', $this->translator->trans(
 | 
			
		||||
            $this->addFlash('success', $this->get('translator')->trans(
 | 
			
		||||
                'The participation was created'
 | 
			
		||||
            ));
 | 
			
		||||
 | 
			
		||||
@@ -261,7 +260,7 @@ class ParticipationController extends AbstractController
 | 
			
		||||
 | 
			
		||||
                $this->addFlash(
 | 
			
		||||
                    'success',
 | 
			
		||||
                    $this->translator
 | 
			
		||||
                    $this->get('translator')
 | 
			
		||||
                        ->trans('The participation has been sucessfully removed')
 | 
			
		||||
                );
 | 
			
		||||
 | 
			
		||||
@@ -341,7 +340,7 @@ class ParticipationController extends AbstractController
 | 
			
		||||
        switch ($event->getParticipations()->count()) {
 | 
			
		||||
            case 0:
 | 
			
		||||
                // if there aren't any participation, redirect to the 'show' view with an add flash
 | 
			
		||||
                $this->addFlash('warning', $this->translator
 | 
			
		||||
                $this->addFlash('warning', $this->get('translator')
 | 
			
		||||
                    ->trans('There are no participation to edit for this event'));
 | 
			
		||||
 | 
			
		||||
                return $this->redirectToRoute(
 | 
			
		||||
@@ -435,7 +434,7 @@ class ParticipationController extends AbstractController
 | 
			
		||||
 | 
			
		||||
            $em->flush();
 | 
			
		||||
 | 
			
		||||
            $this->addFlash('success', $this->translator->trans(
 | 
			
		||||
            $this->addFlash('success', $this->get('translator')->trans(
 | 
			
		||||
                'The participation was updated'
 | 
			
		||||
            ));
 | 
			
		||||
 | 
			
		||||
@@ -481,7 +480,7 @@ class ParticipationController extends AbstractController
 | 
			
		||||
        if ($form->isSubmitted() && $form->isValid()) {
 | 
			
		||||
            $this->getDoctrine()->getManager()->flush();
 | 
			
		||||
 | 
			
		||||
            $this->addFlash('success', $this->translator->trans('The participations '
 | 
			
		||||
            $this->addFlash('success', $this->get('translator')->trans('The participations '
 | 
			
		||||
                    .'have been successfully updated.'));
 | 
			
		||||
 | 
			
		||||
            return $this->redirectToRoute(
 | 
			
		||||
@@ -653,7 +652,7 @@ class ParticipationController extends AbstractController
 | 
			
		||||
 | 
			
		||||
        if ([] === $newParticipations) {
 | 
			
		||||
            // if we do not have nay participants, redirect to event view
 | 
			
		||||
            $this->addFlash('error', $this->translator->trans(
 | 
			
		||||
            $this->addFlash('error', $this->get('translator')->trans(
 | 
			
		||||
                'None of the requested people may participate '
 | 
			
		||||
                    .'the event: they are maybe already participating.'
 | 
			
		||||
            ));
 | 
			
		||||
 
 | 
			
		||||
@@ -32,6 +32,7 @@ use Chill\MainBundle\Security\Resolver\ScopeResolverInterface;
 | 
			
		||||
use Chill\MainBundle\Service\EntityInfo\ViewEntityInfoProviderInterface;
 | 
			
		||||
use Chill\MainBundle\Templating\Entity\ChillEntityRenderInterface;
 | 
			
		||||
use Chill\MainBundle\Templating\UI\NotificationCounterInterface;
 | 
			
		||||
use Chill\MainBundle\Widget\WidgetHandlerInterface;
 | 
			
		||||
use Chill\MainBundle\Workflow\EntityWorkflowHandlerInterface;
 | 
			
		||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
 | 
			
		||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
 | 
			
		||||
@@ -62,9 +63,10 @@ class ChillMainBundle extends Bundle
 | 
			
		||||
            ->addTag('chill_main.workflow_handler');
 | 
			
		||||
        $container->registerForAutoconfiguration(CronJobInterface::class)
 | 
			
		||||
            ->addTag('chill_main.cron_job');
 | 
			
		||||
        $container->registerForAutoconfiguration(WidgetHandlerInterface::class)
 | 
			
		||||
            ->addTag('chill_main.widget_handler');
 | 
			
		||||
        $container->registerForAutoconfiguration(ViewEntityInfoProviderInterface::class)
 | 
			
		||||
            ->addTag('chill_main.entity_info_provider');
 | 
			
		||||
 | 
			
		||||
        $container->addCompilerPass(new SearchableServicesCompilerPass(), \Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, 0);
 | 
			
		||||
        $container->addCompilerPass(new ConfigConsistencyCompilerPass(), \Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, 0);
 | 
			
		||||
        $container->addCompilerPass(new TimelineCompilerClass(), \Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION, 0);
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,133 @@
 | 
			
		||||
<?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\MainBundle\Controller;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
use Chill\MainBundle\Entity\User;
 | 
			
		||||
use Chill\MainBundle\Pagination\PaginatorFactory;
 | 
			
		||||
use Chill\MainBundle\Repository\UserRepository;
 | 
			
		||||
use Chill\MainBundle\Serializer\Model\Collection;
 | 
			
		||||
use Chill\MainBundle\Widget\WidgetHandlerManager;
 | 
			
		||||
use Chill\PersonBundle\Repository\AccompanyingPeriodRepository;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
 | 
			
		||||
use Symfony\Component\Security\Core\Security;
 | 
			
		||||
use PHPUnit\Util\Json;
 | 
			
		||||
use Symfony\Component\HttpFoundation\Request;
 | 
			
		||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
 | 
			
		||||
use Symfony\Component\HttpFoundation\JsonResponse;
 | 
			
		||||
use Symfony\Component\HttpFoundation\Response;
 | 
			
		||||
use Symfony\Component\Routing\Annotation\Route;
 | 
			
		||||
use Psr\Log\LoggerInterface;
 | 
			
		||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
 | 
			
		||||
use Symfony\Component\Serializer\Serializer;
 | 
			
		||||
use Symfony\Component\Serializer\SerializerInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @Route("/{_locale}/dashboard")
 | 
			
		||||
 */
 | 
			
		||||
class DashboardHomepageController extends AbstractController{
 | 
			
		||||
 | 
			
		||||
    private WidgetHandlerManager $widgetHandlerManager;
 | 
			
		||||
 | 
			
		||||
    private Security $security;
 | 
			
		||||
 | 
			
		||||
    private UserRepository $userRepository;
 | 
			
		||||
 | 
			
		||||
    private EntityManagerInterface $em;
 | 
			
		||||
 | 
			
		||||
    private LoggerInterface $logger;
 | 
			
		||||
 | 
			
		||||
    private SerializerInterface $serializer;
 | 
			
		||||
 | 
			
		||||
    private PaginatorFactory $paginatorFactory;
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        //AccompanyingPeriodRepository $accompanyingPeriodRepository,
 | 
			
		||||
        WidgetHandlerManager $widgetHandlerManager,
 | 
			
		||||
        Security $security,
 | 
			
		||||
        UserRepository $userRepository,
 | 
			
		||||
        EntityManagerInterface $em,
 | 
			
		||||
        LoggerInterface $logger,
 | 
			
		||||
        SerializerInterface $serializer,
 | 
			
		||||
        PaginatorFactory $paginatorFactory,
 | 
			
		||||
    )
 | 
			
		||||
    {
 | 
			
		||||
        //$this->accompanyingPeriodRepository = $accompanyingPeriodRepository;
 | 
			
		||||
        $this->widgetHandlerManager = $widgetHandlerManager;
 | 
			
		||||
        $this->security = $security;
 | 
			
		||||
        $this->userRepository = $userRepository;
 | 
			
		||||
        $this->em = $em;
 | 
			
		||||
        $this->logger = $logger;
 | 
			
		||||
        $this->serializer = $serializer;
 | 
			
		||||
        $this->paginatorFactory = $paginatorFactory;
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @Route("/raw_data", name="chill_main_widget_raw_data")
 | 
			
		||||
     * @return JsonResponse
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
    public function index(): JsonResponse
 | 
			
		||||
    {
 | 
			
		||||
        $this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED');
 | 
			
		||||
 | 
			
		||||
        if (!$this->security->getUser() instanceof User) {
 | 
			
		||||
            throw new AccessDeniedHttpException('You must be authenticated and a user to see the dashboard');
 | 
			
		||||
        }
 | 
			
		||||
        // --------------Bar---------------------
 | 
			
		||||
        $config = [
 | 
			
		||||
            'alias' => 'bar',
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $context = [
 | 
			
		||||
            //'user' => $this->security->getUser(),
 | 
			
		||||
            //Hardcoder pour resultat
 | 
			
		||||
            'user' => 19,
 | 
			
		||||
            'what' => 'accompanying_period_by_month',
 | 
			
		||||
        ];
 | 
			
		||||
        // --------------Number------------------
 | 
			
		||||
        /*$config = [
 | 
			
		||||
            'alias' => 'number',
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $context = [
 | 
			
		||||
            'user' => $this->security->getUser(),
 | 
			
		||||
            //'what' => 'notification_unread',
 | 
			
		||||
            'what' => 'notification_sender',
 | 
			
		||||
        ];*/
 | 
			
		||||
        $data = $this->widgetHandlerManager->getDataForWidget($config, $context);
 | 
			
		||||
 | 
			
		||||
        return new JsonResponse($data,Response::HTTP_OK,[]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @Route("/widget/{context}", name="chill_main_widget_get_data")
 | 
			
		||||
     */
 | 
			
		||||
    public function getDataForWidget(Request $request, string $context): JsonResponse
 | 
			
		||||
    {
 | 
			
		||||
        //Retrieve data from request in vue component
 | 
			
		||||
        $requestData = json_decode($request->getContent(), true);
 | 
			
		||||
        dump($requestData);
 | 
			
		||||
        // Process the widget data using the WidgetHandlerManager
 | 
			
		||||
        //$handler = $this->widgetHandlerManager->getHandler($requestData);
 | 
			
		||||
        //dump($handler);
 | 
			
		||||
 | 
			
		||||
        // Return the widget data in JSON response
 | 
			
		||||
        //return new JsonResponse($this->getData($requestData));
 | 
			
		||||
 | 
			
		||||
        return new JsonResponse($requestData);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -27,7 +27,6 @@ use Chill\MainBundle\Security\Authorization\SavedExportVoter;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
use Psr\Log\LoggerInterface;
 | 
			
		||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
 | 
			
		||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
 | 
			
		||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
 | 
			
		||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
 | 
			
		||||
use Symfony\Component\Form\FormFactoryInterface;
 | 
			
		||||
@@ -47,8 +46,6 @@ use Symfony\Contracts\Translation\TranslatorInterface;
 | 
			
		||||
 */
 | 
			
		||||
class ExportController extends AbstractController
 | 
			
		||||
{
 | 
			
		||||
    private readonly bool $filterStatsByCenters;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private readonly ChillRedis $redis,
 | 
			
		||||
        private readonly ExportManager $exportManager,
 | 
			
		||||
@@ -59,11 +56,8 @@ class ExportController extends AbstractController
 | 
			
		||||
        private readonly EntityManagerInterface $entityManager,
 | 
			
		||||
        private readonly ExportFormHelper $exportFormHelper,
 | 
			
		||||
        private readonly SavedExportRepositoryInterface $savedExportRepository,
 | 
			
		||||
        private readonly Security $security,
 | 
			
		||||
        ParameterBagInterface $parameterBag,
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
 | 
			
		||||
    }
 | 
			
		||||
        private readonly Security $security
 | 
			
		||||
    ) {}
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/exports/download/{alias}", name="chill_main_export_download", methods={"GET"})
 | 
			
		||||
@@ -281,7 +275,7 @@ class ExportController extends AbstractController
 | 
			
		||||
        $options = match ($step) {
 | 
			
		||||
            'export', 'generate_export' => [
 | 
			
		||||
                'export_alias' => $alias,
 | 
			
		||||
                'picked_centers' => $exportManager->getPickedCenters($data['centers'] ?? []),
 | 
			
		||||
                'picked_centers' => $exportManager->getPickedCenters($data['centers']),
 | 
			
		||||
            ],
 | 
			
		||||
            'formatter', 'generate_formatter' => [
 | 
			
		||||
                'export_alias' => $alias,
 | 
			
		||||
@@ -339,9 +333,9 @@ class ExportController extends AbstractController
 | 
			
		||||
        $exportManager = $this->exportManager;
 | 
			
		||||
 | 
			
		||||
        // check we have data from the previous step (export step)
 | 
			
		||||
        $data = $this->session->get('centers_step', []);
 | 
			
		||||
        $data = $this->session->get('centers_step', null);
 | 
			
		||||
 | 
			
		||||
        if (null === $data && true === $this->filterStatsByCenters) {
 | 
			
		||||
        if (null === $data) {
 | 
			
		||||
            return $this->redirectToRoute('chill_main_export_new', [
 | 
			
		||||
                'step' => $this->getNextStep('export', $export, true),
 | 
			
		||||
                'alias' => $alias,
 | 
			
		||||
@@ -490,13 +484,9 @@ class ExportController extends AbstractController
 | 
			
		||||
 | 
			
		||||
        $alias = $rawData['alias'];
 | 
			
		||||
 | 
			
		||||
        if ($this->filterStatsByCenters) {
 | 
			
		||||
            $formCenters = $this->createCreateFormExport($alias, 'generate_centers', [], $savedExport);
 | 
			
		||||
            $formCenters->submit($rawData['centers']);
 | 
			
		||||
            $dataCenters = $formCenters->getData();
 | 
			
		||||
        } else {
 | 
			
		||||
            $dataCenters = ['centers' => []];
 | 
			
		||||
        }
 | 
			
		||||
        $formCenters = $this->createCreateFormExport($alias, 'generate_centers', [], $savedExport);
 | 
			
		||||
        $formCenters->submit($rawData['centers']);
 | 
			
		||||
        $dataCenters = $formCenters->getData();
 | 
			
		||||
 | 
			
		||||
        $formExport = $this->createCreateFormExport($alias, 'generate_export', $dataCenters, $savedExport);
 | 
			
		||||
        $formExport->submit($rawData['export']);
 | 
			
		||||
@@ -523,14 +513,6 @@ class ExportController extends AbstractController
 | 
			
		||||
     */
 | 
			
		||||
    private function selectCentersStep(Request $request, DirectExportInterface|ExportInterface $export, $alias, SavedExport $savedExport = null)
 | 
			
		||||
    {
 | 
			
		||||
        if (!$this->filterStatsByCenters) {
 | 
			
		||||
            return $this->redirectToRoute('chill_main_export_new', [
 | 
			
		||||
                'step' => $this->getNextStep('centers', $export),
 | 
			
		||||
                'alias' => $alias,
 | 
			
		||||
                'from_saved' => $request->get('from_saved', ''),
 | 
			
		||||
            ]);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /** @var \Chill\MainBundle\Export\ExportManager $exportManager */
 | 
			
		||||
        $exportManager = $this->exportManager;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -9,11 +9,10 @@ declare(strict_types=1);
 | 
			
		||||
 * the LICENSE file that was distributed with this source code.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
namespace Chill\PersonBundle\Export\Enum;
 | 
			
		||||
namespace Chill\MainBundle\Controller;
 | 
			
		||||
 | 
			
		||||
enum DateGroupingChoiceEnum: string
 | 
			
		||||
use Chill\MainBundle\CRUD\Controller\ApiController;
 | 
			
		||||
 | 
			
		||||
class SavedExportApiController extends ApiController
 | 
			
		||||
{
 | 
			
		||||
    case MONTH = 'YYYY-MM';
 | 
			
		||||
    case WEEK = 'YYYY-IW';
 | 
			
		||||
    case YEAR = 'YYYY';
 | 
			
		||||
}
 | 
			
		||||
@@ -32,13 +32,12 @@ use Symfony\Component\HttpFoundation\Response;
 | 
			
		||||
use Symfony\Component\Routing\Annotation\Route;
 | 
			
		||||
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
 | 
			
		||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
 | 
			
		||||
use Symfony\Contracts\Translation\TranslatorInterface;
 | 
			
		||||
 | 
			
		||||
class UserController extends CRUDController
 | 
			
		||||
{
 | 
			
		||||
    final public const FORM_GROUP_CENTER_COMPOSED = 'composed_groupcenter';
 | 
			
		||||
 | 
			
		||||
    public function __construct(private readonly LoggerInterface $logger, private readonly ValidatorInterface $validator, private readonly UserPasswordEncoderInterface $passwordEncoder, private readonly UserRepository $userRepository, protected ParameterBagInterface $parameterBag, private readonly TranslatorInterface $translator) {}
 | 
			
		||||
    public function __construct(private readonly LoggerInterface $logger, private readonly ValidatorInterface $validator, private readonly UserPasswordEncoderInterface $passwordEncoder, private readonly UserRepository $userRepository, protected ParameterBagInterface $parameterBag) {}
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @Route("/{_locale}/admin/main/user/{uid}/add_link_groupcenter",
 | 
			
		||||
@@ -66,7 +65,7 @@ class UserController extends CRUDController
 | 
			
		||||
            if (0 === $this->validator->validate($user)->count()) {
 | 
			
		||||
                $em->flush();
 | 
			
		||||
 | 
			
		||||
                $this->addFlash('success', $this->translator->trans('The '
 | 
			
		||||
                $this->addFlash('success', $this->get('translator')->trans('The '
 | 
			
		||||
                    .'permissions have been successfully added to the user'));
 | 
			
		||||
 | 
			
		||||
                $returnPathParams = $request->query->has('returnPath') ?
 | 
			
		||||
@@ -116,14 +115,14 @@ class UserController extends CRUDController
 | 
			
		||||
        try {
 | 
			
		||||
            $user->removeGroupCenter($groupCenter);
 | 
			
		||||
        } catch (\RuntimeException $ex) {
 | 
			
		||||
            $this->addFlash('error', $this->translator->trans($ex->getMessage()));
 | 
			
		||||
            $this->addFlash('error', $this->get('translator')->trans($ex->getMessage()));
 | 
			
		||||
 | 
			
		||||
            return $this->redirectToRoute('chill_crud_admin_user_edit', ['id' => $uid]);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $em->flush();
 | 
			
		||||
 | 
			
		||||
        $this->addFlash('success', $this->translator
 | 
			
		||||
        $this->addFlash('success', $this->get('translator')
 | 
			
		||||
            ->trans('The permissions where removed.'));
 | 
			
		||||
 | 
			
		||||
        return $this->redirectToRoute('chill_crud_admin_user_edit', ['id' => $uid]);
 | 
			
		||||
@@ -208,7 +207,7 @@ class UserController extends CRUDController
 | 
			
		||||
            $user->setCurrentLocation($currentLocation);
 | 
			
		||||
 | 
			
		||||
            $this->getDoctrine()->getManager()->flush();
 | 
			
		||||
            $this->addFlash('success', $this->translator->trans('Current location successfully updated'));
 | 
			
		||||
            $this->addFlash('success', $this->get('translator')->trans('Current location successfully updated'));
 | 
			
		||||
 | 
			
		||||
            return $this->redirect(
 | 
			
		||||
                $request->query->has('returnPath') ? $request->query->get('returnPath') :
 | 
			
		||||
@@ -244,7 +243,7 @@ class UserController extends CRUDController
 | 
			
		||||
            $user->setPassword($this->passwordEncoder->encodePassword($user, $password));
 | 
			
		||||
 | 
			
		||||
            $this->getDoctrine()->getManager()->flush();
 | 
			
		||||
            $this->addFlash('success', $this->translator->trans('Password successfully updated!'));
 | 
			
		||||
            $this->addFlash('success', $this->get('translator')->trans('Password successfully updated!'));
 | 
			
		||||
 | 
			
		||||
            return $this->redirect(
 | 
			
		||||
                $request->query->has('returnPath') ? $request->query->get('returnPath') :
 | 
			
		||||
 
 | 
			
		||||
@@ -20,6 +20,7 @@ use Chill\MainBundle\Controller\LanguageController;
 | 
			
		||||
use Chill\MainBundle\Controller\LocationController;
 | 
			
		||||
use Chill\MainBundle\Controller\LocationTypeController;
 | 
			
		||||
use Chill\MainBundle\Controller\RegroupmentController;
 | 
			
		||||
use Chill\MainBundle\Controller\SavedExportApiController;
 | 
			
		||||
use Chill\MainBundle\Controller\UserController;
 | 
			
		||||
use Chill\MainBundle\Controller\UserJobApiController;
 | 
			
		||||
use Chill\MainBundle\Controller\UserJobController;
 | 
			
		||||
@@ -54,6 +55,7 @@ use Chill\MainBundle\Entity\Language;
 | 
			
		||||
use Chill\MainBundle\Entity\Location;
 | 
			
		||||
use Chill\MainBundle\Entity\LocationType;
 | 
			
		||||
use Chill\MainBundle\Entity\Regroupment;
 | 
			
		||||
use Chill\MainBundle\Entity\SavedExport;
 | 
			
		||||
use Chill\MainBundle\Entity\User;
 | 
			
		||||
use Chill\MainBundle\Entity\UserJob;
 | 
			
		||||
use Chill\MainBundle\Form\CenterType;
 | 
			
		||||
@@ -228,7 +230,7 @@ class ChillMainExtension extends Extension implements
 | 
			
		||||
        $twigConfig = [
 | 
			
		||||
            'globals' => [
 | 
			
		||||
                'installation' => [
 | 
			
		||||
                    'name' => $config['installation_name'], ],
 | 
			
		||||
                    'name' => $config['installation_name'],],
 | 
			
		||||
                'available_languages' => $config['available_languages'],
 | 
			
		||||
                'add_address' => $config['add_address'],
 | 
			
		||||
            ],
 | 
			
		||||
@@ -327,9 +329,9 @@ class ChillMainExtension extends Extension implements
 | 
			
		||||
     * Load parameter for configuration and set parameters for api.
 | 
			
		||||
     */
 | 
			
		||||
    protected function configureCruds(
 | 
			
		||||
        ContainerBuilder $container,
 | 
			
		||||
        array $crudConfig,
 | 
			
		||||
        array $apiConfig,
 | 
			
		||||
        ContainerBuilder      $container,
 | 
			
		||||
        array                 $crudConfig,
 | 
			
		||||
        array                 $apiConfig,
 | 
			
		||||
        Loader\YamlFileLoader $loader
 | 
			
		||||
    ): void {
 | 
			
		||||
        if (0 === \count($crudConfig)) {
 | 
			
		||||
@@ -767,7 +769,28 @@ class ChillMainExtension extends Extension implements
 | 
			
		||||
                        ],
 | 
			
		||||
                    ],
 | 
			
		||||
                ],
 | 
			
		||||
            ],
 | 
			
		||||
                [
 | 
			
		||||
                    'class' => SavedExport::class,
 | 
			
		||||
                    'controller' => SavedExportApiController::class,
 | 
			
		||||
                    'name' => 'saved_export',
 | 
			
		||||
                    'base_path' => '/api/1.0/main/saved-export',
 | 
			
		||||
                    'base_role' => 'ROLE_USER',
 | 
			
		||||
                    'actions' => [
 | 
			
		||||
                        '_index' => [
 | 
			
		||||
                            'methods' => [
 | 
			
		||||
                                Request::METHOD_GET => true,
 | 
			
		||||
                                Request::METHOD_HEAD => true,
 | 
			
		||||
                            ],
 | 
			
		||||
                        ],
 | 
			
		||||
                        '_entity' => [
 | 
			
		||||
                            'methods' => [
 | 
			
		||||
                                Request::METHOD_GET => true,
 | 
			
		||||
                                Request::METHOD_HEAD => true,
 | 
			
		||||
                            ],
 | 
			
		||||
                        ],
 | 
			
		||||
                    ],
 | 
			
		||||
                ]
 | 
			
		||||
            ]
 | 
			
		||||
        ]);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -116,12 +116,8 @@ class Configuration implements ConfigurationInterface
 | 
			
		||||
            ->booleanNode('form_show_centers')
 | 
			
		||||
            ->defaultTrue()
 | 
			
		||||
            ->end()
 | 
			
		||||
            ->booleanNode('filter_stats_by_center')
 | 
			
		||||
            ->defaultTrue()
 | 
			
		||||
            ->info("if set to false, the exports won't take into account the center of the people")
 | 
			
		||||
            ->end()
 | 
			
		||||
            ->end()
 | 
			
		||||
            ->end() // end of 'acl'
 | 
			
		||||
            ->booleanNode('access_global_history')
 | 
			
		||||
            ->defaultTrue()
 | 
			
		||||
            ->end()
 | 
			
		||||
 
 | 
			
		||||
@@ -19,6 +19,7 @@ use Doctrine\ORM\Mapping as ORM;
 | 
			
		||||
use Ramsey\Uuid\Uuid;
 | 
			
		||||
use Ramsey\Uuid\UuidInterface;
 | 
			
		||||
use Symfony\Component\Validator\Constraints as Assert;
 | 
			
		||||
use Symfony\Component\Serializer\Annotation\Groups;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @ORM\Entity
 | 
			
		||||
@@ -35,6 +36,7 @@ class SavedExport implements TrackCreationInterface, TrackUpdateInterface
 | 
			
		||||
     * @ORM\Column(type="text", nullable=false, options={"default": ""})
 | 
			
		||||
     *
 | 
			
		||||
     * @Assert\NotBlank
 | 
			
		||||
     * @Groups({"read"})
 | 
			
		||||
     */
 | 
			
		||||
    private string $description = '';
 | 
			
		||||
 | 
			
		||||
@@ -49,11 +51,13 @@ class SavedExport implements TrackCreationInterface, TrackUpdateInterface
 | 
			
		||||
     * @ORM\Column(name="id", type="uuid", unique="true")
 | 
			
		||||
     *
 | 
			
		||||
     * @ORM\GeneratedValue(strategy="NONE")
 | 
			
		||||
     * @Groups({"read"})
 | 
			
		||||
     */
 | 
			
		||||
    private UuidInterface $id;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @ORM\Column(type="json", nullable=false, options={"default": "[]"})
 | 
			
		||||
     * @Groups({"read"})
 | 
			
		||||
     */
 | 
			
		||||
    private array $options = [];
 | 
			
		||||
 | 
			
		||||
@@ -61,11 +65,13 @@ class SavedExport implements TrackCreationInterface, TrackUpdateInterface
 | 
			
		||||
     * @ORM\Column(type="text", nullable=false, options={"default": ""})
 | 
			
		||||
     *
 | 
			
		||||
     * @Assert\NotBlank
 | 
			
		||||
     * @Groups({"read"})
 | 
			
		||||
     */
 | 
			
		||||
    private string $title = '';
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @ORM\ManyToOne(targetEntity=User::class)
 | 
			
		||||
     * @Groups({"read"})
 | 
			
		||||
     */
 | 
			
		||||
    private User $user;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,6 @@ declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Chill\MainBundle\Export;
 | 
			
		||||
 | 
			
		||||
use Chill\MainBundle\Entity\User;
 | 
			
		||||
use Chill\MainBundle\Form\Type\Export\ExportType;
 | 
			
		||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
 | 
			
		||||
use Doctrine\ORM\QueryBuilder;
 | 
			
		||||
@@ -55,17 +54,20 @@ class ExportManager
 | 
			
		||||
     */
 | 
			
		||||
    private array $formatters = [];
 | 
			
		||||
 | 
			
		||||
    private readonly string|\Stringable|\Symfony\Component\Security\Core\User\UserInterface $user;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private readonly LoggerInterface $logger,
 | 
			
		||||
        private readonly AuthorizationCheckerInterface $authorizationChecker,
 | 
			
		||||
        private readonly AuthorizationHelperInterface $authorizationHelper,
 | 
			
		||||
        private readonly TokenStorageInterface $tokenStorage,
 | 
			
		||||
        TokenStorageInterface $tokenStorage,
 | 
			
		||||
        iterable $exports,
 | 
			
		||||
        iterable $aggregators,
 | 
			
		||||
        iterable $filters
 | 
			
		||||
        // iterable $formatters,
 | 
			
		||||
        // iterable $exportElementProvider
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->user = $tokenStorage->getToken()->getUser();
 | 
			
		||||
        $this->exports = iterator_to_array($exports);
 | 
			
		||||
        $this->aggregators = iterator_to_array($aggregators);
 | 
			
		||||
        $this->filters = iterator_to_array($filters);
 | 
			
		||||
@@ -89,24 +91,20 @@ class ExportManager
 | 
			
		||||
     *
 | 
			
		||||
     * @return FilterInterface[] a \Generator that contains filters. The key is the filter's alias
 | 
			
		||||
     */
 | 
			
		||||
    public function getFiltersApplyingOn(DirectExportInterface|ExportInterface $export, array $centers = null): array
 | 
			
		||||
    public function &getFiltersApplyingOn(DirectExportInterface|ExportInterface $export, array $centers = null): iterable
 | 
			
		||||
    {
 | 
			
		||||
        if ($export instanceof DirectExportInterface) {
 | 
			
		||||
            return [];
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $filters = [];
 | 
			
		||||
 | 
			
		||||
        foreach ($this->filters as $alias => $filter) {
 | 
			
		||||
            if (
 | 
			
		||||
                \in_array($filter->applyOn(), $export->supportsModifiers(), true)
 | 
			
		||||
                    && $this->isGrantedForElement($filter, $export, $centers)
 | 
			
		||||
            ) {
 | 
			
		||||
                $filters[$alias] = $filter;
 | 
			
		||||
                yield $alias => $filter;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $filters;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -114,26 +112,22 @@ class ExportManager
 | 
			
		||||
     *
 | 
			
		||||
     * @internal This class check the interface implemented by export, and, if ´ListInterface´ is used, return an empty array
 | 
			
		||||
     *
 | 
			
		||||
     * @return array<string, AggregatorInterface> an array that contains aggregators. The key is the filter's alias
 | 
			
		||||
     * @return iterable<string, AggregatorInterface>|null a \Generator that contains aggretagors. The key is the filter's alias
 | 
			
		||||
     */
 | 
			
		||||
    public function getAggregatorsApplyingOn(DirectExportInterface|ExportInterface $export, array $centers = null): array
 | 
			
		||||
    public function &getAggregatorsApplyingOn(DirectExportInterface|ExportInterface $export, array $centers = null): ?iterable
 | 
			
		||||
    {
 | 
			
		||||
        if ($export instanceof ListInterface || $export instanceof DirectExportInterface) {
 | 
			
		||||
            return [];
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $aggregators = [];
 | 
			
		||||
 | 
			
		||||
        foreach ($this->aggregators as $alias => $aggregator) {
 | 
			
		||||
            if (
 | 
			
		||||
                \in_array($aggregator->applyOn(), $export->supportsModifiers(), true)
 | 
			
		||||
                    && $this->isGrantedForElement($aggregator, $export, $centers)
 | 
			
		||||
            ) {
 | 
			
		||||
                $aggregators[$alias] = $aggregator;
 | 
			
		||||
                yield $alias => $aggregator;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $aggregators;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function addExportElementsProvider(ExportElementsProviderInterface $provider, string $prefix): void
 | 
			
		||||
@@ -353,17 +347,6 @@ class ExportManager
 | 
			
		||||
        return $this->filters[$alias];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getAllFilters(): array
 | 
			
		||||
    {
 | 
			
		||||
        $filters = [];
 | 
			
		||||
 | 
			
		||||
        foreach ($this->filters as $alias => $filter) {
 | 
			
		||||
            $filters[$alias] = $filter;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $filters;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * get all filters.
 | 
			
		||||
     *
 | 
			
		||||
@@ -469,7 +452,7 @@ class ExportManager
 | 
			
		||||
        if (null === $centers || [] === $centers) {
 | 
			
		||||
            // we want to try if at least one center is reachable
 | 
			
		||||
            return [] !== $this->authorizationHelper->getReachableCenters(
 | 
			
		||||
                $this->tokenStorage->getToken()->getUser(),
 | 
			
		||||
                $this->user,
 | 
			
		||||
                $role
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
@@ -501,17 +484,11 @@ class ExportManager
 | 
			
		||||
    {
 | 
			
		||||
        $r = [];
 | 
			
		||||
 | 
			
		||||
        $user = $this->tokenStorage->getToken()->getUser();
 | 
			
		||||
 | 
			
		||||
        if (!$user instanceof User) {
 | 
			
		||||
            return [];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        foreach ($centers as $center) {
 | 
			
		||||
            $r[] = [
 | 
			
		||||
                'center' => $center,
 | 
			
		||||
                'circles' => $this->authorizationHelper->getReachableScopes(
 | 
			
		||||
                    $user,
 | 
			
		||||
                    $this->user,
 | 
			
		||||
                    $element->requiredRole(),
 | 
			
		||||
                    $center
 | 
			
		||||
                ),
 | 
			
		||||
 
 | 
			
		||||
@@ -1,37 +0,0 @@
 | 
			
		||||
<?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\MainBundle\Export;
 | 
			
		||||
 | 
			
		||||
use Symfony\Contracts\Translation\TranslatorInterface;
 | 
			
		||||
 | 
			
		||||
final readonly class SortExportElement
 | 
			
		||||
{
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private TranslatorInterface $translator,
 | 
			
		||||
    ) {}
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param array<int|string, FilterInterface> $elements
 | 
			
		||||
     */
 | 
			
		||||
    public function sortFilters(array &$elements): void
 | 
			
		||||
    {
 | 
			
		||||
        uasort($elements, fn (FilterInterface $a, FilterInterface $b) => $this->translator->trans($a->getTitle()) <=> $this->translator->trans($b->getTitle()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param array<int|string, AggregatorInterface> $elements
 | 
			
		||||
     */
 | 
			
		||||
    public function sortAggregators(array &$elements): void
 | 
			
		||||
    {
 | 
			
		||||
        uasort($elements, fn (AggregatorInterface $a, AggregatorInterface $b) => $this->translator->trans($a->getTitle()) <=> $this->translator->trans($b->getTitle()));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -12,7 +12,6 @@ declare(strict_types=1);
 | 
			
		||||
namespace Chill\MainBundle\Form\Type\Export;
 | 
			
		||||
 | 
			
		||||
use Chill\MainBundle\Export\ExportManager;
 | 
			
		||||
use Chill\MainBundle\Export\SortExportElement;
 | 
			
		||||
use Chill\MainBundle\Validator\Constraints\Export\ExportElementConstraint;
 | 
			
		||||
use Symfony\Component\Form\AbstractType;
 | 
			
		||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
 | 
			
		||||
@@ -29,7 +28,15 @@ class ExportType extends AbstractType
 | 
			
		||||
 | 
			
		||||
    final public const PICK_FORMATTER_KEY = 'pick_formatter';
 | 
			
		||||
 | 
			
		||||
    public function __construct(private readonly ExportManager $exportManager, private readonly SortExportElement $sortExportElement) {}
 | 
			
		||||
    /**
 | 
			
		||||
     * @var ExportManager
 | 
			
		||||
     */
 | 
			
		||||
    protected $exportManager;
 | 
			
		||||
 | 
			
		||||
    public function __construct(ExportManager $exportManager)
 | 
			
		||||
    {
 | 
			
		||||
        $this->exportManager = $exportManager;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder, array $options)
 | 
			
		||||
    {
 | 
			
		||||
@@ -51,12 +58,12 @@ class ExportType extends AbstractType
 | 
			
		||||
        if ($export instanceof \Chill\MainBundle\Export\ExportInterface) {
 | 
			
		||||
            // add filters
 | 
			
		||||
            $filters = $this->exportManager->getFiltersApplyingOn($export, $options['picked_centers']);
 | 
			
		||||
            $this->sortExportElement->sortFilters($filters);
 | 
			
		||||
            $filterBuilder = $builder->create(self::FILTER_KEY, FormType::class, ['compound' => true]);
 | 
			
		||||
 | 
			
		||||
            foreach ($filters as $alias => $filter) {
 | 
			
		||||
                $filterBuilder->add($alias, FilterType::class, [
 | 
			
		||||
                    'filter' => $filter,
 | 
			
		||||
                    'filter_alias' => $alias,
 | 
			
		||||
                    'export_manager' => $this->exportManager,
 | 
			
		||||
                    'label' => $filter->getTitle(),
 | 
			
		||||
                    'constraints' => [
 | 
			
		||||
                        new ExportElementConstraint(['element' => $filter]),
 | 
			
		||||
@@ -69,7 +76,6 @@ class ExportType extends AbstractType
 | 
			
		||||
            // add aggregators
 | 
			
		||||
            $aggregators = $this->exportManager
 | 
			
		||||
                ->getAggregatorsApplyingOn($export, $options['picked_centers']);
 | 
			
		||||
            $this->sortExportElement->sortAggregators($aggregators);
 | 
			
		||||
            $aggregatorBuilder = $builder->create(
 | 
			
		||||
                self::AGGREGATOR_KEY,
 | 
			
		||||
                FormType::class,
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,6 @@ declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Chill\MainBundle\Form\Type\Export;
 | 
			
		||||
 | 
			
		||||
use Chill\MainBundle\Export\FilterInterface;
 | 
			
		||||
use Symfony\Component\Form\AbstractType;
 | 
			
		||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
 | 
			
		||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
 | 
			
		||||
@@ -26,7 +25,8 @@ class FilterType extends AbstractType
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder, array $options)
 | 
			
		||||
    {
 | 
			
		||||
        $filter = $options['filter'];
 | 
			
		||||
        $exportManager = $options['export_manager'];
 | 
			
		||||
        $filter = $exportManager->getFilter($options['filter_alias']);
 | 
			
		||||
 | 
			
		||||
        $builder
 | 
			
		||||
            ->add(self::ENABLED_FIELD, CheckboxType::class, [
 | 
			
		||||
@@ -46,9 +46,8 @@ class FilterType extends AbstractType
 | 
			
		||||
 | 
			
		||||
    public function configureOptions(OptionsResolver $resolver)
 | 
			
		||||
    {
 | 
			
		||||
        $resolver
 | 
			
		||||
            ->setRequired('filter')
 | 
			
		||||
            ->setAllowedTypes('filter', [FilterInterface::class])
 | 
			
		||||
        $resolver->setRequired('filter_alias')
 | 
			
		||||
            ->setRequired('export_manager')
 | 
			
		||||
            ->setDefault('compound', true)
 | 
			
		||||
            ->setDefault('error_bubbling', false);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -34,7 +34,6 @@ class PickRollingDateType extends AbstractType
 | 
			
		||||
                ),
 | 
			
		||||
                'multiple' => false,
 | 
			
		||||
                'expanded' => false,
 | 
			
		||||
                'required' => $options['required'],
 | 
			
		||||
                'label' => 'rolling_date.roll_movement',
 | 
			
		||||
            ])
 | 
			
		||||
            ->add('fixedDate', ChillDateType::class, [
 | 
			
		||||
@@ -58,10 +57,7 @@ class PickRollingDateType extends AbstractType
 | 
			
		||||
            'constraints' => [
 | 
			
		||||
                new Callback($this->validate(...)),
 | 
			
		||||
            ],
 | 
			
		||||
            'required' => true,
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
        $resolver->setAllowedTypes('required', 'bool');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function validate($data, ExecutionContextInterface $context, $payload): void
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
<template>
 | 
			
		||||
   <span v-if="noResults" class="chill-no-data-statement">{{ $t('no_dashboard') }}</span>
 | 
			
		||||
   <div v-else id="dashboards" class="row g-3" data-masonry='{"percentPosition": true }'>
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      <div class="mbloc col col-sm-6 col-lg-4">
 | 
			
		||||
         <div class="custom1">
 | 
			
		||||
            <ul class="list-unstyled">
 | 
			
		||||
@@ -38,39 +38,33 @@
 | 
			
		||||
            </ul>
 | 
			
		||||
         </div>
 | 
			
		||||
      </div>
 | 
			
		||||
      
 | 
			
		||||
      <!--
 | 
			
		||||
      <div class="mbloc col col-sm-6 col-lg-4">
 | 
			
		||||
         <div class="custom2">
 | 
			
		||||
            Mon dashboard personnalisé
 | 
			
		||||
         </div>
 | 
			
		||||
      </div>
 | 
			
		||||
      <div class="mbloc col col-sm-6 col-lg-4">
 | 
			
		||||
         <div class="custom3">
 | 
			
		||||
            Mon dashboard personnalisé
 | 
			
		||||
         </div>
 | 
			
		||||
      </div>
 | 
			
		||||
      <div class="mbloc col col-sm-6 col-lg-4">
 | 
			
		||||
         <div class="custom4">
 | 
			
		||||
            Mon dashboard personnalisé
 | 
			
		||||
         </div>
 | 
			
		||||
      </div>
 | 
			
		||||
      -->
 | 
			
		||||
       <div class="mbloc col col-sm-6 col-lg-4">
 | 
			
		||||
           <div class="custom2">
 | 
			
		||||
               <MyWidget/>
 | 
			
		||||
           </div>
 | 
			
		||||
       </div>
 | 
			
		||||
 | 
			
		||||
   </div>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
 | 
			
		||||
import MyWidget from './MyWidget.vue'
 | 
			
		||||
import { mapGetters } from "vuex";
 | 
			
		||||
import Masonry from 'masonry-layout/masonry';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
   name: "MyCustoms",
 | 
			
		||||
    components:{
 | 
			
		||||
       MyWidget
 | 
			
		||||
    },
 | 
			
		||||
   data() {
 | 
			
		||||
      return {
 | 
			
		||||
         counterClass: {
 | 
			
		||||
            counter: true   //hack to pass class 'counter' in i18n-t
 | 
			
		||||
         }
 | 
			
		||||
         },
 | 
			
		||||
      }
 | 
			
		||||
   },
 | 
			
		||||
   computed: {
 | 
			
		||||
@@ -82,8 +76,8 @@ export default {
 | 
			
		||||
   mounted() {
 | 
			
		||||
      const elem = document.querySelector('#dashboards');
 | 
			
		||||
      const masonry = new Masonry(elem, {});
 | 
			
		||||
   }
 | 
			
		||||
}
 | 
			
		||||
   },
 | 
			
		||||
};
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<style lang="scss" scoped>
 | 
			
		||||
@@ -98,4 +92,4 @@ span.counter {
 | 
			
		||||
      background-color: unset;
 | 
			
		||||
   }
 | 
			
		||||
}
 | 
			
		||||
</style>
 | 
			
		||||
</style>
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,91 @@
 | 
			
		||||
<template>
 | 
			
		||||
    <div class="container">
 | 
			
		||||
        <Bar v-if="loaded_bar" :data="chartData" :options="chartOptions"/>
 | 
			
		||||
        <span v-if="loaded_number">{{ number }}</span>
 | 
			
		||||
    </div>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script lang="ts">
 | 
			
		||||
import {
 | 
			
		||||
    Chart as ChartJS,
 | 
			
		||||
    Title,
 | 
			
		||||
    Tooltip,
 | 
			
		||||
    Legend,
 | 
			
		||||
    BarElement,
 | 
			
		||||
    CategoryScale,
 | 
			
		||||
    LinearScale
 | 
			
		||||
} from 'chart.js'
 | 
			
		||||
import {Bar} from 'vue-chartjs'
 | 
			
		||||
import {defineComponent} from 'vue'
 | 
			
		||||
import {makeFetch} from "../../lib/api/apiMethods";
 | 
			
		||||
 | 
			
		||||
ChartJS.register(CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend)
 | 
			
		||||
 | 
			
		||||
export default defineComponent({
 | 
			
		||||
    name: 'MyWidget',
 | 
			
		||||
    components: {
 | 
			
		||||
        Bar,
 | 
			
		||||
    },
 | 
			
		||||
    data() {
 | 
			
		||||
        return {
 | 
			
		||||
            loaded_bar: false,
 | 
			
		||||
            loaded_number: false,
 | 
			
		||||
            chartData: null,
 | 
			
		||||
            chartOptions: null,
 | 
			
		||||
            number: "",
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    async mounted() {
 | 
			
		||||
        this.loaded_bar = false;
 | 
			
		||||
        this.loaded_number = false;
 | 
			
		||||
        const url = '/fr/dashboard/raw_data';
 | 
			
		||||
        try {
 | 
			
		||||
            const response: { data: any, options: any, type: any } = await makeFetch("GET", url);
 | 
			
		||||
            this.chartData = response.data;
 | 
			
		||||
            this.chartOptions = response.options;
 | 
			
		||||
            if (response.type == 'bar') {
 | 
			
		||||
                this.loaded_bar = true;
 | 
			
		||||
            } else {
 | 
			
		||||
                this.loaded_number = true
 | 
			
		||||
                this.number = response.data.datasets[0].data[0] + " "+ response.data.labels[0];
 | 
			
		||||
            }
 | 
			
		||||
        } catch (error) {
 | 
			
		||||
            console.log(error);
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    /*methods: {
 | 
			
		||||
        async makeNumberWidget() {
 | 
			
		||||
            let body = {
 | 
			
		||||
                config: {
 | 
			
		||||
                    alias: 'number'
 | 
			
		||||
                },
 | 
			
		||||
                context: {
 | 
			
		||||
                    what: 'notification_unread',
 | 
			
		||||
                    user: 19 //Ne rien mettre ou via les refs
 | 
			
		||||
                }
 | 
			
		||||
            };
 | 
			
		||||
            try {
 | 
			
		||||
                const response: {
 | 
			
		||||
                    data: any,
 | 
			
		||||
                    options: any,
 | 
			
		||||
                    type: any
 | 
			
		||||
                } = await makeFetch('POST', '/{_locale}//{_locale}/dashboard/widget/number', body)
 | 
			
		||||
                this.chartData = response.data;
 | 
			
		||||
                this.chartOptions = response.options;
 | 
			
		||||
                this.loaded_number = true;
 | 
			
		||||
                this.number = response.data.datasets[0].data[0] + response.data.labels[0];
 | 
			
		||||
            } catch (error) {
 | 
			
		||||
                console.log(error)
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        },
 | 
			
		||||
    }*/
 | 
			
		||||
})
 | 
			
		||||
</script>
 | 
			
		||||
<style lang="scss" scoped>
 | 
			
		||||
    span {
 | 
			
		||||
        font-size: x-large;
 | 
			
		||||
        color: #0a53be;
 | 
			
		||||
    }
 | 
			
		||||
</style>
 | 
			
		||||
@@ -0,0 +1,28 @@
 | 
			
		||||
export const data = {
 | 
			
		||||
    labels: [
 | 
			
		||||
        'January',
 | 
			
		||||
        'February',
 | 
			
		||||
        'March',
 | 
			
		||||
        'April',
 | 
			
		||||
        'May',
 | 
			
		||||
        'June',
 | 
			
		||||
        'July',
 | 
			
		||||
        'August',
 | 
			
		||||
        'September',
 | 
			
		||||
        'October',
 | 
			
		||||
        'November',
 | 
			
		||||
        'December'
 | 
			
		||||
    ],
 | 
			
		||||
    datasets: [
 | 
			
		||||
        {
 | 
			
		||||
            label: 'Data One',
 | 
			
		||||
            backgroundColor: '#f87979',
 | 
			
		||||
            data: [40, 20, 12, 39, 10, 40, 39, 80, 40, 20, 12, 11]
 | 
			
		||||
        }
 | 
			
		||||
    ]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export const options = {
 | 
			
		||||
    responsive: true,
 | 
			
		||||
    maintainAspectRatio: false
 | 
			
		||||
}
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
{#
 | 
			
		||||
 * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
 | 
			
		||||
 * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, 
 | 
			
		||||
 <info@champs-libres.coop> / <http://www.champs-libres.coop>
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software: you can redistribute it and/or modify
 | 
			
		||||
@@ -36,84 +36,84 @@
 | 
			
		||||
 | 
			
		||||
{% block content  %}
 | 
			
		||||
    <div class="col-md-10">
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
        {{ include('@ChillMain/Export/_breadcrumb.html.twig') }}
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
        <h1>{{ export.title|trans }}</h1>
 | 
			
		||||
 | 
			
		||||
        
 | 
			
		||||
        <p>{{ export.description|trans }}</p>
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
        {{ form_start(form) }}
 | 
			
		||||
 | 
			
		||||
        
 | 
			
		||||
        {% if form.children.export.children.filters is defined %}
 | 
			
		||||
            {% if form.children.export.children.filters is not empty%}
 | 
			
		||||
 | 
			
		||||
            
 | 
			
		||||
            <section class="filter mb-4">
 | 
			
		||||
                <h2>{{ 'Filters'| trans }}</h2>
 | 
			
		||||
 | 
			
		||||
                
 | 
			
		||||
                {{ form_errors(form.children.export.children.filters) }}
 | 
			
		||||
 | 
			
		||||
                
 | 
			
		||||
                <div class="flex-table">
 | 
			
		||||
                {% for filter_form in form.children.export.children.filters %}
 | 
			
		||||
                    <div class="item-bloc no-altern">
 | 
			
		||||
 | 
			
		||||
                        
 | 
			
		||||
                        {{ form_widget(filter_form.enabled, {
 | 
			
		||||
                            'label': filter_form.vars.label,
 | 
			
		||||
                            'label_attr': { 'class': 'h6' },
 | 
			
		||||
                            'attr': { 'data-display-target': filter_form.vars.id }
 | 
			
		||||
                        }) }}
 | 
			
		||||
 | 
			
		||||
                        
 | 
			
		||||
                        <div data-display-show-hide="{{ filter_form.vars.id }}">
 | 
			
		||||
                            {{ form_widget(filter_form.form) }}
 | 
			
		||||
                            {{ form_errors(filter_form) }}
 | 
			
		||||
                        </div>
 | 
			
		||||
 | 
			
		||||
                        
 | 
			
		||||
                    </div>
 | 
			
		||||
                {% endfor %}
 | 
			
		||||
                </div>
 | 
			
		||||
            </section>
 | 
			
		||||
 | 
			
		||||
            
 | 
			
		||||
            {% else %}
 | 
			
		||||
                {# render the children, to mark the widget as 'rendered' #}
 | 
			
		||||
                {{ form_widget(form.children.export.children.filters) }}
 | 
			
		||||
            {% endif %}
 | 
			
		||||
        {% endif %}
 | 
			
		||||
 | 
			
		||||
        
 | 
			
		||||
        {% if form.children.export.children.aggregators is defined %}
 | 
			
		||||
            {% if form.children.export.children.aggregators is not empty %}
 | 
			
		||||
 | 
			
		||||
            
 | 
			
		||||
            <section class="aggregator mb-4">
 | 
			
		||||
                <h2>{{ 'Aggregators'| trans }}</h2>
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
                <div class="flex-table">
 | 
			
		||||
                {% for aggregator_form in form.children.export.children.aggregators %}
 | 
			
		||||
                    <div class="item-bloc no-altern">
 | 
			
		||||
 | 
			
		||||
                        
 | 
			
		||||
                        {{ form_widget(aggregator_form.enabled, {
 | 
			
		||||
                            'label': aggregator_form.vars.label,
 | 
			
		||||
                            'label_attr': { 'class': 'h6' },
 | 
			
		||||
                            'attr': { 'data-display-target': aggregator_form.vars.id }
 | 
			
		||||
                        }) }}
 | 
			
		||||
 | 
			
		||||
                        
 | 
			
		||||
                        <div data-display-show-hide="{{ aggregator_form.vars.id }}">
 | 
			
		||||
                            {{ form_widget(aggregator_form.form) }}
 | 
			
		||||
                            {{ form_errors(aggregator_form) }}
 | 
			
		||||
                        </div>
 | 
			
		||||
 | 
			
		||||
                        
 | 
			
		||||
                    </div>
 | 
			
		||||
                {% endfor %}
 | 
			
		||||
                </div>
 | 
			
		||||
            </section>
 | 
			
		||||
 | 
			
		||||
            
 | 
			
		||||
            {% else %}
 | 
			
		||||
                {# render the children, to mark the widget as 'rendered' #}
 | 
			
		||||
                {{ form_widget(form.children.export.children.aggregators) }}
 | 
			
		||||
            {% endif %}
 | 
			
		||||
        {% endif %}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        
 | 
			
		||||
        
 | 
			
		||||
        {% if form.children.export.children.export.children|length > 0 %}
 | 
			
		||||
 | 
			
		||||
        
 | 
			
		||||
            <style>
 | 
			
		||||
                div#export_export_fields { column-count: 2; }
 | 
			
		||||
            </style>
 | 
			
		||||
@@ -123,12 +123,12 @@
 | 
			
		||||
                </h2>
 | 
			
		||||
                {{ form_widget(form.children.export.children.export) }}
 | 
			
		||||
            </section>
 | 
			
		||||
 | 
			
		||||
        
 | 
			
		||||
        {% else %}
 | 
			
		||||
            {# render the children, to mark the widget as 'rendered' #}
 | 
			
		||||
            {{ form_widget(form.children.export.children.export) }}
 | 
			
		||||
        {% endif %}
 | 
			
		||||
 | 
			
		||||
        
 | 
			
		||||
        {% if form.children.export.children.pick_formatter is defined %}
 | 
			
		||||
            <section class="formatter mb-4">
 | 
			
		||||
                <h2>
 | 
			
		||||
@@ -140,7 +140,7 @@
 | 
			
		||||
                {{ form_row(form.children.export.children.pick_formatter.children.alias, { 'label' : 'Formatter' }) }}
 | 
			
		||||
            </section>
 | 
			
		||||
        {% endif %}
 | 
			
		||||
 | 
			
		||||
        
 | 
			
		||||
        <p>{{ form_widget(form.submit, { 'attr' : { 'class' : 'btn btn-create' }, 'label' : 'Go to formatter options' } ) }}</p>
 | 
			
		||||
        {{ form_end(form) }}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -11,15 +11,11 @@ declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Chill\MainBundle\Test\Export;
 | 
			
		||||
 | 
			
		||||
use Chill\MainBundle\Export\DirectExportInterface;
 | 
			
		||||
use Chill\MainBundle\Export\ExportInterface;
 | 
			
		||||
use Chill\MainBundle\Test\PrepareClientTrait;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
use Doctrine\ORM\NativeQuery;
 | 
			
		||||
use Doctrine\ORM\QueryBuilder;
 | 
			
		||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
 | 
			
		||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
 | 
			
		||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This class provide a set of tests for exports.
 | 
			
		||||
@@ -98,7 +94,7 @@ abstract class AbstractExportTest extends WebTestCase
 | 
			
		||||
    /**
 | 
			
		||||
     * Create an instance of the report to test.
 | 
			
		||||
     *
 | 
			
		||||
     * @return ExportInterface|DirectExportInterface|iterable<ExportInterface>|iterable<DirectExportInterface> an instance of the export to test
 | 
			
		||||
     * @return \Chill\MainBundle\Export\ExportInterface an instance of the export to test
 | 
			
		||||
     */
 | 
			
		||||
    abstract public function getExport();
 | 
			
		||||
 | 
			
		||||
@@ -120,40 +116,19 @@ abstract class AbstractExportTest extends WebTestCase
 | 
			
		||||
     */
 | 
			
		||||
    abstract public function getModifiersCombination();
 | 
			
		||||
 | 
			
		||||
    protected function getParameters(bool $filterStatsByCenter): ParameterBagInterface
 | 
			
		||||
    {
 | 
			
		||||
        return new ParameterBag(['chill_main' => ['acl' => ['filter_stats_by_center' => $filterStatsByCenter]]]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * wrap the results of @see{self::getExports()}, which may be an iterable or an export into an iterble.
 | 
			
		||||
     */
 | 
			
		||||
    private function getExports(): iterable
 | 
			
		||||
    {
 | 
			
		||||
        $exports = $this->getExport();
 | 
			
		||||
 | 
			
		||||
        if (is_iterable($exports)) {
 | 
			
		||||
            return $exports;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return [$exports];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Test the formatters type are string.
 | 
			
		||||
     */
 | 
			
		||||
    public function testGetAllowedFormattersType()
 | 
			
		||||
    {
 | 
			
		||||
        foreach ($this->getExports() as $export) {
 | 
			
		||||
            $formattersTypes = $export->getAllowedFormattersTypes();
 | 
			
		||||
        $formattersTypes = $this->getExport()->getAllowedFormattersTypes();
 | 
			
		||||
 | 
			
		||||
            $this->assertContainsOnly(
 | 
			
		||||
                'string',
 | 
			
		||||
                $formattersTypes,
 | 
			
		||||
                true,
 | 
			
		||||
                'Test that the method `getAllowedFormattersTypes` returns an array of string'
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
        $this->assertContainsOnly(
 | 
			
		||||
            'string',
 | 
			
		||||
            $formattersTypes,
 | 
			
		||||
            true,
 | 
			
		||||
            'Test that the method `getAllowedFormattersTypes` returns an array of string'
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -161,17 +136,17 @@ abstract class AbstractExportTest extends WebTestCase
 | 
			
		||||
     */
 | 
			
		||||
    public function testGetDescription()
 | 
			
		||||
    {
 | 
			
		||||
        foreach ($this->getExports() as $export) {
 | 
			
		||||
            $this->assertIsString(
 | 
			
		||||
                $export->getDescription(),
 | 
			
		||||
                'Assert that the `getDescription` method return a string'
 | 
			
		||||
            );
 | 
			
		||||
            $this->assertNotEmpty(
 | 
			
		||||
                $export->getDescription(),
 | 
			
		||||
                'Assert that the `getDescription` method does not return an empty '
 | 
			
		||||
                .'string.'
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
        $export = $this->getExport();
 | 
			
		||||
 | 
			
		||||
        $this->assertIsString(
 | 
			
		||||
            $export->getDescription(),
 | 
			
		||||
            'Assert that the `getDescription` method return a string'
 | 
			
		||||
        );
 | 
			
		||||
        $this->assertNotEmpty(
 | 
			
		||||
            $export->getDescription(),
 | 
			
		||||
            'Assert that the `getDescription` method does not return an empty '
 | 
			
		||||
            .'string.'
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -181,21 +156,19 @@ abstract class AbstractExportTest extends WebTestCase
 | 
			
		||||
     */
 | 
			
		||||
    public function testGetQueryKeys(array $data)
 | 
			
		||||
    {
 | 
			
		||||
        foreach ($this->getExports() as $export) {
 | 
			
		||||
            $queryKeys = $export->getQueryKeys($data);
 | 
			
		||||
        $queryKeys = $this->getExport()->getQueryKeys($data);
 | 
			
		||||
 | 
			
		||||
            $this->assertContainsOnly(
 | 
			
		||||
                'string',
 | 
			
		||||
                $queryKeys,
 | 
			
		||||
                true,
 | 
			
		||||
                'test that the query keys returned by `getQueryKeys` are only strings'
 | 
			
		||||
            );
 | 
			
		||||
            $this->assertGreaterThanOrEqual(
 | 
			
		||||
                1,
 | 
			
		||||
                \count($queryKeys),
 | 
			
		||||
                'test that there are at least one query key returned'
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
        $this->assertContainsOnly(
 | 
			
		||||
            'string',
 | 
			
		||||
            $queryKeys,
 | 
			
		||||
            true,
 | 
			
		||||
            'test that the query keys returned by `getQueryKeys` are only strings'
 | 
			
		||||
        );
 | 
			
		||||
        $this->assertGreaterThanOrEqual(
 | 
			
		||||
            1,
 | 
			
		||||
            \count($queryKeys),
 | 
			
		||||
            'test that there are at least one query key returned'
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -214,70 +187,61 @@ abstract class AbstractExportTest extends WebTestCase
 | 
			
		||||
     */
 | 
			
		||||
    public function testGetResultsAndLabels($modifiers, $acl, array $data)
 | 
			
		||||
    {
 | 
			
		||||
        foreach ($this->getExports() as $export) {
 | 
			
		||||
            // it is more convenient to  group the `getResult` and `getLabels` test
 | 
			
		||||
            // due to the fact that testing both methods use the same tools.
 | 
			
		||||
        // it is more convenient to  group the `getResult` and `getLabels` test
 | 
			
		||||
        // due to the fact that testing both methods use the same tools.
 | 
			
		||||
 | 
			
		||||
            $queryKeys = $export->getQueryKeys($data);
 | 
			
		||||
            $query = $export->initiateQuery($modifiers, $acl, $data);
 | 
			
		||||
        $queryKeys = $this->getExport()->getQueryKeys($data);
 | 
			
		||||
        $query = $this->getExport()->initiateQuery($modifiers, $acl, $data);
 | 
			
		||||
 | 
			
		||||
            // limit the result for the query for performance reason (only for QueryBuilder,
 | 
			
		||||
            // not possible in NativeQuery)
 | 
			
		||||
            if ($query instanceof QueryBuilder) {
 | 
			
		||||
                $query->setMaxResults(1);
 | 
			
		||||
            }
 | 
			
		||||
        // limit the result for the query for performance reason (only for QueryBuilder,
 | 
			
		||||
        // not possible in NativeQuery)
 | 
			
		||||
        if ($query instanceof QueryBuilder) {
 | 
			
		||||
            $query->setMaxResults(1);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
            $results = $export->getResult($query, $data);
 | 
			
		||||
        $results = $this->getExport()->getResult($query, $data);
 | 
			
		||||
 | 
			
		||||
            $this->assertIsArray(
 | 
			
		||||
                $results,
 | 
			
		||||
                'assert that the returned result is an array'
 | 
			
		||||
        $this->assertIsArray(
 | 
			
		||||
            $results,
 | 
			
		||||
            'assert that the returned result is an array'
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        if (0 === \count($results)) {
 | 
			
		||||
            $this->markTestIncomplete('The result is empty. We cannot process tests '
 | 
			
		||||
                .'on results');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // testing the result
 | 
			
		||||
        $result = $results[0];
 | 
			
		||||
 | 
			
		||||
        $this->assertTrue(
 | 
			
		||||
            is_iterable($result),
 | 
			
		||||
            'test that each row in the result is traversable or an array'
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        foreach ($result as $key => $value) {
 | 
			
		||||
            $this->assertContains(
 | 
			
		||||
                $key,
 | 
			
		||||
                $queryKeys,
 | 
			
		||||
                'test that each key is present in `getQueryKeys`'
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
            if (0 === \count($results)) {
 | 
			
		||||
                $this->markTestIncomplete('The result is empty. We cannot process tests '
 | 
			
		||||
                    .'on results');
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // testing the result
 | 
			
		||||
            $result = $results[0];
 | 
			
		||||
            $closure = $this->getExport()->getLabels($key, [$value], $data);
 | 
			
		||||
 | 
			
		||||
            $this->assertTrue(
 | 
			
		||||
                is_iterable($result),
 | 
			
		||||
                'test that each row in the result is traversable or an array'
 | 
			
		||||
                \is_callable($closure, false),
 | 
			
		||||
                'test that the `getLabels` for key is a callable'
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
            $i = 0;
 | 
			
		||||
            foreach ($result as $key => $value) {
 | 
			
		||||
                $this->assertContains(
 | 
			
		||||
                    $key,
 | 
			
		||||
                    $queryKeys,
 | 
			
		||||
                    'test that each key is present in `getQueryKeys`'
 | 
			
		||||
                );
 | 
			
		||||
 | 
			
		||||
                $closure = $export->getLabels($key, [$value], $data);
 | 
			
		||||
 | 
			
		||||
                $this->assertTrue(
 | 
			
		||||
                    \is_callable($closure, false),
 | 
			
		||||
                    'test that the `getLabels` for key is a callable'
 | 
			
		||||
                );
 | 
			
		||||
 | 
			
		||||
                $this->assertTrue(
 | 
			
		||||
                    // conditions
 | 
			
		||||
                    \is_string((string) \call_user_func($closure, '_header'))
 | 
			
		||||
                    && !empty(\call_user_func($closure, '_header'))
 | 
			
		||||
                    && '_header' !== \call_user_func($closure, '_header'),
 | 
			
		||||
                    // message
 | 
			
		||||
                    sprintf('Test that the callable return by `getLabels` for key %s '
 | 
			
		||||
                        .'can provide an header', $key)
 | 
			
		||||
                );
 | 
			
		||||
                ++$i;
 | 
			
		||||
 | 
			
		||||
                if ($i > 15) {
 | 
			
		||||
                    // do not iterate on each result
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            $this->assertTrue(
 | 
			
		||||
                // conditions
 | 
			
		||||
                \is_string((string) \call_user_func($closure, '_header'))
 | 
			
		||||
                && !empty(\call_user_func($closure, '_header'))
 | 
			
		||||
                && '_header' !== \call_user_func($closure, '_header'),
 | 
			
		||||
                // message
 | 
			
		||||
                sprintf('Test that the callable return by `getLabels` for key %s '
 | 
			
		||||
                .'can provide an header', $key)
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -286,14 +250,14 @@ abstract class AbstractExportTest extends WebTestCase
 | 
			
		||||
     */
 | 
			
		||||
    public function testGetType()
 | 
			
		||||
    {
 | 
			
		||||
        foreach ($this->getExports() as $export) {
 | 
			
		||||
            $this->assertIsString(
 | 
			
		||||
                $export->getType(),
 | 
			
		||||
                'Assert that the `getType` method return a string'
 | 
			
		||||
            );
 | 
			
		||||
            $this->assertNotEmpty($export->getType(), 'Assert that the `getType` method'
 | 
			
		||||
                .' does not return an empty string.');
 | 
			
		||||
        }
 | 
			
		||||
        $export = $this->getExport();
 | 
			
		||||
 | 
			
		||||
        $this->assertIsString(
 | 
			
		||||
            $export->getType(),
 | 
			
		||||
            'Assert that the `getType` method return a string'
 | 
			
		||||
        );
 | 
			
		||||
        $this->assertNotEmpty($export->getType(), 'Assert that the `getType` method'
 | 
			
		||||
            .' does not return an empty string.');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -308,36 +272,34 @@ abstract class AbstractExportTest extends WebTestCase
 | 
			
		||||
     */
 | 
			
		||||
    public function testInitiateQuery(mixed $modifiers, mixed $acl, mixed $data)
 | 
			
		||||
    {
 | 
			
		||||
        foreach ($this->getExports() as $export) {
 | 
			
		||||
            $query = $export->initiateQuery($modifiers, $acl, $data);
 | 
			
		||||
        $query = $this->getExport()->initiateQuery($modifiers, $acl, $data);
 | 
			
		||||
 | 
			
		||||
            $this->assertTrue(
 | 
			
		||||
                $query instanceof QueryBuilder || $query instanceof NativeQuery,
 | 
			
		||||
                sprintf(
 | 
			
		||||
                    'Assert that the returned query is an instance of %s or %s',
 | 
			
		||||
                    QueryBuilder::class,
 | 
			
		||||
                    NativeQuery::class
 | 
			
		||||
                )
 | 
			
		||||
        $this->assertTrue(
 | 
			
		||||
            $query instanceof QueryBuilder || $query instanceof NativeQuery,
 | 
			
		||||
            sprintf(
 | 
			
		||||
                'Assert that the returned query is an instance of %s or %s',
 | 
			
		||||
                QueryBuilder::class,
 | 
			
		||||
                Query::class
 | 
			
		||||
            )
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        if ($query instanceof QueryBuilder) {
 | 
			
		||||
            $this->assertGreaterThanOrEqual(
 | 
			
		||||
                1,
 | 
			
		||||
                \count($query->getDQLPart('select')),
 | 
			
		||||
                "assert there is at least one 'select' part"
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
            if ($query instanceof QueryBuilder) {
 | 
			
		||||
                $this->assertGreaterThanOrEqual(
 | 
			
		||||
                    1,
 | 
			
		||||
                    \count($query->getDQLPart('select')),
 | 
			
		||||
                    "assert there is at least one 'select' part"
 | 
			
		||||
                );
 | 
			
		||||
 | 
			
		||||
                $this->assertGreaterThanOrEqual(
 | 
			
		||||
                    1,
 | 
			
		||||
                    \count($query->getDQLPart('from')),
 | 
			
		||||
                    "assert there is at least one 'from' part"
 | 
			
		||||
                );
 | 
			
		||||
            } elseif ($query instanceof NativeQuery) {
 | 
			
		||||
                $this->assertNotEmpty(
 | 
			
		||||
                    $query->getSQL(),
 | 
			
		||||
                    'check that the SQL query is not empty'
 | 
			
		||||
                );
 | 
			
		||||
            }
 | 
			
		||||
            $this->assertGreaterThanOrEqual(
 | 
			
		||||
                1,
 | 
			
		||||
                \count($query->getDQLPart('from')),
 | 
			
		||||
                "assert there is at least one 'from' part"
 | 
			
		||||
            );
 | 
			
		||||
        } elseif ($query instanceof NativeQuery) {
 | 
			
		||||
            $this->assertNotEmpty(
 | 
			
		||||
                $query->getSQL(),
 | 
			
		||||
                'check that the SQL query is not empty'
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -346,11 +308,9 @@ abstract class AbstractExportTest extends WebTestCase
 | 
			
		||||
     */
 | 
			
		||||
    public function testRequiredRole()
 | 
			
		||||
    {
 | 
			
		||||
        foreach ($this->getExports() as $export) {
 | 
			
		||||
            $role = $export->requiredRole();
 | 
			
		||||
        $role = $this->getExport()->requiredRole();
 | 
			
		||||
 | 
			
		||||
            self::assertIsString($role);
 | 
			
		||||
        }
 | 
			
		||||
        self::assertIsString($role);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -363,23 +323,22 @@ abstract class AbstractExportTest extends WebTestCase
 | 
			
		||||
     */
 | 
			
		||||
    public function testSupportsModifier(mixed $modifiers, mixed $acl, mixed $data)
 | 
			
		||||
    {
 | 
			
		||||
        foreach ($this->getExports() as $export) {
 | 
			
		||||
            $query = $export->initiateQuery($modifiers, $acl, $data);
 | 
			
		||||
        $export = $this->getExport();
 | 
			
		||||
        $query = $export->initiateQuery($modifiers, $acl, $data);
 | 
			
		||||
 | 
			
		||||
            if ($query instanceof QueryBuilder) {
 | 
			
		||||
                $this->assertContainsOnly(
 | 
			
		||||
                    'string',
 | 
			
		||||
                    $export->supportsModifiers(),
 | 
			
		||||
                    true,
 | 
			
		||||
                    'Test that the `supportsModifiers` method returns only strings'
 | 
			
		||||
                );
 | 
			
		||||
            } elseif ($query instanceof NativeQuery) {
 | 
			
		||||
                $this->assertTrue(
 | 
			
		||||
                    null === $export->supportsModifiers()
 | 
			
		||||
                    || 0 === \count($export->supportsModifiers()),
 | 
			
		||||
                    'Test that the `supportsModifier` methods returns null or an empty array'
 | 
			
		||||
                );
 | 
			
		||||
            }
 | 
			
		||||
        if ($query instanceof QueryBuilder) {
 | 
			
		||||
            $this->assertContainsOnly(
 | 
			
		||||
                'string',
 | 
			
		||||
                $export->supportsModifiers(),
 | 
			
		||||
                true,
 | 
			
		||||
                'Test that the `supportsModifiers` method returns only strings'
 | 
			
		||||
            );
 | 
			
		||||
        } elseif ($query instanceof NativeQuery) {
 | 
			
		||||
            $this->assertTrue(
 | 
			
		||||
                null === $export->supportsModifiers()
 | 
			
		||||
                || 0 === \count($export->supportsModifiers()),
 | 
			
		||||
                'Test that the `supportsModifier` methods returns null or an empty array'
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,193 +0,0 @@
 | 
			
		||||
<?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\MainBundle\Tests\Export;
 | 
			
		||||
 | 
			
		||||
use Chill\MainBundle\Export\AggregatorInterface;
 | 
			
		||||
use Chill\MainBundle\Export\ExportManager;
 | 
			
		||||
use Chill\MainBundle\Export\FilterInterface;
 | 
			
		||||
use Chill\MainBundle\Export\SortExportElement;
 | 
			
		||||
use Doctrine\ORM\QueryBuilder;
 | 
			
		||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
use Symfony\Contracts\Translation\TranslatorInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @internal
 | 
			
		||||
 *
 | 
			
		||||
 * @coversNothing
 | 
			
		||||
 */
 | 
			
		||||
class SortExportElementTest extends KernelTestCase
 | 
			
		||||
{
 | 
			
		||||
    private SortExportElement $sortExportElement;
 | 
			
		||||
 | 
			
		||||
    public function setUp(): void
 | 
			
		||||
    {
 | 
			
		||||
        parent::setUpBeforeClass();
 | 
			
		||||
        $this->sortExportElement = new SortExportElement($this->makeTranslator());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testSortFilterRealData(): void
 | 
			
		||||
    {
 | 
			
		||||
        self::bootKernel();
 | 
			
		||||
 | 
			
		||||
        $sorter = self::$container->get(SortExportElement::class);
 | 
			
		||||
        $translator = self::$container->get(TranslatorInterface::class);
 | 
			
		||||
        $exportManager = self::$container->get(ExportManager::class);
 | 
			
		||||
        $filters = $exportManager->getAllFilters();
 | 
			
		||||
 | 
			
		||||
        $sorter->sortFilters($filters);
 | 
			
		||||
 | 
			
		||||
        $previousName = null;
 | 
			
		||||
        foreach ($filters as $filter) {
 | 
			
		||||
            if (null === $previousName) {
 | 
			
		||||
                $previousName = $translator->trans($filter->getTitle());
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            $current = $translator->trans($filter->getTitle());
 | 
			
		||||
            if ($current === $previousName) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            self::assertEquals(-1, $previousName <=> $current, sprintf("comparing '%s' and '%s'", $previousName, $current));
 | 
			
		||||
            $previousName = $current;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testSortAggregator(): void
 | 
			
		||||
    {
 | 
			
		||||
        $aggregators = [
 | 
			
		||||
            'foo' => $a = $this->makeAggregator('a'),
 | 
			
		||||
            'zop' => $q = $this->makeAggregator('q'),
 | 
			
		||||
            'bar' => $c = $this->makeAggregator('c'),
 | 
			
		||||
            'baz' => $b = $this->makeAggregator('b'),
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $this->sortExportElement->sortAggregators($aggregators);
 | 
			
		||||
 | 
			
		||||
        self::assertEquals(['foo', 'baz', 'bar', 'zop'], array_keys($aggregators));
 | 
			
		||||
        self::assertSame($a, $aggregators['foo']);
 | 
			
		||||
        self::assertSame($b, $aggregators['baz']);
 | 
			
		||||
        self::assertSame($c, $aggregators['bar']);
 | 
			
		||||
        self::assertSame($q, $aggregators['zop']);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testSortFilter(): void
 | 
			
		||||
    {
 | 
			
		||||
        $filters = [
 | 
			
		||||
            'foo' => $a = $this->makeFilter('a'),
 | 
			
		||||
            'zop' => $q = $this->makeFilter('q'),
 | 
			
		||||
            'bar' => $c = $this->makeFilter('c'),
 | 
			
		||||
            'baz' => $b = $this->makeFilter('b'),
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $this->sortExportElement->sortFilters($filters);
 | 
			
		||||
 | 
			
		||||
        self::assertEquals(['foo', 'baz', 'bar', 'zop'], array_keys($filters));
 | 
			
		||||
        self::assertSame($a, $filters['foo']);
 | 
			
		||||
        self::assertSame($b, $filters['baz']);
 | 
			
		||||
        self::assertSame($c, $filters['bar']);
 | 
			
		||||
        self::assertSame($q, $filters['zop']);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private function makeTranslator(): TranslatorInterface
 | 
			
		||||
    {
 | 
			
		||||
        return new class () implements TranslatorInterface {
 | 
			
		||||
            public function trans(string $id, array $parameters = [], string $domain = null, string $locale = null)
 | 
			
		||||
            {
 | 
			
		||||
                return $id;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            public function getLocale(): string
 | 
			
		||||
            {
 | 
			
		||||
                return 'en';
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private function makeAggregator(string $title): AggregatorInterface
 | 
			
		||||
    {
 | 
			
		||||
        return new class ($title) implements AggregatorInterface {
 | 
			
		||||
            public function __construct(private readonly string $title) {}
 | 
			
		||||
 | 
			
		||||
            public function buildForm(FormBuilderInterface $builder) {}
 | 
			
		||||
 | 
			
		||||
            public function getFormDefaultData(): array
 | 
			
		||||
            {
 | 
			
		||||
                return [];
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            public function getLabels($key, array $values, mixed $data)
 | 
			
		||||
            {
 | 
			
		||||
                return fn ($v) => $v;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            public function getQueryKeys($data)
 | 
			
		||||
            {
 | 
			
		||||
                return [];
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            public function getTitle()
 | 
			
		||||
            {
 | 
			
		||||
                return $this->title;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            public function addRole(): ?string
 | 
			
		||||
            {
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            public function alterQuery(QueryBuilder $qb, $data) {}
 | 
			
		||||
 | 
			
		||||
            public function applyOn()
 | 
			
		||||
            {
 | 
			
		||||
                return [];
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private function makeFilter(string $title): FilterInterface
 | 
			
		||||
    {
 | 
			
		||||
        return new class ($title) implements FilterInterface {
 | 
			
		||||
            public function __construct(private readonly string $title) {}
 | 
			
		||||
 | 
			
		||||
            public function getTitle()
 | 
			
		||||
            {
 | 
			
		||||
                return $this->title;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            public function buildForm(FormBuilderInterface $builder) {}
 | 
			
		||||
 | 
			
		||||
            public function getFormDefaultData(): array
 | 
			
		||||
            {
 | 
			
		||||
                return [];
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            public function describeAction($data, $format = 'string')
 | 
			
		||||
            {
 | 
			
		||||
                return ['a', []];
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            public function addRole(): ?string
 | 
			
		||||
            {
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            public function alterQuery(QueryBuilder $qb, $data) {}
 | 
			
		||||
 | 
			
		||||
            public function applyOn()
 | 
			
		||||
            {
 | 
			
		||||
                return [];
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										18
									
								
								src/Bundle/ChillMainBundle/Widget/WidgetHandlerInterface.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								src/Bundle/ChillMainBundle/Widget/WidgetHandlerInterface.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Chill\MainBundle\Widget;
 | 
			
		||||
 | 
			
		||||
interface WidgetHandlerInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * Return true if the handler supports the handling for this widget.
 | 
			
		||||
     */
 | 
			
		||||
    public function supports(array $config,array $context = []): bool;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Return an array which will be passed as data for the chart in the Vue element.
 | 
			
		||||
     */
 | 
			
		||||
    public function getDataForWidget(array $config,array $context = []): array;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										36
									
								
								src/Bundle/ChillMainBundle/Widget/WidgetHandlerManager.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								src/Bundle/ChillMainBundle/Widget/WidgetHandlerManager.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
namespace Chill\MainBundle\Widget;
 | 
			
		||||
 | 
			
		||||
use Chill\MainBundle\Widget\WidgetHandlerInterface;
 | 
			
		||||
use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
 | 
			
		||||
 | 
			
		||||
final class WidgetHandlerManager
 | 
			
		||||
{
 | 
			
		||||
    private iterable $handlers;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        iterable $handlers
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->handlers = $handlers;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getHandler(array $config,): WidgetHandlerInterface
 | 
			
		||||
    {
 | 
			
		||||
        foreach ($this->handlers as $widget) {
 | 
			
		||||
            if ($widget->supports($config)) {
 | 
			
		||||
                return $widget;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Handle unsupported context
 | 
			
		||||
        throw new \InvalidArgumentException('Unsupported widget.');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getDataForWidget(array $config, array $context=[]): array
 | 
			
		||||
    {
 | 
			
		||||
        return $this->getHandler($config)->getDataForWidget($config,$context);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,55 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace Chill\MainBundle\Widget\Widgets\DataFetcher;
 | 
			
		||||
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
use Doctrine\ORM\Query\ResultSetMapping;
 | 
			
		||||
 | 
			
		||||
class WidgetBarDataFetcher
 | 
			
		||||
{
 | 
			
		||||
    private EntityManagerInterface $entityManager;
 | 
			
		||||
 | 
			
		||||
    public function __construct(EntityManagerInterface $entityManager)
 | 
			
		||||
    {
 | 
			
		||||
        $this->entityManager = $entityManager;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @throws \Exception
 | 
			
		||||
     */
 | 
			
		||||
    public function fetchDataForWidget(int $userId): array
 | 
			
		||||
    {
 | 
			
		||||
        $sql = "
 | 
			
		||||
            SELECT DATE_TRUNC('month', ap.openingdate) AS month,
 | 
			
		||||
            COUNT(ap.id) AS count
 | 
			
		||||
            FROM chill_person_accompanying_period ap
 | 
			
		||||
            WHERE ap.user_id = :userId
 | 
			
		||||
            GROUP BY DATE_TRUNC('month', ap.openingdate)
 | 
			
		||||
            ORDER BY DATE_TRUNC('month', ap.openingdate) ASC
 | 
			
		||||
        ";
 | 
			
		||||
 | 
			
		||||
        $rsm = new ResultSetMapping();
 | 
			
		||||
        $rsm->addScalarResult('month', 'month');
 | 
			
		||||
        $rsm->addScalarResult('count', 'count');
 | 
			
		||||
 | 
			
		||||
        $query = $this->entityManager->createNativeQuery($sql, $rsm);
 | 
			
		||||
        $query->setParameter('userId', $userId);
 | 
			
		||||
 | 
			
		||||
        $results = $query->getResult();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        $counts = [];
 | 
			
		||||
        $months =[] ;
 | 
			
		||||
        foreach ($results as $result) {
 | 
			
		||||
            $date = new \DateTime($result['month']);
 | 
			
		||||
            $formattedMonth = $date->format('Y-m');
 | 
			
		||||
 | 
			
		||||
            $months[] = $formattedMonth;
 | 
			
		||||
            $counts[] = $result['count'];
 | 
			
		||||
        }
 | 
			
		||||
        return [
 | 
			
		||||
            'months'=>$months,
 | 
			
		||||
            'counts'=>$counts,
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										105
									
								
								src/Bundle/ChillMainBundle/Widget/Widgets/WidgetBar.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										105
									
								
								src/Bundle/ChillMainBundle/Widget/Widgets/WidgetBar.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,105 @@
 | 
			
		||||
<?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\MainBundle\Widget\Widgets;
 | 
			
		||||
 | 
			
		||||
use Chill\MainBundle\Entity\User;
 | 
			
		||||
use Chill\MainBundle\Repository\NotificationRepository;
 | 
			
		||||
use Chill\MainBundle\Widget\WidgetHandlerInterface;
 | 
			
		||||
use Chill\PersonBundle\Repository\AccompanyingPeriodRepository;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
 | 
			
		||||
use Symfony\Component\Security\Core\Security;
 | 
			
		||||
use Chill\MainBundle\Widget\Widgets\DataFetcher\WidgetBarDataFetcher;
 | 
			
		||||
 | 
			
		||||
class WidgetBar implements WidgetHandlerInterface
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    private Security $security;
 | 
			
		||||
 | 
			
		||||
    //private AccompanyingPeriodRepository $acpRepository;
 | 
			
		||||
 | 
			
		||||
    private WidgetBarDataFetcher $dataFetcher;
 | 
			
		||||
 | 
			
		||||
    //private NotificationRepository $notificationRepository;
 | 
			
		||||
 | 
			
		||||
    //private EntityManagerInterface $em;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
    //    AccompanyingPeriodRepository $accompanyingPeriodRepository,
 | 
			
		||||
        Security                     $security,
 | 
			
		||||
    //    NotificationRepository       $notificationRepository,
 | 
			
		||||
    //    EntityManagerInterface       $em,
 | 
			
		||||
        WidgetBarDataFetcher         $dataFetcher
 | 
			
		||||
 | 
			
		||||
    )
 | 
			
		||||
    {
 | 
			
		||||
    //    $this->acpRepository = $accompanyingPeriodRepository;
 | 
			
		||||
        $this->security = $security;
 | 
			
		||||
    //    $this->notificationRepository = $notificationRepository;
 | 
			
		||||
    //    $this->em = $em;
 | 
			
		||||
        $this->dataFetcher = $dataFetcher;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function supports(array $config, array $context = []): bool
 | 
			
		||||
    {
 | 
			
		||||
        // Check if the context is "bar"
 | 
			
		||||
        return $config['alias'] === 'bar';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @throws \Exception
 | 
			
		||||
     */
 | 
			
		||||
    public function getDataForWidget(array $config, array $context = []): array
 | 
			
		||||
    {
 | 
			
		||||
        $user = $this->security->getUser();
 | 
			
		||||
        //$userId = $user->getId();
 | 
			
		||||
        //Hardcoder pour résultat
 | 
			
		||||
        $userId = 19;
 | 
			
		||||
        $dataForWidget = [];
 | 
			
		||||
        if (!$user instanceof User) {
 | 
			
		||||
            throw new AccessDeniedException();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if ($context !== []) {
 | 
			
		||||
            switch ($context['what']) {
 | 
			
		||||
                case 'accompanying_period_by_month':
 | 
			
		||||
 | 
			
		||||
                    $data = $this->dataFetcher->fetchDataForWidget($userId);
 | 
			
		||||
                    $dataForWidget = [
 | 
			
		||||
                        'labels' => $data['months'],
 | 
			
		||||
                        'datasets' => [
 | 
			
		||||
                            [
 | 
			
		||||
                                'label' => 'Number of accompanying periods opened',
 | 
			
		||||
                                'backgroundColor' => ['#41B883'],
 | 
			
		||||
                                'data' => $data['counts']
 | 
			
		||||
                            ]
 | 
			
		||||
                        ]
 | 
			
		||||
                    ];
 | 
			
		||||
                    break;
 | 
			
		||||
                default:
 | 
			
		||||
                    throw new \InvalidArgumentException('Invalid Context.');
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return [
 | 
			
		||||
            'data' => $dataForWidget,
 | 
			
		||||
            'options' => [
 | 
			
		||||
 | 
			
		||||
                'responsive' => 'true',
 | 
			
		||||
                'maintainAspectRatio' => 'false',
 | 
			
		||||
                'position' => 'relative'
 | 
			
		||||
 | 
			
		||||
            ],
 | 
			
		||||
            'type' => 'bar',
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										104
									
								
								src/Bundle/ChillMainBundle/Widget/Widgets/WidgetNumber.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										104
									
								
								src/Bundle/ChillMainBundle/Widget/Widgets/WidgetNumber.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,104 @@
 | 
			
		||||
<?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\MainBundle\Widget\Widgets;
 | 
			
		||||
 | 
			
		||||
use Chill\MainBundle\Entity\User;
 | 
			
		||||
use Chill\MainBundle\Repository\NotificationRepository;
 | 
			
		||||
use Chill\MainBundle\Widget\WidgetHandlerInterface;
 | 
			
		||||
use Chill\PersonBundle\Repository\AccompanyingPeriodRepository;
 | 
			
		||||
use Chill\PersonBundle\Repository\Person;
 | 
			
		||||
use DateInterval;
 | 
			
		||||
use DateTimeImmutable;
 | 
			
		||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
 | 
			
		||||
use Symfony\Component\Security\Core\Security;
 | 
			
		||||
 | 
			
		||||
class WidgetNumber implements WidgetHandlerInterface
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    private Security $security;
 | 
			
		||||
 | 
			
		||||
    //private AccompanyingPeriodRepository $acpRepository;
 | 
			
		||||
 | 
			
		||||
    private NotificationRepository $notificationRepository;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
    //    AccompanyingPeriodRepository $accompanyingPeriodRepository,
 | 
			
		||||
        Security                     $security,
 | 
			
		||||
        NotificationRepository       $notificationRepository,
 | 
			
		||||
 | 
			
		||||
    )
 | 
			
		||||
    {
 | 
			
		||||
    //    $this->acpRepository = $accompanyingPeriodRepository;
 | 
			
		||||
        $this->security = $security;
 | 
			
		||||
        $this->notificationRepository = $notificationRepository;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function supports(array $config, array $context = []): bool
 | 
			
		||||
    {
 | 
			
		||||
        return $config['alias'] === 'number';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public function getDataForWidget(array $config, array $context = []): array
 | 
			
		||||
    {
 | 
			
		||||
        $user = $this->security->getUser();
 | 
			
		||||
        $dataForWidget = [];
 | 
			
		||||
        if (!$user instanceof User) {
 | 
			
		||||
            throw new AccessDeniedException();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if ($context !== []) {
 | 
			
		||||
            switch ($context['what']) {
 | 
			
		||||
 | 
			
		||||
                /*case 'accompanying_period_history' :
 | 
			
		||||
                    //Send back a data that need to be serialize in order to see
 | 
			
		||||
                    $since = (new DateTimeImmutable('now'))->sub(new DateInterval('P1Y'));
 | 
			
		||||
                    $data = $this->acpRepository->countByRecentUserHistory($user, $since);
 | 
			
		||||
                    $what = $this->acpRepository->findConfirmedByUser($user);
 | 
			
		||||
                    break;*/
 | 
			
		||||
                case 'notification_sender':
 | 
			
		||||
                    //Count the number of notification the sender send
 | 
			
		||||
                    $countSend = $this->notificationRepository->countAllForSender($user);
 | 
			
		||||
                    $dataForWidget = [
 | 
			
		||||
                        'labels' => ['notification(s) envoyée(s)'],
 | 
			
		||||
                        'datasets' => [
 | 
			
		||||
                            [
 | 
			
		||||
                                'data' => [$countSend]
 | 
			
		||||
                            ]
 | 
			
		||||
                        ]
 | 
			
		||||
                    ];
 | 
			
		||||
                    break;
 | 
			
		||||
 | 
			
		||||
                case 'notification_unread':
 | 
			
		||||
                    //Count the number of unread notification by the current User
 | 
			
		||||
                    $countUnread = $this->notificationRepository->countUnreadByUser($user);
 | 
			
		||||
                    $dataForWidget = [
 | 
			
		||||
                        'labels' => ['notification(s) non lue(s)'],
 | 
			
		||||
                        'datasets' => [
 | 
			
		||||
                            [
 | 
			
		||||
                                'data' => [$countUnread]
 | 
			
		||||
                            ]
 | 
			
		||||
                        ]
 | 
			
		||||
                    ];
 | 
			
		||||
                    break;
 | 
			
		||||
                default : throw new \InvalidArgumentException('Invalid Context.');
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return [
 | 
			
		||||
            'data' => $dataForWidget,
 | 
			
		||||
            'type' => 'number',
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -10,6 +10,22 @@ servers:
 | 
			
		||||
 | 
			
		||||
components:
 | 
			
		||||
    schemas:
 | 
			
		||||
        SavedExport:
 | 
			
		||||
            type: object
 | 
			
		||||
            properties:
 | 
			
		||||
                id:
 | 
			
		||||
                    type: integer
 | 
			
		||||
                user_id:
 | 
			
		||||
                    type: integer
 | 
			
		||||
                description:
 | 
			
		||||
                    type: string
 | 
			
		||||
                exportalias:
 | 
			
		||||
                    type: string
 | 
			
		||||
                options:
 | 
			
		||||
                    type: string #TODO -> je pense que c'est object
 | 
			
		||||
                title:
 | 
			
		||||
                    type: string
 | 
			
		||||
 | 
			
		||||
        User:
 | 
			
		||||
            type: object
 | 
			
		||||
            properties:
 | 
			
		||||
@@ -791,7 +807,7 @@ paths:
 | 
			
		||||
    /1.0/main/civility.json:
 | 
			
		||||
        get:
 | 
			
		||||
            tags:
 | 
			
		||||
            - civility
 | 
			
		||||
                - civility
 | 
			
		||||
            summary: Return all civility types
 | 
			
		||||
            responses:
 | 
			
		||||
                200:
 | 
			
		||||
@@ -843,3 +859,27 @@ paths:
 | 
			
		||||
                403:
 | 
			
		||||
                    description: "Unauthorized"
 | 
			
		||||
 | 
			
		||||
    /1.0/main/saved-export/{id}.json:
 | 
			
		||||
        get:
 | 
			
		||||
            tags:
 | 
			
		||||
                - export
 | 
			
		||||
            summary: Return a specific saved export who is saved by an existing user.
 | 
			
		||||
            parameters:
 | 
			
		||||
            -   name: id
 | 
			
		||||
                in: path
 | 
			
		||||
                required: true
 | 
			
		||||
                description: The saved export id
 | 
			
		||||
                schema:
 | 
			
		||||
                    type: string
 | 
			
		||||
                    format: string
 | 
			
		||||
            responses:
 | 
			
		||||
                200:
 | 
			
		||||
                    description: "ok"
 | 
			
		||||
                    content:
 | 
			
		||||
                        application/json:
 | 
			
		||||
                            schema:
 | 
			
		||||
                                type: string
 | 
			
		||||
                                items:
 | 
			
		||||
                                    $ref: '#/components/schemas/SavedExport'
 | 
			
		||||
                403:
 | 
			
		||||
                    description: "Unauthorized"
 | 
			
		||||
 
 | 
			
		||||
@@ -115,6 +115,24 @@ services:
 | 
			
		||||
        autowire: true
 | 
			
		||||
        autoconfigure: true
 | 
			
		||||
 | 
			
		||||
    Chill\MainBundle\Widget\:
 | 
			
		||||
        resource: '../Widget/'
 | 
			
		||||
        autowire: true
 | 
			
		||||
        autoconfigure: true
 | 
			
		||||
 | 
			
		||||
    Chill\MainBundle\Widget\WidgetHandlerManager:
 | 
			
		||||
        arguments:
 | 
			
		||||
            $handlers: !tagged_iterator chill_main.widget_handler
 | 
			
		||||
 | 
			
		||||
    Chill\MainBundle\Widget\Widgets\WidgetNumber:
 | 
			
		||||
        autoconfigure: true
 | 
			
		||||
        autowire: true
 | 
			
		||||
 | 
			
		||||
    Chill\MainBundle\Widget\Widgets\WidgetBar:
 | 
			
		||||
        autoconfigure: true
 | 
			
		||||
        autowire: true
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    Chill\MainBundle\Cron\CronManager:
 | 
			
		||||
        autoconfigure: true
 | 
			
		||||
        autowire: true
 | 
			
		||||
 
 | 
			
		||||
@@ -54,5 +54,3 @@ services:
 | 
			
		||||
            - { name: chill.export_formatter, alias: 'csv_pivoted_list' }
 | 
			
		||||
 | 
			
		||||
    Chill\MainBundle\Export\AccompanyingCourseExportHelper: ~
 | 
			
		||||
 | 
			
		||||
    Chill\MainBundle\Export\SortExportElement: ~
 | 
			
		||||
 
 | 
			
		||||
@@ -25,8 +25,8 @@ class PersonMoveRelationHandler implements PersonMoveSqlHandlerInterface
 | 
			
		||||
    public function getSqls(string $className, string $field, Person $from, Person $to): array
 | 
			
		||||
    {
 | 
			
		||||
        $insertSql = sprintf(<<<'SQL'
 | 
			
		||||
            INSERT INTO chill_person_relationships (id, relation_id, reverse, createdat, createdby_id, fromperson_id, toperson_id)
 | 
			
		||||
                SELECT nextval('chill_person_relationships_id_seq'), relation_id, reverse, createdat, createdby_id, fromperson_id, toperson_id
 | 
			
		||||
            INSERT INTO chill_person_relationships (id, relation_id, reverse, fromperson_id, toperson_id)
 | 
			
		||||
                SELECT nextval('chill_person_relationships_id_seq'), relation_id, reverse, fromperson_id, toperson_id
 | 
			
		||||
                    FROM chill_person_relationships cpr
 | 
			
		||||
                    WHERE fromperson_id = %d OR toperson_id = %d
 | 
			
		||||
                        AND NOT EXISTS (
 | 
			
		||||
 
 | 
			
		||||
@@ -113,7 +113,7 @@ class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Contr
 | 
			
		||||
                $em->remove($accompanyingCourse);
 | 
			
		||||
                $em->flush();
 | 
			
		||||
 | 
			
		||||
                $this->addFlash('success', $this->translator
 | 
			
		||||
                $this->addFlash('success', $this->get('translator')
 | 
			
		||||
                    ->trans('The accompanying course has been successfully removed.'));
 | 
			
		||||
 | 
			
		||||
                if (null !== $person_id) {
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,6 @@ use Symfony\Component\HttpFoundation\Request;
 | 
			
		||||
use Symfony\Component\HttpFoundation\Response;
 | 
			
		||||
use Symfony\Component\Validator\ConstraintViolationListInterface;
 | 
			
		||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
 | 
			
		||||
use Symfony\Contracts\Translation\TranslatorInterface;
 | 
			
		||||
use function array_filter;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -34,12 +33,24 @@ use function array_filter;
 | 
			
		||||
 */
 | 
			
		||||
class AccompanyingPeriodController extends AbstractController
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @var EventDispatcherInterface
 | 
			
		||||
     */
 | 
			
		||||
    protected $eventDispatcher;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var ValidatorInterface
 | 
			
		||||
     */
 | 
			
		||||
    protected $validator;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        protected AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository,
 | 
			
		||||
        private readonly EventDispatcherInterface $eventDispatcher,
 | 
			
		||||
        private readonly ValidatorInterface $validator,
 | 
			
		||||
        private readonly TranslatorInterface $translator
 | 
			
		||||
    ) {}
 | 
			
		||||
        EventDispatcherInterface $eventDispatcher,
 | 
			
		||||
        ValidatorInterface $validator
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->eventDispatcher = $eventDispatcher;
 | 
			
		||||
        $this->validator = $validator;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @throws \Exception
 | 
			
		||||
@@ -54,7 +65,7 @@ class AccompanyingPeriodController extends AbstractController
 | 
			
		||||
 | 
			
		||||
        if (false === $person->isOpen()) {
 | 
			
		||||
            $this->get('session')->getFlashBag()
 | 
			
		||||
                ->add('error', $this->translator
 | 
			
		||||
                ->add('error', $this->get('translator')
 | 
			
		||||
                    ->trans(
 | 
			
		||||
                        'Beware period is closed',
 | 
			
		||||
                        ['%name%' => $person->__toString()]
 | 
			
		||||
@@ -81,7 +92,7 @@ class AccompanyingPeriodController extends AbstractController
 | 
			
		||||
 | 
			
		||||
                if (0 === \count($errors)) {
 | 
			
		||||
                    $this->get('session')->getFlashBag()
 | 
			
		||||
                        ->add('success', $this->translator
 | 
			
		||||
                        ->add('success', $this->get('translator')
 | 
			
		||||
                            ->trans('An accompanying period has been closed.', [
 | 
			
		||||
                                '%name%' => $person->__toString(),
 | 
			
		||||
                            ]));
 | 
			
		||||
@@ -93,7 +104,7 @@ class AccompanyingPeriodController extends AbstractController
 | 
			
		||||
                    ]);
 | 
			
		||||
                }
 | 
			
		||||
                $this->get('session')->getFlashBag()
 | 
			
		||||
                    ->add('error', $this->translator
 | 
			
		||||
                    ->add('error', $this->get('translator')
 | 
			
		||||
                        ->trans('Error! Period not closed!'));
 | 
			
		||||
 | 
			
		||||
                foreach ($errors as $error) {
 | 
			
		||||
@@ -104,7 +115,7 @@ class AccompanyingPeriodController extends AbstractController
 | 
			
		||||
                $this->get('session')->getFlashBag()
 | 
			
		||||
                    ->add(
 | 
			
		||||
                        'error',
 | 
			
		||||
                        $this->translator
 | 
			
		||||
                        $this->get('translator')
 | 
			
		||||
                            ->trans('Pediod closing form is not valid')
 | 
			
		||||
                    );
 | 
			
		||||
 | 
			
		||||
@@ -164,7 +175,7 @@ class AccompanyingPeriodController extends AbstractController
 | 
			
		||||
                $em->flush();
 | 
			
		||||
                $flashBag->add(
 | 
			
		||||
                    'success',
 | 
			
		||||
                    $this->translator->trans(
 | 
			
		||||
                    $this->get('translator')->trans(
 | 
			
		||||
                        'A period has been created.'
 | 
			
		||||
                    )
 | 
			
		||||
                );
 | 
			
		||||
@@ -173,7 +184,7 @@ class AccompanyingPeriodController extends AbstractController
 | 
			
		||||
                    'person_id' => $person->getId(),
 | 
			
		||||
                ]);
 | 
			
		||||
            }
 | 
			
		||||
            $flashBag->add('error', $this->translator
 | 
			
		||||
            $flashBag->add('error', $this->get('translator')
 | 
			
		||||
                ->trans('Error! Period not created!'));
 | 
			
		||||
 | 
			
		||||
            foreach ($errors as $error) {
 | 
			
		||||
@@ -233,7 +244,7 @@ class AccompanyingPeriodController extends AbstractController
 | 
			
		||||
        // in case the person is already open
 | 
			
		||||
        if ($person->isOpen()) {
 | 
			
		||||
            $this->get('session')->getFlashBag()
 | 
			
		||||
                ->add('error', $this->translator
 | 
			
		||||
                ->add('error', $this->get('translator')
 | 
			
		||||
                    ->trans(
 | 
			
		||||
                        'Error! Period %name% is not closed ; it can be open',
 | 
			
		||||
                        ['%name%' => $person->__toString()]
 | 
			
		||||
@@ -265,7 +276,7 @@ class AccompanyingPeriodController extends AbstractController
 | 
			
		||||
 | 
			
		||||
                if (\count($errors) <= 0) {
 | 
			
		||||
                    $this->get('session')->getFlashBag()
 | 
			
		||||
                        ->add('success', $this->translator
 | 
			
		||||
                        ->add('success', $this->get('translator')
 | 
			
		||||
                            ->trans(
 | 
			
		||||
                                'An accompanying period has been opened.',
 | 
			
		||||
                                ['%name%' => $person->__toString()]
 | 
			
		||||
@@ -278,7 +289,7 @@ class AccompanyingPeriodController extends AbstractController
 | 
			
		||||
                    ]);
 | 
			
		||||
                }
 | 
			
		||||
                $this->get('session')->getFlashBag()
 | 
			
		||||
                    ->add('error', $this->translator
 | 
			
		||||
                    ->add('error', $this->get('translator')
 | 
			
		||||
                        ->trans('Period not opened'));
 | 
			
		||||
 | 
			
		||||
                foreach ($errors as $error) {
 | 
			
		||||
@@ -289,7 +300,7 @@ class AccompanyingPeriodController extends AbstractController
 | 
			
		||||
                $this->get('session')->getFlashBag()
 | 
			
		||||
                    ->add(
 | 
			
		||||
                        'error',
 | 
			
		||||
                        $this->translator
 | 
			
		||||
                        $this->get('translator')
 | 
			
		||||
                            ->trans('Period not opened : form is invalid')
 | 
			
		||||
                    );
 | 
			
		||||
            }
 | 
			
		||||
@@ -329,7 +340,7 @@ class AccompanyingPeriodController extends AbstractController
 | 
			
		||||
 | 
			
		||||
            $this->getDoctrine()->getManager()->flush();
 | 
			
		||||
 | 
			
		||||
            $this->addFlash('success', $this->translator->trans(
 | 
			
		||||
            $this->addFlash('success', $this->get('translator')->trans(
 | 
			
		||||
                'The period has been re-opened'
 | 
			
		||||
            ));
 | 
			
		||||
 | 
			
		||||
@@ -402,7 +413,7 @@ class AccompanyingPeriodController extends AbstractController
 | 
			
		||||
 | 
			
		||||
                $flashBag->add(
 | 
			
		||||
                    'success',
 | 
			
		||||
                    $this->translator->trans('An accompanying period has been updated.')
 | 
			
		||||
                    $this->get('translator')->trans('An accompanying period has been updated.')
 | 
			
		||||
                );
 | 
			
		||||
 | 
			
		||||
                return $this->redirectToRoute('chill_person_accompanying_period_list', [
 | 
			
		||||
@@ -410,7 +421,7 @@ class AccompanyingPeriodController extends AbstractController
 | 
			
		||||
                ]);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            $flashBag->add('error', $this->translator
 | 
			
		||||
            $flashBag->add('error', $this->get('translator')
 | 
			
		||||
                ->trans('Error when updating the period'));
 | 
			
		||||
 | 
			
		||||
            foreach ($errors as $error) {
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,6 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
 | 
			
		||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
 | 
			
		||||
use Symfony\Component\HttpFoundation\Request;
 | 
			
		||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
 | 
			
		||||
use Symfony\Contracts\Translation\TranslatorInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Class PersonAddressController
 | 
			
		||||
@@ -26,10 +25,18 @@ use Symfony\Contracts\Translation\TranslatorInterface;
 | 
			
		||||
 */
 | 
			
		||||
class PersonAddressController extends AbstractController
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @var ValidatorInterface
 | 
			
		||||
     */
 | 
			
		||||
    protected $validator;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * PersonAddressController constructor.
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct(private readonly ValidatorInterface $validator, private readonly TranslatorInterface $translator) {}
 | 
			
		||||
    public function __construct(ValidatorInterface $validator)
 | 
			
		||||
    {
 | 
			
		||||
        $this->validator = $validator;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/address/create", name="chill_person_address_create", methods={"POST"})
 | 
			
		||||
@@ -70,14 +77,14 @@ class PersonAddressController extends AbstractController
 | 
			
		||||
 | 
			
		||||
                $this->addFlash(
 | 
			
		||||
                    'success',
 | 
			
		||||
                    $this->translator->trans('The new address was created successfully')
 | 
			
		||||
                    $this->get('translator')->trans('The new address was created successfully')
 | 
			
		||||
                );
 | 
			
		||||
 | 
			
		||||
                return $this->redirectToRoute('chill_person_address_list', [
 | 
			
		||||
                    'person_id' => $person->getId(),
 | 
			
		||||
                ]);
 | 
			
		||||
            } else {
 | 
			
		||||
                $this->addFlash('error', $this->translator
 | 
			
		||||
                $this->addFlash('error', $this->get('translator')
 | 
			
		||||
                    ->trans('Error! Address not created!'));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
@@ -206,7 +213,7 @@ class PersonAddressController extends AbstractController
 | 
			
		||||
                $this->getDoctrine()->getManager()
 | 
			
		||||
                    ->flush();
 | 
			
		||||
 | 
			
		||||
                $this->addFlash('success', $this->translator->trans(
 | 
			
		||||
                $this->addFlash('success', $this->get('translator')->trans(
 | 
			
		||||
                    'The address has been successfully updated'
 | 
			
		||||
                ));
 | 
			
		||||
 | 
			
		||||
@@ -214,7 +221,7 @@ class PersonAddressController extends AbstractController
 | 
			
		||||
                    'person_id' => $person->getId(),
 | 
			
		||||
                ]);
 | 
			
		||||
            } else {
 | 
			
		||||
                $this->addFlash('error', $this->translator
 | 
			
		||||
                $this->addFlash('error', $this->get('translator')
 | 
			
		||||
                    ->trans('Error when updating the period'));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -82,6 +82,7 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll
 | 
			
		||||
            $connection->beginTransaction();
 | 
			
		||||
 | 
			
		||||
            foreach ($sqls as $sql) {
 | 
			
		||||
                dump($sql);
 | 
			
		||||
                $connection->executeQuery($sql);
 | 
			
		||||
            }
 | 
			
		||||
            $connection->commit();
 | 
			
		||||
 
 | 
			
		||||
@@ -1,88 +0,0 @@
 | 
			
		||||
<?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\AccompanyingCourseAggregators;
 | 
			
		||||
 | 
			
		||||
use Chill\MainBundle\Export\AggregatorInterface;
 | 
			
		||||
use Chill\PersonBundle\Export\Declarations;
 | 
			
		||||
use Chill\PersonBundle\Export\Enum\DateGroupingChoiceEnum;
 | 
			
		||||
use Chill\PersonBundle\Tests\Export\Aggregator\AccompanyingCourseAggregators\ClosingDateAggregatorTest;
 | 
			
		||||
use Doctrine\ORM\QueryBuilder;
 | 
			
		||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @see ClosingDateAggregatorTest
 | 
			
		||||
 */
 | 
			
		||||
final readonly class ClosingDateAggregator implements AggregatorInterface
 | 
			
		||||
{
 | 
			
		||||
    private const PREFIX = 'acp_closing_date_agg';
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder): void
 | 
			
		||||
    {
 | 
			
		||||
        $builder->add('frequency', ChoiceType::class, [
 | 
			
		||||
            'choices' => array_combine(
 | 
			
		||||
                array_map(fn (DateGroupingChoiceEnum $c) => 'export.enum.frequency.'.$c->value, DateGroupingChoiceEnum::cases()),
 | 
			
		||||
                array_map(fn (DateGroupingChoiceEnum $c) => $c->value, DateGroupingChoiceEnum::cases()),
 | 
			
		||||
            ),
 | 
			
		||||
            'label' => 'export.aggregator.course.by_closing_date.frequency',
 | 
			
		||||
            'multiple' => false,
 | 
			
		||||
            'expanded' => true,
 | 
			
		||||
        ]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getFormDefaultData(): array
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
            'frequency' => 'year',
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getLabels($key, array $values, mixed $data)
 | 
			
		||||
    {
 | 
			
		||||
        return function (null|string $value): string {
 | 
			
		||||
            if ('_header' === $value) {
 | 
			
		||||
                return 'export.aggregator.course.by_closing_date.header';
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return (string) $value;
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getQueryKeys($data)
 | 
			
		||||
    {
 | 
			
		||||
        return [self::PREFIX.'_closing_date'];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getTitle()
 | 
			
		||||
    {
 | 
			
		||||
        return 'export.aggregator.course.by_closing_date.title';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function addRole(): ?string
 | 
			
		||||
    {
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function alterQuery(QueryBuilder $qb, $data)
 | 
			
		||||
    {
 | 
			
		||||
        $p = self::PREFIX;
 | 
			
		||||
 | 
			
		||||
        $qb->addSelect(sprintf("TO_CHAR(acp.closingDate, '%s') AS {$p}_closing_date", $data['frequency']));
 | 
			
		||||
        $qb->addGroupBy("{$p}_closing_date");
 | 
			
		||||
        $qb->addOrderBy("{$p}_closing_date", 'DESC');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function applyOn()
 | 
			
		||||
    {
 | 
			
		||||
        return Declarations::ACP_TYPE;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -38,7 +38,7 @@ final readonly class DurationAggregator implements AggregatorInterface
 | 
			
		||||
        match ($data['precision']) {
 | 
			
		||||
            'day' => $qb->addSelect('(COALESCE(acp.closingDate, :now) - acp.openingDate)  AS duration_aggregator'),
 | 
			
		||||
            'week' => $qb->addSelect('(COALESCE(acp.closingDate, :now) - acp.openingDate) / 7  AS duration_aggregator'),
 | 
			
		||||
            'month' => $qb->addSelect('(EXTRACT (YEAR FROM AGE(COALESCE(acp.closingDate, :now), acp.openingDate)) * 12 +
 | 
			
		||||
            'month' => $qb->addSelect('(EXTRACT (MONTH FROM AGE(COALESCE(acp.closingDate, :now), acp.openingDate)) * 12 +
 | 
			
		||||
                    EXTRACT (MONTH FROM AGE(COALESCE(acp.closingDate, :now), acp.openingDate))) AS duration_aggregator'),
 | 
			
		||||
            default => throw new \LogicException('precision not supported: '.$data['precision']),
 | 
			
		||||
        };
 | 
			
		||||
 
 | 
			
		||||
@@ -1,88 +0,0 @@
 | 
			
		||||
<?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\AccompanyingCourseAggregators;
 | 
			
		||||
 | 
			
		||||
use Chill\MainBundle\Export\AggregatorInterface;
 | 
			
		||||
use Chill\PersonBundle\Export\Declarations;
 | 
			
		||||
use Chill\PersonBundle\Export\Enum\DateGroupingChoiceEnum;
 | 
			
		||||
use Chill\PersonBundle\Tests\Export\Aggregator\AccompanyingCourseAggregators\OpeningDateAggregatorTest;
 | 
			
		||||
use Doctrine\ORM\QueryBuilder;
 | 
			
		||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @see OpeningDateAggregatorTest
 | 
			
		||||
 */
 | 
			
		||||
final readonly class OpeningDateAggregator implements AggregatorInterface
 | 
			
		||||
{
 | 
			
		||||
    private const PREFIX = 'acp_opening_date_agg';
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder): void
 | 
			
		||||
    {
 | 
			
		||||
        $builder->add('frequency', ChoiceType::class, [
 | 
			
		||||
            'choices' => array_combine(
 | 
			
		||||
                array_map(fn (DateGroupingChoiceEnum $c) => 'export.enum.frequency.'.$c->value, DateGroupingChoiceEnum::cases()),
 | 
			
		||||
                array_map(fn (DateGroupingChoiceEnum $c) => $c->value, DateGroupingChoiceEnum::cases()),
 | 
			
		||||
            ),
 | 
			
		||||
            'label' => 'export.aggregator.course.by_opening_date.frequency',
 | 
			
		||||
            'multiple' => false,
 | 
			
		||||
            'expanded' => true,
 | 
			
		||||
        ]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getFormDefaultData(): array
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
            'frequency' => 'year',
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getLabels($key, array $values, mixed $data)
 | 
			
		||||
    {
 | 
			
		||||
        return function (null|string $value): string {
 | 
			
		||||
            if ('_header' === $value) {
 | 
			
		||||
                return 'export.aggregator.course.by_opening_date.header';
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return (string) $value;
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getQueryKeys($data)
 | 
			
		||||
    {
 | 
			
		||||
        return [self::PREFIX.'_opening_date'];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getTitle()
 | 
			
		||||
    {
 | 
			
		||||
        return 'export.aggregator.course.by_opening_date.title';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function addRole(): ?string
 | 
			
		||||
    {
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function alterQuery(QueryBuilder $qb, $data)
 | 
			
		||||
    {
 | 
			
		||||
        $p = self::PREFIX;
 | 
			
		||||
 | 
			
		||||
        $qb->addSelect(sprintf("TO_CHAR(acp.openingDate, '%s') AS {$p}_opening_date", $data['frequency']));
 | 
			
		||||
        $qb->addGroupBy("{$p}_opening_date");
 | 
			
		||||
        $qb->addOrderBy("{$p}_opening_date", 'DESC');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function applyOn()
 | 
			
		||||
    {
 | 
			
		||||
        return Declarations::ACP_TYPE;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -49,7 +49,7 @@ final readonly class StepAggregator implements AggregatorInterface
 | 
			
		||||
                        $qb->expr()->lte(self::A.'.startDate', ':'.self::P),
 | 
			
		||||
                        $qb->expr()->orX(
 | 
			
		||||
                            $qb->expr()->isNull(self::A.'.endDate'),
 | 
			
		||||
                            $qb->expr()->gt(self::A.'.endDate', ':'.self::P)
 | 
			
		||||
                            $qb->expr()->lt(self::A.'.endDate', ':'.self::P)
 | 
			
		||||
                        )
 | 
			
		||||
                    )
 | 
			
		||||
                )
 | 
			
		||||
 
 | 
			
		||||
@@ -1,73 +0,0 @@
 | 
			
		||||
<?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 Chill\PersonBundle\Tests\Export\Aggregator\SocialWorkAggregators\HandlingThirdPartyAggregatorTest;
 | 
			
		||||
use Chill\ThirdPartyBundle\Export\Helper\LabelThirdPartyHelper;
 | 
			
		||||
use Doctrine\ORM\QueryBuilder;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @see HandlingThirdPartyAggregatorTest
 | 
			
		||||
 */
 | 
			
		||||
final readonly class HandlingThirdPartyAggregator implements AggregatorInterface
 | 
			
		||||
{
 | 
			
		||||
    private const PREFIX = 'acpw_handling3party_agg';
 | 
			
		||||
 | 
			
		||||
    public function __construct(private LabelThirdPartyHelper $labelThirdPartyHelper) {}
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder)
 | 
			
		||||
    {
 | 
			
		||||
        // no form needed here
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getFormDefaultData(): array
 | 
			
		||||
    {
 | 
			
		||||
        return [];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getLabels($key, array $values, mixed $data)
 | 
			
		||||
    {
 | 
			
		||||
        return $this->labelThirdPartyHelper->getLabel($key, $values, 'export.aggregator.course_work.by_handling_third_party.header');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getQueryKeys($data)
 | 
			
		||||
    {
 | 
			
		||||
        return [self::PREFIX.'_h3party'];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getTitle()
 | 
			
		||||
    {
 | 
			
		||||
        return 'export.aggregator.course_work.by_handling_third_party.title';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function addRole(): ?string
 | 
			
		||||
    {
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function alterQuery(QueryBuilder $qb, $data)
 | 
			
		||||
    {
 | 
			
		||||
        $p = self::PREFIX;
 | 
			
		||||
 | 
			
		||||
        $qb
 | 
			
		||||
            ->addSelect("IDENTITY(acpw.handlingThierParty) AS {$p}_h3party")
 | 
			
		||||
            ->addGroupBy("{$p}_h3party");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function applyOn()
 | 
			
		||||
    {
 | 
			
		||||
        return Declarations::SOCIAL_WORK_ACTION_TYPE;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -23,20 +23,16 @@ use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
use Doctrine\ORM\EntityRepository;
 | 
			
		||||
use Doctrine\ORM\Query;
 | 
			
		||||
use Doctrine\ORM\QueryBuilder;
 | 
			
		||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface
 | 
			
		||||
{
 | 
			
		||||
    protected EntityRepository $repository;
 | 
			
		||||
    private readonly bool $filterStatsByCenters;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        EntityManagerInterface $em,
 | 
			
		||||
        ParameterBagInterface $parameterBag,
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->repository = $em->getRepository(AccompanyingPeriod::class);
 | 
			
		||||
        $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder): void
 | 
			
		||||
@@ -106,19 +102,15 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface
 | 
			
		||||
            ->andWhere('acp.step != :count_acp_step')
 | 
			
		||||
            ->leftJoin('acp.participations', 'acppart')
 | 
			
		||||
            ->leftJoin('acppart.person', 'person')
 | 
			
		||||
            ->setParameter('count_acp_step', AccompanyingPeriod::STEP_DRAFT);
 | 
			
		||||
 | 
			
		||||
        if ($this->filterStatsByCenters) {
 | 
			
		||||
            $qb
 | 
			
		||||
                ->andWhere(
 | 
			
		||||
                    $qb->expr()->exists(
 | 
			
		||||
                        'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
 | 
			
		||||
            ->andWhere(
 | 
			
		||||
                $qb->expr()->exists(
 | 
			
		||||
                    'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
 | 
			
		||||
                    AND acl_count_person_history.center IN (:authorized_centers)
 | 
			
		||||
                    '
 | 
			
		||||
                    )
 | 
			
		||||
                )
 | 
			
		||||
                ->setParameter('authorized_centers', $centers);
 | 
			
		||||
        }
 | 
			
		||||
            )
 | 
			
		||||
            ->setParameter('count_acp_step', AccompanyingPeriod::STEP_DRAFT)
 | 
			
		||||
            ->setParameter('authorized_centers', $centers);
 | 
			
		||||
 | 
			
		||||
        AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -22,19 +22,11 @@ use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
use Doctrine\ORM\Query;
 | 
			
		||||
use Doctrine\ORM\QueryBuilder;
 | 
			
		||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInterface
 | 
			
		||||
{
 | 
			
		||||
    private readonly bool $filterStatsByCenters;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        protected EntityManagerInterface $em,
 | 
			
		||||
        ParameterBagInterface $parameterBag,
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
 | 
			
		||||
    }
 | 
			
		||||
    public function __construct(protected EntityManagerInterface $em) {}
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder): void
 | 
			
		||||
    {
 | 
			
		||||
@@ -103,19 +95,15 @@ class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInter
 | 
			
		||||
            ->from(AccompanyingPeriod\AccompanyingPeriodWork::class, 'acpw')
 | 
			
		||||
            ->join('acpw.accompanyingPeriod', 'acp')
 | 
			
		||||
            ->join('acp.participations', 'acppart')
 | 
			
		||||
            ->join('acppart.person', 'person');
 | 
			
		||||
 | 
			
		||||
        if ($this->filterStatsByCenters) {
 | 
			
		||||
            $qb
 | 
			
		||||
                ->andWhere(
 | 
			
		||||
                    $qb->expr()->exists(
 | 
			
		||||
                        'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
 | 
			
		||||
            ->join('acppart.person', 'person')
 | 
			
		||||
            ->andWhere(
 | 
			
		||||
                $qb->expr()->exists(
 | 
			
		||||
                    'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
 | 
			
		||||
                    AND acl_count_person_history.center IN (:authorized_centers)
 | 
			
		||||
                    '
 | 
			
		||||
                    )
 | 
			
		||||
                )
 | 
			
		||||
                ->setParameter('authorized_centers', $centers);
 | 
			
		||||
        }
 | 
			
		||||
            )
 | 
			
		||||
            ->setParameter('authorized_centers', $centers);
 | 
			
		||||
 | 
			
		||||
        $qb->select('COUNT(DISTINCT acpw.id) as export_result');
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -21,19 +21,11 @@ use Chill\PersonBundle\Export\Declarations;
 | 
			
		||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
use Doctrine\ORM\Query;
 | 
			
		||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
class CountEvaluation implements ExportInterface, GroupedExportInterface
 | 
			
		||||
{
 | 
			
		||||
    private readonly bool $filterStatsByCenters;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private readonly EntityManagerInterface $entityManager,
 | 
			
		||||
        ParameterBagInterface $parameterBag,
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
 | 
			
		||||
    }
 | 
			
		||||
    public function __construct(private readonly EntityManagerInterface $entityManager) {}
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder) {}
 | 
			
		||||
 | 
			
		||||
@@ -100,19 +92,15 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface
 | 
			
		||||
            ->join('workeval.accompanyingPeriodWork', 'acpw')
 | 
			
		||||
            ->join('acpw.accompanyingPeriod', 'acp')
 | 
			
		||||
            ->join('acp.participations', 'acppart')
 | 
			
		||||
            ->join('acppart.person', 'person');
 | 
			
		||||
 | 
			
		||||
        if ($this->filterStatsByCenters) {
 | 
			
		||||
            $qb
 | 
			
		||||
                ->andWhere(
 | 
			
		||||
                    $qb->expr()->exists(
 | 
			
		||||
                        'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
 | 
			
		||||
            ->join('acppart.person', 'person')
 | 
			
		||||
            ->andWhere(
 | 
			
		||||
                $qb->expr()->exists(
 | 
			
		||||
                    'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
 | 
			
		||||
                    AND acl_count_person_history.center IN (:authorized_centers)
 | 
			
		||||
                    '
 | 
			
		||||
                    )
 | 
			
		||||
                )
 | 
			
		||||
                ->setParameter('authorized_centers', $centers);
 | 
			
		||||
        }
 | 
			
		||||
            )
 | 
			
		||||
            ->setParameter('authorized_centers', $centers);
 | 
			
		||||
 | 
			
		||||
        AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -23,21 +23,13 @@ use Chill\PersonBundle\Export\Declarations;
 | 
			
		||||
use Chill\PersonBundle\Security\Authorization\HouseholdVoter;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
use Doctrine\ORM\Query;
 | 
			
		||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
class CountHousehold implements ExportInterface, GroupedExportInterface
 | 
			
		||||
{
 | 
			
		||||
    private const TR_PREFIX = 'export.export.nb_household_with_course.';
 | 
			
		||||
    private readonly bool $filterStatsByCenters;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private readonly EntityManagerInterface $entityManager,
 | 
			
		||||
        private readonly RollingDateConverterInterface $rollingDateConverter,
 | 
			
		||||
        ParameterBagInterface $parameterBag,
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
 | 
			
		||||
    }
 | 
			
		||||
    public function __construct(private readonly EntityManagerInterface $entityManager, private readonly RollingDateConverterInterface $rollingDateConverter) {}
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder)
 | 
			
		||||
    {
 | 
			
		||||
@@ -120,25 +112,21 @@ class CountHousehold implements ExportInterface, GroupedExportInterface
 | 
			
		||||
            ->join('person.accompanyingPeriodParticipations', 'acppart')
 | 
			
		||||
            ->join('acppart.accompanyingPeriod', 'acp')
 | 
			
		||||
            ->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL')
 | 
			
		||||
            ->andWhere(
 | 
			
		||||
                $qb->expr()->exists(
 | 
			
		||||
                    'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
 | 
			
		||||
                    AND acl_count_person_history.center IN (:authorized_centers)
 | 
			
		||||
                    '
 | 
			
		||||
                )
 | 
			
		||||
            )
 | 
			
		||||
            ->andWhere('hmember.startDate <= :count_household_at_date AND (hmember.endDate IS NULL OR hmember.endDate > :count_household_at_date)')
 | 
			
		||||
            ->setParameter('authorized_centers', $centers)
 | 
			
		||||
            ->setParameter('count_household_at_date', $this->rollingDateConverter->convert($data['calc_date']));
 | 
			
		||||
 | 
			
		||||
        $qb
 | 
			
		||||
            ->select('COUNT(DISTINCT household.id) AS household_export_result')
 | 
			
		||||
            ->addSelect('COUNT(DISTINCT acp.id) AS acp_export_result');
 | 
			
		||||
 | 
			
		||||
        if ($this->filterStatsByCenters) {
 | 
			
		||||
            $qb
 | 
			
		||||
                ->andWhere(
 | 
			
		||||
                    $qb->expr()->exists(
 | 
			
		||||
                        'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
 | 
			
		||||
                    AND acl_count_person_history.center IN (:authorized_centers)
 | 
			
		||||
                    '
 | 
			
		||||
                    )
 | 
			
		||||
                )
 | 
			
		||||
                ->andWhere('hmember.startDate <= :count_household_at_date AND (hmember.endDate IS NULL OR hmember.endDate > :count_household_at_date)')
 | 
			
		||||
                ->setParameter('authorized_centers', $centers);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $qb;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -20,19 +20,11 @@ use Chill\PersonBundle\Repository\PersonRepository;
 | 
			
		||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
 | 
			
		||||
use Doctrine\ORM\Query;
 | 
			
		||||
use Doctrine\ORM\QueryBuilder;
 | 
			
		||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
class CountPerson implements ExportInterface, GroupedExportInterface
 | 
			
		||||
{
 | 
			
		||||
    private readonly bool $filterStatsByCenters;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        protected PersonRepository $personRepository,
 | 
			
		||||
        ParameterBagInterface $parameterBag,
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
 | 
			
		||||
    }
 | 
			
		||||
    public function __construct(protected PersonRepository $personRepository) {}
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder)
 | 
			
		||||
    {
 | 
			
		||||
@@ -102,17 +94,13 @@ class CountPerson implements ExportInterface, GroupedExportInterface
 | 
			
		||||
 | 
			
		||||
        $qb = $this->personRepository->createQueryBuilder('person');
 | 
			
		||||
 | 
			
		||||
        $qb->select('COUNT(DISTINCT person.id) AS export_result');
 | 
			
		||||
 | 
			
		||||
        if ($this->filterStatsByCenters) {
 | 
			
		||||
            $qb
 | 
			
		||||
                ->andWhere(
 | 
			
		||||
                    $qb->expr()->exists(
 | 
			
		||||
                        'SELECT 1 FROM '.PersonCenterHistory::class.' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
 | 
			
		||||
                    )
 | 
			
		||||
        $qb->select('COUNT(DISTINCT person.id) AS export_result')
 | 
			
		||||
            ->andWhere(
 | 
			
		||||
                $qb->expr()->exists(
 | 
			
		||||
                    'SELECT 1 FROM '.PersonCenterHistory::class.' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
 | 
			
		||||
                )
 | 
			
		||||
                ->setParameter('authorized_centers', $centers);
 | 
			
		||||
        }
 | 
			
		||||
            )
 | 
			
		||||
            ->setParameter('authorized_centers', $centers);
 | 
			
		||||
 | 
			
		||||
        return $qb;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -22,20 +22,16 @@ use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
use Doctrine\ORM\EntityRepository;
 | 
			
		||||
use Doctrine\ORM\Query;
 | 
			
		||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExportInterface
 | 
			
		||||
{
 | 
			
		||||
    private readonly EntityRepository $repository;
 | 
			
		||||
    private readonly bool $filterStatsByCenters;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        EntityManagerInterface $em,
 | 
			
		||||
        ParameterBagInterface $parameterBag,
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->repository = $em->getRepository(AccompanyingPeriod::class);
 | 
			
		||||
        $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder)
 | 
			
		||||
@@ -109,13 +105,11 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor
 | 
			
		||||
            $qb->join('acppart.person', 'person');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if ($this->filterStatsByCenters) {
 | 
			
		||||
            $qb->andWhere(
 | 
			
		||||
                $qb->expr()->exists(
 | 
			
		||||
                    'SELECT 1 FROM '.PersonCenterHistory::class.' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
 | 
			
		||||
                )
 | 
			
		||||
            )->setParameter('authorized_centers', $centers);
 | 
			
		||||
        }
 | 
			
		||||
        $qb->andWhere(
 | 
			
		||||
            $qb->expr()->exists(
 | 
			
		||||
                'SELECT 1 FROM '.PersonCenterHistory::class.' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
 | 
			
		||||
            )
 | 
			
		||||
        )->setParameter('authorized_centers', $centers);
 | 
			
		||||
 | 
			
		||||
        AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -26,21 +26,15 @@ use Chill\PersonBundle\Export\Helper\ListAccompanyingPeriodHelper;
 | 
			
		||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
 | 
			
		||||
use Doctrine\ORM\AbstractQuery;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
final readonly class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface
 | 
			
		||||
{
 | 
			
		||||
    private bool $filterStatsByCenters;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private EntityManagerInterface $entityManager,
 | 
			
		||||
        private RollingDateConverterInterface $rollingDateConverter,
 | 
			
		||||
        private ListAccompanyingPeriodHelper $listAccompanyingPeriodHelper,
 | 
			
		||||
        ParameterBagInterface $parameterBag,
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
 | 
			
		||||
    }
 | 
			
		||||
    ) {}
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder)
 | 
			
		||||
    {
 | 
			
		||||
@@ -108,20 +102,16 @@ final readonly class ListAccompanyingPeriod implements ListInterface, GroupedExp
 | 
			
		||||
        $qb
 | 
			
		||||
            ->from(AccompanyingPeriod::class, 'acp')
 | 
			
		||||
            ->andWhere('acp.step != :list_acp_step')
 | 
			
		||||
            ->setParameter('list_acp_step', AccompanyingPeriod::STEP_DRAFT);
 | 
			
		||||
 | 
			
		||||
        if ($this->filterStatsByCenters) {
 | 
			
		||||
            $qb
 | 
			
		||||
                ->andWhere(
 | 
			
		||||
                    $qb->expr()->exists(
 | 
			
		||||
                        'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part
 | 
			
		||||
            ->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);
 | 
			
		||||
        }
 | 
			
		||||
            )
 | 
			
		||||
            ->setParameter('list_acp_step', AccompanyingPeriod::STEP_DRAFT)
 | 
			
		||||
            ->setParameter('authorized_centers', $centers);
 | 
			
		||||
 | 
			
		||||
        $this->listAccompanyingPeriodHelper->addSelectClauses($qb, $this->rollingDateConverter->convert($data['calc_date']));
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -44,7 +44,6 @@ use Chill\ThirdPartyBundle\Export\Helper\LabelThirdPartyHelper;
 | 
			
		||||
use Doctrine\ORM\AbstractQuery;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
use Doctrine\ORM\QueryBuilder;
 | 
			
		||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterface
 | 
			
		||||
@@ -79,8 +78,6 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac
 | 
			
		||||
        'updatedBy',
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
    private readonly bool $filterStatsByCenters;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private readonly EntityManagerInterface $entityManager,
 | 
			
		||||
        private readonly DateTimeHelper $dateTimeHelper,
 | 
			
		||||
@@ -93,11 +90,8 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac
 | 
			
		||||
        private readonly SocialActionRender $socialActionRender,
 | 
			
		||||
        private readonly RollingDateConverterInterface $rollingDateConverter,
 | 
			
		||||
        private readonly AggregateStringHelper $aggregateStringHelper,
 | 
			
		||||
        private readonly SocialActionRepository $socialActionRepository,
 | 
			
		||||
        ParameterBagInterface $parameterBag,
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
 | 
			
		||||
    }
 | 
			
		||||
        private readonly SocialActionRepository $socialActionRepository
 | 
			
		||||
    ) {}
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder)
 | 
			
		||||
    {
 | 
			
		||||
@@ -220,19 +214,15 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac
 | 
			
		||||
            ->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL')
 | 
			
		||||
            // get participants at the given date
 | 
			
		||||
            ->andWhere('acppart.startDate <= :calc_date AND (acppart.endDate > :calc_date OR acppart.endDate IS NULL)')
 | 
			
		||||
            ->setParameter('calc_date', $this->rollingDateConverter->convert($data['calc_date']));
 | 
			
		||||
 | 
			
		||||
        if ($this->filterStatsByCenters) {
 | 
			
		||||
            $qb
 | 
			
		||||
                ->andWhere(
 | 
			
		||||
                    $qb->expr()->exists(
 | 
			
		||||
                        'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
 | 
			
		||||
            ->andWhere(
 | 
			
		||||
                $qb->expr()->exists(
 | 
			
		||||
                    'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
 | 
			
		||||
                    AND acl_count_person_history.center IN (:authorized_centers)
 | 
			
		||||
                    '
 | 
			
		||||
                    )
 | 
			
		||||
                )
 | 
			
		||||
                ->setParameter('authorized_centers', $centers);
 | 
			
		||||
        }
 | 
			
		||||
            )
 | 
			
		||||
            ->setParameter('authorized_centers', $centers)
 | 
			
		||||
            ->setParameter('calc_date', $this->rollingDateConverter->convert($data['calc_date']));
 | 
			
		||||
 | 
			
		||||
        AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -37,7 +37,6 @@ use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
 | 
			
		||||
use Doctrine\ORM\AbstractQuery;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
use Doctrine\ORM\QueryBuilder;
 | 
			
		||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
class ListEvaluation implements ListInterface, GroupedExportInterface
 | 
			
		||||
@@ -69,24 +68,7 @@ class ListEvaluation implements ListInterface, GroupedExportInterface
 | 
			
		||||
        'updatedBy',
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
    private readonly bool $filterStatsByCenters;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private readonly EntityManagerInterface $entityManager,
 | 
			
		||||
        private readonly SocialIssueRender $socialIssueRender,
 | 
			
		||||
        private readonly SocialIssueRepository $socialIssueRepository,
 | 
			
		||||
        private readonly SocialActionRender $socialActionRender,
 | 
			
		||||
        private readonly SocialActionRepository $socialActionRepository,
 | 
			
		||||
        private readonly UserHelper $userHelper,
 | 
			
		||||
        private readonly LabelPersonHelper $personHelper,
 | 
			
		||||
        private readonly DateTimeHelper $dateTimeHelper,
 | 
			
		||||
        private readonly TranslatableStringExportLabelHelper $translatableStringExportLabelHelper,
 | 
			
		||||
        private readonly AggregateStringHelper $aggregateStringHelper,
 | 
			
		||||
        private readonly RollingDateConverterInterface $rollingDateConverter,
 | 
			
		||||
        ParameterBagInterface $parameterBag,
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
 | 
			
		||||
    }
 | 
			
		||||
    public function __construct(private readonly EntityManagerInterface $entityManager, private readonly SocialIssueRender $socialIssueRender, private readonly SocialIssueRepository $socialIssueRepository, private readonly SocialActionRender $socialActionRender, private readonly SocialActionRepository $socialActionRepository, private readonly UserHelper $userHelper, private readonly LabelPersonHelper $personHelper, private readonly DateTimeHelper $dateTimeHelper, private readonly TranslatableStringExportLabelHelper $translatableStringExportLabelHelper, private readonly AggregateStringHelper $aggregateStringHelper, private readonly RollingDateConverterInterface $rollingDateConverter) {}
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder)
 | 
			
		||||
    {
 | 
			
		||||
@@ -208,19 +190,15 @@ class ListEvaluation implements ListInterface, GroupedExportInterface
 | 
			
		||||
            ->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL')
 | 
			
		||||
            // get participants at the given date
 | 
			
		||||
            ->andWhere('acppart.startDate <= :calc_date AND (acppart.endDate > :calc_date OR acppart.endDate IS NULL)')
 | 
			
		||||
            ->setParameter('calc_date', $this->rollingDateConverter->convert($data['calc_date']));
 | 
			
		||||
 | 
			
		||||
        if ($this->filterStatsByCenters) {
 | 
			
		||||
            $qb
 | 
			
		||||
                ->andWhere(
 | 
			
		||||
                    $qb->expr()->exists(
 | 
			
		||||
                        'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
 | 
			
		||||
            ->andWhere(
 | 
			
		||||
                $qb->expr()->exists(
 | 
			
		||||
                    'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
 | 
			
		||||
                        AND acl_count_person_history.center IN (:authorized_centers)
 | 
			
		||||
                        '
 | 
			
		||||
                    )
 | 
			
		||||
                )
 | 
			
		||||
                ->setParameter('authorized_centers', $centers);
 | 
			
		||||
        }
 | 
			
		||||
            )
 | 
			
		||||
            ->setParameter('authorized_centers', $centers)
 | 
			
		||||
            ->setParameter('calc_date', $this->rollingDateConverter->convert($data['calc_date']));
 | 
			
		||||
 | 
			
		||||
        AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -29,7 +29,6 @@ use Chill\PersonBundle\Security\Authorization\HouseholdVoter;
 | 
			
		||||
use Doctrine\ORM\AbstractQuery;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
use Doctrine\ORM\QueryBuilder;
 | 
			
		||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface
 | 
			
		||||
@@ -43,18 +42,14 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface
 | 
			
		||||
        'compositionComment',
 | 
			
		||||
        'compositionType',
 | 
			
		||||
    ];
 | 
			
		||||
    private readonly bool $filterStatsByCenters;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private readonly ExportAddressHelper $addressHelper,
 | 
			
		||||
        private readonly AggregateStringHelper $aggregateStringHelper,
 | 
			
		||||
        private readonly EntityManagerInterface $entityManager,
 | 
			
		||||
        private readonly RollingDateConverterInterface $rollingDateConverter,
 | 
			
		||||
        private readonly TranslatableStringExportLabelHelper $translatableStringHelper,
 | 
			
		||||
        ParameterBagInterface $parameterBag,
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
 | 
			
		||||
    }
 | 
			
		||||
        private readonly TranslatableStringExportLabelHelper $translatableStringHelper
 | 
			
		||||
    ) {}
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder)
 | 
			
		||||
    {
 | 
			
		||||
@@ -143,20 +138,16 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface
 | 
			
		||||
            ->join('person.accompanyingPeriodParticipations', 'acppart')
 | 
			
		||||
            ->join('acppart.accompanyingPeriod', 'acp')
 | 
			
		||||
            ->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL')
 | 
			
		||||
            ->andWhere('hmember.startDate <= :count_household_at_date AND (hmember.endDate IS NULL OR hmember.endDate > :count_household_at_date)')
 | 
			
		||||
            ->setParameter('count_household_at_date', $this->rollingDateConverter->convert($data['calc_date']));
 | 
			
		||||
 | 
			
		||||
        if ($this->filterStatsByCenters) {
 | 
			
		||||
            $qb
 | 
			
		||||
                ->andWhere(
 | 
			
		||||
                    $qb->expr()->exists(
 | 
			
		||||
                        'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
 | 
			
		||||
            ->andWhere(
 | 
			
		||||
                $qb->expr()->exists(
 | 
			
		||||
                    'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
 | 
			
		||||
                    AND acl_count_person_history.center IN (:authorized_centers)
 | 
			
		||||
                    '
 | 
			
		||||
                    )
 | 
			
		||||
                )
 | 
			
		||||
                ->setParameter('authorized_centers', $centers);
 | 
			
		||||
        }
 | 
			
		||||
            )
 | 
			
		||||
            ->andWhere('hmember.startDate <= :count_household_at_date AND (hmember.endDate IS NULL OR hmember.endDate > :count_household_at_date)')
 | 
			
		||||
            ->setParameter('authorized_centers', $centers)
 | 
			
		||||
            ->setParameter('count_household_at_date', $this->rollingDateConverter->convert($data['calc_date']));
 | 
			
		||||
 | 
			
		||||
        $this->addSelectClauses($qb, $this->rollingDateConverter->convert($data['calc_date']));
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -29,7 +29,6 @@ use DateTimeImmutable;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
use Doctrine\ORM\Query;
 | 
			
		||||
use PhpOffice\PhpSpreadsheet\Shared\Date;
 | 
			
		||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
 | 
			
		||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
use Symfony\Component\Validator\Constraints\Callback;
 | 
			
		||||
@@ -41,18 +40,14 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
 | 
			
		||||
class ListPerson implements ExportElementValidatedInterface, ListInterface, GroupedExportInterface
 | 
			
		||||
{
 | 
			
		||||
    private array $slugs = [];
 | 
			
		||||
    private readonly bool $filterStatsByCenters;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private readonly ExportAddressHelper $addressHelper,
 | 
			
		||||
        private readonly CustomFieldProvider $customFieldProvider,
 | 
			
		||||
        private readonly ListPersonHelper $listPersonHelper,
 | 
			
		||||
        private readonly EntityManagerInterface $entityManager,
 | 
			
		||||
        private readonly TranslatableStringHelper $translatableStringHelper,
 | 
			
		||||
        ParameterBagInterface $parameterBag,
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
 | 
			
		||||
    }
 | 
			
		||||
        private readonly TranslatableStringHelper $translatableStringHelper
 | 
			
		||||
    ) {}
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder)
 | 
			
		||||
    {
 | 
			
		||||
@@ -189,18 +184,16 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou
 | 
			
		||||
            throw new \Doctrine\DBAL\Exception\InvalidArgumentException('any fields have been checked');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $qb = $this->entityManager->createQueryBuilder()
 | 
			
		||||
            ->from(Person::class, 'person');
 | 
			
		||||
        $qb = $this->entityManager->createQueryBuilder();
 | 
			
		||||
 | 
			
		||||
        if ($this->filterStatsByCenters) {
 | 
			
		||||
            $qb
 | 
			
		||||
                ->andWhere(
 | 
			
		||||
                    $qb->expr()->exists(
 | 
			
		||||
                        'SELECT 1 FROM '.Person\PersonCenterHistory::class.' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
 | 
			
		||||
                    )
 | 
			
		||||
        $qb
 | 
			
		||||
            ->from(Person::class, 'person')
 | 
			
		||||
            ->andWhere(
 | 
			
		||||
                $qb->expr()->exists(
 | 
			
		||||
                    'SELECT 1 FROM '.Person\PersonCenterHistory::class.' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
 | 
			
		||||
                )
 | 
			
		||||
                ->setParameter('authorized_centers', $centers);
 | 
			
		||||
        }
 | 
			
		||||
            )
 | 
			
		||||
            ->setParameter('authorized_centers', $centers);
 | 
			
		||||
 | 
			
		||||
        $fields = $data['fields'];
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -17,9 +17,7 @@ use Chill\MainBundle\Export\FormatterInterface;
 | 
			
		||||
use Chill\MainBundle\Export\GroupedExportInterface;
 | 
			
		||||
use Chill\MainBundle\Export\Helper\ExportAddressHelper;
 | 
			
		||||
use Chill\MainBundle\Export\ListInterface;
 | 
			
		||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
 | 
			
		||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
 | 
			
		||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
 | 
			
		||||
use Chill\MainBundle\Form\Type\ChillDateType;
 | 
			
		||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
 | 
			
		||||
use Chill\PersonBundle\Entity\Person;
 | 
			
		||||
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
 | 
			
		||||
@@ -29,7 +27,6 @@ use Chill\PersonBundle\Security\Authorization\PersonVoter;
 | 
			
		||||
use DateTimeImmutable;
 | 
			
		||||
use Doctrine\ORM\AbstractQuery;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
 | 
			
		||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
use Symfony\Component\Validator\Constraints\Callback;
 | 
			
		||||
@@ -40,19 +37,9 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
 | 
			
		||||
 *
 | 
			
		||||
 * Details of the accompanying period are not included
 | 
			
		||||
 */
 | 
			
		||||
final readonly class ListPersonHavingAccompanyingPeriod implements ExportElementValidatedInterface, ListInterface, GroupedExportInterface
 | 
			
		||||
class ListPersonHavingAccompanyingPeriod implements ExportElementValidatedInterface, ListInterface, GroupedExportInterface
 | 
			
		||||
{
 | 
			
		||||
    private bool $filterStatsByCenters;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private ExportAddressHelper $addressHelper,
 | 
			
		||||
        private ListPersonHelper $listPersonHelper,
 | 
			
		||||
        private EntityManagerInterface $entityManager,
 | 
			
		||||
        private RollingDateConverterInterface $rollingDateConverter,
 | 
			
		||||
        ParameterBagInterface $parameterBag,
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
 | 
			
		||||
    }
 | 
			
		||||
    public function __construct(private readonly ExportAddressHelper $addressHelper, private readonly ListPersonHelper $listPersonHelper, private readonly EntityManagerInterface $entityManager) {}
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder)
 | 
			
		||||
    {
 | 
			
		||||
@@ -82,9 +69,10 @@ final readonly class ListPersonHavingAccompanyingPeriod implements ExportElement
 | 
			
		||||
            ])],
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
        $builder->add('address_date_rolling', PickRollingDateType::class, [
 | 
			
		||||
        $builder->add('address_date', ChillDateType::class, [
 | 
			
		||||
            'label' => 'Data valid at this date',
 | 
			
		||||
            'help' => 'Data regarding center, addresses, and so on will be computed at this date',
 | 
			
		||||
            'input' => 'datetime_immutable',
 | 
			
		||||
        ]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -92,7 +80,7 @@ final readonly class ListPersonHavingAccompanyingPeriod implements ExportElement
 | 
			
		||||
    {
 | 
			
		||||
        $choices = array_combine(ListPersonHelper::FIELDS, ListPersonHelper::FIELDS);
 | 
			
		||||
 | 
			
		||||
        return ['fields' => array_values($choices), 'address_date_rolling' => new RollingDate(RollingDate::T_TODAY)];
 | 
			
		||||
        return ['fields' => array_values($choices), 'address_date' => new \DateTimeImmutable()];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getAllowedFormattersTypes()
 | 
			
		||||
@@ -174,20 +162,16 @@ final readonly class ListPersonHavingAccompanyingPeriod implements ExportElement
 | 
			
		||||
        $qb->from(Person::class, 'person')
 | 
			
		||||
            ->join('person.accompanyingPeriodParticipations', 'acppart')
 | 
			
		||||
            ->join('acppart.accompanyingPeriod', 'acp')
 | 
			
		||||
            ->andWhere($qb->expr()->neq('acp.step', "'".AccompanyingPeriod::STEP_DRAFT."'"));
 | 
			
		||||
 | 
			
		||||
        if ($this->filterStatsByCenters) {
 | 
			
		||||
            $qb
 | 
			
		||||
                ->andWhere(
 | 
			
		||||
                    $qb->expr()->exists(
 | 
			
		||||
                        'SELECT 1 FROM '.PersonCenterHistory::class.' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
 | 
			
		||||
                    )
 | 
			
		||||
                )->setParameter('authorized_centers', $centers);
 | 
			
		||||
        }
 | 
			
		||||
            ->andWhere($qb->expr()->neq('acp.step', "'".AccompanyingPeriod::STEP_DRAFT."'"))
 | 
			
		||||
            ->andWhere(
 | 
			
		||||
                $qb->expr()->exists(
 | 
			
		||||
                    'SELECT 1 FROM '.PersonCenterHistory::class.' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
 | 
			
		||||
                )
 | 
			
		||||
            )->setParameter('authorized_centers', $centers);
 | 
			
		||||
 | 
			
		||||
        $fields = $data['fields'];
 | 
			
		||||
 | 
			
		||||
        $this->listPersonHelper->addSelect($qb, $fields, $this->rollingDateConverter->convert($data['address_date_rolling']));
 | 
			
		||||
        $this->listPersonHelper->addSelect($qb, $fields, $data['address_date']);
 | 
			
		||||
 | 
			
		||||
        AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -28,7 +28,6 @@ use Chill\PersonBundle\Security\Authorization\PersonVoter;
 | 
			
		||||
use DateTimeImmutable;
 | 
			
		||||
use Doctrine\ORM\AbstractQuery;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -36,17 +35,12 @@ use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 */
 | 
			
		||||
final readonly class ListPersonWithAccompanyingPeriodDetails implements ListInterface, GroupedExportInterface
 | 
			
		||||
{
 | 
			
		||||
    private bool $filterStatsByCenters;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private ListPersonHelper $listPersonHelper,
 | 
			
		||||
        private ListAccompanyingPeriodHelper $listAccompanyingPeriodHelper,
 | 
			
		||||
        private EntityManagerInterface $entityManager,
 | 
			
		||||
        private RollingDateConverterInterface $rollingDateConverter,
 | 
			
		||||
        ParameterBagInterface $parameterBag,
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
 | 
			
		||||
    }
 | 
			
		||||
    ) {}
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder)
 | 
			
		||||
    {
 | 
			
		||||
@@ -120,16 +114,12 @@ final readonly class ListPersonWithAccompanyingPeriodDetails implements ListInte
 | 
			
		||||
        $qb->from(Person::class, 'person')
 | 
			
		||||
            ->join('person.accompanyingPeriodParticipations', 'acppart')
 | 
			
		||||
            ->join('acppart.accompanyingPeriod', 'acp')
 | 
			
		||||
            ->andWhere($qb->expr()->neq('acp.step', "'".AccompanyingPeriod::STEP_DRAFT."'"));
 | 
			
		||||
 | 
			
		||||
        if ($this->filterStatsByCenters) {
 | 
			
		||||
            $qb
 | 
			
		||||
                ->andWhere(
 | 
			
		||||
                    $qb->expr()->exists(
 | 
			
		||||
                        'SELECT 1 FROM '.PersonCenterHistory::class.' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
 | 
			
		||||
                    )
 | 
			
		||||
                )->setParameter('authorized_centers', $centers);
 | 
			
		||||
        }
 | 
			
		||||
            ->andWhere($qb->expr()->neq('acp.step', "'".AccompanyingPeriod::STEP_DRAFT."'"))
 | 
			
		||||
            ->andWhere(
 | 
			
		||||
                $qb->expr()->exists(
 | 
			
		||||
                    'SELECT 1 FROM '.PersonCenterHistory::class.' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
 | 
			
		||||
                )
 | 
			
		||||
            )->setParameter('authorized_centers', $centers);
 | 
			
		||||
 | 
			
		||||
        $this->listPersonHelper->addSelect($qb, ListPersonHelper::FIELDS, $this->rollingDateConverter->convert($data['address_date']));
 | 
			
		||||
        $this->listAccompanyingPeriodHelper->addSelectClauses($qb, $this->rollingDateConverter->convert($data['address_date']));
 | 
			
		||||
 
 | 
			
		||||
@@ -15,9 +15,7 @@ use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
 | 
			
		||||
use Chill\MainBundle\Export\ExportInterface;
 | 
			
		||||
use Chill\MainBundle\Export\FormatterInterface;
 | 
			
		||||
use Chill\MainBundle\Export\GroupedExportInterface;
 | 
			
		||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
 | 
			
		||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
 | 
			
		||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
 | 
			
		||||
use Chill\MainBundle\Form\Type\ChillDateType;
 | 
			
		||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
 | 
			
		||||
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
 | 
			
		||||
use Chill\PersonBundle\Export\Declarations;
 | 
			
		||||
@@ -26,34 +24,28 @@ use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
use Doctrine\ORM\EntityRepository;
 | 
			
		||||
use Doctrine\ORM\Query;
 | 
			
		||||
use Doctrine\ORM\QueryBuilder;
 | 
			
		||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
final readonly class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportInterface
 | 
			
		||||
class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportInterface
 | 
			
		||||
{
 | 
			
		||||
    private readonly EntityRepository $repository;
 | 
			
		||||
 | 
			
		||||
    private bool $filterStatsByCenters;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        EntityManagerInterface $em,
 | 
			
		||||
        private RollingDateConverterInterface $rollingDateConverter,
 | 
			
		||||
        ParameterBagInterface $parameterBag,
 | 
			
		||||
    ) {
 | 
			
		||||
        $this->repository = $em->getRepository(AccompanyingPeriod::class);
 | 
			
		||||
        $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder): void
 | 
			
		||||
    {
 | 
			
		||||
        $builder->add('closingdate_rolling', PickRollingDateType::class, [
 | 
			
		||||
        $builder->add('closingdate', ChillDateType::class, [
 | 
			
		||||
            'label' => 'Closingdate to apply',
 | 
			
		||||
        ]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getFormDefaultData(): array
 | 
			
		||||
    {
 | 
			
		||||
        return ['closingdate_rolling' => new RollingDate(RollingDate::T_TODAY)];
 | 
			
		||||
        return ['closingdate' => new \DateTime('now')];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getAllowedFormattersTypes(): array
 | 
			
		||||
@@ -126,24 +118,20 @@ final readonly class StatAccompanyingCourseDuration implements ExportInterface,
 | 
			
		||||
            ->addSelect('COUNT(DISTINCT acppart.id) AS count_acppart_export_result')
 | 
			
		||||
            ->addSelect('COUNT(DISTINCT person.id) AS count_pers_export_result')
 | 
			
		||||
            ->addSelect('COUNT(DISTINCT acp.id) AS count_acp_export_result')
 | 
			
		||||
            ->setParameter('force_closingDate', $this->rollingDateConverter->convert($data['closingdate_rolling']))
 | 
			
		||||
            ->setParameter('force_closingDate', $data['closingdate'])
 | 
			
		||||
            ->leftJoin('acp.participations', 'acppart')
 | 
			
		||||
            ->leftJoin('acppart.person', 'person')
 | 
			
		||||
            ->andWhere('acp.step != :count_acp_step')
 | 
			
		||||
            ->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL')
 | 
			
		||||
            ->setParameter('count_acp_step', AccompanyingPeriod::STEP_DRAFT);
 | 
			
		||||
 | 
			
		||||
        if ($this->filterStatsByCenters) {
 | 
			
		||||
            $qb
 | 
			
		||||
                ->andWhere(
 | 
			
		||||
                    $qb->expr()->exists(
 | 
			
		||||
                        'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
 | 
			
		||||
            ->andWhere(
 | 
			
		||||
                $qb->expr()->exists(
 | 
			
		||||
                    'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
 | 
			
		||||
                    AND acl_count_person_history.center IN (:authorized_centers)
 | 
			
		||||
                    '
 | 
			
		||||
                    )
 | 
			
		||||
                )
 | 
			
		||||
                ->setParameter('authorized_centers', $centers);
 | 
			
		||||
        }
 | 
			
		||||
            )
 | 
			
		||||
            ->setParameter('count_acp_step', AccompanyingPeriod::STEP_DRAFT)
 | 
			
		||||
            ->setParameter('authorized_centers', $centers);
 | 
			
		||||
 | 
			
		||||
        AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,78 +0,0 @@
 | 
			
		||||
<?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\AccompanyingCourseFilters;
 | 
			
		||||
 | 
			
		||||
use Chill\MainBundle\Export\FilterInterface;
 | 
			
		||||
use Chill\PersonBundle\Export\Declarations;
 | 
			
		||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
 | 
			
		||||
use Chill\ThirdPartyBundle\Form\Type\PickThirdpartyDynamicType;
 | 
			
		||||
use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender;
 | 
			
		||||
use Doctrine\ORM\QueryBuilder;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
final readonly class HandlingThirdPartyFilter implements FilterInterface
 | 
			
		||||
{
 | 
			
		||||
    private const PREFIX = 'acpw_handling_3party_filter';
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private ThirdPartyRender $thirdPartyRender,
 | 
			
		||||
    ) {}
 | 
			
		||||
 | 
			
		||||
    public function getTitle()
 | 
			
		||||
    {
 | 
			
		||||
        return 'export.filter.work.by_handling3party.title';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder)
 | 
			
		||||
    {
 | 
			
		||||
        $builder->add('handling_3parties', PickThirdpartyDynamicType::class, [
 | 
			
		||||
            'label' => 'export.filter.work.by_handling3party.pick_3parties',
 | 
			
		||||
            'multiple' => true,
 | 
			
		||||
        ]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getFormDefaultData(): array
 | 
			
		||||
    {
 | 
			
		||||
        return ['handling_3parties' => []];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function describeAction($data, $format = 'string')
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
            'export.filter.work.by_handling3party.Only 3 parties %3parties%',
 | 
			
		||||
            [
 | 
			
		||||
                '%3parties%' => implode(
 | 
			
		||||
                    ', ',
 | 
			
		||||
                    array_map(fn (ThirdParty $thirdParty) => $this->thirdPartyRender->renderString($thirdParty, []), $data['handling_3parties'])
 | 
			
		||||
                ),
 | 
			
		||||
            ],
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function addRole(): ?string
 | 
			
		||||
    {
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function alterQuery(QueryBuilder $qb, $data)
 | 
			
		||||
    {
 | 
			
		||||
        $p = self::PREFIX;
 | 
			
		||||
 | 
			
		||||
        $qb->andWhere("acpw.handlingThierParty IN (:{$p}_3ps)");
 | 
			
		||||
        $qb->setParameter("{$p}_3ps", $data['handling_3parties']);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function applyOn()
 | 
			
		||||
    {
 | 
			
		||||
        return Declarations::SOCIAL_WORK_ACTION_TYPE;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -61,7 +61,7 @@ class StepFilterOnDate implements FilterInterface
 | 
			
		||||
                    $qb->expr()->lte(self::A.'.startDate', ':'.self::P),
 | 
			
		||||
                    $qb->expr()->orX(
 | 
			
		||||
                        $qb->expr()->isNull(self::A.'.endDate'),
 | 
			
		||||
                        $qb->expr()->gt(self::A.'.endDate', ':'.self::P)
 | 
			
		||||
                        $qb->expr()->lt(self::A.'.endDate', ':'.self::P)
 | 
			
		||||
                    )
 | 
			
		||||
                )
 | 
			
		||||
            )
 | 
			
		||||
 
 | 
			
		||||
@@ -28,7 +28,7 @@ use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 *
 | 
			
		||||
 * Makes use of AccompanyingPeriodInfo
 | 
			
		||||
 */
 | 
			
		||||
final readonly class UserWorkingOnCourseFilter implements FilterInterface
 | 
			
		||||
readonly class UserWorkingOnCourseFilter implements FilterInterface
 | 
			
		||||
{
 | 
			
		||||
    public function __construct(
 | 
			
		||||
        private UserRender $userRender,
 | 
			
		||||
 
 | 
			
		||||
@@ -66,7 +66,7 @@ class AddressRefStatusFilter implements \Chill\MainBundle\Export\FilterInterface
 | 
			
		||||
    {
 | 
			
		||||
        $builder
 | 
			
		||||
            ->add('date_calc', PickRollingDateType::class, [
 | 
			
		||||
                'label' => 'export.filter.person.by_address_ref_status.Address at date',
 | 
			
		||||
                'label' => 'Compute address at date',
 | 
			
		||||
                'required' => true,
 | 
			
		||||
            ])
 | 
			
		||||
            ->add('ref_statuses', ChoiceType::class, [
 | 
			
		||||
 
 | 
			
		||||
@@ -18,21 +18,6 @@ class LabelPersonHelper
 | 
			
		||||
{
 | 
			
		||||
    public function __construct(private readonly PersonRepository $personRepository, private readonly PersonRenderInterface $personRender) {}
 | 
			
		||||
 | 
			
		||||
    public function getLabel(string $key, array $values, string $header): callable
 | 
			
		||||
    {
 | 
			
		||||
        return function (null|int|string $value) use ($header): string {
 | 
			
		||||
            if ('_header' === $value) {
 | 
			
		||||
                return $header;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if ('' === $value || null === $value || null === $person = $this->personRepository->find($value)) {
 | 
			
		||||
                return '';
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return $this->personRender->renderString($person, []);
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getLabelMulti(string $key, array $values, string $header): callable
 | 
			
		||||
    {
 | 
			
		||||
        return function ($value) use ($header) {
 | 
			
		||||
 
 | 
			
		||||
@@ -112,4 +112,17 @@ final class AccompanyingPeriodRepository implements ObjectRepository
 | 
			
		||||
 | 
			
		||||
        return $qb;
 | 
			
		||||
    }
 | 
			
		||||
    public function countByUserGroupedByMonth(User $user): array
 | 
			
		||||
    {
 | 
			
		||||
        $qb = $this->createQueryBuilder('a');
 | 
			
		||||
 | 
			
		||||
        $qb->select()
 | 
			
		||||
            ->addSelect('COUNT(a.id) AS count')
 | 
			
		||||
            ->andWhere('a.user = :user')
 | 
			
		||||
            ->setParameter('user', $user)
 | 
			
		||||
            ->groupBy('month')
 | 
			
		||||
            ->orderBy('month', 'ASC');
 | 
			
		||||
 | 
			
		||||
        return $qb->getQuery()->getResult();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,66 +0,0 @@
 | 
			
		||||
<?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\Tests\Export\Aggregator\AccompanyingCourseAggregators;
 | 
			
		||||
 | 
			
		||||
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
 | 
			
		||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
 | 
			
		||||
use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ClosingDateAggregator;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @internal
 | 
			
		||||
 *
 | 
			
		||||
 * @coversNothing
 | 
			
		||||
 */
 | 
			
		||||
class ClosingDateAggregatorTest extends AbstractAggregatorTest
 | 
			
		||||
{
 | 
			
		||||
    private static ClosingDateAggregator $closingDateAggregator;
 | 
			
		||||
 | 
			
		||||
    private static EntityManagerInterface $entityManager;
 | 
			
		||||
 | 
			
		||||
    public static function setUpBeforeClass(): void
 | 
			
		||||
    {
 | 
			
		||||
        parent::setUpBeforeClass();
 | 
			
		||||
        self::bootKernel();
 | 
			
		||||
 | 
			
		||||
        self::$closingDateAggregator = self::$container->get(ClosingDateAggregator::class);
 | 
			
		||||
        self::$entityManager = self::$container->get(EntityManagerInterface::class);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getAggregator()
 | 
			
		||||
    {
 | 
			
		||||
        return self::$closingDateAggregator;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getFormData()
 | 
			
		||||
    {
 | 
			
		||||
        yield ['frequency' => 'YYYY'];
 | 
			
		||||
        yield ['frequency' => 'YYYY-MM'];
 | 
			
		||||
        yield ['frequency' => 'YYYY-IV'];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getQueryBuilders()
 | 
			
		||||
    {
 | 
			
		||||
        self::bootKernel();
 | 
			
		||||
        self::$entityManager = self::$container->get(EntityManagerInterface::class);
 | 
			
		||||
 | 
			
		||||
        $data = [
 | 
			
		||||
            self::$entityManager->createQueryBuilder()
 | 
			
		||||
                ->select('count(acp.id)')
 | 
			
		||||
                ->from(AccompanyingPeriod::class, 'acp'),
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        self::ensureKernelShutdown();
 | 
			
		||||
 | 
			
		||||
        return $data;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,66 +0,0 @@
 | 
			
		||||
<?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\Tests\Export\Aggregator\AccompanyingCourseAggregators;
 | 
			
		||||
 | 
			
		||||
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
 | 
			
		||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
 | 
			
		||||
use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\OpeningDateAggregator;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @internal
 | 
			
		||||
 *
 | 
			
		||||
 * @coversNothing
 | 
			
		||||
 */
 | 
			
		||||
class OpeningDateAggregatorTest extends AbstractAggregatorTest
 | 
			
		||||
{
 | 
			
		||||
    private static OpeningDateAggregator $openingDateAggregator;
 | 
			
		||||
 | 
			
		||||
    private static EntityManagerInterface $entityManager;
 | 
			
		||||
 | 
			
		||||
    public static function setUpBeforeClass(): void
 | 
			
		||||
    {
 | 
			
		||||
        parent::setUpBeforeClass();
 | 
			
		||||
        self::bootKernel();
 | 
			
		||||
 | 
			
		||||
        self::$openingDateAggregator = self::$container->get(OpeningDateAggregator::class);
 | 
			
		||||
        self::$entityManager = self::$container->get(EntityManagerInterface::class);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getAggregator()
 | 
			
		||||
    {
 | 
			
		||||
        return self::$openingDateAggregator;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getFormData()
 | 
			
		||||
    {
 | 
			
		||||
        yield ['frequency' => 'YYYY'];
 | 
			
		||||
        yield ['frequency' => 'YYYY-MM'];
 | 
			
		||||
        yield ['frequency' => 'YYYY-IV'];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getQueryBuilders()
 | 
			
		||||
    {
 | 
			
		||||
        self::bootKernel();
 | 
			
		||||
        self::$entityManager = self::$container->get(EntityManagerInterface::class);
 | 
			
		||||
 | 
			
		||||
        $data = [
 | 
			
		||||
            self::$entityManager->createQueryBuilder()
 | 
			
		||||
                ->select('count(acp.id)')
 | 
			
		||||
                ->from(AccompanyingPeriod::class, 'acp'),
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        self::ensureKernelShutdown();
 | 
			
		||||
 | 
			
		||||
        return $data;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,60 +0,0 @@
 | 
			
		||||
<?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\Tests\Export\Aggregator\SocialWorkAggregators;
 | 
			
		||||
 | 
			
		||||
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
 | 
			
		||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
 | 
			
		||||
use Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\HandlingThirdPartyAggregator;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @internal
 | 
			
		||||
 *
 | 
			
		||||
 * @coversNothing
 | 
			
		||||
 */
 | 
			
		||||
class HandlingThirdPartyAggregatorTest extends AbstractAggregatorTest
 | 
			
		||||
{
 | 
			
		||||
    private static HandlingThirdPartyAggregator $handlingThirdPartyAggregator;
 | 
			
		||||
 | 
			
		||||
    public static function setUpBeforeClass(): void
 | 
			
		||||
    {
 | 
			
		||||
        parent::setUpBeforeClass();
 | 
			
		||||
        self::bootKernel();
 | 
			
		||||
        self::$handlingThirdPartyAggregator = self::$container->get(HandlingThirdPartyAggregator::class);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getAggregator()
 | 
			
		||||
    {
 | 
			
		||||
        return self::$handlingThirdPartyAggregator;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getFormData()
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
            [],
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getQueryBuilders()
 | 
			
		||||
    {
 | 
			
		||||
        self::bootKernel();
 | 
			
		||||
 | 
			
		||||
        $em = self::$container
 | 
			
		||||
            ->get(EntityManagerInterface::class);
 | 
			
		||||
 | 
			
		||||
        return [
 | 
			
		||||
            $em->createQueryBuilder()
 | 
			
		||||
                ->select('count(acpw.id)')
 | 
			
		||||
                ->from(AccompanyingPeriodWork::class, 'acpw'),
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user