Merge remote-tracking branch 'origin/rector/rules-symfony' into rector/rules-symfony

This commit is contained in:
2023-10-16 18:07:42 +02:00
116 changed files with 3454 additions and 1032 deletions

View File

@@ -36,7 +36,17 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class HouseholdCompositionController extends AbstractController
{
public function __construct(private readonly Security $security, private readonly HouseholdCompositionRepository $householdCompositionRepository, private readonly HouseholdRepository $householdRepository, private readonly PaginatorFactory $paginatorFactory, private readonly FormFactoryInterface $formFactory, private readonly EntityManagerInterface $entityManager, private readonly TranslatorInterface $translator, private readonly \Twig\Environment $engine, private readonly UrlGeneratorInterface $urlGenerator) {}
public function __construct(
private readonly Security $security,
private readonly HouseholdCompositionRepository $householdCompositionRepository,
private readonly HouseholdRepository $householdRepository,
private readonly PaginatorFactory $paginatorFactory,
private readonly FormFactoryInterface $formFactory,
private readonly EntityManagerInterface $entityManager,
private readonly TranslatorInterface $translator,
private readonly \Twig\Environment $engine,
private readonly UrlGeneratorInterface $urlGenerator
) {}
/**
* @Route("/{_locale}/person/household/{household_id}/composition/{composition_id}/delete", name="chill_person_household_composition_delete")

View File

@@ -26,6 +26,7 @@ use DateTimeImmutable;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ReadableCollection;
use Doctrine\ORM\Mapping as ORM;
use LogicException;
use Symfony\Component\Serializer\Annotation as Serializer;
@@ -154,14 +155,10 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
private PrivateCommentEmbeddable $privateComment;
/**
* @var Collection<User>
* @ORM\ManyToMany(targetEntity=User::class)
* @ORM\JoinTable(name="chill_person_accompanying_period_work_referrer")
* @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"})
* @Serializer\Groups({"accompanying_period_work:edit"})
* @Serializer\Groups({"accompanying_period_work:create"})
* @var Collection<int, AccompanyingPeriodWorkReferrerHistory>
* @ORM\OneToMany(targetEntity=AccompanyingPeriodWorkReferrerHistory::class, cascade={"persist", "remove"}, mappedBy="accompanyingPeriodWork", orphanRemoval=true)
*/
private Collection $referrers;
private Collection $referrersHistory;
/**
* @var Collection<Result>
@@ -220,7 +217,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
$this->thirdParties = new ArrayCollection();
$this->persons = new ArrayCollection();
$this->accompanyingPeriodWorkEvaluations = new ArrayCollection();
$this->referrers = new ArrayCollection();
$this->referrersHistory = new ArrayCollection();
}
public function addAccompanyingPeriodWorkEvaluation(AccompanyingPeriodWorkEvaluation $evaluation): self
@@ -254,8 +251,9 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
public function addReferrer(User $referrer): self
{
if (!$this->referrers->contains($referrer)) {
$this->referrers[] = $referrer;
if (!$this->getReferrers()->contains($referrer)) {
$this->referrersHistory[] =
new AccompanyingPeriodWorkReferrerHistory($this, $referrer, new DateTimeImmutable('today'));
}
return $this;
@@ -351,15 +349,26 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
}
/**
* @return Collection|User[]
* @return ReadableCollection<int, User>
* @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"})
* @Serializer\Groups({"accompanying_period_work:edit"})
* @Serializer\Groups({"accompanying_period_work:create"})
*/
public function getReferrers(): Collection
public function getReferrers(): ReadableCollection
{
return $this->referrers;
return $this->referrersHistory
->filter(fn (AccompanyingPeriodWorkReferrerHistory $h) => null === $h->getEndDate())
->map(fn (AccompanyingPeriodWorkReferrerHistory $h) => $h->getUser());
}
public function getReferrersHistory(): Collection
{
return $this->referrersHistory;
}
/**
* @return Collection|Result[]
* @return Collection<int, Result>
*/
public function getResults(): Collection
{
@@ -434,7 +443,16 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
public function removeReferrer(User $referrer): self
{
$this->referrers->removeElement($referrer);
foreach ($this->referrersHistory as $history) {
if ($history->isOpen() && $referrer === $history->getUser()) {
$history->setEndDate(new DateTimeImmutable('today'));
if ($history->isDateRangeEmpty()) {
$history->removeAccompanyingPeriodWork();
$this->referrersHistory->removeElement($history);
}
}
}
return $this;
}

View File

@@ -0,0 +1,120 @@
<?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\Entity\AccompanyingPeriod;
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
use Chill\MainBundle\Entity\User;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="chill_person_accompanying_period_work_referrer")
*/
class AccompanyingPeriodWorkReferrerHistory implements TrackCreationInterface, TrackUpdateInterface
{
use TrackCreationTrait;
use TrackUpdateTrait;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private ?int $id = null;
/**
* @var \DateTimeImmutable|null
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
*/
private ?\DateTimeImmutable $endDate = null;
public function __construct(
/**
* @ORM\ManyToOne(targetEntity=AccompanyingPeriodWork::class, inversedBy="referrersHistory")
*/
private ?AccompanyingPeriodWork $accompanyingPeriodWork,
/**
* @var User
* @ORM\ManyToOne(targetEntity=User::class)
*/
private User $user,
/**
* @var \DateTimeImmutable
* @ORM\Column(type="date_immutable", nullable=false)
*/
private \DateTimeImmutable $startDate
) {}
public function getId(): ?int
{
return $this->id;
}
public function getEndDate(): ?\DateTimeImmutable
{
return $this->endDate;
}
public function setEndDate(?\DateTimeImmutable $endDate): AccompanyingPeriodWorkReferrerHistory
{
$this->endDate = $endDate;
return $this;
}
public function getAccompanyingPeriodWork(): AccompanyingPeriodWork
{
return $this->accompanyingPeriodWork;
}
public function getUser(): User
{
return $this->user;
}
public function getStartDate(): \DateTimeImmutable
{
return $this->startDate;
}
/**
* to be used when the history is removed (when startDate = endDate)
*
* @return self
*/
public function removeAccompanyingPeriodWork(): self
{
$this->accompanyingPeriodWork = null;
return $this;
}
/**
* @return bool true if the endDate is null
*/
public function isOpen(): bool
{
return null === $this->getEndDate();
}
/**
* return true if the date range is empty (start date and end date are equal).
*
* @return bool true if the start date and end date are equal.
*/
public function isDateRangeEmpty(): bool
{
return $this->getStartDate()->format('Y-m-d') === $this->getEndDate()?->format('Y-m-d');
}
}

View File

@@ -11,17 +11,24 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
use Chill\MainBundle\Entity\User\UserJobHistory;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Repository\UserJobRepository;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\Query\Expr;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use function in_array;
class CreatorJobAggregator implements AggregatorInterface
{
public function __construct(private readonly UserJobRepository $jobRepository, private readonly TranslatableStringHelper $translatableStringHelper) {}
private const PREFIX = 'acp_agg_creator_job';
public function __construct(
private readonly UserJobRepository $jobRepository,
private readonly TranslatableStringHelper $translatableStringHelper
) {}
public function addRole(): ?string
{
@@ -30,12 +37,41 @@ class CreatorJobAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array('acp_creator', $qb->getAllAliases(), true)) {
$qb->leftJoin('acp.createdBy', 'acp_creator');
}
$p = self::PREFIX;
$qb->addSelect('IDENTITY(acp_creator.userJob) AS acp_creator_job_aggregator')
->addGroupBy('acp_creator_job_aggregator');
$qb
->leftJoin(
"acp.userHistories",
"{$p}_userHistory",
Join::WITH,
$qb->expr()->andX(
$qb->expr()->eq("{$p}_userHistory.accompanyingPeriod", "acp.id"),
$qb->expr()->andX(
$qb->expr()->gte("COALESCE(acp.closingDate, CURRENT_TIMESTAMP())", "{$p}_userHistory.startDate"),
$qb->expr()->orX(
$qb->expr()->isNull("{$p}_userHistory.endDate"),
$qb->expr()->lt("COALESCE(acp.closingDate, CURRENT_TIMESTAMP())", "{$p}_userHistory.endDate")
)
)
)
)
->leftJoin(
UserJobHistory::class,
"{$p}_jobHistory",
Expr\Join::WITH,
$qb->expr()->andX(
$qb->expr()->eq("{$p}_jobHistory.user", "{$p}_userHistory.createdBy"), // et si il est null ?
$qb->expr()->andX(
$qb->expr()->lte("{$p}_jobHistory.startDate", "{$p}_userHistory.startDate"),
$qb->expr()->orX(
$qb->expr()->isNull("{$p}_jobHistory.endDate"),
$qb->expr()->gt("{$p}_jobHistory.endDate", "{$p}_userHistory.startDate")
)
)
)
)
->addSelect("IDENTITY({$p}_jobHistory.job) AS {$p}_select")
->addGroupBy("{$p}_select");
}
public function applyOn(): string
@@ -43,10 +79,8 @@ class CreatorJobAggregator implements AggregatorInterface
return Declarations::ACP_TYPE;
}
public function buildForm(FormBuilderInterface $builder)
{
// No form needed
}
public function buildForm(FormBuilderInterface $builder) {}
public function getFormDefaultData(): array
{
return [];
@@ -71,11 +105,11 @@ class CreatorJobAggregator implements AggregatorInterface
public function getQueryKeys($data): array
{
return ['acp_creator_job_aggregator'];
return [self::PREFIX . '_select'];
}
public function getTitle(): string
{
return 'Group by creator job';
return 'export.aggregator.course.by_creator_job.Group by creator job';
}
}

View File

@@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
use Chill\MainBundle\Entity\User\UserJobHistory;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Repository\UserJobRepositoryInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
@@ -22,18 +23,57 @@ use Symfony\Component\Form\FormBuilderInterface;
final readonly class JobWorkingOnCourseAggregator implements AggregatorInterface
{
private const COLUMN_NAME = 'user_working_on_course_job_id';
private const PREFIX = 'acp_agg_user_job_working_on_course';
public function __construct(
private UserJobRepositoryInterface $userJobRepository,
private TranslatableStringHelperInterface $translatableStringHelper,
) {}
public function buildForm(FormBuilderInterface $builder)
public function addRole(): ?string
{
// nothing to add here
return null;
}
public function alterQuery(QueryBuilder $qb, $data)
{
$p = self::PREFIX;
$qb
->leftJoin(
AccompanyingPeriodInfo::class,
"acpinfo",
Join::WITH,
$qb->expr()->eq("IDENTITY(acpinfo.accompanyingPeriod)", "acp.id")
)
->leftJoin("acpinfo.user", "{$p}_user")
->leftJoin(
UserJobHistory::class,
"{$p}_history",
Join::WITH,
$qb->expr()->eq("{$p}_history.user", "{$p}_user")
)
// job_at based on _info.infoDate
->andWhere(
$qb->expr()->andX(
$qb->expr()->lte("{$p}_history.startDate", "acpinfo.infoDate"),
$qb->expr()->orX(
$qb->expr()->isNull("{$p}_history.endDate"),
$qb->expr()->gt("{$p}_history.endDate", "acpinfo.infoDate")
)
)
)
->addSelect("IDENTITY({$p}_history.job) AS {$p}_select")
->addGroupBy("{$p}_select");
}
public function applyOn(): string
{
return Declarations::ACP_TYPE;
}
public function buildForm(FormBuilderInterface $builder) {}
public function getFormDefaultData(): array
{
return [];
@@ -58,42 +98,13 @@ final readonly class JobWorkingOnCourseAggregator implements AggregatorInterface
};
}
public function getQueryKeys($data)
public function getQueryKeys($data): array
{
return [self::COLUMN_NAME];
return [self::PREFIX . '_select'];
}
public function getTitle()
public function getTitle(): string
{
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;
}
}

View File

