diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ByHouseholdCompositionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ByHouseholdCompositionAggregator.php new file mode 100644 index 000000000..e96c8a228 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ByHouseholdCompositionAggregator.php @@ -0,0 +1,131 @@ +householdCompositionTypeRepository = $householdCompositionTypeRepository; + $this->translatableStringHelper = $translatableStringHelper; + } + + public function addRole(): ?string + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data) + { + $p = self::PREFIX; + + if (!in_array('acppart', $qb->getAllAliases(), true)) { + $qb->leftJoin('acp.participations', 'acppart'); + } + + $qb + ->leftJoin( + HouseholdMember::class, + "{$p}_hm", + Join::WITH, + $qb->expr()->orX( + $qb->expr()->isNull("{$p}_hm"), + $qb->expr()->andX( + $qb->expr()->lte("{$p}_hm.startDate", ":{$p}_date"), + $qb->expr()->orX( + $qb->expr()->isNull("{$p}_hm.endDate"), + $qb->expr()->gt("{$p}_hm.endDate", ":{$p}_date") + ) + ) + ) + ) + ->leftJoin( + HouseholdComposition::class, + "{$p}_compo", + Join::WITH, + $qb->expr()->orX( + $qb->expr()->isNull("{$p}_compo"), + $qb->expr()->andX( + $qb->expr()->lte("{$p}_compo.startDate", ":{$p}_date"), + $qb->expr()->orX( + $qb->expr()->isNull("{$p}_compo.endDate"), + $qb->expr()->gt("{$p}_compo.endDate", ":{$p}_date") + ) + ) + ) + ) + ->addSelect("IDENTITY({$p}_compo.householdCompositionType) AS {$p}_select") + ->setParameter("{$p}_date", $data['date_calc']) + ->addGroupBy("{$p}_select"); + } + + public function applyOn() + { + return Declarations::ACP_TYPE; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder->add('date_calc', ChillDateType::class, [ + 'label' => 'export.aggregator.course.by_household_composition.Calc date', + 'input_format' => 'datetime_immutable', + 'data' => new \DateTimeImmutable('now'), + ]); + } + + public function getLabels($key, array $values, $data) + { + return function ($value) { + if ('_header' === $value) { + return 'export.aggregator.course.by_household_composition.Household composition'; + } + + if (null === $value) { + return ''; + } + + if (null === $o = $this->householdCompositionTypeRepository->find($value)) { + return ''; + } + + return $this->translatableStringHelper->localize($o->getLabel()); + }; + } + + public function getQueryKeys($data) + { + return [self::PREFIX . '_select']; + } + + public function getTitle() + { + return 'export.aggregator.course.by_household_composition.Group course by household composition'; + } +} diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml index ba79b4166..04d5d8371 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml @@ -1,262 +1,193 @@ services: + _defaults: + autowire: true + autoconfigure: true ## Indicators chill.person.export.count_accompanyingcourse: class: Chill\PersonBundle\Export\Export\CountAccompanyingCourse - autowire: true - autoconfigure: true tags: - { name: chill.export, alias: count_accompanyingcourse } chill.person.export.avg_accompanyingcourse_duration: class: Chill\PersonBundle\Export\Export\StatAccompanyingCourseDuration - autowire: true - autoconfigure: true tags: - { name: chill.export, alias: avg_accompanyingcourse_duration } ## Filters Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\UserScopeFilter: - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_userscope_filter } Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\UserJobFilter: - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_userjob_filter } chill.person.export.filter_socialissue: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\SocialIssueFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_socialissue_filter } chill.person.export.filter_step: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\StepFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_step_filter } chill.person.export.filter_geographicalunitstat: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\GeographicalUnitStatFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_geographicalunitstat_filter } chill.person.export.filter_socialaction: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\SocialActionFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_socialaction_filter } chill.person.export.filter_evaluation: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\EvaluationFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_evaluation_filter } chill.person.export.filter_origin: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\OriginFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_origin_filter } chill.person.export.filter_closingmotive: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\ClosingMotiveFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_closingmotive_filter } chill.person.export.filter_administrative_location: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\AdministrativeLocationFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_administrative_location_filter } chill.person.export.filter_requestor: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\RequestorFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_requestor_filter } chill.person.export.filter_confidential: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\ConfidentialFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_confidential_filter } chill.person.export.filter_emergency: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\EmergencyFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_emergency_filter } chill.person.export.filter_intensity: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\IntensityFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_intensity_filter } chill.person.export.filter_activeondate: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\ActiveOnDateFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_activeondate_filter } chill.person.export.filter_activeonedaybetweendates: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\ActiveOneDayBetweenDatesFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_activeonedaybetweendates_filter } chill.person.export.filter_referrer: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\ReferrerFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_referrer_filter } chill.person.export.filter_openbetweendates: class: Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\OpenBetweenDatesFilter - autowire: true - autoconfigure: true tags: - { name: chill.export_filter, alias: accompanyingcourse_openbetweendates_filter } ## Aggregators chill.person.export.aggregator_referrer_scope: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ScopeAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_scope_aggregator } chill.person.export.aggregator_referrer_job: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\JobAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_referrer_job_aggregator } chill.person.export.aggregator_socialissue: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\SocialIssueAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_socialissue_aggregator } chill.person.export.aggregator_step: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\StepAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_step_aggregator } chill.person.export.aggregator_geographicalunitstat: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\GeographicalUnitStatAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_geographicalunitstat_aggregator } chill.person.export.aggregator_socialaction: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\SocialActionAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_socialaction_aggregator } chill.person.export.aggregator_evaluation: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\EvaluationAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_evaluation_aggregator } chill.person.export.aggregator_origin: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\OriginAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_origin_aggregator } chill.person.export.aggregator_closingmotive: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ClosingMotiveAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_closingmotive_aggregator } chill.person.export.aggregator_administrative_location: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\AdministrativeLocationAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_administrative_location_aggregator } chill.person.export.aggregator_requestor: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\RequestorAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_requestor_aggregator } chill.person.export.aggregator_confidential: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ConfidentialAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_confidential_aggregator } chill.person.export.aggregator_emergency: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\EmergencyAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_emergency_aggregator } chill.person.export.aggregator_intensity: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\IntensityAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_intensity_aggregator } chill.person.export.aggregator_referrer: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ReferrerAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_referrer_aggregator } chill.person.export.aggregator_duration: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\DurationAggregator - autowire: true - autoconfigure: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_duration_aggregator } Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ReferrerScopeAggregator: - autoconfigure: true - autowire: true tags: - { name: chill.export_aggregator, alias: accompanyingcourse_ref_scope_aggregator } - + Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ByHouseholdCompositionAggregator: + tags: + - { name: chill.export_aggregator, alias: accompanyingcourse_by_household_compo_aggregator } diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index ede58394c..191ef6091 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -955,12 +955,15 @@ export: Group course by referrer's scope: Grouper les parcours par service du référent Computation date for referrer: Date à laquelle le référent était actif Referrer's scope: Service du référent de parcours - duration: day: Durée du parcours en jours week: Durée du parcours en semaines month: Durée du parcours en mois Precision: Unité de la durée + by_household_composition: + Household composition: Composition du ménage + Group course by household composition: Grouper les parcours par composition familiale des ménages des usagers concernés + Calc date: Date de calcul de la composition du ménage filter: course: by_user_scope: