Open modal to select acpw

This commit is contained in:
2025-03-04 19:12:18 +01:00
parent 7682d81d50
commit 9e8cf60dd8
7 changed files with 79 additions and 49 deletions

View File

@@ -11,19 +11,18 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Controller;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
use Chill\PersonBundle\Form\FindAccompanyingPeriodWorkType;
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
class AccompanyingPeriodWorkDuplicateController extends AbstractController
{
public function __construct(private readonly AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository, private readonly TranslatorInterface $translator, private readonly SerializerInterface $serializer) {}
public function __construct(private readonly AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository, private readonly TranslatorInterface $translator, private readonly TranslatableStringHelperInterface $stringHelper) {}
/**
* @ParamConverter("accompanyingPeriodWork", options={"id": "acpw_id"})
@@ -35,10 +34,14 @@ class AccompanyingPeriodWorkDuplicateController extends AbstractController
$acpwList = $this->accompanyingPeriodWorkRepository->findByAccompanyingPeriod($accompanyingPeriod);
$acpwListArray = $this->serializer->normalize($acpwList, 'json', ['groups' => ['read']]);
$acpwListJson = json_encode($acpwListArray);
dump($acpwListJson);
$acpwArray = array_map(function ($acpw) {
return [
'id' => $acpw->getId(),
'socialAction' => $this->stringHelper->localize($acpw->getSocialAction()->getTitle()),
'start_date' => $acpw->getStartDate(),
'end_date' => $acpw->getEndDate(),
];
}, $acpwList);
$this->denyAccessUnlessGranted(
'CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE',
@@ -62,7 +65,7 @@ class AccompanyingPeriodWorkDuplicateController extends AbstractController
$direction = $form->get('direction')->getData();
if ('starting' === $direction) {
/* if ('starting' === $direction) {
$params = [
'acpw1_id' => $acpw->getId(),
'acpw2_id' => $acpw2->getId(),
@@ -72,14 +75,14 @@ class AccompanyingPeriodWorkDuplicateController extends AbstractController
'acpw1_id' => $acpw2->getId(),
'acpw2_id' => $acpw->getId(),
];
}
}*/
// return $this->redirectToRoute('chill_person_acpw_duplicate_confirm', $params);
}
return $this->render('@ChillPerson/AccompanyingPeriodWorkDuplicate/assign_acpw_duplicate.html.twig', [
'accompanyingCourse' => $acpw->getAccompanyingPeriod(),
'acpwListJson' => $acpwListJson,
'acpwList' => $acpwArray,
'acpw' => $acpw,
'form' => $form->createView(),
]);