@@ -11,22 +11,24 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
use Chill\MainBundle\Entity\User\UserScopeHistory;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Component\Form\FormBuilderInterface;
class ReferrerScopeAggregator implements AggregatorInterface
readonly class ReferrerScopeAggregator implements AggregatorInterface
{
private const SCOPE_KEY = 'acp_agg_refscope_user_history_ref_scope_name';
private const PREFIX = 'acp_agg_referrer_scope';
public function __construct(private readonly ScopeRepositoryInterface $scopeRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper, private readonly RollingDateConverterInterface $rollingDateConverter) {}
public function __construct(
private ScopeRepositoryInterface $scopeRepository,
private TranslatableStringHelperInterface $translatableStringHelper,
) {}
public function addRole(): ?string
{
@@ -35,52 +37,53 @@ class ReferrerScopeAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
$userHistory = 'acp_agg_refscope_user_history';
$ref = 'acp_agg_refscope_user_history_ref';
$scopeName = self::SCOPE_KEY;
$dateCalc = 'acp_agg_refscope_user_history_date_calc';
$p = self::PREFIX;
$qb
->leftJoin('acp.userHistories', $userHistory)
->leftJoin($userHistory . '.user', $ref)
->andWhere(
$qb->expr()->orX(
$qb->expr()->isNull($userHistory),
->leftJoin(
"acp.userHistories",
"{$p}_userHistory",
Join::WITH,
$qb->expr()->andX(
$qb->expr()->eq("{$p}_userHistory.accompanyingPeriod", "acp.id"),
$qb->expr()->andX(
$qb->expr()->lte($userHistory . '.startDate', ':' . $dateCalc),
$qb->expr()->gte("COALESCE(acp.closingDate, CURRENT_TIMESTAMP())", "{$p}_userHistory.startDate"),
$qb->expr()->orX(
$qb->expr()->isNull($userHistory . '.endDate'),
$qb->expr()->gt($userHistory . '.endDate', ':' . $dateCalc)
$qb->expr()->isNull("{$p}_userHistory.endDate"),
$qb->expr()->lt("COALESCE(acp.closingDate, CURRENT_TIMESTAMP())", "{$p}_userHistory.endDate")
)
)
)
)
->setParameter(
$dateCalc,
$this->rollingDateConverter->convert($data['date_calc'])
);
// add groups
$qb
->addSelect('IDENTITY(' . $ref . '.mainScope) AS ' . $scopeName)
->addGroupBy($scopeName);
->leftJoin(
UserScopeHistory::class,
"{$p}_scopeHistory",
Join::WITH,
$qb->expr()->andX(
$qb->expr()->eq("{$p}_scopeHistory.user", "{$p}_userHistory.user"),
$qb->expr()->andX(
$qb->expr()->lte("{$p}_scopeHistory.startDate", "{$p}_userHistory.startDate"),
$qb->expr()->orX(
$qb->expr()->isNull("{$p}_scopeHistory.endDate"),
$qb->expr()->gt("{$p}_scopeHistory.endDate", "{$p}_userHistory.startDate")
)
)
)
)
->addSelect("IDENTITY({$p}_scopeHistory.scope) AS {$p}_select")
->addGroupBy("{$p}_select");
}
public function applyOn()
public function applyOn(): string
{
return Declarations::ACP_TYPE;
}
public function buildForm(FormBuilderInterface $builder)
{
$builder->add('date_calc', PickRollingDateType::class, [
'label' => 'export.aggregator.course.by_user_scope.Computation date for referrer',
'required' => true,
]);
}
public function buildForm(FormBuilderInterface $builder) {}
public function getFormDefaultData(): array
{
return ['date_calc' => new RollingDate(RollingDate::T_TODAY)];
return [];
}
public function getLabels($key, array $values, $data)
@@ -104,12 +107,12 @@ class ReferrerScopeAggregator implements AggregatorInterface
};
}
public function getQueryKeys($data)
public function getQueryKeys($data): array
{
return [self::SCOPE_KEY];
return [self::PREFIX . '_select'];
}
public function getTitle()
public function getTitle(): string
{
return 'export.aggregator.course.by_user_scope.Group course by referrer\'s scope';
}

View File

@@ -80,6 +80,6 @@ final readonly class ScopeAggregator implements AggregatorInterface
public function getTitle(): string
{
return 'Group course by scope';
return 'export.aggregator.course.by_scope.Group course by scope';
}
}

View File

@@ -11,9 +11,9 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
use Chill\MainBundle\Entity\User\UserScopeHistory;
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;
@@ -23,18 +23,57 @@ use Symfony\Component\Form\FormBuilderInterface;
final readonly class ScopeWorkingOnCourseAggregator implements AggregatorInterface
{
private const COLUMN_NAME = 'user_working_on_course_scope_id';
private const PREFIX = 'acp_agg_user_scope_working_on_course';
public function __construct(
private ScopeRepositoryInterface $scopeRepository,
private TranslatableStringHelperInterface $translatableStringHelper,
) {}
public function buildForm(FormBuilderInterface $builder)
public function addRole(): ?string
{
// nothing to add here
return null;
}
public function alterQuery(QueryBuilder $qb, $data)
{
$p = self::PREFIX;
$qb
->leftJoin(
AccompanyingPeriodInfo::class,
"acpinfo",
Join::WITH,
$qb->expr()->eq("IDENTITY(acpinfo.accompanyingPeriod)", "acp.id")
)
->leftJoin("acpinfo.user", "{$p}_user")
->leftJoin(
UserScopeHistory::class,
"{$p}_history",
Join::WITH,
$qb->expr()->eq("{$p}_history.user", "{$p}_user")
)
// scope_at based on _info.infoDate
->andWhere(
$qb->expr()->andX(
$qb->expr()->lte("{$p}_history.startDate", "acpinfo.infoDate"),
$qb->expr()->orX(
$qb->expr()->isNull("{$p}_history.endDate"),
$qb->expr()->gt("{$p}_history.endDate", "acpinfo.infoDate")
)
)
)
->addSelect("IDENTITY({$p}_history.scope) AS {$p}_select")
->addGroupBy("{$p}_select");
}
public function applyOn(): string
{
return Declarations::ACP_TYPE;
}
public function buildForm(FormBuilderInterface $builder) {}
public function getFormDefaultData(): array
{
return [];
@@ -59,42 +98,13 @@ final readonly class ScopeWorkingOnCourseAggregator implements AggregatorInterfa
};
}
public function getQueryKeys($data)
public function getQueryKeys($data): array
{
return [self::COLUMN_NAME];
return [self::PREFIX. '_select'];
}
public function getTitle()
public function getTitle(): string
{
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;
}
}

View File

@@ -11,17 +11,23 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
use Chill\MainBundle\Entity\User\UserJobHistory;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Repository\UserJobRepository;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use function in_array;
final readonly class UserJobAggregator implements AggregatorInterface
{
public function __construct(private UserJobRepository $jobRepository, private TranslatableStringHelper $translatableStringHelper) {}
private const PREFIX = 'acp_agg_user_job';
public function __construct(
private UserJobRepository $jobRepository,
private TranslatableStringHelper $translatableStringHelper
) {}
public function addRole(): ?string
{
@@ -30,12 +36,41 @@ final readonly class UserJobAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array('acpuser', $qb->getAllAliases(), true)) {
$qb->leftJoin('acp.user', 'acpuser');
}
$p = self::PREFIX;
$qb->addSelect('IDENTITY(acpuser.userJob) AS job_aggregator');
$qb->addGroupBy('job_aggregator');
$qb
->leftJoin(
"acp.userHistories",
"{$p}_userHistory",
Join::WITH,
$qb->expr()->andX(
$qb->expr()->eq("{$p}_userHistory.accompanyingPeriod", "acp.id"),
$qb->expr()->andX(
$qb->expr()->gte("COALESCE(acp.closingDate, CURRENT_TIMESTAMP())", "{$p}_userHistory.startDate"),
$qb->expr()->orX(
$qb->expr()->isNull("{$p}_userHistory.endDate"),
$qb->expr()->lt("COALESCE(acp.closingDate, CURRENT_TIMESTAMP())", "{$p}_userHistory.endDate")
)
)
)
)
->leftJoin(
UserJobHistory::class,
"{$p}_jobHistory",
Join::WITH,
$qb->expr()->andX(
$qb->expr()->eq("{$p}_jobHistory.user", "{$p}_userHistory.user"),
$qb->expr()->andX(
$qb->expr()->lte("{$p}_jobHistory.startDate", "{$p}_userHistory.startDate"),
$qb->expr()->orX(
$qb->expr()->isNull("{$p}_jobHistory.endDate"),
$qb->expr()->gt("{$p}_jobHistory.endDate", "{$p}_userHistory.startDate")
)
)
)
)
->addSelect("IDENTITY({$p}_jobHistory.job) AS {$p}_select")
->addGroupBy("{$p}_select");
}
public function applyOn(): string
@@ -43,10 +78,8 @@ final readonly class UserJobAggregator implements AggregatorInterface
return Declarations::ACP_TYPE;
}
public function buildForm(FormBuilderInterface $builder)
{
// no form
}
public function buildForm(FormBuilderInterface $builder) {}
public function getFormDefaultData(): array
{
return [];
@@ -63,7 +96,9 @@ final readonly class UserJobAggregator implements AggregatorInterface
return '';
}
$j = $this->jobRepository->find($value);
if (null === $j = $this->jobRepository->find($value)) {
return '';
}
return $this->translatableStringHelper->localize(
$j->getLabel()
@@ -73,11 +108,11 @@ final readonly class UserJobAggregator implements AggregatorInterface
public function getQueryKeys($data): array
{
return ['job_aggregator'];
return [self::PREFIX . '_select'];
}
public function getTitle(): string
{
return 'Group by user job';
return 'export.aggregator.course.by_user_job.Group by user job';
}
}

View File

@@ -11,17 +11,30 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User\UserJobHistory;
use Chill\MainBundle\Entity\UserJob;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Repository\UserJobRepository;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverter;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkReferrerHistory;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\Query\Expr;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use function in_array;
final readonly class JobAggregator implements AggregatorInterface
{
public function __construct(private UserJobRepository $jobRepository, private TranslatableStringHelper $translatableStringHelper) {}
private const PREFIX = 'acp_work_action_agg_user_job';
public function __construct(
private UserJobRepository $jobRepository,
private TranslatableStringHelper $translatableStringHelper
) {}
public function addRole(): ?string
{
@@ -30,12 +43,20 @@ final readonly class JobAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array('acpwuser', $qb->getAllAliases(), true)) {
$qb->leftJoin('acpw.referrers', 'acpwuser');
}
$p = self::PREFIX;
$qb->addSelect('IDENTITY(acpwuser.userJob) as job_aggregator')
->addGroupBy('job_aggregator');
$qb
->leftJoin(
UserJob::class,
"{$p}_job",
Expr\Join::WITH,
'EXISTS (SELECT 1 FROM ' . AccompanyingPeriodWorkReferrerHistory::class . " {$p}_ref_history
JOIN {$p}_ref_history.user {$p}_ref_history_user JOIN {$p}_ref_history_user.jobHistories {$p}_job_history
WHERE {$p}_ref_history.accompanyingPeriodWork = acpw AND IDENTITY({$p}_job_history.job) = {$p}_job.id AND {$p}_job_history.startDate <= {$p}_ref_history.startDate
AND ({$p}_job_history.endDate IS NULL or {$p}_job_history.endDate >= {$p}_ref_history.startDate))"
)
->addSelect("{$p}_job.id as {$p}_select")
->addGroupBy("{$p}_select");
}
public function applyOn(): string
@@ -43,10 +64,8 @@ final readonly class JobAggregator implements AggregatorInterface
return Declarations::SOCIAL_WORK_ACTION_TYPE;
}
public function buildForm(FormBuilderInterface $builder)
{
// no form
}
public function buildForm(FormBuilderInterface $builder) {}
public function getFormDefaultData(): array
{
return [];
@@ -63,7 +82,9 @@ final readonly class JobAggregator implements AggregatorInterface
return '';
}
$j = $this->jobRepository->find($value);
if (null === $j = $this->jobRepository->find($value)) {
return '';
}
return $this->translatableStringHelper->localize(
$j->getLabel()
@@ -73,11 +94,11 @@ final readonly class JobAggregator implements AggregatorInterface
public function getQueryKeys($data): array
{
return ['job_aggregator'];
return [self::PREFIX . '_select'];
}
public function getTitle(): string
{
return 'Group by treating agent job';
return 'export.aggregator.course_work.by_agent_job.Group by treating agent job';
}
}

View File

@@ -12,7 +12,10 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Repository\UserRepository;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Templating\Entity\UserRender;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
@@ -21,7 +24,13 @@ use function in_array;
final readonly class ReferrerAggregator implements AggregatorInterface
{
public function __construct(private UserRepository $userRepository, private UserRender $userRender) {}
private const PREFIX = 'acpw_referrer_aggregator';
public function __construct(
private UserRepository $userRepository,
private UserRender $userRender,
private RollingDateConverterInterface $rollingDateConverter
) {}
public function addRole(): ?string
{
@@ -30,11 +39,16 @@ final readonly class ReferrerAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array('acpwuser', $qb->getAllAliases(), true)) {
$qb->leftJoin('acpw.referrers', 'acpwuser');
}
$p = self::PREFIX;
$qb->addSelect('acpwuser.id AS referrer_aggregator');
$qb
->leftJoin('acpw.referrersHistory', $p . "_acpwusers_history")
->andWhere("{$p}_acpwusers_history.startDate <= :{$p}_calc_date AND ({$p}_acpwusers_history.endDate IS NULL or {$p}_acpwusers_history.endDate > :{$p}_calc_date)");
$qb->setParameter("{$p}_calc_date", $this->rollingDateConverter->convert(
$data['referrer_at'] ?? new RollingDate(RollingDate::T_TODAY)
));
$qb->addSelect("IDENTITY({$p}_acpwusers_history.user) AS referrer_aggregator");
$qb->addGroupBy('referrer_aggregator');
}
@@ -45,11 +59,16 @@ final readonly class ReferrerAggregator implements AggregatorInterface
public function buildForm(FormBuilderInterface $builder)
{
// no form
$builder->add('referrer_at', PickRollingDateType::class, [
'label' => 'export.aggregator.course_work.by_treating_agent.Calc date'
]);
}
public function getFormDefaultData(): array
{
return [];
return [
'referrer_at' => new RollingDate(RollingDate::T_TODAY),
];
}
public function getLabels($key, array $values, $data)
@@ -65,7 +84,7 @@ final readonly class ReferrerAggregator implements AggregatorInterface
$r = $this->userRepository->find($value);
return $this->userRender->renderString($r, []);
return $this->userRender->renderString($r, ['absence' => false, 'user_job' => false, 'main_scope' => false]);
};
}
@@ -76,6 +95,6 @@ final readonly class ReferrerAggregator implements AggregatorInterface
public function getTitle(): string
{
return 'Group by treating agent';
return 'export.aggregator.course_work.by_treating_agent.Group by treating agent';
}
}

