src/Controller/ChildsController.php line 243

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Childs
  4. use App\Form\ChildsFormType;
  5. use App\Repository\ChildsRepository;
  6. use App\Repository\SessionsRepository;
  7. use Doctrine\ORM\EntityManagerInterface;
  8. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\HttpFoundation\Request;
  11. use Symfony\Component\Routing\Annotation\Route;
  12. use Symfony\Component\Validator\Validator\ValidatorInterface;
  13. use Symfony\Component\Security\Core\Security;
  14. use Knp\Component\Pager\PaginatorInterface;
  15. use Symfony\Component\Mailer\MailerInterface;
  16. use Symfony\Component\Mime\Email;
  17. use Monolog\DateTimeImmutable;
  18. class ChildsController extends AbstractController
  19. {
  20.     private $em;
  21.     private $childsRepository;
  22.     private $security;
  23.     public function __construct(ChildsRepository $childsRepositoryEntityManagerInterface $emSecurity $securitySessionsRepository $sessionsRepository)
  24.     {
  25.         $this->childsRepository $childsRepository;
  26.         $this->sessionsRepository $sessionsRepository;
  27.         $this->em $em;
  28.         $this->security $security;
  29.     }
  30.     #[Route('/childs'name'app_childs')]
  31.     public function index(Request $requestPaginatorInterface $paginator): Response
  32.     {
  33.         $current_user $this->security->getUser(); 
  34.         $assigned_childs = array();
  35.         foreach ($current_user->getChilds() as $value) {
  36.             $assigned_childs[] = $value;
  37.         }  
  38.         $filter         $request->query->get('filter');
  39.         $status         $request->query->get('status');
  40.         $search_term    $request->query->get('q');
  41.         //if( !empty($assigned_childs) ){
  42.         if( isset($current_user->getRoles()[0]) && $current_user->getRoles()[0] == 'ROLE_STAKEHOLDER' ){
  43.             
  44.             $queryBuilder $this->childsRepository->findByUser($current_user->getId(), $filter$search_term$status);
  45.         }else{ 
  46.             if( !empty($filter) ){
  47.                 $queryBuilder $this->childsRepository->findAllFilter($filter$search_term$status);
  48.             }else{ 
  49.                 $queryBuilder $this->childsRepository->findAll($search_term$status);
  50.             }
  51.         } 
  52.         
  53.         $pagination $paginator->paginate(
  54.             $queryBuilder/* query NOT result */
  55.             $request->query->getInt('page'1)/*page number*/,
  56.             10/*limit per page*/
  57.         );
  58.         return $this->render('childs/index.html.twig', [
  59.             'pagination'    => $pagination,
  60.             'filter'        => $filter,
  61.             'status'        => $status,
  62.             'search_term'   => $search_term,
  63.         ]);
  64.     }
  65.     #[Route('/notcheck'name'app_notcheck')]
  66.     public function notcheck(Request $requestPaginatorInterface $paginator): Response
  67.     {
  68.         $current_user $this->security->getUser(); 
  69.         $assigned_childs = array();
  70.         foreach ($current_user->getChilds() as $value) {
  71.             $assigned_childs[] = $value;
  72.         }  
  73.         $filter         $request->query->get('filter');
  74.         $status         $request->query->get('status');
  75.         $search_term    $request->query->get('q');
  76.         //if( !empty($assigned_childs) ){
  77.         if( isset($current_user->getRoles()[0]) && $current_user->getRoles()[0] == 'ROLE_STAKEHOLDER' ){
  78.             
  79.             return $this->redirectToRoute('app_childs');
  80.         }else{ 
  81.             if( !empty($filter) ){
  82.                 $queryBuilder $this->childsRepository->findAllFilter($filter$search_term$status);
  83.             }else{ 
  84.                 $queryBuilder $this->childsRepository->findAllNotCheck($search_term$status);
  85.             }
  86.         } 
  87.         
  88.         $pagination $paginator->paginate(
  89.             $queryBuilder/* query NOT result */
  90.             $request->query->getInt('page'1)/*page number*/,
  91.             10/*limit per page*/
  92.         );
  93.         return $this->render('childs/notcheck.html.twig', [
  94.             'pagination'    => $pagination,
  95.             'filter'        => $filter,
  96.             'status'        => $status,
  97.             'search_term'   => $search_term,
  98.         ]);
  99.     }
  100.     #[Route('/childs/create'name'create_childs')]
  101.     public function create(Request $request): Response
  102.     
  103.         $childs = new Childs();
  104.         $form $this->createForm(ChildsFormType::class, $childs);
  105.         
  106.         $form->handleRequest($request);
  107.         if ( $form->isSubmitted() && $form->isValid() ) {
  108.             $newChilds $form->getData(); 
  109.             $imagePath $form->get('image')->getData();
  110.             $fileone $form->get('fileone')->getData();
  111.             $filetwo $form->get('filetwo')->getData();
  112.             $filethree $form->get('filethree')->getData();
  113.             if( $imagePath ){
  114.                 $newFileName uniqid() . '.' $imagePath->guessExtension();
  115.                 try {
  116.                     $imagePath->move(
  117.                         $this->getParameter('kernel.project_dir') . '/public/uploads',
  118.                         $newFileName
  119.                     );
  120.                 } catch (FileException $e) {
  121.                     return new Response($e->getMessage());
  122.                 }
  123.                 $newChilds->setImage('uploads/' $newFileName);
  124.             }
  125.             if( $fileone ){
  126.                 $fileone_path = array(); 
  127.                 foreach( $fileone as $fileone_single ){ 
  128.                     $fileonename uniqid() . '.' $fileone_single->guessExtension();
  129.                     try {
  130.                         $fileone_single->move(
  131.                             $this->getParameter('kernel.project_dir') . '/public/uploads/childfiles',
  132.                             $fileonename
  133.                         );
  134.                     } catch (FileException $e) {
  135.                         return new Response($e->getMessage());
  136.                     }
  137.                     $fileone_path[] = 'uploads/childfiles/' $fileonename;
  138.                 } 
  139.                 
  140.                 $newChilds->setFileone($fileone_path);
  141.             }
  142.             if( $filetwo ){
  143.                 $filetwo_path = array(); 
  144.                 foreach( $filetwo as $filetwo_single ){ 
  145.                     $filetwoname uniqid() . '.' $filetwo_single->guessExtension();
  146.                     try {
  147.                         $filetwo_single->move(
  148.                             $this->getParameter('kernel.project_dir') . '/public/uploads/childfiles',
  149.                             $filetwoname
  150.                         );
  151.                     } catch (FileException $e) {
  152.                         return new Response($e->getMessage());
  153.                     }
  154.                     $filetwo_path[] = 'uploads/childfiles/' $filetwoname;
  155.                 } 
  156.                 
  157.                 $newChilds->setFiletwo($filetwo_path);
  158.             }
  159.             if( $filethree ){
  160.                 $filethree_path = array(); 
  161.                 foreach( $filethree as $filethree_single ){ 
  162.                     $filethreename uniqid() . '.' $filethree_single->guessExtension();
  163.                     try {
  164.                         $filethree_single->move(
  165.                             $this->getParameter('kernel.project_dir') . '/public/uploads/childfiles',
  166.                             $filethreename
  167.                         );
  168.                     } catch (FileException $e) {
  169.                         return new Response($e->getMessage());
  170.                     }
  171.                     $filethree_path[] = 'uploads/childfiles/' $filethreename;
  172.                 } 
  173.                 
  174.                 $newChilds->setFilethree($filethree_path);
  175.             }
  176.             $current_datetime = new DateTimeImmutable('now');
  177.             $newChilds->setCreationdate($current_datetime);
  178.             $newChilds->setSessionsemail(0);
  179.             $this->em->persist($newChilds);
  180.             $this->em->flush();
  181.             return $this->redirectToRoute('childs');
  182.         }
  183.         return $this->render('childs/create.html.twig', [
  184.             'form' => $form->createView()
  185.         ]);
  186.     }
  187.     // For without login
  188.     #[Route('/childs/inscription'name'inscription_childs')]
  189.     public function inscription(Request $request): Response
  190.     
  191.         $childs = new Childs();
  192.         $form $this->createForm(ChildsFormType::class, $childs);
  193.         
  194.         $form->handleRequest($request);
  195.         if ( $form->isSubmitted() && $form->isValid() ) {
  196.             $newChilds $form->getData(); 
  197.             $imagePath $form->get('image')->getData();
  198.             $fileone $form->get('fileone')->getData();
  199.             $filetwo $form->get('filetwo')->getData();
  200.             $filethree $form->get('filethree')->getData();
  201.             if( $imagePath ){
  202.                 $newFileName uniqid() . '.' $imagePath->guessExtension();
  203.                 try {
  204.                     $imagePath->move(
  205.                         $this->getParameter('kernel.project_dir') . '/public/uploads',
  206.                         $newFileName
  207.                     );
  208.                 } catch (FileException $e) {
  209.                     return new Response($e->getMessage());
  210.                 }
  211.                 $newChilds->setImage('uploads/' $newFileName);
  212.             }
  213.             if( $fileone ){
  214.                 $fileone_path = array(); 
  215.                 foreach( $fileone as $fileone_single ){ 
  216.                     $fileonename uniqid() . '.' $fileone_single->guessExtension();
  217.                     try {
  218.                         $fileone_single->move(
  219.                             $this->getParameter('kernel.project_dir') . '/public/uploads/childfiles',
  220.                             $fileonename
  221.                         );
  222.                     } catch (FileException $e) {
  223.                         return new Response($e->getMessage());
  224.                     }
  225.                     $fileone_path[] = 'uploads/childfiles/' $fileonename;
  226.                 } 
  227.                 
  228.                 $newChilds->setFileone($fileone_path);
  229.             }
  230.             if( $filetwo ){
  231.                 $filetwo_path = array(); 
  232.                 foreach( $filetwo as $filetwo_single ){ 
  233.                     $filetwoname uniqid() . '.' $filetwo_single->guessExtension();
  234.                     try {
  235.                         $filetwo_single->move(
  236.                             $this->getParameter('kernel.project_dir') . '/public/uploads/childfiles',
  237.                             $filetwoname
  238.                         );
  239.                     } catch (FileException $e) {
  240.                         return new Response($e->getMessage());
  241.                     }
  242.                     $filetwo_path[] = 'uploads/childfiles/' $filetwoname;
  243.                 } 
  244.                 
  245.                 $newChilds->setFiletwo($filetwo_path);
  246.             }
  247.             if( $filethree ){
  248.                 $filethree_path = array(); 
  249.                 foreach( $filethree as $filethree_single ){ 
  250.                     $filethreename uniqid() . '.' $filethree_single->guessExtension();
  251.                     try {
  252.                         $filethree_single->move(
  253.                             $this->getParameter('kernel.project_dir') . '/public/uploads/childfiles',
  254.                             $filethreename
  255.                         );
  256.                     } catch (FileException $e) {
  257.                         return new Response($e->getMessage());
  258.                     }
  259.                     $filethree_path[] = 'uploads/childfiles/' $filethreename;
  260.                 } 
  261.                 
  262.                 $newChilds->setFilethree($filethree_path);
  263.             }
  264.             $newChilds->setStatus('not_check');
  265.             $current_datetime = new DateTimeImmutable('now');
  266.             $newChilds->setCreationdate($current_datetime);
  267.             $newChilds->setSessionsemail(0);
  268.             $this->em->persist($newChilds);
  269.             $this->em->flush();
  270.             return $this->redirectToRoute('childs');
  271.         }
  272.         return $this->render('childs/inscription.html.twig', [
  273.             'form' => $form->createView()
  274.         ]);
  275.     }
  276.     #[Route('/childs/edit/{id}'name'edit_child')]
  277.     public function edit($idRequest $request): Response 
  278.     {
  279.         $child $this->childsRepository->find($id);
  280.         $current_img $child->getImage();
  281.         $oldStatus $child->getStatus(); 
  282.         $form $this->createForm(ChildsFormType::class, $child); 
  283.         $form->handleRequest($request);
  284.         $image $form->get('image')->getData(); 
  285.         $newStatus $form->get('status')->getData(); 
  286.         $fileone $form->get('fileone')->getData();
  287.         $filetwo $form->get('filetwo')->getData();
  288.         $filethree $form->get('filethree')->getData();
  289.         if ($form->isSubmitted() && $form->isValid()) {
  290.             if ($image) {
  291.                 if ($child->getImage() !== null) {
  292.                     if (file_exists(
  293.                         $this->getParameter('kernel.project_dir') . $child->getImage()
  294.                         )) {
  295.                             $this->GetParameter('kernel.project_dir') . $child->getImage();
  296.                     }
  297.                     $newFileName uniqid() . '.' $image->guessExtension();
  298.                     try {
  299.                         $image->move(
  300.                             $this->getParameter('kernel.project_dir') . '/public/uploads',
  301.                             $newFileName
  302.                         );
  303.                     } catch (FileException $e) {
  304.                         return new Response($e->getMessage());
  305.                     }
  306.                     $child->setImage('uploads/' $newFileName);
  307.                 }
  308.             } else {
  309.                 $child->setImage($current_img);
  310.             }
  311.             if( $fileone ){  
  312.                 $fileone_path = array(); 
  313.                 foreach( $fileone as $fileone_single ){  
  314.                     $fileonename uniqid() . '.' $fileone_single->guessExtension();
  315.                     try {
  316.                         $fileone_single->move(
  317.                             $this->getParameter('kernel.project_dir') . '/public/uploads/childfiles',
  318.                             $fileonename
  319.                         );
  320.                     } catch (FileException $e) {
  321.                         return new Response($e->getMessage());
  322.                     }
  323.                     $fileone_path[] = 'uploads/childfiles/' $fileonename;
  324.                 } 
  325.                 
  326.                 $child->setFileone($fileone_path);
  327.             }
  328.             if( $filetwo ){
  329.                 $filetwo_path = array(); 
  330.                 foreach( $filetwo as $filetwo_single ){ 
  331.                     $filetwoname uniqid() . '.' $filetwo_single->guessExtension();
  332.                     try {
  333.                         $filetwo_single->move(
  334.                             $this->getParameter('kernel.project_dir') . '/public/uploads/childfiles',
  335.                             $filetwoname
  336.                         );
  337.                     } catch (FileException $e) {
  338.                         return new Response($e->getMessage());
  339.                     }
  340.                     $filetwo_path[] = 'uploads/childfiles/' $filetwoname;
  341.                 } 
  342.                 
  343.                 $child->setFiletwo($filetwo_path);
  344.             }
  345.             if( $filethree ){
  346.                 $filethree_path = array(); 
  347.                 foreach( $filethree as $filethree_single ){ 
  348.                     $filethreename uniqid() . '.' $filethree_single->guessExtension();
  349.                     try {
  350.                         $filethree_single->move(
  351.                             $this->getParameter('kernel.project_dir') . '/public/uploads/childfiles',
  352.                             $filethreename
  353.                         );
  354.                     } catch (FileException $e) {
  355.                         return new Response($e->getMessage());
  356.                     }
  357.                     $filethree_path[] = 'uploads/childfiles/' $filethreename;
  358.                 } 
  359.                 
  360.                 $child->setFilethree($filethree_path);
  361.             }
  362.             // Check old status 
  363.             if( $oldStatus != 'terminé' && $newStatus == 'terminé' ){
  364.                 $finish_datetime = new DateTimeImmutable('now');
  365.                 $child->setFinishdate($finish_datetime);
  366.             }
  367.             $this->em->persist($child);
  368.             $this->em->flush();
  369.             return $this->redirectToRoute('childs');
  370.         }
  371.         return $this->render('childs/edit.html.twig', [
  372.             'child' => $child,
  373.             'form' => $form->createView()
  374.         ]);
  375.     }
  376.     #[Route('/childs/sendsessionemail'name'send_session_email')]
  377.     public function sendsessionemail(MailerInterface $mailer)
  378.     {
  379.         $childs $this->childsRepository->findExpired();
  380.         if( !empty($childs) ){
  381.             foreach($childs as $child){
  382.                 
  383.                 if( $child->getSessionsemail() == ){
  384.                     $email = (new Email())
  385.                     ->from('contact@skykeys.fr')
  386.                     ->to('rranveer4@gmail.com'
  387.                     ->subject('Rappel de saisie')
  388.                     ->html('<p>Test email</p>');
  389.                     $status $mailer->send($email);
  390.                     $email = (new Email())
  391.                     ->from('contact@skykeys.fr')
  392.                     ->to('contact@skykeys.fr'
  393.                     ->subject('Rappel de saisie')
  394.                     ->html('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><head><title>Attention ! veuillez mettre a jour le profil de cette enfant a terminer</title></head><body><meta charset="UTF-8" />
  395.                     <meta content="width=device-width, initial-scale=1" name="viewport" />
  396.                     <meta name="x-apple-disable-message-reformatting" />
  397.                     <meta content="IE=edge" http-equiv="X-UA-Compatible" />
  398.                     <meta content="telephone=no" name="format-detection" />
  399.                     <!--[if (mso 16)]>
  400.                     <style type="text/css">
  401.                     a {text-decoration: none;}
  402.                     </style>
  403.                     <![endif]--><!--[if gte mso 9]><style>sup { font-size: 100% !important; }</style><![endif]--><!--[if gte mso 9]>
  404.                     <xml>
  405.                     <o:OfficeDocumentSettings>
  406.                     <o:AllowPNG></o:AllowPNG>
  407.                     <o:PixelsPerInch>96</o:PixelsPerInch>
  408.                     </o:OfficeDocumentSettings>
  409.                     </xml>
  410.                     <![endif]-->
  411.                     <style type="text/css">
  412.                     #outlook a {
  413.                     padding:0;
  414.                     }
  415.                     .es-button {
  416.                     mso-style-priority:100!important;
  417.                     text-decoration:none!important;
  418.                     }
  419.                     a[x-apple-data-detectors] {
  420.                     color:inherit!important;
  421.                     text-decoration:none!important;
  422.                     font-size:inherit!important;
  423.                     font-family:inherit!important;
  424.                     font-weight:inherit!important;
  425.                     line-height:inherit!important;
  426.                     }
  427.                     .es-desk-hidden {
  428.                     display:none;
  429.                     float:left;
  430.                     overflow:hidden;
  431.                     width:0;
  432.                     max-height:0;
  433.                     line-height:0;
  434.                     mso-hide:all;
  435.                     }
  436.                     [data-ogsb] .es-button {
  437.                     border-width:0!important;
  438.                     padding:10px 30px 10px 30px!important;
  439.                     }
  440.                     @media only screen and (max-width:600px) {p, ul li, ol li, a { line-height:150%!important } h1, h2, h3, h1 a, h2 a, h3 a { line-height:120% } h1 { font-size:36px!important; text-align:left } h2 { font-size:26px!important; text-align:left } h3 { font-size:20px!important; text-align:left } .es-header-body h1 a, .es-content-body h1 a, .es-footer-body h1 a { font-size:36px!important; text-align:left } .es-header-body h2 a, .es-content-body h2 a, .es-footer-body h2 a { font-size:26px!important; text-align:left } .es-header-body h3 a, .es-content-body h3 a, .es-footer-body h3 a { font-size:20px!important; text-align:left } .es-menu td a { font-size:12px!important } .es-header-body p, .es-header-body ul li, .es-header-body ol li, .es-header-body a { font-size:14px!important } .es-content-body p, .es-content-body ul li, .es-content-body ol li, .es-content-body a { font-size:16px!important } .es-footer-body p, .es-footer-body ul li, .es-footer-body ol li, .es-footer-body a { font-size:14px!important } .es-infoblock p, .es-infoblock ul li, .es-infoblock ol li, .es-infoblock a { font-size:12px!important } *[class="gmail-fix"] { display:none!important } .es-m-txt-c, .es-m-txt-c h1, .es-m-txt-c h2, .es-m-txt-c h3 { text-align:center!important } .es-m-txt-r, .es-m-txt-r h1, .es-m-txt-r h2, .es-m-txt-r h3 { text-align:right!important } .es-m-txt-l, .es-m-txt-l h1, .es-m-txt-l h2, .es-m-txt-l h3 { text-align:left!important } .es-m-txt-r img, .es-m-txt-c img, .es-m-txt-l img { display:inline!important } .es-button-border { display:inline-block!important } a.es-button, button.es-button { font-size:20px!important; display:inline-block!important } .es-adaptive table, .es-left, .es-right { width:100%!important } .es-content table, .es-header table, .es-footer table, .es-content, .es-footer, .es-header { width:100%!important; max-width:600px!important } .es-adapt-td { display:block!important; width:100%!important } .adapt-img { width:100%!important; height:auto!important } .es-m-p0 { padding:0!important } .es-m-p0r { padding-right:0!important } .es-m-p0l { padding-left:0!important } .es-m-p0t { padding-top:0!important } .es-m-p0b { padding-bottom:0!important } .es-m-p20b { padding-bottom:20px!important } .es-mobile-hidden, .es-hidden { display:none!important } tr.es-desk-hidden, td.es-desk-hidden, table.es-desk-hidden { width:auto!important; overflow:visible!important; float:none!important; max-height:inherit!important; line-height:inherit!important } tr.es-desk-hidden { display:table-row!important } table.es-desk-hidden { display:table!important } td.es-desk-menu-hidden { display:table-cell!important } .es-menu td { width:1%!important } table.es-table-not-adapt, .esd-block-html table { width:auto!important } table.es-social { display:inline-block!important } table.es-social td { display:inline-block!important } .es-m-p5 { padding:5px!important } .es-m-p5t { padding-top:5px!important } .es-m-p5b { padding-bottom:5px!important } .es-m-p5r { padding-right:5px!important } .es-m-p5l { padding-left:5px!important } .es-m-p10 { padding:10px!important } .es-m-p10t { padding-top:10px!important } .es-m-p10b { padding-bottom:10px!important } .es-m-p10r { padding-right:10px!important } .es-m-p10l { padding-left:10px!important } .es-m-p15 { padding:15px!important } .es-m-p15t { padding-top:15px!important } .es-m-p15b { padding-bottom:15px!important } .es-m-p15r { padding-right:15px!important } .es-m-p15l { padding-left:15px!important } .es-m-p20 { padding:20px!important } .es-m-p20t { padding-top:20px!important } .es-m-p20r { padding-right:20px!important } .es-m-p20l { padding-left:20px!important } .es-m-p25 { padding:25px!important } .es-m-p25t { padding-top:25px!important } .es-m-p25b { padding-bottom:25px!important } .es-m-p25r { padding-right:25px!important } .es-m-p25l { padding-left:25px!important } .es-m-p30 { padding:30px!important } .es-m-p30t { padding-top:30px!important } .es-m-p30b { padding-bottom:30px!important } .es-m-p30r { padding-right:30px!important } .es-m-p30l { padding-left:30px!important } .es-m-p35 { padding:35px!important } .es-m-p35t { padding-top:35px!important } .es-m-p35b { padding-bottom:35px!important } .es-m-p35r { padding-right:35px!important } .es-m-p35l { padding-left:35px!important } .es-m-p40 { padding:40px!important } .es-m-p40t { padding-top:40px!important } .es-m-p40b { padding-bottom:40px!important } .es-m-p40r { padding-right:40px!important } .es-m-p40l { padding-left:40px!important } .es-desk-hidden { display:table-row!important; width:auto!important; overflow:visible!important; max-height:inherit!important } }</style>
  441.                     <div class="es-wrapper-color" style="background-color:#FAFAFA">
  442.                     <!--[if gte mso 9]>
  443.                     <v:background xmlns:v="urn:schemas-microsoft-com:vml" fill="t">
  444.                     <v:fill type="tile" color="#fafafa"></v:fill>
  445.                     </v:background>
  446.                     <![endif]-->
  447.                     <table cellpadding="0" cellspacing="0" class="es-wrapper" style="mso-table-lspace:0pt;mso-table-rspace:0pt;border-collapse:collapse;border-spacing:0px;padding:0;Margin:0;width:100%;height:100%;background-repeat:repeat;background-position:center top;background-color:#FAFAFA" width="100%">
  448.                     <tbody>
  449.                     <tr>
  450.                     <td style="padding:0;Margin:0" valign="top">
  451.                     <table align="center" cellpadding="0" cellspacing="0" class="es-content" style="mso-table-lspace:0pt;mso-table-rspace:0pt;border-collapse:collapse;border-spacing:0px;table-layout:fixed !important;width:100%">
  452.                     <tbody>
  453.                     <tr>
  454.                     <td align="center" style="padding:0;Margin:0">
  455.                     <table align="center" bgcolor="#ffffff" cellpadding="0" cellspacing="0" class="es-content-body" style="mso-table-lspace:0pt;mso-table-rspace:0pt;border-collapse:collapse;border-spacing:0px;background-color:#FFFFFF;width:600px">
  456.                     <tbody>
  457.                     <tr>
  458.                     <td align="left" style="Margin:0;padding-left:20px;padding-right:20px;padding-top:30px;padding-bottom:30px">
  459.                     <table cellpadding="0" cellspacing="0" style="mso-table-lspace:0pt;mso-table-rspace:0pt;border-collapse:collapse;border-spacing:0px" width="100%">
  460.                     <tbody>
  461.                     <tr>
  462.                     <td align="center" style="padding:0;Margin:0;width:560px" valign="top">
  463.                     <table cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace:0pt;mso-table-rspace:0pt;border-collapse:collapse;border-spacing:0px" width="100%">
  464.                     <tbody>
  465.                     <tr>
  466.                     <td align="center" style="padding:0;Margin:0;padding-top:10px;padding-bottom:10px;font-size:0px">
  467.                     <img alt="" height="45" src="https://suzielc.fr/wp-content/uploads/2021/11/logo2-2048x576.png" style="display:block;border:0;outline:none;text-decoration:none;-ms-interpolation-mode:bicubic" width="185" /></td>
  468.                     </tr>
  469.                     <tr>
  470.                     <td align="center" class="es-m-txt-c" style="padding:0;Margin:0;padding-bottom:10px">
  471.                     <h1 style="Margin:0;line-height:46px;mso-line-height-rule:exactly;font-family:arial, helvetica neue, helvetica, sans-serif;font-size:46px;font-style:normal;font-weight:bold;color:#333333">
  472.                     Rappel de saisie</h1>
  473.                     </td>
  474.                     </tr>
  475.                     <tr>
  476.                     <td align="center" class="es-m-p0r es-m-p0l" style="Margin:0;padding-top:5px;padding-bottom:5px;padding-left:40px;padding-right:40px">
  477.                     <p class="p1" style="margin: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 19.5px; line-height: normal; font-family: Helvetica; color: rgb(0, 0, 0);">
  478.                     <span style="font-size:16px;">Bonjour , lenfant '$child->getFirstname() .' '$child->getLastname() .' a dépasser sa date provisoire de fin de session qui été le '$child->getSessionseta()->format('Y-m-d') .'</span></p> 
  479.                     <p style="Margin:0;-webkit-text-size-adjust:none;-ms-text-size-adjust:none;mso-line-height-rule:exactly;font-family:arial, helvetica neue, helvetica, sans-serif;line-height:21px;color:#333333;font-size:14px">
  480.                     <span style="font-size:16px;">Merci de modifer son statut de <strong>En cour </strong> à <strong>Terminer</strong></span></p>
  481.                     </td>
  482.                     </tr>
  483.                     <tr>
  484.                     <td align="center" style="padding:0;Margin:0;padding-top:10px;padding-bottom:10px">
  485.                     <span class="es-button-border" style="border-style:solid;border-color:#2CB543;background:#5C68E2;border-width:0px;display:inline-block;border-radius:6px;width:auto"><a class="es-button" href="https://suzielc.com/login" style="mso-style-priority:100 !important;text-decoration:none;-webkit-text-size-adjust:none;-ms-text-size-adjust:none;mso-line-height-rule:exactly;color:#FFFFFF;font-size:20px;border-style:solid;border-color:#5C68E2;border-width:10px 30px 10px 30px;display:inline-block;background:#5C68E2;border-radius:6px;font-family:arial, helvetica neue, helvetica, sans-serif;font-weight:normal;font-style:normal;line-height:24px;width:auto;text-align:center;border-left-width:30px;border-right-width:30px" target="_blank">Connexion</a></span></td>
  486.                     </tr>
  487.                     <tr>
  488.                     <td align="center" class="es-m-p0r es-m-p0l" style="Margin:0;padding-top:5px;padding-bottom:5px;padding-left:40px;padding-right:40px">
  489.                     <p style="Margin:0;-webkit-text-size-adjust:none;-ms-text-size-adjust:none;mso-line-height-rule:exactly;font-family:arial, helvetica neue, helvetica, sans-serif;line-height:21px;color:#333333;font-size:14px">
  490.                     Cette email est confidentiel afin de garantir une total securité </p>
  491.                     </td>
  492.                     </tr>
  493.                     </tbody>
  494.                     </table>
  495.                     </td>
  496.                     </tr>
  497.                     </tbody>
  498.                     </table>
  499.                     </td>
  500.                     </tr>
  501.                     </tbody>
  502.                     </table>
  503.                     </td>
  504.                     </tr>
  505.                     </tbody>
  506.                     </table>
  507.                     </td>
  508.                     </tr>
  509.                     </tbody>
  510.                     </table>
  511.                     </div>
  512.                     <br />
  513.                     </body>');
  514.                     $status $mailer->send($email);
  515.                     $child->setSessionsemail(1);
  516.                     $this->em->persist($child);
  517.                     $this->em->flush();
  518.                 }
  519.             }
  520.         }         
  521.         exit();
  522.     }
  523.     #[Route('/childs/{id}'methods: ['GET'], name'show_childs')]
  524.     public function show($id): Response
  525.     {
  526.         $child $this->childsRepository->find($id);
  527.         $school $child->getSchool()->getName();
  528.         
  529.         return $this->render('childs/show.html.twig', [
  530.             'child' => $child,
  531.             'school' => $school
  532.         ]);
  533.     }
  534.     #[Route('/childs/delete/{id}'methods: ['GET''DELETE'], name'delete_child')]
  535.     public function delete($id): Response
  536.     {
  537.         $child $this->childsRepository->find($id);
  538.         $sessions $child->getSessions();
  539.         // Get sessions
  540.         if( !empty($sessions) ){
  541.             foreach($sessions as $session){ 
  542.                 $session $this->sessionsRepository->find($session->getId());
  543.                 $this->em->remove($session);
  544.                 $this->em->flush();
  545.             }
  546.         }  
  547.         $this->em->remove($child);
  548.         $this->em->flush();
  549.         return $this->redirectToRoute('childs');
  550.     }
  551. }