diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php index 6d2c0c6f6..b1d6af4b4 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php @@ -18,6 +18,7 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; @@ -26,15 +27,12 @@ use LogicException; class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface { - /** - * @var EntityManagerInterface - */ - protected $entityManager; + protected EntityRepository $repository; public function __construct( EntityManagerInterface $em ) { - $this->entityManager = $em; + $this->repository = $em->getRepository(AccompanyingPeriod::class); } public function buildForm(FormBuilderInterface $builder): void @@ -88,12 +86,9 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder { - $qb = $this->entityManager->createQueryBuilder(); - $expr = $qb->expr(); + $qb = $this->repository->createQueryBuilder('acp'); - $qb->select('COUNT(acp.id) AS export_result') - ->from('ChillPersonBundle:AccompanyingPeriod', 'acp') - ; + $qb->select('COUNT(acp.id) AS export_result'); return $qb; } @@ -105,7 +100,10 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface public function supportsModifiers(): array { - return [Declarations::ACP_TYPE, Declarations::ACP_SHARED]; + return [ + Declarations::ACP_TYPE, + Declarations::ACP_SHARED + ]; } public function getGroup(): string diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php index 98b73c398..3c7a0e319 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php @@ -17,12 +17,12 @@ use Symfony\Component\Security\Core\Role\Role; class CountEvaluation implements ExportInterface, GroupedExportInterface { - private EntityRepository $acpRepository; + private EntityRepository $repository; public function __construct( EntityManagerInterface $em ) { - $this->acpRepository = $em->getRepository(AccompanyingPeriod::class); + $this->repository = $em->getRepository(AccompanyingPeriod::class); } /** @@ -103,7 +103,7 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface */ public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $qb = $this->acpRepository->createQueryBuilder('acp') + $qb = $this->repository->createQueryBuilder('acp') ->join('acp.works', 'acpw') ->join('acpw.accompanyingPeriodWorkEvaluations', 'eval') ; diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php index 5bc333e2a..9767c17ed 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountHousehold.php @@ -16,12 +16,12 @@ use Symfony\Component\Security\Core\Role\Role; class CountHousehold implements ExportInterface, GroupedExportInterface { - private EntityRepository $acpRepository; + private EntityRepository $repository; public function __construct( EntityManagerInterface $em ) { - $this->acpRepository = $em->getRepository(AccompanyingPeriod::class); + $this->repository = $em->getRepository(AccompanyingPeriod::class); } /** @@ -102,7 +102,7 @@ class CountHousehold implements ExportInterface, GroupedExportInterface */ public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { - $qb = $this->acpRepository->createQueryBuilder('acp') + $qb = $this->repository->createQueryBuilder('acp') ->join('acp.participations', 'acppart') ->join('acppart.person', 'person') ->join('person.householdParticipations', 'householdmember') diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountSocialWorkActions.php b/src/Bundle/ChillPersonBundle/Export/Export/CountSocialWorkActions.php index 7cba36904..bad952743 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountSocialWorkActions.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountSocialWorkActions.php @@ -14,9 +14,11 @@ namespace Chill\PersonBundle\Export\Export; use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Declarations; -use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; +use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; @@ -25,11 +27,12 @@ use Symfony\Component\Security\Core\Role\Role; class CountSocialWorkActions implements ExportInterface, GroupedExportInterface { - protected AccompanyingPeriodWorkRepository $socialActionRepository; + protected EntityRepository $repository; - public function __construct(AccompanyingPeriodWorkRepository $socialActionRepository) - { - $this->socialActionRepository = $socialActionRepository; + public function __construct( + EntityManagerInterface $em + ) { + $this->repository = $em->getRepository(AccompanyingPeriod::class); } public function buildForm(FormBuilderInterface $builder): void @@ -54,7 +57,7 @@ class CountSocialWorkActions implements ExportInterface, GroupedExportInterface public function getLabels($key, array $values, $data) { - if ('export_count_social_work_actions' !== $key) { + if ('export_result' !== $key) { throw new LogicException("the key {$key} is not used by this export"); } @@ -68,7 +71,7 @@ class CountSocialWorkActions implements ExportInterface, GroupedExportInterface public function getQueryKeys($data): array { - return ['export_count_social_work_actions']; + return ['export_result']; } public function getResult($qb, $data) @@ -83,10 +86,11 @@ class CountSocialWorkActions implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder { - $qb = $this - ->socialActionRepository - ->createQueryBuilder('acpw') - ->select('COUNT(acpw.id) as export_count_social_work_actions'); + $qb = $this->repository->createQueryBuilder('acp') + ->join('acp.works', 'acpw') + ; + + $qb->select('COUNT(acpw.id) as export_result'); return $qb; } @@ -99,7 +103,10 @@ class CountSocialWorkActions implements ExportInterface, GroupedExportInterface public function supportsModifiers(): array { - return [Declarations::SOCIAL_WORK_ACTION_TYPE, Declarations::ACP_SHARED]; + return [ + Declarations::SOCIAL_WORK_ACTION_TYPE, + Declarations::ACP_SHARED + ]; } public function getGroup(): string diff --git a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php index 8747c288a..417411f98 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php @@ -15,9 +15,11 @@ use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; use Chill\MainBundle\Form\Type\ChillDateType; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Declarations; -use Chill\PersonBundle\Repository\AccompanyingPeriodRepository; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; +use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; @@ -26,15 +28,12 @@ use Symfony\Component\Security\Core\Role\Role; class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportInterface { - private AccompanyingPeriodRepository $periodRepository; + private EntityRepository $repository; - /** - * @param AccompanyingPeriodRepository $periodRepository - */ public function __construct( - AccompanyingPeriodRepository $periodRepository + EntityManagerInterface $em ) { - $this->periodRepository = $periodRepository; + $this->repository = $em->getRepository(AccompanyingPeriod::class); } /** @@ -118,10 +117,7 @@ class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportIn */ public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder { - $qb = $this->periodRepository->createQueryBuilder('acp'); - $expr = $qb->expr(); - - $force_closingdate = $data['closingdate']; // parameter from buildForm + $qb = $this->repository->createQueryBuilder('acp'); $qb ->select('AVG( @@ -131,7 +127,7 @@ class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportIn ELSE :force_closingDate END ) - acp.openingDate ) AS export_result') - ->setParameter('force_closingDate', $force_closingdate) + ->setParameter('force_closingDate', $data['closingdate']) ; return $qb; @@ -150,7 +146,9 @@ class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportIn */ public function supportsModifiers(): array { - return [Declarations::ACP_TYPE]; + return [ + Declarations::ACP_TYPE + ]; } public function getGroup(): string