View File

@@ -11,17 +11,30 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User\UserScopeHistory;
use Chill\MainBundle\Entity\UserJob;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Repository\ScopeRepository;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverter;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkReferrerHistory;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\Query\Expr;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use function in_array;
final readonly class ScopeAggregator implements AggregatorInterface
{
public function __construct(private ScopeRepository $scopeRepository, private TranslatableStringHelper $translatableStringHelper) {}
private const PREFIX = 'acp_work_action_agg_user_scope';
public function __construct(
private ScopeRepository $scopeRepository,
private TranslatableStringHelper $translatableStringHelper
) {}
public function addRole(): ?string
{
@@ -30,12 +43,20 @@ final readonly class ScopeAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array('acpwuser', $qb->getAllAliases(), true)) {
$qb->leftJoin('acpw.referrers', 'acpwuser');
}
$p = self::PREFIX;
$qb->addSelect('IDENTITY(acpwuser.mainScope) as scope_aggregator');
$qb->addGroupBy('scope_aggregator');
$qb
->leftJoin(
Scope::class,
"{$p}_scope",
Expr\Join::WITH,
'EXISTS (SELECT 1 FROM ' . AccompanyingPeriodWorkReferrerHistory::class . " {$p}_ref_history
JOIN {$p}_ref_history.user {$p}_ref_history_user JOIN {$p}_ref_history_user.scopeHistories {$p}_scope_history
WHERE {$p}_ref_history.accompanyingPeriodWork = acpw AND IDENTITY({$p}_scope_history.scope) = {$p}_scope.id AND {$p}_scope_history.startDate <= {$p}_ref_history.startDate
AND ({$p}_scope_history.endDate IS NULL or {$p}_scope_history.endDate >= {$p}_ref_history.startDate))"
)
->addSelect("{$p}_scope.id as {$p}_select")
->addGroupBy("{$p}_select");
}
public function applyOn(): string
@@ -43,10 +64,8 @@ final readonly class ScopeAggregator implements AggregatorInterface
return Declarations::SOCIAL_WORK_ACTION_TYPE;
}
public function buildForm(FormBuilderInterface $builder)
{
// no form
}
public function buildForm(FormBuilderInterface $builder) {}
public function getFormDefaultData(): array
{
return [];
@@ -63,7 +82,9 @@ final readonly class ScopeAggregator implements AggregatorInterface
return '';
}
$s = $this->scopeRepository->find($value);
if (null === $s = $this->scopeRepository->find($value)) {
return '';
}
return $this->translatableStringHelper->localize(
$s->getName()
@@ -73,11 +94,11 @@ final readonly class ScopeAggregator implements AggregatorInterface
public function getQueryKeys($data): array
{
return ['scope_aggregator'];
return [self::PREFIX . '_select'];
}
public function getTitle(): string
{
return 'Group by treating agent scope';
return 'export.aggregator.course_work.by_agent_scope.Group by treating agent scope';
}
}

View File

@@ -25,6 +25,7 @@ use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkGoal;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkReferrerHistory;
use Chill\PersonBundle\Entity\AccompanyingPeriod\UserHistory;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
@@ -70,6 +71,7 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac
'personsName',
'thirdParties',
'handlingThierParty',
//'acpwReferrers',
'referrers',
'createdAt',
'createdBy',
@@ -77,7 +79,20 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac
'updatedBy',
];
public function __construct(private readonly EntityManagerInterface $entityManager, private readonly DateTimeHelper $dateTimeHelper, private readonly UserHelper $userHelper, private readonly LabelPersonHelper $personHelper, private readonly LabelThirdPartyHelper $thirdPartyHelper, private readonly TranslatableStringExportLabelHelper $translatableStringExportLabelHelper, private readonly SocialIssueRender $socialIssueRender, private readonly SocialIssueRepository $socialIssueRepository, private readonly SocialActionRender $socialActionRender, private readonly RollingDateConverterInterface $rollingDateConverter, private readonly AggregateStringHelper $aggregateStringHelper, private readonly SocialActionRepository $socialActionRepository) {}
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly DateTimeHelper $dateTimeHelper,
private readonly UserHelper $userHelper,
private readonly LabelPersonHelper $personHelper,
private readonly LabelThirdPartyHelper $thirdPartyHelper,
private readonly TranslatableStringExportLabelHelper $translatableStringExportLabelHelper,
private readonly SocialIssueRender $socialIssueRender,
private readonly SocialIssueRepository $socialIssueRepository,
private readonly SocialActionRender $socialActionRender,
private readonly RollingDateConverterInterface $rollingDateConverter,
private readonly AggregateStringHelper $aggregateStringHelper,
private readonly SocialActionRepository $socialActionRepository
) {}
public function buildForm(FormBuilderInterface $builder)
{
@@ -142,6 +157,7 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac
},
'createdBy', 'updatedBy', 'acp_user' => $this->userHelper->getLabel($key, $values, 'export.list.acpw.' . $key),
'referrers' => $this->userHelper->getLabel($key, $values, 'export.list.acpw.' . $key),
//'acpwReferrers' => $this->userHelper->getLabelMulti($key, $values, 'export.list.acpw.' . $key),
'personsName' => $this->personHelper->getLabelMulti($key, $values, 'export.list.acpw.' . $key),
'handlingThierParty' => $this->thirdPartyHelper->getLabel($key, $values, 'export.list.acpw.' . $key),
'thirdParties' => $this->thirdPartyHelper->getLabelMulti($key, $values, 'export.list.acpw.' . $key),
@@ -168,7 +184,7 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac
public function getResult($query, $data)
{
return $query->getQuery()->getResult(AbstractQuery::HYDRATE_SCALAR);
return dump($query->getQuery()->getResult(AbstractQuery::HYDRATE_SCALAR));
}
public function getTitle(): string
@@ -272,9 +288,20 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac
// referrers => at date XXXX
$qb
->addSelect('(SELECT IDENTITY(history.user) FROM ' . UserHistory::class . ' history ' .
->addSelect('(SELECT JSON_BUILD_OBJECT(\'uid\', IDENTITY(history.user), \'d\', history.startDate) FROM ' . UserHistory::class . ' history ' .
'WHERE history.accompanyingPeriod = acp AND history.startDate <= :calcDate AND (history.endDate IS NULL OR history.endDate > :calcDate)) AS referrers');
/*
// acpwReferrers at date XXX
$qb
->addSelect('(
SELECT IDENTITY(acpw_ref_history.accompanyingPeriodWork) AS acpw_ref_history_id,
JSON_BUILD_OBJECT(\'uid\', IDENTITY(acpw_ref_history.user), \'d\', acpw_ref_history.startDate)
FROM ' . AccompanyingPeriodWorkReferrerHistory::class . ' acpw_ref_history ' .
'WHERE acpw_ref_history.accompanyingPeriodWork = acpw AND acpw_ref_history.startDate <= :calcDate AND (acpw_ref_history.endDate IS NULL or acpw_ref_history.endDate > :calcDate) GROUP BY acpw_ref_history_id) AS acpwReferrers'
);
*/
// thirdparties
$qb
->addSelect('(SELECT AGGREGATE(tp.id) FROM ' . ThirdParty::class . ' tp '

View File

@@ -133,7 +133,7 @@ class ListEvaluation implements ListInterface, GroupedExportInterface
);
},
'createdBy', 'updatedBy', 'acpw_acp_user' => $this->userHelper->getLabel($key, $values, 'export.list.eval.' . $key),
'acpw_referrers' => $this->userHelper->getLabel($key, $values, 'export.list.eval.' . $key),
'acpw_referrers' => $this->userHelper->getLabelMulti($key, $values, 'export.list.eval.' . $key),
'acpw_persons_id' => $this->aggregateStringHelper->getLabelMulti($key, $values, 'export.list.eval.' . $key),
'acpw_persons' => $this->personHelper->getLabelMulti($key, $values, 'export.list.eval.' . $key),
'eval_title' => $this->translatableStringExportLabelHelper
@@ -255,8 +255,8 @@ class ListEvaluation implements ListInterface, GroupedExportInterface
// referrers => at date XXXX
$qb
->addSelect('(SELECT IDENTITY(history.user) FROM ' . UserHistory::class . ' history ' .
'WHERE history.accompanyingPeriod = acp AND history.startDate <= :calc_date AND (history.endDate IS NULL OR history.endDate > :calc_date)) AS acpw_referrers');
->addSelect('(SELECT JSON_BUILD_OBJECT(\'uid\', IDENTITY(history.user), \'d\', history.startDate) FROM ' . UserHistory::class . ' history ' .
'WHERE history.accompanyingPeriod = acp AND history.startDate <= :calc_date AND (history.endDate IS NULL OR history.endDate > :calc_date)) AS referrers');
// persons
$qb

View File

@@ -11,19 +11,25 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters;
use Chill\MainBundle\Entity\User\UserJobHistory;
use Chill\MainBundle\Entity\UserJob;
use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Repository\UserJobRepositoryInterface;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface;
use function in_array;
class CreatorJobFilter implements FilterInterface
{
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly UserJobRepositoryInterface $userJobRepository) {}
private const PREFIX = 'acp_filter_creator_job';
public function __construct(
private readonly TranslatableStringHelper $translatableStringHelper,
private readonly UserJobRepositoryInterface $userJobRepository
) {}
public function addRole(): ?string
{
@@ -32,13 +38,44 @@ class CreatorJobFilter implements FilterInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array('acp_creator', $qb->getAllAliases(), true)) {
$qb->join('acp.createdBy', 'acp_creator');
}
$p = self::PREFIX;
$qb
->andWhere($qb->expr()->in('acp_creator.userJob', ':creator_job'))
->setParameter('creator_job', $data['creator_job']);
->join(
"acp.userHistories",
"{$p}_userHistory",
Join::WITH,
$qb->expr()->andX(
$qb->expr()->eq("{$p}_userHistory.accompanyingPeriod", "acp.id"),
$qb->expr()->andX(
$qb->expr()->gte("COALESCE(acp.closingDate, CURRENT_TIMESTAMP())", "{$p}_userHistory.startDate"),
$qb->expr()->orX(
$qb->expr()->isNull("{$p}_userHistory.endDate"),
$qb->expr()->lt("COALESCE(acp.closingDate, CURRENT_TIMESTAMP())", "{$p}_userHistory.endDate")
)
)
)
)
->leftJoin(
UserJobHistory::class,
"{$p}_history",
Join::WITH,
$qb->expr()->andX(
$qb->expr()->eq("{$p}_history.user", "{$p}_userHistory.createdBy"),
$qb->expr()->andX(
$qb->expr()->lte("{$p}_history.startDate", "{$p}_userHistory.startDate"),
$qb->expr()->orX(
$qb->expr()->isNull("{$p}_history.endDate"),
$qb->expr()->gt("{$p}_history.endDate", "{$p}_userHistory.startDate")
)
)
)
)
->andWhere($qb->expr()->in("{$p}_history.job", ":{$p}_jobs"))
->setParameter(
"{$p}_jobs",
$data["creator_job"],
);
}
public function applyOn(): string
@@ -48,20 +85,17 @@ class CreatorJobFilter implements FilterInterface
public function buildForm(FormBuilderInterface $builder)
{
$builder->add('creator_job', EntityType::class, [
'class' => UserJob::class,
'choices' => $this->userJobRepository->findAllActive(),
'choice_label' => fn (UserJob $j) => $this->translatableStringHelper->localize(
$j->getLabel()
),
'multiple' => true,
'expanded' => true,
'label' => 'Job',
]);
}
public function getFormDefaultData(): array
{
return [];
$builder
->add('creator_job', EntityType::class, [
'class' => UserJob::class,
'choices' => $this->userJobRepository->findAllActive(),
'choice_label' => fn (UserJob $j) => $this->translatableStringHelper->localize(
$j->getLabel()
),
'multiple' => true,
'expanded' => true,
'label' => 'Job',
]);
}
public function describeAction($data, $format = 'string'): array
@@ -79,8 +113,15 @@ class CreatorJobFilter implements FilterInterface
]];
}
public function getFormDefaultData(): array
{
return [
'creator_job' => [],
];
}
public function getTitle(): string
{
return 'Filter by creator job';
return 'export.filter.course.creator_job.Filter by creator job';
}
}

