mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
Merge remote-tracking branch 'origin/master' into issue120_filter_social_actions
This commit is contained in:
@@ -219,13 +219,13 @@ class AccompanyingPeriodController extends AbstractController
|
||||
]);
|
||||
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
|
||||
|
||||
$accompanyingPeriodsRaw = $this->accompanyingPeriodACLAwareRepository
|
||||
->findByPerson($person, AccompanyingPeriodVoter::SEE);
|
||||
$accompanyingPeriods = $this->accompanyingPeriodACLAwareRepository
|
||||
->findByPerson($person, AccompanyingPeriodVoter::SEE, ["openingDate" => "DESC", "id" => "DESC"]);
|
||||
|
||||
usort($accompanyingPeriodsRaw, static fn ($a, $b) => $b->getOpeningDate() > $a->getOpeningDate());
|
||||
//usort($accompanyingPeriodsRaw, static fn ($a, $b) => $b->getOpeningDate() <=> $a->getOpeningDate());
|
||||
|
||||
// filter visible or not visible
|
||||
$accompanyingPeriods = array_filter($accompanyingPeriodsRaw, fn (AccompanyingPeriod $ap) => $this->isGranted(AccompanyingPeriodVoter::SEE, $ap));
|
||||
//$accompanyingPeriods = array_filter($accompanyingPeriodsRaw, fn (AccompanyingPeriod $ap) => $this->isGranted(AccompanyingPeriodVoter::SEE, $ap));
|
||||
|
||||
return $this->render('@ChillPerson/AccompanyingPeriod/list.html.twig', [
|
||||
'accompanying_periods' => $accompanyingPeriods,
|
||||
|
@@ -78,6 +78,7 @@ class AccompanyingPeriodRegulationListController
|
||||
$form['jobs']->getData(),
|
||||
$form['services']->getData(),
|
||||
$form['locations']->getData(),
|
||||
['openingDate' => 'DESC', 'id' => 'DESC'],
|
||||
$paginator->getItemsPerPage(),
|
||||
$paginator->getCurrentPageFirstItemNumber()
|
||||
);
|
||||
|
@@ -20,6 +20,7 @@ use Chill\MainBundle\Repository\UserRepository;
|
||||
use Chill\MainBundle\Templating\Entity\UserRender;
|
||||
use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepositoryInterface;
|
||||
use Chill\PersonBundle\Repository\AccompanyingPeriodRepository;
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\CallbackTransformer;
|
||||
@@ -30,6 +31,7 @@ use Symfony\Component\Form\FormFactoryInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
@@ -85,8 +87,8 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
||||
*/
|
||||
public function listAction(Request $request): Response
|
||||
{
|
||||
if (!$this->security->isGranted('ROLE_USER') || !$this->security->getUser() instanceof User) {
|
||||
throw new AccessDeniedException();
|
||||
if (!$this->security->isGranted(AccompanyingPeriodVoter::REASSIGN_BULK)) {
|
||||
throw new AccessDeniedHttpException('no right to reassign bulk');
|
||||
}
|
||||
|
||||
$form = $this->buildFilterForm();
|
||||
@@ -96,7 +98,7 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
||||
$userFrom = $form['user']->getData();
|
||||
$postalCodes = $form['postal_code']->getData() instanceof PostalCode ? [$form['postal_code']->getData()] : [];
|
||||
|
||||
$total = $this->accompanyingPeriodACLAwareRepository->countByUserOpenedAccompanyingPeriod($userFrom);
|
||||
$total = $this->accompanyingPeriodACLAwareRepository->countByUserAndPostalCodesOpenedAccompanyingPeriod($userFrom, $postalCodes);
|
||||
$paginator = $this->paginatorFactory->create($total);
|
||||
$paginator->setItemsPerPage(50);
|
||||
$periods = $this->accompanyingPeriodACLAwareRepository
|
||||
|
@@ -983,11 +983,8 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
AccompanyingPeriodVoter::EDIT,
|
||||
AccompanyingPeriodVoter::DELETE,
|
||||
],
|
||||
AccompanyingPeriodVoter::REASSIGN_BULK => [
|
||||
AccompanyingPeriodVoter::CONFIDENTIAL_CRUD,
|
||||
],
|
||||
AccompanyingPeriodVoter::TOGGLE_CONFIDENTIAL => [
|
||||
AccompanyingPeriodVoter::CONFIDENTIAL_CRUD,
|
||||
AccompanyingPeriodVoter::TOGGLE_CONFIDENTIAL_ALL => [
|
||||
AccompanyingPeriodVoter::SEE_CONFIDENTIAL_ALL,
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
|
||||
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Repository\UserJobRepositoryInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodInfo;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
final readonly class JobWorkingOnCourseAggregator implements AggregatorInterface
|
||||
{
|
||||
private const COLUMN_NAME = 'user_working_on_course_job_id';
|
||||
|
||||
public function __construct(
|
||||
private UserJobRepositoryInterface $userJobRepository,
|
||||
private TranslatableStringHelperInterface $translatableStringHelper,
|
||||
) {
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
// nothing to add here
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data): \Closure
|
||||
{
|
||||
return function (int|string|null $jobId) {
|
||||
if (null === $jobId || '' === $jobId) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ('_header' === $jobId) {
|
||||
return 'export.aggregator.course.by_job_working.job';
|
||||
}
|
||||
|
||||
if (null === $job = $this->userJobRepository->find((int) $jobId)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->translatableStringHelper->localize($job->getLabel());
|
||||
};
|
||||
}
|
||||
|
||||
public function getQueryKeys($data)
|
||||
{
|
||||
return [self::COLUMN_NAME];
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return 'export.aggregator.course.by_job_working.title';
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
if (!in_array('acpinfo', $qb->getAllAliases(), true)) {
|
||||
$qb->leftJoin(
|
||||
AccompanyingPeriodInfo::class,
|
||||
'acpinfo',
|
||||
Join::WITH,
|
||||
'acp.id = IDENTITY(acpinfo.accompanyingPeriod)'
|
||||
);
|
||||
}
|
||||
|
||||
if (!in_array('acpinfo_user', $qb->getAllAliases(), true)) {
|
||||
$qb->leftJoin('acpinfo.user', 'acpinfo_user');
|
||||
}
|
||||
|
||||
$qb->addSelect('IDENTITY(acpinfo_user.userJob) AS ' . self::COLUMN_NAME);
|
||||
$qb->addGroupBy(self::COLUMN_NAME);
|
||||
}
|
||||
|
||||
public function applyOn()
|
||||
{
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
}
|
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
|
||||
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
|
||||
use Chill\MainBundle\Repository\UserJobRepositoryInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodInfo;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
final readonly class ScopeWorkingOnCourseAggregator implements AggregatorInterface
|
||||
{
|
||||
private const COLUMN_NAME = 'user_working_on_course_scope_id';
|
||||
|
||||
public function __construct(
|
||||
private ScopeRepositoryInterface $scopeRepository,
|
||||
private TranslatableStringHelperInterface $translatableStringHelper,
|
||||
) {
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
// nothing to add here
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data): \Closure
|
||||
{
|
||||
return function (int|string|null $scopeId) {
|
||||
if (null === $scopeId || '' === $scopeId) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ('_header' === $scopeId) {
|
||||
return 'export.aggregator.course.by_scope_working.scope';
|
||||
}
|
||||
|
||||
if (null === $scope = $this->scopeRepository->find((int) $scopeId)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->translatableStringHelper->localize($scope->getName());
|
||||
};
|
||||
}
|
||||
|
||||
public function getQueryKeys($data)
|
||||
{
|
||||
return [self::COLUMN_NAME];
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return 'export.aggregator.course.by_scope_working.title';
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
if (!in_array('acpinfo', $qb->getAllAliases(), true)) {
|
||||
$qb->leftJoin(
|
||||
AccompanyingPeriodInfo::class,
|
||||
'acpinfo',
|
||||
Join::WITH,
|
||||
'acp.id = IDENTITY(acpinfo.accompanyingPeriod)'
|
||||
);
|
||||
}
|
||||
|
||||
if (!in_array('acpinfo_user', $qb->getAllAliases(), true)) {
|
||||
$qb->leftJoin('acpinfo.user', 'acpinfo_user');
|
||||
}
|
||||
|
||||
$qb->addSelect('IDENTITY(acpinfo_user.mainScope) AS ' . self::COLUMN_NAME);
|
||||
$qb->addGroupBy(self::COLUMN_NAME);
|
||||
}
|
||||
|
||||
public function applyOn()
|
||||
{
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
}
|
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
|
||||
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Repository\UserRepositoryInterface;
|
||||
use Chill\MainBundle\Templating\Entity\UserRender;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodInfo;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
final readonly class UserWorkingOnCourseAggregator implements AggregatorInterface
|
||||
{
|
||||
private const COLUMN_NAME = 'user_working_on_course_user_id';
|
||||
|
||||
public function __construct(
|
||||
private UserRender $userRender,
|
||||
private UserRepositoryInterface $userRepository,
|
||||
) {
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
// nothing to add here
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data): \Closure
|
||||
{
|
||||
return function (int|string|null $userId) {
|
||||
if (null === $userId || '' === $userId) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ('_header' === $userId) {
|
||||
return 'export.aggregator.course.by_user_working.user';
|
||||
}
|
||||
|
||||
if (null === $user = $this->userRepository->find((int) $userId)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->userRender->renderString($user, []);
|
||||
};
|
||||
}
|
||||
|
||||
public function getQueryKeys($data)
|
||||
{
|
||||
return [self::COLUMN_NAME];
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return 'export.aggregator.course.by_user_working.title';
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
if (!in_array('acpinfo', $qb->getAllAliases(), true)) {
|
||||
$qb->leftJoin(
|
||||
AccompanyingPeriodInfo::class,
|
||||
'acpinfo',
|
||||
Join::WITH,
|
||||
'acp.id = IDENTITY(acpinfo.accompanyingPeriod)'
|
||||
);
|
||||
}
|
||||
|
||||
if (!in_array('acpinfo_user', $qb->getAllAliases(), true)) {
|
||||
$qb->leftJoin('acpinfo.user', 'acpinfo_user');
|
||||
}
|
||||
|
||||
$qb->addSelect('acpinfo_user.id AS ' . self::COLUMN_NAME);
|
||||
$qb->addGroupBy('acpinfo_user.id');
|
||||
}
|
||||
|
||||
public function applyOn()
|
||||
{
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
}
|
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Export\Aggregator\PersonAggregators;
|
||||
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
||||
use Chill\MainBundle\Repository\CenterRepositoryInterface;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Closure;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
final readonly class CenterAggregator implements AggregatorInterface
|
||||
{
|
||||
private const COLUMN_NAME = 'person_center_aggregator';
|
||||
|
||||
public function __construct(
|
||||
private CenterRepositoryInterface $centerRepository,
|
||||
private RollingDateConverterInterface $rollingDateConverter,
|
||||
) {
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add('at_date', PickRollingDateType::class, [
|
||||
'label' => 'export.aggregator.person.by_center.at_date',
|
||||
]);
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [
|
||||
'at_date' => new RollingDate(RollingDate::T_TODAY)
|
||||
];
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data): Closure
|
||||
{
|
||||
return function (int|string|null $value) {
|
||||
if (null === $value || '' === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ('_header' === $value) {
|
||||
return 'export.aggregator.person.by_center.center';
|
||||
}
|
||||
|
||||
return (string) $this->centerRepository->find((int) $value)?->getName();
|
||||
};
|
||||
}
|
||||
|
||||
public function getQueryKeys($data)
|
||||
{
|
||||
return [self::COLUMN_NAME];
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return 'export.aggregator.person.by_center.title';
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$alias = 'pers_center_agg';
|
||||
$atDate = 'pers_center_agg_at_date';
|
||||
|
||||
$qb->leftJoin('person.centerHistory', $alias);
|
||||
$qb
|
||||
->andWhere(
|
||||
$qb->expr()->lte($alias.'.startDate', ':'.$atDate),
|
||||
)->andWhere(
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull($alias.'.endDate'),
|
||||
$qb->expr()->gt($alias.'.endDate', ':'.$atDate)
|
||||
)
|
||||
);
|
||||
$qb->setParameter($atDate, $this->rollingDateConverter->convert($data['at_date']));
|
||||
|
||||
$qb->addSelect("IDENTITY({$alias}.center) AS " . self::COLUMN_NAME);
|
||||
$qb->addGroupBy(self::COLUMN_NAME);
|
||||
}
|
||||
|
||||
public function applyOn()
|
||||
{
|
||||
return Declarations::PERSON_TYPE;
|
||||
}
|
||||
}
|
@@ -29,6 +29,7 @@ use Chill\PersonBundle\Entity\Household\PersonHouseholdAddress;
|
||||
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Chill\PersonBundle\Export\Helper\ListAccompanyingPeriodHelper;
|
||||
use Chill\PersonBundle\Repository\PersonRepository;
|
||||
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
@@ -45,95 +46,13 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use function strlen;
|
||||
|
||||
class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface
|
||||
final readonly class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface
|
||||
{
|
||||
private const FIELDS = [
|
||||
'id',
|
||||
'step',
|
||||
'stepSince',
|
||||
'openingDate',
|
||||
'closingDate',
|
||||
'referrer',
|
||||
'referrerSince',
|
||||
'administrativeLocation',
|
||||
'locationIsPerson',
|
||||
'locationIsTemp',
|
||||
'locationPersonName',
|
||||
'locationPersonId',
|
||||
'origin',
|
||||
'closingMotive',
|
||||
'confidential',
|
||||
'emergency',
|
||||
'intensity',
|
||||
'job',
|
||||
'isRequestorPerson',
|
||||
'isRequestorThirdParty',
|
||||
'requestorPerson',
|
||||
'requestorPersonId',
|
||||
'requestorThirdParty',
|
||||
'requestorThirdPartyId',
|
||||
'scopes',
|
||||
'socialIssues',
|
||||
'createdAt',
|
||||
'createdBy',
|
||||
'updatedAt',
|
||||
'updatedBy',
|
||||
];
|
||||
|
||||
private ExportAddressHelper $addressHelper;
|
||||
|
||||
private DateTimeHelper $dateTimeHelper;
|
||||
|
||||
private EntityManagerInterface $entityManager;
|
||||
|
||||
private PersonRenderInterface $personRender;
|
||||
|
||||
private PersonRepository $personRepository;
|
||||
|
||||
private RollingDateConverterInterface $rollingDateConverter;
|
||||
|
||||
private SocialIssueRender $socialIssueRender;
|
||||
|
||||
private SocialIssueRepository $socialIssueRepository;
|
||||
|
||||
private ThirdPartyRender $thirdPartyRender;
|
||||
|
||||
private ThirdPartyRepository $thirdPartyRepository;
|
||||
|
||||
private TranslatableStringHelperInterface $translatableStringHelper;
|
||||
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
private UserHelper $userHelper;
|
||||
|
||||
public function __construct(
|
||||
ExportAddressHelper $addressHelper,
|
||||
DateTimeHelper $dateTimeHelper,
|
||||
EntityManagerInterface $entityManager,
|
||||
PersonRenderInterface $personRender,
|
||||
PersonRepository $personRepository,
|
||||
ThirdPartyRepository $thirdPartyRepository,
|
||||
ThirdPartyRender $thirdPartyRender,
|
||||
SocialIssueRepository $socialIssueRepository,
|
||||
SocialIssueRender $socialIssueRender,
|
||||
TranslatableStringHelperInterface $translatableStringHelper,
|
||||
TranslatorInterface $translator,
|
||||
RollingDateConverterInterface $rollingDateConverter,
|
||||
UserHelper $userHelper
|
||||
private EntityManagerInterface $entityManager,
|
||||
private RollingDateConverterInterface $rollingDateConverter,
|
||||
private ListAccompanyingPeriodHelper $listAccompanyingPeriodHelper,
|
||||
) {
|
||||
$this->addressHelper = $addressHelper;
|
||||
$this->dateTimeHelper = $dateTimeHelper;
|
||||
$this->entityManager = $entityManager;
|
||||
$this->personRender = $personRender;
|
||||
$this->personRepository = $personRepository;
|
||||
$this->socialIssueRender = $socialIssueRender;
|
||||
$this->socialIssueRepository = $socialIssueRepository;
|
||||
$this->thirdPartyRender = $thirdPartyRender;
|
||||
$this->thirdPartyRepository = $thirdPartyRepository;
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
$this->translator = $translator;
|
||||
$this->rollingDateConverter = $rollingDateConverter;
|
||||
$this->userHelper = $userHelper;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
@@ -169,141 +88,12 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface
|
||||
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
if (substr($key, 0, strlen('address_fields')) === 'address_fields') {
|
||||
return $this->addressHelper->getLabel($key, $values, $data, 'address_fields');
|
||||
}
|
||||
|
||||
switch ($key) {
|
||||
case 'stepSince':
|
||||
case 'openingDate':
|
||||
case 'closingDate':
|
||||
case 'referrerSince':
|
||||
case 'createdAt':
|
||||
case 'updatedAt':
|
||||
return $this->dateTimeHelper->getLabel('export.list.acp.' . $key);
|
||||
|
||||
case 'origin':
|
||||
case 'closingMotive':
|
||||
case 'job':
|
||||
return function ($value) use ($key) {
|
||||
if ('_header' === $value) {
|
||||
return 'export.list.acp.' . $key;
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR));
|
||||
};
|
||||
|
||||
case 'locationPersonName':
|
||||
case 'requestorPerson':
|
||||
return function ($value) use ($key) {
|
||||
if ('_header' === $value) {
|
||||
return 'export.list.acp.' . $key;
|
||||
}
|
||||
|
||||
if (null === $value || null === $person = $this->personRepository->find($value)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->personRender->renderString($person, []);
|
||||
};
|
||||
|
||||
case 'requestorThirdParty':
|
||||
return function ($value) use ($key) {
|
||||
if ('_header' === $value) {
|
||||
return 'export.list.acp.' . $key;
|
||||
}
|
||||
|
||||
if (null === $value || null === $thirdparty = $this->thirdPartyRepository->find($value)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->thirdPartyRender->renderString($thirdparty, []);
|
||||
};
|
||||
|
||||
case 'scopes':
|
||||
return function ($value) use ($key) {
|
||||
if ('_header' === $value) {
|
||||
return 'export.list.acp.' . $key;
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return implode(
|
||||
'|',
|
||||
array_map(
|
||||
fn ($s) => $this->translatableStringHelper->localize($s),
|
||||
json_decode($value, true, 512, JSON_THROW_ON_ERROR)
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
case 'socialIssues':
|
||||
return function ($value) use ($key) {
|
||||
if ('_header' === $value) {
|
||||
return 'export.list.acp.' . $key;
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return implode(
|
||||
'|',
|
||||
array_map(
|
||||
fn ($s) => $this->socialIssueRender->renderString($this->socialIssueRepository->find($s), []),
|
||||
json_decode($value, true, 512, JSON_THROW_ON_ERROR)
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
case 'step':
|
||||
return fn ($value) => match ($value) {
|
||||
'_header' => 'export.list.acp.step',
|
||||
null => '',
|
||||
AccompanyingPeriod::STEP_DRAFT => $this->translator->trans('course.draft'),
|
||||
AccompanyingPeriod::STEP_CONFIRMED => $this->translator->trans('course.confirmed'),
|
||||
AccompanyingPeriod::STEP_CLOSED => $this->translator->trans('course.closed'),
|
||||
AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT => $this->translator->trans('course.inactive_short'),
|
||||
AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG => $this->translator->trans('course.inactive_long'),
|
||||
default => $value,
|
||||
};
|
||||
|
||||
case 'intensity':
|
||||
return fn ($value) => match ($value) {
|
||||
'_header' => 'export.list.acp.intensity',
|
||||
null => '',
|
||||
AccompanyingPeriod::INTENSITY_OCCASIONAL => $this->translator->trans('occasional'),
|
||||
AccompanyingPeriod::INTENSITY_REGULAR => $this->translator->trans('regular'),
|
||||
default => $value,
|
||||
};
|
||||
|
||||
default:
|
||||
return static function ($value) use ($key) {
|
||||
if ('_header' === $value) {
|
||||
return 'export.list.acp.' . $key;
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $value;
|
||||
};
|
||||
}
|
||||
return $this->listAccompanyingPeriodHelper->getLabels($key, $values, $data);
|
||||
}
|
||||
|
||||
public function getQueryKeys($data)
|
||||
{
|
||||
return array_merge(
|
||||
self::FIELDS,
|
||||
$this->addressHelper->getKeys(ExportAddressHelper::F_ALL, 'address_fields')
|
||||
);
|
||||
return $this->listAccompanyingPeriodHelper->getQueryKeys($data);
|
||||
}
|
||||
|
||||
public function getResult($query, $data)
|
||||
@@ -341,7 +131,12 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface
|
||||
->setParameter('list_acp_step', AccompanyingPeriod::STEP_DRAFT)
|
||||
->setParameter('authorized_centers', $centers);
|
||||
|
||||
$this->addSelectClauses($qb, $this->rollingDateConverter->convert($data['calc_date']));
|
||||
$this->listAccompanyingPeriodHelper->addSelectClauses($qb, $this->rollingDateConverter->convert($data['calc_date']));
|
||||
|
||||
$qb
|
||||
->addOrderBy('acp.openingDate')
|
||||
->addOrderBy('acp.closingDate')
|
||||
->addOrderBy('acp.id');
|
||||
|
||||
return $qb;
|
||||
}
|
||||
@@ -357,91 +152,4 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface
|
||||
Declarations::ACP_TYPE,
|
||||
];
|
||||
}
|
||||
|
||||
private function addSelectClauses(QueryBuilder $qb, DateTimeImmutable $calcDate): void
|
||||
{
|
||||
// add the regular fields
|
||||
foreach (['id', 'openingDate', 'closingDate', 'confidential', 'emergency', 'intensity', 'createdAt', 'updatedAt'] as $field) {
|
||||
$qb->addSelect(sprintf('acp.%s AS %s', $field, $field));
|
||||
}
|
||||
|
||||
// add the field which are simple association
|
||||
foreach (['origin' => 'label', 'closingMotive' => 'name', 'job' => 'label', 'createdBy' => 'label', 'updatedBy' => 'label', 'administrativeLocation' => 'name'] as $entity => $field) {
|
||||
$qb
|
||||
->leftJoin(sprintf('acp.%s', $entity), "{$entity}_t")
|
||||
->addSelect(sprintf('%s_t.%s AS %s', $entity, $field, $entity));
|
||||
}
|
||||
|
||||
// step at date
|
||||
$qb
|
||||
->addSelect('stepHistory.step AS step')
|
||||
->addSelect('stepHistory.startDate AS stepSince')
|
||||
->leftJoin('acp.stepHistories', 'stepHistory')
|
||||
->andWhere(
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->lte('stepHistory.startDate', ':calcDate'),
|
||||
$qb->expr()->orX($qb->expr()->isNull('stepHistory.endDate'), $qb->expr()->gt('stepHistory.endDate', ':calcDate'))
|
||||
)
|
||||
);
|
||||
|
||||
// referree at date
|
||||
$qb
|
||||
->addSelect('referrer_t.label AS referrer')
|
||||
->addSelect('userHistory.startDate AS referrerSince')
|
||||
->leftJoin('acp.userHistories', 'userHistory')
|
||||
->leftJoin('userHistory.user', 'referrer_t')
|
||||
->andWhere(
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull('userHistory'),
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->lte('userHistory.startDate', ':calcDate'),
|
||||
$qb->expr()->orX($qb->expr()->isNull('userHistory.endDate'), $qb->expr()->gt('userHistory.endDate', ':calcDate'))
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// location of the acp
|
||||
$qb
|
||||
->addSelect('CASE WHEN locationHistory.personLocation IS NOT NULL THEN 1 ELSE 0 END AS locationIsPerson')
|
||||
->addSelect('CASE WHEN locationHistory.personLocation IS NOT NULL THEN 0 ELSE 1 END AS locationIsTemp')
|
||||
->addSelect('IDENTITY(locationHistory.personLocation) AS locationPersonName')
|
||||
->addSelect('IDENTITY(locationHistory.personLocation) AS locationPersonId')
|
||||
->leftJoin('acp.locationHistories', 'locationHistory')
|
||||
->andWhere(
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull('locationHistory'),
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->lte('locationHistory.startDate', ':calcDate'),
|
||||
$qb->expr()->orX($qb->expr()->isNull('locationHistory.endDate'), $qb->expr()->gt('locationHistory.endDate', ':calcDate'))
|
||||
)
|
||||
)
|
||||
)
|
||||
->leftJoin(
|
||||
PersonHouseholdAddress::class,
|
||||
'personAddress',
|
||||
Join::WITH,
|
||||
'locationHistory.personLocation = personAddress.person AND (personAddress.validFrom <= :calcDate AND (personAddress.validTo IS NULL OR personAddress.validTo > :calcDate))'
|
||||
)
|
||||
->leftJoin(Address::class, 'acp_address', Join::WITH, 'COALESCE(IDENTITY(locationHistory.addressLocation), IDENTITY(personAddress.address)) = acp_address.id');
|
||||
|
||||
$this->addressHelper->addSelectClauses(ExportAddressHelper::F_ALL, $qb, 'acp_address', 'address_fields');
|
||||
|
||||
// requestor
|
||||
$qb
|
||||
->addSelect('CASE WHEN acp.requestorPerson IS NULL THEN 1 ELSE 0 END AS isRequestorPerson')
|
||||
->addSelect('CASE WHEN acp.requestorPerson IS NULL THEN 0 ELSE 1 END AS isRequestorThirdParty')
|
||||
->addSelect('IDENTITY(acp.requestorPerson) AS requestorPersonId')
|
||||
->addSelect('IDENTITY(acp.requestorThirdParty) AS requestorThirdPartyId')
|
||||
->addSelect('IDENTITY(acp.requestorPerson) AS requestorPerson')
|
||||
->addSelect('IDENTITY(acp.requestorThirdParty) AS requestorThirdParty');
|
||||
|
||||
$qb
|
||||
// scopes
|
||||
->addSelect('(SELECT AGGREGATE(scope.name) FROM ' . Scope::class . ' scope WHERE scope MEMBER OF acp.scopes) AS scopes')
|
||||
// social issues
|
||||
->addSelect('(SELECT AGGREGATE(socialIssue.id) FROM ' . SocialIssue::class . ' socialIssue WHERE socialIssue MEMBER OF acp.socialIssues) AS socialIssues');
|
||||
|
||||
// add parameter
|
||||
$qb->setParameter('calcDate', $calcDate);
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,12 @@ use function count;
|
||||
use function in_array;
|
||||
use function strlen;
|
||||
|
||||
class ListPersonWithAccompanyingPeriod implements ExportElementValidatedInterface, ListInterface, GroupedExportInterface
|
||||
/**
|
||||
* List the persons, having an accompanying period.
|
||||
*
|
||||
* Details of the accompanying period are not included
|
||||
*/
|
||||
class ListPersonHavingAccompanyingPeriod implements ExportElementValidatedInterface, ListInterface, GroupedExportInterface
|
||||
{
|
||||
private ExportAddressHelper $addressHelper;
|
||||
|
||||
@@ -185,6 +190,11 @@ class ListPersonWithAccompanyingPeriod implements ExportElementValidatedInterfac
|
||||
|
||||
$this->listPersonHelper->addSelect($qb, $fields, $data['address_date']);
|
||||
|
||||
$qb
|
||||
->addOrderBy('person.lastName')
|
||||
->addOrderBy('person.firstName')
|
||||
->addOrderBy('person.id');
|
||||
|
||||
return $qb;
|
||||
}
|
||||
|
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Export\Export;
|
||||
|
||||
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
||||
use Chill\MainBundle\Export\FormatterInterface;
|
||||
use Chill\MainBundle\Export\GroupedExportInterface;
|
||||
use Chill\MainBundle\Export\Helper\ExportAddressHelper;
|
||||
use Chill\MainBundle\Export\ListInterface;
|
||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Chill\PersonBundle\Export\Helper\ListAccompanyingPeriodHelper;
|
||||
use Chill\PersonBundle\Export\Helper\ListPersonHelper;
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\AbstractQuery;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Validator\Constraints\Callback;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
use function array_key_exists;
|
||||
use function count;
|
||||
use function in_array;
|
||||
use function strlen;
|
||||
|
||||
/**
|
||||
* List the persons having an accompanying period, with the accompanying period details
|
||||
*
|
||||
*/
|
||||
final readonly class ListPersonWithAccompanyingPeriodDetails implements ListInterface, GroupedExportInterface
|
||||
{
|
||||
public function __construct(
|
||||
private ListPersonHelper $listPersonHelper,
|
||||
private ListAccompanyingPeriodHelper $listAccompanyingPeriodHelper,
|
||||
private EntityManagerInterface $entityManager,
|
||||
private RollingDateConverterInterface $rollingDateConverter,
|
||||
) {
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add('address_date', PickRollingDateType::class, [
|
||||
'label' => 'Data valid at this date',
|
||||
'help' => 'Data regarding center, addresses, and so on will be computed at this date',
|
||||
]);
|
||||
}
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return ['address_date' => new RollingDate(RollingDate::T_TODAY)];
|
||||
}
|
||||
|
||||
public function getAllowedFormattersTypes()
|
||||
{
|
||||
return [FormatterInterface::TYPE_LIST];
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return 'export.list.person_with_acp.Create a list of people having an accompaying periods with details of period, according to various filters.';
|
||||
}
|
||||
|
||||
public function getGroup(): string
|
||||
{
|
||||
return 'Exports of persons';
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
if (in_array($key, $this->listPersonHelper->getAllKeys(), true)) {
|
||||
return $this->listPersonHelper->getLabels($key, $values, $data);
|
||||
}
|
||||
|
||||
return $this->listAccompanyingPeriodHelper->getLabels($key, $values, $data);
|
||||
}
|
||||
|
||||
public function getQueryKeys($data)
|
||||
{
|
||||
return array_merge(
|
||||
$this->listPersonHelper->getAllKeys(),
|
||||
$this->listAccompanyingPeriodHelper->getQueryKeys($data),
|
||||
);
|
||||
}
|
||||
|
||||
public function getResult($query, $data)
|
||||
{
|
||||
return $query->getQuery()->getResult(AbstractQuery::HYDRATE_SCALAR);
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return 'export.list.person_with_acp.List peoples having an accompanying period with period details';
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return Declarations::PERSON_TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* param array{fields: string[], address_date: DateTimeImmutable} $data.
|
||||
*/
|
||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||
{
|
||||
$centers = array_map(static fn ($el) => $el['center'], $acl);
|
||||
|
||||
$qb = $this->entityManager->createQueryBuilder();
|
||||
|
||||
$qb->from(Person::class, 'person')
|
||||
->join('person.accompanyingPeriodParticipations', 'acppart')
|
||||
->join('acppart.accompanyingPeriod', 'acp')
|
||||
->andWhere($qb->expr()->neq('acp.step', "'" . AccompanyingPeriod::STEP_DRAFT . "'"))
|
||||
->andWhere(
|
||||
$qb->expr()->exists(
|
||||
'SELECT 1 FROM ' . PersonCenterHistory::class . ' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
|
||||
)
|
||||
)->setParameter('authorized_centers', $centers);
|
||||
|
||||
$this->listPersonHelper->addSelect($qb, ListPersonHelper::FIELDS, $this->rollingDateConverter->convert($data['address_date']));
|
||||
$this->listAccompanyingPeriodHelper->addSelectClauses($qb, $this->rollingDateConverter->convert($data['address_date']));
|
||||
|
||||
$qb
|
||||
->addOrderBy('person.lastName')
|
||||
->addOrderBy('person.firstName')
|
||||
->addOrderBy('person.id')
|
||||
->addOrderBy('acp.id');
|
||||
|
||||
return $qb;
|
||||
}
|
||||
|
||||
public function requiredRole(): string
|
||||
{
|
||||
return PersonVoter::LISTS;
|
||||
}
|
||||
|
||||
public function supportsModifiers()
|
||||
{
|
||||
return [Declarations::PERSON_TYPE, Declarations::PERSON_IMPLIED_IN, Declarations::ACP_TYPE];
|
||||
}
|
||||
}
|
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Entity\UserJob;
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
||||
use Chill\MainBundle\Form\Type\PickUserDynamicType;
|
||||
use Chill\MainBundle\Repository\UserJobRepositoryInterface;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
||||
use Chill\MainBundle\Templating\Entity\UserRender;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
/**
|
||||
* Filter course where a user with the given job is "working" on it
|
||||
*
|
||||
* Makes use of AccompanyingPeriodInfo
|
||||
*/
|
||||
readonly class JobWorkingOnCourseFilter implements FilterInterface
|
||||
{
|
||||
public function __construct(
|
||||
private UserJobRepositoryInterface $userJobRepository,
|
||||
private RollingDateConverterInterface $rollingDateConverter,
|
||||
private TranslatableStringHelperInterface $translatableStringHelper,
|
||||
) {
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder): void
|
||||
{
|
||||
$jobs = $this->userJobRepository->findAllActive();
|
||||
usort($jobs, fn (UserJob $a, UserJob $b) => $this->translatableStringHelper->localize($a->getLabel()) <=> $this->translatableStringHelper->localize($b->getLabel()));
|
||||
|
||||
$builder
|
||||
->add('jobs', EntityType::class, [
|
||||
'class' => UserJob::class,
|
||||
'choices' => $jobs,
|
||||
'choice_label' => fn (UserJob $userJob) => $this->translatableStringHelper->localize($userJob->getLabel()),
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
])
|
||||
->add('start_date', PickRollingDateType::class, [
|
||||
'label' => 'export.filter.course.by_job_working.Job working after'
|
||||
])
|
||||
->add('end_date', PickRollingDateType::class, [
|
||||
'label' => 'export.filter.course.by_job_working.Job working before'
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [
|
||||
'jobs' => [],
|
||||
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
||||
'end_date' => new RollingDate(RollingDate::T_TODAY),
|
||||
];
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'export.filter.course.by_job_working.title';
|
||||
}
|
||||
|
||||
public function describeAction($data, $format = 'string'): array
|
||||
{
|
||||
return [
|
||||
'export.filter.course.by_job_working.Filtered by job working on course: only %jobs%, between %start_date% and %end_date%', [
|
||||
'%jobs%' => implode(
|
||||
', ',
|
||||
array_map(
|
||||
fn (UserJob $userJob) => $this->translatableStringHelper->localize($userJob->getLabel()),
|
||||
$data['jobs']
|
||||
)
|
||||
),
|
||||
'%start_date%' => $this->rollingDateConverter->convert($data['start_date'])?->format('d-m-Y'),
|
||||
'%end_date%' => $this->rollingDateConverter->convert($data['end_date'])?->format('d-m-Y'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data): void
|
||||
{
|
||||
$ai_alias = 'jobs_working_on_course_filter_acc_info';
|
||||
$ai_user_alias = 'jobs_working_on_course_filter_user';
|
||||
$ai_jobs = 'jobs_working_on_course_filter_jobs';
|
||||
$start = 'acp_jobs_work_on_start';
|
||||
$end = 'acp_jobs_work_on_end';
|
||||
|
||||
$qb
|
||||
->andWhere(
|
||||
$qb->expr()->exists(
|
||||
"SELECT 1 FROM " . AccompanyingPeriod\AccompanyingPeriodInfo::class . " {$ai_alias} JOIN {$ai_alias}.user {$ai_user_alias} " .
|
||||
"WHERE IDENTITY({$ai_alias}.accompanyingPeriod) = acp.id
|
||||
AND {$ai_user_alias}.userJob IN (:{$ai_jobs})
|
||||
AND {$ai_alias}.infoDate >= :{$start} and {$ai_alias}.infoDate < :{$end}
|
||||
"
|
||||
)
|
||||
)
|
||||
->setParameter($ai_jobs, $data['jobs'])
|
||||
->setParameter($start, $this->rollingDateConverter->convert($data['start_date']))
|
||||
->setParameter($end, $this->rollingDateConverter->convert($data['end_date']))
|
||||
;
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
}
|
@@ -38,7 +38,7 @@ class OpenBetweenDatesFilter implements FilterInterface
|
||||
{
|
||||
$clause = $qb->expr()->andX(
|
||||
$qb->expr()->gte('acp.openingDate', ':datefrom'),
|
||||
$qb->expr()->lte('acp.openingDate', ':dateto')
|
||||
$qb->expr()->lt('acp.openingDate', ':dateto')
|
||||
);
|
||||
|
||||
$qb->andWhere($clause);
|
||||
|
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters;
|
||||
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Entity\UserJob;
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
||||
use Chill\MainBundle\Form\Type\PickUserDynamicType;
|
||||
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
|
||||
use Chill\MainBundle\Repository\UserJobRepositoryInterface;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
||||
use Chill\MainBundle\Templating\Entity\UserRender;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
/**
|
||||
* Filter course where a user with the given scope is "working" on it
|
||||
*
|
||||
* Makes use of AccompanyingPeriodInfo
|
||||
*/
|
||||
readonly class ScopeWorkingOnCourseFilter implements FilterInterface
|
||||
{
|
||||
public function __construct(
|
||||
private ScopeRepositoryInterface $scopeRepository,
|
||||
private RollingDateConverterInterface $rollingDateConverter,
|
||||
private TranslatableStringHelperInterface $translatableStringHelper,
|
||||
) {
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder): void
|
||||
{
|
||||
$scopes = $this->scopeRepository->findAllActive();
|
||||
usort($scopes, fn (Scope $a, Scope $b) => $this->translatableStringHelper->localize($a->getName()) <=> $this->translatableStringHelper->localize($b->getName()));
|
||||
|
||||
$builder
|
||||
->add('scopes', EntityType::class, [
|
||||
'class' => Scope::class,
|
||||
'choices' => $scopes,
|
||||
'choice_label' => fn (Scope $scope) => $this->translatableStringHelper->localize($scope->getName()),
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
])
|
||||
->add('start_date', PickRollingDateType::class, [
|
||||
'label' => 'export.filter.course.by_scope_working.Scope working after'
|
||||
])
|
||||
->add('end_date', PickRollingDateType::class, [
|
||||
'label' => 'export.filter.course.by_scope_working.Scope working before'
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [
|
||||
'scopes' => [],
|
||||
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
||||
'end_date' => new RollingDate(RollingDate::T_TODAY),
|
||||
];
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'export.filter.course.by_scope_working.title';
|
||||
}
|
||||
|
||||
public function describeAction($data, $format = 'string'): array
|
||||
{
|
||||
return [
|
||||
'export.filter.course.by_scope_working.Filtered by scope working on course: only %scopes%, between %start_date% and %end_date%', [
|
||||
'%scopes%' => implode(
|
||||
', ',
|
||||
array_map(
|
||||
fn (Scope $scope) => $this->translatableStringHelper->localize($scope->getName()),
|
||||
$data['scopes']
|
||||
)
|
||||
),
|
||||
'%start_date%' => $this->rollingDateConverter->convert($data['start_date'])?->format('d-m-Y'),
|
||||
'%end_date%' => $this->rollingDateConverter->convert($data['end_date'])?->format('d-m-Y'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data): void
|
||||
{
|
||||
$ai_alias = 'scopes_working_on_course_filter_acc_info';
|
||||
$ai_user_alias = 'scopes_working_on_course_filter_user';
|
||||
$ai_scopes = 'scopes_working_on_course_filter_scopes';
|
||||
$start = 'acp_scopes_work_on_start';
|
||||
$end = 'acp_scopes_work_on_end';
|
||||
|
||||
$qb
|
||||
->andWhere(
|
||||
$qb->expr()->exists(
|
||||
"SELECT 1 FROM " . AccompanyingPeriod\AccompanyingPeriodInfo::class . " {$ai_alias} JOIN {$ai_alias}.user {$ai_user_alias} " .
|
||||
"WHERE IDENTITY({$ai_alias}.accompanyingPeriod) = acp.id
|
||||
AND {$ai_user_alias}.mainScope IN (:{$ai_scopes})
|
||||
AND {$ai_alias}.infoDate >= :{$start} and {$ai_alias}.infoDate < :{$end}
|
||||
"
|
||||
)
|
||||
)
|
||||
->setParameter($ai_scopes, $data['scopes'])
|
||||
->setParameter($start, $this->rollingDateConverter->convert($data['start_date']))
|
||||
->setParameter($end, $this->rollingDateConverter->convert($data['end_date']))
|
||||
;
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
}
|
@@ -13,7 +13,10 @@ namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
||||
use Chill\MainBundle\Form\Type\PickUserDynamicType;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
||||
use Chill\MainBundle\Templating\Entity\UserRender;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
@@ -27,11 +30,9 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||
*/
|
||||
readonly class UserWorkingOnCourseFilter implements FilterInterface
|
||||
{
|
||||
private const AI_ALIAS = 'user_working_on_course_filter_acc_info';
|
||||
private const AI_USERS = 'user_working_on_course_filter_users';
|
||||
|
||||
public function __construct(
|
||||
private UserRender $userRender,
|
||||
private RollingDateConverterInterface $rollingDateConverter,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -40,11 +41,23 @@ readonly class UserWorkingOnCourseFilter implements FilterInterface
|
||||
$builder
|
||||
->add('users', PickUserDynamicType::class, [
|
||||
'multiple' => true,
|
||||
]);
|
||||
])
|
||||
->add('start_date', PickRollingDateType::class, [
|
||||
'label' => 'export.filter.course.by_user_working.User working after'
|
||||
])
|
||||
->add('end_date', PickRollingDateType::class, [
|
||||
'label' => 'export.filter.course.by_user_working.User working before'
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
return [
|
||||
'users' => [],
|
||||
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
||||
'end_date' => new RollingDate(RollingDate::T_TODAY),
|
||||
];
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
@@ -55,7 +68,7 @@ readonly class UserWorkingOnCourseFilter implements FilterInterface
|
||||
public function describeAction($data, $format = 'string'): array
|
||||
{
|
||||
return [
|
||||
'export.filter.course.by_user_working.Filtered by user working on course: only %users%', [
|
||||
'export.filter.course.by_user_working.Filtered by user working on course: only %users%, between %start_date% and %end_date%', [
|
||||
'%users%' => implode(
|
||||
', ',
|
||||
array_map(
|
||||
@@ -63,6 +76,8 @@ readonly class UserWorkingOnCourseFilter implements FilterInterface
|
||||
$data['users']
|
||||
)
|
||||
),
|
||||
'%start_date%' => $this->rollingDateConverter->convert($data['start_date'])?->format('d-m-Y'),
|
||||
'%end_date%' => $this->rollingDateConverter->convert($data['end_date'])?->format('d-m-Y'),
|
||||
],
|
||||
];
|
||||
}
|
||||
@@ -74,14 +89,21 @@ readonly class UserWorkingOnCourseFilter implements FilterInterface
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data): void
|
||||
{
|
||||
$ai_alias = 'user_working_on_course_filter_acc_info';
|
||||
$ai_users = 'user_working_on_course_filter_users';
|
||||
$start = 'acp_use_work_on_start';
|
||||
$end = 'acp_use_work_on_end';
|
||||
|
||||
$qb
|
||||
->andWhere(
|
||||
$qb->expr()->exists(
|
||||
"SELECT 1 FROM " . AccompanyingPeriod\AccompanyingPeriodInfo::class . " " . self::AI_ALIAS . " " .
|
||||
"WHERE " . self::AI_ALIAS . ".user IN (:" . self::AI_USERS .") AND IDENTITY(" . self::AI_ALIAS . ".accompanyingPeriod) = acp.id"
|
||||
"SELECT 1 FROM " . AccompanyingPeriod\AccompanyingPeriodInfo::class . " {$ai_alias} " .
|
||||
"WHERE {$ai_alias}.user IN (:{$ai_users}) AND IDENTITY({$ai_alias}.accompanyingPeriod) = acp.id AND {$ai_alias}.infoDate >= :{$start} and {$ai_alias}.infoDate < :{$end}"
|
||||
)
|
||||
)
|
||||
->setParameter(self::AI_USERS, $data['users'])
|
||||
->setParameter($ai_users, $data['users'])
|
||||
->setParameter($start, $this->rollingDateConverter->convert($data['start_date']))
|
||||
->setParameter($end, $this->rollingDateConverter->convert($data['end_date']))
|
||||
;
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,317 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Export\Helper;
|
||||
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Export\Helper\DateTimeHelper;
|
||||
use Chill\MainBundle\Export\Helper\ExportAddressHelper;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\Household\PersonHouseholdAddress;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
||||
use Chill\PersonBundle\Repository\PersonRepository;
|
||||
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
|
||||
use Chill\PersonBundle\Templating\Entity\PersonRenderInterface;
|
||||
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
|
||||
use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository;
|
||||
use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
final readonly class ListAccompanyingPeriodHelper
|
||||
{
|
||||
public const FIELDS = [
|
||||
'acpId',
|
||||
'step',
|
||||
'stepSince',
|
||||
'openingDate',
|
||||
'closingDate',
|
||||
'referrer',
|
||||
'referrerSince',
|
||||
'administrativeLocation',
|
||||
'locationIsPerson',
|
||||
'locationIsTemp',
|
||||
'locationPersonName',
|
||||
'locationPersonId',
|
||||
'origin',
|
||||
'closingMotive',
|
||||
'confidential',
|
||||
'emergency',
|
||||
'intensity',
|
||||
'job',
|
||||
'isRequestorPerson',
|
||||
'isRequestorThirdParty',
|
||||
'requestorPerson',
|
||||
'requestorPersonId',
|
||||
'requestorThirdParty',
|
||||
'requestorThirdPartyId',
|
||||
'scopes',
|
||||
'socialIssues',
|
||||
'acpCreatedAt',
|
||||
'acpCreatedBy',
|
||||
'acpUpdatedAt',
|
||||
'acpUpdatedBy',
|
||||
];
|
||||
|
||||
public function __construct(
|
||||
private ExportAddressHelper $addressHelper,
|
||||
private DateTimeHelper $dateTimeHelper,
|
||||
private PersonRenderInterface $personRender,
|
||||
private PersonRepository $personRepository,
|
||||
private ThirdPartyRepository $thirdPartyRepository,
|
||||
private ThirdPartyRender $thirdPartyRender,
|
||||
private SocialIssueRepository $socialIssueRepository,
|
||||
private SocialIssueRender $socialIssueRender,
|
||||
private TranslatableStringHelperInterface $translatableStringHelper,
|
||||
private TranslatorInterface $translator,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getQueryKeys($data)
|
||||
{
|
||||
return array_merge(
|
||||
ListAccompanyingPeriodHelper::FIELDS,
|
||||
$this->addressHelper->getKeys(ExportAddressHelper::F_ALL, 'acp_address_fields')
|
||||
);
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
if (str_starts_with($key, 'acp_address_fields')) {
|
||||
return $this->addressHelper->getLabel($key, $values, $data, 'acp_address_fields');
|
||||
}
|
||||
|
||||
switch ($key) {
|
||||
case 'stepSince':
|
||||
case 'openingDate':
|
||||
case 'closingDate':
|
||||
case 'referrerSince':
|
||||
case 'acpCreatedAt':
|
||||
case 'acpUpdatedAt':
|
||||
return $this->dateTimeHelper->getLabel('export.list.acp.' . $key);
|
||||
|
||||
case 'origin':
|
||||
case 'closingMotive':
|
||||
case 'job':
|
||||
return function ($value) use ($key) {
|
||||
if ('_header' === $value) {
|
||||
return 'export.list.acp.' . $key;
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR));
|
||||
};
|
||||
|
||||
case 'locationPersonName':
|
||||
case 'requestorPerson':
|
||||
return function ($value) use ($key) {
|
||||
if ('_header' === $value) {
|
||||
return 'export.list.acp.' . $key;
|
||||
}
|
||||
|
||||
if (null === $value || null === $person = $this->personRepository->find($value)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->personRender->renderString($person, []);
|
||||
};
|
||||
|
||||
case 'requestorThirdParty':
|
||||
return function ($value) use ($key) {
|
||||
if ('_header' === $value) {
|
||||
return 'export.list.acp.' . $key;
|
||||
}
|
||||
|
||||
if (null === $value || null === $thirdparty = $this->thirdPartyRepository->find($value)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->thirdPartyRender->renderString($thirdparty, []);
|
||||
};
|
||||
|
||||
case 'scopes':
|
||||
return function ($value) use ($key) {
|
||||
if ('_header' === $value) {
|
||||
return 'export.list.acp.' . $key;
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return implode(
|
||||
'|',
|
||||
array_map(
|
||||
fn ($s) => $this->translatableStringHelper->localize($s),
|
||||
json_decode($value, true, 512, JSON_THROW_ON_ERROR)
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
case 'socialIssues':
|
||||
return function ($value) use ($key) {
|
||||
if ('_header' === $value) {
|
||||
return 'export.list.acp.' . $key;
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return implode(
|
||||
'|',
|
||||
array_map(
|
||||
fn ($s) => $this->socialIssueRender->renderString($this->socialIssueRepository->find($s), []),
|
||||
json_decode($value, true, 512, JSON_THROW_ON_ERROR)
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
case 'step':
|
||||
return fn ($value) => match ($value) {
|
||||
'_header' => 'export.list.acp.step',
|
||||
null => '',
|
||||
AccompanyingPeriod::STEP_DRAFT => $this->translator->trans('course.draft'),
|
||||
AccompanyingPeriod::STEP_CONFIRMED => $this->translator->trans('course.confirmed'),
|
||||
AccompanyingPeriod::STEP_CLOSED => $this->translator->trans('course.closed'),
|
||||
AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT => $this->translator->trans('course.inactive_short'),
|
||||
AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG => $this->translator->trans('course.inactive_long'),
|
||||
default => $value,
|
||||
};
|
||||
|
||||
case 'intensity':
|
||||
return fn ($value) => match ($value) {
|
||||
'_header' => 'export.list.acp.intensity',
|
||||
null => '',
|
||||
AccompanyingPeriod::INTENSITY_OCCASIONAL => $this->translator->trans('occasional'),
|
||||
AccompanyingPeriod::INTENSITY_REGULAR => $this->translator->trans('regular'),
|
||||
default => $value,
|
||||
};
|
||||
|
||||
default:
|
||||
return static function ($value) use ($key) {
|
||||
if ('_header' === $value) {
|
||||
return 'export.list.acp.' . $key;
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $value;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public function addSelectClauses(QueryBuilder $qb, \DateTimeImmutable $calcDate): void
|
||||
{
|
||||
$qb->addSelect('acp.id AS acpId');
|
||||
$qb->addSelect('acp.createdAt AS acpCreatedAt');
|
||||
$qb->addSelect('acp.updatedAt AS acpUpdatedAt');
|
||||
|
||||
// add the regular fields
|
||||
foreach (['openingDate', 'closingDate', 'confidential', 'emergency', 'intensity'] as $field) {
|
||||
$qb->addSelect(sprintf('acp.%s AS %s', $field, $field));
|
||||
}
|
||||
|
||||
// add the field which are simple association
|
||||
$qb
|
||||
->leftJoin('acp.createdBy', "acp_created_by_t")
|
||||
->addSelect('acp_created_by_t.label AS acpCreatedBy');
|
||||
$qb
|
||||
->leftJoin('acp.updatedBy', "acp_updated_by_t")
|
||||
->addSelect('acp_updated_by_t.label AS acpUpdatedBy');
|
||||
|
||||
foreach (['origin' => 'label', 'closingMotive' => 'name', 'job' => 'label', 'administrativeLocation' => 'name'] as $entity => $field) {
|
||||
$qb
|
||||
->leftJoin(sprintf('acp.%s', $entity), "{$entity}_t")
|
||||
->addSelect(sprintf('%s_t.%s AS %s', $entity, $field, $entity));
|
||||
}
|
||||
|
||||
// step at date
|
||||
$qb
|
||||
->addSelect('stepHistory.step AS step')
|
||||
->addSelect('stepHistory.startDate AS stepSince')
|
||||
->leftJoin('acp.stepHistories', 'stepHistory')
|
||||
->andWhere(
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->lte('stepHistory.startDate', ':calcDate'),
|
||||
$qb->expr()->orX($qb->expr()->isNull('stepHistory.endDate'), $qb->expr()->gt('stepHistory.endDate', ':calcDate'))
|
||||
)
|
||||
);
|
||||
|
||||
// referree at date
|
||||
$qb
|
||||
->addSelect('referrer_t.label AS referrer')
|
||||
->addSelect('userHistory.startDate AS referrerSince')
|
||||
->leftJoin('acp.userHistories', 'userHistory')
|
||||
->leftJoin('userHistory.user', 'referrer_t')
|
||||
->andWhere(
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull('userHistory'),
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->lte('userHistory.startDate', ':calcDate'),
|
||||
$qb->expr()->orX($qb->expr()->isNull('userHistory.endDate'), $qb->expr()->gt('userHistory.endDate', ':calcDate'))
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// location of the acp
|
||||
$qb
|
||||
->addSelect('CASE WHEN locationHistory.personLocation IS NOT NULL THEN 1 ELSE 0 END AS locationIsPerson')
|
||||
->addSelect('CASE WHEN locationHistory.personLocation IS NOT NULL THEN 0 ELSE 1 END AS locationIsTemp')
|
||||
->addSelect('IDENTITY(locationHistory.personLocation) AS locationPersonName')
|
||||
->addSelect('IDENTITY(locationHistory.personLocation) AS locationPersonId')
|
||||
->leftJoin('acp.locationHistories', 'locationHistory')
|
||||
->andWhere(
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull('locationHistory'),
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->lte('locationHistory.startDate', ':calcDate'),
|
||||
$qb->expr()->orX($qb->expr()->isNull('locationHistory.endDate'), $qb->expr()->gt('locationHistory.endDate', ':calcDate'))
|
||||
)
|
||||
)
|
||||
)
|
||||
->leftJoin(
|
||||
PersonHouseholdAddress::class,
|
||||
'acpPersonAddress',
|
||||
Join::WITH,
|
||||
'locationHistory.personLocation = acpPersonAddress.person AND (acpPersonAddress.validFrom <= :calcDate AND (acpPersonAddress.validTo IS NULL OR acpPersonAddress.validTo > :calcDate))'
|
||||
)
|
||||
->leftJoin(Address::class, 'acp_address', Join::WITH, 'COALESCE(IDENTITY(locationHistory.addressLocation), IDENTITY(acpPersonAddress.address)) = acp_address.id');
|
||||
|
||||
$this->addressHelper->addSelectClauses(ExportAddressHelper::F_ALL, $qb, 'acp_address', 'acp_address_fields');
|
||||
|
||||
// requestor
|
||||
$qb
|
||||
->addSelect('CASE WHEN acp.requestorPerson IS NULL THEN 1 ELSE 0 END AS isRequestorPerson')
|
||||
->addSelect('CASE WHEN acp.requestorPerson IS NULL THEN 0 ELSE 1 END AS isRequestorThirdParty')
|
||||
->addSelect('IDENTITY(acp.requestorPerson) AS requestorPersonId')
|
||||
->addSelect('IDENTITY(acp.requestorThirdParty) AS requestorThirdPartyId')
|
||||
->addSelect('IDENTITY(acp.requestorPerson) AS requestorPerson')
|
||||
->addSelect('IDENTITY(acp.requestorThirdParty) AS requestorThirdParty');
|
||||
|
||||
$qb
|
||||
// scopes
|
||||
->addSelect('(SELECT AGGREGATE(scope.name) FROM ' . Scope::class . ' scope WHERE scope MEMBER OF acp.scopes) AS scopes')
|
||||
// social issues
|
||||
->addSelect('(SELECT AGGREGATE(socialIssue.id) FROM ' . SocialIssue::class . ' socialIssue WHERE socialIssue MEMBER OF acp.socialIssues) AS socialIssues');
|
||||
|
||||
// add parameter
|
||||
$qb->setParameter('calcDate', $calcDate);
|
||||
}
|
||||
}
|
@@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Export\Helper;
|
||||
|
||||
use Chill\MainBundle\Entity\Language;
|
||||
use Chill\MainBundle\Export\Helper\ExportAddressHelper;
|
||||
use Chill\MainBundle\Repository\CenterRepositoryInterface;
|
||||
use Chill\MainBundle\Repository\CivilityRepositoryInterface;
|
||||
@@ -42,7 +43,7 @@ use function strlen;
|
||||
class ListPersonHelper
|
||||
{
|
||||
public const FIELDS = [
|
||||
'id',
|
||||
'personId',
|
||||
'civility',
|
||||
'firstName',
|
||||
'lastName',
|
||||
@@ -114,7 +115,26 @@ class ListPersonHelper
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|value-of<self::FIELDS>[] $fields
|
||||
* Those keys are the "direct" keys, which are created when we decide to use to list all the keys.
|
||||
*
|
||||
* This method must be used in `getKeys` instead of the `self::FIELDS`
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public function getAllKeys(): array
|
||||
{
|
||||
return [
|
||||
...array_filter(
|
||||
ListPersonHelper::FIELDS,
|
||||
fn (string $key) => !in_array($key, ['address_fields', 'lifecycleUpdate'], true)
|
||||
),
|
||||
...$this->addressHelper->getKeys(ExportAddressHelper::F_ALL, 'address_fields'),
|
||||
...['createdAt', 'createdBy', 'updatedAt', 'updatedBy'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<value-of<self::FIELDS>> $fields
|
||||
*/
|
||||
public function addSelect(QueryBuilder $qb, array $fields, DateTimeImmutable $computedDate): void
|
||||
{
|
||||
@@ -124,6 +144,11 @@ class ListPersonHelper
|
||||
}
|
||||
|
||||
switch ($f) {
|
||||
case 'personId':
|
||||
$qb->addSelect('person.id AS personId');
|
||||
|
||||
break;
|
||||
|
||||
case 'countryOfBirth':
|
||||
case 'nationality':
|
||||
$qb->addSelect(sprintf('IDENTITY(person.%s) as %s', $f, $f));
|
||||
@@ -138,25 +163,7 @@ class ListPersonHelper
|
||||
break;
|
||||
|
||||
case 'spokenLanguages':
|
||||
$qb
|
||||
->leftJoin('person.spokenLanguages', 'spokenLanguage')
|
||||
->addSelect('AGGREGATE(spokenLanguage.id) AS spokenLanguages')
|
||||
->addGroupBy('person');
|
||||
|
||||
if (in_array('center', $fields, true)) {
|
||||
$qb->addGroupBy('center');
|
||||
}
|
||||
|
||||
if (in_array('address_fields', $fields, true)) {
|
||||
$qb
|
||||
->addGroupBy('address_fieldsid')
|
||||
->addGroupBy('address_fieldscountry_t.id')
|
||||
->addGroupBy('address_fieldspostcode_t.id');
|
||||
}
|
||||
|
||||
if (in_array('household_id', $fields, true)) {
|
||||
$qb->addGroupBy('household_id');
|
||||
}
|
||||
$qb->addSelect('(SELECT AGGREGATE(language.id) FROM ' . Language::class . ' language WHERE language MEMBER OF person.spokenLanguages) AS spokenLanguages');
|
||||
|
||||
break;
|
||||
|
||||
|
@@ -12,107 +12,93 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Repository;
|
||||
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Entity\Location;
|
||||
use Chill\MainBundle\Entity\PostalCode;
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Entity\UserJob;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface;
|
||||
use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
|
||||
use Chill\PersonBundle\Entity\Household\PersonHouseholdAddress;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||
use DateTime;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\NonUniqueResultException;
|
||||
use Doctrine\ORM\NoResultException;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Repository\AccompanyingPeriodACLAwareRepositoryTest;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use function count;
|
||||
|
||||
final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodACLAwareRepositoryInterface
|
||||
/**
|
||||
* @see AccompanyingPeriodACLAwareRepositoryTest
|
||||
*/
|
||||
final readonly class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodACLAwareRepositoryInterface
|
||||
{
|
||||
private AccompanyingPeriodRepository $accompanyingPeriodRepository;
|
||||
|
||||
private AuthorizationHelper $authorizationHelper;
|
||||
private AuthorizationHelperForCurrentUserInterface $authorizationHelper;
|
||||
|
||||
private CenterResolverDispatcherInterface $centerResolverDispatcher;
|
||||
private CenterResolverManagerInterface $centerResolver;
|
||||
|
||||
private Security $security;
|
||||
|
||||
public function __construct(
|
||||
AccompanyingPeriodRepository $accompanyingPeriodRepository,
|
||||
Security $security,
|
||||
AuthorizationHelper $authorizationHelper,
|
||||
CenterResolverDispatcherInterface $centerResolverDispatcher
|
||||
AuthorizationHelperForCurrentUserInterface $authorizationHelper,
|
||||
CenterResolverManagerInterface $centerResolverDispatcher
|
||||
) {
|
||||
$this->accompanyingPeriodRepository = $accompanyingPeriodRepository;
|
||||
$this->security = $security;
|
||||
$this->authorizationHelper = $authorizationHelper;
|
||||
$this->centerResolverDispatcher = $centerResolverDispatcher;
|
||||
$this->centerResolver = $centerResolverDispatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|PostalCode[]
|
||||
*
|
||||
* @return QueryBuilder
|
||||
*/
|
||||
public function buildQueryOpenedAccompanyingCourseByUser(?User $user, array $postalCodes = [])
|
||||
public function buildQueryOpenedAccompanyingCourseByUserAndPostalCodes(?User $user, array $postalCodes = []): QueryBuilder
|
||||
{
|
||||
$qb = $this->accompanyingPeriodRepository->createQueryBuilder('ap');
|
||||
|
||||
$qb->where($qb->expr()->eq('ap.user', ':user'))
|
||||
->andWhere(
|
||||
$qb->expr()->neq('ap.step', ':draft'),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull('ap.closingDate'),
|
||||
$qb->expr()->gt('ap.closingDate', ':now')
|
||||
)
|
||||
$qb->expr()->neq('ap.step', ':closed'),
|
||||
)
|
||||
->setParameter('user', $user)
|
||||
->setParameter('now', new DateTime('now'))
|
||||
->setParameter('draft', AccompanyingPeriod::STEP_DRAFT);
|
||||
->setParameter('draft', AccompanyingPeriod::STEP_DRAFT)
|
||||
->setParameter('closed', AccompanyingPeriod::STEP_CLOSED);
|
||||
|
||||
if ([] !== $postalCodes) {
|
||||
$qb->join('ap.locationHistories', 'location_history')
|
||||
->leftJoin(PersonHouseholdAddress::class, 'person_address', Join::WITH, 'IDENTITY(location_history.personLocation) = IDENTITY(person_address.person)')
|
||||
$qb->join('ap.locationHistories', 'location_history', Join::WITH, 'location_history.endDate IS NULL')
|
||||
->leftJoin(Person\PersonCurrentAddress::class, 'person_address', Join::WITH, 'IDENTITY(location_history.personLocation) = IDENTITY(person_address.person)')
|
||||
->join(
|
||||
Address::class,
|
||||
'address',
|
||||
Join::WITH,
|
||||
'COALESCE(IDENTITY(location_history.addressLocation), IDENTITY(person_address.address)) = address.id'
|
||||
'COALESCE(IDENTITY(person_address.address), IDENTITY(location_history.addressLocation)) = address.id'
|
||||
)
|
||||
->join('address.postcode', 'postcode')
|
||||
->andWhere(
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull('person_address'),
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->lte('person_address.validFrom', ':now'),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull('person_address.validTo'),
|
||||
$qb->expr()->lt('person_address.validTo', ':now')
|
||||
)
|
||||
)
|
||||
)
|
||||
$qb->expr()->in('postcode.code', ':postal_codes')
|
||||
)
|
||||
->andWhere(
|
||||
$qb->expr()->isNull('location_history.endDate')
|
||||
)
|
||||
->andWhere(
|
||||
$qb->expr()->in('address.postcode', ':postal_codes')
|
||||
)
|
||||
->setParameter('now', new DateTimeImmutable('now'), Types::DATE_IMMUTABLE)
|
||||
->setParameter('postal_codes', $postalCodes);
|
||||
->setParameter('postal_codes', array_map(fn (PostalCode $postalCode) => $postalCode->getCode(), $postalCodes));
|
||||
}
|
||||
|
||||
return $qb;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws NonUniqueResultException
|
||||
* @throws NoResultException
|
||||
*/
|
||||
public function countByUnDispatched(array $jobs, array $services, array $administrativeLocations): int
|
||||
{
|
||||
$qb = $this->addACLByUnDispatched($this->buildQueryUnDispatched($jobs, $services, $administrativeLocations));
|
||||
$qb = $this->addACLMultiCenterOnQuery(
|
||||
$this->buildQueryUnDispatched($jobs, $services, $administrativeLocations),
|
||||
$this->buildCenterOnScope()
|
||||
);
|
||||
|
||||
$qb->select('COUNT(ap)');
|
||||
|
||||
@@ -125,22 +111,12 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $this->buildQueryOpenedAccompanyingCourseByUser($user, $postalCodes)
|
||||
->select('COUNT(ap)')
|
||||
->getQuery()
|
||||
->getSingleScalarResult();
|
||||
}
|
||||
$qb = $this->buildQueryOpenedAccompanyingCourseByUserAndPostalCodes($user, $postalCodes);
|
||||
$qb = $this->addACLMultiCenterOnQuery($qb, $this->buildCenterOnScope(), false);
|
||||
|
||||
public function countByUserOpenedAccompanyingPeriod(?User $user): int
|
||||
{
|
||||
if (null === $user) {
|
||||
return 0;
|
||||
}
|
||||
$qb->select('COUNT(DISTINCT ap)');
|
||||
|
||||
return $this->buildQueryOpenedAccompanyingCourseByUser($user)
|
||||
->select('COUNT(ap)')
|
||||
->getQuery()
|
||||
->getSingleScalarResult();
|
||||
return $qb->getQuery()->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function findByPerson(
|
||||
@@ -152,10 +128,14 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC
|
||||
): array {
|
||||
$qb = $this->accompanyingPeriodRepository->createQueryBuilder('ap');
|
||||
$scopes = $this->authorizationHelper
|
||||
->getReachableCircles(
|
||||
$this->security->getUser(),
|
||||
->getReachableScopes(
|
||||
$role,
|
||||
$this->centerResolverDispatcher->resolveCenter($person)
|
||||
$this->centerResolver->resolveCenters($person)
|
||||
);
|
||||
$scopesCanSeeConfidential = $this->authorizationHelper
|
||||
->getReachableScopes(
|
||||
AccompanyingPeriodVoter::SEE_CONFIDENTIAL_ALL,
|
||||
$this->centerResolver->resolveCenters($person)
|
||||
);
|
||||
|
||||
if (0 === count($scopes)) {
|
||||
@@ -165,12 +145,44 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC
|
||||
$qb
|
||||
->join('ap.participations', 'participation')
|
||||
->where($qb->expr()->eq('participation.person', ':person'))
|
||||
->andWhere(
|
||||
$qb->expr()->orX(
|
||||
'ap.confidential = FALSE',
|
||||
$qb->expr()->eq('ap.user', ':user')
|
||||
)
|
||||
)
|
||||
->setParameter('person', $person);
|
||||
|
||||
$qb = $this->addACLClauses($qb, $scopes, $scopesCanSeeConfidential);
|
||||
$qb = $this->addOrderLimitClauses($qb, $orderBy, $limit, $offset);
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
public function addOrderLimitClauses(QueryBuilder $qb, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): QueryBuilder
|
||||
{
|
||||
if (null !== $orderBy) {
|
||||
foreach ($orderBy as $field => $order) {
|
||||
$qb->addOrderBy('ap.' . $field, $order);
|
||||
}
|
||||
}
|
||||
|
||||
if (null !== $limit) {
|
||||
$qb->setMaxResults($limit);
|
||||
}
|
||||
|
||||
if (null !== $offset) {
|
||||
$qb->setFirstResult($offset);
|
||||
}
|
||||
|
||||
return $qb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add clause for scope on a query, based on no
|
||||
*
|
||||
* @param QueryBuilder $qb where the accompanying period have the `ap` alias
|
||||
* @param array<Scope> $scopesCanSee
|
||||
* @param array<Scope> $scopesCanSeeConfidential
|
||||
* @return QueryBuilder
|
||||
*/
|
||||
public function addACLClauses(QueryBuilder $qb, array $scopesCanSee, array $scopesCanSeeConfidential): QueryBuilder
|
||||
{
|
||||
$qb
|
||||
->andWhere(
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->neq('ap.step', ':draft'),
|
||||
@@ -181,40 +193,67 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC
|
||||
)
|
||||
)
|
||||
->setParameter('draft', AccompanyingPeriod::STEP_DRAFT)
|
||||
->setParameter('person', $person)
|
||||
->setParameter('user', $this->security->getUser())
|
||||
->setParameter('creator', $this->security->getUser());
|
||||
|
||||
// add join condition for scopes
|
||||
$orx = $qb->expr()->orX(
|
||||
// even if the scope is not in one authorized, the user can see the course if it is in DRAFT state
|
||||
$qb->expr()->eq('ap.step', ':draft')
|
||||
);
|
||||
|
||||
foreach ($scopes as $key => $scope) {
|
||||
$orx->add($qb->expr()->orX(
|
||||
foreach ($scopesCanSee as $key => $scope) {
|
||||
// for each scope:
|
||||
// - either the user is the referrer of the course
|
||||
// - or the accompanying course is one of the reachable scopes
|
||||
// - and the parcours is not confidential OR the user is the referrer OR the user can see the confidential course
|
||||
|
||||
$orOnScope = $qb->expr()->orX(
|
||||
$qb->expr()->isMemberOf(':scope_' . $key, 'ap.scopes'),
|
||||
$qb->expr()->eq('ap.user', ':user')
|
||||
));
|
||||
);
|
||||
|
||||
if (in_array($scope, $scopesCanSeeConfidential, true)) {
|
||||
$orx->add($orOnScope);
|
||||
} else {
|
||||
// we must add a condition: the course is not confidential or the user is the referrer
|
||||
$andXOnScope = $qb->expr()->andX(
|
||||
$orOnScope,
|
||||
$qb->expr()->orX(
|
||||
'ap.confidential = FALSE',
|
||||
$qb->expr()->eq('ap.user', ':user')
|
||||
)
|
||||
);
|
||||
$orx->add($andXOnScope);
|
||||
}
|
||||
$qb->setParameter('scope_' . $key, $scope);
|
||||
$qb->setParameter('user', $this->security->getUser());
|
||||
}
|
||||
$qb->andWhere($orx);
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
return $qb;
|
||||
}
|
||||
|
||||
public function findByUnDispatched(array $jobs, array $services, array $administrativeLocations, ?int $limit = null, ?int $offset = null): array
|
||||
public function buildCenterOnScope(): array
|
||||
{
|
||||
$qb = $this->addACLByUnDispatched($this->buildQueryUnDispatched($jobs, $services, $administrativeLocations));
|
||||
$centerOnScopes = [];
|
||||
foreach ($this->authorizationHelper->getReachableCenters(AccompanyingPeriodVoter::SEE) as $center) {
|
||||
$centerOnScopes[] = [
|
||||
'center' => $center,
|
||||
'scopeOnRole' => $this->authorizationHelper->getReachableScopes(AccompanyingPeriodVoter::SEE, $center),
|
||||
'scopeCanSeeConfidential' => $this->authorizationHelper->getReachableScopes(AccompanyingPeriodVoter::SEE_CONFIDENTIAL_ALL, $center),
|
||||
];
|
||||
}
|
||||
|
||||
return $centerOnScopes;
|
||||
}
|
||||
|
||||
public function findByUnDispatched(array $jobs, array $services, array $administrativeAdministrativeLocations, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array
|
||||
{
|
||||
$qb = $this->buildQueryUnDispatched($jobs, $services, $administrativeAdministrativeLocations);
|
||||
$qb->select('ap');
|
||||
|
||||
if (null !== $limit) {
|
||||
$qb->setMaxResults($limit);
|
||||
}
|
||||
|
||||
if (null !== $offset) {
|
||||
$qb->setFirstResult($offset);
|
||||
}
|
||||
$qb = $this->addACLMultiCenterOnQuery($qb, $this->buildCenterOnScope(), false);
|
||||
$qb = $this->addOrderLimitClauses($qb, $orderBy, $limit, $offset);
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
@@ -225,76 +264,80 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC
|
||||
return [];
|
||||
}
|
||||
|
||||
$qb = $this->buildQueryOpenedAccompanyingCourseByUser($user);
|
||||
|
||||
$qb->setFirstResult($offset)
|
||||
->setMaxResults($limit);
|
||||
|
||||
foreach ($orderBy as $field => $direction) {
|
||||
$qb->addOrderBy('ap.' . $field, $direction);
|
||||
}
|
||||
$qb = $this->buildQueryOpenedAccompanyingCourseByUserAndPostalCodes($user, $postalCodes);
|
||||
$qb = $this->addACLMultiCenterOnQuery($qb, $this->buildCenterOnScope(), false);
|
||||
$qb = $this->addOrderLimitClauses($qb, $orderBy, $limit, $offset);
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|AccompanyingPeriod[]
|
||||
* @param QueryBuilder $qb
|
||||
* @param list<array{center: Center, scopeOnRole: list<Scope>, scopeCanSeeConfidential: list<Scope>}> $centerScopes
|
||||
* @param bool $allowNoCenter if true, will allow to see the periods linked to person which does not have any center. Very few edge case when some Person are not associated to a center.
|
||||
* @return QueryBuilder
|
||||
*/
|
||||
public function findByUserOpenedAccompanyingPeriod(?User $user, array $orderBy = [], int $limit = 0, int $offset = 50): array
|
||||
public function addACLMultiCenterOnQuery(QueryBuilder $qb, array $centerScopes, bool $allowNoCenter = false): QueryBuilder
|
||||
{
|
||||
if (null === $user) {
|
||||
return [];
|
||||
}
|
||||
$user = $this->security->getUser();
|
||||
|
||||
$qb = $this->buildQueryOpenedAccompanyingCourseByUser($user);
|
||||
|
||||
$qb->setFirstResult($offset)
|
||||
->setMaxResults($limit);
|
||||
|
||||
foreach ($orderBy as $field => $direction) {
|
||||
$qb->addOrderBy('ap.' . $field, $direction);
|
||||
}
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
private function addACLByUnDispatched(QueryBuilder $qb): QueryBuilder
|
||||
{
|
||||
$centers = $this->authorizationHelper->getReachableCenters(
|
||||
$this->security->getUser(),
|
||||
AccompanyingPeriodVoter::SEE
|
||||
);
|
||||
|
||||
$orX = $qb->expr()->orX();
|
||||
|
||||
if (0 === count($centers)) {
|
||||
if (0 === count($centerScopes) || !$user instanceof User) {
|
||||
return $qb->andWhere("'FALSE' = 'TRUE'");
|
||||
}
|
||||
|
||||
foreach ($centers as $key => $center) {
|
||||
$scopes = $this->authorizationHelper
|
||||
->getReachableCircles(
|
||||
$this->security->getUser(),
|
||||
AccompanyingPeriodVoter::SEE,
|
||||
$center
|
||||
);
|
||||
$orX = $qb->expr()->orX();
|
||||
|
||||
$idx = 0;
|
||||
foreach ($centerScopes as ['center' => $center, 'scopeOnRole' => $scopes, 'scopeCanSeeConfidential' => $scopesCanSeeConfidential]) {
|
||||
$and = $qb->expr()->andX(
|
||||
$qb->expr()->exists('SELECT part FROM ' . AccompanyingPeriodParticipation::class . ' part ' .
|
||||
"JOIN part.person p WHERE part.accompanyingPeriod = ap.id AND p.center = :center_{$key}")
|
||||
$qb->expr()->exists(
|
||||
'SELECT 1 FROM ' . AccompanyingPeriodParticipation::class . " part_{$idx} " .
|
||||
"JOIN part_{$idx}.person p{$idx} LEFT JOIN p{$idx}.centerCurrent centerCurrent_{$idx} " .
|
||||
"WHERE part_{$idx}.accompanyingPeriod = ap.id AND (centerCurrent_{$idx}.center = :center_{$idx}"
|
||||
. ($allowNoCenter ? " OR centerCurrent_{$idx}.id IS NULL)" : ")")
|
||||
)
|
||||
);
|
||||
$qb->setParameter('center_' . $key, $center);
|
||||
$orScope = $qb->expr()->orX();
|
||||
$qb->setParameter('center_' . $idx, $center);
|
||||
|
||||
foreach ($scopes as $skey => $scope) {
|
||||
$orScope->add(
|
||||
$qb->expr()->isMemberOf(':scope_' . $key . '_' . $skey, 'ap.scopes')
|
||||
$orScopeInsideCenter = $qb->expr()->orX(
|
||||
// even if the scope is not in one authorized, the user can see the course if it is in DRAFT state
|
||||
$qb->expr()->eq('ap.step', ':draft')
|
||||
);
|
||||
|
||||
$idx++;
|
||||
foreach ($scopes as $scope) {
|
||||
// for each scope:
|
||||
// - either the user is the referrer of the course
|
||||
// - or the accompanying course is one of the reachable scopes
|
||||
// - and the parcours is not confidential OR the user is the referrer OR the user can see the confidential course
|
||||
$orOnScope = $qb->expr()->orX(
|
||||
$qb->expr()->isMemberOf(':scope_' . $idx, 'ap.scopes'),
|
||||
$qb->expr()->eq('ap.user', ':user_executing')
|
||||
);
|
||||
$qb->setParameter('scope_' . $key . '_' . $skey, $scope);
|
||||
$qb->setParameter('user_executing', $user);
|
||||
|
||||
if (in_array($scope, $scopesCanSeeConfidential, true)) {
|
||||
$orScopeInsideCenter->add($orOnScope);
|
||||
} else {
|
||||
// we must add a condition: the course is not confidential or the user is the referrer
|
||||
$andXOnScope = $qb->expr()->andX(
|
||||
$orOnScope,
|
||||
$qb->expr()->orX(
|
||||
'ap.confidential = FALSE',
|
||||
$qb->expr()->eq('ap.user', ':user_executing')
|
||||
)
|
||||
);
|
||||
$orScopeInsideCenter->add($andXOnScope);
|
||||
}
|
||||
$qb->setParameter('scope_' . $idx, $scope);
|
||||
|
||||
$idx++;
|
||||
}
|
||||
|
||||
$and->add($orScope);
|
||||
$and->add($orScopeInsideCenter);
|
||||
$orX->add($and);
|
||||
|
||||
$idx++;
|
||||
}
|
||||
|
||||
return $qb->andWhere($orX);
|
||||
@@ -305,7 +348,7 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC
|
||||
* @param array|Scope[] $services
|
||||
* @param array|Location[] $locations
|
||||
*/
|
||||
private function buildQueryUnDispatched(array $jobs, array $services, array $locations): QueryBuilder
|
||||
public function buildQueryUnDispatched(array $jobs, array $services, array $locations): QueryBuilder
|
||||
{
|
||||
$qb = $this->accompanyingPeriodRepository->createQueryBuilder('ap');
|
||||
|
||||
@@ -333,8 +376,8 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC
|
||||
$or = $qb->expr()->orX();
|
||||
|
||||
foreach ($services as $key => $service) {
|
||||
$or->add($qb->expr()->isMemberOf(':scope_' . $key, 'ap.scopes'));
|
||||
$qb->setParameter('scope_' . $key, $service);
|
||||
$or->add($qb->expr()->isMemberOf(':scopef_' . $key, 'ap.scopes'));
|
||||
$qb->setParameter('scopef_' . $key, $service);
|
||||
}
|
||||
$qb->andWhere($or);
|
||||
}
|
||||
|
@@ -31,28 +31,28 @@ interface AccompanyingPeriodACLAwareRepositoryInterface
|
||||
*/
|
||||
public function countByUserAndPostalCodesOpenedAccompanyingPeriod(?User $user, array $postalCodes): int;
|
||||
|
||||
public function countByUserOpenedAccompanyingPeriod(?User $user): int;
|
||||
|
||||
/**
|
||||
* @return array<AccompanyingPeriod>
|
||||
*/
|
||||
public function findByPerson(
|
||||
Person $person,
|
||||
string $role,
|
||||
?array $orderBy = [],
|
||||
?int $limit = null,
|
||||
?int $offset = null
|
||||
?int $limit = null,
|
||||
?int $offset = null
|
||||
): array;
|
||||
|
||||
/**
|
||||
* @param array|UserJob[] $jobs if empty, does not take this argument into account
|
||||
* @param array|Scope[] $services if empty, does not take this argument into account
|
||||
*
|
||||
* @return array|AccompanyingPeriod[]
|
||||
* @return list<AccompanyingPeriod>
|
||||
*/
|
||||
public function findByUnDispatched(array $jobs, array $services, array $administrativeLocations, ?int $limit = null, ?int $offset = null): array;
|
||||
public function findByUnDispatched(array $jobs, array $services, array $administrativeAdministrativeLocations, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array;
|
||||
|
||||
/**
|
||||
* @param array|PostalCode[] $postalCodes
|
||||
* @return list<AccompanyingPeriod>
|
||||
*/
|
||||
public function findByUserAndPostalCodesOpenedAccompanyingPeriod(?User $user, array $postalCodes, array $orderBy = [], int $limit = 0, int $offset = 50): array;
|
||||
|
||||
public function findByUserOpenedAccompanyingPeriod(?User $user, array $orderBy = [], int $limit = 0, int $offset = 50): array;
|
||||
}
|
||||
|
@@ -1,9 +1,11 @@
|
||||
<div class="accompanying-course-work">
|
||||
<div class="accompanying-course-work">
|
||||
{% for w in works | slice(0,5) %}
|
||||
|
||||
<a href="{{ chill_path_add_return_path('chill_person_accompanying_period_work_edit', { 'id': w.id }) }}"
|
||||
class="dashboard-link" title="{{ 'crud.social_action.title_link'|trans }}">
|
||||
|
||||
<a href="{%- if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', w) -%}
|
||||
{{- chill_path_add_return_path('chill_person_accompanying_period_work_edit', { 'id': w.id }) -}}
|
||||
{%- elseif is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_SEE', w) -%}
|
||||
{{- chill_path_add_return_path('chill_person_accompanying_period_work_show', { 'id': w.id }) -}}
|
||||
{%- else %}#{% endif -%}" class="dashboard-link" title="{{ 'crud.social_action.title_link'|trans }}">
|
||||
<div class="dashboard">
|
||||
<span class="title_label"></span>
|
||||
<span class="title_action"><span class="like-h3">{{ w.socialAction|chill_entity_render_string }}</span>
|
||||
@@ -14,7 +16,7 @@
|
||||
<b>{{ w.startDate|format_date('short') }}</b>
|
||||
</li>
|
||||
{% if w.endDate %}
|
||||
<li>
|
||||
<li>
|
||||
<span class="item-key">{{ 'accompanying_course_work.end_date'|trans ~ ' : ' }}</span>
|
||||
<b>{{ w.endDate|format_date('short') }}</b>
|
||||
</li>
|
||||
@@ -23,20 +25,20 @@
|
||||
|
||||
<ul class="small_in_title">
|
||||
{% if w.handlingThierParty %}
|
||||
<li>
|
||||
<li>
|
||||
<span class="item-key">{{ 'Thirdparty handling'|trans ~ ' : ' }}</span>
|
||||
<span class="badge-thirdparty">{{ w.handlingThierParty|chill_entity_render_box }}</span>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if w.referrers %}
|
||||
<li>
|
||||
<li>
|
||||
<span class="item-key">{{ 'Referrers'|trans ~ ' : ' }}</span>
|
||||
{% for u in w.referrers %}
|
||||
<span class="badge-user">{{ u|chill_entity_render_box }}</span>
|
||||
{% endfor %}
|
||||
{% if w.referrers|length == 0 %}
|
||||
<span class="chill-no-data-statement">{{ 'Not given'|trans }}</span>
|
||||
{% endif %}
|
||||
{% if w.referrers|length == 0 %}
|
||||
<span class="chill-no-data-statement">{{ 'Not given'|trans }}</span>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endif %}
|
||||
<li class="associated-persons">
|
||||
@@ -65,8 +67,8 @@
|
||||
</span>
|
||||
</div>
|
||||
|
||||
</a>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
@@ -42,11 +42,6 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
||||
self::RE_OPEN_COURSE,
|
||||
];
|
||||
|
||||
/**
|
||||
* Give the ability to see all confidential courses.
|
||||
*/
|
||||
public const CONFIDENTIAL_CRUD = 'CHILL_PERSON_ACCOMPANYING_PERIOD_CRUD_CONFIDENTIAL';
|
||||
|
||||
public const CREATE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_CREATE';
|
||||
|
||||
/**
|
||||
@@ -107,6 +102,11 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
||||
*/
|
||||
public const TOGGLE_INTENSITY = 'CHILL_PERSON_ACCOMPANYING_PERIOD_TOGGLE_INTENSITY';
|
||||
|
||||
/**
|
||||
* Right to see confidential period even if not referrer
|
||||
*/
|
||||
public const SEE_CONFIDENTIAL_ALL = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_CONFIDENTIAL';
|
||||
|
||||
private Security $security;
|
||||
|
||||
private VoterHelperInterface $voterHelper;
|
||||
@@ -131,7 +131,6 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
||||
return [
|
||||
self::SEE,
|
||||
self::SEE_DETAILS,
|
||||
self::CONFIDENTIAL_CRUD,
|
||||
self::CREATE,
|
||||
self::EDIT,
|
||||
self::DELETE,
|
||||
@@ -139,6 +138,7 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
||||
self::TOGGLE_CONFIDENTIAL_ALL,
|
||||
self::REASSIGN_BULK,
|
||||
self::STATS,
|
||||
self::SEE_CONFIDENTIAL_ALL,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
||||
|
||||
public function getRolesWithoutScope(): array
|
||||
{
|
||||
return [self::REASSIGN_BULK];
|
||||
return [];
|
||||
}
|
||||
|
||||
protected function supports($attribute, $subject)
|
||||
@@ -216,7 +216,7 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
||||
|
||||
// if confidential, only the referent can see it
|
||||
if ($subject->isConfidential()) {
|
||||
if ($this->voterHelper->voteOnAttribute(self::CONFIDENTIAL_CRUD, $subject, $token)) {
|
||||
if ($this->voterHelper->voteOnAttribute(self::SEE_CONFIDENTIAL_ALL, $subject, $token)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -360,10 +360,12 @@ final class PersonContext implements PersonContextInterface
|
||||
|
||||
private function isScopeNecessary(Person $person): bool
|
||||
{
|
||||
if ($this->showScopes && 1 < $this->authorizationHelper->getReachableScopes(
|
||||
$this->security->getUser(),
|
||||
PersonDocumentVoter::CREATE,
|
||||
$this->centerResolverManager->resolveCenters($person)
|
||||
if ($this->showScopes && 1 < count(
|
||||
$this->authorizationHelper->getReachableScopes(
|
||||
$this->security->getUser(),
|
||||
PersonDocumentVoter::CREATE,
|
||||
$this->centerResolverManager->resolveCenters($person)
|
||||
)
|
||||
)) {
|
||||
return true;
|
||||
}
|
||||
|
@@ -0,0 +1,517 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Repository;
|
||||
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Repository\CenterRepositoryInterface;
|
||||
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface;
|
||||
use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepository;
|
||||
use Chill\PersonBundle\Repository\AccompanyingPeriodRepository;
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Prophecy\Argument;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Workflow\Registry;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class AccompanyingPeriodACLAwareRepositoryTest extends KernelTestCase
|
||||
{
|
||||
use ProphecyTrait;
|
||||
|
||||
private AccompanyingPeriodRepository $accompanyingPeriodRepository;
|
||||
|
||||
private CenterResolverManagerInterface $centerResolverManager;
|
||||
|
||||
private CenterRepositoryInterface $centerRepository;
|
||||
|
||||
private EntityManagerInterface $entityManager;
|
||||
|
||||
private ScopeRepositoryInterface $scopeRepository;
|
||||
|
||||
private Registry $registry;
|
||||
|
||||
private static array $periodsIdsToDelete = [];
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
self::bootKernel();
|
||||
$this->accompanyingPeriodRepository = self::$container->get(AccompanyingPeriodRepository::class);
|
||||
$this->centerRepository = self::$container->get(CenterRepositoryInterface::class);
|
||||
$this->centerResolverManager = self::$container->get(CenterResolverManagerInterface::class);
|
||||
$this->entityManager = self::$container->get(EntityManagerInterface::class);
|
||||
$this->scopeRepository = self::$container->get(ScopeRepositoryInterface::class);
|
||||
$this->registry = self::$container->get(Registry::class);
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass(): void
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
$repository = self::$container->get(AccompanyingPeriodRepository::class);
|
||||
|
||||
foreach (self::$periodsIdsToDelete as $id) {
|
||||
if (null === $period = $repository->find($id)) {
|
||||
throw new \RuntimeException("period not found while trying to delete it");
|
||||
}
|
||||
|
||||
foreach ($period->getParticipations() as $participation) {
|
||||
$em->remove($participation);
|
||||
}
|
||||
$em->remove($period);
|
||||
}
|
||||
|
||||
//$em->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideDataFindByUserAndPostalCodesOpenedAccompanyingPeriod
|
||||
* @param list<array{center: Center, scopeOnRole: list<Scope>, scopeCanSeeConfidential: list<Scope>}> $centerScopes
|
||||
* @param list<AccompanyingPeriod> $expectedContains
|
||||
* @param list<AccompanyingPeriod> $expectedNotContains
|
||||
*/
|
||||
public function testFindByUserAndPostalCodesOpenedAccompanyingPeriod(User $user, User $searched, array $centerScopes, array $expectedContains, array $expectedNotContains, string $message): void
|
||||
{
|
||||
$security = $this->prophesize(Security::class);
|
||||
$security->getUser()->willReturn($user);
|
||||
|
||||
$authorizationHelper = $this->prophesize(AuthorizationHelperForCurrentUserInterface::class);
|
||||
$centers = [];
|
||||
|
||||
foreach ($centerScopes as ['center' => $center, 'scopeOnRole' => $scopes, 'scopeCanSeeConfidential' => $scopesCanSeeConfidential]) {
|
||||
$centers[spl_object_hash($center)] = $center;
|
||||
$authorizationHelper->getReachableScopes(AccompanyingPeriodVoter::SEE, $center)
|
||||
->willReturn($scopes);
|
||||
$authorizationHelper->getReachableScopes(AccompanyingPeriodVoter::SEE_CONFIDENTIAL_ALL, $center)
|
||||
->willReturn($scopesCanSeeConfidential);
|
||||
}
|
||||
$authorizationHelper->getReachableCenters(AccompanyingPeriodVoter::SEE)->willReturn(array_values($centers));
|
||||
|
||||
$repository = new AccompanyingPeriodACLAwareRepository(
|
||||
$this->accompanyingPeriodRepository,
|
||||
$security->reveal(),
|
||||
$authorizationHelper->reveal(),
|
||||
$this->centerResolverManager
|
||||
);
|
||||
|
||||
$actual = array_map(
|
||||
fn (AccompanyingPeriod $period) => $period->getId(),
|
||||
$repository->findByUserAndPostalCodesOpenedAccompanyingPeriod($searched, [], ['id' => 'DESC'], 20, 0)
|
||||
);
|
||||
|
||||
foreach ($expectedContains as $expected) {
|
||||
self::assertContains($expected->getId(), $actual, $message);
|
||||
}
|
||||
foreach ($expectedNotContains as $expected) {
|
||||
self::assertNotContains($expected->getId(), $actual, $message);
|
||||
}
|
||||
}
|
||||
|
||||
public function provideDataFindByUserAndPostalCodesOpenedAccompanyingPeriod(): iterable
|
||||
{
|
||||
$this->setUp();
|
||||
|
||||
if (null === $user = $this->entityManager->createQuery("SELECT u FROM " . User::class . " u")->setMaxResults(1)->getSingleResult()) {
|
||||
throw new \RuntimeException("no user found");
|
||||
}
|
||||
|
||||
if (null === $anotherUser = $this->entityManager->createQuery("SELECT u FROM " . User::class . " u WHERE u.id != :uid")->setParameter('uid', $user->getId())
|
||||
->setMaxResults(1)->getSingleResult()) {
|
||||
throw new \RuntimeException("no user found");
|
||||
}
|
||||
|
||||
/** @var Person $person */
|
||||
[$person, $anotherPerson, $person2, $person3] = $this->entityManager
|
||||
->createQuery("SELECT p FROM " . Person::class . " p JOIN p.centerCurrent current_center")
|
||||
->setMaxResults(4)
|
||||
->getResult();
|
||||
|
||||
if (null === $person || null === $anotherPerson || null === $person2 || null === $person3) {
|
||||
throw new \RuntimeException("no person found");
|
||||
}
|
||||
|
||||
$scopes = $this->scopeRepository->findAll();
|
||||
|
||||
if (3 > count($scopes)) {
|
||||
throw new \RuntimeException("not enough scopes for this test");
|
||||
}
|
||||
$scopesCanSee = [ $scopes[0] ];
|
||||
$scopesGroup2 = [ $scopes[1] ];
|
||||
|
||||
$centers = $this->centerRepository->findActive();
|
||||
$aCenterNotAssociatedToPerson = array_values(array_filter($centers, fn (Center $c) => $c !== $person->getCenter()))[0];
|
||||
|
||||
if (2 > count($centers)) {
|
||||
throw new \RuntimeException("not enough centers for this test");
|
||||
}
|
||||
|
||||
$period = $this->buildPeriod($person, $scopesCanSee, $user, true);
|
||||
$period->setUser($user);
|
||||
|
||||
yield [
|
||||
$anotherUser,
|
||||
$user,
|
||||
[
|
||||
[
|
||||
'center' => $person->getCenter(),
|
||||
'scopeOnRole' => $scopesCanSee,
|
||||
'scopeCanSeeConfidential' => [],
|
||||
],
|
||||
],
|
||||
[$period],
|
||||
[],
|
||||
"period should be visible with expected scopes",
|
||||
];
|
||||
|
||||
yield [
|
||||
$anotherUser,
|
||||
$user,
|
||||
[
|
||||
[
|
||||
'center' => $person->getCenter(),
|
||||
'scopeOnRole' => $scopesGroup2,
|
||||
'scopeCanSeeConfidential' => [],
|
||||
],
|
||||
],
|
||||
[],
|
||||
[$period],
|
||||
"period should not be visible without expected scopes",
|
||||
];
|
||||
|
||||
yield [
|
||||
$anotherUser,
|
||||
$user,
|
||||
[
|
||||
[
|
||||
'center' => $person->getCenter(),
|
||||
'scopeOnRole' => $scopesGroup2,
|
||||
'scopeCanSeeConfidential' => [],
|
||||
],
|
||||
[
|
||||
'center' => $aCenterNotAssociatedToPerson,
|
||||
'scopeOnRole' => $scopesCanSee,
|
||||
'scopeCanSeeConfidential' => [],
|
||||
],
|
||||
],
|
||||
[],
|
||||
[$period],
|
||||
"period should not be visible for user having right in another scope (with multiple centers)"
|
||||
];
|
||||
|
||||
$period = $this->buildPeriod($person, $scopesCanSee, $user, true);
|
||||
$period->setUser($user);
|
||||
$period->setConfidential(true);
|
||||
|
||||
yield [
|
||||
$anotherUser,
|
||||
$user,
|
||||
[
|
||||
[
|
||||
'center' => $person->getCenter(),
|
||||
'scopeOnRole' => $scopesCanSee,
|
||||
'scopeCanSeeConfidential' => [],
|
||||
],
|
||||
],
|
||||
[],
|
||||
[$period],
|
||||
"period confidential should not be visible",
|
||||
];
|
||||
|
||||
yield [
|
||||
$anotherUser,
|
||||
$user,
|
||||
[
|
||||
[
|
||||
'center' => $person->getCenter(),
|
||||
'scopeOnRole' => $scopesCanSee,
|
||||
'scopeCanSeeConfidential' => $scopesCanSee,
|
||||
],
|
||||
],
|
||||
[$period],
|
||||
[],
|
||||
"period confidential be visible if user has required scopes",
|
||||
];
|
||||
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideDataFindByUndispatched
|
||||
* @param list<array{center: Center, scopeOnRole: list<Scope>, scopeCanSeeConfidential: list<Scope>}> $centerScopes
|
||||
* @param list<AccompanyingPeriod> $expectedContains
|
||||
* @param list<AccompanyingPeriod> $expectedNotContains
|
||||
*/
|
||||
public function testFindByUndispatched(User $user, array $centerScopes, array $expectedContains, array $expectedNotContains, string $message): void
|
||||
{
|
||||
$security = $this->prophesize(Security::class);
|
||||
$security->getUser()->willReturn($user);
|
||||
|
||||
$authorizationHelper = $this->prophesize(AuthorizationHelperForCurrentUserInterface::class);
|
||||
$centers = [];
|
||||
|
||||
foreach ($centerScopes as ['center' => $center, 'scopeOnRole' => $scopes, 'scopeCanSeeConfidential' => $scopesCanSeeConfidential]) {
|
||||
$centers[spl_object_hash($center)] = $center;
|
||||
$authorizationHelper->getReachableScopes(AccompanyingPeriodVoter::SEE, $center)
|
||||
->willReturn($scopes);
|
||||
$authorizationHelper->getReachableScopes(AccompanyingPeriodVoter::SEE_CONFIDENTIAL_ALL, $center)
|
||||
->willReturn($scopesCanSeeConfidential);
|
||||
}
|
||||
$authorizationHelper->getReachableCenters(AccompanyingPeriodVoter::SEE)->willReturn(array_values($centers));
|
||||
|
||||
$repository = new AccompanyingPeriodACLAwareRepository(
|
||||
$this->accompanyingPeriodRepository,
|
||||
$security->reveal(),
|
||||
$authorizationHelper->reveal(),
|
||||
$this->centerResolverManager
|
||||
);
|
||||
|
||||
$actual = array_map(
|
||||
fn (AccompanyingPeriod $period) => $period->getId(),
|
||||
$repository->findByUnDispatched([], [], [], ['id' => 'DESC'], 20, 0)
|
||||
);
|
||||
|
||||
foreach ($expectedContains as $expected) {
|
||||
self::assertContains($expected->getId(), $actual, $message);
|
||||
}
|
||||
foreach ($expectedNotContains as $expected) {
|
||||
self::assertNotContains($expected->getId(), $actual, $message);
|
||||
}
|
||||
}
|
||||
|
||||
public function provideDataFindByUndispatched(): iterable
|
||||
{
|
||||
$this->setUp();
|
||||
|
||||
if (null === $user = $this->entityManager->createQuery("SELECT u FROM " . User::class . " u")->setMaxResults(1)->getSingleResult()) {
|
||||
throw new \RuntimeException("no user found");
|
||||
}
|
||||
|
||||
if (null === $anotherUser = $this->entityManager->createQuery("SELECT u FROM " . User::class . " u WHERE u.id != :uid")->setParameter('uid', $user->getId())
|
||||
->setMaxResults(1)->getSingleResult()) {
|
||||
throw new \RuntimeException("no user found");
|
||||
}
|
||||
|
||||
/** @var Person $person */
|
||||
[$person, $anotherPerson, $person2, $person3] = $this->entityManager
|
||||
->createQuery("SELECT p FROM " . Person::class . " p ")
|
||||
->setMaxResults(4)
|
||||
->getResult();
|
||||
|
||||
if (null === $person || null === $anotherPerson || null === $person2 || null === $person3) {
|
||||
throw new \RuntimeException("no person found");
|
||||
}
|
||||
|
||||
$scopes = $this->scopeRepository->findAll();
|
||||
|
||||
if (3 > count($scopes)) {
|
||||
throw new \RuntimeException("not enough scopes for this test");
|
||||
}
|
||||
$scopesCanSee = [ $scopes[0] ];
|
||||
$scopesGroup2 = [ $scopes[1] ];
|
||||
|
||||
$centers = $this->centerRepository->findActive();
|
||||
|
||||
if (2 > count($centers)) {
|
||||
throw new \RuntimeException("not enough centers for this test");
|
||||
}
|
||||
|
||||
$period = $this->buildPeriod($person, $scopesCanSee, $user, true);
|
||||
|
||||
|
||||
// expected scope: can see the period
|
||||
yield [
|
||||
$anotherUser,
|
||||
[
|
||||
[
|
||||
'center' => $person->getCenter(),
|
||||
'scopeOnRole' => $scopesCanSee,
|
||||
'scopeCanSeeConfidential' => [],
|
||||
],
|
||||
],
|
||||
[$period],
|
||||
[],
|
||||
"period should be visible with expected scopes",
|
||||
];
|
||||
|
||||
// no scope visible
|
||||
yield [
|
||||
$anotherUser,
|
||||
[
|
||||
[
|
||||
'center' => $person->getCenter(),
|
||||
'scopeOnRole' => $scopesGroup2,
|
||||
'scopeCanSeeConfidential' => [],
|
||||
],
|
||||
],
|
||||
[],
|
||||
[$period],
|
||||
"period should not be visible without expected scopes",
|
||||
];
|
||||
|
||||
// another center
|
||||
yield [
|
||||
$anotherUser,
|
||||
[
|
||||
[
|
||||
'center' => $person->getCenter(),
|
||||
'scopeOnRole' => $scopesGroup2,
|
||||
'scopeCanSeeConfidential' => [],
|
||||
],
|
||||
[
|
||||
'center' => array_values(array_filter($centers, fn (Center $c) => $c !== $person->getCenter()))[0],
|
||||
'scopeOnRole' => $scopesCanSee,
|
||||
'scopeCanSeeConfidential' => [],
|
||||
],
|
||||
],
|
||||
[],
|
||||
[$period],
|
||||
"period should not be visible for user having right in another scope (with multiple centers)"
|
||||
];
|
||||
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* For testing this method, we mock the authorization helper to return different Scope that a user
|
||||
* can see, or that a user can see confidential periods.
|
||||
*
|
||||
* @param array<Scope> $scopeUserCanSee
|
||||
* @param array<Scope> $scopeUserCanSeeConfidential
|
||||
* @param array<AccompanyingPeriod> $expectedPeriod
|
||||
* @dataProvider provideDataForFindByPerson
|
||||
*/
|
||||
public function testFindByPersonTestUser(User $user, Person $person, array $scopeUserCanSee, array $scopeUserCanSeeConfidential, array $expectedPeriod, string $message): void
|
||||
{
|
||||
$security = $this->prophesize(Security::class);
|
||||
$security->getUser()->willReturn($user);
|
||||
|
||||
$authorizationHelper = $this->prophesize(AuthorizationHelperForCurrentUserInterface::class);
|
||||
$authorizationHelper->getReachableScopes(AccompanyingPeriodVoter::SEE, Argument::any())
|
||||
->willReturn($scopeUserCanSee);
|
||||
$authorizationHelper->getReachableScopes(AccompanyingPeriodVoter::SEE_CONFIDENTIAL_ALL, Argument::any())
|
||||
->willReturn($scopeUserCanSeeConfidential);
|
||||
|
||||
$repository = new AccompanyingPeriodACLAwareRepository(
|
||||
$this->accompanyingPeriodRepository,
|
||||
$security->reveal(),
|
||||
$authorizationHelper->reveal(),
|
||||
$this->centerResolverManager
|
||||
);
|
||||
|
||||
$actuals = $repository->findByPerson($person, AccompanyingPeriodVoter::SEE);
|
||||
$expectedIds = array_map(fn (AccompanyingPeriod $period) => $period->getId(), $expectedPeriod);
|
||||
|
||||
self::assertCount(count($expectedPeriod), $actuals, $message);
|
||||
foreach ($actuals as $actual) {
|
||||
self::assertContains($actual->getId(), $expectedIds);
|
||||
}
|
||||
}
|
||||
|
||||
public function provideDataForFindByPerson(): iterable
|
||||
{
|
||||
$this->setUp();
|
||||
|
||||
if (null === $user = $this->entityManager->createQuery("SELECT u FROM " . User::class . " u")->setMaxResults(1)->getSingleResult()) {
|
||||
throw new \RuntimeException("no user found");
|
||||
}
|
||||
|
||||
if (null === $anotherUser = $this->entityManager->createQuery("SELECT u FROM " . User::class . " u WHERE u.id != :uid")->setParameter('uid', $user->getId())
|
||||
->setMaxResults(1)->getSingleResult()) {
|
||||
throw new \RuntimeException("no user found");
|
||||
}
|
||||
|
||||
[$person, $anotherPerson, $person2, $person3] = $this->entityManager
|
||||
->createQuery("SELECT p FROM " . Person::class . " p WHERE SIZE(p.accompanyingPeriodParticipations) = 0")
|
||||
->setMaxResults(4)
|
||||
->getResult();
|
||||
|
||||
if (null === $person || null === $anotherPerson || null === $person2 || null === $person3) {
|
||||
throw new \RuntimeException("no person found");
|
||||
}
|
||||
|
||||
$scopes = $this->scopeRepository->findAll();
|
||||
|
||||
if (3 > count($scopes)) {
|
||||
throw new \RuntimeException("not enough scopes for this test");
|
||||
}
|
||||
$scopesCanSee = [ $scopes[0] ];
|
||||
$scopesGroup2 = [ $scopes[1] ];
|
||||
|
||||
// case: a period is in draft state
|
||||
$period = $this->buildPeriod($person, $scopesCanSee, $user, false);
|
||||
|
||||
yield [$user, $person, $scopesCanSee, [], [$period], "a user can see his period during draft state"];
|
||||
|
||||
// another user is not allowed to see this period, because it is in DRAFT state
|
||||
yield [$anotherUser, $person, $scopesCanSee, [], [], "another user is not allowed to see the period of someone else in draft state"];
|
||||
|
||||
// the period is confirmed
|
||||
$period = $this->buildPeriod($anotherPerson, $scopesCanSee, $user, true);
|
||||
|
||||
// the other user can now see it
|
||||
yield [$user, $anotherPerson, $scopesCanSee, [], [$period], "a user see his period when confirmed"];
|
||||
yield [$anotherUser, $anotherPerson, $scopesCanSee, [], [$period], "another user with required scopes is allowed to see the period when not draft"];
|
||||
yield [$anotherUser, $anotherPerson, $scopesGroup2, [], [], "another user without the required scopes is not allowed to see the period when not draft"];
|
||||
|
||||
// this period will be confidential
|
||||
$period = $this->buildPeriod($person2, $scopesCanSee, $user, true);
|
||||
$period->setConfidential(true)->setUser($user, true);
|
||||
|
||||
yield [$user, $person2, $scopesCanSee, [], [$period], "a user see his period when confirmed and confidential with required scopes"];
|
||||
yield [$user, $person2, $scopesGroup2, [], [$period], "a user see his period when confirmed and confidential without required scopes"];
|
||||
yield [$anotherUser, $person2, $scopesCanSee, [], [], "a user don't see a confidential period, even if he has required scopes"];
|
||||
yield [$anotherUser, $person2, $scopesCanSee, $scopesCanSee, [$period], "a user see the period when confirmed and confidential if he has required scope to see the period"];
|
||||
|
||||
// period draft with creator = null
|
||||
$period = $this->buildPeriod($person3, $scopesCanSee, null, false);
|
||||
yield [$user, $person3, $scopesCanSee, [], [$period], "a user see a period when draft if no creator on the period"];
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Person $person
|
||||
* @param array<Scope> $scopes
|
||||
* @return AccompanyingPeriod
|
||||
*/
|
||||
private function buildPeriod(Person $person, array $scopes, User|null $creator, bool $confirm): AccompanyingPeriod
|
||||
{
|
||||
$period = new AccompanyingPeriod();
|
||||
$period->addPerson($person);
|
||||
if (null !== $creator) {
|
||||
$period->setCreatedBy($creator);
|
||||
}
|
||||
|
||||
foreach ($scopes as $scope) {
|
||||
$period->addScope($scope);
|
||||
}
|
||||
|
||||
$this->entityManager->persist($period);
|
||||
self::$periodsIdsToDelete[] = $period->getId();
|
||||
|
||||
if ($confirm) {
|
||||
$workflow = $this->registry->get($period, 'accompanying_period_lifecycle');
|
||||
$workflow->apply($period, 'confirm');
|
||||
}
|
||||
|
||||
return $period;
|
||||
}
|
||||
}
|
@@ -135,6 +135,14 @@ services:
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: accompanyingcourse_user_working_on_filter }
|
||||
|
||||
Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\JobWorkingOnCourseFilter:
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: accompanyingcourse_job_working_on_filter }
|
||||
|
||||
Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\ScopeWorkingOnCourseFilter:
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: accompanyingcourse_scope_working_on_filter }
|
||||
|
||||
Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\HavingAnAccompanyingPeriodInfoWithinDatesFilter:
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: accompanyingcourse_info_within_filter }
|
||||
@@ -231,3 +239,15 @@ services:
|
||||
Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\CreatorJobAggregator:
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: accompanyingcourse_creator_job_aggregator }
|
||||
|
||||
Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\UserWorkingOnCourseAggregator:
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: accompanyingcourse_user_working_on_course_aggregator }
|
||||
|
||||
Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\JobWorkingOnCourseAggregator:
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: accompanyingcourse_job_working_on_course_aggregator }
|
||||
|
||||
Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ScopeWorkingOnCourseAggregator:
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: accompanyingcourse_scope_working_on_course_aggregator }
|
||||
|
@@ -4,35 +4,27 @@ services:
|
||||
autowire: true
|
||||
|
||||
## Indicators
|
||||
chill.person.export.count_person:
|
||||
class: Chill\PersonBundle\Export\Export\CountPerson
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
Chill\PersonBundle\Export\Export\CountPerson:
|
||||
tags:
|
||||
- { name: chill.export, alias: count_person }
|
||||
|
||||
chill.person.export.count_person_with_accompanying_course:
|
||||
class: Chill\PersonBundle\Export\Export\CountPersonWithAccompanyingCourse
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
Chill\PersonBundle\Export\Export\CountPersonWithAccompanyingCourse:
|
||||
tags:
|
||||
- { name: chill.export, alias: count_person_with_accompanying_course }
|
||||
|
||||
Chill\PersonBundle\Export\Export\ListPerson:
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export, alias: list_person }
|
||||
|
||||
Chill\PersonBundle\Export\Export\ListPersonWithAccompanyingPeriod:
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
Chill\PersonBundle\Export\Export\ListPersonHavingAccompanyingPeriod:
|
||||
tags:
|
||||
- { name: chill.export, alias: list_person_with_acp }
|
||||
|
||||
Chill\PersonBundle\Export\Export\ListPersonWithAccompanyingPeriodDetails:
|
||||
tags:
|
||||
- { name: chill.export, alias: list_person_with_acp_details }
|
||||
|
||||
Chill\PersonBundle\Export\Export\ListAccompanyingPeriod:
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export, alias: list_acp }
|
||||
|
||||
@@ -177,3 +169,8 @@ services:
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: person_household_compo_aggregator }
|
||||
|
||||
Chill\PersonBundle\Export\Aggregator\PersonAggregators\CenterAggregator:
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: person_center_aggregator }
|
||||
|
||||
|
||||
|
@@ -329,8 +329,9 @@ CHILL_PERSON_ACCOMPANYING_PERIOD_CREATE: Créer un parcours d'accompagnement
|
||||
CHILL_PERSON_ACCOMPANYING_PERIOD_UPDATE: Modifier un parcours d'accompagnement
|
||||
CHILL_PERSON_ACCOMPANYING_PERIOD_FULL: Voir les détails, créer, supprimer et mettre à jour un parcours d'accompagnement
|
||||
CHILL_PERSON_ACCOMPANYING_COURSE_REASSIGN_BULK: Réassigner les parcours en lot
|
||||
CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_DETAILS: Voir les détails d'un parcours d'accompagnement
|
||||
CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_DETAILS: Voir les détails d'un parcours d'accompagnement
|
||||
CHILL_PERSON_ACCOMPANYING_PERIOD_STATS: Statistiques sur les parcours d'accompagnement
|
||||
CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_CONFIDENTIAL: Voir les parcours confidentiels
|
||||
|
||||
CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_CREATE: Créer une action d'accompagnement
|
||||
CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_DELETE: Supprimer une action d'accompagnement
|
||||
@@ -372,7 +373,7 @@ Count people participating in an accompanying course by various parameters.: Com
|
||||
Exports of accompanying courses: Exports des parcours d'accompagnement
|
||||
Count accompanying courses: Nombre de parcours
|
||||
Count accompanying courses by various parameters: Compte le nombre de parcours en fonction de différents filtres.
|
||||
Accompanying courses participation duration and number of participations: Durée moyenne et nombre des participation des usagers aux parcours
|
||||
Accompanying courses participation duration and number of participations: Durée moyenne et nombre des participations des usagers aux parcours
|
||||
Create an average of accompanying courses duration of each person participation to accompanying course, according to filters on persons, accompanying course: Crée un rapport qui comptabilise la moyenne de la durée de participation de chaque usager concerné aux parcours, avec différents filtres, notamment sur les usagers concernés.
|
||||
Closingdate to apply: Date de fin à prendre en compte lorsque le parcours n'est pas clotûré
|
||||
|
||||
@@ -1000,6 +1001,8 @@ notification:
|
||||
Notify referrer: Notifier le référent
|
||||
Notify any: Notifier d'autres utilisateurs
|
||||
|
||||
personId: Identifiant de l'usager
|
||||
|
||||
export:
|
||||
export:
|
||||
acp_stats:
|
||||
@@ -1019,6 +1022,11 @@ export:
|
||||
Household composition: Composition du ménage
|
||||
Group course by household composition: Grouper les usagers par composition familiale
|
||||
Calc date: Date de calcul de la composition du ménage
|
||||
by_center:
|
||||
title: Grouper les usagers par centre
|
||||
at_date: Date de calcul du centre
|
||||
center: Centre de l'usager
|
||||
|
||||
course:
|
||||
by_referrer:
|
||||
Computation date for referrer: Date à laquelle le référent était actif
|
||||
@@ -1035,6 +1043,15 @@ export:
|
||||
Number of actions: Nombre d'actions
|
||||
by_creator_job:
|
||||
Creator's job: Métier du créateur
|
||||
by_user_working:
|
||||
title: Grouper les parcours par intervenant
|
||||
user: Intervenant
|
||||
by_job_working:
|
||||
title: Grouper les parcours par métier de l'intervenant
|
||||
job: Métier de l'intervenant
|
||||
by_scope_working:
|
||||
title: Grouper les parcours par service de l'intervenant
|
||||
scope: Service de l'intervenant
|
||||
course_work:
|
||||
by_current_action:
|
||||
Current action ?: Action en cours ?
|
||||
@@ -1084,8 +1101,20 @@ export:
|
||||
end_date: Fin de la période
|
||||
Only course with events between %startDate% and %endDate%: Seulement les parcours ayant reçu une intervention entre le %startDate% et le %endDate%
|
||||
by_user_working:
|
||||
title: Filter les parcours par intervenant
|
||||
'Filtered by user working on course: only %users%': 'Filtré par intervenants sur le parcours: seulement %users%'
|
||||
title: Filter les parcours par intervenant, entre deux dates
|
||||
'Filtered by user working on course: only %users%, between %start_date% and %end_date%': 'Filtré par intervenants sur le parcours: seulement %users%, entre le %start_date% et le %end_date%'
|
||||
User working after: Intervention après le
|
||||
User working before: Intervention avant le
|
||||
by_job_working:
|
||||
title: Filtrer les parcours par métier de l'intervenant, entre deux dates
|
||||
'Filtered by job working on course: only %jobs%, between %start_date% and %end_date%': 'Filtré par métier des intervenants sur le parcours: seulement %jobs%, entre le %start_date% et le %end_date%'
|
||||
Job working after: Intervention après le
|
||||
Job working before: Intervention avant le
|
||||
by_scope_working:
|
||||
title: Filtrer les parcours par service de l'intervenant, entre deux dates
|
||||
'Filtered by scope working on course: only %scopes%, between %start_date% and %end_date%': 'Filtré par service des intervenants sur le parcours: seulement %scopes%, entre le %start_date% et le %end_date%'
|
||||
Scope working after: Intervention après le
|
||||
Scope working before: Intervention avant le
|
||||
by_step:
|
||||
Filter by step: Filtrer les parcours par statut du parcours
|
||||
Filter by step between dates: Filtrer les parcours par statut du parcours entre deux dates
|
||||
@@ -1123,13 +1152,15 @@ export:
|
||||
list:
|
||||
person_with_acp:
|
||||
List peoples having an accompanying period: Liste des usagers ayant un parcours d'accompagnement
|
||||
List peoples having an accompanying period with period details: Liste des usagers concernés avec détail de chaque parcours
|
||||
Create a list of people having an accompaying periods, according to various filters.: Génère une liste des usagers ayant un parcours d'accompagnement, selon différents critères liés au parcours ou à l'usager
|
||||
Create a list of people having an accompaying periods with details of period, according to various filters.: Génère une liste des usagers ayant un parcours d'accompagnement, selon différents critères liés au parcours ou à l'usager. Ajoute les détails du parcours à la liste.
|
||||
acp:
|
||||
List of accompanying periods: Liste des parcours d'accompagnements
|
||||
Generate a list of accompanying periods, filtered on different parameters.: Génère une liste des parcours d'accompagnement, filtrée sur différents paramètres.
|
||||
Date of calculation for associated elements: Date de calcul des éléments associés
|
||||
The associated referree, localisation, and other elements will be valid at this date: Les éléments associés, comme la localisation, le référent et d'autres éléments seront valides à cette date
|
||||
id: Identifiant du parcours
|
||||
acpId: Identifiant du parcours
|
||||
openingDate: Date d'ouverture du parcours
|
||||
closingDate: Date de fermeture du parcours
|
||||
closingMotive: Motif de cloture
|
||||
@@ -1137,14 +1168,14 @@ export:
|
||||
confidential: Confidentiel
|
||||
emergency: Urgent
|
||||
intensity: Intensité
|
||||
createdAt: Créé le
|
||||
updatedAt: Dernière mise à jour le
|
||||
acpCreatedAt: Créé le
|
||||
acpUpdatedAt: Dernière mise à jour le
|
||||
acpOrigin: Origine du parcours
|
||||
origin: Origine du parcours
|
||||
acpClosingMotive: Motif de fermeture
|
||||
acpJob: Métier du parcours
|
||||
createdBy: Créé par
|
||||
updatedBy: Dernière modification par
|
||||
acpCreatedBy: Créé par
|
||||
acpUpdatedBy: Dernière modification par
|
||||
administrativeLocation: Location administrative
|
||||
step: Etape
|
||||
stepSince: Dernière modification de l'étape
|
||||
@@ -1152,7 +1183,7 @@ export:
|
||||
referrerSince: Référent depuis le
|
||||
locationIsPerson: Parcours localisé auprès d'un usager concerné
|
||||
locationIsTemp: Parcours avec une localisation temporaire
|
||||
acpLocationPersonName: Usager auprès duquel le parcours est localisé
|
||||
locationPersonName: Usager auprès duquel le parcours est localisé
|
||||
locationPersonId: Identifiant de l'usager auprès duquel le parcours est localisé
|
||||
acpaddress_fieldscountry: Pays de l'adresse
|
||||
isRequestorPerson: Le demandeur est-il un usager ?
|
||||
|
Reference in New Issue
Block a user