mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
Features: [export] Apply person filters and aggreators on Count Social Works export
This commit is contained in:
parent
8e44f20535
commit
61f44396c5
@ -15,12 +15,10 @@ use Chill\MainBundle\Export\ExportInterface;
|
|||||||
use Chill\MainBundle\Export\FormatterInterface;
|
use Chill\MainBundle\Export\FormatterInterface;
|
||||||
use Chill\MainBundle\Export\GroupedExportInterface;
|
use Chill\MainBundle\Export\GroupedExportInterface;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
|
|
||||||
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
|
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\EntityRepository;
|
|
||||||
use Doctrine\ORM\Query;
|
use Doctrine\ORM\Query;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use LogicException;
|
use LogicException;
|
||||||
@ -28,12 +26,12 @@ use Symfony\Component\Form\FormBuilderInterface;
|
|||||||
|
|
||||||
class CountSocialWorkActions implements ExportInterface, GroupedExportInterface
|
class CountSocialWorkActions implements ExportInterface, GroupedExportInterface
|
||||||
{
|
{
|
||||||
protected EntityRepository $repository;
|
protected EntityManagerInterface $em;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
EntityManagerInterface $em
|
EntityManagerInterface $em
|
||||||
) {
|
) {
|
||||||
$this->repository = $em->getRepository(AccompanyingPeriod::class);
|
$this->em = $em;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder): void
|
public function buildForm(FormBuilderInterface $builder): void
|
||||||
@ -96,15 +94,18 @@ class CountSocialWorkActions implements ExportInterface, GroupedExportInterface
|
|||||||
return $el['center'];
|
return $el['center'];
|
||||||
}, $acl);
|
}, $acl);
|
||||||
|
|
||||||
$qb = $this->repository->createQueryBuilder('acp')
|
$qb = $this->em->createQueryBuilder();
|
||||||
->join('acp.works', 'acpw');
|
|
||||||
|
|
||||||
$qb
|
$qb
|
||||||
|
->from(AccompanyingPeriod\AccompanyingPeriodWork::class, 'acpw')
|
||||||
|
->join('acpw.accompanyingPeriod', 'acp')
|
||||||
|
->join('acp.participations', 'acppart')
|
||||||
|
->join('acppart.person', 'person')
|
||||||
|
->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL')
|
||||||
->andWhere(
|
->andWhere(
|
||||||
$qb->expr()->exists(
|
$qb->expr()->exists(
|
||||||
'SELECT 1 FROM ' . AccompanyingPeriodParticipation::class . ' acl_count_part
|
'SELECT 1 FROM ' . PersonCenterHistory::class . ' acl_count_person_history WHERE acl_count_person_history.person = person
|
||||||
JOIN ' . PersonCenterHistory::class . ' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person)
|
AND acl_count_person_history.center IN (:authorized_centers)
|
||||||
WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers)
|
|
||||||
'
|
'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -125,6 +126,7 @@ class CountSocialWorkActions implements ExportInterface, GroupedExportInterface
|
|||||||
return [
|
return [
|
||||||
Declarations::SOCIAL_WORK_ACTION_TYPE,
|
Declarations::SOCIAL_WORK_ACTION_TYPE,
|
||||||
Declarations::ACP_TYPE,
|
Declarations::ACP_TYPE,
|
||||||
|
Declarations::PERSON_TYPE,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user