View File

@@ -11,17 +11,15 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Entity\User\UserJobHistory;
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\Entity\AccompanyingPeriod\AccompanyingPeriodInfo;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
@@ -34,12 +32,54 @@ use Symfony\Component\Form\FormBuilderInterface;
*/
readonly class JobWorkingOnCourseFilter implements FilterInterface
{
private const PREFIX = 'acp_filter_user_job_working_on_course';
public function __construct(
private UserJobRepositoryInterface $userJobRepository,
private RollingDateConverterInterface $rollingDateConverter,
private TranslatableStringHelperInterface $translatableStringHelper,
) {}
public function addRole(): ?string
{
return null;
}
public function alterQuery(QueryBuilder $qb, $data): void
{
$p = self::PREFIX;
$qb
->andWhere(
$qb->expr()->exists(
"SELECT 1 FROM " . AccompanyingPeriodInfo::class . " {$p}_info "
. "JOIN {$p}_info.user {$p}_user "
. "JOIN " . UserJobHistory::class . " {$p}_history WITH {$p}_history.user = {$p}_user "
. "WHERE IDENTITY({$p}_info.accompanyingPeriod) = acp.id "
. "AND {$p}_history.job IN (:{$p}_jobs) "
// job_at based on _info.infoDate
. "AND {$p}_history.startDate <= {$p}_info.infoDate "
. "AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > {$p}_info.infoDate) "
. "AND {$p}_info.infoDate >= :{$p}_start and {$p}_info.infoDate < :{$p}_end"
)
)
->setParameter("{$p}_jobs", $data['jobs'])
->setParameter(
"{$p}_start",
$this->rollingDateConverter->convert($data['start_date']),
)
->setParameter(
"{$p}_end",
$this->rollingDateConverter->convert($data['end_date'])
)
;
}
public function applyOn(): string
{
return Declarations::ACP_TYPE;
}
public function buildForm(FormBuilderInterface $builder): void
{
$jobs = $this->userJobRepository->findAllActive();
@@ -59,23 +99,14 @@ readonly class JobWorkingOnCourseFilter implements FilterInterface
->add('end_date', PickRollingDateType::class, [
'label' => 'export.filter.course.by_job_working.Job working before'
])
//->add('job_at', PickRollingDateType::class, [
// 'label' => 'bla',
// 'help' => 'bli',
// 'required' => false,
//])
;
}
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 [
@@ -93,37 +124,18 @@ readonly class JobWorkingOnCourseFilter implements FilterInterface
];
}
public function addRole(): ?string
public function getFormDefaultData(): array
{
return null;
return [
'jobs' => [],
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
'end_date' => new RollingDate(RollingDate::T_TODAY),
//'job_at' => null,
];
}
public function alterQuery(QueryBuilder $qb, $data): void
public function getTitle(): string
{
$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;
return 'export.filter.course.by_job_working.title';
}
}

View File

@@ -12,18 +12,14 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Entity\UserJob;
use Chill\MainBundle\Entity\User\UserScopeHistory;
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\Entity\AccompanyingPeriod\AccompanyingPeriodInfo;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
@@ -36,12 +32,54 @@ use Symfony\Component\Form\FormBuilderInterface;
*/
readonly class ScopeWorkingOnCourseFilter implements FilterInterface
{
private const PREFIX = 'acp_filter_user_scope_working_on_course';
public function __construct(
private ScopeRepositoryInterface $scopeRepository,
private RollingDateConverterInterface $rollingDateConverter,
private TranslatableStringHelperInterface $translatableStringHelper,
) {}
public function addRole(): ?string
{
return null;
}
public function alterQuery(QueryBuilder $qb, $data): void
{
$p = self::PREFIX;
$qb
->andWhere(
$qb->expr()->exists(
"SELECT 1 FROM " . AccompanyingPeriodInfo::class . " {$p}_info "
. "JOIN {$p}_info.user {$p}_user "
. "JOIN " . UserScopeHistory::class . " {$p}_history WITH {$p}_history.user = {$p}_user "
. "WHERE IDENTITY({$p}_info.accompanyingPeriod) = acp.id "
. "AND {$p}_history.scope IN ( :{$p}_scopes ) "
// scope_at based on _info.infoDate
. "AND {$p}_history.startDate <= {$p}_info.infoDate "
. "AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > {$p}_info.infoDate) "
. "AND {$p}_info.infoDate >= :{$p}_start AND {$p}_info.infoDate < :{$p}_end"
)
)
->setParameter("{$p}_scopes", $data["scopes"])
->setParameter(
"{$p}_start",
$this->rollingDateConverter->convert($data["start_date"]),
)
->setParameter(
"{$p}_end",
$this->rollingDateConverter->convert($data["end_date"])
)
;
}
public function applyOn(): string
{
return Declarations::ACP_TYPE;
}
public function buildForm(FormBuilderInterface $builder): void
{
$scopes = $this->scopeRepository->findAllActive();
@@ -64,20 +102,6 @@ readonly class ScopeWorkingOnCourseFilter implements FilterInterface
;
}
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 [
@@ -95,37 +119,17 @@ readonly class ScopeWorkingOnCourseFilter implements FilterInterface
];
}
public function addRole(): ?string
public function getFormDefaultData(): array
{
return null;
return [
'scopes' => [],
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
'end_date' => new RollingDate(RollingDate::T_TODAY),
];
}
public function alterQuery(QueryBuilder $qb, $data): void
public function getTitle(): string
{
$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;
return 'export.filter.course.by_scope_working.title';
}
}

View File

