mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-22 23:53:50 +00:00
Add a filter to list for acpw where current user intervenes
This commit is contained in:
@@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Controller;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
use Chill\MainBundle\Templating\Listing\FilterOrderHelper;
|
||||
use Chill\MainBundle\Templating\Listing\FilterOrderHelperFactoryInterface;
|
||||
@@ -130,6 +131,7 @@ final class AccompanyingCourseWorkController extends AbstractController
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodWorkVoter::SEE, $period);
|
||||
|
||||
$filter = $this->buildFilterOrder($period);
|
||||
$currentUser = $this->getUser();
|
||||
|
||||
$filterData = [
|
||||
'types' => $filter->hasEntityChoice('typesFilter') ? $filter->getEntityChoiceData('typesFilter') : [],
|
||||
@@ -138,6 +140,10 @@ final class AccompanyingCourseWorkController extends AbstractController
|
||||
'user' => $filter->getUserPickerData('userFilter'),
|
||||
];
|
||||
|
||||
if ($filter->getSingleCheckboxData('currentUserFilter') && $currentUser instanceof User) {
|
||||
$filterData['currentUser'] = $currentUser;
|
||||
}
|
||||
|
||||
$totalItems = $this->workRepository->countByAccompanyingPeriod($period);
|
||||
$paginator = $this->paginator->create($totalItems);
|
||||
|
||||
@@ -201,6 +207,8 @@ final class AccompanyingCourseWorkController extends AbstractController
|
||||
->addUserPicker('userFilter', 'accompanying_course_work.user_filter', ['required' => false])
|
||||
;
|
||||
|
||||
$filterBuilder->addSingleCheckbox('currentUserFilter', 'accompanying_course_work.my_actions_filter');
|
||||
|
||||
return $filterBuilder->build();
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -926,7 +926,7 @@ accompanying_course_work:
|
||||
types_filter: Filtrer par type d'action
|
||||
user_filter: Filtrer par intervenant
|
||||
On-going works over total: Actions en cours / Actions du parcours
|
||||
|
||||
my_actions_filter: Mes actions (où j'interviens)
|
||||
|
||||
#
|
||||
Person addresses: Adresses de résidence
|
||||
|
Reference in New Issue
Block a user