src/Controller/Registration/RegistrationStudentRegistrationController.php line 63

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Registration;
  3. use DateInterval;
  4. use Knp\Snappy\Pdf;
  5. use App\Entity\User;
  6. use DateTimeImmutable;
  7. use App\Entity\SettingFee;
  8. use App\Service\SMSSender;
  9. use App\Entity\StockKitOut;
  10. use App\Entity\TransportZone;
  11. use App\Entity\StockKitOutLine;
  12. use App\Entity\SettingClassroom;
  13. use App\Service\DateIntervalManage;
  14. use App\Entity\CommunicationMessage;
  15. use App\Entity\SettingDocumentToProvide;
  16. use App\Repository\SettingFeeRepository;
  17. use PhpOffice\PhpSpreadsheet\Spreadsheet;
  18. use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
  19. use App\Repository\TransportZoneRepository;
  20. use Symfony\Component\HttpFoundation\Request;
  21. use App\Repository\SettingClassroomRepository;
  22. use Symfony\Component\HttpFoundation\Response;
  23. use App\Entity\RegistrationStudentRegistration;
  24. use App\Entity\RegistrationTransportCheckpoint;
  25. use Symfony\Component\Routing\Annotation\Route;
  26. use App\Entity\AccountingStudentRegistrationFee;
  27. use Doctrine\Common\Collections\ArrayCollection;
  28. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  29. use App\Entity\RegistrationStudentPreRegistration;
  30. use App\Entity\AccountingStudentRegistrationFeeShedul;
  31. use App\Repository\SettingDocumentToProvideRepository;
  32. use Symfony\Component\HttpFoundation\ResponseHeaderBag;
  33. use Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse;
  34. use App\Form\Accounting\AccountingStudentRegistrationFeeType;
  35. use App\Repository\RegistrationStudentRegistrationRepository;
  36. use App\Form\Registration\RegistrationStudentRegistrationType;
  37. use App\Form\Registration\RegistrationTransportCheckpointType;
  38. use App\Repository\EquivalentMatterRepository;
  39. use App\Repository\RegistrationStudentPreRegistrationRepository;
  40. use App\Repository\SchoolReportCardRepository;
  41. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  42. /**
  43.  * @Route("/registration/student-registration")
  44.  */
  45. class RegistrationStudentRegistrationController extends AbstractController
  46. {
  47.     /**
  48.      * @Route("/index/{_from}", name="registration_student_registration_index", methods={"GET"})
  49.      */
  50.     public function index($_from 'All'): Response
  51.     {
  52.         return $this->render('registration/registration_student_registration/index.html.twig', [
  53.             '_from' => $_from,
  54.         ]);
  55.     }
  56.     /**
  57.      * @Route("/_searh-table/{_from}", name="registration_student_registration_searh_table", methods={"GET","POST"})
  58.      */
  59.     public function _searh_table($_from 'All'Request $requestRegistrationStudentRegistrationRepository $registrationStudentRegistrationRepository): Response
  60.     {
  61.         /**@var User $user */
  62.         $user $this->getUser();
  63.         $establishment $user->getEstablishment();
  64.         $schoolYear $user->getSchoolYear();
  65.         $query $registrationStudentRegistrationRepository->createQueryBuilder('entity')
  66.         ->innerJoin('entity.student''student')
  67.         ->addSelect('student')
  68.         ->andWhere('entity.establishment = :establishment')
  69.         ->setParameter('establishment'$establishment)
  70.         
  71.         ->andWhere('entity.schoolYear = :schoolYear')
  72.         ->setParameter('schoolYear'$schoolYear);
  73.         if ($request->get('registrationNumber')) {
  74.             $query $query
  75.             ->andWhere('student.registration_number LIKE :registration_number')
  76.             ->setParameter('registration_number''%'.$request->get('registrationNumber').'%');
  77.         }
  78.         
  79.         if ($request->get('code')) {
  80.             $query $query
  81.             ->andWhere('student.code LIKE :code')
  82.             ->setParameter('code''%'.$request->get('code').'%');
  83.         }
  84.         if ($request->get('lastName')) {
  85.             $query $query
  86.             ->andWhere('student.last_name LIKE :last_name')
  87.             ->setParameter('last_name''%'.$request->get('lastName').'%');
  88.         }
  89.         if ($request->get('firstName')) {
  90.             $query $query
  91.             ->andWhere('student.first_name LIKE :first_name')
  92.             ->setParameter('first_name''%'.$request->get('firstName').'%');
  93.         } 
  94.         $query $query
  95.         ->orderBy('student.last_name''ASC')
  96.         ->getQuery();
  97.         $registration_student_registrations $query
  98.         ->setMaxResults(100)
  99.         ->getResult();
  100.         return $this->renderForm('registration/registration_student_registration/_searh_table.html.twig', [
  101.             'registration_student_registrations' => $registration_student_registrations,
  102.             '_from' => $_from,
  103.         ]);
  104.     }
  105.     /**
  106.      * @Route("/new", name="registration_student_registration_new", methods={"GET","POST"})
  107.      */
  108.     public function new(Request $requestSettingFeeRepository $settingFeeRepositoryRegistrationStudentPreRegistrationRepository $registrationStudentPreRegistrationRepositorySettingDocumentToProvideRepository $settingDocumentToProvideRepositoryRegistrationStudentRegistrationRepository $registrationStudentRegistrationRepositorySettingClassroomRepository $settingClassroomRepository): Response
  109.     {
  110.         /**@var User $user */
  111.         $user $this->getUser();
  112.         $schoolYear $user->getSchoolYear();
  113.         $establishment $user->getEstablishment();
  114.         
  115.         if ($schoolYear == null) {
  116.             $this->addFlash('warning'"Aucune base de donnée n'est activé.");
  117.             return $this->redirectToRoute('registration_student_registration_new');
  118.         }
  119.         /* recuperation des non encore incrits */
  120.         $unregisteredRegistrationStudentPreRegistrations = new ArrayCollection();
  121.         $registrationStudentPreRegistrations $registrationStudentPreRegistrationRepository->createQueryBuilder('entity')
  122.         ->andWhere('entity.establishment = :establishment')
  123.         ->setParameter('establishment'$establishment)
  124.         ->andWhere('entity.schoolYear = :schoolYear')
  125.         ->setParameter('schoolYear'$schoolYear)
  126.         ->getQuery()
  127.         ->getResult();
  128.         foreach ($registrationStudentPreRegistrations as $key => $registrationStudentPreRegistration) {
  129.             if ($registrationStudentPreRegistration->getStudent() != null) {
  130.                 if(count($registrationStudentPreRegistration->getRegistrationStudentRegistrations()) <= 0){
  131.                     if ($registrationStudentPreRegistration->getIsEntryTestPerformed() or !$registrationStudentPreRegistration->getIsSubjectEntryTest()) {
  132.                         $unregisteredRegistrationStudentPreRegistrations->add($registrationStudentPreRegistration);
  133.                     }
  134.                 } 
  135.             }
  136.         }
  137.         $registrationStudentRegistration = new RegistrationStudentRegistration();
  138.         $registrationStudentRegistration->setPortalLogin($registrationStudentRegistration->getId().time());
  139.         $registrationStudentRegistration->setPortalPassword(uniqid());
  140.         $form $this->createForm(RegistrationStudentRegistrationType::class, $registrationStudentRegistration)
  141.         
  142.         ->add('registrationStudentPreRegistration'EntityType::class, [
  143.             'class' => RegistrationStudentPreRegistration::class,
  144.             'choices' => $unregisteredRegistrationStudentPreRegistrations
  145.         ])
  146.         ->add('classroom'EntityType::class, [
  147.             'class' => SettingClassroom::class,
  148.             'choices' => $settingClassroomRepository->findBy(['schoolYear' => $schoolYear'establishment' => $establishment], ['label' => 'ASC'])
  149.             //'choices' => $settingClassroomRepository->findBy(['schoolYear' => $schoolYear, 'is_excellent' => 0], ['label' => 'ASC'])
  150.         ])
  151.         ->add('documentProvides'EntityType::class, [
  152.             'class' => SettingDocumentToProvide::class,
  153.             'choices' => $settingDocumentToProvideRepository->findBy(['establishment' => $establishment], []),
  154.             'multiple' => true,
  155.             'required' => false
  156.         ]);
  157.         $form->handleRequest($request);
  158.         if($form->isSubmitted() && $form->isValid()) {
  159.             $entityManager $this->getDoctrine()->getManager();
  160.             $student $registrationStudentRegistration->getRegistrationStudentPreRegistration()->getStudent();
  161.             if ($registrationStudentRegistrationRepository->findOneBy(['establishment' => $establishment'schoolYear' => $schoolYear'student' => $student], []) != null) {
  162.                 $this->addFlash('warning'"Cet élève est déjà inscrit");
  163.                 return $this->redirectToRoute('registration_student_registration_new');
  164.             }
  165.             $registrationStudentRegistration->setSchoolYear($schoolYear);
  166.             $registrationStudentRegistration->setEstablishment($establishment);
  167.             
  168.             $registrationStudentRegistration->setStudent($student);
  169.             $registrationStudentRegistration->setIsAffected($student->getIsAffected());
  170.             
  171.             if (count($student->getRegistrationStudentRegistrations()) <= 0) {
  172.                 if ($student->getAnteriorBalance() > 0) {
  173.                     // Ajout de solde anterieur pour la première année de gestion
  174.                     $fee $settingFeeRepository->findOneBy(['establishment' => $registrationStudentRegistration->getEstablishment(), 'schoolYear' => $schoolYear'label'  => 'SOLDE ANTERIEUR'], []);
  175.                     if (null == $fee) {
  176.                         $fee = new SettingFee();
  177.                         $fee->setEstablishment($registrationStudentRegistration->getEstablishment());
  178.                         $fee->setCategory('AUTRE-FRAIS');
  179.                         $fee->setLabel('SOLDE ANTERIEUR');
  180.                         $fee->setAmount(0);
  181.                         $fee->setSchoolYear($schoolYear);
  182.                         $fee->setIsForAll(false);
  183.                         $fee->setIsForAffected(false);
  184.                         $fee->setIsForNonAffected(false);
  185.                         $entityManager->persist($fee);
  186.                     }
  187.                     $anteriorAccountingStudentRegistrationFee = new AccountingStudentRegistrationFee();
  188.                     $anteriorAccountingStudentRegistrationFee->setEstablishment($registrationStudentRegistration->getEstablishment());
  189.                     $anteriorAccountingStudentRegistrationFee->setStudentRegistration($registrationStudentRegistration);
  190.                     $anteriorAccountingStudentRegistrationFee->setFee($fee);
  191.                     $anteriorAccountingStudentRegistrationFee->setAmount($student->getAnteriorBalance());
  192.                     $anteriorAccountingStudentRegistrationFee->setCode($fee->getLabel().'-'.$registrationStudentRegistration->getId());
  193.                     $anteriorAccountingStudentRegistrationFee->setLabel($fee->getLabel());
  194.                     $anteriorAccountingStudentRegistrationFeeShedul = new AccountingStudentRegistrationFeeShedul();
  195.                     $anteriorAccountingStudentRegistrationFeeShedul->setAmount($student->getAnteriorBalance());
  196.                     $anteriorAccountingStudentRegistrationFeeShedul->setDateDue(new DateTimeImmutable());
  197.                     $anteriorAccountingStudentRegistrationFeeShedul->setOrderNum(1);
  198.                     $anteriorAccountingStudentRegistrationFeeShedul->setEstablishment($registrationStudentRegistration->getEstablishment());
  199.                     $anteriorAccountingStudentRegistrationFeeShedul->setStudentRegistrationFee($anteriorAccountingStudentRegistrationFee);
  200.                     
  201.                     $entityManager->persist($anteriorAccountingStudentRegistrationFeeShedul);
  202.                     $entityManager->persist($anteriorAccountingStudentRegistrationFee);
  203.                 }
  204.             }
  205.             // Ajout de solde anterieur à partir de la deuxième année de gestion
  206.             $anteriorRegistrationStudentRegistration $registrationStudentRegistrationRepository->findOneBy(['student' => $registrationStudentRegistration->getStudent()], ['id' => 'DESC']);
  207.             $order 0;
  208.             if (null != $anteriorRegistrationStudentRegistration) {
  209.                 foreach ($anteriorRegistrationStudentRegistration->getAccountingStudentRegistrationFees() as $key => $accountingStudentRegistrationFee) {
  210.                     $order++;
  211.                     if (!$accountingStudentRegistrationFee->getIsArchived()) {
  212.                         if (!$accountingStudentRegistrationFee->getIsCancel()) {
  213.                             if (!$accountingStudentRegistrationFee->getIsReported()) {
  214.                                 if ($accountingStudentRegistrationFee->getAmountRest() > 0) {
  215.                                     $anteriorAccountingStudentRegistrationFee = new AccountingStudentRegistrationFee();
  216.                                     $anteriorAccountingStudentRegistrationFee->setEstablishment($registrationStudentRegistration->getEstablishment());
  217.                                     $anteriorAccountingStudentRegistrationFee->setStudentRegistration($registrationStudentRegistration);
  218.                                     $anteriorAccountingStudentRegistrationFee->setFee($accountingStudentRegistrationFee->getFee());
  219.                                     $anteriorAccountingStudentRegistrationFee->setAmount($accountingStudentRegistrationFee->getAmountRest());
  220.                                     $anteriorAccountingStudentRegistrationFee->setCode('SA-'.$accountingStudentRegistrationFee->getLabel().'-'.$registrationStudentRegistration->getId());
  221.                                     $anteriorAccountingStudentRegistrationFee->setLabel('SOLDE ANT. '.$accountingStudentRegistrationFee->getLabel());
  222.                                     $anteriorAccountingStudentRegistrationFee->setIsArchived($accountingStudentRegistrationFee->getIsArchived());
  223.                                     $anteriorAccountingStudentRegistrationFee->setIsCancel($accountingStudentRegistrationFee->getIsCancel());
  224.                                     $anteriorAccountingStudentRegistrationFeeShedul = new AccountingStudentRegistrationFeeShedul();
  225.                                     $anteriorAccountingStudentRegistrationFeeShedul->setAmount($anteriorAccountingStudentRegistrationFee->getAmount());
  226.                                     $anteriorAccountingStudentRegistrationFeeShedul->setDateDue(new DateTimeImmutable());
  227.                                     $anteriorAccountingStudentRegistrationFeeShedul->setOrderNum($order);
  228.                                     $anteriorAccountingStudentRegistrationFeeShedul->setEstablishment($registrationStudentRegistration->getEstablishment());
  229.                                     $anteriorAccountingStudentRegistrationFeeShedul->setStudentRegistrationFee($anteriorAccountingStudentRegistrationFee);
  230.                                     
  231.                                     foreach ($accountingStudentRegistrationFee->getAccountingStudentRegistrationFeeSheduls() as $key => $accountingStudentRegistrationFeeShedul) {
  232.                                         $accountingStudentRegistrationFeeShedul->setAmountReported($accountingStudentRegistrationFeeShedul->getAmountCancel() + $accountingStudentRegistrationFeeShedul->getAmountRest());
  233.                                         $accountingStudentRegistrationFeeShedul->setIsReported(true);
  234.                                     }
  235.                                     
  236.                                     $accountingStudentRegistrationFee->setIsReported(true);
  237.                                     $accountingStudentRegistrationFee->setAmountReported($accountingStudentRegistrationFee->getAmountRest());
  238.                                     $entityManager->persist($anteriorAccountingStudentRegistrationFeeShedul);
  239.                                     $entityManager->persist($anteriorAccountingStudentRegistrationFee);
  240.                                 }
  241.                             }
  242.                         }
  243.                     }
  244.                 }
  245.             }
  246.             /* Ajout des frais de SCOLARITE pour tous*/
  247.             $settingScolariteFees $settingFeeRepository->findBy(['is_for_all' => true'category' => 'SCOLARITE''schoolYear' => $schoolYear'establishment' => $establishment],['id' => 'DESC']);
  248.             foreach ($settingScolariteFees as $key => $settingFee) {
  249.                 if($settingFee->getLevels()->contains($registrationStudentRegistration->getClassroom()->getLevel()->getParent()) || $settingFee->getLevels()->contains($registrationStudentRegistration->getClassroom()->getLevel()) || count($settingFee->getLevels()) <= 0){
  250.                     $accountingStudentRegistrationFee = new AccountingStudentRegistrationFee;
  251.                     $accountingStudentRegistrationFee->setStudentRegistration($registrationStudentRegistration);
  252.                     $accountingStudentRegistrationFee->setAmount($settingFee->getAmount());
  253.                     $accountingStudentRegistrationFee->setCode('ASF-'.$registrationStudentRegistration->getId().$settingFee->getId());
  254.                     $accountingStudentRegistrationFee->setFee($settingFee);
  255.                     $accountingStudentRegistrationFee->setEstablishment($this->getUser()->getEstablishment());
  256.                     $accountingStudentRegistrationFee->setLabel($settingFee->getLabel());
  257.                     $entityManager->persist($accountingStudentRegistrationFee);
  258.                     /* Etablissement des echeanciers */
  259.                     if (count($settingFee->getSettingFeeSheduls()) > 0) {
  260.                         foreach ($settingFee->getSettingFeeSheduls() as $key => $feeShedul) {
  261.                             $order++;
  262.                             $accountingStudentRegistrationFeeShedul = new AccountingStudentRegistrationFeeShedul();
  263.                             $accountingStudentRegistrationFeeShedul->setAmount($feeShedul->getAmount());
  264.                             $accountingStudentRegistrationFeeShedul->setDateDue($feeShedul->getDateDue());
  265.                             $accountingStudentRegistrationFeeShedul->setOrderNum($order);
  266.                             $accountingStudentRegistrationFeeShedul->setEstablishment($this->getUser()->getEstablishment());
  267.                             $accountingStudentRegistrationFeeShedul->setStudentRegistrationFee($accountingStudentRegistrationFee);
  268.                             $entityManager->persist($accountingStudentRegistrationFeeShedul);
  269.                         }
  270.                     }else {
  271.                         $accountingStudentRegistrationFeeShedul = new AccountingStudentRegistrationFeeShedul();
  272.                         $accountingStudentRegistrationFeeShedul->setAmount($settingFee->getAmount());
  273.                         $accountingStudentRegistrationFeeShedul->setDateDue(new DateTimeImmutable());
  274.                         $accountingStudentRegistrationFeeShedul->setOrderNum(1);
  275.                         $accountingStudentRegistrationFeeShedul->setEstablishment($this->getUser()->getEstablishment());
  276.                         $accountingStudentRegistrationFeeShedul->setStudentRegistrationFee($accountingStudentRegistrationFee);
  277.                         $entityManager->persist($accountingStudentRegistrationFeeShedul);
  278.                     }
  279.                 }
  280.             }
  281.             /* Ajout des frais de SCOLARITE  specifiques */
  282.             $settingScolariteAffectedFees $settingFeeRepository->findBy(['is_for_affected' => true'category' => 'SCOLARITE''schoolYear' => $schoolYear'establishment' => $establishment],['id' => 'DESC']);
  283.             $settingScolariteNonAffectedFees $settingFeeRepository->findBy(['is_for_non_affected' => true'category' => 'SCOLARITE''schoolYear' => $schoolYear'establishment' => $establishment],['id' => 'DESC']);
  284.             if ($registrationStudentRegistration->getIsAffected()) {
  285.                 foreach ($settingScolariteAffectedFees as $key => $settingFee) {
  286.                     if($settingFee->getLevels()->contains($registrationStudentRegistration->getClassroom()->getLevel()->getParent()) || $settingFee->getLevels()->contains($registrationStudentRegistration->getClassroom()->getLevel()) || count($settingFee->getLevels()) <= 0){
  287.                         $accountingStudentRegistrationFee = new AccountingStudentRegistrationFee;
  288.                         $accountingStudentRegistrationFee->setStudentRegistration($registrationStudentRegistration);
  289.                         $accountingStudentRegistrationFee->setAmount($settingFee->getAmount());
  290.                         $accountingStudentRegistrationFee->setCode('ASF-'.$registrationStudentRegistration->getId().$settingFee->getId());
  291.                         $accountingStudentRegistrationFee->setFee($settingFee);
  292.                         $accountingStudentRegistrationFee->setEstablishment($this->getUser()->getEstablishment());
  293.                         $accountingStudentRegistrationFee->setLabel($settingFee->getLabel());
  294.                         $entityManager->persist($accountingStudentRegistrationFee);
  295.                         /* Etablissement des echeancier */
  296.                         if (count($settingFee->getSettingFeeSheduls()) > 0) {
  297.                             foreach ($settingFee->getSettingFeeSheduls() as $key => $feeShedul) {
  298.                                 $order++;
  299.                                 $accountingStudentRegistrationFeeShedul = new AccountingStudentRegistrationFeeShedul();
  300.                                 $accountingStudentRegistrationFeeShedul->setAmount($feeShedul->getAmount());
  301.                                 $accountingStudentRegistrationFeeShedul->setDateDue($feeShedul->getDateDue());
  302.                                 $accountingStudentRegistrationFeeShedul->setOrderNum($order);
  303.                                 $accountingStudentRegistrationFeeShedul->setEstablishment($this->getUser()->getEstablishment());
  304.                                 $accountingStudentRegistrationFeeShedul->setStudentRegistrationFee($accountingStudentRegistrationFee);
  305.                                 $entityManager->persist($accountingStudentRegistrationFeeShedul);
  306.                             }
  307.                         }else {
  308.                             $accountingStudentRegistrationFeeShedul = new AccountingStudentRegistrationFeeShedul();
  309.                             $accountingStudentRegistrationFeeShedul->setAmount($settingFee->getAmount());
  310.                             $accountingStudentRegistrationFeeShedul->setDateDue(new DateTimeImmutable());
  311.                             $accountingStudentRegistrationFeeShedul->setOrderNum(1);
  312.                             $accountingStudentRegistrationFeeShedul->setEstablishment($this->getUser()->getEstablishment());
  313.                             $accountingStudentRegistrationFeeShedul->setStudentRegistrationFee($accountingStudentRegistrationFee);
  314.                             $entityManager->persist($accountingStudentRegistrationFeeShedul);
  315.                         }
  316.                     }
  317.                 }
  318.             }else{
  319.                 foreach ($settingScolariteNonAffectedFees as $key => $settingFee) {
  320.                     if($settingFee->getLevels()->contains($registrationStudentRegistration->getClassroom()->getLevel()->getParent()) || $settingFee->getLevels()->contains($registrationStudentRegistration->getClassroom()->getLevel()) || count($settingFee->getLevels()) <= 0){
  321.                         $accountingStudentRegistrationFee = new AccountingStudentRegistrationFee;
  322.                         $accountingStudentRegistrationFee->setStudentRegistration($registrationStudentRegistration);
  323.                         $accountingStudentRegistrationFee->setAmount($settingFee->getAmount());
  324.                         $accountingStudentRegistrationFee->setCode('ASF-'.$registrationStudentRegistration->getId().$settingFee->getId());
  325.                         $accountingStudentRegistrationFee->setFee($settingFee);
  326.                         $accountingStudentRegistrationFee->setEstablishment($this->getUser()->getEstablishment());
  327.                         $accountingStudentRegistrationFee->setLabel($settingFee->getLabel());
  328.                         $entityManager->persist($accountingStudentRegistrationFee);
  329.                         /* Etablissement des echeancier */
  330.                         if (count($settingFee->getSettingFeeSheduls()) > 0) {
  331.                             foreach ($settingFee->getSettingFeeSheduls() as $key => $feeShedul) {
  332.                                 $order++;
  333.                                 $accountingStudentRegistrationFeeShedul = new AccountingStudentRegistrationFeeShedul();
  334.                                 $accountingStudentRegistrationFeeShedul->setAmount($feeShedul->getAmount());
  335.                                 $accountingStudentRegistrationFeeShedul->setDateDue($feeShedul->getDateDue());
  336.                                 $accountingStudentRegistrationFeeShedul->setOrderNum($order);
  337.                                 $accountingStudentRegistrationFeeShedul->setEstablishment($this->getUser()->getEstablishment());
  338.                                 $accountingStudentRegistrationFeeShedul->setStudentRegistrationFee($accountingStudentRegistrationFee);
  339.                                 $entityManager->persist($accountingStudentRegistrationFeeShedul);
  340.                             }
  341.                         }else {
  342.                             $accountingStudentRegistrationFeeShedul = new AccountingStudentRegistrationFeeShedul();
  343.                             $accountingStudentRegistrationFeeShedul->setAmount($settingFee->getAmount());
  344.                             $accountingStudentRegistrationFeeShedul->setDateDue(new DateTimeImmutable());
  345.                             $accountingStudentRegistrationFeeShedul->setOrderNum(1);
  346.                             $accountingStudentRegistrationFeeShedul->setEstablishment($this->getUser()->getEstablishment());
  347.                             $accountingStudentRegistrationFeeShedul->setStudentRegistrationFee($accountingStudentRegistrationFee);
  348.                             $entityManager->persist($accountingStudentRegistrationFeeShedul);
  349.                         }
  350.                     }
  351.                 }
  352.             }
  353.             /* Ajout des frais de ARTICLE pour tous */
  354.             $settingArticleFees $settingFeeRepository->findBy(['is_for_all' => true'category' => 'ARTICLE''schoolYear' => $schoolYear'establishment' => $establishment],['id' => 'DESC']);
  355.             $settingArticleAffectedFees $settingFeeRepository->findBy(['is_for_affected' => true'category' => 'ARTICLE''schoolYear' => $schoolYear'establishment' => $establishment],['id' => 'DESC']);
  356.             $settingArticleNonAffectedFees $settingFeeRepository->findBy(['is_for_non_affected' => true'category' => 'ARTICLE''schoolYear' => $schoolYear'establishment' => $establishment],['id' => 'DESC']);
  357.             foreach ($settingArticleFees as $key => $settingFee) {
  358.                 if($settingFee->getLevels()->contains($registrationStudentRegistration->getClassroom()->getLevel()->getParent()) || $settingFee->getLevels()->contains($registrationStudentRegistration->getClassroom()->getLevel()) || count($settingFee->getLevels()) <= 0){
  359.                     $accountingStudentRegistrationFee = new AccountingStudentRegistrationFee;
  360.                     $accountingStudentRegistrationFee->setStudentRegistration($registrationStudentRegistration);
  361.                     $accountingStudentRegistrationFee->setAmount($settingFee->getAmount());
  362.                     $accountingStudentRegistrationFee->setCode('ASF-'.$registrationStudentRegistration->getId().$settingFee->getId());
  363.                     $accountingStudentRegistrationFee->setFee($settingFee);
  364.                     $accountingStudentRegistrationFee->setEstablishment($this->getUser()->getEstablishment());
  365.                     $accountingStudentRegistrationFee->setLabel($settingFee->getLabel());
  366.                     $entityManager->persist($accountingStudentRegistrationFee);
  367.                     /* Etablissement des echeancier */
  368.                     if (count($settingFee->getSettingFeeSheduls()) > 0) {
  369.                         foreach ($settingFee->getSettingFeeSheduls() as $key => $feeShedul) {
  370.                             $order++;
  371.                             $accountingStudentRegistrationFeeShedul = new AccountingStudentRegistrationFeeShedul();
  372.                             $accountingStudentRegistrationFeeShedul->setAmount($feeShedul->getAmount());
  373.                             $accountingStudentRegistrationFeeShedul->setDateDue($feeShedul->getDateDue());
  374.                             $accountingStudentRegistrationFeeShedul->setOrderNum($order);
  375.                             $accountingStudentRegistrationFeeShedul->setEstablishment($this->getUser()->getEstablishment());
  376.                             $accountingStudentRegistrationFeeShedul->setStudentRegistrationFee($accountingStudentRegistrationFee);
  377.                             $entityManager->persist($accountingStudentRegistrationFeeShedul);
  378.                         }
  379.                     }else {
  380.                         $accountingStudentRegistrationFeeShedul = new AccountingStudentRegistrationFeeShedul();
  381.                         $accountingStudentRegistrationFeeShedul->setAmount($settingFee->getAmount());
  382.                         $accountingStudentRegistrationFeeShedul->setDateDue(new DateTimeImmutable());
  383.                         $accountingStudentRegistrationFeeShedul->setOrderNum(1);
  384.                         $accountingStudentRegistrationFeeShedul->setEstablishment($this->getUser()->getEstablishment());
  385.                         $accountingStudentRegistrationFeeShedul->setStudentRegistrationFee($accountingStudentRegistrationFee);
  386.                         $entityManager->persist($accountingStudentRegistrationFeeShedul);
  387.                     }
  388.                 }
  389.             }
  390.             /* Ajout des frais de ARTICLE specifique */
  391.             if ($registrationStudentRegistration->getIsAffected()) {
  392.                 foreach ($settingArticleAffectedFees as $key => $settingFee) {
  393.                     if($settingFee->getLevels()->contains($registrationStudentRegistration->getClassroom()->getLevel()->getParent()) || $settingFee->getLevels()->contains($registrationStudentRegistration->getClassroom()->getLevel()) || count($settingFee->getLevels()) <= 0){
  394.                         $accountingStudentRegistrationFee = new AccountingStudentRegistrationFee;
  395.                         $accountingStudentRegistrationFee->setStudentRegistration($registrationStudentRegistration);
  396.                         $accountingStudentRegistrationFee->setAmount($settingFee->getAmount());
  397.                         $accountingStudentRegistrationFee->setCode('ASF-'.$registrationStudentRegistration->getId().$settingFee->getId());
  398.                         $accountingStudentRegistrationFee->setFee($settingFee);
  399.                         $accountingStudentRegistrationFee->setEstablishment($this->getUser()->getEstablishment());
  400.                         $accountingStudentRegistrationFee->setLabel($settingFee->getLabel());
  401.                         $entityManager->persist($accountingStudentRegistrationFee);
  402.                         /* Etablissement des echeancier */
  403.                         if (count($settingFee->getSettingFeeSheduls()) > 0) {
  404.                             foreach ($settingFee->getSettingFeeSheduls() as $key => $feeShedul) {
  405.                                 $order++;
  406.                                 $accountingStudentRegistrationFeeShedul = new AccountingStudentRegistrationFeeShedul();
  407.                                 $accountingStudentRegistrationFeeShedul->setAmount($feeShedul->getAmount());
  408.                                 $accountingStudentRegistrationFeeShedul->setDateDue($feeShedul->getDateDue());
  409.                                 $accountingStudentRegistrationFeeShedul->setOrderNum($order);
  410.                                 $accountingStudentRegistrationFeeShedul->setEstablishment($this->getUser()->getEstablishment());
  411.                                 $accountingStudentRegistrationFeeShedul->setStudentRegistrationFee($accountingStudentRegistrationFee);
  412.                                 $entityManager->persist($accountingStudentRegistrationFeeShedul);
  413.                             }
  414.                         }else {
  415.                             $accountingStudentRegistrationFeeShedul = new AccountingStudentRegistrationFeeShedul();
  416.                             $accountingStudentRegistrationFeeShedul->setAmount($settingFee->getAmount());
  417.                             $accountingStudentRegistrationFeeShedul->setDateDue(new DateTimeImmutable());
  418.                             $accountingStudentRegistrationFeeShedul->setOrderNum(1);
  419.                             $accountingStudentRegistrationFeeShedul->setEstablishment($this->getUser()->getEstablishment());
  420.                             $accountingStudentRegistrationFeeShedul->setStudentRegistrationFee($accountingStudentRegistrationFee);
  421.                             $entityManager->persist($accountingStudentRegistrationFeeShedul);
  422.                         }
  423.                     }
  424.                 }
  425.             }else {
  426.                 foreach ($settingArticleNonAffectedFees as $key => $settingFee) {
  427.                     if($settingFee->getLevels()->contains($registrationStudentRegistration->getClassroom()->getLevel()->getParent()) || $settingFee->getLevels()->contains($registrationStudentRegistration->getClassroom()->getLevel()) || count($settingFee->getLevels()) <= 0){
  428.                         $accountingStudentRegistrationFee = new AccountingStudentRegistrationFee;
  429.                         $accountingStudentRegistrationFee->setStudentRegistration($registrationStudentRegistration);
  430.                         $accountingStudentRegistrationFee->setAmount($settingFee->getAmount());
  431.                         $accountingStudentRegistrationFee->setCode('ASF-'.$registrationStudentRegistration->getId().$settingFee->getId());
  432.                         $accountingStudentRegistrationFee->setFee($settingFee);
  433.                         $accountingStudentRegistrationFee->setEstablishment($this->getUser()->getEstablishment());
  434.                         $accountingStudentRegistrationFee->setLabel($settingFee->getLabel());
  435.                         $entityManager->persist($accountingStudentRegistrationFee);
  436.                         /* Etablissement des echeancier */
  437.                         if (count($settingFee->getSettingFeeSheduls()) > 0) {
  438.                             foreach ($settingFee->getSettingFeeSheduls() as $key => $feeShedul) {
  439.                                 $order++;
  440.                                 $accountingStudentRegistrationFeeShedul = new AccountingStudentRegistrationFeeShedul();
  441.                                 $accountingStudentRegistrationFeeShedul->setAmount($feeShedul->getAmount());
  442.                                 $accountingStudentRegistrationFeeShedul->setDateDue($feeShedul->getDateDue());
  443.                                 $accountingStudentRegistrationFeeShedul->setOrderNum($order);
  444.                                 $accountingStudentRegistrationFeeShedul->setEstablishment($this->getUser()->getEstablishment());
  445.                                 $accountingStudentRegistrationFeeShedul->setStudentRegistrationFee($accountingStudentRegistrationFee);
  446.                                 $entityManager->persist($accountingStudentRegistrationFeeShedul);
  447.                             }
  448.                         }else {
  449.                             $accountingStudentRegistrationFeeShedul = new AccountingStudentRegistrationFeeShedul();
  450.                             $accountingStudentRegistrationFeeShedul->setAmount($settingFee->getAmount());
  451.                             $accountingStudentRegistrationFeeShedul->setDateDue(new DateTimeImmutable());
  452.                             $accountingStudentRegistrationFeeShedul->setOrderNum(1);
  453.                             $accountingStudentRegistrationFeeShedul->setEstablishment($this->getUser()->getEstablishment());
  454.                             $accountingStudentRegistrationFeeShedul->setStudentRegistrationFee($accountingStudentRegistrationFee);
  455.                             $entityManager->persist($accountingStudentRegistrationFeeShedul);
  456.                         }
  457.                     }
  458.                 }
  459.             }
  460.             /* Ajout des frais de ACTIVITE-EXTAT pour tous */
  461.             $settingActiviteExtratFees $settingFeeRepository->findBy(['is_for_all' => true'category' => 'ACTIVITE-EXTAT''schoolYear' => $schoolYear'establishment' => $establishment],['id' => 'DESC']);
  462.             $settingActiviteExtratAffectedFees $settingFeeRepository->findBy(['is_for_affected' => true'category' => 'ACTIVITE-EXTAT''schoolYear' => $schoolYear'establishment' => $establishment],['id' => 'DESC']);
  463.             $settingActiviteExtratNonAffectedFees $settingFeeRepository->findBy(['is_for_non_affected' => true'category' => 'ACTIVITE-EXTAT''schoolYear' => $schoolYear'establishment' => $establishment],['id' => 'DESC']);
  464.             foreach ($settingActiviteExtratFees as $key => $settingFee) {
  465.                 if($settingFee->getLevels()->contains($registrationStudentRegistration->getClassroom()->getLevel()->getParent()) || $settingFee->getLevels()->contains($registrationStudentRegistration->getClassroom()->getLevel()) || count($settingFee->getLevels()) <= 0){
  466.                     $accountingStudentRegistrationFee = new AccountingStudentRegistrationFee;
  467.                     $accountingStudentRegistrationFee->setStudentRegistration($registrationStudentRegistration);
  468.                     $accountingStudentRegistrationFee->setAmount($settingFee->getAmount());
  469.                     $accountingStudentRegistrationFee->setCode('ASF-'.$registrationStudentRegistration->getId().$settingFee->getId());
  470.                     $accountingStudentRegistrationFee->setFee($settingFee);
  471.                     $accountingStudentRegistrationFee->setEstablishment($this->getUser()->getEstablishment());
  472.                     $accountingStudentRegistrationFee->setLabel($settingFee->getLabel());
  473.                     $entityManager->persist($accountingStudentRegistrationFee);
  474.                     /* Etablissement des echeancier */
  475.                     if (count($settingFee->getSettingFeeSheduls()) > 0) {
  476.                         foreach ($settingFee->getSettingFeeSheduls() as $key => $feeShedul) {
  477.                             $order++;
  478.                             $accountingStudentRegistrationFeeShedul = new AccountingStudentRegistrationFeeShedul();
  479.                             $accountingStudentRegistrationFeeShedul->setAmount($feeShedul->getAmount());
  480.                             $accountingStudentRegistrationFeeShedul->setDateDue($feeShedul->getDateDue());
  481.                             $accountingStudentRegistrationFeeShedul->setOrderNum($order);
  482.                             $accountingStudentRegistrationFeeShedul->setEstablishment($this->getUser()->getEstablishment());
  483.                             $accountingStudentRegistrationFeeShedul->setStudentRegistrationFee($accountingStudentRegistrationFee);
  484.                             $entityManager->persist($accountingStudentRegistrationFeeShedul);
  485.                         }
  486.                     }else {
  487.                         $accountingStudentRegistrationFeeShedul = new AccountingStudentRegistrationFeeShedul();
  488.                         $accountingStudentRegistrationFeeShedul->setAmount($settingFee->getAmount());
  489.                         $accountingStudentRegistrationFeeShedul->setDateDue(new DateTimeImmutable());
  490.                         $accountingStudentRegistrationFeeShedul->setOrderNum(1);
  491.                         $accountingStudentRegistrationFeeShedul->setEstablishment($this->getUser()->getEstablishment());
  492.                         $accountingStudentRegistrationFeeShedul->setStudentRegistrationFee($accountingStudentRegistrationFee);
  493.                         $entityManager->persist($accountingStudentRegistrationFeeShedul);
  494.                     }
  495.                 }
  496.             }
  497.             /* Ajout des frais de ACTIVITE-EXTAT specifique */
  498.             if ($registrationStudentRegistration->getIsAffected()) {
  499.                 foreach ($settingActiviteExtratAffectedFees as $key => $settingFee) {
  500.                     if($settingFee->getLevels()->contains($registrationStudentRegistration->getClassroom()->getLevel()->getParent()) || $settingFee->getLevels()->contains($registrationStudentRegistration->getClassroom()->getLevel()) || count($settingFee->getLevels()) <= 0){
  501.                         $accountingStudentRegistrationFee = new AccountingStudentRegistrationFee;
  502.                         $accountingStudentRegistrationFee->setStudentRegistration($registrationStudentRegistration);
  503.                         $accountingStudentRegistrationFee->setAmount($settingFee->getAmount());
  504.                         $accountingStudentRegistrationFee->setCode('ASF-'.$registrationStudentRegistration->getId().$settingFee->getId());
  505.                         $accountingStudentRegistrationFee->setFee($settingFee);
  506.                         $accountingStudentRegistrationFee->setEstablishment($this->getUser()->getEstablishment());
  507.                         $accountingStudentRegistrationFee->setLabel($settingFee->getLabel());
  508.                         $entityManager->persist($accountingStudentRegistrationFee);
  509.                         /* Etablissement des echeancier */
  510.                         if (count($settingFee->getSettingFeeSheduls()) > 0) {
  511.                             foreach ($settingFee->getSettingFeeSheduls() as $key => $feeShedul) {
  512.                                 $order++;
  513.                                 $accountingStudentRegistrationFeeShedul = new AccountingStudentRegistrationFeeShedul();
  514.                                 $accountingStudentRegistrationFeeShedul->setAmount($feeShedul->getAmount());
  515.                                 $accountingStudentRegistrationFeeShedul->setDateDue($feeShedul->getDateDue());
  516.                                 $accountingStudentRegistrationFeeShedul->setOrderNum($order);
  517.                                 $accountingStudentRegistrationFeeShedul->setEstablishment($this->getUser()->getEstablishment());
  518.                                 $accountingStudentRegistrationFeeShedul->setStudentRegistrationFee($accountingStudentRegistrationFee);
  519.                                 $entityManager->persist($accountingStudentRegistrationFeeShedul);
  520.                             }
  521.                         }else {
  522.                             $order++;
  523.                             $accountingStudentRegistrationFeeShedul = new AccountingStudentRegistrationFeeShedul();
  524.                             $accountingStudentRegistrationFeeShedul->setAmount($settingFee->getAmount());
  525.                             $accountingStudentRegistrationFeeShedul->setDateDue(new DateTimeImmutable());
  526.                             $accountingStudentRegistrationFeeShedul->setOrderNum($order);
  527.                             $accountingStudentRegistrationFeeShedul->setEstablishment($this->getUser()->getEstablishment());
  528.                             $accountingStudentRegistrationFeeShedul->setStudentRegistrationFee($accountingStudentRegistrationFee);
  529.                             $entityManager->persist($accountingStudentRegistrationFeeShedul);
  530.                         }
  531.                     }
  532.                 }
  533.             }else {
  534.                 foreach ($settingActiviteExtratNonAffectedFees as $key => $settingFee) {
  535.                     if($settingFee->getLevels()->contains($registrationStudentRegistration->getClassroom()->getLevel()->getParent()) || $settingFee->getLevels()->contains($registrationStudentRegistration->getClassroom()->getLevel()) || count($settingFee->getLevels()) <= 0){
  536.                         $accountingStudentRegistrationFee = new AccountingStudentRegistrationFee;
  537.                         $accountingStudentRegistrationFee->setStudentRegistration($registrationStudentRegistration);
  538.                         $accountingStudentRegistrationFee->setAmount($settingFee->getAmount());
  539.                         $accountingStudentRegistrationFee->setCode('ASF-'.$registrationStudentRegistration->getId().$settingFee->getId());
  540.                         $accountingStudentRegistrationFee->setFee($settingFee);
  541.                         $accountingStudentRegistrationFee->setEstablishment($this->getUser()->getEstablishment());
  542.                         $accountingStudentRegistrationFee->setLabel($settingFee->getLabel());
  543.                         $entityManager->persist($accountingStudentRegistrationFee);
  544.                         /* Etablissement des echeancier */
  545.                         if (count($settingFee->getSettingFeeSheduls()) > 0) {
  546.                             foreach ($settingFee->getSettingFeeSheduls() as $key => $feeShedul) {
  547.                                 $order++;
  548.                                 $accountingStudentRegistrationFeeShedul = new AccountingStudentRegistrationFeeShedul();
  549.                                 $accountingStudentRegistrationFeeShedul->setAmount($feeShedul->getAmount());
  550.                                 $accountingStudentRegistrationFeeShedul->setDateDue($feeShedul->getDateDue());
  551.                                 $accountingStudentRegistrationFeeShedul->setOrderNum($order);
  552.                                 $accountingStudentRegistrationFeeShedul->setEstablishment($this->getUser()->getEstablishment());
  553.                                 $accountingStudentRegistrationFeeShedul->setStudentRegistrationFee($accountingStudentRegistrationFee);
  554.                                 $entityManager->persist($accountingStudentRegistrationFeeShedul);
  555.                             }
  556.                         }else {
  557.                             $order++;
  558.                             $accountingStudentRegistrationFeeShedul = new AccountingStudentRegistrationFeeShedul();
  559.                             $accountingStudentRegistrationFeeShedul->setAmount($settingFee->getAmount());
  560.                             $accountingStudentRegistrationFeeShedul->setDateDue(new DateTimeImmutable());
  561.                             $accountingStudentRegistrationFeeShedul->setOrderNum($order);
  562.                             $accountingStudentRegistrationFeeShedul->setEstablishment($this->getUser()->getEstablishment());
  563.                             $accountingStudentRegistrationFeeShedul->setStudentRegistrationFee($accountingStudentRegistrationFee);
  564.                             $entityManager->persist($accountingStudentRegistrationFeeShedul);
  565.                         }
  566.                     }
  567.                 }
  568.             }
  569.             /* Ajout des frais de AUTRE-FRAIS pour tous */
  570.             $settingAutreFraisFees $settingFeeRepository->findBy(['is_for_all' => true'category' => 'AUTRE-FRAIS''schoolYear' => $schoolYear'establishment' => $establishment],['id' => 'DESC']);
  571.             $settingAutreFraisAffectedFees $settingFeeRepository->findBy(['is_for_affected' => true'category' => 'AUTRE-FRAIS''schoolYear' => $schoolYear'establishment' => $establishment],['id' => 'DESC']);
  572.             $settingAutreFraisNonAffectedFees $settingFeeRepository->findBy(['is_for_non_affected' => true'category' => 'AUTRE-FRAIS''schoolYear' => $schoolYear'establishment' => $establishment],['id' => 'DESC']);
  573.             foreach ($settingAutreFraisFees as $key => $settingFee) {
  574.                 if($settingFee->getLevels()->contains($registrationStudentRegistration->getClassroom()->getLevel()->getParent()) || $settingFee->getLevels()->contains($registrationStudentRegistration->getClassroom()->getLevel()) || count($settingFee->getLevels()) <= 0){
  575.                     $accountingStudentRegistrationFee = new AccountingStudentRegistrationFee;
  576.                     $accountingStudentRegistrationFee->setStudentRegistration($registrationStudentRegistration);
  577.                     $accountingStudentRegistrationFee->setAmount($settingFee->getAmount());
  578.                     $accountingStudentRegistrationFee->setCode('ASF-'.$registrationStudentRegistration->getId().$settingFee->getId());
  579.                     $accountingStudentRegistrationFee->setFee($settingFee);
  580.                     $accountingStudentRegistrationFee->setEstablishment($this->getUser()->getEstablishment());
  581.                     $accountingStudentRegistrationFee->setLabel($settingFee->getLabel());
  582.                     $entityManager->persist($accountingStudentRegistrationFee);
  583.                     /* Etablissement des echeancier */
  584.                     if (count($settingFee->getSettingFeeSheduls()) > 0) {
  585.                         foreach ($settingFee->getSettingFeeSheduls() as $key => $feeShedul) {
  586.                             $order++;
  587.                             $accountingStudentRegistrationFeeShedul = new AccountingStudentRegistrationFeeShedul();
  588.                             $accountingStudentRegistrationFeeShedul->setAmount($feeShedul->getAmount());
  589.                             $accountingStudentRegistrationFeeShedul->setDateDue($feeShedul->getDateDue());
  590.                             $accountingStudentRegistrationFeeShedul->setOrderNum($order);
  591.                             $accountingStudentRegistrationFeeShedul->setEstablishment($this->getUser()->getEstablishment());
  592.                             $accountingStudentRegistrationFeeShedul->setStudentRegistrationFee($accountingStudentRegistrationFee);
  593.                             $entityManager->persist($accountingStudentRegistrationFeeShedul);
  594.                         }
  595.                     }else {
  596.                         $order++;
  597.                         $accountingStudentRegistrationFeeShedul = new AccountingStudentRegistrationFeeShedul();
  598.                         $accountingStudentRegistrationFeeShedul->setAmount($settingFee->getAmount());
  599.                         $accountingStudentRegistrationFeeShedul->setDateDue(new DateTimeImmutable());
  600.                         $accountingStudentRegistrationFeeShedul->setOrderNum($order);
  601.                         $accountingStudentRegistrationFeeShedul->setEstablishment($this->getUser()->getEstablishment());
  602.                         $accountingStudentRegistrationFeeShedul->setStudentRegistrationFee($accountingStudentRegistrationFee);
  603.                         $entityManager->persist($accountingStudentRegistrationFeeShedul);
  604.                     }
  605.                 }
  606.             }
  607.             /* Ajout des frais de ACTIVITE-EXTAT specifique */
  608.             if ($registrationStudentRegistration->getIsAffected()) {
  609.                 foreach ($settingAutreFraisAffectedFees as $key => $settingFee) {
  610.                     if($settingFee->getLevels()->contains($registrationStudentRegistration->getClassroom()->getLevel()->getParent()) || $settingFee->getLevels()->contains($registrationStudentRegistration->getClassroom()->getLevel()) || count($settingFee->getLevels()) <= 0){
  611.                         $accountingStudentRegistrationFee = new AccountingStudentRegistrationFee;
  612.                         $accountingStudentRegistrationFee->setStudentRegistration($registrationStudentRegistration);
  613.                         $accountingStudentRegistrationFee->setAmount($settingFee->getAmount());
  614.                         $accountingStudentRegistrationFee->setCode('ASF-'.$registrationStudentRegistration->getId().$settingFee->getId());
  615.                         $accountingStudentRegistrationFee->setFee($settingFee);
  616.                         $accountingStudentRegistrationFee->setEstablishment($this->getUser()->getEstablishment());
  617.                         $accountingStudentRegistrationFee->setLabel($settingFee->getLabel());
  618.                         $entityManager->persist($accountingStudentRegistrationFee);
  619.                         /* Etablissement des echeancier */
  620.                         if (count($settingFee->getSettingFeeSheduls()) > 0) {
  621.                             foreach ($settingFee->getSettingFeeSheduls() as $key => $feeShedul) {
  622.                                 $order++;
  623.                                 $accountingStudentRegistrationFeeShedul = new AccountingStudentRegistrationFeeShedul();
  624.                                 $accountingStudentRegistrationFeeShedul->setAmount($feeShedul->getAmount());
  625.                                 $accountingStudentRegistrationFeeShedul->setDateDue($feeShedul->getDateDue());
  626.                                 $accountingStudentRegistrationFeeShedul->setOrderNum($order);
  627.                                 $accountingStudentRegistrationFeeShedul->setEstablishment($this->getUser()->getEstablishment());
  628.                                 $accountingStudentRegistrationFeeShedul->setStudentRegistrationFee($accountingStudentRegistrationFee);
  629.                                 $entityManager->persist($accountingStudentRegistrationFeeShedul);
  630.                             }
  631.                         }else {
  632.                             $order++;
  633.                             $accountingStudentRegistrationFeeShedul = new AccountingStudentRegistrationFeeShedul();
  634.                             $accountingStudentRegistrationFeeShedul->setAmount($settingFee->getAmount());
  635.                             $accountingStudentRegistrationFeeShedul->setDateDue(new DateTimeImmutable());
  636.                             $accountingStudentRegistrationFeeShedul->setOrderNum($order);
  637.                             $accountingStudentRegistrationFeeShedul->setEstablishment($this->getUser()->getEstablishment());
  638.                             $accountingStudentRegistrationFeeShedul->setStudentRegistrationFee($accountingStudentRegistrationFee);
  639.                             $entityManager->persist($accountingStudentRegistrationFeeShedul);
  640.                         }
  641.                     }
  642.                 }
  643.             }else {
  644.                 foreach ($settingAutreFraisNonAffectedFees as $key => $settingFee) {
  645.                     if($settingFee->getLevels()->contains($registrationStudentRegistration->getClassroom()->getLevel()->getParent()) || $settingFee->getLevels()->contains($registrationStudentRegistration->getClassroom()->getLevel()) || count($settingFee->getLevels()) <= 0){
  646.                         $accountingStudentRegistrationFee = new AccountingStudentRegistrationFee;
  647.                         $accountingStudentRegistrationFee->setStudentRegistration($registrationStudentRegistration);
  648.                         $accountingStudentRegistrationFee->setAmount($settingFee->getAmount());
  649.                         $accountingStudentRegistrationFee->setCode('ASF-'.$registrationStudentRegistration->getId().$settingFee->getId());
  650.                         $accountingStudentRegistrationFee->setFee($settingFee);
  651.                         $accountingStudentRegistrationFee->setEstablishment($this->getUser()->getEstablishment());
  652.                         $accountingStudentRegistrationFee->setLabel($settingFee->getLabel());
  653.                         $entityManager->persist($accountingStudentRegistrationFee);
  654.                         /* Etablissement des echeancier */
  655.                         if (count($settingFee->getSettingFeeSheduls()) > 0) {
  656.                             foreach ($settingFee->getSettingFeeSheduls() as $key => $feeShedul) {
  657.                                 $order++;
  658.                                 $accountingStudentRegistrationFeeShedul = new AccountingStudentRegistrationFeeShedul();
  659.                                 $accountingStudentRegistrationFeeShedul->setAmount($feeShedul->getAmount());
  660.                                 $accountingStudentRegistrationFeeShedul->setDateDue($feeShedul->getDateDue());
  661.                                 $accountingStudentRegistrationFeeShedul->setOrderNum($order);
  662.                                 $accountingStudentRegistrationFeeShedul->setEstablishment($this->getUser()->getEstablishment());
  663.                                 $accountingStudentRegistrationFeeShedul->setStudentRegistrationFee($accountingStudentRegistrationFee);
  664.                                 $entityManager->persist($accountingStudentRegistrationFeeShedul);
  665.                             }
  666.                         }else {
  667.                             $order++;
  668.                             $accountingStudentRegistrationFeeShedul = new AccountingStudentRegistrationFeeShedul();
  669.                             $accountingStudentRegistrationFeeShedul->setAmount($settingFee->getAmount());
  670.                             $accountingStudentRegistrationFeeShedul->setDateDue(new DateTimeImmutable());
  671.                             $accountingStudentRegistrationFeeShedul->setOrderNum($order);
  672.                             $accountingStudentRegistrationFeeShedul->setEstablishment($this->getUser()->getEstablishment());
  673.                             $accountingStudentRegistrationFeeShedul->setStudentRegistrationFee($accountingStudentRegistrationFee);
  674.                             $entityManager->persist($accountingStudentRegistrationFeeShedul);
  675.                         }
  676.                     }
  677.                 }
  678.             }
  679.             $entityManager->persist($registrationStudentRegistration);
  680.             try {
  681.                 $entityManager->flush();
  682.                 $this->addFlash('success'"Un inscrit à été ajouté.");
  683.             } catch (\Throwable $th) {
  684.                 $this->addFlash('warning'"Une erreure est survenue lors de l'ajout de l'inscrit.");
  685.                 $this->addFlash('info'$th->getMessage());
  686.             }
  687.             return $this->redirectToRoute('registration_student_registration_index', [], Response::HTTP_SEE_OTHER);
  688.         }
  689.         return $this->renderForm('registration/registration_student_registration/new.html.twig', [
  690.             'registration_student_registration' => $registrationStudentRegistration,
  691.             'form' => $form,
  692.         ]);
  693.     }
  694.     /**
  695.      * @Route("/{id}/show", name="registration_student_registration_show", methods={"GET","POST"})
  696.      */
  697.     public function show(Request $requestRegistrationStudentRegistration $registrationStudentRegistrationSettingFeeRepository $settingFeeRepositoryTransportZoneRepository $transportZoneRepositorySMSSender $smsSender): Response
  698.     {
  699.         /**@var User $user */
  700.         $user $this->getUser();
  701.         $schoolYear $user->getSchoolYear();
  702.         $establishment $this->getUser()->getEstablishment();
  703.         
  704.         /* Ajouter un nouveau frais */
  705.         $setting_fees $settingFeeRepository->createQueryBuilder('entity')
  706.         ->andWhere('entity.establishment = :establishment')
  707.         ->setParameter('establishment'$establishment)
  708.         ->andWhere('entity.schoolYear = :schoolYear')
  709.         ->setParameter('schoolYear'$schoolYear)
  710.         ->andWhere('entity.category != :category')
  711.         ->setParameter('category''SCOLARITE')
  712.         ->andWhere('entity.category != :category')
  713.         ->setParameter('category'SettingFee::TRANSPORT_FEE)
  714.         ->orderBy('entity.id''DESC')
  715.         ->getQuery()
  716.         ->getResult();
  717.         $accountingStudentRegistrationFee = new AccountingStudentRegistrationFee();
  718.         $accountingStudentRegistrationFeeForm $this->createForm(AccountingStudentRegistrationFeeType::class, $accountingStudentRegistrationFee)
  719.         ->add('fee'EntityType::class,[
  720.             'class' => SettingFee::class,
  721.             'choices' => $setting_fees
  722.         ]);
  723.         $accountingStudentRegistrationFeeForm->handleRequest($request);
  724.         if ($accountingStudentRegistrationFeeForm->isSubmitted() && $accountingStudentRegistrationFeeForm->isValid()) {
  725.             $entityManager $this->getDoctrine()->getManager();
  726.             $settingFee $accountingStudentRegistrationFee->getFee();
  727.             if (strlen($settingFee->getDuration()) > && null == $accountingStudentRegistrationFee->getStartAt()) {
  728.                 $this->addFlash('warning'"Veuillez saisir la date de debut SVP.");
  729.                 return $this->redirectToRoute('registration_student_registration_show', ['id' => $registrationStudentRegistration->getId()]);
  730.             }
  731.             /** set start date end end date */
  732.             if (null != $accountingStudentRegistrationFee->getStartAt()) {
  733.                 if ($settingFee->getDuration() == 'JOURNALIER') {
  734.                     $accountingStudentRegistrationFee->setEndAt($accountingStudentRegistrationFee->getStartAt());
  735.                     
  736.                 }
  737.                 if ($settingFee->getDuration() == 'HEBDOMADAIRE') {
  738.                     $date $accountingStudentRegistrationFee->getStartAt();
  739.                     $njdsc date($date->format('w') , strtotime("-7 days"));
  740.                     $njmc date("t");
  741.                     switch ($njdsc) {
  742.                         case 0:
  743.                             $accountingStudentRegistrationFee->setEndAt($date->sub(new DateInterval("P2D")));
  744.                             break;
  745.                         case 1:
  746.                             $accountingStudentRegistrationFee->setEndAt($date->add(new DateInterval("P4D")));
  747.                             break;
  748.                         case 2:
  749.                             $accountingStudentRegistrationFee->setEndAt($date->add(new DateInterval("P3D")));
  750.                             break;
  751.                         case 3:
  752.                             $accountingStudentRegistrationFee->setEndAt($date->add(new DateInterval("P2D")));
  753.                             break;
  754.                         case 4:
  755.                             $accountingStudentRegistrationFee->setEndAt($date->add(new DateInterval("P1D")));
  756.                             break;
  757.                         case 5:
  758.                             $accountingStudentRegistrationFee->setEndAt($date->add(new DateInterval("P0D")));
  759.                             break;
  760.                         case 6:
  761.                             $accountingStudentRegistrationFee->setEndAt($date->sub(new DateInterval("P1D")));
  762.                             break;
  763.                         default:
  764.                             # code...
  765.                             break;
  766.                     }
  767.                 }
  768.                 if ($settingFee->getDuration() == 'MENSUEL-SIMPLE') {
  769.                     $date $accountingStudentRegistrationFee->getStartAt();
  770.                     $njdsc date($date->format('w') , strtotime("-7 days"));
  771.                     $njmc date("t");
  772.                     $date_end = new DateTimeImmutable($date->format('Y-m-').$njmc);
  773.                     $accountingStudentRegistrationFee->setEndAt($date_end);
  774.                     if ($date_end->format('D') == 'Sun') {
  775.                         $accountingStudentRegistrationFee->setEndAt($date_end->sub(new DateInterval("P2D")));
  776.                     }
  777.                     if ($date_end->format('D') == 'Sat') {
  778.                         $accountingStudentRegistrationFee->setEndAt($date_end->sub(new DateInterval("P1D")));
  779.                     }
  780.                 }
  781.                 if ($settingFee->getDuration() == 'MENSUEL-FULL') {
  782.                     $date $accountingStudentRegistrationFee->getStartAt();
  783.                     $njdsc date($date->format('w') , strtotime("-7 days"));
  784.                     $njmc date("t");
  785.                     $date_end = new DateTimeImmutable($date->format('Y-m-').$njmc);
  786.                     $accountingStudentRegistrationFee->setEndAt($date_end);
  787.                 }
  788.                 $contacts = [];
  789.                 $contacts[] = '225'.str_replace(' ''',trim($registrationStudentRegistration->getStudent()->getNotificationPhoneNumber()));
  790.                 $message "BIENVENUE A LA GARDERIE, VOTRE ABONNEMENT "$settingFee->getLabel() ." DEBUTE LE "strtoupper(DateIntervalManage::FRENCH_DAY[$accountingStudentRegistrationFee->getStartAt()->format('D')]). ' ' .$accountingStudentRegistrationFee->getStartAt()->format('d'). ' ' .strtoupper(DateIntervalManage::FRENCH_MONTH[$accountingStudentRegistrationFee->getStartAt()->format('m')]). ' '$accountingStudentRegistrationFee->getStartAt()->format('Y') ." A 07H00 ET PRENDRA FIN LE ".  strtoupper(DateIntervalManage::FRENCH_DAY[$accountingStudentRegistrationFee->getEndAt()->format('D')]). ' ' .$accountingStudentRegistrationFee->getEndAt()->format('d'). ' ' .strtoupper(DateIntervalManage::FRENCH_MONTH[$accountingStudentRegistrationFee->getEndAt()->format('m')]). ' '$accountingStudentRegistrationFee->getEndAt()->format('Y') ." A 18H00. Contact: ".$settingFee->getEstablishment()->getMobileNumber();
  791.                 try {
  792.                     $response $smsSender->sendSmsByEstablishment($establishment$message$contacts$smsSender::UNICODE_CHARSET);
  793.                     $responses explode(':'$response);
  794.                     $code trim($responses[1]);
  795.                     $communicationMessage = new CommunicationMessage();
  796.                     $communicationMessage->setCode($code);
  797.                     $communicationMessage->setContacts($contacts);
  798.                     $communicationMessage->setContent($message);
  799.                     $communicationMessage->setEstablishment($establishment);
  800.                     $communicationMessage->setType($smsSender::UNICODE_CHARSET);
  801.                     $entityManager->persist($communicationMessage);
  802.                 } catch (\Throwable $th) {
  803.                     //throw $th;
  804.                 }
  805.                 
  806.             }
  807.             
  808.             /** */
  809.             $accountingStudentRegistrationFee->setDuration($settingFee->getDuration());
  810.             $accountingStudentRegistrationFee->setEstablishment($establishment);
  811.             $accountingStudentRegistrationFee->setCode(time());
  812.             $accountingStudentRegistrationFee->setLabel($settingFee->getLabel());
  813.             $accountingStudentRegistrationFee->setAmount($settingFee->getAmount());
  814.             $accountingStudentRegistrationFee->setStudentRegistration($registrationStudentRegistration);
  815.             $accountingStudentRegistrationFee->setFee($settingFee);
  816.             if (count($settingFee->getSettingFeeSheduls()) > 0) {
  817.                 $order 0;
  818.                 foreach ($settingFee->getSettingFeeSheduls() as $key => $feeShedul) {
  819.                     $accountingStudentRegistrationFeeShedul = new AccountingStudentRegistrationFeeShedul();
  820.                     $accountingStudentRegistrationFeeShedul->setAmount($feeShedul->getAmount());
  821.                     $accountingStudentRegistrationFeeShedul->setDateDue($feeShedul->getDateDue());
  822.                     $accountingStudentRegistrationFeeShedul->setOrderNum($order 1);
  823.                     $accountingStudentRegistrationFeeShedul->setEstablishment($establishment);
  824.                     $accountingStudentRegistrationFeeShedul->setStudentRegistrationFee($accountingStudentRegistrationFee);
  825.                     $entityManager->persist($accountingStudentRegistrationFeeShedul);
  826.                     $order++;
  827.                 }
  828.             }else {
  829.                 $accountingStudentRegistrationFeeShedul = new AccountingStudentRegistrationFeeShedul();
  830.                 $accountingStudentRegistrationFeeShedul->setAmount($settingFee->getAmount());
  831.                 $accountingStudentRegistrationFeeShedul->setDateDue(new DateTimeImmutable());
  832.                 $accountingStudentRegistrationFeeShedul->setOrderNum(1);
  833.                 $accountingStudentRegistrationFeeShedul->setEstablishment($this->getUser()->getEstablishment());
  834.                 $accountingStudentRegistrationFeeShedul->setStudentRegistrationFee($accountingStudentRegistrationFee);
  835.                 
  836.                 $entityManager->persist($accountingStudentRegistrationFeeShedul);
  837.             }
  838.             foreach ($settingFee->getStockKitCategories() as $key => $stockKitCategory) {
  839.                 // sortie de kits
  840.                 $stockKitOut = new StockKitOut();
  841.                 $stockKitOut->setEstablishment($establishment);
  842.                 $stockKitOut->setSchoolYear($schoolYear);
  843.                 $stockKitOut->setRegistrationStudent($registrationStudentRegistration);
  844.                 $stockKitOut->setIsValidated(false);
  845.                 $stockKitOut->setKitCategory($stockKitCategory);
  846.                 $stockKitOut->setCreateDate(new DateTimeImmutable());
  847.                 // lignes de sortie de kits
  848.                 foreach ($stockKitCategory->getStockKitProducts() as $key => $stockKitProduct) {
  849.                     $stockKitOutLine = new StockKitOutLine();
  850.                     $stockKitOutLine->setEstablishment($establishment);
  851.                     $stockKitOutLine->setSchoolYear($schoolYear);
  852.                     $stockKitOutLine->setStockKitOut($stockKitOut);
  853.                     $stockKitOutLine->setStockKitProduct($stockKitProduct);
  854.                     $stockKitOutLine->setProduct($stockKitProduct->getProduct());
  855.                     $stockKitOutLine->setQuantity($stockKitProduct->getQuantity());
  856.                     $entityManager->persist($stockKitOutLine);
  857.                 }
  858.                 $entityManager->persist($stockKitOut);
  859.             }
  860.             
  861.             $entityManager->persist($accountingStudentRegistrationFee);
  862.             
  863.             try {
  864.                 $this->getDoctrine()->getManager()->flush();
  865.                 $accountingStudentRegistrationFee->setCode('ABN-'.sprintf("%'05s"$accountingStudentRegistrationFee->getId()));
  866.                 $this->getDoctrine()->getManager()->flush();
  867.                 $this->addFlash('success'"des frais ont été ajouté.");
  868.             } catch (\Throwable $th) {
  869.                 $this->addFlash('info'$th->getMessage());
  870.             }
  871.             return $this->redirectToRoute('registration_student_registration_show', ['id' => $registrationStudentRegistration->getId()]);
  872.         }
  873.         $transport_zones $transportZoneRepository->createQueryBuilder('entity')
  874.         ->innerJoin('entity.establishment''establishment')
  875.         ->addSelect('establishment')
  876.         ->innerJoin('establishment.establishmentGroup''establishmentGroup')
  877.         ->addSelect('establishmentGroup')
  878.         ->andWhere('establishmentGroup.id = :establishmentGroupId')
  879.         ->setParameter('establishmentGroupId'$establishment->getEstablishmentGroup()->getId())
  880.         ->orderBy('entity.id''DESC')
  881.         ->getQuery()
  882.         ->getResult();
  883.         $registrationTransportCheckpoint = new RegistrationTransportCheckpoint();
  884.         $registrationTransportCheckpointForm $this->createForm(RegistrationTransportCheckpointType::class, $registrationTransportCheckpoint)
  885.         ->add('transportZone'EntityType::class, [
  886.             'class' => TransportZone::class,
  887.             'choices' => $transport_zones
  888.         ]);
  889.         $registrationTransportCheckpointForm->handleRequest($request);
  890.         if ($registrationTransportCheckpointForm->isSubmitted() && $registrationTransportCheckpointForm->isValid()) {
  891.             $entityManager $this->getDoctrine()->getManager();
  892.             $registrationTransportCheckpoint->setRegistrationStudentRegistration($registrationStudentRegistration);
  893.             $registrationTransportCheckpoint->setEstablishment($registrationStudentRegistration->getEstablishment());
  894.             $entityManager->persist($registrationTransportCheckpoint);
  895.             
  896.             try{
  897.                 $entityManager->flush();
  898.             }catch(\Throwable $th){
  899.                 $this->addFlash('info'$th->getMessage());
  900.             }
  901.             return $this->redirectToRoute('registration_student_registration_show', ['id' => $registrationStudentRegistration->getId()]);
  902.         }
  903.         if ($request->get('__cd_token___') == 'soldeAnterieur') {
  904.             $entityManager $this->getDoctrine()->getManager();
  905.             $fee $settingFeeRepository->findOneBy(['establishment' => $registrationStudentRegistration->getEstablishment(),'schoolYear' => $schoolYear'label'  => 'SOLDE ANTERIEUR'], []);
  906.             if (null == $fee) {
  907.                 $fee = new SettingFee();
  908.                 $fee->setEstablishment($registrationStudentRegistration->getEstablishment());
  909.                 $fee->setCategory('AUTRE-FRAIS');
  910.                 $fee->setLabel('SOLDE ANTERIEUR');
  911.                 $fee->setAmount(0);
  912.                 $fee->setSchoolYear($schoolYear);
  913.                 $entityManager->persist($fee);
  914.             }
  915.             $anteriorAccountingStudentRegistrationFee = new AccountingStudentRegistrationFee();
  916.             $anteriorAccountingStudentRegistrationFee->setEstablishment($registrationStudentRegistration->getEstablishment());
  917.             $anteriorAccountingStudentRegistrationFee->setStudentRegistration($registrationStudentRegistration);
  918.             $anteriorAccountingStudentRegistrationFee->setFee($fee);
  919.             $anteriorAccountingStudentRegistrationFee->setAmount(intval($request->get('anterior_balance_amount')));
  920.             $anteriorAccountingStudentRegistrationFee->setCode($fee->getLabel().'-'.$registrationStudentRegistration->getId());
  921.             $anteriorAccountingStudentRegistrationFee->setLabel($fee->getLabel());
  922.             $anteriorAccountingStudentRegistrationFeeShedul = new AccountingStudentRegistrationFeeShedul();
  923.             $anteriorAccountingStudentRegistrationFeeShedul->setAmount($anteriorAccountingStudentRegistrationFee->getAmount());
  924.             $anteriorAccountingStudentRegistrationFeeShedul->setDateDue(new DateTimeImmutable());
  925.             $anteriorAccountingStudentRegistrationFeeShedul->setOrderNum(1);
  926.             $anteriorAccountingStudentRegistrationFeeShedul->setEstablishment($registrationStudentRegistration->getEstablishment());
  927.             $anteriorAccountingStudentRegistrationFeeShedul->setStudentRegistrationFee($anteriorAccountingStudentRegistrationFee);
  928.             
  929.             $entityManager->persist($anteriorAccountingStudentRegistrationFeeShedul);
  930.             $entityManager->persist($anteriorAccountingStudentRegistrationFee);
  931.             
  932.             try{
  933.                 $entityManager->flush();
  934.             }catch(\Throwable $th){
  935.                 $this->addFlash('info'$th->getMessage());
  936.             }
  937.             return $this->redirectToRoute('registration_student_registration_show', ['id' => $registrationStudentRegistration->getId()]);
  938.         }
  939.         return $this->renderForm('registration/registration_student_registration/show.html.twig', [
  940.             'registration_student_registration' => $registrationStudentRegistration,
  941.             'accounting_student_registration_fee' => $accountingStudentRegistrationFee,
  942.             'accounting_student_registration_fee_form' => $accountingStudentRegistrationFeeForm,
  943.             'registrationTransportCheckpoint' => $registrationTransportCheckpoint,
  944.             'registrationTransportCheckpointForm' => $registrationTransportCheckpointForm,
  945.         ]);
  946.     }
  947.     /**
  948.      * @Route("/{id}/edit", name="registration_student_registration_edit", methods={"GET","POST"})
  949.      */
  950.     public function edit(Request $requestRegistrationStudentRegistration $registrationStudentRegistrationSettingDocumentToProvideRepository $settingDocumentToProvideRepository): Response
  951.     {
  952.         $establishment $this->getUser()->getEstablishment();
  953.         $form $this->createForm(RegistrationStudentRegistrationType::class, $registrationStudentRegistration)
  954.         ->add('documentProvides'EntityType::class, [
  955.             'class' => SettingDocumentToProvide::class,
  956.             'choices' => $settingDocumentToProvideRepository->findBy(['establishment' => $establishment], []),
  957.             'multiple' => true,
  958.             'required' => false
  959.         ])
  960.         ->remove('student');
  961.         $form->handleRequest($request);
  962.         if ($form->isSubmitted() && $form->isValid()) {
  963.             
  964.             try {
  965.                 $this->getDoctrine()->getManager()->flush();
  966.                 $this->addFlash('success'"l'inscrit à été édité.");
  967.             } catch (\Throwable $th) {
  968.                 $this->addFlash('warning'"Une erreure est survenue lors de l'édition de l'inscrit.");
  969.                 $this->addFlash('info'$th->getMessage());
  970.             }
  971.             return $this->redirectToRoute('registration_student_registration_edit', ['id' => $registrationStudentRegistration->getId()], Response::HTTP_SEE_OTHER);
  972.         }
  973.         return $this->renderForm('registration/registration_student_registration/edit.html.twig', [
  974.             'registration_student_registration' => $registrationStudentRegistration,
  975.             'form' => $form,
  976.         ]);
  977.     }
  978.     /**
  979.      * @Route("/delete-selection", name="registration_student_registrations_selected_delete", methods={"GET"})
  980.     */
  981.     public function deleteSelected(Request $requestRegistrationStudentRegistrationRepository $entityRepository): Response
  982.     {
  983.         $list $request->get('entities');
  984.         $entityManager $this->getDoctrine()->getManager();
  985.         $errors 0;
  986.         foreach ($list as $key => $id) {
  987.             $entity $entityRepository->findOneBy(['id' => intval($id)], []);
  988.             if ($entity != null) {
  989.                 if (count($entity->getAccountingStudentRegistrationFees()) <= 0) {
  990.                     $entityManager->remove($entity);
  991.                 }
  992.                 foreach ($entity->getStockKitOuts() as $key => $stockKitOut) {
  993.                     if (!$stockKitOut->getIsValidated()) {
  994.                         foreach ($stockKitOut->getStockKitOutLines() as $key => $stockKitOutLine) {
  995.                             $entityManager->remove($stockKitOutLine);
  996.                         }
  997.                         $entityManager->remove($stockKitOut);
  998.                     }
  999.                 }
  1000.                 
  1001.                 foreach ($entity->getStockStudentKitEntries() as $key => $stockStudentKitEntry) {
  1002.                     foreach ($stockStudentKitEntry->getStockStudentKitEntryLines() as $key => $stockStudentKitEntryLine) {
  1003.                         $entityManager->remove($stockStudentKitEntryLine);
  1004.                     }
  1005.                     $entityManager->remove($stockStudentKitEntry);
  1006.                 }
  1007.             }
  1008.         }
  1009.         try {
  1010.             $entityManager->flush();
  1011.             $this->addFlash('success'"Traitement effectué");
  1012.             return $this->json(['code' => 200'message' => "Traitement effectué :)"], 200);
  1013.         } catch (\Throwable $th) {
  1014.             //$th->getMessage()
  1015.             $this->addFlash('warning'$th->getMessage());
  1016.         }
  1017.         
  1018.         $this->addFlash('warning'"Traitement non effectué");
  1019.         return $this->json(['code' => 500'message' => "Traitement non effectué"], 200);
  1020.     }
  1021.     /**
  1022.      * @Route("/api/get-info", name="api_registration_student_registration_info", methods={"GET"})
  1023.     */
  1024.     public function apiGetInfo(Request $requestRegistrationStudentRegistrationRepository $entityRepositorySettingClassroomRepository $settingClassroomRepository): Response
  1025.     {
  1026.         /**@var User $user */
  1027.         $user $this->getUser();
  1028.         $establishment $user->getEstablishment();
  1029.         $schoolYear $user->getSchoolYear();
  1030.         $id intval($request->get('id'));
  1031.         $student $entityRepository->findOneBy(['id' => $id], []);
  1032.         if (null == $student) {
  1033.             return $this->json(['code' => 500'message' => "not found :)"], 200);
  1034.         }
  1035.         $sclassrooms = new ArrayCollection();
  1036.         $_sclassrooms $settingClassroomRepository->findBy(['level' => $student->getClassroom()->getLevel(), 'schoolYear' => $schoolYear], ['label' => 'ASC']);
  1037.         
  1038.         $_sclassrooms =  $settingClassroomRepository->createQueryBuilder('entity')
  1039.         ->innerJoin('entity.level''level')
  1040.         ->addSelect('level')
  1041.         ->andWhere('entity.establishment = :establishment')
  1042.         ->setParameter('establishment'$establishment)
  1043.         ->andWhere('entity.schoolYear = :schoolYear')
  1044.         ->setParameter('schoolYear'$schoolYear)
  1045.         ->andWhere('level.parent = :parent')
  1046.         ->setParameter('parent'$student->getClassroom()->getLevel()->getParent())
  1047.         ->getQuery()
  1048.         ->getResult();
  1049.         $__sclassrooms =  $settingClassroomRepository->createQueryBuilder('entity')
  1050.         ->innerJoin('entity.level''level')
  1051.         ->addSelect('level')
  1052.         ->andWhere('entity.establishment = :establishment')
  1053.         ->setParameter('establishment'$establishment)
  1054.         ->andWhere('entity.schoolYear = :schoolYear')
  1055.         ->setParameter('schoolYear'$schoolYear)
  1056.         ->andWhere('entity.level = :level')
  1057.         ->setParameter('level'$student->getClassroom()->getLevel())
  1058.         ->getQuery()
  1059.         ->getResult();
  1060.         foreach ($_sclassrooms as $key => $_sclassroom) {
  1061.             if ($student->getClassroom() != $_sclassroom) {
  1062.                 $sclassrooms->add([
  1063.                     'id' => $_sclassroom->getId(),
  1064.                     'label' => $_sclassroom->getLabel()
  1065.                 ]);
  1066.             }
  1067.         };
  1068.         foreach ($__sclassrooms as $key => $_sclassroom) {
  1069.             if ($student->getClassroom() != $_sclassroom) {
  1070.                 if ($student->getClassroom()->getLevel()->getParent() == null) {
  1071.                     $sclassrooms->add([
  1072.                         'id' => $_sclassroom->getId(),
  1073.                         'label' => $_sclassroom->getLabel()
  1074.                     ]);
  1075.                 }
  1076.             }
  1077.         };
  1078.         if ($student != null) {
  1079.             return $this->json([
  1080.                 'code' => 200
  1081.                 'message' => "found :)"
  1082.                 'sname' => $student->getName(), 
  1083.                 'sregistrationNumber' => $student->getStudent()->getRegistrationNumber(), 
  1084.                 'scode' => $student->getStudent()->getCode(), 
  1085.                 'sclassroom' => $student->getClassroom()->getLabel(), 
  1086.                 'sclassrooms' => $sclassrooms
  1087.                 'slevel' => $student->getClassroom()->getLevel()->getId(), 
  1088.                 'sestablishment' => $student->getEstablishment()->getName(), 
  1089.                 'ssolde' => number_format(($student->getGleAmount() - $student->getAmountPaid()), 0','' '),
  1090.                 'is_affected' => $student->getStudent()->getIsAffected(), 
  1091.                 'is_redoubling' => $student->getStudent()->getIsRedoubling(), 
  1092.             ], 
  1093.             200);
  1094.         }else{
  1095.             return $this->json(['code' => 500'message' => "not found :)"], 200);
  1096.         }
  1097.     }
  1098.     /**
  1099.      * @Route("/print/{id}/card", name="registration_student_registration_print_card", methods={"GET"})
  1100.     */
  1101.     public function printCard(Pdf $knpSnappyPdfRegistrationStudentRegistration $registrationStudent)
  1102.     {
  1103.         /**@var User $user */
  1104.         $user $this->getUser();
  1105.         $schoolYear $user->getSchoolYear();
  1106.         $setting $registrationStudent->getEstablishment();
  1107.         $template 'registration/print/primaireCard.html.twig';
  1108.         if ($setting->getType() != $setting::ESTABLISHMENT_PRESCOLAIRE_PRIMAIRE_TYPES) {
  1109.             $template 'registration/print/secondaireCard.html.twig';
  1110.         }
  1111.         
  1112.         $html $this->renderView($template, [
  1113.             'student_registration' => $registrationStudent,
  1114.             'school_year' => $schoolYear,
  1115.             'setting' => $setting,
  1116.         ]);
  1117.         $file_name 'CARTE_DE_SORTIE_'.$registrationStudent->getStudent()->getCode().".pdf";
  1118.         return new PdfResponse(
  1119.             $knpSnappyPdf->getOutputFromHtml($html),
  1120.             $file_name,
  1121.             'application/pdf',
  1122.             'attachment'
  1123.         );
  1124.     }
  1125.     /**
  1126.      * @Route("/print/{id}/badge", name="registration_student_registration_print_badge", methods={"GET"})
  1127.     */
  1128.     public function printBadge(Pdf $knpSnappyPdfRegistrationStudentRegistration $registrationStudent)
  1129.     {
  1130.         /**@var User $user */
  1131.         $user $this->getUser();
  1132.         $schoolYear $user->getSchoolYear();
  1133.         $setting $registrationStudent->getEstablishment();
  1134.         $template 'registration/print/primaireBadge.html.twig';
  1135.         if ($setting->getType() != $setting::ESTABLISHMENT_PRESCOLAIRE_PRIMAIRE_TYPES) {
  1136.             $template 'registration/print/secondaireBadge.html.twig';
  1137.         }
  1138.         
  1139.         $html $this->renderView($template, [
  1140.             'student_registration' => $registrationStudent,
  1141.             'school_year' => $schoolYear,
  1142.             'setting' => $setting,
  1143.         ]);
  1144.         $file_name 'BADGE_'.$registrationStudent->getStudent()->getCode().".pdf";
  1145.         return new PdfResponse(
  1146.             $knpSnappyPdf->getOutputFromHtml($html, [
  1147.                 'margin-left' => '0',
  1148.                 'margin-top' => '0',
  1149.                 'margin-right' => '0',
  1150.                 'margin-bottom' => '0',
  1151.                 'page-height' =>  35,
  1152.                 'page-width' => 53
  1153.             ]),
  1154.             $file_name,
  1155.             'application/pdf',
  1156.             'attachment'
  1157.         );
  1158.     }
  1159.     /**
  1160.      * @Route("/print/{id}/badgeVerso", name="registration_student_registration_print_badge_verso", methods={"GET"})
  1161.     */
  1162.     public function printBadgeVerso(Pdf $knpSnappyPdfRegistrationStudentRegistration $registrationStudent)
  1163.     {
  1164.         /**@var User $user */
  1165.         $user $this->getUser();
  1166.         $schoolYear $user->getSchoolYear();
  1167.         $setting $registrationStudent->getEstablishment();
  1168.         $template 'registration/print/primaireBadgeVerso.html.twig';
  1169.         if ($setting->getType() != $setting::ESTABLISHMENT_PRESCOLAIRE_PRIMAIRE_TYPES) {
  1170.             $template 'registration/print/secondaireBadgeVerso.html.twig';
  1171.         }
  1172.         
  1173.         $html $this->renderView($template, [
  1174.             'student_registration' => $registrationStudent,
  1175.             'school_year' => $schoolYear,
  1176.             'setting' => $setting,
  1177.         ]);
  1178.         $file_name 'BADGE_VERSO'.$registrationStudent->getStudent()->getCode().".pdf";
  1179.         return new PdfResponse(
  1180.             $knpSnappyPdf->getOutputFromHtml($html, [
  1181.                 'margin-left' => '0',
  1182.                 'margin-top' => '0',
  1183.                 'margin-right' => '0',
  1184.                 'margin-bottom' => '0',
  1185.                 'page-height' =>  35,
  1186.                 'page-width' => 53
  1187.             ]),
  1188.             $file_name,
  1189.             'application/pdf',
  1190.             'attachment'
  1191.         );
  1192.     }
  1193.     /**
  1194.      * @Route("/print/{id}/attestationOfAttendance", name="registration_student_registration_print_attestation_of_attendance", methods={"GET"})
  1195.     */
  1196.     public function printAttestationOfAttendance(Pdf $knpSnappyPdfRegistrationStudentRegistration $registrationStudent)
  1197.     {
  1198.         /**@var User $user */
  1199.         $user $this->getUser();
  1200.         $schoolYear $user->getSchoolYear();
  1201.         $setting $registrationStudent->getEstablishment();
  1202.         $template 'registration/print/attestation_of_attendance.html.twig';
  1203.         $html $this->renderView($template, [
  1204.             'student_registration' => $registrationStudent,
  1205.             'school_year' => $schoolYear,
  1206.             'setting' => $setting,
  1207.         ]);
  1208.         $file_name 'ATTESTATION_DE_FREQUENTATION_'.$registrationStudent->getStudent()->getCode().".pdf";
  1209.         $footer $this->renderView('print/footer.html.twig', ['setting' => $setting,]);
  1210.         $header $this->renderView('print/header.html.twig', ['setting' => $setting,]);
  1211.         $options = [
  1212.             'orientation' => 'Portrait'
  1213.             //'header-html' => $header
  1214.             //'footer-html' => $footer
  1215.         ];
  1216.         try {
  1217.             $knpSnappyPdf->generateFromHtml($html$this->getParameter('app.app_directory').'/downloads/students/' $file_name$optionstrue);
  1218.         } catch (\Throwable $th) {
  1219.             $this->addFlash('info'"Ce reçu à déjà été imprimé.");
  1220.         }
  1221.         
  1222.         return $this->redirectToRoute('preview', [
  1223.             'file' => $file_name,
  1224.             'dir' => 'students',
  1225.         ]);
  1226.     }
  1227.     /**
  1228.      * @Route("/print/{id}/transpotantionSheet", name="registration_student_registration_print_transpotantion_sheet", methods={"GET"})
  1229.     */
  1230.     public function printTranspotantionSheet(Pdf $knpSnappyPdfRegistrationStudentRegistration $registrationStudent)
  1231.     {
  1232.         /**@var User $user */
  1233.         $user $this->getUser();
  1234.         $schoolYear $user->getSchoolYear();
  1235.         $setting $registrationStudent->getEstablishment();
  1236.         $template 'registration/print/transpotantion_sheet.html.twig';
  1237.         $html $this->renderView($template, [
  1238.             'student_registration' => $registrationStudent,
  1239.             'school_year' => $schoolYear,
  1240.             'setting' => $setting,
  1241.         ]);
  1242.         $file_name 'FICHE_DE_TRANSPORT_'.$registrationStudent->getStudent()->getCode().".pdf";
  1243.         $footer $this->renderView('print/footer.html.twig', ['setting' => $setting,]);
  1244.         $header $this->renderView('print/header.html.twig', ['setting' => $setting,]);
  1245.         $options = [
  1246.             'orientation' => 'Portrait',
  1247.             'header-html' => $header
  1248.             //'footer-html' => $footer
  1249.         ];
  1250.         try {
  1251.             $knpSnappyPdf->generateFromHtml($html$this->getParameter('app.app_directory').'/downloads/students/' $file_name$optionstrue);
  1252.         } catch (\Throwable $th) {
  1253.             $this->addFlash('info'$th->getMessage());
  1254.         }
  1255.         
  1256.         return $this->redirectToRoute('preview', [
  1257.             'file' => $file_name,
  1258.             'dir' => 'students',
  1259.         ]);
  1260.     }
  1261.     /**
  1262.      * @Route("/print/{id}/acknowledgmentReceip", name="registration_student_registration_print_acknowledgment_receip", methods={"GET"})
  1263.     */
  1264.     public function acknowledgment_receip(Pdf $knpSnappyPdfRegistrationStudentRegistration $registrationStudent)
  1265.     {
  1266.         /**@var User $user */
  1267.         $user $this->getUser();
  1268.         $schoolYear $user->getSchoolYear();
  1269.         $setting $registrationStudent->getEstablishment();
  1270.         $template 'registration/print/acknowledgment_receip.html.twig';
  1271.         
  1272.         $html $this->renderView($template, [
  1273.             'student_registration' => $registrationStudent,
  1274.             'school_year' => $schoolYear,
  1275.             'setting' => $setting,
  1276.         ]);
  1277.         $file_name 'ACCUSE_DE_RECEPTION_'.$registrationStudent->getId().".pdf";
  1278.         $footer $this->renderView('print/footer.html.twig', ['setting' => $setting,]);
  1279.         $header $this->renderView('print/header.html.twig', ['setting' => $setting,]);
  1280.         $options = [
  1281.             'orientation' => 'Portrait',
  1282.             'header-html' => $header
  1283.             //'footer-html' => $footer
  1284.         ];
  1285.         try {
  1286.             $knpSnappyPdf->generateFromHtml($html$this->getParameter('app.app_directory').'/downloads/students/' $file_name$optionstrue);
  1287.         } catch (\Throwable $th) {
  1288.             $this->addFlash('info'$th->getMessage());
  1289.         }
  1290.         
  1291.         return $this->redirectToRoute('preview', [
  1292.             'file' => $file_name,
  1293.             'dir' => 'students',
  1294.         ]);
  1295.     }
  1296.     /**
  1297.      * @Route("/api/get-kit-model", name="api_registration_student_registration_get_kit_models", methods={"GET"})
  1298.     */
  1299.     public function apiGetKitModel(Request $requestRegistrationStudentRegistrationRepository $entityRepository): Response
  1300.     {
  1301.         $id intval($request->get('id'));
  1302.         $student $entityRepository->find($id);
  1303.         $kitCategories = new ArrayCollection();
  1304.         $level $student->getClassroom()->getLevel();
  1305.         foreach ($level->getSettingFees() as $key => $settingFee) {
  1306.             foreach ($settingFee->getStockKitCategories() as $key => $stockKitCategorie) {
  1307.                 $kitCategories->add([
  1308.                     'id' => $stockKitCategorie->getId(),
  1309.                     'name' => $stockKitCategorie->getName()
  1310.                 ]);
  1311.             };
  1312.         };
  1313.         if ($student != null) {
  1314.             return $this->json([
  1315.                 'code' => 200
  1316.                 'message' => "found :)"
  1317.                 'sname' => $student->getName(), 
  1318.                 'sregistrationNumber' => $student->getStudent()->getRegistrationNumber(), 
  1319.                 'scode' => $student->getStudent()->getCode(), 
  1320.                 'sclassroom' => $student->getClassroom()->getLabel(), 
  1321.                 'slevel' => $student->getClassroom()->getLevel()->getId(), 
  1322.                 'sestablishment' => $student->getEstablishment()->getName(), 
  1323.                 'ssolde' => number_format(($student->getGleAmount() - $student->getAmountPaid()), 0','' '),
  1324.                 'kit_categories' => $kitCategories
  1325.             ], 
  1326.             200);
  1327.         }else{
  1328.             return $this->json(['code' => 500'message' => "not found :)"], 200);
  1329.         }
  1330.     }
  1331.     /**
  1332.      * @Route("/{id}/print", name="registration_student_registration_print", methods={"GET"})
  1333.     */
  1334.     public function print(Pdf $knpSnappyPdfRegistrationStudentRegistration $registrationStudentRegistration)
  1335.     {
  1336.         /**@var User $user */
  1337.         $user $this->getUser();
  1338.         $schoolYear $user->getSchoolYear();
  1339.         $setting $registrationStudentRegistration->getEstablishment();
  1340.         $template 'registration/print/rePrimaire.html.twig';
  1341.         if ($setting->getType() != $setting::ESTABLISHMENT_PRESCOLAIRE_PRIMAIRE_TYPES) {
  1342.             $template 'registration/print/reSecondaire.html.twig';
  1343.         }
  1344.         
  1345.         $html $this->renderView($template, [
  1346.             'registration_student_registration' => $registrationStudentRegistration,
  1347.             'school_year' => $schoolYear,
  1348.             'setting' => $setting,
  1349.         ]);
  1350.         $file_name 'INSCRIPTION_N_'.$schoolYear->getCode().'--'.$registrationStudentRegistration->getStudent()->getCode().".pdf";
  1351.         return new PdfResponse(
  1352.             $knpSnappyPdf->getOutputFromHtml($html),
  1353.             $file_name,
  1354.             'application/pdf',
  1355.             'attachment'
  1356.         );
  1357.     }
  1358.     /**
  1359.      * @Route("/print/{id}/access-card", name="registration_student_registration_print_access_card", methods={"GET"})
  1360.     */
  1361.     public function printAccessCard(Pdf $knpSnappyPdfRegistrationStudentRegistration $registrationStudent)
  1362.     {
  1363.         /**@var User $user */
  1364.         $user $this->getUser();
  1365.         $schoolYear $user->getSchoolYear();
  1366.         $setting $registrationStudent->getEstablishment();
  1367.         $template 'registration/print/accessCard2.html.twig';
  1368.         if ($setting->getType() != $setting::ESTABLISHMENT_PRESCOLAIRE_PRIMAIRE_TYPES) {
  1369.             $template 'registration/print/accessCard2.html.twig';
  1370.         }
  1371.         
  1372.         $html $this->renderView($template, [
  1373.             'student_registration' => $registrationStudent,
  1374.             'school_year' => $schoolYear,
  1375.             'setting' => $setting,
  1376.         ]);
  1377.         $options = [
  1378.             'margin-left' => '0',
  1379.             'margin-top' => '0',
  1380.             'margin-right' => '0',
  1381.             'margin-bottom' => '0',
  1382.             'page-height' =>  37,
  1383.             'page-width' => 55
  1384.         ];
  1385.         $file_name 'CARTE_DACCES_'.$registrationStudent->getStudent()->getCode().".pdf";
  1386.         try {
  1387.             $knpSnappyPdf->generateFromHtml($html$this->getParameter('app.app_directory').'/downloads/students/' $file_name$optionstrue);
  1388.         } catch (\Throwable $th) {
  1389.             $this->addFlash('info'$th->getMessage());
  1390.         }
  1391.         return $this->redirectToRoute('preview', [
  1392.             'file' => $file_name,
  1393.             'dir' => 'students',
  1394.         ]);
  1395.     }
  1396.     /**
  1397.      * @Route("/export", name="registration_student_registration_export")
  1398.     */
  1399.     public function export(RegistrationStudentRegistrationRepository $registrationStudentRegistrationRepository): Response
  1400.     {
  1401.         /**@var User $user */
  1402.         $user $this->getUser();
  1403.         $schoolYear $user->getSchoolYear();
  1404.         $students = new ArrayCollection();
  1405.         $establishment $this->getUser()->getEstablishment();
  1406.         $registration_student_registrations $registrationStudentRegistrationRepository->createQueryBuilder('entity')
  1407.             ->innerJoin('entity.student''student')
  1408.             ->addSelect('student')
  1409.             ->andWhere('entity.is_abandonned = :is_abandonned')
  1410.             ->setParameter('is_abandonned'0)
  1411.             ->andWhere('entity.establishment = :establishment')
  1412.             ->setParameter('establishment'$establishment)
  1413.             ->andWhere('entity.schoolYear = :schoolYear')
  1414.             ->setParameter('schoolYear'$schoolYear)
  1415.             ->orderBy('student.last_name''asc')
  1416.             ->getQuery()
  1417.             ->getResult();
  1418.         
  1419.         foreach ($registration_student_registrations as $key => $registration_student_registration) {
  1420.             $students->add(
  1421.                 [
  1422.                     'registrationNumber' => $registration_student_registration->getStudent()->getRegistrationNumber(),
  1423.                     'code' => $registration_student_registration->getStudent()->getCode(),
  1424.                     'name' => $registration_student_registration->getStudent()->getName(),
  1425.                     'lastName' => $registration_student_registration->getStudent()->getLastName(),
  1426.                     'firstName' => $registration_student_registration->getStudent()->getFirstName(),
  1427.                     'birthDay' => $registration_student_registration->getStudent()->getBirthDay()->format('d/m/Y'),
  1428.                     'birthLocation' => $registration_student_registration->getStudent()->getBirthLocation(),
  1429.                     'statut' => $registration_student_registration->getStudent()->getIsAffected() ? "Affecté(e)" "Non Affecté(e)",
  1430.                     'notificationPhoneNumber' => $registration_student_registration->getStudent()->getNotificationPhoneNumber(),
  1431.                     'doubling' => $registration_student_registration->getIsRedoubling() ? "Doublant(e)" "Non Doublant(e)",
  1432.                     'nationality' => $registration_student_registration->getStudent()->getNationality(),
  1433.                     'classroom' => $registration_student_registration->getClassroom()->getLabel(),
  1434.                     'level' => $registration_student_registration->getClassroom()->getLevel()->getLabel(),
  1435.                     'gender' => $registration_student_registration->getStudent()->getGender(),
  1436.                     'round' => $registration_student_registration->getClassroom()->getRound() ?  $registration_student_registration->getClassroom()->getRound()->getLabel() : '',
  1437.                     'lv1' => $registration_student_registration->getStudent()->getLv1(),
  1438.                     'lv2' => $registration_student_registration->getStudent()->getLv2(),
  1439.                     'createDate' => $registration_student_registration->getRegisteredAt() ? $registration_student_registration->getRegisteredAt()->format('d/m/Y') : '',
  1440.                 ]
  1441.             );
  1442.             
  1443.         }
  1444.         
  1445.         $iterator $students->getIterator();
  1446.         $iterator->uasort(function ($first$second) {
  1447.             if ($first === $second) {
  1448.                 return 0;
  1449.             }
  1450.             return $first['name'] < $second['name'] ? -1;
  1451.         });
  1452.         $students = new ArrayCollection(iterator_to_array($iterator));
  1453.         $spreadsheet = new Spreadsheet();
  1454.         $sheet $spreadsheet->getActiveSheet();
  1455.         $index 1;
  1456.         $sheet->setCellValue('A' $index'MATRICULE NATIONAL');
  1457.         $sheet->setCellValue('B' $index'NOM');
  1458.         $sheet->setCellValue('C' $index'PRENOMS');
  1459.         $sheet->setCellValue('D' $index'DATE DE NAISSANCE');
  1460.         $sheet->setCellValue('E' $index'LIEU DE NAISSANCE');
  1461.         $sheet->setCellValue('F' $index'STATUT');
  1462.         $sheet->setCellValue('G' $index'CONTACT PARENT');
  1463.         $sheet->setCellValue('H' $index'DOUBLANT');
  1464.         $sheet->setCellValue('I' $index'NATIONALITE');
  1465.         $sheet->setCellValue('J' $index'CLASSE');
  1466.         $sheet->setCellValue('K' $index'NIVEAU');
  1467.         $sheet->setCellValue('L' $index'SEX');
  1468.         $sheet->setCellValue('M' $index'SERIE');
  1469.         $sheet->setCellValue('N' $index'LV1');
  1470.         $sheet->setCellValue('O' $index'LV2');
  1471.         $sheet->setCellValue('P' $index'MATRICULE INTERNE');
  1472.         $sheet->setCellValue('Q' $index'Date Inscription');
  1473.         $index++;
  1474.         $loopIndex 1;
  1475.         foreach ($students as $key => $student) {
  1476.             $sheet->setCellValue('A' $index$student['registrationNumber']);
  1477.             $sheet->setCellValue('B' $index$student['lastName']);
  1478.             $sheet->setCellValue('C' $index$student['firstName']);
  1479.             $sheet->setCellValue('D' $index$student['birthDay']);
  1480.             $sheet->setCellValue('E' $index$student['birthLocation']);
  1481.             $sheet->setCellValue('F' $index$student['statut']);
  1482.             $sheet->setCellValue('G' $index$student['notificationPhoneNumber']);
  1483.             $sheet->setCellValue('H' $index$student['doubling']);
  1484.             $sheet->setCellValue('I' $index$student['nationality']);
  1485.             $sheet->setCellValue('J' $index$student['classroom']);
  1486.             $sheet->setCellValue('K' $index$student['level']);
  1487.             $sheet->setCellValue('L' $index$student['gender']);
  1488.             $sheet->setCellValue('M' $index$student['round']);
  1489.             $sheet->setCellValue('N' $index$student['lv1']);
  1490.             $sheet->setCellValue('O' $index$student['lv2']);
  1491.             $sheet->setCellValue('P' $index$student['code']);
  1492.             $sheet->setCellValue('Q' $index$student['createDate']);
  1493.             $index++;
  1494.             $loopIndex++;
  1495.         }
  1496.         $sheet->setTitle('INSCRITS_' $establishment->getCode().'_'.$schoolYear->getCode());
  1497.         $writer = new Xlsx($spreadsheet);
  1498.         // Create a Temporary file in the system
  1499.         $fileName 'LISTE_INSCRITS_' $establishment->getName().'_'.date('Y').'.xlsx';
  1500.         $temp_file tempnam(sys_get_temp_dir(), $fileName);
  1501.         $writer->save($temp_file);
  1502.         // Return the excel file as an attachment
  1503.         return $this->file($temp_file$fileNameResponseHeaderBag::DISPOSITION_INLINE);
  1504.     }
  1505.     /**
  1506.      * @Route("/print/{id}/extract-school-record-book", name="registration_student_registration_print_extract_school_record_book", methods={"GET"})
  1507.     */
  1508.     public function extract_school_record_book(Pdf $knpSnappyPdfRegistrationStudentRegistration $registrationStudentSchoolReportCardRepository $schoolReportCardRepositoryEquivalentMatterRepository $equivalentMatterRepository)
  1509.     {
  1510.         /**@var User $user */
  1511.         $user $this->getUser();
  1512.         $schoolYear $user->getSchoolYear();
  1513.         $setting $registrationStudent->getEstablishment();
  1514.         $school_report_cards $schoolReportCardRepository->createQueryBuilder('entity')
  1515.         ->innerJoin('entity.schoolYearPeriode''schoolYearPeriode')
  1516.         ->addSelect('schoolYearPeriode')
  1517.         ->andWhere('entity.studentRegistration = :studentRegistration')
  1518.         ->setParameter('studentRegistration'$registrationStudent)
  1519.         ->orderBy('schoolYearPeriode.code''ASC')
  1520.         ->getQuery()
  1521.         ->getResult();
  1522.         $equivalent_matters $equivalentMatterRepository->createQueryBuilder('entity')
  1523.         ->orderBy('entity.num_order''ASC')
  1524.         ->getQuery()
  1525.         ->getResult();
  1526.         $template 'registration/print/extract_school_record_book.html.twig';
  1527.         
  1528.         $html $this->renderView($template, [
  1529.             'equivalent_matters' => $equivalent_matters,
  1530.             'school_report_cards' => $school_report_cards,
  1531.             'student_registration' => $registrationStudent,
  1532.             'school_year' => $schoolYear,
  1533.             'setting' => $setting,
  1534.         ]);
  1535.         $file_name 'EXTRAIT_DE_LIVRET_SCOLAIRE_'.$registrationStudent->getId().".pdf";
  1536.         $footer $this->renderView('print/footer.html.twig', ['setting' => $setting]);
  1537.         $header $this->renderView('print/header.html.twig', ['setting' => $setting]);
  1538.         $options = [
  1539.             'orientation' => 'Landscape',
  1540.             'header-html' => $header
  1541.             //'footer-html' => $footer
  1542.         ];
  1543.         try {
  1544.             $knpSnappyPdf->generateFromHtml($html$this->getParameter('app.app_directory').'/downloads/students/' $file_name$optionstrue);
  1545.         } catch (\Throwable $th) {
  1546.             $this->addFlash('info'$th->getMessage());
  1547.         }
  1548.         
  1549.         return $this->redirectToRoute('preview', [
  1550.             'file' => $file_name,
  1551.             'dir' => 'students',
  1552.         ]);
  1553.     }
  1554.     /**
  1555.      * @Route("/_statistics-table", name="registration_student_registration_statistics_table", methods={"GET","POST"})
  1556.      */
  1557.     public function _statistics_table(RegistrationStudentRegistrationRepository $registrationStudentRegistrationRepository): Response
  1558.     {
  1559.         /**@var User $user */
  1560.         $user $this->getUser();
  1561.         $establishment $user->getEstablishment();
  1562.         $schoolYear $user->getSchoolYear();
  1563.         $registration_student_registrations $registrationStudentRegistrationRepository->createQueryBuilder('entity')
  1564.         ->innerJoin('entity.student''student')
  1565.         ->addSelect('student')
  1566.         ->andWhere('entity.establishment = :establishment')
  1567.         ->setParameter('establishment'$establishment)
  1568.         
  1569.         ->andWhere('entity.schoolYear = :schoolYear')
  1570.         ->setParameter('schoolYear'$schoolYear)
  1571.         ->getQuery()
  1572.         ->getResult();
  1573.         $registration_student_registration_women $registrationStudentRegistrationRepository->createQueryBuilder('entity')
  1574.         ->innerJoin('entity.student''student')
  1575.         ->addSelect('student')
  1576.         ->andWhere('entity.establishment = :establishment')
  1577.         ->setParameter('establishment'$establishment)
  1578.         
  1579.         ->andWhere('entity.schoolYear = :schoolYear')
  1580.         ->setParameter('schoolYear'$schoolYear)
  1581.         ->andWhere('student.gender = :gender')
  1582.         ->setParameter('gender''FEMININ')
  1583.         ->getQuery()
  1584.         ->getResult();
  1585.         $registration_student_registration_men $registrationStudentRegistrationRepository->createQueryBuilder('entity')
  1586.         ->innerJoin('entity.student''student')
  1587.         ->addSelect('student')
  1588.         ->andWhere('entity.establishment = :establishment')
  1589.         ->setParameter('establishment'$establishment)
  1590.         
  1591.         ->andWhere('entity.schoolYear = :schoolYear')
  1592.         ->setParameter('schoolYear'$schoolYear)
  1593.         ->andWhere('student.gender = :gender')
  1594.         ->setParameter('gender''MASCULIN')
  1595.         ->getQuery()
  1596.         ->getResult();
  1597.         $registration_student_registration_affecteds $registrationStudentRegistrationRepository->createQueryBuilder('entity')
  1598.         ->innerJoin('entity.student''student')
  1599.         ->addSelect('student')
  1600.         ->andWhere('entity.establishment = :establishment')
  1601.         ->setParameter('establishment'$establishment)
  1602.         
  1603.         ->andWhere('entity.schoolYear = :schoolYear')
  1604.         ->setParameter('schoolYear'$schoolYear)
  1605.         ->andWhere('student.is_affected = :is_affected')
  1606.         ->setParameter('is_affected'1)
  1607.         ->getQuery()
  1608.         ->getResult();
  1609.         return $this->renderForm('registration/registration_student_registration/_statistics_table.html.twig', [
  1610.             'registration_student_registrations' => count($registration_student_registrations),
  1611.             'registration_student_registration_women' => count($registration_student_registration_women),
  1612.             'registration_student_registration_men' => count($registration_student_registration_men),
  1613.             'registration_student_registration_affecteds' => count($registration_student_registration_affecteds),
  1614.         ]);
  1615.     }
  1616. }