@@ -11,30 +11,25 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters;
use Chill\MainBundle\Entity\User\UserJobHistory;
use Chill\MainBundle\Entity\UserJob;
use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Repository\UserJobRepositoryInterface;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Security;
class UserJobFilter implements FilterInterface
{
private const A = 'acp_ujob_filter_uhistory';
private const PREFIX = 'acp_filter_user_job';
private const AU = 'acp_ujob_filter_uhistory_user';
private const P = 'acp_ujob_filter_date';
private const PJ = 'acp_ujob_filter_job';
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly UserJobRepositoryInterface $userJobRepository, private readonly RollingDateConverterInterface $rollingDateConverter) {}
public function __construct(
private readonly TranslatableStringHelper $translatableStringHelper,
private readonly UserJobRepositoryInterface $userJobRepository,
) {}
public function addRole(): ?string
{
@@ -43,26 +38,45 @@ class UserJobFilter implements FilterInterface
public function alterQuery(QueryBuilder $qb, $data)
{
$p = self::PREFIX;
$qb
->join('acp.userHistories', self::A)
->andWhere(
->leftJoin(
"acp.userHistories",
"{$p}_userHistory",
Join::WITH,
$qb->expr()->andX(
$qb->expr()->lte(self::A . '.startDate', ':' . self::P),
$qb->expr()->orX(
$qb->expr()->isNull(self::A . '.endDate'),
$qb->expr()->gt(self::A . '.endDate', ':' . self::P)
$qb->expr()->eq("{$p}_userHistory.accompanyingPeriod", "acp.id"),
$qb->expr()->andX(
$qb->expr()->gte("COALESCE(acp.closingDate, CURRENT_TIMESTAMP())", "{$p}_userHistory.startDate"),
$qb->expr()->orX(
$qb->expr()->isNull("{$p}_userHistory.endDate"),
$qb->expr()->lt("COALESCE(acp.closingDate, CURRENT_TIMESTAMP())", "{$p}_userHistory.endDate")
)
)
)
)
->leftJoin(
UserJobHistory::class,
"{$p}_jobHistory",
Join::WITH,
$qb->expr()->andX(
$qb->expr()->eq("{$p}_jobHistory.user", "{$p}_userHistory.user"),
$qb->expr()->andX(
$qb->expr()->lte("{$p}_jobHistory.startDate", "{$p}_userHistory.startDate"),
$qb->expr()->orX(
$qb->expr()->isNull("{$p}_jobHistory" . ".endDate"),
$qb->expr()->gt("{$p}_jobHistory.endDate", "{$p}_userHistory.startDate")
)
)
)
)
->andWhere($qb->expr()->in("{$p}_jobHistory.job", ":{$p}_job"))
->setParameter(
self::P,
$this->rollingDateConverter->convert($data['date_calc'])
"{$p}_job",
$data["jobs"],
)
->join(self::A . '.user', self::AU)
->andWhere(
$qb->expr()->in(self::AU . '.userJob', ':' . self::PJ)
)
->setParameter(self::PJ, $data['jobs']);
;
}
public function applyOn()
@@ -80,21 +94,13 @@ class UserJobFilter implements FilterInterface
'expanded' => true,
'choice_label' => fn (UserJob $job) => $this->translatableStringHelper->localize($job->getLabel()),
'label' => 'Job',
])
->add('date_calc', PickRollingDateType::class, [
'label' => 'export.filter.course.by_user_scope.Computation date for referrer',
'required' => true,
]);
}
public function getFormDefaultData(): array
{
return ['date_calc' => new RollingDate(RollingDate::T_TODAY)];
}
public function describeAction($data, $format = 'string')
{
return [
'Filtered by user job: only %job%', [
'export.filter.course.by_user_job.Filtered by user job: only %job%', [
'%job%' => implode(
', ',
array_map(
@@ -106,8 +112,15 @@ class UserJobFilter implements FilterInterface
];
}
public function getTitle()
public function getFormDefaultData(): array
{
return 'Filter by user job';
return [
'jobs' => [],
];
}
public function getTitle(): string
{
return 'export.filter.course.by_user_job.Filter by user job';
}
}

View File

@@ -12,30 +12,24 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Entity\User\UserScopeHistory;
use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Security;
class UserScopeFilter implements FilterInterface
{
private const A = 'acp_uscope_filter_uhistory';
private const PREFIX = 'acp_filter_main_scope';
private const AU = 'acp_uscope_filter_uhistory_user';
private const P = 'acp_uscope_filter_date';
private const PS = 'acp_uscope_filter_scopes';
public function __construct(private readonly ScopeRepositoryInterface $scopeRepository, private readonly Security $security, private readonly TranslatableStringHelper $translatableStringHelper, private readonly RollingDateConverterInterface $rollingDateConverter) {}
public function __construct(
private readonly ScopeRepositoryInterface $scopeRepository,
private readonly TranslatableStringHelper $translatableStringHelper,
) {}
public function addRole(): ?string
{
@@ -44,29 +38,48 @@ class UserScopeFilter implements FilterInterface
public function alterQuery(QueryBuilder $qb, $data)
{
$p = self::PREFIX;
$qb
->join('acp.userHistories', self::A)
->andWhere(
->join(
"acp.userHistories",
"{$p}_userHistory",
Join::WITH,
$qb->expr()->andX(
$qb->expr()->lte(self::A . '.startDate', ':' . self::P),
$qb->expr()->orX(
$qb->expr()->isNull(self::A . '.endDate'),
$qb->expr()->gt(self::A . '.endDate', ':' . self::P)
$qb->expr()->eq("{$p}_userHistory.accompanyingPeriod", "acp.id"),
$qb->expr()->andX(
$qb->expr()->gte("COALESCE(acp.closingDate, CURRENT_TIMESTAMP())", "{$p}_userHistory.startDate"),
$qb->expr()->orX(
$qb->expr()->isNull("{$p}_userHistory.endDate"),
$qb->expr()->lt("COALESCE(acp.closingDate, CURRENT_TIMESTAMP())", "{$p}_userHistory.endDate")
)
)
)
)
->join(
UserScopeHistory::class,
"{$p}_scopeHistory",
Join::WITH,
$qb->expr()->andX(
$qb->expr()->eq("{$p}_scopeHistory.user", "{$p}_userHistory.user"),
$qb->expr()->andX(
$qb->expr()->lte("{$p}_scopeHistory.startDate", "{$p}_userHistory.startDate"),
$qb->expr()->orX(
$qb->expr()->isNull("{$p}_scopeHistory.endDate"),
$qb->expr()->gt("{$p}_scopeHistory.endDate", "{$p}_userHistory.startDate")
)
)
)
)
->andWhere($qb->expr()->in("{$p}_scopeHistory.scope", ":{$p}_scopes"))
->setParameter(
self::P,
$this->rollingDateConverter->convert($data['date_calc'])
"{$p}_scopes",
$data["scopes"],
)
->join(self::A . '.user', self::AU)
->andWhere(
$qb->expr()->in(self::AU . '.mainScope', ':' . self::PS)
)
->setParameter(self::PS, $data['scopes']);
;
}
public function applyOn()
public function applyOn(): string
{
return Declarations::ACP_TYPE;
}
@@ -80,21 +93,13 @@ class UserScopeFilter implements FilterInterface
'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize($s->getName()),
'multiple' => true,
'expanded' => true,
])
->add('date_calc', PickRollingDateType::class, [
'label' => 'export.filter.course.by_user_scope.Computation date for referrer',
'required' => true,
]);
}
public function getFormDefaultData(): array
{
return ['date_calc' => new RollingDate(RollingDate::T_TODAY)];
}
public function describeAction($data, $format = 'string')
{
return [
'Filtered by user main scope: only %scope%', [
'export.filter.course.by_user_scope.Filtered by user main scope: only %scope%', [
'%scope%' => implode(
', ',
array_map(
@@ -106,16 +111,15 @@ class UserScopeFilter implements FilterInterface
];
}
public function getTitle()
public function getFormDefaultData(): array
{
return 'Filter by user scope';
return [
'scopes' => [],
];
}
private function getUserMainScope(): Scope
public function getTitle(): string
{
/** @var User $user */
$user = $this->security->getUser();
return $user->getMainScope();
return 'export.filter.course.by_user_scope.Filter by user scope';
}
}

View File

@@ -11,10 +11,16 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Filter\SocialWorkFilters;
use Chill\MainBundle\Entity\User\UserJobHistory;
use Chill\MainBundle\Entity\UserJob;
use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverter;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkReferrerHistory;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\Query\Expr;
use Doctrine\ORM\Query\Expr\Andx;
use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
@@ -24,7 +30,12 @@ use function in_array;
class JobFilter implements FilterInterface
{
public function __construct(protected TranslatorInterface $translator, private readonly TranslatableStringHelper $translatableStringHelper) {}
private const PREFIX = 'acp_work_action_filter_user_job';
public function __construct(
protected TranslatorInterface $translator,
private readonly TranslatableStringHelper $translatableStringHelper
) {}
public function addRole(): ?string
{
@@ -33,42 +44,35 @@ class JobFilter implements FilterInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array('acpwuser', $qb->getAllAliases(), true)) {
$qb->join('acpw.referrers', 'acpwuser');
}
$p = self::PREFIX;
$where = $qb->getDQLPart('where');
$clause = $qb->expr()->in('acpwuser.userJob', ':job');
$qb->andWhere(
'EXISTS (SELECT 1 FROM ' . AccompanyingPeriodWorkReferrerHistory::class . " {$p}_ref_history
JOIN {$p}_ref_history.user {$p}_ref_history_user JOIN {$p}_ref_history_user.jobHistories {$p}_job_history
WHERE {$p}_ref_history.accompanyingPeriodWork = acpw AND {$p}_job_history.job IN (:{$p}_job) AND {$p}_job_history.startDate <= {$p}_ref_history.startDate
AND ({$p}_job_history.endDate IS NULL or {$p}_job_history.endDate >= {$p}_ref_history.startDate))"
);
if ($where instanceof Andx) {
$where->add($clause);
} else {
$where = $qb->expr()->andX($clause);
}
$qb->add('where', $where);
$qb->setParameter('job', $data['job']);
$qb->setParameter("{$p}_job", $data["job"]);
}
public function applyOn()
public function applyOn(): string
{
return Declarations::SOCIAL_WORK_ACTION_TYPE;
}
public function buildForm(FormBuilderInterface $builder)
{
$builder->add('job', EntityType::class, [
'class' => UserJob::class,
'choice_label' => fn (UserJob $j) => $this->translatableStringHelper->localize(
$j->getLabel()
),
'multiple' => true,
'expanded' => true,
]);
}
public function getFormDefaultData(): array
{
return [];
$builder
->add('job', EntityType::class, [
'class' => UserJob::class,
'choice_label' => fn (UserJob $j) => $this->translatableStringHelper->localize(
$j->getLabel()
),
'multiple' => true,
'expanded' => true,
])
;
}
public function describeAction($data, $format = 'string')
@@ -81,13 +85,21 @@ class JobFilter implements FilterInterface
);
}
return ['Filtered by treating agent job: only %jobs%', [
return ['export.filter.work.by_user_job.Filtered by treating agent job: only %jobs%', [
'%jobs%' => implode(', ', $userjobs),
]];
}
public function getFormDefaultData(): array
{
return [
'job' => [],
'job_at' => new RollingDate(RollingDate::T_TODAY)
];
}
public function getTitle(): string
{
return 'Filter by treating agent job';
return 'export.filter.work.by_user_job.Filter by treating agent job';
}
}

View File

@@ -12,7 +12,10 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Filter\SocialWorkFilters;
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\Export\Declarations;
use Doctrine\ORM\Query\Expr\Andx;
@@ -20,8 +23,12 @@ use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use function in_array;
class ReferrerFilter implements FilterInterface
final readonly class ReferrerFilter implements FilterInterface
{
private const PREFIX = 'acpw_referrer_filter';
public function __construct(private RollingDateConverterInterface $rollingDateConverter) {}
public function addRole(): ?string
{
return null;
@@ -29,21 +36,19 @@ class ReferrerFilter implements FilterInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array('acpwuser', $qb->getAllAliases(), true)) {
$qb->join('acpw.referrers', 'acpwuser');
}
$p = self::PREFIX;
$where = $qb->getDQLPart('where');
$clause = $qb->expr()->in('acpwuser', ':agents');
$qb
->leftJoin('acpw.referrersHistory', $p . "_acpwusers_history")
->andWhere("{$p}_acpwusers_history.startDate <= :{$p}_calc_date AND ({$p}_acpwusers_history.endDate IS NULL or {$p}_acpwusers_history.endDate > :{$p}_calc_date)")
->andWhere("{$p}_acpwusers_history.user IN (:{$p}_agents)");
if ($where instanceof Andx) {
$where->add($clause);
} else {
$where = $qb->expr()->andX($clause);
}
$qb->add('where', $where);
$qb->setParameter('agents', $data['accepted_agents']);
$qb
->setParameter("{$p}_agents", $data['accepted_agents'])
->setParameter("{$p}_calc_date", $this->rollingDateConverter->convert(
$data['agent_at'] ?? new RollingDate(RollingDate::T_TODAY)
))
;
}
public function applyOn(): string
@@ -53,13 +58,23 @@ class ReferrerFilter implements FilterInterface
public function buildForm(FormBuilderInterface $builder)
{
$builder->add('accepted_agents', PickUserDynamicType::class, [
'multiple' => true,
]);
$builder
->add('accepted_agents', PickUserDynamicType::class, [
'multiple' => true,
'label' => 'export.filter.work.by_treating_agent.Accepted agents'
])
->add('agent_at', PickRollingDateType::class, [
'label' => 'export.filter.work.by_treating_agent.Calc date',
'help' => 'export.filter.work.by_treating_agent.calc_date_help',
])
;
}
public function getFormDefaultData(): array
{
return [];
return [
'accepted_agents' => [],
'agent_at' => new RollingDate(RollingDate::T_TODAY),
];
}
public function describeAction($data, $format = 'string'): array
@@ -71,13 +86,14 @@ class ReferrerFilter implements FilterInterface
}
return [
'Filtered by treating agent: only %agents%', [
'%agents' => implode(', ', $users),
'exports.filter.work.by_treating_agent.Filtered by treating agent at date', [
'agents' => implode(', ', $users),
'agent_at' => $this->rollingDateConverter->convert($data['agent_at'] ?? new RollingDate(RollingDate::T_TODAY)),
], ];
}
public function getTitle(): string
{
return 'Filter by treating agent';
return 'export.filter.work.by_treating_agent.Filter by treating agent';
}
}

View File

@@ -12,19 +12,28 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Filter\SocialWorkFilters;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User\UserScopeHistory;
use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverter;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkReferrerHistory;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\Query\Expr\Andx;
use Doctrine\ORM\Query\Expr;
use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use function in_array;
class ScopeFilter implements FilterInterface
{
public function __construct(protected TranslatorInterface $translator, private readonly TranslatableStringHelper $translatableStringHelper) {}
private const PREFIX = 'acp_work_action_filter_user_scope';
public function __construct(
protected TranslatorInterface $translator,
private readonly TranslatableStringHelper $translatableStringHelper
) {}
public function addRole(): ?string
{
@@ -33,21 +42,15 @@ class ScopeFilter implements FilterInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array('acpwuser', $qb->getAllAliases(), true)) {
$qb->join('acpw.referrers', 'acpwuser');
}
$p = self::PREFIX;
$where = $qb->getDQLPart('where');
$clause = $qb->expr()->in('acpwuser.mainScope', ':scope');
if ($where instanceof Andx) {
$where->add($clause);
} else {
$where = $qb->expr()->andX($clause);
}
$qb->add('where', $where);
$qb->setParameter('scope', $data['scope']);
$qb->andWhere(
'EXISTS (SELECT 1 FROM ' . AccompanyingPeriodWorkReferrerHistory::class . " {$p}_ref_history
JOIN {$p}_ref_history.user {$p}_ref_history_user JOIN {$p}_ref_history_user.scopeHistories {$p}_scope_history
WHERE {$p}_ref_history.accompanyingPeriodWork = acpw AND {$p}_scope_history.scope IN (:{$p}_scope) AND {$p}_scope_history.startDate <= {$p}_ref_history.startDate
AND ({$p}_scope_history.endDate IS NULL or {$p}_scope_history.endDate >= {$p}_ref_history.startDate))"
)
->setParameter("{$p}_scope", $data["scope"]);
}
public function applyOn()
@@ -57,21 +60,19 @@ class ScopeFilter implements FilterInterface
public function buildForm(FormBuilderInterface $builder)
{
$builder->add('scope', EntityType::class, [
'class' => Scope::class,
'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize(
$s->getName()
),
'multiple' => true,
'expanded' => true,
]);
}
public function getFormDefaultData(): array
{
return [];
$builder
->add('scope', EntityType::class, [
'class' => Scope::class,
'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize(
$s->getName()
),
'multiple' => true,
'expanded' => true,
])
;
}
public function describeAction($data, $format = 'string')
public function describeAction($data, $format = 'string'): array
{
$scopes = [];
@@ -81,13 +82,21 @@ class ScopeFilter implements FilterInterface
);
}
return ['Filtered by treating agent scope: only %scopes%', [
return ['export.filter.work.by_user_scope.Filtered by treating agent scope: only %scopes%', [
'%scopes%' => implode(', ', $scopes),
]];
}
public function getTitle()
public function getFormDefaultData(): array
{
return 'Filter by treating agent scope';
return [
'scope' => [],
'scope_at' => new RollingDate(RollingDate::T_TODAY)
];
}
public function getTitle(): string
{
return 'export.filter.work.by_user_scope.Filter by treating agent scope';
}
}

View File

