mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
exports: fix initiateQuery to always begin from acp entity
This commit is contained in:
parent
b8d187c82b
commit
c45ef7d74f
@ -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
|
||||
|
@ -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')
|
||||
;
|
||||
|
@ -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')
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user