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