@@ -15,6 +15,7 @@ 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\Export\Helper\UserHelper;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Household\PersonHouseholdAddress;
@@ -59,8 +60,10 @@ final readonly class ListAccompanyingPeriodHelper
'scopes',
'socialIssues',
'acpCreatedAt',
'acpCreatedBy_id',
'acpCreatedBy',
'acpUpdatedAt',
'acpUpdatedBy_id',
'acpUpdatedBy',
];
@@ -75,6 +78,7 @@ final readonly class ListAccompanyingPeriodHelper
private SocialIssueRender $socialIssueRender,
private TranslatableStringHelperInterface $translatableStringHelper,
private TranslatorInterface $translator,
private UserHelper $userHelper,
) {}
public function getQueryKeys($data)
@@ -104,6 +108,7 @@ final readonly class ListAccompanyingPeriodHelper
return $this->translatableStringHelper->localize(json_decode((string) $value, true, 512, JSON_THROW_ON_ERROR));
},
'acpCreatedBy', 'acpUpdatedBy', 'referrer' => $this->userHelper->getLabel($key, $values, 'export.list.acp.' . $key),
'locationPersonName', 'requestorPerson' => function ($value) use ($key) {
if ('_header' === $value) {
return 'export.list.acp.' . $key;
@@ -204,11 +209,11 @@ final readonly class ListAccompanyingPeriodHelper
// add the field which are simple association
$qb
->leftJoin('acp.createdBy', "acp_created_by_t")
->addSelect('acp_created_by_t.label AS acpCreatedBy');
->addSelect('IDENTITY(acp.createdBy) AS acpCreatedBy_id')
->addSelect('JSON_BUILD_OBJECT(\'uid\', IDENTITY(acp.createdBy), \'d\', acp.createdAt) AS acpCreatedBy');
$qb
->leftJoin('acp.updatedBy', "acp_updated_by_t")
->addSelect('acp_updated_by_t.label AS acpUpdatedBy');
->addSelect('IDENTITY(acp.updatedBy) AS acpUpdatedBy_id')
->addSelect('JSON_BUILD_OBJECT(\'uid\', IDENTITY(acp.updatedBy), \'d\', acp.updatedAt) AS acpUpdatedBy');
foreach (['origin' => 'label', 'closingMotive' => 'name', 'job' => 'label', 'administrativeLocation' => 'name'] as $entity => $field) {
$qb
@@ -230,7 +235,7 @@ final readonly class ListAccompanyingPeriodHelper
// referree at date
$qb
->addSelect('referrer_t.label AS referrer')
->addSelect('JSON_BUILD_OBJECT(\'uid\', IDENTITY(userHistory.user), \'d\', userHistory.startDate) AS referrer')
->addSelect('userHistory.startDate AS referrerSince')
->leftJoin('acp.userHistories', 'userHistory')
->leftJoin('userHistory.user', 'referrer_t')

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Repository\AccompanyingPeriod;
use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
use DateTimeImmutable;
use Doctrine\ORM\EntityManagerInterface;
@@ -91,7 +92,9 @@ class AccompanyingPeriodWorkEvaluationRepository implements ObjectRepository
$qb->expr()->gte(':now', $qb->expr()->diff('e.maxDate', 'e.warningInterval')),
$qb->expr()->orX(
$qb->expr()->eq('period.user', ':user'),
$qb->expr()->isMemberOf(':user', 'work.referrers')
$qb->expr()->exists(
'SELECT 1 FROM ' . AccompanyingPeriodWork::class . ' subw JOIN subw.referrersHistory subw_ref_history WHERE subw.id = work.id AND subw_ref_history.user = :user'
)
)
)
)

View File

@@ -132,10 +132,10 @@ final readonly class AccompanyingPeriodWorkRepository implements ObjectRepositor
// set limit and offset
$sql .= " ORDER BY
CASE WHEN enddate IS NULL THEN '-infinity'::timestamp ELSE 'infinity'::timestamp END ASC,
startdate DESC,
enddate DESC,
id DESC";
CASE WHEN w.enddate IS NULL THEN '-infinity'::timestamp ELSE 'infinity'::timestamp END ASC,
w.startdate DESC,
w.enddate DESC,
w.id DESC";
$sql .= " LIMIT :limit OFFSET :offset";
@@ -239,7 +239,9 @@ final readonly class AccompanyingPeriodWorkRepository implements ObjectRepositor
$qb->expr()->lte('w.startDate', ':until'),
$qb->expr()->orX(
$qb->expr()->eq('period.user', ':user'),
$qb->expr()->isMemberOf(':user', 'w.referrers')
$qb->expr()->exists(
'SELECT 1 FROM ' . AccompanyingPeriodWork::class . ' subw JOIN subw.referrersHistory subw_ref_history WHERE subw.id = w.id AND subw_ref_history.user = :user and subw.ref_history.endDate IS NULL'
)
)
)
)

View File

@@ -54,7 +54,7 @@ class AccompanyingPeriodWorkEndQueryPartForAccompanyingPeriodInfo implements Acc
public function getFromStatement(): string
{
return 'chill_person_accompanying_period_work w
LEFT JOIN chill_person_accompanying_period_work_referrer cpapwr on w.id = cpapwr.accompanyingperiodwork_id';
LEFT JOIN chill_person_accompanying_period_work_referrer cpapwr ON w.id = cpapwr.accompanyingperiodwork_id AND daterange(cpapwr.startDate, cpapwr.endDate) @> w.endDate';
}
public function getWhereClause(): string

View File

@@ -11,10 +11,11 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Service\EntityInfo\AccompanyingPeriodInfoQueryPart;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
use Chill\PersonBundle\Service\EntityInfo\AccompanyingPeriodInfoUnionQueryPartInterface;
class AccompanyingPeriodWorkEvaluationWarningDateQueryPartForAccompanyingPeriodInfo implements AccompanyingPeriodInfoUnionQueryPartInterface
class AccompanyingPeriodWorkEvaluationCreationQueryPartForAccompanyingPeriodInfo implements AccompanyingPeriodInfoUnionQueryPartInterface
{
public function getAccompanyingPeriodIdColumn(): string
{
@@ -33,12 +34,12 @@ class AccompanyingPeriodWorkEvaluationWarningDateQueryPartForAccompanyingPeriodI
public function getUserIdColumn(): string
{
return 'cpapwr.user_id';
return 'e.createdBy_id';
}
public function getDateTimeColumn(): string
{
return 'e.maxDate';
return 'e.createdAt';
}
public function getMetadataColumn(): string
@@ -48,18 +49,18 @@ class AccompanyingPeriodWorkEvaluationWarningDateQueryPartForAccompanyingPeriodI
public function getDiscriminator(): string
{
return 'accompanying_period_work_evaluation_max';
return 'accompanying_period_work_evaluation_creation';
}
public function getFromStatement(): string
{
return 'chill_person_accompanying_period_work_evaluation e
JOIN chill_person_accompanying_period_work cpapw ON cpapw.id = e.accompanyingperiodwork_id
LEFT JOIN chill_person_accompanying_period_work_referrer cpapwr ON cpapw.id = cpapwr.accompanyingperiodwork_id';
LEFT JOIN chill_person_accompanying_period_work_referrer cpapwr ON cpapw.id = cpapwr.accompanyingperiodwork_id AND daterange(cpapwr.startDate, cpapwr.endDate) @> e.startDate';
}
public function getWhereClause(): string
{
return 'e.maxDate IS NOT NULL';
return 'e.createdAt IS NOT NULL';
}
}

View File

@@ -56,7 +56,7 @@ class AccompanyingPeriodWorkEvaluationMaxQueryPartForAccompanyingPeriodInfo impl
{
return 'chill_person_accompanying_period_work_evaluation e
JOIN chill_person_accompanying_period_work cpapw ON cpapw.id = e.accompanyingperiodwork_id
LEFT JOIN chill_person_accompanying_period_work_referrer cpapwr ON cpapw.id = cpapwr.accompanyingperiodwork_id';
LEFT JOIN chill_person_accompanying_period_work_referrer cpapwr ON cpapw.id = cpapwr.accompanyingperiodwork_id AND daterange(cpapwr.startDate, cpapwr.endDate) @> e.maxDate';
}
public function getWhereClause(): string

View File

@@ -56,11 +56,11 @@ class AccompanyingPeriodWorkEvaluationStartQueryPartForAccompanyingPeriodInfo im
{
return 'chill_person_accompanying_period_work_evaluation e
JOIN chill_person_accompanying_period_work cpapw ON cpapw.id = e.accompanyingperiodwork_id
LEFT JOIN chill_person_accompanying_period_work_referrer cpapwr ON cpapw.id = cpapwr.accompanyingperiodwork_id';
LEFT JOIN chill_person_accompanying_period_work_referrer cpapwr ON cpapw.id = cpapwr.accompanyingperiodwork_id AND daterange(cpapwr.startDate, cpapwr.endDate) @> e.startDate';
}
public function getWhereClause(): string
{
return '';
return 'e.startDate IS NOT NULL';
}
}

View File

@@ -0,0 +1,64 @@
<?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\Service\EntityInfo\AccompanyingPeriodInfoQueryPart;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
use Chill\PersonBundle\Service\EntityInfo\AccompanyingPeriodInfoUnionQueryPartInterface;
class AccompanyingPeriodWorkNewReferrerQueryPartForAccompanyingPeriodInfo implements AccompanyingPeriodInfoUnionQueryPartInterface
{
public function getAccompanyingPeriodIdColumn(): string
{
return 'w.accompanyingperiod_id';
}
public function getRelatedEntityColumn(): string
{
return AccompanyingPeriodWork::class;
}
public function getRelatedEntityIdColumn(): string
{
return 'w.id';
}
public function getUserIdColumn(): string
{
return 'cpapwr.user_id';
}
public function getDateTimeColumn(): string
{
return 'cpapwr.startDate';
}
public function getMetadataColumn(): string
{
return "'{}'::jsonb";
}
public function getDiscriminator(): string
{
return 'accompanying_period_work_referrer_new';
}
public function getFromStatement(): string
{
return 'chill_person_accompanying_period_work w
JOIN chill_person_accompanying_period_work_referrer cpapwr on w.id = cpapwr.accompanyingperiodwork_id';
}
public function getWhereClause(): string
{
return '';
}
}

View File

@@ -54,7 +54,7 @@ class AccompanyingPeriodWorkStartQueryPartForAccompanyingPeriodInfo implements A
public function getFromStatement(): string
{
return 'chill_person_accompanying_period_work w
LEFT JOIN chill_person_accompanying_period_work_referrer cpapwr on w.id = cpapwr.accompanyingperiodwork_id';
LEFT JOIN chill_person_accompanying_period_work_referrer cpapwr on w.id = cpapwr.accompanyingperiodwork_id AND daterange(cpapwr.startDate, cpapwr.endDate) @> w.startDate';
}
public function getWhereClause(): string

View File

@@ -24,6 +24,7 @@ use Chill\PersonBundle\Entity\Household\HouseholdMember;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\Relationships\Relation;
use Chill\PersonBundle\Entity\Relationships\Relationship;
use Chill\PersonBundle\Repository\Person\PersonCenterHistoryInterface;
use Chill\PersonBundle\Repository\PersonRepository;
use Doctrine\DBAL\Connection;
use Doctrine\ORM\EntityManagerInterface;
@@ -44,6 +45,8 @@ class PersonMoveTest extends KernelTestCase
private CenterRepositoryInterface $centerRepository;
private PersonCenterHistoryInterface $personCenterHistory;
/**
* @var list<array{0: class-string, 1: int}>
*/
@@ -56,6 +59,7 @@ class PersonMoveTest extends KernelTestCase
$this->personMoveManager = self::$container->get(PersonMoveManager::class);
$this->eventDispatcher = self::$container->get(EventDispatcherInterface::class);
$this->centerRepository = self::$container->get(CenterRepositoryInterface::class);
$this->personCenterHistory = self::$container->get(PersonCenterHistoryInterface::class);
}
public static function tearDownAfterClass(): void
@@ -146,18 +150,22 @@ class PersonMoveTest extends KernelTestCase
$personB = $this->em->find(Person::class, $personB->getId());
$message = 'Move persons with overlapping center histories';
$this->em->refresh($personB);
self::assertCount(0, $personsByIdOfA);
self::assertNotNull($personB?->getId(), $message);
$centerHistoriesB = $personB->getCenterHistory();
$oldestDate = new \DateTimeImmutable('2023-01-01');
$centersHistories = $this->personCenterHistory->findBy(['person' => $personB]);
$this->em->refresh($centerHistoriesB->first());
// compute the oldest center history
$oldestCenterHistory = null;
foreach ($centersHistories as $centerHistory) {
$this->em->refresh($centerHistory);
if (null === $oldestCenterHistory || ($oldestCenterHistory instanceof Person\PersonCenterHistory && $oldestCenterHistory->getStartDate() >= $centerHistory->getStartDate())) {
$oldestCenterHistory = $centerHistory;
}
}
self::assertCount(2, $centerHistoriesB);
self::assertEquals($oldestDate, $centerHistoriesB->first()->getStartDate());
self::assertCount(2, $centersHistories);
self::assertEquals('2023-01-01', $oldestCenterHistory?->getStartDate()->format('Y-m-d'));
self::$entitiesToDelete[] = [Person::class, $personA];
self::$entitiesToDelete[] = [Person::class, $personB];
@@ -218,11 +226,11 @@ class PersonMoveTest extends KernelTestCase
$this->em->persist($memberA);
$this->em->persist($memberB);
self::$entitiesToDelete[] = [Person::class, $personA];
self::$entitiesToDelete[] = [Person::class, $personB];
self::$entitiesToDelete[] = [HouseholdMember::class, $memberA];
self::$entitiesToDelete[] = [HouseholdMember::class, $memberB];
self::$entitiesToDelete[] = [Household::class, $household];
self::$entitiesToDelete[] = [Person::class, $personA];
self::$entitiesToDelete[] = [Person::class, $personB];
yield [$personA, $personB, "move 2 people having the same household at the same time"];

View File

