From e5a449118e8535adc46c1a2131ce994c2913d9d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 28 Sep 2023 14:56:53 +0200 Subject: [PATCH] Reassign list: when reassigning course, the job associated to the period becomes the job of the new referrer (user) https://gitlab.com/Chill-Projet/chill-bundles/-/issues/162 --- .changes/unreleased/Feature-20230928-145628.yaml | 6 ++++++ .../Controller/ReassignAccompanyingPeriodController.php | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .changes/unreleased/Feature-20230928-145628.yaml diff --git a/.changes/unreleased/Feature-20230928-145628.yaml b/.changes/unreleased/Feature-20230928-145628.yaml new file mode 100644 index 000000000..ec20d8883 --- /dev/null +++ b/.changes/unreleased/Feature-20230928-145628.yaml @@ -0,0 +1,6 @@ +kind: Feature +body: 'Reassigning list: when reassigning courses to a new user, the job associated + with the course become the one of the new user (if any)' +time: 2023-09-28T14:56:28.69132294+02:00 +custom: + Issue: "162" diff --git a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php index 3e5b59c2a..05ed4c91d 100644 --- a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php @@ -100,7 +100,7 @@ class ReassignAccompanyingPeriodController extends AbstractController $total = $this->accompanyingPeriodACLAwareRepository->countByUserAndPostalCodesOpenedAccompanyingPeriod($userFrom, $postalCodes); $paginator = $this->paginatorFactory->create($total); - $paginator->setItemsPerPage(50); + $paginator->setItemsPerPage(100); $periods = $this->accompanyingPeriodACLAwareRepository ->findByUserAndPostalCodesOpenedAccompanyingPeriod( $userFrom, @@ -123,6 +123,7 @@ class ReassignAccompanyingPeriodController extends AbstractController if ($assignForm->isSubmitted() && $assignForm->isValid()) { $assignPeriodIds = json_decode($assignForm->get('periods')->getData(), true, 512, JSON_THROW_ON_ERROR); + /** @var User $userTo */ $userTo = $assignForm->get('userTo')->getData(); $userFrom = $assignForm->get('userFrom')->getData(); @@ -131,6 +132,10 @@ class ReassignAccompanyingPeriodController extends AbstractController if ($period->getUser() === $userFrom) { $period->setUser($userTo, true); + + if (null !== $userTo->getUserJob() && $period->getJob() !== $userTo->getUserJob()) { + $period->setJob($userTo->getUserJob()); + } } }