diff --git a/CHANGELOG.md b/CHANGELOG.md index 027eff683..9d05f1767 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,11 @@ and this project adheres to * [activity] Fix delete button for document (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/554) * [activity] Add return path the document generation (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/553) +* [person] add person ressource to person docgen normaliser (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/517) +* [person] AccompanyingCourseWorkEdit: fix deleting evaluation documents (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/546) +* [person] AccompanyingCourseWorkEdit: download existing documents (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/512) +* [person] AccompanyingCourseWorkEdit: replace document by a new one (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/511) +* [person] AccompanyingPeriodWork: add referrers to work, add doctrine event listener to add logged user to referrers collection and display a referrers list in work list (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/502) * [person] AccompanyingPeriodWorkEvaluation: fix circular reference when serialising (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/495) * [person] order accompanying period by opening date in search persons, person and household period lists (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/493) * [parcours] autosave of the pinned comment for draft accompanying course (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/477) @@ -48,6 +53,9 @@ and this project adheres to * [contact] add contact button color changed plus the pipe at the side removed (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/506) * [household] create-edit household composition placed in separate page to avoid confusion (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/505) * [blur] Improved positioning of toggle icon (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/486) +* [parcours] List of parcours for a specific user so they can be reassigned in case of absence (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/509) +* [thirdparty] Thirdparty view page, english text translated (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/534) +* [social_action] Translation changed in evaluation section (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/512) ## Test releases diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/listPerson.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/listPerson.html.twig index ac4266f8c..8b30bc6c7 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/listPerson.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/listPerson.html.twig @@ -46,7 +46,7 @@ {% include 'ChillActivityBundle:Activity:list.html.twig' with {'context': 'person'} %} - {% if is_granted('CHILL_ACTIVITY_CREATE', person) %} + {% if is_granted('CHILL_ACTIVITY_CREATE_PERSON', person) %}
+ + + + + {% endfor %} + + {{ chill_pagination(paginator) }} + +{% endblock %} \ No newline at end of file diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/CommentEmbeddableDocGenNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/CommentEmbeddableDocGenNormalizer.php index bd812e036..10f43a2f6 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/CommentEmbeddableDocGenNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/CommentEmbeddableDocGenNormalizer.php @@ -39,7 +39,7 @@ class CommentEmbeddableDocGenNormalizer implements ContextAwareNormalizerInterfa */ public function normalize($object, ?string $format = null, array $context = []): array { - if (null === $object) { + if (null === $object || ($object->isEmpty())) { return [ 'comment' => '', 'isNull' => true, diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php index 677199ad4..7eb323754 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Serializer\Exception\UnexpectedValueException; use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; -use Symfony\Component\Serializer\Normalizer\NormalizerInterface; class PhonenumberNormalizer implements ContextAwareNormalizerInterface, DenormalizerInterface { @@ -54,7 +53,7 @@ class PhonenumberNormalizer implements ContextAwareNormalizerInterface, Denormal public function normalize($object, ?string $format = null, array $context = []): string { - if ($format === 'docgen' && null === $object) { + if ('docgen' === $format && null === $object) { return ''; } @@ -68,13 +67,13 @@ class PhonenumberNormalizer implements ContextAwareNormalizerInterface, Denormal public function supportsNormalization($data, ?string $format = null, array $context = []): bool { - if ($data instanceof PhoneNumber && $format === 'json') { + if ($data instanceof PhoneNumber && 'json' === $format) { return true; } - if ($format === 'docgen' && ( + if ('docgen' === $format && ( $data instanceof PhoneNumber || PhoneNumber::class === ($context['docgen:expects'] ?? null) - )) { + )) { return true; } diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/UserControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/UserControllerTest.php index f5d76ef8f..42f541d56 100644 --- a/src/Bundle/ChillMainBundle/Tests/Controller/UserControllerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Controller/UserControllerTest.php @@ -100,10 +100,10 @@ final class UserControllerTest extends WebTestCase $crawler = $this->client->followRedirect(); // Check data in the show view - $this->assertGreaterThan( - 0, - $crawler->filter('td:contains("Test_user")')->count(), - 'Missing element td:contains("Test user")' + $this->assertStringContainsString( + 'Test_user', + $crawler->text(), + 'page contains the name of the user' ); //test the auth of the new client @@ -125,11 +125,7 @@ final class UserControllerTest extends WebTestCase $this->client->submit($form); $crawler = $this->client->followRedirect(); // Check the element contains an attribute with value equals "Foo" - $this->assertGreaterThan( - 0, - $crawler->filter('[data-username="' . $username . '"]')->count(), - 'Missing element [data-username="Foo bar"]' - ); + $this->assertResponseIsSuccessful(); } /** diff --git a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php new file mode 100644 index 000000000..4abf5e93c --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php @@ -0,0 +1,114 @@ +accompanyingPeriodACLAwareRepository = $accompanyingPeriodACLAwareRepository; + $this->engine = $engine; + $this->formFactory = $formFactory; + $this->paginatorFactory = $paginatorFactory; + $this->security = $security; + $this->userRepository = $userRepository; + $this->userRender = $userRender; + } + + /** + * @Route("/{_locale}/person/accompanying-periods/reassign", name="chill_course_list_reassign") + */ + public function listAction(Request $request): Response + { + if (!$this->security->isGranted('ROLE_USER') || !$this->security->getUser() instanceof User) { + throw new AccessDeniedException(); + } + + $form = $this->buildFilterForm(); + + $form->handleRequest($request); + + $total = $this->accompanyingPeriodACLAwareRepository->countByUserOpenedAccompanyingPeriod( + $form['user']->getData() + ); + $paginator = $this->paginatorFactory->create($total); + $periods = $this->accompanyingPeriodACLAwareRepository + ->findByUserOpenedAccompanyingPeriod( + $form['user']->getData(), + ['openingDate' => 'ASC'], + $paginator->getItemsPerPage(), + $paginator->getCurrentPageFirstItemNumber() + ); + + return new Response( + $this->engine->render('@ChillPerson/AccompanyingPeriod/reassign_list.html.twig', [ + 'paginator' => $paginator, + 'periods' => $periods, + 'form' => $form->createView(), + ]) + ); + } + + private function buildFilterForm(): FormInterface + { + $data = [ + 'user' => null, + ]; + $builder = $this->formFactory->createBuilder(FormType::class, $data, [ + 'method' => 'get', 'csrf_protection' => false, ]); + + $builder + ->add('user', EntityType::class, [ + 'class' => User::class, + 'choices' => $this->userRepository->findByActive(['username' => 'ASC']), + 'choice_label' => function (User $u) { + return $this->userRender->renderString($u, []); + }, + 'multiple' => false, + 'label' => 'User', + 'required' => false, + ]); + + return $builder->getForm(); + } +} diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php index ed00c8611..95ec008d9 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php @@ -142,6 +142,15 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues */ private Collection $persons; + /** + * @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"}) + */ + private Collection $referrers; + /** * @ORM\ManyToMany(targetEntity=Result::class, inversedBy="accompanyingPeriodWorks") * @ORM\JoinTable(name="chill_person_accompanying_period_work_result") @@ -196,6 +205,7 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues $this->thirdParties = new ArrayCollection(); $this->persons = new ArrayCollection(); $this->accompanyingPeriodWorkEvaluations = new ArrayCollection(); + $this->referrers = new ArrayCollection(); } public function addAccompanyingPeriodWorkEvaluation(AccompanyingPeriodWorkEvaluation $evaluation): self @@ -227,6 +237,15 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues return $this; } + public function addReferrer(User $referrer): self + { + if (!$this->referrers->contains($referrer)) { + $this->referrers[] = $referrer; + } + + return $this; + } + public function addResult(Result $result): self { if (!$this->results->contains($result)) { @@ -308,6 +327,14 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues return $this->persons; } + /** + * @return Collection|User[] + */ + public function getReferrers(): Collection + { + return $this->referrers; + } + /** * @return Collection|Result[] */ @@ -382,6 +409,13 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues return $this; } + public function removeReferrer(User $referrer): self + { + $this->referrers->removeElement($referrer); + + return $this; + } + public function removeResult(Result $result): self { $this->results->removeElement($result); diff --git a/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php index 3cd82680e..1d2343067 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php @@ -39,13 +39,13 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="comment_") - * @Groups({"read"}) + * @Groups({"read", "docgen:read"}) */ private CommentEmbeddable $comment; /** * @ORM\Column(type="text", nullable=true) - * @Groups({"read"}) + * @Groups({"read", "docgen:read"}) */ private ?string $freeText = null; @@ -53,24 +53,29 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") + * @Groups({"read", "docgen:read"}) */ private ?int $id; /** * @ORM\ManyToOne(targetEntity=PersonResourceKind::class, inversedBy="personResources") * @ORM\JoinColumn(nullable=true) - * @Groups({"read"}) + * @Groups({"read", "docgen:read"}) */ - private $kind; + private ?PersonResourceKind $kind = null; /** + * The person which host the owner of this resource. + * * @ORM\ManyToOne(targetEntity=Person::class, inversedBy="personResources") * @ORM\JoinColumn(nullable=true) - * @Groups({"read"}) + * @Groups({"read", "docgen:read"}) */ private ?Person $person = null; /** + * The person linked with this resource. + * * @ORM\ManyToOne(targetEntity=Person::class) * @ORM\JoinColumn(nullable=false) * @Groups({"read"}) @@ -80,7 +85,7 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\ManyToOne(targetEntity=ThirdParty::class, inversedBy="personResources") * @ORM\JoinColumn(nullable=true) - * @Groups({"read"}) + * @Groups({"read", "docgen:read"}) */ private ?ThirdParty $thirdParty = null; @@ -122,6 +127,26 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface return $this->personOwner; } + /** + * @Groups({"read", "docgen:read"}) + */ + public function getResourceKind(): string + { + if ($this->getPerson() instanceof Person) { + return 'person'; + } + + if ($this->getThirdParty() instanceof ThirdParty) { + return 'thirdparty'; + } + + if (null !== $this->getFreeText()) { + return 'freetext'; + } + + return 'none'; + } + public function getThirdParty(): ?ThirdParty { return $this->thirdParty; diff --git a/src/Bundle/ChillPersonBundle/Entity/Person/PersonResourceKind.php b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResourceKind.php index 4e65fda9f..f450997fa 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person/PersonResourceKind.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResourceKind.php @@ -12,10 +12,9 @@ declare(strict_types=1); namespace Chill\PersonBundle\Entity\Person; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Serializer\Annotation as Serializer; /** - * **About denormalization**: this operation is operated by @see{AccompanyingPeriodResourdeNormalizer}. - * * @ORM\Entity * @ORM\Table(name="chill_person_resource_kind") */ @@ -25,8 +24,9 @@ class PersonResourceKind * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") + * @Serializer\Groups({"docgen:read"}) */ - private int $id; + private ?int $id = null; /** * @ORM\Column(type="boolean") @@ -35,6 +35,8 @@ class PersonResourceKind /** * @ORM\Column(type="json", length=255) + * @Serializer\Groups({"docgen:read"}) + * @Serializer\Context({"is-translatable": true}, groups={"docgen:read"}) */ private array $title; diff --git a/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php b/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php new file mode 100644 index 000000000..83f9ca460 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/EventListener/AccompanyingPeriodWorkEventListener.php @@ -0,0 +1,33 @@ +security = $security; + } + + public function prePersistAccompanyingPeriodWork(AccompanyingPeriodWork $work): void + { + if ($this->security->getUser() instanceof User) { + $work->addReferrer($this->security->getUser()); + } + } +} diff --git a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php index 827dfb0a6..929fb2ae0 100644 --- a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -68,12 +68,14 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface } if ($this->security->isGranted(AccompanyingPeriodVoter::SEE_DETAILS, $period)) { - $menu->addChild($this->translator->trans('Accompanying Course History'), [ - 'route' => 'chill_person_accompanying_course_history', - 'routeParameters' => [ - 'accompanying_period_id' => $period->getId(), - ], ]) - ->setExtras(['order' => 30]); + /* + $menu->addChild($this->translator->trans('Accompanying Course History'), [ + 'route' => 'chill_person_accompanying_course_history', + 'routeParameters' => [ + 'accompanying_period_id' => $period->getId(), + ], ]) + ->setExtras(['order' => 30]); + */ $menu->addChild($this->translator->trans('Accompanying Course Comment'), [ 'route' => 'chill_person_accompanying_period_comment_list', diff --git a/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php index 04f989d84..4635eb4fc 100644 --- a/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/SectionMenuBuilder.php @@ -22,15 +22,9 @@ use Symfony\Contracts\Translation\TranslatorInterface; */ class SectionMenuBuilder implements LocalMenuBuilderInterface { - /** - * @var AuthorizationCheckerInterface - */ - protected $authorizationChecker; + protected AuthorizationCheckerInterface $authorizationChecker; - /** - * @var TranslatorInterface - */ - protected $translator; + protected TranslatorInterface $translator; /** * SectionMenuBuilder constructor. @@ -63,6 +57,14 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface 'order' => 11, 'icons' => ['plus'], ]); + + $menu->addChild($this->translator->trans('Accompanying courses of users'), [ + 'route' => 'chill_course_list_reassign', + ]) + ->setExtras([ + 'order' => 12, + 'icons' => ['task'], + ]); } public static function getMenuIds(): array diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationRepository.php index 3178aa6e2..3273e3a7d 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationRepository.php @@ -87,9 +87,12 @@ class AccompanyingPeriodWorkEvaluationRepository implements ObjectRepository ->join('work.accompanyingPeriod', 'period') ->where( $qb->expr()->andX( - $qb->expr()->eq('period.user', ':user'), $qb->expr()->isNull('e.endDate'), - $qb->expr()->gte(':now', $qb->expr()->diff('e.maxDate', 'e.warningInterval')) + $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') + ) ) ) ->setParameters([ diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php index 9e67da458..dd27cf434 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php @@ -159,9 +159,12 @@ final class AccompanyingPeriodWorkRepository implements ObjectRepository ->join('w.accompanyingPeriod', 'period') ->where( $qb->expr()->andX( - $qb->expr()->eq('period.user', ':user'), $qb->expr()->gte('w.endDate', ':since'), - $qb->expr()->lte('w.startDate', ':until') + $qb->expr()->lte('w.startDate', ':until'), + $qb->expr()->orX( + $qb->expr()->eq('period.user', ':user'), + $qb->expr()->isMemberOf(':user', 'w.referrers') + ) ) ) ->setParameters([ diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php index 6e6c3ca44..8efd60e58 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php @@ -11,12 +11,14 @@ declare(strict_types=1); namespace Chill\PersonBundle\Repository; +use Chill\MainBundle\Entity\User; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; -use Symfony\Component\Security\Core\Security; +use DateTime; +use Symfony\Component\Security\Core\Security; use function count; final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodACLAwareRepositoryInterface @@ -41,6 +43,37 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC $this->centerResolverDispatcher = $centerResolverDispatcher; } + public function buildQueryOpenedAccompanyingCourseByUser(?User $user) + { + $qb = $this->accompanyingPeriodRepository->createQueryBuilder('ap'); + + $qb->where($qb->expr()->eq('ap.user', ':user')) + ->andWhere( + $qb->expr()->neq('ap.step', ':draft'), + $qb->expr()->orX( + $qb->expr()->isNull('ap.closingDate'), + $qb->expr()->gt('ap.closingDate', ':now') + ) + ) + ->setParameter('user', $user) + ->setParameter('now', new DateTime('now')) + ->setParameter('draft', AccompanyingPeriod::STEP_DRAFT); + + return $qb; + } + + public function countByUserOpenedAccompanyingPeriod(?User $user): int + { + if (null === $user) { + return 0; + } + + return $this->buildQueryOpenedAccompanyingCourseByUser($user) + ->select('COUNT(ap)') + ->getQuery() + ->getSingleScalarResult(); + } + public function findByPerson( Person $person, string $role, @@ -92,4 +125,25 @@ final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodAC return $qb->getQuery()->getResult(); } + + /** + * @return array|AccompanyingPeriod[] + */ + public function findByUserOpenedAccompanyingPeriod(?User $user, array $orderBy = [], int $limit = 0, int $offset = 50): array + { + if (null === $user) { + return []; + } + + $qb = $this->buildQueryOpenedAccompanyingCourseByUser($user); + + $qb->setFirstResult($offset) + ->setMaxResults($limit); + + foreach ($orderBy as $field => $direction) { + $qb->addOrderBy('ap.' . $field, $direction); + } + + return $qb->getQuery()->getResult(); + } } diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepositoryInterface.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepositoryInterface.php index 778e8d8fe..a02ec27c6 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepositoryInterface.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepositoryInterface.php @@ -11,10 +11,13 @@ declare(strict_types=1); namespace Chill\PersonBundle\Repository; +use Chill\MainBundle\Entity\User; use Chill\PersonBundle\Entity\Person; interface AccompanyingPeriodACLAwareRepositoryInterface { + public function countByUserOpenedAccompanyingPeriod(?User $user): int; + public function findByPerson( Person $person, string $role, @@ -22,4 +25,6 @@ interface AccompanyingPeriodACLAwareRepositoryInterface ?int $limit = null, ?int $offset = null ): array; + + public function findByUserOpenedAccompanyingPeriod(?User $user, array $orderBy = [], int $limit = 0, int $offset = 50): array; } diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodRepository.php index 122b658bd..ab7006fd8 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodRepository.php @@ -78,6 +78,16 @@ final class AccompanyingPeriodRepository implements ObjectRepository ->getResult(); } + public function findConfirmedByUser(User $user) + { + $qb = $this->createQueryBuilder('ap'); + $qb->where($qb->expr()->eq('ap.user', ':user')) + ->andWhere('ap.step', 'CONFIRMED') + ->setParameter('user', $user); + + return $qb; + } + public function findOneBy(array $criteria): ?AccompanyingPeriod { return $this->findOneBy($criteria); diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue index a0d88d1bf..bcfa53e45 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue @@ -127,7 +127,7 @@{{ $t('no_referrers') }}
+Créé par {{ d.createdBy.text }}
Le {{ $d(ISOToDatetime(d.createdAt.datetime), 'long') }}
- {{ w.createdBy|chill_entity_render_box }} + {% for u in w.referrers %} + {{ u|chill_entity_render_box }} + {% if not loop.last %}, {% endif %} + {% endfor %}
{{ 'period_by_user_list.Pick a user'|trans }}
+ {% elseif periods|length == 0 and form.user.vars.value is not empty %} +{{ 'period_by_user_list.Any course or no authorization to see them'|trans }}
+ + {% else %} +{{ paginator.totalItems }} parcours à réassigner (calculé ce jour à {{ null|format_time('medium') }})
+ +