@@ -52,16 +52,6 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
private ?int $personId = null;
private KernelBrowser $client;
/**
* Setup before each test method (see phpunit doc).
*/
protected function setUp(): void
{
$this->client = $this->getClientAuthenticated();
}
protected function tearDown(): void
{
self::ensureKernelShutdown();
@@ -427,8 +417,9 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
*/
public function testAccompanyingCourseShow(int $personId, int $periodId)
{
$c = $this->client->request(Request::METHOD_GET, sprintf('/api/1.0/person/accompanying-course/%d.json', $periodId));
$response = $this->client->getResponse();
$client = $this->getClientAuthenticated();
$client->request(Request::METHOD_GET, sprintf('/api/1.0/person/accompanying-course/%d.json', $periodId));
$response = $client->getResponse();
$this->assertTrue(in_array($response->getStatusCode(), [200, 422], true));
@@ -548,12 +539,13 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
*/
public function testReferralAvailable(int $personId, int $periodId)
{
$this->client->request(
$client = $this->getClientAuthenticated();
$client->request(
Request::METHOD_POST,
sprintf('/api/1.0/person/accompanying-course/%d/referrers-suggested.json', $periodId)
);
$this->assertTrue(in_array($this->client->getResponse()->getStatusCode(), [200, 422], true));
$this->assertTrue(in_array($client->getResponse()->getStatusCode(), [200, 422], true));
}
/**
@@ -732,8 +724,9 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
public function testShow404()
{
$this->client->request(Request::METHOD_GET, sprintf('/api/1.0/person/accompanying-course/%d.json', 99999));
$response = $this->client->getResponse();
$client = $this->getClientAuthenticated();
$client->request(Request::METHOD_GET, sprintf('/api/1.0/person/accompanying-course/%d.json', 99999));
$response = $client->getResponse();
$this->assertEquals(404, $response->getStatusCode(), "Test that the response of rest api has a status code 'not found' (404)");
}

View File

@@ -137,20 +137,17 @@ final class HouseholdApiControllerTest extends WebTestCase
$qb = self::$container->get(EntityManagerInterface::class)
->createQueryBuilder();
$period = $qb
->select('ap')
->from(AccompanyingPeriod::class, 'ap')
$personIds = $qb
->select("p.id AS pid")
->from(Person::class, 'p')
->where(
$qb->expr()->gte('SIZE(ap.participations)', 2)
$qb->expr()->gte('SIZE(p.accompanyingPeriodParticipations)', 2)
)
->getQuery()
->setMaxResults(1)
->getSingleResult();
$person = $period->getParticipations()
->first()->getPerson();
yield [$person->getId()];
yield [$personIds['pid']];
self::ensureKernelShutdown();
}

View File

@@ -0,0 +1,96 @@
<?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\Tests\Entity\AccompanyingPeriod;
use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkReferrerHistory;
use PHPUnit\Framework\TestCase;
/**
* @internal
* @coversNothing
*/
class AccompanyingPeriodWorkTest extends TestCase
{
public function testReferrerHistory(): void
{
$work = new AccompanyingPeriodWork();
$userA = new User();
$userB = new User();
$userC = new User();
self::assertCount(0, $work->getReferrers());
$work->addReferrer($userA);
self::assertCount(1, $work->getReferrers());
self::assertContains($userA, $work->getReferrers());
$work->addReferrer($userB);
self::assertCount(2, $work->getReferrers());
self::assertContains($userA, $work->getReferrers());
self::assertContains($userB, $work->getReferrers());
$work->addReferrer($userC);
$work->removeReferrer($userB);
self::assertCount(2, $work->getReferrers());
self::assertContains($userA, $work->getReferrers());
self::assertNotContains($userB, $work->getReferrers());
self::assertContains($userC, $work->getReferrers());
$work->removeReferrer($userA);
self::assertNotContains($userA, $work->getReferrers());
self::assertNotContains($userB, $work->getReferrers());
self::assertContains($userC, $work->getReferrers());
}
public function testReferrerHistoryOnDifferentDays(): void
{
$work = new AccompanyingPeriodWork();
$userA = new User();
$userB = new User();
$userC = new User();
$work->addReferrer($userA);
$historyA = $work->getReferrersHistory()->first();
$reflection = new \ReflectionClass($historyA);
$startDateReflection = $reflection->getProperty('startDate');
$startDateReflection->setAccessible(true);
$startDateReflection->setValue($historyA, new \DateTimeImmutable('1 year ago'));
$work->addReferrer($userB);
$work->addReferrer($userC);
$work->removeReferrer($userB);
$work->removeReferrer($userA);
self::assertCount(1, $work->getReferrers());
self::assertNotContains($userA, $work->getReferrers());
self::assertNotContains($userB, $work->getReferrers());
self::assertContains($userC, $work->getReferrers());
self::assertCount(2, $work->getReferrersHistory());
$historyA = $work->getReferrersHistory()
->filter(fn (AccompanyingPeriodWorkReferrerHistory $h) => $userA === $h->getUser())
->first();
self::assertNotFalse($historyA);
self::assertSame($userA, $historyA->getUser());
self::assertEquals((new \DateTimeImmutable())->format('Y-m-d'), $historyA->getEndDate()->format('Y-m-d'));
}
}

View File

@@ -71,7 +71,6 @@ final class ReferrerScopeAggregatorTest extends AbstractAggregatorTest
$em->createQueryBuilder()
->select('count(acp.id)')
->from(AccompanyingPeriod::class, 'acp')
->join('acp.scopes', 'acpscope'),
];
}
}

View File

@@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Export\Aggregator\AccompanyingCourseAggregators;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\UserJobAggregator;
@@ -39,7 +40,9 @@ final class UserJobAggregatorTest extends AbstractAggregatorTest
public function getFormData(): array
{
return [
[],
[
'job_at' => new RollingDate(RollingDate::T_FIXED_DATE, \DateTimeImmutable::createFromFormat('Y-m-d', '2020-01-01')),
],
];
}

View File

@@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Export\Aggregator\SocialWorkAggregators;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\JobAggregator;
@@ -54,7 +55,6 @@ final class JobAggregatorTest extends AbstractAggregatorTest
->select('count(acp.id)')
->from(AccompanyingPeriod::class, 'acp')
->join('acp.works', 'acpw')
->join('acpw.referrers', 'acpwuser'),
];
}
}

View File

@@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Export\Aggregator\SocialWorkAggregators;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
use Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ReferrerAggregator;
@@ -39,7 +40,10 @@ final class ReferrerAggregatorTest extends AbstractAggregatorTest
public function getFormData(): array
{
return [
[],
[], // there are previous saved export which does not contains any data
[
'referrer_at' => new RollingDate(RollingDate::T_TODAY)
]
];
}

View File

@@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Export\Aggregator\SocialWorkAggregators;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ScopeAggregator;
@@ -54,7 +55,6 @@ final class ScopeAggregatorTest extends AbstractAggregatorTest
->select('count(acp.id)')
->from(AccompanyingPeriod::class, 'acp')
->join('acp.works', 'acpw')
->join('acpw.referrers', 'acpwuser'),
];
}
}

View File

@@ -0,0 +1,53 @@
<?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\Tests\Export\Export;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Export\Formatter\SpreadsheetListFormatter;
use Chill\MainBundle\Repository\CenterRepositoryInterface;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\PersonBundle\Export\Export\ListAccompanyingPeriod;
use Doctrine\ORM\AbstractQuery;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
/**
* @internal
* @coversNothing
*/
class ListAccompanyingPeriodTest extends KernelTestCase
{
private ListAccompanyingPeriod $listAccompanyingPeriod;
private CenterRepositoryInterface $centerRepository;
protected function setUp(): void
{
parent::setUp();
self::bootKernel();
$this->listAccompanyingPeriod = self::$container->get(ListAccompanyingPeriod::class);
$this->centerRepository = self::$container->get(CenterRepositoryInterface::class);
}
public function testQuery(): void
{
$centers = $this->centerRepository->findAll();
$query = $this->listAccompanyingPeriod->initiateQuery([], array_map(fn (Center $c) => ['center' => $c ], $centers), $exportOpts = ['calc_date' => new RollingDate(RollingDate::T_TODAY)]);
$query->setMaxResults(1);
$actual = $query->getQuery()->getResult(AbstractQuery::HYDRATE_ARRAY);
self::assertIsArray($actual);
}
}

View File

@@ -0,0 +1,49 @@
<?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\Tests\Export\Export;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Repository\CenterRepositoryInterface;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\PersonBundle\Export\Export\ListAccompanyingPeriodWork;
use Doctrine\ORM\AbstractQuery;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
/**
* @internal
* @coversNothing
*/
class ListAccompanyingPeriodWorkTest extends KernelTestCase
{
private ListAccompanyingPeriodWork $listAccompanyingPeriodWork;
private CenterRepositoryInterface $centerRepository;
protected function setUp(): void
{
parent::setUp();
self::bootKernel();
$this->listAccompanyingPeriodWork = self::$container->get(ListAccompanyingPeriodWork::class);
$this->centerRepository = self::$container->get(CenterRepositoryInterface::class);
}
public function testQuery(): void
{
$centers = $this->centerRepository->findAll();
$query = $this->listAccompanyingPeriodWork->initiateQuery([], array_map(fn (Center $c) => ['center' => $c], $centers), ['calc_date' => new RollingDate(RollingDate::T_TODAY)]);
$query->setMaxResults(1);
self::assertIsArray($query->getQuery()->getResult(AbstractQuery::HYDRATE_ARRAY));
}
}

View File

@@ -0,0 +1,49 @@
<?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\Tests\Export\Export;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Repository\CenterRepositoryInterface;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\PersonBundle\Export\Export\ListEvaluation;
use Doctrine\ORM\AbstractQuery;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
/**
* @internal
* @coversNothing
*/
class ListEvaluationTest extends KernelTestCase
{
private ListEvaluation $listEvaluation;
private CenterRepositoryInterface $centerRepository;
protected function setUp(): void
{
parent::setUp();
self::bootKernel();
$this->listEvaluation = self::$container->get(ListEvaluation::class);
$this->centerRepository = self::$container->get(CenterRepositoryInterface::class);
}
public function testQuery(): void
{
$centers = $this->centerRepository->findAll();
$query = $this->listEvaluation->initiateQuery([], array_map(fn (Center $c) => ['center' => $c], $centers), ['calc_date' => new RollingDate(RollingDate::T_TODAY)]);
$query->setMaxResults(1);
self::assertIsArray($query->getQuery()->getResult(AbstractQuery::HYDRATE_ARRAY));
}
}

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Export\Filter\SocialWorkFilters;
use Chill\MainBundle\Entity\UserJob;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
use Chill\PersonBundle\Export\Filter\SocialWorkFilters\JobFilter;
@@ -49,7 +50,7 @@ final class JobFilterTest extends AbstractFilterTest
return [
[
'job' => new ArrayCollection($jobs)
'job' => new ArrayCollection($jobs),
]
];
}

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Export\Filter\SocialWorkFilters;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Export\Filter\SocialWorkFilters\ReferrerFilter;
@@ -47,8 +48,13 @@ final class ReferrerFilterTest extends AbstractFilterTest
$data = [];
foreach ($users as $u) {
$data[] = [
'accepted_agents' => $u, // some saved export does not have the parameter "agent_at"
];
$data[] = [
'accepted_agents' => $u,
'agent_at' => new RollingDate(RollingDate::T_TODAY)
];
}

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Export\Filter\SocialWorkFilters;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
use Chill\PersonBundle\Export\Filter\SocialWorkFilters\ScopeFilter;
@@ -48,7 +49,7 @@ final class ScopeFilterTest extends AbstractFilterTest
return [
[
'scope' => $scopes
'scope' => $scopes,
]
];
}

View File

@@ -0,0 +1,44 @@
<?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\Tests\Repository;
use Chill\MainBundle\Repository\UserRepository;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
/**
* @internal
* @coversNothing
*/
class UserRepositoryTest extends KernelTestCase
{
private UserRepository $userRepository;
protected function setUp(): void
{
parent::setUp();
self::bootKernel();
$this->userRepository = self::$container->get(UserRepository::class);
}
public function testFindAllAsArray(): void
{
$userIterator = $this->userRepository->findAllAsArray('fr');
self::assertIsIterable($userIterator);
$i = 0;
foreach ($userIterator as $u) {
self::assertIsArray($u);
$i++;
}
self::assertGreaterThan(0, $i);
}
}

View File

