mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-02-27 18:49:41 +00:00
Add a filter to list for acpw where current user intervenes
This commit is contained in:
@@ -90,7 +90,7 @@ class AccompanyingPeriodWorkRepository implements ObjectRepository
|
||||
* * first, opened works
|
||||
* * then, closed works
|
||||
*
|
||||
* @param array{types?: list<SocialAction>, user?: list<User>, after?: \DateTimeImmutable|null, before?: \DateTimeImmutable|null} $filters
|
||||
* @param array{types?: list<SocialAction>, user?: list<User>, currentUser?: User, after?: \DateTimeImmutable|null, before?: \DateTimeImmutable|null} $filters
|
||||
*
|
||||
* @return AccompanyingPeriodWork[]
|
||||
*/
|
||||
@@ -101,6 +101,7 @@ class AccompanyingPeriodWorkRepository implements ObjectRepository
|
||||
|
||||
$sql = "SELECT {$rsm} FROM chill_person_accompanying_period_work w
|
||||
LEFT JOIN chill_person_accompanying_period_work_referrer AS rw ON accompanyingperiodwork_id = w.id
|
||||
AND (rw.enddate IS NULL OR rw.enddate > CURRENT_DATE)
|
||||
WHERE accompanyingPeriod_id = :periodId";
|
||||
|
||||
// implement filters
|
||||
@@ -119,6 +120,10 @@ class AccompanyingPeriodWorkRepository implements ObjectRepository
|
||||
.')';
|
||||
}
|
||||
|
||||
if (isset($filters['currentUser'])) {
|
||||
$sql .= ' AND rw.user_id = :currentUser';
|
||||
}
|
||||
|
||||
$sql .= " AND daterange(:after::date, :before::date) && daterange(w.startDate, w.endDate, '[]')";
|
||||
|
||||
// if the start and end date were inversed, we inverse the order to avoid an error
|
||||
@@ -152,6 +157,11 @@ class AccompanyingPeriodWorkRepository implements ObjectRepository
|
||||
->setParameter('limit', $limit, Types::INTEGER)
|
||||
->setParameter('offset', $offset, Types::INTEGER);
|
||||
|
||||
if (isset($filters['currentUser'])) {
|
||||
$nq->setParameter('currentUser', $filters['currentUser']->getId());
|
||||
}
|
||||
|
||||
|
||||
foreach ($filters['user'] as $key => $user) {
|
||||
$nq->setParameter('user_'.$key, $user);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user