src/Controller/Registration/RegistrationStudentPreRegistrationController.php line 161

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Registration;
  3. use Knp\Snappy\Pdf;
  4. use App\Entity\User;
  5. use App\Service\SMSSender;
  6. use App\Entity\SettingLevel;
  7. use App\Entity\RegistrationStudent;
  8. use Knp\Component\Pager\PaginatorInterface;
  9. use Symfony\Component\HttpFoundation\Request;
  10. use Symfony\Component\HttpFoundation\Response;
  11. use Symfony\Component\Routing\Annotation\Route;
  12. use Doctrine\Common\Collections\ArrayCollection;
  13. use App\Repository\RegistrationStudentRepository;
  14. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  15. use App\Entity\RegistrationStudentPreRegistration;
  16. use App\Repository\SchoolAssessmentByLevelRepository;
  17. use Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse;
  18. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  19. use App\Repository\RegistrationStudentPreRegistrationRepository;
  20. use App\Form\Registration\RegistrationStudentPreRegistrationType;
  21. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  22. /**
  23.  * @Route("/registration/student-pre-registration")
  24.  */
  25. class RegistrationStudentPreRegistrationController extends AbstractController
  26. {
  27.     /**
  28.      * @Route("/index", name="registration_student_pre_registration_index", methods={"GET"})
  29.      */
  30.     public function index(Request $requestPaginatorInterface $paginatorRegistrationStudentPreRegistrationRepository $registrationStudentPreRegistrationRepository): Response
  31.     {
  32.         /**@var User $user */
  33.         $user $this->getUser();
  34.         $schoolYear $user->getSchoolYear();
  35.         $establishment $user->getEstablishment();/* 
  36.         $registration_student_pre_registrations = $paginator->paginate(
  37.             $registrationStudentPreRegistrationRepository->createQueryBuilder('entity')
  38.             ->andWhere('entity.establishment = :establishment')
  39.             ->setParameter('establishment', $establishment)
  40.             ->andWhere('entity.schoolYear = :schoolYear')
  41.             ->setParameter('schoolYear', $schoolYear)
  42.             ->orderBy('entity.id', 'DESC')
  43.             ->getQuery(),
  44.             $request->query->getInt('page', 1),
  45.             1000
  46.         ); */
  47.         $waiting_for_validations = new ArrayCollection();
  48.         $waiting_for_registrations = new ArrayCollection();
  49.         $waiting_for_test = new ArrayCollection();
  50.         if ($establishment->getType() == $establishment::ESTABLISHMENT_PRESCOLAIRE_PRIMAIRE_TYPES) {
  51.             foreach ($registrationStudentPreRegistrationRepository->findBy(['establishment' => $establishment'schoolYear' => $schoolYear], []) as $key => $registration_student_pre_registration) {
  52.                 if (null == $registration_student_pre_registration->getStudent()) {
  53.                     if (true == $registration_student_pre_registration->getIsSubjectEntryTest()) {
  54.                         if (true == $registration_student_pre_registration->getIsEntryTestDone()) {
  55.                             if (true == $registration_student_pre_registration->getIsEntryTestPerformed()) {
  56.                                 $waiting_for_validations->add($registration_student_pre_registration);
  57.                             }
  58.                         }
  59.                     }else {
  60.                         $waiting_for_validations->add($registration_student_pre_registration);
  61.                     }
  62.                     
  63.                 }
  64.             }
  65.             
  66.             foreach ($registrationStudentPreRegistrationRepository->findBy(['establishment' => $establishment'schoolYear' => $schoolYear], []) as $key => $registration_student_pre_registration) {
  67.                 if (null == $registration_student_pre_registration->getStudent()) {
  68.                     if (true == $registration_student_pre_registration->getIsSubjectEntryTest()) {
  69.                         if (false == $registration_student_pre_registration->getIsEntryTestPerformed()) {
  70.                             $waiting_for_test->add($registration_student_pre_registration);
  71.                         }
  72.                     }
  73.                     
  74.                 }
  75.             }
  76.             
  77.             foreach ($registrationStudentPreRegistrationRepository->findBy(['establishment' => $establishment'schoolYear' => $schoolYear], []) as $key => $registration_student_pre_registration) {
  78.                 if (null != $registration_student_pre_registration->getStudent()) {
  79.                     if (true == $registration_student_pre_registration->getIsSubjectEntryTest()) {
  80.                         if (true == $registration_student_pre_registration->getIsEntryTestDone()) {
  81.                             if (true == $registration_student_pre_registration->getIsEntryTestPerformed()) {
  82.                                 if (count($registration_student_pre_registration->getRegistrationStudentRegistrations()) <= 0) {
  83.                                     $waiting_for_registrations->add($registration_student_pre_registration);
  84.                                 }
  85.                             }
  86.                         }
  87.                     }else {
  88.                         if (count($registration_student_pre_registration->getRegistrationStudentRegistrations()) <= 0) {
  89.                             $waiting_for_registrations->add($registration_student_pre_registration);
  90.                         }
  91.                     }
  92.                 }
  93.             }
  94.         }else {
  95.             foreach ($registrationStudentPreRegistrationRepository->findBy(['establishment' => $establishment'schoolYear' => $schoolYear], []) as $key => $registration_student_pre_registration) {
  96.                 if (null == $registration_student_pre_registration->getStudent()) {
  97.                     if (true == $registration_student_pre_registration->getIsSubjectToxicologicalTest()) {
  98.                         if (true == $registration_student_pre_registration->getIsToxicologicalTestPerformed()) {
  99.                             //if (true == $registration_student_pre_registration->getIsEntryTestPerformed()) {
  100.                                 $waiting_for_validations->add($registration_student_pre_registration);
  101.                             //}
  102.                         }
  103.                     }else {
  104.                         $waiting_for_validations->add($registration_student_pre_registration);
  105.                     }
  106.                     
  107.                 }
  108.             }
  109.             
  110.             foreach ($registrationStudentPreRegistrationRepository->findBy(['establishment' => $establishment'schoolYear' => $schoolYear], []) as $key => $registration_student_pre_registration) {
  111.                 if (null == $registration_student_pre_registration->getStudent()) {
  112.                     if (true == $registration_student_pre_registration->getIsSubjectToxicologicalTest()) {
  113.                         if (false == $registration_student_pre_registration->getIsToxicologicalTestPerformed()) {
  114.                             $waiting_for_test->add($registration_student_pre_registration);
  115.                         }
  116.                     }
  117.                     
  118.                 }
  119.             }
  120.             
  121.             foreach ($registrationStudentPreRegistrationRepository->findBy(['establishment' => $establishment'schoolYear' => $schoolYear], []) as $key => $registration_student_pre_registration) {
  122.                 if (null != $registration_student_pre_registration->getStudent()) {
  123.                     if (true == $registration_student_pre_registration->getIsSubjectToxicologicalTest()) {
  124.                         if (true == $registration_student_pre_registration->getIsToxicologicalTestPerformed()) {
  125.                             //if (true == $registration_student_pre_registration->getIsEntryTestPerformed()) {
  126.                                 if (count($registration_student_pre_registration->getRegistrationStudentRegistrations()) <= 0) {
  127.                                     $waiting_for_registrations->add($registration_student_pre_registration);
  128.                                 }
  129.                             //}
  130.                         }
  131.                     }else {
  132.                         if (count($registration_student_pre_registration->getRegistrationStudentRegistrations()) <= 0) {
  133.                             $waiting_for_registrations->add($registration_student_pre_registration);
  134.                         }
  135.                     }
  136.                 }
  137.             }
  138.         }
  139.         return $this->render('registration/registration_student_pre_registration/index.html.twig', [
  140.             /* 'registration_student_pre_registrations' => $registration_student_pre_registrations, */
  141.             'waiting_for_validations' => count($waiting_for_validations),
  142.             'waiting_for_test' => count($waiting_for_test),
  143.             'waiting_for_registrations' => count($waiting_for_registrations),
  144.             'pre_registrations' => count($registrationStudentPreRegistrationRepository->findBy(['establishment' => $establishment'schoolYear' => $schoolYear], [])),
  145.         ]);
  146.     }
  147.     /**
  148.      * @Route("/_searh-table", name="registration_student_pre_registration_searh_table", methods={"GET","POST"})
  149.      */
  150.     public function _searh_table(Request $requestRegistrationStudentPreRegistrationRepository $registrationStudentPreRegistrationRepository): Response
  151.     {
  152.         /**@var User $user */
  153.         $user $this->getUser();
  154.         $establishment $user->getEstablishment();
  155.         $schoolYear $user->getSchoolYear();
  156.         $establishment $this->getUser()->getEstablishment();
  157.         $query $registrationStudentPreRegistrationRepository->createQueryBuilder('entity')
  158.         ->andWhere('entity.establishment = :establishment')
  159.         ->setParameter('establishment'$establishment)
  160.         
  161.         ->andWhere('entity.schoolYear = :schoolYear')
  162.         ->setParameter('schoolYear'$schoolYear);
  163.         if ($request->get('registrationNumber')) {
  164.             $query $query
  165.             ->andWhere('entity.registration_number LIKE :registration_number')
  166.             ->setParameter('registration_number''%'.$request->get('registrationNumber').'%');
  167.         }
  168.         
  169.         if ($request->get('code')) {
  170.             $query $query
  171.             ->andWhere('entity.code LIKE :code')
  172.             ->setParameter('code''%'.$request->get('code').'%');
  173.         }
  174.         if ($request->get('lastName')) {
  175.             $query $query
  176.             ->andWhere('entity.last_name LIKE :last_name')
  177.             ->setParameter('last_name''%'.$request->get('lastName').'%');
  178.         }
  179.         if ($request->get('firstName')) {
  180.             $query $query
  181.             ->andWhere('entity.first_name LIKE :first_name')
  182.             ->setParameter('first_name''%'.$request->get('firstName').'%');
  183.         } 
  184.         $query $query
  185.         ->orderBy('entity.last_name''ASC')
  186.         ->getQuery();
  187.         $registration_student_pre_registrations $query
  188.         ->setMaxResults(100)
  189.         ->getResult();
  190.         return $this->renderForm('registration/registration_student_pre_registration/_searh_table.html.twig', [
  191.             'registration_student_pre_registrations' => $registration_student_pre_registrations,
  192.         ]);
  193.     }
  194.     /**
  195.      * @Route("/waiting-for-validation", name="registration_student_pre_registration_waiting_for_validation", methods={"GET"})
  196.      */
  197.     public function waiting_for_validation(RegistrationStudentPreRegistrationRepository $registrationStudentPreRegistrationRepository): Response
  198.     {
  199.         /**@var User $user */
  200.         $user $this->getUser();
  201.         $schoolYear $user->getSchoolYear();
  202.         $establishment $this->getUser()->getEstablishment();
  203.         $waiting_for_validations = new ArrayCollection();
  204.         $waiting_for_registrations = new ArrayCollection();
  205.         $waiting_for_test = new ArrayCollection();
  206.         if ($establishment->getType() == $establishment::ESTABLISHMENT_PRESCOLAIRE_PRIMAIRE_TYPES) {
  207.             foreach ($registrationStudentPreRegistrationRepository->findBy(['establishment' => $establishment'schoolYear' => $schoolYear], []) as $key => $registration_student_pre_registration) {
  208.                 if (null == $registration_student_pre_registration->getStudent()) {
  209.                     if (true == $registration_student_pre_registration->getIsSubjectEntryTest()) {
  210.                         if (true == $registration_student_pre_registration->getIsEntryTestDone()) {
  211.                             if (true == $registration_student_pre_registration->getIsEntryTestPerformed()) {
  212.                                 $waiting_for_validations->add($registration_student_pre_registration);
  213.                             }
  214.                         }
  215.                     }else {
  216.                         $waiting_for_validations->add($registration_student_pre_registration);
  217.                     }
  218.                     
  219.                 }
  220.             }
  221.             
  222.             foreach ($registrationStudentPreRegistrationRepository->findBy(['establishment' => $establishment'schoolYear' => $schoolYear], []) as $key => $registration_student_pre_registration) {
  223.                 if (null == $registration_student_pre_registration->getStudent()) {
  224.                     if (true == $registration_student_pre_registration->getIsSubjectEntryTest()) {
  225.                         if (false == $registration_student_pre_registration->getIsEntryTestPerformed()) {
  226.                             $waiting_for_test->add($registration_student_pre_registration);
  227.                         }
  228.                     }
  229.                     
  230.                 }
  231.             }
  232.             
  233.             foreach ($registrationStudentPreRegistrationRepository->findBy(['establishment' => $establishment'schoolYear' => $schoolYear], []) as $key => $registration_student_pre_registration) {
  234.                 if (null != $registration_student_pre_registration->getStudent()) {
  235.                     if (true == $registration_student_pre_registration->getIsSubjectEntryTest()) {
  236.                         if (true == $registration_student_pre_registration->getIsEntryTestDone()) {
  237.                             if (true == $registration_student_pre_registration->getIsEntryTestPerformed()) {
  238.                                 if (count($registration_student_pre_registration->getRegistrationStudentRegistrations()) <= 0) {
  239.                                     $waiting_for_registrations->add($registration_student_pre_registration);
  240.                                 }
  241.                             }
  242.                         }
  243.                     }else {
  244.                         if (count($registration_student_pre_registration->getRegistrationStudentRegistrations()) <= 0) {
  245.                             $waiting_for_registrations->add($registration_student_pre_registration);
  246.                         }
  247.                     }
  248.                 }
  249.             }
  250.         }else {
  251.             foreach ($registrationStudentPreRegistrationRepository->findBy(['establishment' => $establishment'schoolYear' => $schoolYear], []) as $key => $registration_student_pre_registration) {
  252.                 if (null == $registration_student_pre_registration->getStudent()) {
  253.                     if (true == $registration_student_pre_registration->getIsSubjectToxicologicalTest()) {
  254.                         if (true == $registration_student_pre_registration->getIsToxicologicalTestPerformed()) {
  255.                             //if (true == $registration_student_pre_registration->getIsEntryTestPerformed()) {
  256.                                 $waiting_for_validations->add($registration_student_pre_registration);
  257.                             //}
  258.                         }
  259.                     }else {
  260.                         $waiting_for_validations->add($registration_student_pre_registration);
  261.                     }
  262.                     
  263.                 }
  264.             }
  265.             
  266.             foreach ($registrationStudentPreRegistrationRepository->findBy(['establishment' => $establishment'schoolYear' => $schoolYear], []) as $key => $registration_student_pre_registration) {
  267.                 if (null == $registration_student_pre_registration->getStudent()) {
  268.                     if (true == $registration_student_pre_registration->getIsSubjectToxicologicalTest()) {
  269.                         if (false == $registration_student_pre_registration->getIsToxicologicalTestPerformed()) {
  270.                             $waiting_for_test->add($registration_student_pre_registration);
  271.                         }
  272.                     }
  273.                     
  274.                 }
  275.             }
  276.             
  277.             foreach ($registrationStudentPreRegistrationRepository->findBy(['establishment' => $establishment'schoolYear' => $schoolYear], []) as $key => $registration_student_pre_registration) {
  278.                 if (null != $registration_student_pre_registration->getStudent()) {
  279.                     if (true == $registration_student_pre_registration->getIsSubjectToxicologicalTest()) {
  280.                         if (true == $registration_student_pre_registration->getIsToxicologicalTestPerformed()) {
  281.                             //if (true == $registration_student_pre_registration->getIsEntryTestPerformed()) {
  282.                                 if (count($registration_student_pre_registration->getRegistrationStudentRegistrations()) <= 0) {
  283.                                     $waiting_for_registrations->add($registration_student_pre_registration);
  284.                                 }
  285.                             //}
  286.                         }
  287.                     }else {
  288.                         if (count($registration_student_pre_registration->getRegistrationStudentRegistrations()) <= 0) {
  289.                             $waiting_for_registrations->add($registration_student_pre_registration);
  290.                         }
  291.                     }
  292.                 }
  293.             }
  294.         }
  295.         return $this->render('registration/registration_student_pre_registration/wfv.html.twig', [
  296.             'registration_student_pre_registrations' => $waiting_for_validations,
  297.             'waiting_for_validations' => count($waiting_for_validations),
  298.             'waiting_for_test' => count($waiting_for_test),
  299.             'waiting_for_registrations' => count($waiting_for_registrations),
  300.             'pre_registrations' => count($registrationStudentPreRegistrationRepository->findBy(['establishment' => $establishment'schoolYear' => $schoolYear], [])),
  301.         ]);
  302.     }
  303.     /**
  304.      * @Route("/waiting-for-test", name="registration_student_pre_registration_waiting_for_test", methods={"GET"})
  305.     */
  306.     public function waiting_for_test(RegistrationStudentPreRegistrationRepository $registrationStudentPreRegistrationRepository): Response
  307.     {
  308.         /**@var User $user */
  309.         $user $this->getUser();
  310.         $schoolYear $user->getSchoolYear();
  311.         $establishment $this->getUser()->getEstablishment();
  312.         $waiting_for_validations = new ArrayCollection();
  313.         $waiting_for_registrations = new ArrayCollection();
  314.         $waiting_for_test = new ArrayCollection();
  315.         if ($establishment->getType() == $establishment::ESTABLISHMENT_PRESCOLAIRE_PRIMAIRE_TYPES) {
  316.             foreach ($registrationStudentPreRegistrationRepository->findBy(['establishment' => $establishment'schoolYear' => $schoolYear], []) as $key => $registration_student_pre_registration) {
  317.                 if (null == $registration_student_pre_registration->getStudent()) {
  318.                     if (true == $registration_student_pre_registration->getIsSubjectEntryTest()) {
  319.                         if (true == $registration_student_pre_registration->getIsEntryTestDone()) {
  320.                             if (true == $registration_student_pre_registration->getIsEntryTestPerformed()) {
  321.                                 $waiting_for_validations->add($registration_student_pre_registration);
  322.                             }
  323.                         }
  324.                     }else {
  325.                         $waiting_for_validations->add($registration_student_pre_registration);
  326.                     }
  327.                     
  328.                 }
  329.             }
  330.             
  331.             foreach ($registrationStudentPreRegistrationRepository->findBy(['establishment' => $establishment'schoolYear' => $schoolYear], []) as $key => $registration_student_pre_registration) {
  332.                 if (null == $registration_student_pre_registration->getStudent()) {
  333.                     if (true == $registration_student_pre_registration->getIsSubjectEntryTest()) {
  334.                         if (false == $registration_student_pre_registration->getIsEntryTestPerformed()) {
  335.                             $waiting_for_test->add($registration_student_pre_registration);
  336.                         }
  337.                     }
  338.                     
  339.                 }
  340.             }
  341.             
  342.             foreach ($registrationStudentPreRegistrationRepository->findBy(['establishment' => $establishment'schoolYear' => $schoolYear], []) as $key => $registration_student_pre_registration) {
  343.                 if (null != $registration_student_pre_registration->getStudent()) {
  344.                     if (true == $registration_student_pre_registration->getIsSubjectEntryTest()) {
  345.                         if (true == $registration_student_pre_registration->getIsEntryTestDone()) {
  346.                             if (true == $registration_student_pre_registration->getIsEntryTestPerformed()) {
  347.                                 if (count($registration_student_pre_registration->getRegistrationStudentRegistrations()) <= 0) {
  348.                                     $waiting_for_registrations->add($registration_student_pre_registration);
  349.                                 }
  350.                             }
  351.                         }
  352.                     }else {
  353.                         if (count($registration_student_pre_registration->getRegistrationStudentRegistrations()) <= 0) {
  354.                             $waiting_for_registrations->add($registration_student_pre_registration);
  355.                         }
  356.                     }
  357.                 }
  358.             }
  359.         }else {
  360.             foreach ($registrationStudentPreRegistrationRepository->findBy(['establishment' => $establishment'schoolYear' => $schoolYear], []) as $key => $registration_student_pre_registration) {
  361.                 if (null == $registration_student_pre_registration->getStudent()) {
  362.                     if (true == $registration_student_pre_registration->getIsSubjectToxicologicalTest()) {
  363.                         if (true == $registration_student_pre_registration->getIsToxicologicalTestPerformed()) {
  364.                             //if (true == $registration_student_pre_registration->getIsEntryTestPerformed()) {
  365.                                 $waiting_for_validations->add($registration_student_pre_registration);
  366.                             //}
  367.                         }
  368.                     }else {
  369.                         $waiting_for_validations->add($registration_student_pre_registration);
  370.                     }
  371.                     
  372.                 }
  373.             }
  374.             
  375.             foreach ($registrationStudentPreRegistrationRepository->findBy(['establishment' => $establishment'schoolYear' => $schoolYear], []) as $key => $registration_student_pre_registration) {
  376.                 if (null == $registration_student_pre_registration->getStudent()) {
  377.                     if (true == $registration_student_pre_registration->getIsSubjectToxicologicalTest()) {
  378.                         if (false == $registration_student_pre_registration->getIsToxicologicalTestPerformed()) {
  379.                             $waiting_for_test->add($registration_student_pre_registration);
  380.                         }
  381.                     }
  382.                     
  383.                 }
  384.             }
  385.             
  386.             foreach ($registrationStudentPreRegistrationRepository->findBy(['establishment' => $establishment'schoolYear' => $schoolYear], []) as $key => $registration_student_pre_registration) {
  387.                 if (null != $registration_student_pre_registration->getStudent()) {
  388.                     if (true == $registration_student_pre_registration->getIsSubjectToxicologicalTest()) {
  389.                         if (true == $registration_student_pre_registration->getIsToxicologicalTestPerformed()) {
  390.                             //if (true == $registration_student_pre_registration->getIsEntryTestPerformed()) {
  391.                                 if (count($registration_student_pre_registration->getRegistrationStudentRegistrations()) <= 0) {
  392.                                     $waiting_for_registrations->add($registration_student_pre_registration);
  393.                                 }
  394.                             //}
  395.                         }
  396.                     }else {
  397.                         if (count($registration_student_pre_registration->getRegistrationStudentRegistrations()) <= 0) {
  398.                             $waiting_for_registrations->add($registration_student_pre_registration);
  399.                         }
  400.                     }
  401.                 }
  402.             }
  403.         }
  404.         return $this->render('registration/registration_student_pre_registration/wft.html.twig', [
  405.             'registration_student_pre_registrations' => $waiting_for_test,
  406.             'waiting_for_validations' => count($waiting_for_validations),
  407.             'waiting_for_test' => count($waiting_for_test),
  408.             'waiting_for_registrations' => count($waiting_for_registrations),
  409.             'pre_registrations' => count($registrationStudentPreRegistrationRepository->findBy(['establishment' => $establishment'schoolYear' => $schoolYear], [])),
  410.         ]);
  411.     }
  412.     /**
  413.      * @Route("/waiting-for-registrations", name="registration_student_pre_registration_waiting_for_registrations", methods={"GET"})
  414.     */
  415.     public function waiting_for_registrations(RegistrationStudentPreRegistrationRepository $registrationStudentPreRegistrationRepository): Response
  416.     {
  417.         /**@var User $user */
  418.         $user $this->getUser();
  419.         $schoolYear $user->getSchoolYear();
  420.         $establishment $this->getUser()->getEstablishment();
  421.         $waiting_for_validations = new ArrayCollection();
  422.         $waiting_for_registrations = new ArrayCollection();
  423.         $waiting_for_test = new ArrayCollection();
  424.         if ($establishment->getType() == $establishment::ESTABLISHMENT_PRESCOLAIRE_PRIMAIRE_TYPES) {
  425.             foreach ($registrationStudentPreRegistrationRepository->findBy(['establishment' => $establishment'schoolYear' => $schoolYear], []) as $key => $registration_student_pre_registration) {
  426.                 if (null == $registration_student_pre_registration->getStudent()) {
  427.                     if (true == $registration_student_pre_registration->getIsSubjectEntryTest()) {
  428.                         if (true == $registration_student_pre_registration->getIsEntryTestDone()) {
  429.                             if (true == $registration_student_pre_registration->getIsEntryTestPerformed()) {
  430.                                 $waiting_for_validations->add($registration_student_pre_registration);
  431.                             }
  432.                         }
  433.                     }else {
  434.                         $waiting_for_validations->add($registration_student_pre_registration);
  435.                     }
  436.                     
  437.                 }
  438.             }
  439.             
  440.             foreach ($registrationStudentPreRegistrationRepository->findBy(['establishment' => $establishment'schoolYear' => $schoolYear], []) as $key => $registration_student_pre_registration) {
  441.                 if (null == $registration_student_pre_registration->getStudent()) {
  442.                     if (true == $registration_student_pre_registration->getIsSubjectEntryTest()) {
  443.                         if (false == $registration_student_pre_registration->getIsEntryTestPerformed()) {
  444.                             $waiting_for_test->add($registration_student_pre_registration);
  445.                         }
  446.                     }
  447.                     
  448.                 }
  449.             }
  450.             
  451.             foreach ($registrationStudentPreRegistrationRepository->findBy(['establishment' => $establishment'schoolYear' => $schoolYear], []) as $key => $registration_student_pre_registration) {
  452.                 if (null != $registration_student_pre_registration->getStudent()) {
  453.                     if (true == $registration_student_pre_registration->getIsSubjectEntryTest()) {
  454.                         if (true == $registration_student_pre_registration->getIsEntryTestDone()) {
  455.                             if (true == $registration_student_pre_registration->getIsEntryTestPerformed()) {
  456.                                 if (count($registration_student_pre_registration->getRegistrationStudentRegistrations()) <= 0) {
  457.                                     $waiting_for_registrations->add($registration_student_pre_registration);
  458.                                 }
  459.                             }
  460.                         }
  461.                     }else {
  462.                         if (count($registration_student_pre_registration->getRegistrationStudentRegistrations()) <= 0) {
  463.                             $waiting_for_registrations->add($registration_student_pre_registration);
  464.                         }
  465.                     }
  466.                 }
  467.             }
  468.         }else {
  469.             foreach ($registrationStudentPreRegistrationRepository->findBy(['establishment' => $establishment'schoolYear' => $schoolYear], []) as $key => $registration_student_pre_registration) {
  470.                 if (null == $registration_student_pre_registration->getStudent()) {
  471.                     if (true == $registration_student_pre_registration->getIsSubjectToxicologicalTest()) {
  472.                         if (true == $registration_student_pre_registration->getIsToxicologicalTestPerformed()) {
  473.                             //if (true == $registration_student_pre_registration->getIsEntryTestPerformed()) {
  474.                                 $waiting_for_validations->add($registration_student_pre_registration);
  475.                             //}
  476.                         }
  477.                     }else {
  478.                         $waiting_for_validations->add($registration_student_pre_registration);
  479.                     }
  480.                     
  481.                 }
  482.             }
  483.             
  484.             foreach ($registrationStudentPreRegistrationRepository->findBy(['establishment' => $establishment'schoolYear' => $schoolYear], []) as $key => $registration_student_pre_registration) {
  485.                 if (null == $registration_student_pre_registration->getStudent()) {
  486.                     if (true == $registration_student_pre_registration->getIsSubjectToxicologicalTest()) {
  487.                         if (false == $registration_student_pre_registration->getIsToxicologicalTestPerformed()) {
  488.                             $waiting_for_test->add($registration_student_pre_registration);
  489.                         }
  490.                     }
  491.                     
  492.                 }
  493.             }
  494.             
  495.             foreach ($registrationStudentPreRegistrationRepository->findBy(['establishment' => $establishment'schoolYear' => $schoolYear], []) as $key => $registration_student_pre_registration) {
  496.                 if (null != $registration_student_pre_registration->getStudent()) {
  497.                     if (true == $registration_student_pre_registration->getIsSubjectToxicologicalTest()) {
  498.                         if (true == $registration_student_pre_registration->getIsToxicologicalTestPerformed()) {
  499.                             //if (true == $registration_student_pre_registration->getIsEntryTestPerformed()) {
  500.                                 if (count($registration_student_pre_registration->getRegistrationStudentRegistrations()) <= 0) {
  501.                                     $waiting_for_registrations->add($registration_student_pre_registration);
  502.                                 }
  503.                             //}
  504.                         }
  505.                     }else {
  506.                         if (count($registration_student_pre_registration->getRegistrationStudentRegistrations()) <= 0) {
  507.                             $waiting_for_registrations->add($registration_student_pre_registration);
  508.                         }
  509.                     }
  510.                 }
  511.             }
  512.         }
  513.         return $this->render('registration/registration_student_pre_registration/wfr.html.twig', [
  514.             'registration_student_pre_registrations' => $waiting_for_registrations,
  515.             'waiting_for_validations' => count($waiting_for_validations),
  516.             'waiting_for_test' => count($waiting_for_test),
  517.             'waiting_for_registrations' => count($waiting_for_registrations),
  518.             'pre_registrations' => count($registrationStudentPreRegistrationRepository->findBy(['establishment' => $establishment'schoolYear' => $schoolYear], [])),
  519.         ]);
  520.     }
  521.     /**
  522.      * @Route("/{id}/edit", name="registration_student_pre_registration_edit", methods={"GET","POST"})
  523.      */
  524.     public function edit(Request $requestRegistrationStudentPreRegistration $registrationStudentPreRegistration): Response
  525.     {
  526.         $establishment $this->getUser()->getEstablishment();
  527.         $template 'registration/registration_student_pre_registration/primaireEdit.html.twig';
  528.         if ($establishment->getType() != $establishment::ESTABLISHMENT_PRESCOLAIRE_PRIMAIRE_TYPES) {
  529.             $template 'registration/registration_student_pre_registration/secondaireEdit.html.twig';
  530.         }
  531.         $entryLevels = new ArrayCollection();
  532.         foreach ($establishment->getSettingLevels() as $key => $level) {
  533.             if (count($level->getSettingClassrooms()) > 0) {
  534.                 $entryLevels->add($level);
  535.             }
  536.         }
  537.         
  538.         $form $this->createForm(RegistrationStudentPreRegistrationType::class, $registrationStudentPreRegistration)
  539.         ->remove('agree_parent_engagement')
  540.         ->remove('agree_internal_rules')
  541.         ->add('is_entry_test_done'ChoiceType::class,[
  542.             'choices' => [
  543.                 'OUI' => true,
  544.                 'NON' => false
  545.             ]
  546.         ])
  547.         ->add('entryLevel'EntityType::class, [
  548.             'class' => SettingLevel::class,
  549.             'choices' => $entryLevels,
  550.             'required' => true
  551.         ])
  552.         ->add('classJumps'EntityType::class, [
  553.             'class' => SettingLevel::class,
  554.             'choices' => $entryLevels,
  555.             'required' => false,
  556.             'multiple' => true,
  557.         ]);
  558.         
  559.         if ($establishment->getType() != $establishment::ESTABLISHMENT_PRESCOLAIRE_PRIMAIRE_TYPES) {
  560.             $form $this->createForm(RegistrationStudentPreRegistrationType::class, $registrationStudentPreRegistration)
  561.             ->add('lv1'ChoiceType::class,[
  562.                 'choices' => RegistrationStudent::LV1
  563.             ])
  564.             ->add('lv2'ChoiceType::class,[
  565.                 'choices' => RegistrationStudent::LV2
  566.             ])
  567.             ->add('entryLevel'EntityType::class, [
  568.                 'class' => SettingLevel::class,
  569.                 'choices' => $entryLevels,
  570.                 'required' => true
  571.             ])
  572.             ->remove('agree_parent_engagement')
  573.             ->remove('agree_internal_rules')
  574.             ->remove('is_need_canteen')
  575.             ->remove('is_need_keep');
  576.         }
  577.         $form->handleRequest($request);
  578.         if ($form->isSubmitted() && $form->isValid()) {
  579.             try {
  580.                 $this->getDoctrine()->getManager()->flush();
  581.                 $this->addFlash('success'"pre-inscription à été édité.");
  582.             } catch (\Throwable $th) {
  583.                 $this->addFlash('warning'"Une erreure est survenue lors de l'édition de pre-inscription.");
  584.                 $this->addFlash('info'$th->getMessage());
  585.             }
  586.             return $this->redirectToRoute('registration_student_pre_registration_index', [], Response::HTTP_SEE_OTHER);
  587.         }
  588.         return $this->renderForm($template, [
  589.             'registration_student_pre_registration' => $registrationStudentPreRegistration,
  590.             'form' => $form,
  591.         ]);
  592.     }
  593.     /**
  594.      * @Route("/delete-selection", name="registration_student_pre_registrations_selected_delete", methods={"GET"})
  595.     */
  596.     public function deleteSelected(Request $requestRegistrationStudentPreRegistrationRepository $entityRepository): Response
  597.     {
  598.         $list $request->get('entities');
  599.         $entityManager $this->getDoctrine()->getManager();
  600.         $errors 0;
  601.         $success 0;
  602.         foreach ($list as $key => $id) {
  603.             $entity $entityRepository->findOneBy(['id' => intval($id)], []);
  604.             if ($entity != null) {
  605.                 if (count($entity->getRegistrationStudentRegistrations()) <= 0) {
  606.                     $entityManager->remove($entity);
  607.                     $success $success 1
  608.                 }else{
  609.                     $errors $errors 1
  610.                 }
  611.             }else{
  612.                 $errors $errors 1;
  613.             }
  614.         }
  615.         try {
  616.             $entityManager->flush();
  617.             $this->addFlash('success'$success" Eléments ont été supprimé.");
  618.             return $this->json(['code' => 200'message' => $success" Eléments ont été supprimé. ".$errors "N'ont pas pu être supprimés." ], 200);
  619.         } catch (\Throwable $th) {
  620.             //$th->getMessage()
  621.             $this->addFlash('warning'$th->getMessage());
  622.         }
  623.         
  624.         $this->addFlash('warning'"Traitement non effectué, une erreur s'est produite.");
  625.         return $this->json(['code' => 500'message' => "Traitement non effectué, une erreur s'est produite."], 200);
  626.     }
  627.     /**
  628.      * @Route("/validate/{id}", name="registration_student_pre_registration_validate", methods={"GET"})
  629.     */
  630.     public function validate(RegistrationStudentPreRegistration $registrationStudentPreRegistrationRegistrationStudentRepository $registrationStudentRepositorySMSSender $smsSender): Response
  631.     {
  632.         if(null != $registrationStudentPreRegistration->getStudent()) {
  633.             return $this->json(['code' => 500'message' => "Echèc: cette pre-inscription est déjà validé."], 200);
  634.         }
  635.         $entityManager $this->getDoctrine()->getManager();
  636.         $establishment $this->getUser()->getEstablishment();
  637.         $registrationStudent $registrationStudentRepository->findOneBy(['id' => $registrationStudentPreRegistration->getHoldStudentId()], []);
  638.         
  639.         if (null == $registrationStudent) {
  640.             $registrationStudent = new RegistrationStudent();
  641.             $nextIndex count($registrationStudentRepository->findBy([], [])) + 1;
  642.             $registrationStudent->setCode(date('Y').'-'.sprintf("%'05s"$nextIndex));
  643.             $registrationStudent->setEstablishment($establishment);
  644.         }
  645.         $registrationStudent->setAccompanyingPersonName($registrationStudentPreRegistration->getAccompanyingPersonName());
  646.         $registrationStudent->setAccompanyingPersonPhoneNumber($registrationStudentPreRegistration->getAccompanyingPersonPhoneNumber());
  647.         $registrationStudent->setFatherAddress($registrationStudentPreRegistration->getFatherAddress());
  648.         $registrationStudent->setFatherEmail($registrationStudentPreRegistration->getFatherEmail());
  649.         $registrationStudent->setFatherFirstName($registrationStudentPreRegistration->getFatherFirstName());
  650.         $registrationStudent->setFatherLastName($registrationStudentPreRegistration->getFatherLastName());
  651.         $registrationStudent->setFatherPhoneNumber($registrationStudentPreRegistration->getFatherPhoneNumber());
  652.         $registrationStudent->setIsFatherCallToEmergency($registrationStudentPreRegistration->getIsFatherCallToEmergency());
  653.         $registrationStudent->setIsParntalAuthorityFather($registrationStudentPreRegistration->getIsParntalAuthorityFather());
  654.         $registrationStudent->setMotherAddress($registrationStudentPreRegistration->getMotherAddress());
  655.         $registrationStudent->setMotherEmail($registrationStudentPreRegistration->getMotherEmail());
  656.         $registrationStudent->setMotherFirstName($registrationStudentPreRegistration->getMotherFirstName());
  657.         $registrationStudent->setMotherLastName($registrationStudentPreRegistration->getMotherLastName());
  658.         $registrationStudent->setMotherPhoneNumber($registrationStudentPreRegistration->getMotherPhoneNumber());
  659.         $registrationStudent->setIsMotherCallToEmergency($registrationStudentPreRegistration->getIsMotherCallToEmergency());
  660.         $registrationStudent->setIsParntalAuthorityMother($registrationStudentPreRegistration->getIsParntalAuthorityMother());
  661.         $registrationStudent->setFirstName($registrationStudentPreRegistration->getFirstName());
  662.         $registrationStudent->setLastName($registrationStudentPreRegistration->getLastName());
  663.         $registrationStudent->setImage($registrationStudentPreRegistration->getImage());
  664.         $registrationStudent->setIsAffected($registrationStudentPreRegistration->getIsAffected());
  665.         $registrationStudent->setLocation($registrationStudentPreRegistration->getLocation());
  666.         if ($establishment->getType() != $establishment::ESTABLISHMENT_PRESCOLAIRE_PRIMAIRE_TYPES) {
  667.             $registrationStudent->setLv1($registrationStudentPreRegistration->getLv1());
  668.             $registrationStudent->setLv2($registrationStudentPreRegistration->getLv2());
  669.         }
  670.         $registrationStudent->setNationality($registrationStudentPreRegistration->getNationality());
  671.         $registrationStudent->setBirthday($registrationStudentPreRegistration->getBirthday());
  672.         $registrationStudent->setBirthLocation($registrationStudentPreRegistration->getBirthLocation());
  673.         $registrationStudent->setBirthCertificateNumber($registrationStudentPreRegistration->getBirthCertificateNumber());
  674.         $registrationStudent->setRegistrationNumber($registrationStudentPreRegistration->getRegistrationNumber());
  675.         $registrationStudent->setLastSchoolAttended($registrationStudentPreRegistration->getLastSchoolAttended());
  676.         $registrationStudent->setLastSchoolAttendedType($registrationStudentPreRegistration->getLastSchoolAttendedType());          
  677.         
  678.         $registrationStudent->setNotificationWatsappNumber($registrationStudentPreRegistration->getNotificationWatsappNumber());
  679.         $registrationStudent->setNotificationPhoneNumber($registrationStudentPreRegistration->getNotificationPhoneNumber());
  680.         $registrationStudent->setObservation($registrationStudentPreRegistration->getObservation());
  681.         $registrationStudent->setParentStatus($registrationStudentPreRegistration->getParentStatus());
  682.         $registrationStudent->setResponsibleOfSchooling($registrationStudentPreRegistration->getResponsibleOfSchooling());
  683.         $registrationStudent->setResponsibleOfSchoolingAddress($registrationStudentPreRegistration->getResponsibleOfSchoolingAddress());
  684.         $registrationStudent->setResponsibleOfSchoolingFirstName($registrationStudentPreRegistration->getResponsibleOfSchoolingFirstName());
  685.         $registrationStudent->setResponsibleOfSchoolingLastName($registrationStudentPreRegistration->getResponsibleOfSchoolingLastName());
  686.         $registrationStudent->setResponsibleOfSchoolingLocation($registrationStudentPreRegistration->getResponsibleOfSchoolingLocation());
  687.         $registrationStudent->setResponsibleOfSchoolingPhoneNumber($registrationStudentPreRegistration->getResponsibleOfSchoolingPhoneNumber());
  688.         $registrationStudent->setResponsibleOfSchoolingPost($registrationStudentPreRegistration->getResponsibleOfSchoolingPost());
  689.         $registrationStudent->setGender($registrationStudentPreRegistration->getGender());
  690.         
  691.         if (>= $registrationStudent->getId()) {
  692.             $entityManager->persist($registrationStudent);
  693.             try {
  694.                 $entityManager->flush();
  695.                 $registrationStudent->setCode(date('Y').'-'.sprintf("%'05s"$registrationStudent->getId()));
  696.                 $entityManager->flush();
  697.             } catch (\Throwable $th) {
  698.                 $this->addFlash('info'$th->getMessage());
  699.             }
  700.         }
  701.         $registrationStudentPreRegistration->setStudent($registrationStudent);
  702.         try {
  703.             $entityManager->flush();
  704.             $this->addFlash('success'"Validation effectuée");
  705.             return $this->json(['code' => 200'message' => "Traitement effectué :)"], 200);
  706.         } catch (\Throwable $th) {
  707.             //$th->getMessage()
  708.             $this->addFlash('warning'$th->getMessage());
  709.         }
  710.         
  711.         $this->addFlash('warning'"Validation non effectuée");
  712.         return $this->json(['code' => 500'message' => "Traitement non effectué"], 200);
  713.     }
  714.     /**
  715.      * @Route("/{id}/print", name="registration_student_pre_registration_print", methods={"GET"})
  716.     */
  717.     public function print(Pdf $knpSnappyPdfRegistrationStudentPreRegistration $registrationStudentPreRegistration)
  718.     {
  719.         /**@var User $user */
  720.         $user $this->getUser();
  721.         $schoolYear $user->getSchoolYear();
  722.         
  723.         $setting $registrationStudentPreRegistration->getEstablishment();
  724.         $template 'registration/print/prePrimaire.html.twig';
  725.         if ($setting->getType() != $setting::ESTABLISHMENT_PRESCOLAIRE_PRIMAIRE_TYPES) {
  726.             $template 'registration/print/preSecondaire.html.twig';
  727.         }
  728.         
  729.         $html $this->renderView($template, [
  730.             'registration_student_pre_registration' => $registrationStudentPreRegistration,
  731.             'school_year' => $schoolYear,
  732.             'setting' => $setting,
  733.         ]);
  734.         $file_name 'PRE_INSCRIPTION_N_'.$registrationStudentPreRegistration->getCode().".pdf";
  735.         return new PdfResponse(
  736.             $knpSnappyPdf->getOutputFromHtml($html),
  737.             $file_name,
  738.             'application/pdf',
  739.             'attachment'
  740.         );
  741.     }
  742.     /**
  743.      * @Route("/api/get-info", name="api_registration_student_pre_registration_info", methods={"GET"})
  744.     */
  745.     public function apiGetInfo(Request $requestRegistrationStudentPreRegistrationRepository $entityRepositorySchoolAssessmentByLevelRepository $schoolAssessmentByLevelRepository): Response
  746.     {
  747.         /**@var User $user */
  748.         $user $this->getUser();
  749.         $schoolYear $user->getSchoolYear();
  750.         $id intval($request->get('id'));
  751.         $entity $entityRepository->findOneBy(['id' => $id], []);
  752.         $schoolAssessmentByLevels $schoolAssessmentByLevelRepository->createQueryBuilder('entity')
  753.         ->innerJoin('entity.studentRegistration''studentRegistration')
  754.         ->addSelect('studentRegistration')
  755.         ->innerJoin('entity.schoolAssessment''schoolAssessment')
  756.         ->addSelect('schoolAssessment')
  757.         ->innerJoin('entity.nextClassroom''nextClassroom')
  758.         ->addSelect('nextClassroom')
  759.         
  760.         ->andWhere('studentRegistration.student = :student')
  761.         ->setParameter('student'$entity->getStudent())
  762.         ->andWhere('schoolAssessment.nexSchoolYear = :nexSchoolYear')
  763.         ->setParameter('nexSchoolYear'$schoolYear)
  764.         ->getQuery()
  765.         ->getResult();
  766.         if ($entity != null) {
  767.             $classrooms = new ArrayCollection();
  768.             foreach ($schoolAssessmentByLevels as $key => $schoolAssessmentByLevel) {
  769.                 if ($schoolAssessmentByLevel->getNextClassroom()->getCapacity() > count($schoolAssessmentByLevel->getNextClassroom()->getRegistereds($schoolYear))) {
  770.                     $classrooms->add([
  771.                         'id' => $schoolAssessmentByLevel->getNextClassroom()->getId(),
  772.                         'label' => $schoolAssessmentByLevel->getNextClassroom()->getLabel()
  773.                     ]);
  774.                 }
  775.             };
  776.             
  777.             if (count($classrooms) <= 0) {
  778.                 foreach ($entity->getEntryLevel()->getSettingClassrooms() as $key => $classroom) {
  779.                     if (!$classroom->getIsExcellent()) {
  780.                         if ($classroom->getSchoolYear() == $schoolYear) {
  781.                             if ($classroom->getCapacity() > count($classroom->getRegistereds($schoolYear))) {
  782.                                 $classrooms->add([
  783.                                     'id' => $classroom->getId(),
  784.                                     'label' => $classroom->getLabel()
  785.                                 ]);
  786.                             }
  787.                         }
  788.                     }
  789.                 }
  790.             }
  791.             
  792.             $is_affected false;
  793.             $is_redoubling $entity->getIsRedoubling();
  794.             
  795.             if (null != $entity->getStudent()) {
  796.                 $is_affected $entity->getStudent()->getIsAffected();
  797.             }
  798.             
  799.             return $this->json([
  800.                 'code' => 200'message' => "found :)"
  801.                 'name' => $entity->getName(), 
  802.                 'registrationNumber' => $entity->getRegistrationNumber(), 
  803.                 'id' => $entity->getCode(), 
  804.                 'birthDate' => $entity->getBirthday()->format('d/m/Y'), 
  805.                 'birthLocation' => $entity->getBirthLocation(), 
  806.                 'phoneNumber' => $entity->getNotificationPhoneNumber(), 
  807.                 'establishment' => $entity->getEstablishment()->getName(),
  808.                 'classroom' => $entity->getEntryLevel()->getLabel(),
  809.                 'classrooms' => $classrooms,
  810.                 'preCode' => $entity->getCode(),
  811.                 'is_affected' => $is_affected
  812.                 'is_redoubling' => $is_redoubling
  813.                 'img_src' =>$entity->getImage(), 
  814.             ], 200);
  815.         }else{
  816.             return $this->json(['code' => 500'message' => "not found :)"], 200);
  817.         }
  818.     }
  819. }