mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
merge upgrade-sf5 branch
This commit is contained in:
@@ -707,19 +707,24 @@ class AccompanyingPeriod implements
|
||||
public function getNextCalendarsForPerson(Person $person, $limit = 5): ReadableCollection
|
||||
{
|
||||
$today = new \DateTimeImmutable('today');
|
||||
$criteria = Criteria::create()
|
||||
->where(Criteria::expr()->gte('startDate', $today))
|
||||
// ->andWhere(Criteria::expr()->memberOf('persons', $person))
|
||||
->orderBy(['startDate' => 'DESC'])
|
||||
->setMaxResults($limit * 2);
|
||||
|
||||
return $this->calendars->matching($criteria)
|
||||
->matching(
|
||||
// due to a bug, filter two times
|
||||
Criteria::create()
|
||||
->where(Criteria::expr()->memberOf('persons', $person))
|
||||
->setMaxResults($limit)
|
||||
);
|
||||
$criteria = Criteria::create();
|
||||
$expr = Criteria::expr();
|
||||
|
||||
$criteria
|
||||
->where(
|
||||
$expr->gte('startDate', $today),
|
||||
)
|
||||
->orderBy(['startDate' => 'ASC']);
|
||||
|
||||
$criteriaByPerson = Criteria::create();
|
||||
$criteriaByPerson
|
||||
->where(
|
||||
$expr->memberOf('persons', $person)
|
||||
)
|
||||
->setMaxResults($limit);
|
||||
|
||||
return $this->calendars->matching($criteria)->matching($criteriaByPerson);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1332,6 +1337,16 @@ class AccompanyingPeriod implements
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUserHistories(): ReadableCollection
|
||||
{
|
||||
return $this->userHistories;
|
||||
}
|
||||
|
||||
public function getCurrentUserHistory(): ?UserHistory
|
||||
{
|
||||
return $this->getUserHistories()->findFirst(fn (int $key, UserHistory $userHistory) => null === $userHistory->getEndDate());
|
||||
}
|
||||
|
||||
private function addStepHistory(AccompanyingPeriodStepHistory $stepHistory, array $context = []): self
|
||||
{
|
||||
if (!$this->stepHistories->contains($stepHistory)) {
|
||||
|
@@ -42,9 +42,10 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
|
||||
/**
|
||||
* @var Collection<AccompanyingPeriodWorkEvaluation>
|
||||
*
|
||||
* @internal /!\ the serialization for write evaluations is handled in `AccompanyingPeriodWorkDenormalizer`
|
||||
* @internal the serialization for write evaluations is handled in `accompanyingperiodworkdenormalizer`
|
||||
* @internal the serialization for context docgen:read is handled in `accompanyingperiodworknormalizer`
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[Serializer\Groups(['read'])]
|
||||
#[ORM\OneToMany(targetEntity: AccompanyingPeriodWorkEvaluation::class, mappedBy: 'accompanyingPeriodWork', cascade: ['remove', 'persist'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['startDate' => \Doctrine\Common\Collections\Criteria::DESC, 'id' => 'DESC'])]
|
||||
private Collection $accompanyingPeriodWorkEvaluations;
|
||||
@@ -291,18 +292,20 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
|
||||
/**
|
||||
* @return ReadableCollection<int, User>
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read', 'read:accompanyingPeriodWork:light', 'accompanying_period_work:edit', 'accompanying_period_work:create'])]
|
||||
#[Serializer\Groups(['accompanying_period_work:edit'])]
|
||||
public function getReferrers(): ReadableCollection
|
||||
{
|
||||
$users = $this->referrersHistory
|
||||
->filter(fn (AccompanyingPeriodWorkReferrerHistory $h) => null === $h->getEndDate())
|
||||
->map(fn (AccompanyingPeriodWorkReferrerHistory $h) => $h->getUser())
|
||||
->getValues()
|
||||
;
|
||||
->getValues();
|
||||
|
||||
return new ArrayCollection(array_values($users));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, AccompanyingPeriodWorkReferrerHistory>
|
||||
*/
|
||||
public function getReferrersHistory(): Collection
|
||||
{
|
||||
return $this->referrersHistory;
|
||||
@@ -470,9 +473,9 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCreatedBy(?User $createdBy): self
|
||||
public function setCreatedBy(?User $user): self
|
||||
{
|
||||
$this->createdBy = $createdBy;
|
||||
$this->createdBy = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -514,14 +517,14 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
|
||||
|
||||
public function setStartDate(\DateTimeInterface $startDate): self
|
||||
{
|
||||
$this->startDate = $startDate;
|
||||
$this->startDate = $startDate instanceof \DateTime ? \DateTimeImmutable::createFromMutable($startDate) : $startDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUpdatedAt(\DateTimeInterface $datetime): TrackUpdateInterface
|
||||
{
|
||||
$this->updatedAt = $datetime;
|
||||
$this->updatedAt = $datetime instanceof \DateTime ? \DateTimeImmutable::createFromMutable($datetime) : $datetime;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@@ -132,6 +132,11 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCreatedBy(): ?User
|
||||
{
|
||||
return $this->getCreator();
|
||||
}
|
||||
|
||||
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
|
||||
{
|
||||
$this->updatedAt = $updatedAt;
|
||||
|
@@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
|
||||
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Export\DataTransformerInterface;
|
||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
||||
use Chill\MainBundle\Repository\UserRepository;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
@@ -21,13 +22,17 @@ use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
final readonly class ReferrerAggregator implements AggregatorInterface
|
||||
final readonly class ReferrerAggregator implements AggregatorInterface, DataTransformerInterface
|
||||
{
|
||||
private const A = 'acp_ref_agg_uhistory';
|
||||
|
||||
private const P = 'acp_ref_agg_date';
|
||||
|
||||
public function __construct(private UserRepository $userRepository, private UserRender $userRender, private RollingDateConverterInterface $rollingDateConverter) {}
|
||||
public function __construct(
|
||||
private UserRepository $userRepository,
|
||||
private UserRender $userRender,
|
||||
private RollingDateConverterInterface $rollingDateConverter
|
||||
) {}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
@@ -44,18 +49,16 @@ final readonly class ReferrerAggregator implements AggregatorInterface
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull(self::A),
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->lte(self::A.'.startDate', ':'.self::P),
|
||||
$qb->expr()->lt(self::A.'.startDate', ':'.self::P.'_end_date'),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull(self::A.'.endDate'),
|
||||
$qb->expr()->gt(self::A.'.endDate', ':'.self::P)
|
||||
$qb->expr()->gte(self::A.'.endDate', ':'.self::P.'_start_date')
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
->setParameter(
|
||||
self::P,
|
||||
$this->rollingDateConverter->convert($data['date_calc'])
|
||||
);
|
||||
->setParameter(':'.self::P.'_end_date', $this->rollingDateConverter->convert($data['end_date']))
|
||||
->setParameter(':'.self::P.'_start_date', $this->rollingDateConverter->convert($data['end_date']));
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
@@ -66,15 +69,37 @@ final readonly class ReferrerAggregator implements AggregatorInterface
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder
|
||||
->add('date_calc', PickRollingDateType::class, [
|
||||
'label' => 'export.aggregator.course.by_referrer.Computation date for referrer',
|
||||
->add('start_date', PickRollingDateType::class, [
|
||||
'label' => 'export.aggregator.course.by_referrer.Referrer after',
|
||||
'required' => true,
|
||||
])
|
||||
->add('end_date', PickRollingDateType::class, [
|
||||
'label' => 'export.aggregator.course.by_referrer.Until',
|
||||
'required' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return ['date_calc' => new RollingDate(RollingDate::T_TODAY)];
|
||||
return [
|
||||
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
||||
'end_date' => new RollingDate(RollingDate::T_TODAY),
|
||||
];
|
||||
}
|
||||
|
||||
public function transformData(?array $before): array
|
||||
{
|
||||
$default = $this->getFormDefaultData();
|
||||
$data = [];
|
||||
|
||||
if (null === $before) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
$data['start_date'] = $before['date_calc'] ?? $before['start_date'] ?? $default['start_date'];
|
||||
$data['end_date'] = $before['date_calc'] ?? $before['end_date'] ?? $default['end_date'];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data)
|
||||
|
@@ -13,20 +13,25 @@ namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
|
||||
|
||||
use Chill\MainBundle\Entity\User\UserScopeHistory;
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Export\DataTransformerInterface;
|
||||
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 Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
readonly class ReferrerScopeAggregator implements AggregatorInterface
|
||||
readonly class ReferrerScopeAggregator implements AggregatorInterface, DataTransformerInterface
|
||||
{
|
||||
private const PREFIX = 'acp_agg_referrer_scope';
|
||||
|
||||
public function __construct(
|
||||
private ScopeRepositoryInterface $scopeRepository,
|
||||
private TranslatableStringHelperInterface $translatableStringHelper,
|
||||
private RollingDateConverterInterface $rollingDateConverter,
|
||||
) {}
|
||||
|
||||
public function addRole(): ?string
|
||||
@@ -46,11 +51,16 @@ readonly class ReferrerScopeAggregator implements AggregatorInterface
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->eq("{$p}_userHistory.accompanyingPeriod", 'acp.id'),
|
||||
$qb->expr()->andX(
|
||||
// check that the user is referrer when the accompanying period is opened
|
||||
$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")
|
||||
)
|
||||
),
|
||||
$qb->expr()->andX(
|
||||
"{$p}_userHistory.startDate <= :{$p}_endDate",
|
||||
"COALESCE({$p}_userHistory.endDate, CURRENT_TIMESTAMP()) > :{$p}_startDate"
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -66,9 +76,15 @@ readonly class ReferrerScopeAggregator implements AggregatorInterface
|
||||
$qb->expr()->isNull("{$p}_scopeHistory.endDate"),
|
||||
$qb->expr()->gt("{$p}_scopeHistory.endDate", "{$p}_userHistory.startDate")
|
||||
)
|
||||
),
|
||||
$qb->expr()->andX(
|
||||
"{$p}_scopeHistory.startDate <= :{$p}_endDate",
|
||||
"COALESCE({$p}_scopeHistory.endDate, CURRENT_TIMESTAMP()) > :{$p}_startDate"
|
||||
)
|
||||
)
|
||||
)
|
||||
->setParameter("{$p}_startDate", $this->rollingDateConverter->convert($data['start_date']))
|
||||
->setParameter("{$p}_endDate", $this->rollingDateConverter->convert($data['end_date']))
|
||||
->addSelect("IDENTITY({$p}_scopeHistory.scope) AS {$p}_select")
|
||||
->addGroupBy("{$p}_select");
|
||||
}
|
||||
@@ -78,11 +94,36 @@ readonly class ReferrerScopeAggregator implements AggregatorInterface
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder) {}
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder
|
||||
->add('start_date', PickRollingDateType::class, [
|
||||
'label' => 'export.aggregator.course.by_referrer_scope.Referrer and scope after',
|
||||
'required' => true,
|
||||
])
|
||||
->add('end_date', PickRollingDateType::class, [
|
||||
'label' => 'export.aggregator.course.by_referrer_scope.Until',
|
||||
'required' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
return [
|
||||
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
||||
'end_date' => new RollingDate(RollingDate::T_TODAY),
|
||||
];
|
||||
}
|
||||
|
||||
public function transformData(?array $before): array
|
||||
{
|
||||
$default = $this->getFormDefaultData();
|
||||
$data = [];
|
||||
|
||||
$data['start_date'] = $before['start_date'] ?? new RollingDate(RollingDate::T_FIXED_DATE, new \DateTimeImmutable('1970-01-01'));
|
||||
$data['end_date'] = $before['end_date'] ?? $default['end_date'];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data)
|
||||
|
@@ -13,20 +13,25 @@ namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
|
||||
|
||||
use Chill\MainBundle\Entity\User\UserJobHistory;
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Export\DataTransformerInterface;
|
||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
||||
use Chill\MainBundle\Repository\UserJobRepository;
|
||||
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\Component\Form\FormBuilderInterface;
|
||||
|
||||
final readonly class UserJobAggregator implements AggregatorInterface
|
||||
final readonly class UserJobAggregator implements AggregatorInterface, DataTransformerInterface
|
||||
{
|
||||
private const PREFIX = 'acp_agg_user_job';
|
||||
|
||||
public function __construct(
|
||||
private UserJobRepository $jobRepository,
|
||||
private TranslatableStringHelper $translatableStringHelper
|
||||
private TranslatableStringHelper $translatableStringHelper,
|
||||
private RollingDateConverterInterface $rollingDateConverter,
|
||||
) {}
|
||||
|
||||
public function addRole(): ?string
|
||||
@@ -51,6 +56,10 @@ final readonly class UserJobAggregator implements AggregatorInterface
|
||||
$qb->expr()->isNull("{$p}_userHistory.endDate"),
|
||||
$qb->expr()->lt('COALESCE(acp.closingDate, CURRENT_TIMESTAMP())', "{$p}_userHistory.endDate")
|
||||
)
|
||||
),
|
||||
$qb->expr()->andX(
|
||||
"{$p}_userHistory.startDate <= :{$p}_endDate",
|
||||
"COALESCE({$p}_userHistory.endDate, CURRENT_TIMESTAMP()) > :{$p}_startDate"
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -66,9 +75,15 @@ final readonly class UserJobAggregator implements AggregatorInterface
|
||||
$qb->expr()->isNull("{$p}_jobHistory.endDate"),
|
||||
$qb->expr()->gt("{$p}_jobHistory.endDate", "{$p}_userHistory.startDate")
|
||||
)
|
||||
),
|
||||
$qb->expr()->andX(
|
||||
"{$p}_jobHistory.startDate <= :{$p}_endDate",
|
||||
"COALESCE({$p}_jobHistory.endDate, CURRENT_TIMESTAMP()) > :{$p}_startDate"
|
||||
)
|
||||
)
|
||||
)
|
||||
->setParameter("{$p}_startDate", $this->rollingDateConverter->convert($data['start_date']))
|
||||
->setParameter("{$p}_endDate", $this->rollingDateConverter->convert($data['end_date']))
|
||||
->addSelect("IDENTITY({$p}_jobHistory.job) AS {$p}_select")
|
||||
->addGroupBy("{$p}_select");
|
||||
}
|
||||
@@ -78,11 +93,36 @@ final readonly class UserJobAggregator implements AggregatorInterface
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder) {}
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder
|
||||
->add('start_date', PickRollingDateType::class, [
|
||||
'label' => 'export.aggregator.course.by_referrer_job.Referrer and job after',
|
||||
'required' => true,
|
||||
])
|
||||
->add('end_date', PickRollingDateType::class, [
|
||||
'label' => 'export.aggregator.course.by_referrer_job.Until',
|
||||
'required' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
return [
|
||||
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
||||
'end_date' => new RollingDate(RollingDate::T_TODAY),
|
||||
];
|
||||
}
|
||||
|
||||
public function transformData(?array $before): array
|
||||
{
|
||||
$default = $this->getFormDefaultData();
|
||||
$data = [];
|
||||
|
||||
$data['start_date'] = $before['start_date'] ?? new RollingDate(RollingDate::T_FIXED_DATE, new \DateTimeImmutable('1970-01-01'));
|
||||
$data['end_date'] = $before['end_date'] ?? $default['end_date'];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data)
|
||||
|
@@ -54,7 +54,6 @@ final readonly class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeri
|
||||
'socialAction',
|
||||
'socialIssue',
|
||||
'acp_id',
|
||||
'acp_user',
|
||||
'startDate',
|
||||
'endDate',
|
||||
'goalsId',
|
||||
@@ -70,8 +69,8 @@ final readonly class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeri
|
||||
'personsName',
|
||||
'thirdParties',
|
||||
'handlingThierParty',
|
||||
// 'acpwReferrers',
|
||||
'referrers',
|
||||
'acpwReferrers',
|
||||
'referrer',
|
||||
'createdAt',
|
||||
'createdBy',
|
||||
'updatedAt',
|
||||
@@ -156,9 +155,9 @@ final readonly class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeri
|
||||
[]
|
||||
);
|
||||
},
|
||||
'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),
|
||||
'createdBy', 'updatedBy' => $this->userHelper->getLabel($key, $values, 'export.list.acpw.'.$key),
|
||||
'referrer' => $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),
|
||||
@@ -272,8 +271,7 @@ final readonly class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeri
|
||||
|
||||
// join acp
|
||||
$qb
|
||||
->addSelect('acp.id AS acp_id')
|
||||
->addSelect('IDENTITY(acp.user) AS acp_user');
|
||||
->addSelect('acp.id AS acp_id');
|
||||
|
||||
// persons
|
||||
$qb
|
||||
@@ -282,21 +280,18 @@ final readonly class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeri
|
||||
->addSelect('(SELECT AGGREGATE(person1_acpw_member.id) FROM '.Person::class.' person1_acpw_member '
|
||||
.'WHERE person1_acpw_member MEMBER OF acpw.persons) AS personsName');
|
||||
|
||||
// referrers => at date XXXX
|
||||
$qb
|
||||
->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
|
||||
// referrer => at date XXXX
|
||||
$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'
|
||||
);
|
||||
*/
|
||||
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 referrer');
|
||||
|
||||
// acpwReferrer at date XXX
|
||||
$qb->addSelect('(SELECT AGGREGATE(IDENTITY(acpwrh.user)) FROM '.AccompanyingPeriodWorkReferrerHistory::class.' acpwrh
|
||||
WHERE acpwrh.accompanyingPeriodWork = acpw
|
||||
AND acpwrh.startDate <= :calcDate AND (acpwrh.endDate IS NULL or acpwrh.endDate > :calcDate)
|
||||
) AS acpwReferrers');
|
||||
$qb->setParameter('calcDate', $calcDate);
|
||||
|
||||
// thirdparties
|
||||
$qb
|
||||
|
@@ -54,7 +54,6 @@ final readonly class ListAccompanyingPeriodWorkAssociatePersonOnWork implements
|
||||
'socialAction',
|
||||
'socialIssue',
|
||||
'acp_id',
|
||||
'acp_user',
|
||||
'startDate',
|
||||
'endDate',
|
||||
'goalsId',
|
||||
@@ -70,8 +69,8 @@ final readonly class ListAccompanyingPeriodWorkAssociatePersonOnWork implements
|
||||
'personsName',
|
||||
'thirdParties',
|
||||
'handlingThierParty',
|
||||
// 'acpwReferrers',
|
||||
'referrers',
|
||||
'acpwReferrers',
|
||||
'referrer',
|
||||
'createdAt',
|
||||
'createdBy',
|
||||
'updatedAt',
|
||||
@@ -156,9 +155,9 @@ final readonly class ListAccompanyingPeriodWorkAssociatePersonOnWork implements
|
||||
[]
|
||||
);
|
||||
},
|
||||
'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),
|
||||
'createdBy', 'updatedBy' => $this->userHelper->getLabel($key, $values, 'export.list.acpw.'.$key),
|
||||
'referrer' => $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),
|
||||
@@ -267,8 +266,7 @@ final readonly class ListAccompanyingPeriodWorkAssociatePersonOnWork implements
|
||||
|
||||
// join acp
|
||||
$qb
|
||||
->addSelect('acp.id AS acp_id')
|
||||
->addSelect('IDENTITY(acp.user) AS acp_user');
|
||||
->addSelect('acp.id AS acp_id');
|
||||
|
||||
// persons
|
||||
$qb
|
||||
@@ -277,21 +275,17 @@ final readonly class ListAccompanyingPeriodWorkAssociatePersonOnWork implements
|
||||
->addSelect('(SELECT AGGREGATE(person1_acpw_member.id) FROM '.Person::class.' person1_acpw_member '
|
||||
.'WHERE person1_acpw_member MEMBER OF acpw.persons) AS personsName');
|
||||
|
||||
// referrers => at date XXXX
|
||||
// referrer => at date XXXX
|
||||
$qb
|
||||
->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');
|
||||
'WHERE history.accompanyingPeriod = acp AND history.startDate <= :calcDate AND (history.endDate IS NULL OR history.endDate > :calcDate)) AS referrer');
|
||||
|
||||
/*
|
||||
// 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'
|
||||
);
|
||||
*/
|
||||
$qb->addSelect('(SELECT AGGREGATE(IDENTITY(acpwrh.user)) FROM '.AccompanyingPeriodWorkReferrerHistory::class.' acpwrh
|
||||
WHERE acpwrh.accompanyingPeriodWork = acpw
|
||||
AND acpwrh.startDate <= :calcDate AND (acpwrh.endDate IS NULL or acpwrh.endDate > :calcDate)
|
||||
) AS acpwReferrers');
|
||||
$qb->setParameter('calcDate', $calcDate);
|
||||
|
||||
// thirdparties
|
||||
$qb
|
||||
|
@@ -13,23 +13,28 @@ namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters;
|
||||
|
||||
use Chill\MainBundle\Entity\User\UserJobHistory;
|
||||
use Chill\MainBundle\Entity\UserJob;
|
||||
use Chill\MainBundle\Export\DataTransformerInterface;
|
||||
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\Entity\AccompanyingPeriod\UserHistory;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class UserJobFilter implements FilterInterface
|
||||
final readonly class UserJobFilter implements FilterInterface, DataTransformerInterface
|
||||
{
|
||||
private const PREFIX = 'acp_filter_user_job';
|
||||
|
||||
public function __construct(
|
||||
private readonly TranslatableStringHelper $translatableStringHelper,
|
||||
private readonly UserJobRepositoryInterface $userJobRepository,
|
||||
private TranslatableStringHelper $translatableStringHelper,
|
||||
private UserJobRepositoryInterface $userJobRepository,
|
||||
private RollingDateConverterInterface $rollingDateConverter,
|
||||
) {}
|
||||
|
||||
public function addRole(): ?string
|
||||
@@ -41,42 +46,31 @@ class UserJobFilter implements FilterInterface
|
||||
{
|
||||
$p = self::PREFIX;
|
||||
|
||||
$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")
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
->andWhere($qb->expr()->in("{$p}_jobHistory.job", ":{$p}_job"))
|
||||
->setParameter(
|
||||
"{$p}_job",
|
||||
$data['jobs'],
|
||||
$qb->andWhere(
|
||||
$qb->expr()->exists(
|
||||
sprintf(
|
||||
<<<DQL
|
||||
SELECT 1
|
||||
FROM %s {$p}_userHistory
|
||||
JOIN %s {$p}_userJobHistory
|
||||
WITH
|
||||
{$p}_userHistory.user = {$p}_userJobHistory.user
|
||||
AND OVERLAPSI({$p}_userHistory.startDate, {$p}_userHistory.endDate),({$p}_userJobHistory.startDate, {$p}_userJobHistory.endDate) = TRUE
|
||||
WHERE {$p}_userHistory.accompanyingPeriod = acp
|
||||
AND {$p}_userHistory.startDate <= :{$p}_endDate
|
||||
AND ({$p}_userHistory.endDate IS NULL OR {$p}_userHistory.endDate > :{$p}_startDate)
|
||||
AND {$p}_userJobHistory.startDate <= :{$p}_endDate
|
||||
AND ({$p}_userJobHistory.endDate IS NULL OR {$p}_userJobHistory.endDate > :{$p}_startDate)
|
||||
AND {$p}_userJobHistory.job IN (:{$p}_jobs)
|
||||
DQL,
|
||||
UserHistory::class,
|
||||
UserJobHistory::class,
|
||||
),
|
||||
)
|
||||
)
|
||||
->setParameter("{$p}_jobs", $data['jobs'])
|
||||
->setParameter("{$p}_startDate", $this->rollingDateConverter->convert($data['start_date']))
|
||||
->setParameter("{$p}_endDate", $this->rollingDateConverter->convert($data['end_date']))
|
||||
;
|
||||
}
|
||||
|
||||
@@ -95,20 +89,29 @@ class UserJobFilter implements FilterInterface
|
||||
'expanded' => true,
|
||||
'choice_label' => fn (UserJob $job) => $this->translatableStringHelper->localize($job->getLabel()),
|
||||
'label' => 'Job',
|
||||
]);
|
||||
])
|
||||
->add('start_date', PickRollingDateType::class, [
|
||||
'label' => 'export.filter.course.by_user_job.Start from',
|
||||
])
|
||||
->add('end_date', PickRollingDateType::class, [
|
||||
'label' => 'export.filter.course.by_user_job.Until',
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function describeAction($data, $format = 'string')
|
||||
{
|
||||
return [
|
||||
'export.filter.course.by_user_job.Filtered by user job: only %job%', [
|
||||
'%job%' => implode(
|
||||
'exports.filter.course.by_user_job.Filtered by user job: only job', [
|
||||
'job' => implode(
|
||||
', ',
|
||||
array_map(
|
||||
fn (UserJob $job) => $this->translatableStringHelper->localize($job->getLabel()),
|
||||
$data['jobs'] instanceof Collection ? $data['jobs']->toArray() : $data['jobs']
|
||||
)
|
||||
),
|
||||
'startDate' => $this->rollingDateConverter->convert($data['start_date']),
|
||||
'endDate' => $this->rollingDateConverter->convert($data['end_date']),
|
||||
],
|
||||
];
|
||||
}
|
||||
@@ -117,9 +120,30 @@ class UserJobFilter implements FilterInterface
|
||||
{
|
||||
return [
|
||||
'jobs' => [],
|
||||
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
||||
'end_date' => new RollingDate(RollingDate::T_TODAY),
|
||||
];
|
||||
}
|
||||
|
||||
public function transformData(?array $before): array
|
||||
{
|
||||
$default = $this->getFormDefaultData();
|
||||
|
||||
if (null === $before) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
if (!array_key_exists('start_date', $before) || null === $before['start_date']) {
|
||||
$before['start_date'] = $default['start_date'];
|
||||
}
|
||||
|
||||
if (!array_key_exists('end_date', $before) || null === $before['end_date']) {
|
||||
$before['end_date'] = $default['end_date'];
|
||||
}
|
||||
|
||||
return $before;
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'export.filter.course.by_user_job.Filter by user job';
|
||||
|
@@ -13,23 +13,28 @@ namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters;
|
||||
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Entity\User\UserScopeHistory;
|
||||
use Chill\MainBundle\Export\DataTransformerInterface;
|
||||
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\Entity\AccompanyingPeriod\UserHistory;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class UserScopeFilter implements FilterInterface
|
||||
final readonly class UserScopeFilter implements FilterInterface, DataTransformerInterface
|
||||
{
|
||||
private const PREFIX = 'acp_filter_main_scope';
|
||||
|
||||
public function __construct(
|
||||
private readonly ScopeRepositoryInterface $scopeRepository,
|
||||
private readonly TranslatableStringHelper $translatableStringHelper,
|
||||
private ScopeRepositoryInterface $scopeRepository,
|
||||
private TranslatableStringHelper $translatableStringHelper,
|
||||
private RollingDateConverterInterface $rollingDateConverter,
|
||||
) {}
|
||||
|
||||
public function addRole(): ?string
|
||||
@@ -37,47 +42,35 @@ class UserScopeFilter implements FilterInterface
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
public function alterQuery(QueryBuilder $qb, $data): void
|
||||
{
|
||||
$p = self::PREFIX;
|
||||
|
||||
$qb
|
||||
->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")
|
||||
)
|
||||
)
|
||||
)
|
||||
$qb->andWhere(
|
||||
$qb->expr()->exists(
|
||||
sprintf(
|
||||
<<<DQL
|
||||
SELECT 1
|
||||
FROM %s {$p}_userHistory
|
||||
JOIN %s {$p}_userScopeHistory
|
||||
WITH
|
||||
{$p}_userHistory.user = {$p}_userScopeHistory.user
|
||||
AND OVERLAPSI({$p}_userHistory.startDate, {$p}_userHistory.endDate),({$p}_userScopeHistory.startDate, {$p}_userScopeHistory.endDate) = TRUE
|
||||
WHERE {$p}_userHistory.accompanyingPeriod = acp
|
||||
AND {$p}_userHistory.startDate <= :{$p}_endDate
|
||||
AND ({$p}_userHistory.endDate IS NULL OR {$p}_userHistory.endDate > :{$p}_startDate)
|
||||
AND {$p}_userScopeHistory.startDate <= :{$p}_endDate
|
||||
AND ({$p}_userScopeHistory.endDate IS NULL OR {$p}_userScopeHistory.endDate > :{$p}_startDate)
|
||||
AND {$p}_userScopeHistory.scope IN (:{$p}_scopes)
|
||||
DQL,
|
||||
UserHistory::class,
|
||||
UserScopeHistory::class,
|
||||
),
|
||||
)
|
||||
->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(
|
||||
"{$p}_scopes",
|
||||
$data['scopes'],
|
||||
)
|
||||
;
|
||||
)
|
||||
->setParameter("{$p}_scopes", $data['scopes'])
|
||||
->setParameter("{$p}_startDate", $this->rollingDateConverter->convert($data['start_date']))
|
||||
->setParameter("{$p}_endDate", $this->rollingDateConverter->convert($data['end_date']));
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
@@ -94,20 +87,28 @@ class UserScopeFilter implements FilterInterface
|
||||
'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize($s->getName()),
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
])
|
||||
->add('start_date', PickRollingDateType::class, [
|
||||
'label' => 'export.filter.course.by_user_scope.Start from',
|
||||
])
|
||||
->add('end_date', PickRollingDateType::class, [
|
||||
'label' => 'export.filter.course.by_user_scope.Until',
|
||||
]);
|
||||
}
|
||||
|
||||
public function describeAction($data, $format = 'string')
|
||||
{
|
||||
return [
|
||||
'export.filter.course.by_user_scope.Filtered by user main scope: only %scope%', [
|
||||
'%scope%' => implode(
|
||||
'exports.filter.course.by_user_scope.Filtered by user main scope: only scopes', [
|
||||
'scopes' => implode(
|
||||
', ',
|
||||
array_map(
|
||||
fn (Scope $s) => $this->translatableStringHelper->localize($s->getName()),
|
||||
$data['scopes'] instanceof Collection ? $data['scopes']->toArray() : $data['scopes']
|
||||
)
|
||||
),
|
||||
'startDate' => $this->rollingDateConverter->convert($data['start_date']),
|
||||
'endDate' => $this->rollingDateConverter->convert($data['end_date']),
|
||||
],
|
||||
];
|
||||
}
|
||||
@@ -116,9 +117,30 @@ class UserScopeFilter implements FilterInterface
|
||||
{
|
||||
return [
|
||||
'scopes' => [],
|
||||
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
||||
'end_date' => new RollingDate(RollingDate::T_TODAY),
|
||||
];
|
||||
}
|
||||
|
||||
public function transformData(?array $before): array
|
||||
{
|
||||
$default = $this->getFormDefaultData();
|
||||
|
||||
if (null === $before) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
if (!array_key_exists('start_date', $before) || null === $before['start_date']) {
|
||||
$before['start_date'] = $default['start_date'];
|
||||
}
|
||||
|
||||
if (!array_key_exists('end_date', $before) || null === $before['end_date']) {
|
||||
$before['end_date'] = $default['end_date'];
|
||||
}
|
||||
|
||||
return $before;
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'export.filter.course.by_user_scope.Filter by user scope';
|
||||
|
49
src/Bundle/ChillPersonBundle/Menu/PersonQuickMenuBuilder.php
Normal file
49
src/Bundle/ChillPersonBundle/Menu/PersonQuickMenuBuilder.php
Normal 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\Menu;
|
||||
|
||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||
use Knp\Menu\MenuItem;
|
||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||
|
||||
final readonly class PersonQuickMenuBuilder implements LocalMenuBuilderInterface
|
||||
{
|
||||
public function __construct(private AuthorizationCheckerInterface $authorizationChecker) {}
|
||||
|
||||
public static function getMenuIds(): array
|
||||
{
|
||||
return ['person_quick_menu'];
|
||||
}
|
||||
|
||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||
{
|
||||
/** @var \Chill\PersonBundle\Entity\Person $person */
|
||||
$person = $parameters['person'];
|
||||
|
||||
if ($this->authorizationChecker->isGranted(AccompanyingPeriodVoter::CREATE, $person)) {
|
||||
$menu->addChild(
|
||||
'Create Accompanying Course',
|
||||
[
|
||||
'route' => 'chill_person_accompanying_course_new',
|
||||
'routeParameters' => [
|
||||
'person_id' => [$person->getId()],
|
||||
],
|
||||
]
|
||||
)
|
||||
->setExtras([
|
||||
'order' => 10,
|
||||
'icon' => 'plus',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
@@ -30,7 +30,7 @@ div.list-with-period {
|
||||
|
||||
// override wrap-list
|
||||
div.wrap-list.periods-list {
|
||||
padding-right: 1rem;
|
||||
padding-right: 0;
|
||||
div.wl-row {
|
||||
flex-wrap: nowrap;
|
||||
div.wl-col {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<a class="btn" :class="getClassButton" :title="$t(buttonTitle)" @click="openModal">
|
||||
<span v-if="displayTextButton">{{ $t(buttonTitle) }}</span>
|
||||
<a class="btn" :class="getClassButton" :title="$t(buttonTitle || '')" @click="openModal">
|
||||
<span v-if="displayTextButton">{{ $t(buttonTitle || '') }}</span>
|
||||
</a>
|
||||
|
||||
<teleport to="body">
|
||||
|
@@ -7,10 +7,8 @@
|
||||
{% endif %}
|
||||
<a id="comment-{{ comment.id }}" href="{{ '#comment-' ~ comment.id }}" class="fa fa-pencil-square-o fa-fw"></a>
|
||||
|
||||
{% set creator = comment.creator is defined ? comment.creator : comment.createdBy %}
|
||||
{{ 'by'|trans }}<b>{{ creator }}</b>
|
||||
|
||||
{{ ', ' ~ 'on'|trans ~ ' ' ~ comment.createdAt|format_date('long') }}<br>
|
||||
{{ 'by'|trans }}
|
||||
<span class="badge-user">{{ comment.createdBy|chill_entity_render_box({'at_date': comment.createdAt }) }}</span>{{ ', ' ~ 'on'|trans ~ ' ' ~ comment.createdAt|format_date('long') }}<br>
|
||||
<i>{{ 'Last updated on'|trans ~ ' ' ~ comment.updatedAt|format_datetime('long', 'short') }}</i>
|
||||
</div>
|
||||
<ul class="record_actions">
|
||||
|
@@ -99,7 +99,7 @@
|
||||
<div class="metadata">
|
||||
{{ 'Last updated by'| trans }}
|
||||
<span class="user">
|
||||
{{ accompanyingCourse.pinnedComment.updatedBy|chill_entity_render_box }}
|
||||
{{ accompanyingCourse.pinnedComment.updatedBy|chill_entity_render_box({'at_date': accompanyingCourse.pinnedComment.updatedAt}) }}
|
||||
</span>
|
||||
{{ 'on'|trans ~ ' ' }}
|
||||
<span class="date">
|
||||
|
@@ -83,9 +83,9 @@
|
||||
</div>
|
||||
<div class="wl-col list">
|
||||
{%- if w.referrers|length > 0 -%}
|
||||
{% for u in w.referrers %}
|
||||
{% for r in w.referrersHistory %}
|
||||
<span class="wl-item">
|
||||
<span class="badge-user">{{ u|chill_entity_render_box }}</span>
|
||||
<span class="badge-user">{{ r.user|chill_entity_render_box({'at_date': r.startDate}) }}</span>
|
||||
{% if not loop.last %}, {% endif %}
|
||||
</span>
|
||||
{% endfor %}
|
||||
|
@@ -33,8 +33,8 @@
|
||||
{% if w.referrers %}
|
||||
<li>
|
||||
<span class="item-key">{{ 'Referrers'|trans ~ ' : ' }}</span>
|
||||
{% for u in w.referrers %}
|
||||
<span class="badge-user">{{ u|chill_entity_render_box }}</span>
|
||||
{% for rh in w.referrersHistory %}
|
||||
<span class="badge-user">{{ rh.user|chill_entity_render_box({'at_date': rh.startDate}) }}</span>
|
||||
{% endfor %}
|
||||
{% if w.referrers|length == 0 %}
|
||||
<span class="chill-no-data-statement">{{ 'Not given'|trans }}</span>
|
||||
|
@@ -89,7 +89,7 @@
|
||||
<li>
|
||||
{% if evaluation.createdBy is not null %}
|
||||
<span class="item-key">créé par</span>
|
||||
<b>{{ evaluation.createdBy.username }}</b>
|
||||
<b>{{ evaluation.createdBy|chill_entity_render_string({'at_date': evaluation.createdAt}) }}</b>
|
||||
{% endif %}
|
||||
{% if evaluation.createdAt is not null %}
|
||||
<span class="item-key">{{ 'le'|trans }}</span>
|
||||
|
@@ -13,7 +13,7 @@
|
||||
{{ 'Last updated by'|trans }}
|
||||
{% endif %}
|
||||
<span class="user">
|
||||
{{ entity.updatedBy|chill_entity_render_box }}
|
||||
{{ entity.updatedBy|chill_entity_render_box({'at_date': entity.updatedAt }) }}
|
||||
</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
@@ -34,8 +34,8 @@
|
||||
{{ 'Created by'|trans }}
|
||||
{% endif %}
|
||||
<span class="user">
|
||||
{{ entity.createdBy|chill_entity_render_string }}
|
||||
{{ entity.createdBy|chill_entity_render_string({'at_date': entity.createdAt}) }}
|
||||
</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endmacro %}
|
||||
{% endmacro %}
|
||||
|
@@ -1,13 +1,19 @@
|
||||
{% macro button_person_before(person) %}
|
||||
{{ chill_menu('person_quick_menu', {
|
||||
'layout': '@ChillMain/Menu/quick_menu.html.twig',
|
||||
'args' : { 'person': person }
|
||||
}) }}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro button_person_after(person) %}
|
||||
{% set household = person.getCurrentHousehold %}
|
||||
{% if household is not null and is_granted('CHILL_PERSON_HOUSEHOLD_SEE', household) %}
|
||||
<li>
|
||||
<a href="{{ path('chill_person_household_summary', { 'household_id': household.id }) }}" class="btn btn-sm btn-chill-beige"><i class="fa fa-home"></i></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_CREATE', person) %}
|
||||
<li>
|
||||
<a href="{{ path('chill_person_accompanying_course_new', { 'person_id': [ person.id ]}) }}" class="btn btn-sm btn-create change-icon" title="{{ 'Create an accompanying period'|trans }}"><i class="fa fa-random"></i></a>
|
||||
<a href="{{ path('chill_person_household_summary', { 'household_id': household.id }) }}"
|
||||
class="btn btn-sm btn-chill-beige"
|
||||
title="{{ 'Show household'|trans }}"
|
||||
><i class="fa fa-home"></i>
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
@@ -165,7 +171,24 @@
|
||||
<h3>{{ 'chill_calendar.Next calendars'|trans }}</h3>
|
||||
</div>
|
||||
<div class="wl-col list">
|
||||
{% for c in calendars %}<span>{{ c.startDate|format_datetime('long', 'short') }}</span>{% if not loop.last %}, {% endif %}{% endfor %}
|
||||
<div class="calendar-list">
|
||||
<ul class="calendar-list">
|
||||
{% for c in calendars %}
|
||||
<li>
|
||||
{% if is_granted('CHILL_CALENDAR_CALENDAR_EDIT', c) %}
|
||||
<a href="{{ chill_path_add_return_path('chill_calendar_calendar_edit', {id: c.id}) }}">
|
||||
<span class="badge bg-secondary">{{ c.startDate|format_datetime('long', 'short') }}</span>
|
||||
</a>
|
||||
{% else %}
|
||||
<span class="badge bg-secondary">{{ c.startDate|format_datetime('long', 'short') }}</span>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% if is_granted('CHILL_CALENDAR_CALENDAR_SEE', acp) %}
|
||||
<a href="{{ chill_path_add_return_path('chill_calendar_calendar_list_by_period', {'id': acp.id}) }}" class="calendar-list__global"><i class="fa fa-list"></i></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -184,13 +207,20 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<ul class="record_actions record_actions_column">
|
||||
<ul class="record_actions">
|
||||
{{ chill_menu('accompanying_course_quick_menu', {
|
||||
'layout': '@ChillMain/Menu/quick_menu.html.twig',
|
||||
'args' : { 'accompanying-course': acp }
|
||||
}) }}
|
||||
|
||||
<li>
|
||||
<a href="{{ path('chill_person_accompanying_course_index', { 'accompanying_period_id': acp.id }) }}"
|
||||
class="btn btn-sm btn-outline-primary" title="{{ 'See accompanying period'|trans }}">
|
||||
<i class="fa fa-random fa-fw"></i>
|
||||
class="btn btn-sm btn-primary"
|
||||
title="{{ 'See accompanying period'|trans }}"
|
||||
><i class="fa fa-random fa-fw"></i>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -247,7 +277,7 @@
|
||||
'addAltNames': true,
|
||||
'addCenter': true,
|
||||
'address_multiline': false,
|
||||
'customButtons': { 'after': _self.button_person_after(person) }
|
||||
'customButtons': { 'after': _self.button_person_after(person), 'before': _self.button_person_before((person)) }
|
||||
}) }}
|
||||
|
||||
{#- 'acps' is for AcCompanyingPeriodS #}
|
||||
|
@@ -296,7 +296,7 @@ This view should receive those arguments:
|
||||
<div class="created-updated">
|
||||
{% if person.createdBy %}
|
||||
<div class="createdBy">
|
||||
{{ 'Created by'|trans}}: <b>{{ person.createdBy|chill_entity_render_box }}</b>,<br>
|
||||
{{ 'Created by'|trans}}: <b>{{ person.createdBy|chill_entity_render_box({'at_date': person.createdAt}) }}</b>,<br>
|
||||
{{ 'on'|trans ~ person.createdAt|format_datetime('long', 'short') }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
@@ -64,7 +64,7 @@
|
||||
<li>
|
||||
{% if evaluation.createdBy is not null %}
|
||||
<span class="item-key">créé par</span>
|
||||
<b>{{ evaluation.createdBy.username }}</b>
|
||||
<b>{{ evaluation.createdBy|chill_entity_render_string({'at_date': evaluation.createdAt}) }}</b>
|
||||
{% endif %}
|
||||
{% if evaluation.createdAt is not null %}
|
||||
<span class="item-key">{{ 'le'|trans }}</span>
|
||||
|
@@ -92,7 +92,7 @@
|
||||
<li>
|
||||
{% if evaluation.createdBy is not null %}
|
||||
<span class="item-key">créé par</span>
|
||||
<b>{{ evaluation.createdBy.username }}</b>
|
||||
<b>{{ evaluation.createdBy|chill_entity_render_string({'at_date': evaluation.createdAt}) }}</b>
|
||||
{% endif %}
|
||||
{% if evaluation.createdAt is not null %}
|
||||
<span class="item-key">{{ 'le'|trans }}</span>
|
||||
|
@@ -17,6 +17,7 @@ use Chill\MainBundle\Entity\Location;
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Security\Resolver\ScopeResolverDispatcher;
|
||||
use Chill\MainBundle\Serializer\Normalizer\UserNormalizer;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
|
||||
@@ -81,6 +82,7 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
|
||||
{
|
||||
if ($period instanceof AccompanyingPeriod) {
|
||||
$scopes = $this->scopeResolverDispatcher->isConcerned($period) ? $this->scopeResolverDispatcher->resolveScope($period) : [];
|
||||
$userHistory = $period->getCurrentUserHistory();
|
||||
|
||||
if (!\is_array($scopes)) {
|
||||
$scopes = [$scopes];
|
||||
@@ -101,7 +103,7 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
|
||||
'closingMotive' => $this->normalizer->normalize($period->getClosingMotive(), $format, array_merge($context, ['docgen:expects' => AccompanyingPeriod\ClosingMotive::class])),
|
||||
'confidential' => $period->isConfidential(),
|
||||
'createdAt' => $this->normalizer->normalize($period->getCreatedAt(), $format, $dateContext),
|
||||
'createdBy' => $this->normalizer->normalize($period->getCreatedBy(), $format, $userContext),
|
||||
'createdBy' => $this->normalizer->normalize($period->getCreatedBy(), $format, [...$userContext, UserNormalizer::AT_DATE => $period->getCreatedAt()]),
|
||||
'emergency' => $period->isEmergency(),
|
||||
'openingDate' => $this->normalizer->normalize($period->getOpeningDate(), $format, $dateContext),
|
||||
'origin' => $this->normalizer->normalize($period->getOrigin(), $format, array_merge($context, ['docgen:expects' => AccompanyingPeriod\Origin::class])),
|
||||
@@ -123,7 +125,7 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
|
||||
'isClosed' => null !== $period->getClosingDate(),
|
||||
'closingMotiveText' => null !== $period->getClosingMotive() ?
|
||||
$this->closingMotiveRender->renderString($period->getClosingMotive(), []) : '',
|
||||
'ref' => $this->normalizer->normalize($period->getUser(), $format, $userContext),
|
||||
'ref' => $this->normalizer->normalize($userHistory?->getUser(), $format, [...$userContext, UserNormalizer::AT_DATE => $userHistory?->getStartDate()]),
|
||||
'hasRef' => null !== $period->getUser(),
|
||||
'socialIssuesText' => implode(', ', array_map(fn (SocialIssue $s) => $this->socialIssueRender->renderString($s, []), $period->getSocialIssues()->toArray())),
|
||||
'scopesText' => implode(', ', array_map(fn (Scope $s) => $this->translatableStringHelper->localize($s->getName()), $scopes)),
|
||||
@@ -135,7 +137,7 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
|
||||
'locationPerson' => $this->normalizer->normalize($period->getPersonLocation(), $format, array_merge($context, ['docgen:expects' => Person::class])),
|
||||
'location' => $this->normalizer->normalize($period->getLocation(), $format, $addressContext),
|
||||
'administrativeLocation' => $this->normalizer->normalize($period->getAdministrativeLocation(), $format, $administrativeLocationContext),
|
||||
'works' => $this->normalizer->normalize($period->getWorks(), $format, $workContext),
|
||||
'works' => $this->normalizer->normalize($period->getWorks()->getValues(), $format, $workContext),
|
||||
'comments' => $this->normalizer->normalize($period->getComments(), $format, array_merge($context, ['docgen:expects' => AccompanyingPeriod\Comment::class])),
|
||||
'pinnedComment' => $this->normalizer->normalize($period->getPinnedComment(), $format, array_merge($context, ['docgen:expects' => AccompanyingPeriod\Comment::class])),
|
||||
];
|
||||
|
@@ -11,12 +11,16 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Serializer\Normalizer;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Repository\Workflow\EntityWorkflowRepository;
|
||||
use Chill\MainBundle\Serializer\Normalizer\UserNormalizer;
|
||||
use Chill\MainBundle\Workflow\Helper\MetadataExtractor;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
|
||||
use Symfony\Component\Serializer\Exception\ExceptionInterface;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
|
||||
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
||||
@@ -30,16 +34,48 @@ class AccompanyingPeriodWorkNormalizer implements ContextAwareNormalizerInterfac
|
||||
|
||||
public function __construct(private readonly Registry $registry, private readonly EntityWorkflowRepository $entityWorkflowRepository, private readonly MetadataExtractor $metadataExtractor) {}
|
||||
|
||||
/**
|
||||
* @param AccompanyingPeriodWork $object
|
||||
*
|
||||
* @throws ExceptionInterface
|
||||
*/
|
||||
public function normalize($object, ?string $format = null, array $context = []): array|\ArrayObject|bool|float|int|string|null
|
||||
{
|
||||
if (!$object instanceof AccompanyingPeriodWork && 'json' === $format) {
|
||||
throw new UnexpectedValueException('Object cannot be null or empty when format is json');
|
||||
}
|
||||
if ('docgen' === $format && !($object instanceof AccompanyingPeriodWork || null === $object)) {
|
||||
throw new UnexpectedValueException(sprintf('Object must be an instanceof AccompanyingPeriodWork or null when format is docgen, %s given', get_debug_type($object)));
|
||||
}
|
||||
|
||||
$cleanContext = array_filter($context, fn (string|int $key) => !in_array($key, ['docgen:expects', self::IGNORE_WORK], true), ARRAY_FILTER_USE_KEY);
|
||||
|
||||
if (null === $object && 'docgen' === $format) {
|
||||
$dateNull = $this->normalizer->normalize(null, $format, [...$context, 'docgen:expects' => \DateTimeImmutable::class]);
|
||||
$userNull = $this->normalizer->normalize(null, $format, [...$context, 'docgen:expects' => User::class]);
|
||||
|
||||
return [
|
||||
'isNull' => true,
|
||||
'type' => 'accompanying_period_work',
|
||||
'accompanyingPeriodWorkEvaluations' => [],
|
||||
'referrers' => [],
|
||||
'createdAt' => $dateNull,
|
||||
'createdAutomatically' => 'false',
|
||||
'createdAutomaticallyReason' => '',
|
||||
'createdBy' => $userNull,
|
||||
'endDate' => $dateNull,
|
||||
'goals' => [],
|
||||
'handlingThierParty' => $this->normalizer->normalize(null, $format, [...$cleanContext, 'docgen:expects' => ThirdParty::class]),
|
||||
'id' => '',
|
||||
'note' => '',
|
||||
'persons' => [],
|
||||
'results' => [],
|
||||
'socialAction' => $this->normalizer->normalize(null, $format, [...$cleanContext, 'docgen:expects' => SocialAction::class]),
|
||||
'startDate' => $dateNull,
|
||||
'thirdParties' => [],
|
||||
'updatedAt' => $dateNull,
|
||||
'updatedBy' => $userNull,
|
||||
];
|
||||
}
|
||||
|
||||
$initial = $this->normalizer->normalize($object, $format, array_merge(
|
||||
$context,
|
||||
[self::IGNORE_WORK => spl_object_hash($object)]
|
||||
$cleanContext,
|
||||
[self::IGNORE_WORK => null === $object ? null : spl_object_hash($object)]
|
||||
));
|
||||
|
||||
// due to bug: https://api-platform.com/docs/core/serialization/#collection-relation
|
||||
@@ -48,38 +84,57 @@ class AccompanyingPeriodWorkNormalizer implements ContextAwareNormalizerInterfac
|
||||
$initial['accompanyingPeriodWorkEvaluations'] = $this->normalizer->normalize(
|
||||
$object->getAccompanyingPeriodWorkEvaluations()->getValues(),
|
||||
$format,
|
||||
$context
|
||||
[...$cleanContext]
|
||||
);
|
||||
|
||||
// then, we add normalization for things which are not into the entity
|
||||
// add the referrers
|
||||
$initial['referrers'] = [];
|
||||
|
||||
$initial['workflows_availables'] = $this->metadataExtractor->availableWorkflowFor(
|
||||
AccompanyingPeriodWork::class,
|
||||
$object->getId()
|
||||
);
|
||||
foreach ($object->getReferrersHistory() as $referrerHistory) {
|
||||
if (null !== $referrerHistory->getEndDate()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$initial['workflows_availables_evaluation'] = $this->metadataExtractor->availableWorkflowFor(
|
||||
AccompanyingPeriodWorkEvaluation::class
|
||||
);
|
||||
$initial['referrers'][] = $this->normalizer->normalize(
|
||||
$referrerHistory->getUser(),
|
||||
$format,
|
||||
[...$cleanContext, UserNormalizer::AT_DATE => $referrerHistory->getStartDate()]
|
||||
);
|
||||
}
|
||||
|
||||
$initial['workflows_availables_evaluation_documents'] = $this->metadataExtractor->availableWorkflowFor(
|
||||
AccompanyingPeriodWorkEvaluationDocument::class
|
||||
);
|
||||
if ('json' === $format) {
|
||||
// then, we add normalization for things which are not into the entity
|
||||
$initial['workflows_availables'] = $this->metadataExtractor->availableWorkflowFor(
|
||||
AccompanyingPeriodWork::class,
|
||||
$object->getId()
|
||||
);
|
||||
|
||||
$workflows = $this->entityWorkflowRepository->findBy([
|
||||
'relatedEntityClass' => AccompanyingPeriodWork::class,
|
||||
'relatedEntityId' => $object->getId(),
|
||||
]);
|
||||
$initial['workflows_availables_evaluation'] = $this->metadataExtractor->availableWorkflowFor(
|
||||
AccompanyingPeriodWorkEvaluation::class
|
||||
);
|
||||
|
||||
$initial['workflows'] = $this->normalizer->normalize($workflows, 'json', $context);
|
||||
$initial['workflows_availables_evaluation_documents'] = $this->metadataExtractor->availableWorkflowFor(
|
||||
AccompanyingPeriodWorkEvaluationDocument::class
|
||||
);
|
||||
|
||||
$workflows = $this->entityWorkflowRepository->findBy([
|
||||
'relatedEntityClass' => AccompanyingPeriodWork::class,
|
||||
'relatedEntityId' => $object->getId(),
|
||||
]);
|
||||
|
||||
$initial['workflows'] = $this->normalizer->normalize($workflows, 'json', $context);
|
||||
}
|
||||
|
||||
return $initial;
|
||||
}
|
||||
|
||||
public function supportsNormalization($data, ?string $format = null, array $context = []): bool
|
||||
{
|
||||
return 'json' === $format
|
||||
&& $data instanceof AccompanyingPeriodWork
|
||||
&& !\array_key_exists(self::IGNORE_WORK, $context);
|
||||
return match ($format) {
|
||||
'json' => $data instanceof AccompanyingPeriodWork && ($context[self::IGNORE_WORK] ?? null) !== spl_object_hash($data),
|
||||
'docgen' => ($data instanceof AccompanyingPeriodWork || (null === $data && ($context['docgen:expects'] ?? null) === AccompanyingPeriodWork::class))
|
||||
&& !array_key_exists(self::IGNORE_WORK, $context),
|
||||
default => false,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -48,7 +48,7 @@ class SocialActionNormalizer implements NormalizerAwareInterface, NormalizerInte
|
||||
'type' => 'social_work_social_action',
|
||||
'text' => $this->render->renderString($socialAction, []),
|
||||
'title' => $socialAction->getTitle(),
|
||||
'parent' => $this->normalizer->normalize($socialAction->getParent(), $format, $context),
|
||||
'parent' => $this->normalizer->normalize($socialAction->getParent(), $format, [...$context, 'docgen:expects' => SocialAction::class]),
|
||||
'issue' => $this->normalizer->normalize($socialAction->getIssue(), $format, $context),
|
||||
];
|
||||
|
||||
|
@@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Serializer\Normalizer;
|
||||
|
||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
|
||||
use Chill\MainBundle\Serializer\Normalizer\UserNormalizer;
|
||||
use Chill\MainBundle\Workflow\Helper\MetadataExtractor;
|
||||
use Symfony\Component\Serializer\Exception\ExceptionInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
|
||||
@@ -46,7 +47,7 @@ class WorkflowNormalizer implements ContextAwareNormalizerInterface, NormalizerA
|
||||
$data['workflow'] = $this->metadataExtractor->buildArrayPresentationForWorkflow($workflow);
|
||||
$data['current_place'] = $this->metadataExtractor->buildArrayPresentationForPlace($object);
|
||||
$data['current_place_at'] = $this->normalizer->normalize($object->getCurrentStepCreatedAt(), 'json', ['groups' => ['read']]);
|
||||
$data['current_place_by'] = $this->normalizer->normalize($object->getCurrentStepCreatedBy(), 'json', ['groups' => ['read']]);
|
||||
$data['current_place_by'] = $this->normalizer->normalize($object->getCurrentStepCreatedBy(), 'json', ['groups' => ['read'], UserNormalizer::AT_DATE => $object->getCurrentStepCreatedAt()]);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
@@ -33,7 +33,40 @@ final class ReferrerAggregatorTest extends AbstractAggregatorTest
|
||||
$this->aggregator = self::getContainer()->get('chill.person.export.aggregator_referrer');
|
||||
}
|
||||
|
||||
public function getAggregator()
|
||||
/**
|
||||
* @dataProvider provideBeforeData
|
||||
*/
|
||||
public function testDataTransformer(?array $before, array $expected): void
|
||||
{
|
||||
$actual = $this->getAggregator()->transformData($before);
|
||||
|
||||
self::assertEqualsCanonicalizing(array_keys($expected), array_keys($actual));
|
||||
foreach (['start_date', 'end_date'] as $key) {
|
||||
self::assertInstanceOf(RollingDate::class, $actual[$key]);
|
||||
self::assertEquals($expected[$key]->getRoll(), $actual[$key]->getRoll(), "Check that the roll is the same for {$key}");
|
||||
}
|
||||
}
|
||||
|
||||
public static function provideBeforeData(): iterable
|
||||
{
|
||||
yield [
|
||||
['date_calc' => new RollingDate(RollingDate::T_TODAY)],
|
||||
['start_date' => new RollingDate(RollingDate::T_TODAY), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
];
|
||||
|
||||
yield [
|
||||
['start_date' => new RollingDate(RollingDate::T_WEEK_CURRENT_START), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
['start_date' => new RollingDate(RollingDate::T_WEEK_CURRENT_START), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
];
|
||||
|
||||
yield [
|
||||
null,
|
||||
// this is the default configuration
|
||||
['start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
];
|
||||
}
|
||||
|
||||
public function getAggregator(): ReferrerAggregator
|
||||
{
|
||||
return $this->aggregator;
|
||||
}
|
||||
@@ -41,7 +74,10 @@ final class ReferrerAggregatorTest extends AbstractAggregatorTest
|
||||
public static function getFormData(): array
|
||||
{
|
||||
return [
|
||||
['date_calc' => new RollingDate(RollingDate::T_TODAY)],
|
||||
[
|
||||
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
||||
'end_date' => new RollingDate(RollingDate::T_TODAY),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -14,6 +14,7 @@ namespace Export\Aggregator\AccompanyingCourseAggregators;
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverter;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
||||
@@ -48,16 +49,46 @@ final class ReferrerScopeAggregatorTest extends AbstractAggregatorTest
|
||||
return new ReferrerScopeAggregator(
|
||||
$scopeRepository->reveal(),
|
||||
$translatableStringHelper->reveal(),
|
||||
$dateConverter->reveal()
|
||||
new RollingDateConverter(),
|
||||
);
|
||||
}
|
||||
|
||||
public static function getFormData(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'date_calc' => new RollingDate(RollingDate::T_TODAY),
|
||||
],
|
||||
['start_date' => new RollingDate(RollingDate::T_WEEK_CURRENT_START), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideBeforeData
|
||||
*/
|
||||
public function testDataTransformer(?array $before, array $expected): void
|
||||
{
|
||||
$actual = $this->getAggregator()->transformData($before);
|
||||
|
||||
self::assertEqualsCanonicalizing(array_keys($expected), array_keys($actual));
|
||||
foreach (['start_date', 'end_date'] as $key) {
|
||||
self::assertInstanceOf(RollingDate::class, $actual[$key]);
|
||||
self::assertEquals($expected[$key]->getRoll(), $actual[$key]->getRoll(), "Check that the roll is the same for {$key}");
|
||||
}
|
||||
}
|
||||
|
||||
public static function provideBeforeData(): iterable
|
||||
{
|
||||
yield [
|
||||
null,
|
||||
['start_date' => new RollingDate(RollingDate::T_FIXED_DATE, new \DateTimeImmutable('1970-01-01')), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
];
|
||||
|
||||
yield [
|
||||
[],
|
||||
['start_date' => new RollingDate(RollingDate::T_FIXED_DATE, new \DateTimeImmutable('1970-01-01')), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
];
|
||||
|
||||
yield [
|
||||
['start_date' => new RollingDate(RollingDate::T_WEEK_CURRENT_START), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
['start_date' => new RollingDate(RollingDate::T_WEEK_CURRENT_START), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -33,7 +33,39 @@ final class UserJobAggregatorTest extends AbstractAggregatorTest
|
||||
$this->aggregator = self::getContainer()->get('chill.person.export.aggregator_referrer_job');
|
||||
}
|
||||
|
||||
public function getAggregator()
|
||||
/**
|
||||
* @dataProvider provideBeforeData
|
||||
*/
|
||||
public function testDataTransformer(?array $before, array $expected): void
|
||||
{
|
||||
$actual = $this->getAggregator()->transformData($before);
|
||||
|
||||
self::assertEqualsCanonicalizing(array_keys($expected), array_keys($actual));
|
||||
foreach (['start_date', 'end_date'] as $key) {
|
||||
self::assertInstanceOf(RollingDate::class, $actual[$key]);
|
||||
self::assertEquals($expected[$key]->getRoll(), $actual[$key]->getRoll(), "Check that the roll is the same for {$key}");
|
||||
}
|
||||
}
|
||||
|
||||
public static function provideBeforeData(): iterable
|
||||
{
|
||||
yield [
|
||||
null,
|
||||
['start_date' => new RollingDate(RollingDate::T_FIXED_DATE, new \DateTimeImmutable('1970-01-01')), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
];
|
||||
|
||||
yield [
|
||||
[],
|
||||
['start_date' => new RollingDate(RollingDate::T_FIXED_DATE, new \DateTimeImmutable('1970-01-01')), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
];
|
||||
|
||||
yield [
|
||||
['start_date' => new RollingDate(RollingDate::T_WEEK_CURRENT_START), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
['start_date' => new RollingDate(RollingDate::T_WEEK_CURRENT_START), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
];
|
||||
}
|
||||
|
||||
public function getAggregator(): UserJobAggregator
|
||||
{
|
||||
return $this->aggregator;
|
||||
}
|
||||
@@ -41,9 +73,7 @@ final class UserJobAggregatorTest extends AbstractAggregatorTest
|
||||
public static function getFormData(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'job_at' => new RollingDate(RollingDate::T_FIXED_DATE, \DateTimeImmutable::createFromFormat('Y-m-d', '2020-01-01')),
|
||||
],
|
||||
['start_date' => new RollingDate(RollingDate::T_WEEK_CURRENT_START), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -50,11 +50,13 @@ final class UserJobFilterTest extends AbstractFilterTest
|
||||
$data = [];
|
||||
$data[] = [
|
||||
'jobs' => new ArrayCollection($jobs),
|
||||
'date_calc' => new RollingDate(RollingDate::T_TODAY),
|
||||
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
||||
'end_date' => new RollingDate(RollingDate::T_TODAY),
|
||||
];
|
||||
$data[] = [
|
||||
'jobs' => $jobs,
|
||||
'date_calc' => new RollingDate(RollingDate::T_TODAY),
|
||||
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
||||
'end_date' => new RollingDate(RollingDate::T_TODAY),
|
||||
];
|
||||
|
||||
return $data;
|
||||
|
@@ -50,11 +50,13 @@ final class UserScopeFilterTest extends AbstractFilterTest
|
||||
|
||||
return [
|
||||
[
|
||||
'date_calc' => new RollingDate(RollingDate::T_TODAY),
|
||||
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
||||
'end_date' => new RollingDate(RollingDate::T_TODAY),
|
||||
'scopes' => new ArrayCollection($scopes),
|
||||
],
|
||||
[
|
||||
'date_calc' => new RollingDate(RollingDate::T_TODAY),
|
||||
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
||||
'end_date' => new RollingDate(RollingDate::T_TODAY),
|
||||
'scopes' => $scopes,
|
||||
],
|
||||
];
|
||||
|
@@ -11,13 +11,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace Serializer\Normalizer;
|
||||
|
||||
use Chill\DocGeneratorBundle\Test\DocGenNormalizerTestAbstract;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkGoal;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\SocialWork\Goal;
|
||||
use Chill\PersonBundle\Entity\SocialWork\Result;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
||||
@@ -25,8 +25,10 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*
|
||||
* @template-extends DocGenNormalizerTestAbstract<AccompanyingPeriodWork>
|
||||
*/
|
||||
final class AccompanyingPeriodWorkDocGenNormalizerTest extends KernelTestCase
|
||||
final class AccompanyingPeriodWorkDocGenNormalizerTest extends DocGenNormalizerTestAbstract
|
||||
{
|
||||
private NormalizerInterface $normalizer;
|
||||
|
||||
@@ -36,28 +38,31 @@ final class AccompanyingPeriodWorkDocGenNormalizerTest extends KernelTestCase
|
||||
$this->normalizer = self::getContainer()->get(NormalizerInterface::class);
|
||||
}
|
||||
|
||||
public function testNormalizationNull()
|
||||
public function provideNotNullObject(): object
|
||||
{
|
||||
$actual = $this->normalizer->normalize(null, 'docgen', [
|
||||
'docgen:expects' => AccompanyingPeriodWork::class,
|
||||
AbstractNormalizer::GROUPS => ['docgen:read'],
|
||||
]);
|
||||
$work = new AccompanyingPeriodWork();
|
||||
$work
|
||||
->addPerson((new Person())->setFirstName('hello')->setLastName('name'))
|
||||
->addGoal($g = new AccompanyingPeriodWorkGoal())
|
||||
->addResult($r = new Result())
|
||||
->setCreatedAt(new \DateTimeImmutable())
|
||||
->setUpdatedAt(new \DateTimeImmutable())
|
||||
->setCreatedBy($user = new User())
|
||||
->setUpdatedBy($user);
|
||||
$g->addResult($r)->setGoal($goal = new Goal());
|
||||
$goal->addResult($r);
|
||||
|
||||
$expected = [
|
||||
'id' => '',
|
||||
];
|
||||
return $work;
|
||||
}
|
||||
|
||||
$this->assertIsArray($actual);
|
||||
$this->markTestSkipped('specification still not finalized');
|
||||
$this->assertEqualsCanonicalizing(array_keys($expected), array_keys($actual));
|
||||
public function provideDocGenExpectClass(): string
|
||||
{
|
||||
return AccompanyingPeriodWork::class;
|
||||
}
|
||||
|
||||
foreach ($expected as $key => $item) {
|
||||
if ('@ignored' === $item) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->assertEquals($item, $actual[$key]);
|
||||
}
|
||||
public function getNormalizer(): NormalizerInterface
|
||||
{
|
||||
return $this->normalizer;
|
||||
}
|
||||
|
||||
public function testNormalize()
|
||||
@@ -79,20 +84,6 @@ final class AccompanyingPeriodWorkDocGenNormalizerTest extends KernelTestCase
|
||||
AbstractNormalizer::GROUPS => ['docgen:read'],
|
||||
]);
|
||||
|
||||
$expected = [
|
||||
'id' => 0,
|
||||
];
|
||||
|
||||
$this->assertIsArray($actual);
|
||||
$this->markTestSkipped('specification still not finalized');
|
||||
$this->assertEqualsCanonicalizing(array_keys($expected), array_keys($actual));
|
||||
|
||||
foreach ($expected as $key => $item) {
|
||||
if (0 === $item) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->assertEquals($item, $actual[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,19 +1,9 @@
|
||||
services:
|
||||
Chill\PersonBundle\Menu\:
|
||||
resource: './../../Menu'
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: 'chill.menu_builder' }
|
||||
|
||||
# Chill\PersonBundle\Menu\SectionMenuBuilder:
|
||||
# arguments:
|
||||
# $authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'
|
||||
# $translator: '@Symfony\Contracts\Translation\TranslatorInterface'
|
||||
# tags:
|
||||
# - { name: 'chill.menu_builder' }
|
||||
#
|
||||
Chill\PersonBundle\Menu\PersonMenuBuilder:
|
||||
_defaults:
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
|
||||
Chill\PersonBundle\Menu\:
|
||||
resource: './../../Menu'
|
||||
tags:
|
||||
- { name: 'chill.menu_builder' }
|
||||
|
@@ -143,6 +143,10 @@ exports:
|
||||
by_referrer_between_dates:
|
||||
description: >-
|
||||
Filtré par référent du parcours, entre deux dates: depuis le {start_date, date, medium}, jusqu'au {end_date, date, medium}, seulement {agents}
|
||||
by_user_job:
|
||||
"Filtered by user job: only job": "Filtré par métier du référent entre le {startDate, date, short} et le {endDate, date, short}: uniquement {job}"
|
||||
by_user_scope:
|
||||
"Filtered by user main scope: only scopes": "Filtré par service du référent entre le {startDate, date, short} et le {endDate, date, short}: uniquement {scopes}"
|
||||
work:
|
||||
by_treating_agent:
|
||||
Filtered by treating agent at date: >-
|
||||
|
@@ -1058,9 +1058,15 @@ export:
|
||||
by-user:
|
||||
title: Grouper les parcours par usager participant
|
||||
header: Usager participant
|
||||
|
||||
by_referrer:
|
||||
Computation date for referrer: Date à laquelle le référent était actif
|
||||
Referrer after: Référent après le
|
||||
Until: Jusqu'au
|
||||
by_referrer_scope:
|
||||
Referrer and scope after: Référent et service après le
|
||||
Until: Jusqu'au
|
||||
by_referrer_job:
|
||||
Referrer and job after: Référent et métier après le
|
||||
Until: Jusqu'au
|
||||
by_user_scope:
|
||||
Group course by referrer's scope: Grouper les parcours par service du référent
|
||||
Referrer's scope: Service du référent de parcours
|
||||
@@ -1215,7 +1221,8 @@ export:
|
||||
'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:
|
||||
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%"
|
||||
Start from: Référent et service depuis le
|
||||
Until: Jusqu'au
|
||||
by_referrer:
|
||||
Computation date for referrer: Date à laquelle le référent était actif
|
||||
by_referrer_between_dates:
|
||||
@@ -1232,7 +1239,8 @@ export:
|
||||
'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%"
|
||||
Start from: Référent et métier depuis le
|
||||
Until: Jusqu'au
|
||||
by_social_action:
|
||||
title: Filtrer les parcours par action d'accompagnement
|
||||
Accepted socialactions: Actions d'accompagnement
|
||||
@@ -1405,7 +1413,8 @@ export:
|
||||
updatedBy: Modifié par
|
||||
acp_id: Identifiant du parcours
|
||||
acp_user: Référent du parcours
|
||||
referrers: Agents traitants
|
||||
acpwReferrers: Agents traitants
|
||||
referrer: Référent du parcours
|
||||
personsId: Identifiants des usagers
|
||||
personsName: Usagers de l'action
|
||||
goalsId: Identifiants des objectifs
|
||||
|
Reference in New Issue
Block a user