src/Controller/EspaceParent/EspaceParentController.php line 53

Open in your IDE?
  1. <?php
  2. namespace App\Controller\EspaceParent;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use App\Manager\PaiementManager;
  8. use App\Entity\Commande;
  9. use App\Entity\Compta;
  10. use App\Entity\ContactForFamilleAccueil;
  11. use App\Entity\TiersDeConfiance;
  12. use App\Entity\ContactPropertyValue;
  13. use App\Entity\FrontOption;
  14. use App\Entity\MessageParent;
  15. use App\Entity\Inscription;
  16. use App\Entity\Media;
  17. use App\Entity\Metier;
  18. use App\Entity\Property;
  19. use App\Entity\SejourSession;
  20. use App\Entity\SejourSessionEquipier;
  21. use App\Factory\ParentFactory;
  22. use App\Form\ContactForFamilleAccueilType;
  23. use App\Form\ContactPropertyValueType;
  24. use App\Form\MessageParentType;
  25. use App\Form\MissingPropertyType;
  26. use App\Form\ParentContactType;
  27. use App\Form\TiersDeConfianceType;
  28. use App\Frontend\Controller\TiersDeConfianceController;
  29. use App\Manager\DocumentManager;
  30. use App\Manager\PropertyManager;
  31. use App\Message\SendEmailMessage;
  32. use Doctrine\ORM\EntityManagerInterface;
  33. use App\Repository\ContactRepository;
  34. use App\Repository\InscriptionRepository;
  35. use App\Repository\SejourSessionRepository;
  36. use App\Utility\InscriptionUpdater;
  37. use App\Utility\PropertyAndMediaUpdater;
  38. use Doctrine\ORM\EntityManager;
  39. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  40. use Symfony\Component\HttpFoundation\JsonResponse;
  41. use Symfony\Component\Messenger\MessageBusInterface;
  42. use Symfony\Component\Validator\Validator\ValidatorInterface;
  43. use App\Form\PropertyCollectionType;
  44. class EspaceParentController extends AbstractController
  45. {
  46. /**
  47. * @Route("/espace-parent", name="espace_parent")
  48. * @Route("/espace-parent/tab_{tab}", name="espace_parent_tab")
  49. */
  50. public function index(
  51. PaiementManager $pm,
  52. EntityManagerInterface $em,
  53. DocumentManager $dm,
  54. PropertyManager $prm,
  55. Request $request,
  56. $tab = null
  57. ): Response {
  58. $error = [];
  59. $parent = $this->getUser()->getContact();
  60. $enfants = $parent->getChildren();
  61. $profilIncomplet = false;
  62. foreach ($parent->getContactPropertyValues() as $prop) {
  63. if ($prop->getProperty()->getIsMandatory() && $prop->getValue() == null && $profilIncomplet == false) {
  64. $profilIncomplet = true;
  65. $error[] = ['votre profil est incomplet: ' . $prop->getProperty()->getName(), 'action' => ['name' => 'completer vos informations', 'lien' => 'toutou']];
  66. }
  67. }
  68. if ($parent->getLocation() == null) {
  69. $error[] = ['votre profil est incomplet', 'action' => ['name' => 'completer vos informations', 'lien' => 'toutou']];
  70. }
  71. foreach ($enfants as $enfant) {
  72. $profilIncomplet = false;
  73. foreach ($enfant->getContactPropertyValues() as $prop) {
  74. $profilIncomplet = false;
  75. if ($prop->getProperty()->getIsMandatory() && $prop->getValue() == null && $profilIncomplet == false) {
  76. $profilIncomplet = true;
  77. $error[] = ['le profil de ' . $enfant->getFirstName() . ' est incomplet', 'action' => ['name' => 'completer vos informations', 'lien' => 'toutou']];
  78. }
  79. }
  80. }
  81. $documentsManquants = [];
  82. $hasMissing = false;
  83. $resas = $this->getUser()->getContact()->getInscriptionParents();
  84. $commandes = $em->getRepository(Commande::class)->retrieveCommandesFromContact($this->getUser()->getContact());
  85. $now = new \Datetime();
  86. $isOpen = [];
  87. $paiementOverview = [];
  88. $paiementDone = [];
  89. // foreach ($resas as $resa) {
  90. // if ($resa->getSejourSession()->getDateDebut() > $now && ($resa->getStatut() !== Inscription::CANCELLED || $resa->getStatut() !== null)) {
  91. // $resa = $dm->hasInscriptionAllMandatoryDocumentation($resa);
  92. // $resa = $prm->hasInscriptionAllMandatoryProperty($resa);
  93. // $em->refresh($resa);
  94. // }
  95. // }
  96. foreach ($commandes as $commande) {
  97. $em->refresh($commande);
  98. if ($commande->getStatut() !== Compta::STATUT_COMPLETE && $commande->getStatut() !== Commande::STATUT_CANCELLED && $commande->getStatut() !== Commande::STATUT_TO_BE_DELETED) {
  99. $paiementOverview[$commande->getId()]['commande'] = $commande;
  100. $paiementOverview[$commande->getId()]['paiement'] = [];
  101. foreach ($commande->getCompta() as $compta) {
  102. $paiementOverview[$commande->getId()]['paiement'] = [
  103. $commande->getPaiementOverview()
  104. ];
  105. }
  106. }
  107. if ($commande->getStatut() == Compta::STATUT_COMPLETE) {
  108. $paiementDone[$commande->getId()]['commande'] = $commande;
  109. $paiementDone[$commande->getId()]['paiement'] = [];
  110. foreach ($commande->getCompta() as $compta) {
  111. $paiementDone[$commande->getId()]['paiement'] = [
  112. $commande->getPaiementOverview()
  113. ];
  114. }
  115. }
  116. }
  117. $infosManquantes = [];
  118. foreach ($resas as $resa) {
  119. $em->refresh($resa);
  120. if ($resa->getSejourSession()->getDateDebut() > $now && ($resa->getStatut() !== null && $resa->getStatut() !== Inscription::CANCELLED)) {
  121. $resa = $dm->hasInscriptionAllMandatoryDocumentation($resa);
  122. $resa = $prm->hasInscriptionAllMandatoryProperty($resa);
  123. $dm->removeDoubleMedia($resa);
  124. $documentsManquants[] = ['documents' => $dm->listMissingDocFromInscription($resa, false), 'resa' => $resa, 'incomplete' => false];
  125. if (count($prm->listMissingPropertyFromInscription($resa)) > 0) {
  126. $infosManquantes = array_merge($infosManquantes, $prm->listMissingPropertyFromInscription($resa));
  127. foreach ($documentsManquants as $key => $missingDoc) {
  128. if ($missingDoc['resa'] == $resa) {
  129. $documentsManquants[$key]['incomplete'] = true;
  130. $hasMissing = true;
  131. }
  132. }
  133. }
  134. }
  135. }
  136. $enquete = $em->getRepository(FrontOption::class)->findOneBy(['name' => 'lienEnquete']);
  137. return $this->render('espace_parent/index.html.twig', [
  138. 'hasMissing' => $hasMissing,
  139. 'paiementOverview' => $paiementOverview,
  140. 'documentManquants' => $documentsManquants,
  141. 'infosManquantes' => $infosManquantes,
  142. 'lienEnquete' => $enquete,
  143. 'paiementDone' => $paiementDone,
  144. 'tab' => $tab ?? $request->get('tab')
  145. ]);
  146. }
  147. /**
  148. * @Route("/espace-parent/validationContactFamilleAccueil/{id}", name="espace_parent_validation_contact_famille_accueil")
  149. */
  150. public function contactFamilleAccueil(ContactForFamilleAccueil $cffa, EntityManagerInterface $em, Request $request)
  151. {
  152. $form = $this->createForm(ContactForFamilleAccueilType::class, $cffa);
  153. $form->handleRequest($request);
  154. if ($form->isSubmitted() && $form->isValid()) {
  155. $em->persist($cffa);
  156. $em->flush();
  157. return $this->redirectToRoute('espace_parent');
  158. }
  159. return $this->render(
  160. 'espace_parent/contactAccueil.html.twig',
  161. [
  162. 'form' => $form->createView(),
  163. 'cffa' => $cffa
  164. ]
  165. );
  166. }
  167. /**
  168. * @Route("/espace-parent/uploadDoc/{id}", name="espace_parent_upload_doc")
  169. * @Route("/espace-candidature/uploadDoc/{id}", name="espace_candidature_upload_doc")
  170. */
  171. public function uploadDoc(Request $request, int $id, EntityManagerInterface $em, ValidatorInterface $vi)
  172. {
  173. $media = $em->getRepository(Media::class)->findOneById($id);
  174. $params = $this->getRefererParams($request);
  175. $this->denyAccessUnlessGranted('POST_VIEW', $media);
  176. if ($media->getInscription() !== null && $media->getInscription()->getStatut() == Inscription::CANCELLED) {
  177. $this->addFlash('danger', 'Le fichier ne correspond pas au format demandé (' . implode(",", $media->getMediaCategorie()->getAllowedFormat()) . ")");
  178. return new jsonResponse('Format non valide');
  179. }
  180. $parent = $media;
  181. foreach ($request->files as $file) {
  182. if (!$media->setPrivateFile($file)) {
  183. $this->addFlash('danger', 'Le fichier ne correspond pas au format demandé (' . implode(",", $media->getMediaCategorie()->getAllowedFormat()) . ")");
  184. return new jsonResponse('Format non valide');
  185. }
  186. if ($media->getMediaCategorie()->getName() == 'Photo') {
  187. $contact = $media->getContact();
  188. $this->convertAndSaveToBMP($file, $contact);
  189. }
  190. $media->setIsValidated(false);
  191. $em->persist($media);
  192. $media->setUpdatedDate(new \Datetime());
  193. $media = (new Media())->setMediaParent($parent)->setMediaCategorie($parent->getMediaCategorie());
  194. if ($media->getMediaCategorie()->getIsPrivate()) {
  195. $media->setPrivateFile($media->getImgFile());
  196. $media->setImgFile(null);
  197. }
  198. }
  199. $em->flush();
  200. return new jsonResponse('OK');
  201. if (array_key_exists('id', $params)) {
  202. return $this->redirect($this->generateUrl($params['_route'], ['id' => $params['id']]));
  203. }
  204. return $this->redirect($this->generateUrl($params['_route'], ['tab' => "dossier"]));
  205. }
  206. private function convertAndSaveToBMP($file, $contact)
  207. {
  208. $tempFilePath = $file->getPathname();
  209. $uploadDirectory = $this->getParameter('kernel.project_dir') . '/public/bmp/';
  210. if (!is_dir($uploadDirectory)) {
  211. mkdir($uploadDirectory, 0777, true);
  212. }
  213. // Retrieve ID, prenom, and nom from media's contact
  214. $id = $contact->getId();
  215. $prenom = $contact ? $contact->getFirstName() : 'unknown';
  216. $nom = $contact ? $contact->getLastName() : 'unknown';
  217. // Sanitize prenom and nom to avoid illegal filename characters
  218. $prenom = preg_replace('/[^a-zA-Z0-9_-]/', '', $prenom);
  219. $nom = preg_replace('/[^a-zA-Z0-9_-]/', '', $nom);
  220. $newFileName = sprintf('%d-%s-%s.bmp', $id, $prenom, $nom);
  221. $newFilePath = $uploadDirectory . $newFileName;
  222. $image = imagecreatefromstring(file_get_contents($tempFilePath));
  223. if ($image !== false) {
  224. if (function_exists('imagebmp')) {
  225. imagebmp($image, $newFilePath);
  226. } else {
  227. // If BMP is not supported, fall back to PNG format
  228. $newFilePath = str_replace('.bmp', '.png', $newFilePath);
  229. imagepng($image, $newFilePath);
  230. }
  231. imagedestroy($image);
  232. } else {
  233. $this->addFlash('danger', 'Erreur lors de la conversion de l\'image en BMP ou PNG.');
  234. }
  235. }
  236. /**
  237. * @Route("/espace-parent/deleteDoc/{id}", name="espace_parent_delete_doc", methods={"DELETE"})
  238. * @Route("/espace-candidature/deleteDoc/{id}", name="espace_candidature_delete_doc", methods={"DELETE"})
  239. */
  240. public function removeFile(int $id, EntityManagerInterface $em): JsonResponse
  241. {
  242. $media = $em->getRepository(Media::class)->findOneById($id);
  243. if (!$media) {
  244. return new JsonResponse(['error' => 'Fichier non trouvé.'], 404);
  245. }
  246. $this->denyAccessUnlessGranted('POST_VIEW', $media);
  247. try {
  248. unlink($media->getFilePath());
  249. $media->setFilePath(null);
  250. $em->persist($media);
  251. $em->flush();
  252. return new JsonResponse(['message' => 'Fichier supprimé avec succès.'], 200);
  253. } catch (\Exception $e) {
  254. return new JsonResponse(['error' => 'Une erreur est survenue lors de la suppression du fichier.'], 500);
  255. }
  256. }
  257. /**
  258. * @Route("/espace-parent/infoManquantes",name="espace_parent_missing_properties")
  259. */
  260. public function missingProperties(PropertyManager $prm, Request $request)
  261. {
  262. $infosManquantes = [];
  263. $resas = $this->getUser()->getContact()->getInscriptionParents();
  264. foreach ($resas as $resa) {
  265. $infosManquantes = array_merge($infosManquantes, $prm->listMissingPropertyFromInscription($resa));
  266. }
  267. $form = $this->createForm(MissingPropertyType::class, null, ['missingProperties' => $infosManquantes]);
  268. $form->handleRequest($request);
  269. if ($form->isSubmitted() and $form->isValid()) {
  270. $response = $form->getData();
  271. //TODO: voters
  272. $this->getDoctrine()->getManager()->flush();
  273. return $this->redirectToRoute('espace_parent');
  274. }
  275. return $this->render('espace_parent/informationsManquantes.html.twig', ['missingProperties' => $infosManquantes, 'form' => $form->createView()]);
  276. }
  277. //regarder si pas le passer en trait.
  278. private function getRefererParams(Request $request)
  279. {
  280. $referer = $request->headers->get('referer');
  281. $baseUrl = $request->getSchemeAndHttpHost();
  282. $lastPath = substr($referer, strpos($referer, $baseUrl) + strlen($baseUrl));
  283. return $this->get('router')->getMatcher()->match(substr($lastPath, 0, strpos($lastPath, '?')));
  284. }
  285. /**
  286. * @Route("/espace-parent/photosSejour/{id}", name="espace_parent_photos_sejour")
  287. */
  288. public function photoSejours(EntityManagerInterface $em, SejourSession $sejourSession)
  289. {
  290. $this->denyAccessUnlessGranted('POST_VIEW', $sejourSession);
  291. return $this->render('espace_parent/photosSejour.html.twig', ['sejourSession' => $sejourSession]);
  292. }
  293. /**
  294. * @Route("/espace-parent/messagesDirecteur/{id}", name="espace_parent_message_directeur")
  295. */
  296. public function messagesDirecteurs(EntityManagerInterface $em, SejourSession $sejourSession)
  297. {
  298. $this->denyAccessUnlessGranted('POST_VIEW', $sejourSession);
  299. return $this->render('espace_parent/messageDirecteur.html.twig', ['sejourSession' => $sejourSession]);
  300. }
  301. /**
  302. * @Route("/espace-parent/info/modifier/{id}",name="espace_parent_modify_property")
  303. */
  304. public function modifyProperty(EntityManagerInterface $em, $id, Request $request, InscriptionUpdater $inscriptionUpdater)
  305. {
  306. $property = $em->getRepository(ContactPropertyValue::class)->findOneById($id);
  307. $enfant = $property->getContact();
  308. $this->denyAccessUnlessGranted('view', $enfant);
  309. $form = $this->createForm(ContactPropertyValueType::class, $property);
  310. //$form->add('Sauver', SubmitType::class, ['attr' => ['class' => 'button bounce item-sejour__button'],'label'=>'Enregistrer et Sauver']);
  311. $form->handleRequest($request);
  312. if ($form->isSubmitted() and $form->isValid()) {
  313. $em->persist($property);
  314. $em->flush();
  315. $inscriptionUpdater->updateInscription($property);
  316. return new JsonResponse(['id' => $id]);
  317. }
  318. if ($form->isSubmitted() and !$form->isValid()) {
  319. $vcString = $property->getProperty()->getValidationClass();
  320. if ($vcString !== null) {
  321. $vc = new $vcString();
  322. return new JsonResponse(['error' => $vc->getErrorMessage()]);
  323. }
  324. }
  325. return $this->render('frontend/simpleForm.html.twig', ['form' => $form->createView(), 'pageTitle' => 'Mise à jour information']);
  326. }
  327. /**
  328. * @Route("/espace-parent/equipe-peda/{id}",name="espace_parent_equipe_peda")
  329. */
  330. public function equipePeda(SejourSessionRepository $ssrp, int $id)
  331. {
  332. $sejourSession = $ssrp->findOneById($id);
  333. $equipiers = $sejourSession->getSejourSessionEquipiers();
  334. return $this->render('espace_parent/equipe_peda.html.twig', [
  335. 'sejourSession' => $sejourSession,
  336. 'equipiers' => $equipiers
  337. ]);
  338. }
  339. /**
  340. * @Route("/espace-parent/messageEnfant/{id}", name="espace_parent_message")
  341. */
  342. public function MessageEnfant(EntityManagerInterface $em, $id, Request $request, MessageBusInterface $bus)
  343. {
  344. $inscription = $em->getRepository(Inscription::class)->findOneBy([
  345. 'id' => $id,
  346. 'parent' => $this->getUser()->getContact()
  347. ]);
  348. $messageParent = new MessageParent();
  349. $messageParent->setSejourSession($inscription->getSejourSession());
  350. $messageParent->setEnfant($inscription->getEnfant()->getFirstName() . " " . $inscription->getEnfant()->getLastName());
  351. $messageParent->setEmail($this->getUser()->getEmail());
  352. $messageParent->setParent($this->getUser()->getContact()->getFirstName() . " " . $this->getUser()->getContact()->getLastName());
  353. $messageParent->setIsValid(true);
  354. $form = $this->createForm(MessageParentType::class, $messageParent);
  355. $form->handleRequest($request);
  356. if ($form->isSubmitted() and $form->isValid()) {
  357. $em->persist($messageParent);
  358. $em->flush();
  359. $directeur = $em->getRepository(Metier::class)->findOneByName("Directeur");
  360. $contact = $em->getRepository(SejourSessionEquipier::class)->findOneBy(
  361. [
  362. 'metier' => $directeur,
  363. 'sejourSession' => $inscription->getSejourSession()
  364. ]
  365. );
  366. $this->addFlash('success', 'votre message est bien envoyé');
  367. $bus->dispatch((new SendEmailMessage('email_parents', '', $messageParent->getId(), $contact->getContact()->getEmail())));
  368. //TODO: message au directeurs.
  369. return $this->redirectToRoute("espace_parent");
  370. }
  371. return $this->render('frontend/form.html.twig', ['form' => $form->createView(), 'pageTitle' => 'Message à mon enfant']);
  372. }
  373. /**
  374. * @Route("/espace-parent/vueProfilEnfant/{id}", name="espace_parent_enfant")
  375. * @Route("/espace-candidat/vueProfil", name="espace_candidature_modify")
  376. */
  377. public function ProfilEnfant(ContactRepository $cp, EntityManagerInterface $em, Request $request, $id = null)
  378. {
  379. $mandatoryPropertiesEnfant = $em->getRepository(Property::class)->findBy([
  380. 'type' => 'enfant',
  381. 'isFactory' => true
  382. ]);
  383. //TODO: voters pour voir si a droit de voir l'enfant
  384. if ($id !== null) {
  385. $isEnfant = true;
  386. $enfant = $cp->findOneById($id);
  387. $this->denyAccessUnlessGranted('view', $enfant);
  388. $params = $this->getRefererParams($request);
  389. foreach ($mandatoryPropertiesEnfant as $property) {
  390. $cpv = $em->getRepository(ContactPropertyValue::class)->findBy([
  391. 'property' => $property,
  392. 'contact' => $enfant
  393. ]);
  394. if ($cpv == null) {
  395. $newCpv = new ContactPropertyValue();
  396. $newCpv->setContact($enfant);
  397. $newCpv->setProperty($property);
  398. $newCpv->setValue($property->getDefault());
  399. $em->persist($newCpv);
  400. $enfant->addContactPropertyValue($newCpv);
  401. }
  402. }
  403. $filesEnfant = $em->getRepository(Media::class)->findBy(['contact' => $enfant]);
  404. } else {
  405. $isEnfant = false;
  406. $enfant = $this->getUser()->getContact();
  407. $filesEnfant = $em->getRepository(Media::class)->findCandidaturesFiles($enfant);
  408. }
  409. $form = $this->createForm(PropertyCollectionType::class, $enfant, array('csrf_protection' => false));
  410. $form->handleRequest($request);
  411. if ($form->isSubmitted() and $form->isValid()) {
  412. $em->flush();
  413. $this->addFlash('success', 'Informations modifiées');
  414. if ($id !== null)
  415. return $this->redirectToRoute("espace_parent", ['tab' => 'dossier']);
  416. }
  417. $em->flush();
  418. return $this->render(
  419. 'espace_parent/profil_enfant.html.twig',
  420. [
  421. 'enfant' => $enfant,
  422. 'documents' => $filesEnfant,
  423. 'referer' => $request->headers->get('referer'),
  424. 'isEnfant' => $isEnfant,
  425. 'form' => $form->createView(),
  426. ]
  427. );
  428. }
  429. /**
  430. * @Route("/espace-parent/ajoutTiersDeConfiance/{id}", name="ajout-tiers-de-confiance")
  431. */
  432. public function addTiersDeConfiance(EntityManagerInterface $em, ParentFactory $pf, Request $request, $id)
  433. {
  434. $inscription = $em->getRepository(Inscription::class)->findOneById($id);
  435. $this->denyAccessUnlessGranted('POST_VIEW', $inscription);
  436. $tdc = new TiersDeConfiance();
  437. $tdc->setInscription($inscription);
  438. $tdc->setMain($this->getUser()->getContact());
  439. $contact = $pf->createContact();
  440. $tdc->setTiers($contact);
  441. foreach ($contact->getContactPropertyValues() as $cpv) {
  442. $em->persist($cpv->getProperty());
  443. $em->persist($cpv);
  444. }
  445. $em->persist($tdc->getTiers());
  446. $em->flush();
  447. $form = $this->createForm(TiersDeConfianceType::class, $tdc);
  448. $form->get('tiers')->remove('certif');
  449. $form->handleRequest($request);
  450. if ($form->isSubmitted() and $form->isValid()) {
  451. $em->persist($tdc);
  452. $em->flush();
  453. $this->addFlash('success', 'ajout d\'un tiers de confiance effectué');
  454. return $this->redirectToRoute('espace_parent');
  455. }
  456. return $this->render('espace_parent/tiersDeConfiance.html.twig', ['form' => $form->createView()]);
  457. }
  458. /**
  459. * @Route("espace-parent/mes-informations", name="espace-parent_mes-informations")
  460. */
  461. public function mesInformations(Request $request, EntityManagerInterface $em)
  462. {
  463. $form = $this->createForm(ParentContactType::class, $this->getUser()->getContact());
  464. $form->remove('certif');
  465. $form->add('valider', SubmitType::class, ['attr' => ['class' => 'btn btn-primary bounce small-spacing-before']]);
  466. $form->handleRequest($request);
  467. if ($form->isSubmitted() and $form->isValid()) {
  468. $em->flush();
  469. $this->addFlash('success', 'Informations modifiées');
  470. return $this->redirectToRoute('espace_parent');
  471. }
  472. return $this->render('frontend/form.html.twig', ['form' => $form->createView(), 'pageTitle' => 'mes Coordonnées']);
  473. }
  474. /**
  475. * @Route("/espace-parent/modifier-profil-enfant/{id}", name="espace-parent_enfant_edit")
  476. */
  477. public function modifyProfilEnfant(PropertyManager $prm, Request $request, int $id, ContactRepository $cp, EntityManagerInterface $em)
  478. {
  479. $enfant = $cp->findOneById($id);
  480. $this->denyAccessUnlessGranted('view', $enfant);
  481. $allProperties = $em->getRepository(ContactPropertyValue::class)->findBy([
  482. 'contact' => $enfant
  483. ]);
  484. $form = $this->createForm(MissingPropertyType::class, null, ['missingProperties' => [$allProperties]]);
  485. $form->handleRequest($request);
  486. if ($form->isSubmitted() and $form->isValid()) {
  487. $response = $form->getData();
  488. //TODO: voters
  489. $this->getDoctrine()->getManager()->flush();
  490. return $this->redirectToRoute('espace_parent');
  491. }
  492. return $this->render('espace_parent/informationsManquantes.html.twig', ['missingProperties' => $allProperties, 'form' => $form->createView()]);
  493. }
  494. /**
  495. * @Route("espace-parent/responsable/{id}", name="contact_edit")
  496. */
  497. public function responsableEdit(Request $request, EntityManagerInterface $em, int $id, ContactRepository $cp)
  498. {
  499. $responsable = $cp->findOneById($id);
  500. $form = $this->createForm(ParentContactType::class, $responsable);
  501. $form->remove('certif');
  502. $form->add('valider', SubmitType::class, ['attr' => ['class' => 'btn btn-primary bounce small-spacing-before']]);
  503. $form->handleRequest($request);
  504. if ($form->isSubmitted() and $form->isValid()) {
  505. $em->flush();
  506. $this->addFlash('success', 'Informations modifiées');
  507. return $this->redirectToRoute('espace_parent');
  508. }
  509. return $this->render('frontend/form.html.twig', ['form' => $form->createView(), 'pageTitle' => 'mes Coordonnées']);
  510. }
  511. /**
  512. * @Route("/espace-parent/oldSejours",name="espace-parent_old-sejours")
  513. */
  514. public function oldSejours(InscriptionRepository $inscriptionRepo, EntityManagerInterface $em): Response
  515. {
  516. $inscriptions = $inscriptionRepo->findOld($this->getUser());
  517. $enquete = $em->getRepository(FrontOption::class)->findOneBy(['name' => 'lienEnquete']);
  518. return $this->render('espace_parent/old_sejours.html.twig', [
  519. 'inscriptions' => $inscriptions,
  520. 'lienEnquete' => $enquete
  521. ]);
  522. }
  523. }