Merge branch '162-change-job-on-course-when-reassigning-user' into 'master'

Reassign list: when reassigning course, the job associated to the period...

Closes #162

See merge request Chill-Projet/chill-bundles!596
This commit is contained in:
Julien Fastré 2023-10-02 10:24:55 +00:00
commit a625260c36
2 changed files with 12 additions and 1 deletions

View File

@ -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"

View File

@ -100,7 +100,7 @@ class ReassignAccompanyingPeriodController extends AbstractController
$total = $this->accompanyingPeriodACLAwareRepository->countByUserAndPostalCodesOpenedAccompanyingPeriod($userFrom, $postalCodes); $total = $this->accompanyingPeriodACLAwareRepository->countByUserAndPostalCodesOpenedAccompanyingPeriod($userFrom, $postalCodes);
$paginator = $this->paginatorFactory->create($total); $paginator = $this->paginatorFactory->create($total);
$paginator->setItemsPerPage(50); $paginator->setItemsPerPage(100);
$periods = $this->accompanyingPeriodACLAwareRepository $periods = $this->accompanyingPeriodACLAwareRepository
->findByUserAndPostalCodesOpenedAccompanyingPeriod( ->findByUserAndPostalCodesOpenedAccompanyingPeriod(
$userFrom, $userFrom,
@ -123,6 +123,7 @@ class ReassignAccompanyingPeriodController extends AbstractController
if ($assignForm->isSubmitted() && $assignForm->isValid()) { if ($assignForm->isSubmitted() && $assignForm->isValid()) {
$assignPeriodIds = json_decode($assignForm->get('periods')->getData(), true, 512, JSON_THROW_ON_ERROR); $assignPeriodIds = json_decode($assignForm->get('periods')->getData(), true, 512, JSON_THROW_ON_ERROR);
/** @var User $userTo */
$userTo = $assignForm->get('userTo')->getData(); $userTo = $assignForm->get('userTo')->getData();
$userFrom = $assignForm->get('userFrom')->getData(); $userFrom = $assignForm->get('userFrom')->getData();
@ -131,6 +132,10 @@ class ReassignAccompanyingPeriodController extends AbstractController
if ($period->getUser() === $userFrom) { if ($period->getUser() === $userFrom) {
$period->setUser($userTo, true); $period->setUser($userTo, true);
if (null !== $userTo->getUserJob() && $period->getJob() !== $userTo->getUserJob()) {
$period->setJob($userTo->getUserJob());
}
} }
} }