diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php index 5818ef2ba..bf73b4f81 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php @@ -100,6 +100,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac } $loader->load('services/exports_accompanying_course.yaml'); $loader->load('services/exports_social_actions.yaml'); + $loader->load('services/exports_evaluation.yaml'); } /** diff --git a/src/Bundle/ChillPersonBundle/Export/Declarations.php b/src/Bundle/ChillPersonBundle/Export/Declarations.php index 72d702aa2..5a88d988b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Declarations.php +++ b/src/Bundle/ChillPersonBundle/Export/Declarations.php @@ -22,7 +22,9 @@ abstract class Declarations public const ACP_TYPE = 'accompanying_period'; - public const SOCIAL_WORK_ACTION_TYPE = 'social_actions'; - public const ACP_SHARED = 'accompanying_period_shared'; + + public const SOCIAL_WORK_ACTION_TYPE = 'social_actions'; + + public const EVAL_TYPE = 'evaluation'; } diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php new file mode 100644 index 000000000..985a69df6 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php @@ -0,0 +1,135 @@ +evaluationRepository = $em->getRepository(Evaluation::class); + } + + /** + * @inheritDoc + */ + public function buildForm(FormBuilderInterface $builder) + { + // TODO: Implement buildForm() method. + } + + /** + * @inheritDoc + */ + public function getTitle(): string + { + return 'Count evaluations'; + } + + /** + * @inheritDoc + */ + public function getAllowedFormattersTypes(): array + { + return [FormatterInterface::TYPE_TABULAR]; + } + + /** + * @inheritDoc + */ + public function getDescription(): string + { + return 'Count evaluation by various parameters.'; + } + + /** + * @inheritDoc + */ + public function getLabels($key, array $values, $data) + { + if ('export_result' !== $key) { + throw new LogicException("the key {$key} is not used by this export"); + } + + $labels = array_combine($values, $values); + $labels['_header'] = $this->getTitle(); + + return static function ($value) use ($labels) { + return $labels[$value]; + }; + } + + /** + * @inheritDoc + */ + public function getQueryKeys($data): array + { + return ['export_result']; + } + + /** + * @inheritDoc + */ + public function getResult($qb, $data) + { + return $qb->getQuery()->getResult(Query::HYDRATE_SCALAR); + } + + /** + * @inheritDoc + */ + public function getType(): string + { + return Declarations::EVAL_TYPE; + } + + /** + * @inheritDoc + */ + public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) + { + $qb = $this->evaluationRepository->createQueryBuilder('eval'); + + $qb->select('COUNT(eval.id) AS export_result'); + + return $qb; + } + + /** + * @inheritDoc + */ + public function requiredRole() + { + return new Role(AccompanyingPeriodVoter::STATS); + } + + /** + * @inheritDoc + */ + public function supportsModifiers(): array + { + return [ + Declarations::EVAL_TYPE, + ]; + } + + public function getGroup(): string + { + return 'Exports of evaluations'; + } +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php b/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php index 96f669524..a2f3842e7 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountPerson.php @@ -111,7 +111,11 @@ class CountPerson implements ExportInterface, GroupedExportInterface public function supportsModifiers() { - return [Declarations::PERSON_TYPE, Declarations::PERSON_IMPLIED_IN, Declarations::ACP_SHARED]; + return [ + Declarations::PERSON_TYPE, + Declarations::PERSON_IMPLIED_IN, + Declarations::ACP_SHARED + ]; } public function getGroup(): string diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_evaluation.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_evaluation.yaml new file mode 100644 index 000000000..03cd37ee3 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/config/services/exports_evaluation.yaml @@ -0,0 +1,13 @@ +services: + + ## Indicators + chill.person.export.count_evaluation: + class: Chill\PersonBundle\Export\Export\CountEvaluation + autowire: true + autoconfigure: true + tags: + - { name: chill.export, alias: count_evaluation } + + ## Filters + ## Aggregators + \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 9b0d72fbf..750bbf0ba 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -350,6 +350,10 @@ Exports of social work actions: Exports des actions d'accompangement Count social work actions: Nombre d'actions d'accompagnement Count social work actions by various parameters: Compte le nombre d'actions d'accompagnement en fonction de différents filtres. +Exports of evaluations: Exports des évaluations +Count evaluations: Nombre d'évaluations +Count evaluation by various parameters.: Compte le nombre d'évaluations selon différents filtres. + ## filters Filter by person gender: Filtrer par genre de la personne Accepted genders: Genres acceptés