mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
adjust logic for calendar exports linked to person
This commit is contained in:
parent
9c04212c45
commit
fe9ce1a356
@ -104,23 +104,24 @@ class CountCalendars implements ExportInterface, GroupedExportInterface
|
||||
$qb = $this->calendarRepository->createQueryBuilder('cal');
|
||||
|
||||
$qb->select('COUNT(cal.id) AS export_result');
|
||||
$qb->leftJoin('cal.accompanyingPeriod', 'acp');
|
||||
$qb->leftJoin('cal.person', 'person');
|
||||
|
||||
if ($this->filterStatsByCenters) {
|
||||
$qb
|
||||
->andWhere(
|
||||
$qb->expr()->exists(
|
||||
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part
|
||||
JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person)
|
||||
WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers)
|
||||
'
|
||||
->join('person.centerHistory', 'centerHistory')
|
||||
->where(
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->lte('centerHistory.startDate', 'cal.startDate'),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull('centerHistory.endDate'),
|
||||
$qb->expr()->gt('centerHistory.endDate', 'cal.endDate')
|
||||
)
|
||||
)
|
||||
)
|
||||
->setParameter('authorized_centers', $centers);
|
||||
->andWhere($qb->expr()->in('centerHistory.center', ':centers'))
|
||||
->setParameter('centers', $centers);
|
||||
}
|
||||
|
||||
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
|
||||
|
||||
return $qb;
|
||||
}
|
||||
|
||||
|
@ -88,9 +88,23 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface
|
||||
$qb = $this->calendarRepository->createQueryBuilder('cal');
|
||||
|
||||
$qb->select('AVG(cal.endDate - cal.startDate) AS export_result');
|
||||
$qb->join('cal.accompanyingPeriod', 'acp');
|
||||
$qb->join('cal.person', 'person');
|
||||
|
||||
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
|
||||
if ($this->filterStatsByCenters) {
|
||||
$qb
|
||||
->join('person.centerHistory', 'centerHistory')
|
||||
->where(
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->lte('centerHistory.startDate', 'cal.startDate'),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull('centerHistory.endDate'),
|
||||
$qb->expr()->gt('centerHistory.endDate', 'cal.endDate')
|
||||
)
|
||||
)
|
||||
)
|
||||
->andWhere($qb->expr()->in('centerHistory.center', ':centers'))
|
||||
->setParameter('centers', $centers);
|
||||
}
|
||||
|
||||
return $qb;
|
||||
}
|
||||
|
@ -88,9 +88,23 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface
|
||||
$qb = $this->calendarRepository->createQueryBuilder('cal');
|
||||
|
||||
$qb->select('SUM(cal.endDate - cal.startDate) AS export_result');
|
||||
$qb->join('cal.accompanyingPeriod', 'acp');
|
||||
$qb->join('cal.person', 'person');
|
||||
|
||||
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
|
||||
if ($this->filterStatsByCenters) {
|
||||
$qb
|
||||
->join('person.centerHistory', 'centerHistory')
|
||||
->where(
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->lte('centerHistory.startDate', 'cal.startDate'),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull('centerHistory.endDate'),
|
||||
$qb->expr()->gt('centerHistory.endDate', 'cal.endDate')
|
||||
)
|
||||
)
|
||||
)
|
||||
->andWhere($qb->expr()->in('centerHistory.center', ':centers'))
|
||||
->setParameter('centers', $centers);
|
||||
}
|
||||
|
||||
return $qb;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user