@@ -0,0 +1,85 @@
<?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\Migrations\Person;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20231004142738 extends AbstractMigration
{
public function getDescription(): string
{
return 'keep an history of accompanying period work referrer';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE SEQUENCE chill_person_accompanying_period_work_referrer_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer DROP CONSTRAINT fk_3619f5ebb99f6060');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer DROP CONSTRAINT FK_3619F5EBA76ED395');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer DROP CONSTRAINT chill_person_accompanying_period_work_referrer_pkey');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ADD id INT NOT NULL DEFAULT nextval(\'chill_person_accompanying_period_work_referrer_id_seq\')');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ADD endDate DATE DEFAULT NULL');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ADD startDate DATE DEFAULT NULL');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ALTER accompanyingperiodwork_id DROP NOT NULL');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ALTER user_id DROP NOT NULL');
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work_referrer.endDate IS \'(DC2Type:date_immutable)\'');
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work_referrer.startDate IS \'(DC2Type:date_immutable)\'');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ADD CONSTRAINT FK_3619F5EBC55C1209 FOREIGN KEY (accompanyingPeriodWork_id) REFERENCES chill_person_accompanying_period_work (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ADD CONSTRAINT FK_3619F5EBA76ED395 FOREIGN KEY (user_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ADD PRIMARY KEY (id)');
$this->addSql('ALTER INDEX idx_3619f5ebb99f6060 RENAME TO IDX_3619F5EBC55C1209');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ADD createdAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL;');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ADD updatedAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL;');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ADD createdBy_id INT DEFAULT NULL;');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ADD updatedBy_id INT DEFAULT NULL;');
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work_referrer.endDate IS \'(DC2Type:date_immutable)\'');
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work_referrer.startDate IS \'(DC2Type:date_immutable)\'');
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work_referrer.createdAt IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work_referrer.updatedAt IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ADD CONSTRAINT FK_3619F5EB3174800F FOREIGN KEY (createdBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE;');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ADD CONSTRAINT FK_3619F5EB65FF1AEC FOREIGN KEY (updatedBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE;');
$this->addSql('CREATE INDEX IDX_3619F5EB3174800F ON chill_person_accompanying_period_work_referrer (createdBy_id);');
$this->addSql('CREATE INDEX IDX_3619F5EB65FF1AEC ON chill_person_accompanying_period_work_referrer (updatedBy_id);');
// set a default date on startDate
$this->addSql('UPDATE chill_person_accompanying_period_work_referrer r SET startdate=w.startdate FROM chill_person_accompanying_period_work w WHERE w.id = r.accompanyingperiodwork_id');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ALTER startDate SET NOT NULL');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ADD CONSTRAINT cpapwr_start_date_before_end CHECK (startdate <= enddate OR enddate IS NULL)');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer
ADD CONSTRAINT acc_period_work_ref_history_not_overlaps
EXCLUDE USING GIST (accompanyingperiodwork_id with =, user_id with =, tsrange(startdate, enddate) with &&)
DEFERRABLE INITIALLY DEFERRED');
}
public function down(Schema $schema): void
{
$this->addSql('DROP SEQUENCE chill_person_accompanying_period_work_referrer_id_seq CASCADE');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer DROP CONSTRAINT FK_3619F5EBC55C1209');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer DROP CONSTRAINT fk_3619f5eba76ed395');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer DROP CONSTRAINT cpapwr_start_date_before_end');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer DROP CONSTRAINT acc_period_work_ref_history_not_overlaps');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer DROP CONSTRAINT chill_person_accompanying_period_work_referrer_pkey');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer DROP id');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer DROP endDate');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer DROP startDate');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ALTER user_id SET NOT NULL');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ALTER accompanyingPeriodWork_id SET NOT NULL');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ADD CONSTRAINT fk_3619f5ebb99f6060 FOREIGN KEY (accompanyingperiodwork_id) REFERENCES chill_person_accompanying_period_work (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ADD CONSTRAINT fk_3619f5eba76ed395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ADD PRIMARY KEY (accompanyingperiodwork_id, user_id)');
$this->addSql('ALTER INDEX idx_3619f5ebc55c1209 RENAME TO idx_3619f5ebb99f6060');
}
}

View File

@@ -135,7 +135,11 @@ exports:
by_person:
Filtered by person\'s geographical unit (based on address) computed at date, only units:
"Filtré par zone géographique sur base de l'adresse, calculé à {datecalc, date, short}, seulement les zones suivantes: {units}"
filter:
work:
by_treating_agent:
Filtered by treating agent at date: >-
Les agents traitant au { agent_at, date, medium }, seulement {agents}
'total persons matching the search pattern': >-
{ total, plural,
=0 {Aucun usager ne correspond aux termes de recherche}

View File

@@ -461,15 +461,6 @@ Filtered by person having an activity between %date_from% and %date_to% with rea
## accompanying course filters/aggr
Filter by user scope: Filtrer les parcours par service du référent
"Filtered by user main scope: only %scope%": "Filtré par service du référent: uniquement %scope%"
Group course by scope: Grouper les parcours par service
Filter by user job: Filtrer les parcours par métier du référent
"Filtered by user job: only %job%": "Filtré par métier du référent: uniquement %job%"
Group by user job: Grouper les parcours par métier du référent
Filter by social issue: Filtrer les parcours par problématiques sociales
Accepted socialissues: Problématiques sociales
"Filtered by socialissues: only %socialissues%": "Filtré par problématique sociale: uniquement %socialissues%"
@@ -583,9 +574,6 @@ Filtered acp which has no actions: 'Filtré: uniquement les parcours qui n''ont
Group by number of actions: Grouper les parcours par nombre dactions
Filter by creator: Filtrer les parcours par créateur
'Filtered by creator: only %creators%': 'Filtré par créateur: uniquement %creators%'
Filter by creator job: Filtrer les parcours par métier du créateur
'Filtered by creator job: only %jobs%': 'Filtré par métier du créateur: uniquement %jobs%'
Group by creator job: Grouper les parcours par métier du créateur
Filter actions without end date: Filtre les actions sans date de fin (ouvertes)
Filtered actions without end date: 'Filtré: uniquement les actions sans date de fin (ouvertes)'
@@ -601,20 +589,8 @@ Filter by current evaluations: Filtrer les évaluations en cours
'Filtered by geographic unit: computed at %date%, only in %units%': 'Filtré par unité géographique: adresse le %date%, seulement les unités %units%'
## social actions filters/aggr
Filter by treating agent scope: Filtrer les actions par service de l'agent traitant
"Filtered by treating agent scope: only %scopes%": "Filtré par service de l'agent traitant: uniquement %scopes%"
Group by treating agent scope: Grouper les actions par service de l'agent traitant
Filter by scope: Filtrer par service
Filter by treating agent job: Filtrer les actions par métier de l'agent traitant
"Filtered by treating agent job: only %jobs%": "Filtré par métier de l'agent traitant: uniquement %jobs%"
Group by treating agent job: Grouper les actions par métier de l'agent traitant
Filter by treating agent: Filtrer les actions par agent traitant
Accepted agents: Agent traitant
"Filtered by treating agent: only %agents%": "Filtré par agent traitant: uniquement %agents%"
Group by treating agent: Grouper les actions par agent traitant
Group social work actions by action type: Grouper les actions par type
Group social work actions by goal: Grouper les actions par objectif
@@ -1011,12 +987,14 @@ export:
count_participations: Nombre de participations distinctes
count_persons: Nombre d'usagers concernés distincts
count_acps: Nombre de parcours distincts
nb_household_with_course:
Count households with accompanying course: Nombre de ménages impliqués dans un parcours
Count households: Nombre de ménages
Count accompanying periods: Nombre de parcours
Count household with accompanying course by various parameters.: Compte le nombre de ménages impliqués dans un parcours selon différents filtres.
Date of calculation of household members: Date à laquelle les membres du ménages sont comptabilisés
aggregator:
person:
by_household_composition:
@@ -1033,8 +1011,9 @@ export:
Computation date for referrer: Date à laquelle le référent était actif
by_user_scope:
Group course by referrer's scope: Grouper les parcours par service du référent
Computation date for referrer: Date à laquelle le référent était actif
Referrer's scope: Service du référent de parcours
by_user_job:
Group by user job: Grouper les parcours par métier du référent
duration:
day: Durée du parcours en jours
week: Durée du parcours en semaines
@@ -1044,21 +1023,37 @@ export:
Number of actions: Nombre d'actions
by_creator_job:
Creator's job: Métier du créateur
Group by creator job: Grouper les parcours par 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
Calc date: Date de calcul du métier de l'intervenant
by_scope_working:
title: Grouper les parcours par service de l'intervenant
scope: Service de l'intervenant
Calc date: Date de calcul du service de l'intervenant
by_scope:
Group course by scope: Grouper les parcours par service
course_work:
by_treating_agent:
Calc date: Référent à la date
Group by treating agent: Grouper les actions par agent traitant
by_current_action:
Current action ?: Action en cours ?
Group by current actions: Grouper les actions en cours
Current action: Action en cours
Not current action: Action terminée
by_agent_scope:
Group by treating agent scope: Grouper les actions par service de l'agent traitant
Calc date: Date de calcul du service de l'agent traitant
by_agent_job:
Group by treating agent job: Grouper les actions par métier de l'agent traitant
Calc date: Date de calcul du métier de l'agent traitant
eval:
by_end_date:
Has end date ?: Évaluation en cours ?
@@ -1077,6 +1072,7 @@ export:
filter:
by_geog_unit:
Filtered by person's geographical unit (based on address) computed at %datecalc%, only %units%: Filtré par unité géographique (sur base de l'adresse), calculé le %datecalc%, seulement %units%
person:
by_composition:
Filter by household composition: Filtrer les usagers par composition du ménage
@@ -1111,11 +1107,13 @@ export:
'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
Calc date:
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
Calc date:
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
@@ -1125,7 +1123,8 @@ export:
date_to: Statuts acquis avant cette date
'Filtered by steps: only %step% and between %date_from% and %date_to%': 'Filtré par statut: seulement %step%, entre %date_from% et %date_to%'
by_user_scope:
Computation date for referrer: Date à laquelle le référent était actif
Filter by user scope: Filtrer les parcours par service du référent
"Filtered by user main scope: only %scope%": "Filtré par service du référent: uniquement %scope%"
by_referrer:
Computation date for referrer: Date à laquelle le référent était actif
having_temporarily:
@@ -1134,7 +1133,12 @@ export:
Having a person's location: Ayant une localisation auprès d'un usager
Calculation date: Date de la localisation
creator_job:
'Filtered by creator job: only %jobs%': 'Filtré par métier du créateur: seulement %jobs%'
Filter by creator job: Filtrer les parcours par métier du créateur
'Filtered by creator job: only %jobs%': "Filtré par métier du créateur: uniquement %jobs%"
by_user_job:
Filter by user job: Filtrer les parcours par métier du référent
"Filtered by user job: only %job%": "Filtré par métier du référent: uniquement %job%"
work:
start_between_dates:
title: Filtre les actions d'accompagnement dont la date d'ouverture est entre deux dates
@@ -1150,12 +1154,28 @@ export:
keep_null: Conserver les actions dont la date de fin n'est pas indiquée (actions en cours)
keep_null_help: Si coché, les actions dont la date de fin est vide seront prises en compte. Si non coché, elles ne seront pas comptabilisée.
Only where start date is between %startDate% and %endDate%: Seulement les actions dont la date de fin est entre le %startDate% et le %endDate%
by_user_job:
Filter by treating agent job: Filtrer les actions par métier de l'agent traitant
"Filtered by treating agent job: only %jobs%": "Filtré par métier de l'agent traitant: uniquement %jobs%"
Calc date: Date de calcul du métier de l'agent traitant
by_user_scope:
Filter by treating agent scope: Filtrer les actions par service de l'agent traitant
"Filtered by treating agent scope: only %scopes%": "Filtré par service de l'agent traitant: uniquement %scopes%"
Calc date: Date de calcul du service de l'agent traitant
by_treating_agent:
Filter by treating agent: Filtrer les actions par agent traitant
Accepted agents: Agent traitant
Calc date: Date à laquelle l'agent est en situation de désignation sur l'action
calc_date_help: Il s'agit de la date à laquelle l'agent est actif comme agent traitant de l'action, et non la date à la quelle l'agent est désigné comme agent traitant.
"Filtered by treating agent: only %agents%": "Filtré par agent traitant: uniquement %agents%"
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.
@@ -1175,7 +1195,9 @@ export:
origin: Origine du parcours
acpClosingMotive: Motif de fermeture
acpJob: Métier du parcours
acpCreatedBy_id: Créé par (identifiant)
acpCreatedBy: Créé par
acpUpdatedBy_id: Dernière modificaton par (identifiant)
acpUpdatedBy: Dernière modification par
administrativeLocation: Location administrative
step: Etape
@@ -1194,6 +1216,7 @@ export:
socialIssues: Problématiques sociales
requestorPerson: Demandeur (personne)
requestorThirdParty: Demandeur (tiers)
eval:
List of evaluations: Liste des évaluations
Generate a list of evaluations, filtered on different parameters: Génère une liste des évaluations, filtrée sur différents paramètres.
@@ -1223,6 +1246,7 @@ export:
createdBy: Créé par
updatedBy: Modifié par
timeSpent: Temps de rédaction (minutes)
acpw:
List of accompanying period works: Liste des actions
List description: Génère une liste des actions d'accompagnement, filtrée sur différents paramètres.
@@ -1252,6 +1276,7 @@ export:
resultsTitle: Résultats
evaluationsId: Identifiants des évaluations
evaluationsTitle: Évaluations
household:
List household associated with accompanying period title: Liste des ménages impliqués dans un parcours
List description: Génère la liste des ménages, filtrée selon divers paramètres.
@@ -1265,6 +1290,7 @@ export:
compositionNumberOfChildren: Nombre d'enfants dans la composition
compositionComment: Commentaire sur la composition
compositionType: Type de composition
acpaddress_fieldscountry: Pays # addressHelper effect
social_action: