src/Controller/Front/DashboardController.php line 361

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Front;
  3. use App\Entity\Contract;
  4. use App\Entity\Course;
  5. use App\Entity\Director;
  6. use App\Entity\FeaturedModule;
  7. use App\Entity\Job;
  8. use App\Entity\Live;
  9. use App\Entity\Module;
  10. use App\Entity\ModuleItem;
  11. use App\Entity\NotificationReceiver;
  12. use App\Entity\Office;
  13. use App\Entity\Program;
  14. use App\Entity\Quiz;
  15. use App\Entity\Quote;
  16. use App\Entity\SubsidiaryCompany;
  17. use App\Entity\User;
  18. use App\Entity\Partenaire;
  19. use App\Form\ChangePasswordType;
  20. use App\Form\CourseType;
  21. use App\Form\DirectorType;
  22. use App\Form\FeaturedModuleType;
  23. use App\Form\JobType;
  24. use App\Form\LiveType;
  25. use App\Form\ModuleType;
  26. use App\Form\ProgramType;
  27. use App\Form\QuizType;
  28. use App\Form\QuoteType;
  29. use App\Form\PartenaireType;
  30. use App\Form\RegistrationFormType;
  31. use App\Helper\ControllerHelper;
  32. use App\Message\Notification;
  33. use App\Entity\Notification as NotificationEntity;
  34. use App\Event\PreExecutionEvent;
  35. use App\Repository\CourseRepository;
  36. use App\Repository\DirectorRepository;
  37. use App\Repository\FeaturedModuleRepository;
  38. use App\Repository\JobRepository;
  39. use App\Repository\LiveRepository;
  40. use App\Repository\ModuleItemRepository;
  41. use App\Repository\ModuleNoticeRepository;
  42. use App\Repository\ModuleParticipationRepository;
  43. use App\Repository\ModuleRepository;
  44. use App\Repository\ModuleViewRepository;
  45. use App\Repository\OfficeRepository;
  46. use App\Repository\ProgramParticipationRepository;
  47. use App\Repository\ProgramRepository;
  48. use App\Repository\QuizRepository;
  49. use App\Repository\QuoteRepository;
  50. use App\Repository\SubsidiaryCompanyRepository;
  51. use App\Repository\UserRepository;
  52. use App\Repository\ModuleObjectiveRepository;
  53. use App\Repository\NotificationReceiverRepository;
  54. use App\Repository\NotificationRepository;
  55. use App\Repository\PartenaireRepository;
  56. use App\Repository\SubjectRepository;
  57. use App\Repository\CommentRepository;
  58. use App\Schedule\AppScheduleBuilder;
  59. use App\Service\HelperService;
  60. use App\Service\PushNotification;
  61. use App\Utils\Constants;
  62. use DateInterval;
  63. use DateTime;
  64. use Doctrine\Persistence\ManagerRegistry;
  65. use Exception;
  66. use Kreait\Firebase\Contract\Messaging;
  67. use LogicException;
  68. use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel\Date;
  69. use Symfony\Bridge\Twig\Mime\TemplatedEmail;
  70. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  71. use Symfony\Component\HttpFoundation\JsonResponse;
  72. use Symfony\Component\HttpFoundation\Request;
  73. use Symfony\Component\HttpFoundation\Response;
  74. use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
  75. use Symfony\Component\Mailer\MailerInterface;
  76. use Symfony\Component\Mime\Address;
  77. use Symfony\Component\Mime\Email;
  78. use Symfony\Component\Routing\Annotation\Route;
  79. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  80. use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
  81. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
  82. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  83. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  84. use Symfony\Component\Form\Extension\Core\Type\TextType;
  85. use Symfony\Component\Mercure\HubInterface;
  86. use Symfony\Component\Mercure\Update;
  87. use Symfony\Component\Messenger\MessageBusInterface;
  88. use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
  89. use Symfony\Component\String\Slugger\SluggerInterface;
  90. use Symfony\Component\Workflow\WorkflowInterface;
  91. use JMS\Serializer\SerializationContext;
  92. use JMS\Serializer\SerializerInterface;
  93. use Knp\Component\Pager\Paginator;
  94. use Knp\Component\Pager\PaginatorInterface;
  95. use Symfony\Component\EventDispatcher\EventDispatcher;
  96. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  97. use Zenstruck\ScheduleBundle\Schedule;
  98. /**
  99.  * Require ROLE_EMPLOYEE for all the actions of this controller
  100.  *
  101.  * @IsGranted("ROLE_EMPLOYEE")
  102.  * 
  103.  * @Route("/dashboard")
  104.  */
  105. class DashboardController extends AbstractController
  106. {
  107.     use ControllerHelper;
  108.     private $helperService;
  109.     private $courseWorkflow;
  110.     private $liveWorkflow;
  111.     private $quizWorkflow;
  112.     private $doctrine;
  113.     private $mailer;
  114.     private $messaging;
  115.     private $pushNotification;
  116.     private $slugger;
  117.     private $hub;
  118.     private $bus;
  119.     private $paginator;
  120.     public function __construct(
  121.         HelperService $helperService
  122.         WorkflowInterface $coursePublishingStateMachine
  123.         WorkflowInterface $livePublishingStateMachine
  124.         WorkflowInterface $quizPublishingStateMachine
  125.         MailerInterface $mailer
  126.         ManagerRegistry $doctrine
  127.         Messaging $messaging
  128.         PushNotification $pushNotification
  129.         SluggerInterface $slugger
  130.         HubInterface $hub
  131.         MessageBusInterface $bus,
  132.         PaginatorInterface $paginator)
  133.     {
  134.         $this->helperService $helperService;
  135.         $this->courseWorkflow $coursePublishingStateMachine;
  136.         $this->liveWorkflow $livePublishingStateMachine;
  137.         $this->quizWorkflow $quizPublishingStateMachine;
  138.         $this->doctrine $doctrine;
  139.         $this->mailer $mailer;
  140.         $this->messaging $messaging;
  141.         $this->pushNotification $pushNotification;
  142.         $this->slugger $slugger;
  143.         $this->hub $hub;
  144.         $this->bus $bus;
  145.         $this->paginator $paginator;
  146.     }
  147.     
  148.     /**
  149.      * @Route("/{profil}/password", name="app_front_dashboard_update_password_page")
  150.      */
  151.     public function updatePassword(Request $requestUserRepository $userRepositoryUserPasswordHasherInterface $userPasswordHasherString $profil): Response
  152.     {
  153.         /** @var User */
  154.         $user $this->getUser();
  155.         $form $this->createForm(ChangePasswordType::class, $user);
  156.         $form->handleRequest($request);
  157.         if ($form->isSubmitted() && $form->isValid()) {
  158.             $oldPassword $form->get('oldPassword')->getData();
  159.             if (!$userPasswordHasher->isPasswordValid($user$oldPassword)) {
  160.                 $this->addFlash('user_password_update_error''Mot de passe incorrect');
  161.                 
  162.                 return $this->redirectToRoute('app_front_dashboard_update_password_page', ['profil' => $profil]);
  163.             }
  164.             $user->setPassword(
  165.                 $userPasswordHasher->hashPassword(
  166.                     $user,
  167.                     $form->get('newPassword')->getData()
  168.                 )
  169.             );
  170.             $userRepository->add($usertrue);
  171.             $mail = (new TemplatedEmail())
  172.                 ->from(new Address($this->getParameter('cofina_sender_mail'), 'Cofina Academy'))
  173.                 ->to($user->getEmail())
  174.                 ->subject('Changement de mot de passe au Programme')
  175.                 ->htmlTemplate('security/change-password-email.html.twig')
  176.                 ->context([]);
  177.     
  178.             try {
  179.                 $this->mailer->send($mail);
  180.             } catch (TransportExceptionInterface $e) {
  181.                 // dump($e->getMessage()); die;
  182.             }
  183.             $this->addFlash('user_password_updated''Mot de passe mis à jour');
  184.             return $this->redirectToRoute('app_front_dashboard_update_password_page', ['profil' => $profil]);
  185.         }
  186.         return $this->render('front/pages/dashboard/password.html.twig', [
  187.              'form' => $form->createView(),
  188.         ]);
  189.     }
  190.     /**
  191.      * @Route("/apprenant/profil/{id}", name="app_learner_dashboard_page")
  192.      * @Route("/apprenant", name="app_front_learner_dashboard_page")
  193.      */
  194.     public function learner(Request $requestProgramRepository $programRepositoryModuleRepository $moduleRepositoryNotificationRepository $notificationRepositoryUser $learner null): Response
  195.     {   
  196.         // $programs = $programRepository->findAll();
  197.         // foreach ($programs as $program) {
  198.         //     $slug = $this->slugger->slug($program->getLabel());
  199.         //     $program->setSlug($slug);
  200.         //     $programRepository->add($program, true);
  201.         // }
  202.         // die("ok");
  203.         $followedModulesPage = (int)$request->query->get('followedModulesPage'1);
  204.         $allModulesPage = (int)$request->query->get('allModulesPage'1);
  205.         $terminatedModulesPage = (int)$request->query->get('terminatedModulesPage'1);
  206.         $notificationPage = (int)$request->query->get('notificationPage'1);
  207.         $session $request->getSession();
  208.         /** @var User */
  209.         $user $this->getUser();
  210.         $refererProfile null;
  211.         if ($learner !== null) {
  212.             $user $learner;
  213.             $refererProfile $session->has('__profile') ? $session->get('__profile') : null;
  214.         }
  215.         $followedProgramCount $programRepository->getFollowedProgramCount($user);
  216.         $terminatedProgramCount $programRepository->getTerminatedProgramCount($user);
  217.         $limit Constants::PAGINATION_LIMIT;
  218.         // $allModulesQb = $moduleRepository->findAllModuleQueryBuilder($user, $allModulesPage, $limit);
  219.         // $allModules = $moduleRepository->findAllModule($allModulesQb);
  220.         
  221.         $allModulesCountQb $moduleRepository->findAllModuleQueryBuilder($user);
  222.         $allModuleCount $moduleRepository->findAllModule($allModulesCountQb)->count();
  223.         //$followedModules = $moduleRepository->findFollowedModules($user, $followedModulesPage, Constants::PAGINATION_LIMIT);
  224.         $followedModuleCount $moduleRepository->getFollowedModuleCount($usertrue);
  225.         //$followedModuleCountHist = $moduleRepository->getFollowedModuleCount($user, false);
  226.         $terminatedModules $moduleRepository->findTerminatedModules($user$terminatedModulesPage$limit);
  227.         $terminatedModuleCount $moduleRepository->getTerminatedModuleCount($user);
  228.         //$modulesObjectives = $moduleObjectiveRepository->findBy(array('module' => $allModules->getIterator()->getArrayCopy()));
  229.         //dd($allModules->getIterator()->getArrayCopy());
  230.         $programParticipationWithCertificate $user->getProgramParticipations()->filter(function($programParticipation) {
  231.             return ($programParticipation->getCertificate() !== null);
  232.         });
  233.         $programs $programRepository->findActivePrograms($user);
  234.         $modules $moduleRepository->searchModule(nullnull$user);
  235.         // Filter form
  236.         $form $this->createFormBuilder()
  237.         ->add('program'EntityType::class, [
  238.             'class' => Program::class,
  239.             'label' => false,
  240.             'choice_label' => 'label',
  241.             'placeholder' => 'Choisir un programme',
  242.             'required' => false,
  243.             'choices' => $programs,
  244.             'attr' => [
  245.                 // 'class' => 'form-select select-2-tags',
  246.                 'class' => 'select-2-tags custom-dash-select shadow-sm me-0 me-md-4 custom-dash-select-w bg-white',
  247.                 'data-placeholder' => 'Choisir un programme'
  248.             ], 
  249.         ])
  250.         ->add('module'EntityType::class, [
  251.             'class' => Module::class,
  252.             'label' => false,
  253.             'choice_label' => 'name',
  254.             'placeholder' => 'Choisir un module',
  255.             'required' => false,
  256.             'choices' => $modules,
  257.             'attr' => [
  258.                 // 'class' => 'form-select select-2-tags',
  259.                 'class' => 'select-2-tags custom-dash-select shadow-sm custom-dash-select-w bg-white',
  260.                 'data-placeholder' => 'Choisir un module'
  261.             ], 
  262.         ])
  263.         ->add('filter'SubmitType::class, [
  264.             'label' => 'Filtrer',
  265.             // 'attr' => ['class' => 'btn btn-danger opificio rounded-4 px-5 fw-bold fs-5']
  266.             'attr' => ['class' => 'custom-dash-select shadow-sm bg-white']
  267.         ])
  268.         ->getForm();
  269.         $form->handleRequest($request);
  270.         if ($form->isSubmitted() && $form->isValid()) {
  271.             $programData $form->get('program')->getData();
  272.             $moduleData $form->get('module')->getData();
  273.             if ($programData !== null$session->set('__program'$programData->getId());
  274.             if ($moduleData !== null$session->set('__module'$moduleData->getId());
  275.         }
  276.         $current_role $this->helperService->getUserCurrentRole();
  277.         $unreadNotifications $notificationRepository->findUnreadNotifications($user$notificationPageConstants::PAGINATION_LIMIT);
  278.         $unreadNotificationCount $notificationRepository->getUnreadNotificationCount($user);
  279.         $notificationCount $notificationRepository->findNotificationCount($user);
  280.         // $notifications = $notificationRepository->findBy(
  281.         //                                             array('receiver' => $user),
  282.         //                                             array('createdAt' => 'DESC'),
  283.         //                                             Constants::PAGINATION_LIMIT,
  284.         //                                             $notificationPage-1
  285.         //                                         );
  286.         $notifications $notificationRepository->findNotifications($user$notificationPageConstants::PAGINATION_LIMIT);
  287.         
  288.         // return $this->render('front/pages/dashboard/learner.html.twig', [
  289.         return $this->render('front/pages/dashboard/index.html.twig', [
  290.             'followed_program_count' => $followedProgramCount,
  291.             'terminated_program_count' => $terminatedProgramCount,
  292.             'followed_module_count' => $followedModuleCount,
  293.             'terminated_module_count' => $terminatedModuleCount,
  294.             //'followed_module_count_hist' => $followedModuleCountHist,
  295.             //'terminatedModuleCount' => $terminatedModuleCount,
  296.             //'followedModules' => $followedModules,
  297.             //'allModules' => $allModules,
  298.             'terminated_modules' => $terminatedModules,
  299.             'program_participation_with_certificate' => $programParticipationWithCertificate,
  300.             'limit' => Constants::PAGINATION_LIMIT,
  301.             'allModulesPage' => $allModulesPage,
  302.             'allModuleCount' => $allModuleCount,
  303.             'followedModulesPage' => $followedModulesPage,
  304.             //'followedModuleCount' => $followedModuleCount,
  305.             'terminatedModulesPage' => $terminatedModulesPage,
  306.             //'terminatedModuleCount' => $terminatedModuleCount,
  307.             'program' => ($session->has('__program') ? $programRepository->findOneById($session->get('__program')) : null),
  308.             'module' => ($session->has('__module') ? $moduleRepository->findOneById($session->get('__module')) : null),
  309.             //'programs' => $programs,
  310.             //'modules' => $modules,
  311.             'form' => $form->createView(),
  312.             'user' => $user,
  313.             'learner' => $learner,
  314.             'referer_profile' => $refererProfile,
  315.             'current_role' => $current_role,
  316.             'unreadNotifications' => $unreadNotifications,
  317.             'unreadNotificationCount' => $unreadNotificationCount,
  318.             'notificationPage' => $notificationPage,
  319.             'notifications' => $notifications,
  320.             'notificationCount' => $notificationCount
  321.         ]);
  322.     }
  323.     /**
  324.      * @Route("/apprenant/training-history/user/{id}", name="app_front_learner_training_history_for_user")
  325.      * @Route("/apprenant/training-history", name="app_front_learner_training_history")
  326.      * @Route("/apprenant/training-history/{id}", name="app_front_learner_training__history")
  327.      */
  328.     public function training_history(Request $requestModuleRepository $moduleRepositoryUser $learner null): Response
  329.     {   
  330.         $type $request->get('type''all');
  331.         $page = (int) $request->get('page'1);
  332.         $followedModulesPage 1;
  333.         $allModulesPage 1;
  334.         $terminatedModulesPage 1;
  335.         
  336.         if ($type == 'followed') {
  337.             $followedModulesPage $page;
  338.         } else if($type == 'terminated') {
  339.             $terminatedModulesPage $page;
  340.         } else {
  341.             $allModulesPage $page;
  342.         }
  343.         // dd($allModulesPage);
  344.         // $session = $request->getSession();
  345.         // dd($learner);
  346.         /** @var User */
  347.         $user = ($learner !== null) ? $learner $this->getUser();
  348.         // $refererProfile = null;
  349.         // if ($learner !== null) {
  350.         //     $user = $learner;
  351.         //     //$refererProfile = $session->has('__profile') ? $session->get('__profile') : null;
  352.         // }
  353.         // $followedProgramCount = $programRepository->getFollowedProgramCount($user);
  354.         // $terminatedProgramCount = $programRepository->getTerminatedProgramCount($user);
  355.         $allModulesQb $moduleRepository->findAllModuleQueryBuilder($user$allModulesPageConstants::PAGINATION_LIMIT);
  356.         $allModules $moduleRepository->findAllModule($allModulesQb);
  357.         
  358.         $allModulesCountQb $moduleRepository->findAllModuleQueryBuilder($user);
  359.         $allModuleCount $moduleRepository->findAllModule($allModulesCountQb)->count();
  360.         $followedModules $moduleRepository->findFollowedModules($user$followedModulesPageConstants::PAGINATION_LIMITfalse);
  361.         $followedModuleCount $moduleRepository->getFollowedModuleCount($usertrue);
  362.         $followedModuleCountHist $moduleRepository->getFollowedModuleCount($userfalse);
  363.         // dump($followedModuleCount);
  364.         // dump($followedModuleCountHist);
  365.         // die;
  366.         $terminatedModules $moduleRepository->findTerminatedModules($user$terminatedModulesPageConstants::PAGINATION_LIMIT);
  367.         $terminatedModuleCount $moduleRepository->getTerminatedModuleCount($user);
  368.         $allModulesPagination $this->paginator->paginate(
  369.             $allModulesQb,
  370.             $allModulesPage,
  371.             Constants::PAGINATION_LIMIT
  372.         );
  373.         return $this->render('front/layouts/partials/training-history.html.twig', [
  374.             'followedModules' => $followedModules,
  375.             'allModules' => $allModules,
  376.             'terminatedModules' => $terminatedModules,
  377.             'limit' => Constants::PAGINATION_LIMIT,
  378.             'allModulesPage' => $allModulesPage,
  379.             'all_module_count' => $allModuleCount,
  380.             'followedModulesPage' => $followedModulesPage,
  381.             'followedModuleCount' => $followedModuleCount,
  382.             'terminatedModulesPage' => $terminatedModulesPage,
  383.             //'terminatedModuleCount' => $terminatedModuleCount,
  384.             'terminated_module_count' => $terminatedModuleCount,
  385.             'followed_module_count_hist' => $followedModuleCountHist,
  386.             'user' => $user,
  387.             'learner' => $learner,
  388.             // 'allModulesPage' => $allModulesPage,
  389.             'followedModulesPage' => $followedModulesPage,
  390.             'terminatedModulesPage' => $terminatedModulesPage,
  391.             'type' => $type,
  392.             'allModulesPagination' => $allModulesPagination
  393.         ]);
  394.     }
  395.     /**
  396.      * @Route("/apprenant/all-certificates", name="app_front_learner_all_certificates")
  397.      */
  398.     public function allCertificates(Request $requestProgramRepository $programRepositoryModuleRepository $moduleRepositoryUser $learner null): Response
  399.     {   
  400.         $followedModulesPage = (int)$request->query->get('followedModulesPage'1);
  401.         $allModulesPage = (int)$request->query->get('allModulesPage'1);
  402.         $session $request->getSession();
  403.         /** @var User */
  404.         $user $this->getUser();
  405.         $refererProfile null;
  406.         if ($learner !== null) {
  407.             $user $learner;
  408.             $refererProfile $session->has('__profile') ? $session->get('__profile') : null;
  409.         }
  410.         $allModules $moduleRepository->findAllModule($user$allModulesPageConstants::PAGINATION_LIMIT);
  411.         $allModuleCount $moduleRepository->findAllModule($user)->count();
  412.         $programParticipationWithCertificate $user->getProgramParticipations()->filter(function($programParticipation) {
  413.             return ($programParticipation->getCertificate() !== null);
  414.         });
  415.         return $this->render('front/layouts/partials/all-certificates-dashboard.html.twig', [
  416.             'allModules' => $allModules,
  417.             'program_participation_with_certificate' => $programParticipationWithCertificate,
  418.             'user' => $user
  419.         ]);
  420.     }
  421.     /**
  422.      * @Route("/{profil}/list-apprenants", name="app_front_learner_page")
  423.      */
  424.     public function learnerPage(Request $requestUserRepository $userRepositoryProgramRepository $programRepositoryModuleRepository $moduleRepositoryString $profil): Response
  425.     {
  426.         $page = (int)$request->query->get('page'1);
  427.         if ($page <= 0) throw $this->createNotFoundException("La page demandée n'existe pas");
  428.         $programs $programRepository->findActivePrograms($this->getUser());
  429.         $modules $moduleRepository->searchModule(nullnull$this->getUser());
  430.         $session $request->getSession();
  431.         // Filter form
  432.         $form $this->createFormBuilder()
  433.         ->add('program'EntityType::class, [
  434.             'class' => Program::class,
  435.             'label' => false,
  436.             'choice_label' => 'label',
  437.             'attr' => ['class' => 'form-select fw-bold border-0 shadow-sm height-50'],
  438.             'placeholder' => 'Choisir un programme',
  439.             'required' => false,
  440.             'choices' => $programs,
  441.         ])
  442.         ->add('module'EntityType::class, [
  443.             'class' => Module::class,
  444.             'label' => false,
  445.             'choice_label' => 'name',
  446.             'attr' => ['class' => 'form-select fw-bold border-0 shadow-sm height-50'],
  447.             'placeholder' => 'Choisir un module',
  448.             'required' => false,
  449.             'choices' => $modules
  450.         ])
  451.         ->add('filter'SubmitType::class, [
  452.             'label' => 'Filtrer',
  453.             'attr' => ['class' => 'custom-dash-select shadow-sm bg-white']
  454.         ])
  455.         ->getForm();
  456.         
  457.         $form->handleRequest($request);
  458.         if ($form->isSubmitted() && $form->isValid()) {
  459.             $programData $form->get('program')->getData();
  460.             $module $form->get('module')->getData();
  461.             $session->set('__program'$programData->getId());
  462.             $session->set('__module'$module->getId());
  463.         }
  464.         $current_role $this->helperService->getUserCurrentRole();
  465.         $learners $userRepository->findLearners($pageConstants::PAGINATION_LIMIT$this->getUser(), $current_role);
  466.         // $learnerWithCertificateCount = $userRepository->getLearnerWithCertificateCount();
  467.         $learnerCount $this->getLearnerCount();
  468.         
  469.         
  470.         return $this->render('front/pages/dashboard/learners/learners.html.twig', [
  471.             'learners' => $learners,
  472.             'total_learner' => $learnerCount,
  473.             'limit' => Constants::PAGINATION_LIMIT,
  474.             'page' => $page,
  475.             'program' => ($session->has('__program') ? $programRepository->findOneById($session->get('__program')) : null),
  476.             'module' => ($session->has('__module') ? $moduleRepository->findOneById($session->get('__module')) : null),
  477.             'user' => ($profil === 'integrateur' || $profil === 'administrateur') ? null $this->getUser(),
  478.             'programs' => $programs,
  479.             'modules' => $modules,
  480.             'form' => $form->createView(),
  481.             'current_role' => $current_role
  482.             // 'success_rate' => ($learnerWithCertificateCount / $learnerCount) * 100,
  483.         ]);
  484.     }
  485.     /**
  486.      * @Route("/{profil}/utilisateurs", name="app_front_user_page")
  487.      */
  488.     public function utilisateurPage(): Response
  489.     {
  490.         return $this->render('front/pages/dashboard/users/users.html.twig', [
  491.             'controller_name' => 'users',
  492.         ]);
  493.     }
  494.     /**
  495.      * @Route("/{profil}/programmes", name="app_front_program_page")
  496.      * @Route("/{profil}/programmes-termines", name="app_front_terminated_program_page")
  497.      * @Route("/{profil}/{id}/programmes", name="app_front_learner_program_page")
  498.      * @Route("/{profil}/{id}/programmes-termines", name="app_front_learner_terminated_program_page")
  499.      */
  500.     public function programPage(Request $requestProgramRepository $programRepositoryPaginatorInterface $paginatorUser $learner null): Response
  501.     {
  502.         $session $request->getSession();
  503.         if ($request->query->get('page') === null$session->remove('program_search_key');
  504.         $program = new Program();
  505.         $page = (int)$request->query->get('page'1);
  506.         if ($page <= 0) throw $this->createNotFoundException("La page demandée n'existe pas");
  507.         // Search form
  508.         $searchKey $session->has('program_search_key') ? $session->get('program_search_key') : null;
  509.         $form $this->createFormBuilder()
  510.         ->add('searchKey'TextType::class, [
  511.             'label' => 'Rechercher: ',
  512.             'label_attr' => ['class' => 'text-grey'],
  513.             'attr' => [
  514.                 'style' => 'border: 1px solid transparent !important'
  515.             ],
  516.             'required' => false,
  517.             'data' => $session->has('program_search_key') ? $session->get('program_search_key') : ''
  518.         ])
  519.         ->getForm();
  520.          
  521.         $form->handleRequest($request);
  522.         if ($form->isSubmitted() && $form->isValid()) {
  523.             $searchKey $form->get('searchKey')->getData();
  524.             $session->remove('program_search_key');
  525.             if ($searchKey !== null$session->set('program_search_key'$searchKey);
  526.         }
  527.         $user = ($learner !== null) ? $learner $this->getUser();
  528.         // $programs = $programRepository->findPrograms($user, $page, Constants::PAGINATION_LIMIT, $searchKey);
  529.         $programs $programRepository->findProgramsQuery($usertrue$searchKey);
  530.         // $totalProgram = $programRepository->getTotalProgram($user, $searchKey);
  531.         $pagination $paginator->paginate(
  532.             $programs,
  533.             $page,
  534.             10
  535.         );
  536.         return $this->renderForm('front/pages/dashboard/program/program.html.twig', [
  537.             'program' => $program,
  538.             'programs' => $pagination,
  539.             //'totalProgram' => $totalProgram,
  540.             'limit' => Constants::PAGINATION_LIMIT,
  541.             'page' => $page,
  542.             'form' => $form
  543.         ]);
  544.     }
  545.     /**
  546.      * @Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_INTEGRATOR')")
  547.      * 
  548.      * @Route("/{profil}/programmes/creer-un-programme", name="app_front_create_program_page")
  549.      */
  550.     public function createProgram(Request $requestProgramRepository $programRepositoryString $profil): Response
  551.     {
  552.         // if (!$this->isGranted('ROLE_ADMIN') && !$this->isGranted('ROLE_INTEGRATOR')) throw $this->createNotFoundException("La page demandée n'existe pas");
  553.         // if (!in_array($this->helperService->getUserCurrentRole(), Constants::MANAGER_ROLES)) throw $this->createNotFoundException("La page demandée n'existe pas");
  554.         $program = new Program();
  555.         $form $this->createForm(ProgramType::class, $program);
  556.         $form->handleRequest($request);
  557.         if ($form->isSubmitted() && $form->isValid()) {
  558.             $programRepository->add($programtrue);
  559.         
  560.             $subsidiaryCompanies = ($program->isIsAllSubsidiaryCompanies()) ? "Toutes les filiales" $program->getSubsidiaryCompanies()->toArray();
  561.             $jobs = ($program->isIsAllJobs()) ? "Tous les métiers" $program->getJobs()->toArray();
  562.             $offices = ($program->isIsAllOffices()) ? "Toutes les fonctions" $program->getOffices()->toArray();
  563.             $contracts = ($program->isIsAllContracts()) ? "Tous les types de contrat" $program->getContracts()->toArray();
  564.             $toAddresses = [];
  565.             $topics = [];
  566.             if (is_array($subsidiaryCompanies)) {
  567.                 foreach ($subsidiaryCompanies as $subsidiaryCompany) {
  568.                     $toAddresses [] = $subsidiaryCompany->getMailingListAllStaff();
  569.                 }
  570.             } else {
  571.                 $toAddresses [] = $this->getParameter('cofina_all_subsidiary_companies_recipient_mail');
  572.                 $topics [] = Constants::DEFAULT_TOPIC;
  573.             }
  574.             $deviceTokens = [];
  575.             foreach ($program->getUsers() as $user) {
  576.                 $toAddresses [] = $user->getEmail();
  577.                 $deviceTokens array_diff($deviceTokens, ($user->getDeviceTokens() ?? []));
  578.             }
  579.             if ($toAddresses !== null && count($toAddresses) > 0) {
  580.                 $okUrl $_ENV['SECURE_SCHEME'].':'.$this->generateUrl('app_admin_program_participation_page', ['id' => $program->getId()], UrlGeneratorInterface::NETWORK_PATH);
  581.                 $nokUrl $_ENV['SECURE_SCHEME'].':'.$this->generateUrl('app_admin_program_participant_unavailable_page', ['id' => $program->getId()], UrlGeneratorInterface::NETWORK_PATH);
  582.                 $mail = (new TemplatedEmail())
  583.                     ->from(new Address($this->getParameter('cofina_sender_mail'), 'Cofina Academy'))
  584.                     ->to(...$toAddresses)
  585.                     ->subject('Invitation au Programme')
  586.                     ->htmlTemplate('front/pages/dashboard/program/mail.html.twig')
  587.                     ->context([
  588.                         'subsidiaryCompanies' => $subsidiaryCompanies,
  589.                         'jobs' => $jobs,
  590.                         'offices' => $offices,
  591.                         'contracts' => $contracts,
  592.                         'objective' => $program->getObjective(),
  593.                         'name' => $program->getLabel(),
  594.                         'startAt' => $program->getStartAt(),
  595.                         'endAt' => $program->getEndAt(),
  596.                         'program_participation_url' => $okUrl,
  597.                         'nok_url' => $nokUrl
  598.                     ]);
  599.                 try {
  600.                     $this->mailer->send($mail);
  601.                 } catch (TransportExceptionInterface $e) {
  602.                     // dump($e->getMessage()); die;
  603.                 }
  604.             }  
  605.             try {
  606.                 $this->bus->dispatch(new Notification($program->getId(), 'Program''new_program'$program->getCreatedBy()->getId()));
  607.             } catch (Exception $e) {
  608.                 // dump($e->getMessage()); die;
  609.             }
  610.             return $this->redirectToRoute('app_front_program_page', ['profil' => $profil], Response::HTTP_SEE_OTHER);
  611.         }
  612.         return $this->renderForm('front/pages/dashboard/program/create_program.html.twig', [
  613.             'program' => $program,
  614.             'form' => $form,
  615.             'profil' => $profil
  616.         ]);
  617.     }
  618.     /**
  619.      * @Route("/{profil}/modules", name="app_front_module_page")
  620.      * @Route("/{profil}/modules-termines", name="app_front_terminated_module_page")
  621.      * @Route("/{profil}/{id}/modules", name="app_front_learner_module_page")
  622.      * @Route("/{profil}/{id}/modules-termines", name="app_front_learner_terminated_module_page")
  623.      */
  624.     public function modulePage(Request $requestModuleRepository $moduleRepositoryPaginatorInterface $paginatorUser $learner null): Response
  625.     {
  626.         $session $request->getSession();
  627.         if ($request->query->get('page') === null$session->remove('module_search_key');
  628.         // $module = new Module();
  629.         $page = (int)$request->query->get('page'1);
  630.         if ($page <= 0) throw $this->createNotFoundException("La page demandée n'existe pas");
  631.         // Search form
  632.         $searchKey $session->has('module_search_key') ? $session->get('module_search_key') : null;
  633.         $form $this->createFormBuilder()
  634.         ->add('searchKey'TextType::class, [
  635.             'label' => 'Rechercher: ',
  636.             'label_attr' => ['class' => 'text-grey'],
  637.             'attr' => [
  638.                 'style' => 'border: 1px solid transparent !important'
  639.             ],
  640.             'required' => false,
  641.             'data' => $session->has('module_search_key') ? $session->get('module_search_key') : ''
  642.         ])
  643.         ->getForm();
  644.         
  645.         $form->handleRequest($request);
  646.         if ($form->isSubmitted() && $form->isValid()) {
  647.             $searchKey $form->get('searchKey')->getData();
  648.             $session->remove('module_search_key');
  649.             if ($searchKey !== null$session->set('module_search_key'$searchKey);
  650.         }
  651.         //$modules = $moduleRepository->findPaginateModule($page, Constants::PAGINATION_LIMIT);
  652.         $user = ($learner !== null) ? $learner $this->getUser();
  653.         $modules $moduleRepository->findModulesQuery($usertrue$searchKey);
  654.         //$totalModule = $moduleRepository->findModules($this->getUser(), false, null, null, $searchKey);
  655.         //$totalModule = $moduleRepository->getTotalModule($this->getUser());
  656.         //dd($totalModule);
  657.         $pagination $paginator->paginate(
  658.             $modules,
  659.             $page,
  660.             10
  661.         );
  662.         return $this->renderForm('front/pages/dashboard/modules/modules.html.twig', [
  663.             //'module' => $module,
  664.             'modules' => $pagination,
  665.             // 'totalModule' => $totalModule,
  666.             'limit' => Constants::PAGINATION_LIMIT,
  667.             'page' => $page,
  668.             'form' => $form
  669.         ]);
  670.     }
  671.     /**
  672.      * @Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_INTEGRATOR')")
  673.      * 
  674.      * @Route("/{profil}/modules/creer-un-module", name="app_front_create_module_page")
  675.      */
  676.     public function createModule(Request $requestModuleRepository $moduleRepositoryModuleItemRepository $moduleItemRepositoryString $profil): Response
  677.     {
  678.         // if (!$this->isGranted('ROLE_ADMIN') && !$this->isGranted('ROLE_INTEGRATOR')) throw $this->createNotFoundException("La page demandée n'existe pas");
  679.         if (!in_array($this->helperService->getUserCurrentRole(), Constants::MANAGER_ROLES)) throw $this->createNotFoundException("La page demandée n'existe pas");
  680.         $module = new Module();
  681.         $form $this->createForm(ModuleType::class, $module);
  682.         $form->handleRequest($request);
  683.         if ($form->isSubmitted() && $form->isValid()) {
  684.             if ($module->isIsPublished()) $module->setPublishedAt(new DateTime());
  685.             $moduleRepository->add($moduletrue);
  686.             $courses $module->getCourses();
  687.             foreach ($courses as $course) {
  688.                 // $moduleItem = $moduleItemRepository->findOneBy(['module' => $module, 'course' => $course]);
  689.                 // if ($moduleItem === null) {
  690.                     $moduleItem = new ModuleItem();
  691.                     $moduleItem->setModule($module);
  692.                     $moduleItem->setCourse($course);
  693.                     $moduleItem->setType('course');
  694.                     $moduleItemRepository->add($moduleItemtrue);
  695.                 // }
  696.             }
  697.             $_quiz $module->getQuiz();
  698.             foreach ($_quiz as $quiz) {
  699.                 // $moduleItem = $moduleItemRepository->findOneBy(['module' => $module, 'quiz' => $quiz]);
  700.                 // if ($moduleItem === null) {
  701.                     $moduleItem = new ModuleItem();
  702.                     $moduleItem->setModule($module);
  703.                     $moduleItem->setQuiz($quiz);
  704.                     $moduleItem->setType('quiz');
  705.                     $moduleItemRepository->add($moduleItemtrue);
  706.                 // }
  707.             }
  708.             return $this->redirectToRoute('app_front_module_page', ['profil' => $profil], Response::HTTP_SEE_OTHER);
  709.         }
  710.         return $this->renderForm('front/pages/dashboard/modules/create_module.html.twig', [
  711.             'module' => $module,
  712.             'form' => $form,
  713.             'profil' => $profil
  714.         ]);
  715.     }
  716.     /**
  717.      * @Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_INTEGRATOR')")
  718.      * 
  719.      * @Route("/{profil}/modules/organiser-le-module/{slug}", name="app_front_module_arrange_page")
  720.      */
  721.     public function arrangeModulePage(ModuleItemRepository $moduleItemRepositoryModule $module): Response
  722.     {
  723.         // if (!$this->isGranted('ROLE_ADMIN') && !$this->isGranted('ROLE_INTEGRATOR')) throw $this->createNotFoundException("La page demandée n'existe pas");
  724.         // if (!in_array($this->helperService->getUserCurrentRole(), Constants::MANAGER_ROLES)) throw $this->createNotFoundException("La page demandée n'existe pas");
  725.         $items $moduleItemRepository->findItems($module);
  726.         // dump($items); die;
  727.         return $this->renderForm('front/pages/dashboard/modules/arrange.html.twig', [
  728.             'items' => $items,
  729.             'module' => $module
  730.         ]);
  731.     }
  732.     /**
  733.      * @Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_INTEGRATOR') or is_granted('ROLE_COACH') or is_granted('ROLE_TUTOR') or is_granted('ROLE_ADVISE')")
  734.      * 
  735.      * @Route("/{profil}/quiz", name="app_front_quiz_page")
  736.      */
  737.     public function quizPage(Request $requestQuizRepository $quizRepositoryString $profil null): Response
  738.     {
  739.         $session $request->getSession();
  740.         if ($request->query->get('page') === null$session->remove('quiz_search_key');
  741.         $userRole $this->getUserActivedRole($profil);
  742.         if ($userRole === null) throw $this->createNotFoundException("La page demandée n'existe pas");
  743.         $quiz = new Quiz();
  744.         $page = (int)$request->query->get('page'1);
  745.         if ($page <= 0) throw $this->createNotFoundException("La page demandée n'existe pas");
  746.         // Search form
  747.         $searchKey $session->has('quiz_search_key') ? $session->get('quiz_search_key') : null;
  748.         $form $this->createFormBuilder()
  749.         ->add('searchKey'TextType::class, [
  750.             'label' => 'Rechercher: ',
  751.             'label_attr' => ['class' => 'text-grey'],
  752.             'attr' => [
  753.                 'style' => 'border: 1px solid transparent !important'
  754.             ],
  755.             'required' => false,
  756.             'data' => $session->has('quiz_search_key') ? $session->get('quiz_search_key') : ''
  757.         ])
  758.         ->getForm();
  759.         
  760.         $form->handleRequest($request);
  761.         if ($form->isSubmitted() && $form->isValid()) {
  762.             $searchKey $form->get('searchKey')->getData();
  763.             $session->remove('quiz_search_key');
  764.             if ($searchKey !== null$session->set('quiz_search_key'$searchKey);
  765.         }
  766.         $quizs $quizRepository->findQuiz($this->getUser(), $pageConstants::PAGINATION_LIMIT$searchKey);
  767.         $totalQuiz $quizRepository->findQuiz($this->getUser(), nullnull$searchKey);
  768.         // $totalQuiz = $quizRepository->getTotalQuiz($this->getUser());
  769.         return $this->renderForm('front/pages/dashboard/quiz/quiz.html.twig', [
  770.             'quizs' => $quizs,
  771.             'quiz' => $quiz,
  772.             'totalQuiz' => $totalQuiz,
  773.             'limit' => Constants::PAGINATION_LIMIT,
  774.             'page' => $page,
  775.             'form' => $form
  776.         ]);
  777.     }
  778.     /**
  779.      * @Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_INTEGRATOR') or is_granted('ROLE_COACH') or is_granted('ROLE_TUTOR') or is_granted('ROLE_ADVISE')")
  780.      * 
  781.      * @Route("/{profil}/quiz/creer-un-quiz", name="app_front_create_quiz_page")
  782.      */
  783.     public function createQuiz(Request $requestQuizRepository $quizRepositoryModuleItemRepository $moduleItemRepositoryString $profil): Response
  784.     {
  785.         // if (!$this->isGranted('ROLE_ADMIN') && !$this->isGranted('ROLE_INTEGRATOR') && !$this->isGranted('ROLE_COACH')) throw $this->createNotFoundException("La page demandée n'existe pas");
  786.         $quiz = new Quiz();
  787.         $form $this->createForm(QuizType::class, $quiz);
  788.         $form->handleRequest($request);
  789.         if ($form->isSubmitted() && $form->isValid()) {
  790.             // $hour = (int)$quiz->getTime()->format('H');
  791.             // $minute = (int)$quiz->getTime()->format('i');
  792.             // $second = (int)$quiz->getTime()->format('s');
  793.             // $curentDate = clone (new DateTime());
  794.             // $endAt = $curentDate->add(new DateInterval('PT'.$hour.'H'.$minute.'M'.$second.'S'));
  795.             // $quiz->setAutomaticEndAt($endAt);
  796.             try {
  797.                 if ($form->has('saveAndSentToReview') && $form->get('saveAndSentToReview')->isClicked()) {
  798.                     $this->quizWorkflow->apply($quiz'to_review');
  799.                     $this->addFlash('quiz_added_and_sent_to_review''Quiz créé et envoyé à validation');
  800.                 } elseif ($form->has('saveAndPublished') && $form->get('saveAndPublished')->isClicked()) {
  801.                     $this->quizWorkflow->apply($quiz'publish');
  802.                     $quiz->setIsPublished(true);
  803.                     $this->addFlash('quiz_added_and_published''Quiz créé et publié');
  804.                 } else {
  805.                     $message 'Quiz crée';
  806.                     if ($quiz->isIsPublished()) $message .= ' et publié';
  807.                     $this->addFlash('quiz_added'$message);
  808.                 }
  809.                 $quizRepository->add($quiztrue);
  810.                 $modules $quiz->getModules();
  811.                 foreach ($modules as $module) {
  812.                     $moduleItem = new ModuleItem();
  813.                     $moduleItem->setModule($module);
  814.                     $moduleItem->setQuiz($quiz);
  815.                     $moduleItem->setType('quiz');
  816.                     $moduleItemRepository->add($moduleItemtrue);
  817.                 }
  818.             } catch (LogicException $exception) {
  819.                 $this->addFlash('quiz_no_sent_to_review'"Erreur survenue lors de l'envoie du quiz à la validation. Veuillez contacter l'administrateur");
  820.             }
  821.             return $this->redirectToRoute('app_front_quiz_page', ['profil' => $profil], Response::HTTP_SEE_OTHER);
  822.         }
  823.         return $this->renderForm('front/pages/dashboard/quiz/create_quiz.html.twig', [
  824.             'quiz' => $quiz,
  825.             'form' => $form,
  826.             'profil' => $profil,
  827.         ]);
  828.     }
  829.     /**
  830.      * @Route("/{profil}/cours", name="app_front_course_page")
  831.      */
  832.     public function coursePage(Request $requestCourseRepository $courseRepositoryString $profil null): Response
  833.     {
  834.         // $userRole = $this->getUserActivedRole($profil);
  835.         // if ($userRole === null) throw $this->createNotFoundException("La page demandée n'existe pas");
  836.         $session $request->getSession();
  837.         if ($request->query->get('page') === null$session->remove('course_search_key');
  838.         $course = new Course();
  839.         $page = (int)$request->query->get('page'1);
  840.         if ($page <= 0) throw $this->createNotFoundException("La page demandée n'existe pas");
  841.         // Search form
  842.         $searchKey $session->has('course_search_key') ? $session->get('course_search_key') : null;
  843.         $form $this->createFormBuilder()
  844.         ->add('searchKey'TextType::class, [
  845.             'label' => 'Rechercher: ',
  846.             'label_attr' => ['class' => 'text-grey'],
  847.             'attr' => [
  848.                 'style' => 'border: 1px solid transparent !important'
  849.             ],
  850.             'required' => false,
  851.             'data' => $session->has('course_search_key') ? $session->get('course_search_key') : ''
  852.         ])
  853.         ->getForm();
  854.         
  855.         $form->handleRequest($request);
  856.         if ($form->isSubmitted() && $form->isValid()) {
  857.             $searchKey $form->get('searchKey')->getData();
  858.             $session->remove('course_search_key');
  859.             if ($searchKey !== null$session->set('course_search_key'$searchKey);
  860.         }
  861.         $courses $courseRepository->findCourses($this->getUser(), $pageConstants::PAGINATION_LIMIT$searchKey);
  862.         $totalCourse $courseRepository->findCourses($this->getUser(), nullnull$searchKey);
  863.         // $totalCourse = $courseRepository->getTotalCourse($this->getUser());
  864.         return $this->renderForm('front/pages/dashboard/courses/courses.html.twig', [
  865.             'course' => $course,
  866.             'courses' => $courses,
  867.             'totalCourse' => $totalCourse,
  868.             'limit' => Constants::PAGINATION_LIMIT,
  869.             'page' => $page,
  870.             'form' => $form
  871.         ]);
  872.     }
  873.     /**
  874.      * @Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_INTEGRATOR') or is_granted('ROLE_COACH')")
  875.      * 
  876.      * @Route("/{profil}/cours/creer-un-cours", name="app_front_create_course_page")
  877.      */
  878.     public function createCourse(Request $requestCourseRepository $courseRepositoryModuleItemRepository $moduleItemRepositoryString $profil): Response
  879.     {
  880.         // if (!$this->isGranted('ROLE_ADMIN') && !$this->isGranted('ROLE_INTEGRATOR') && !$this->isGranted('ROLE_COACH')) throw $this->createNotFoundException("La page demandée n'existe pas");
  881.         $course = new Course();
  882.         $form $this->createForm(CourseType::class, $course);
  883.         $form->handleRequest($request);
  884.         if ($form->isSubmitted() && $form->isValid()) {
  885.             try {
  886.                 if ($form->has('saveAndSentToReview') && $form->get('saveAndSentToReview')->isClicked()) {
  887.                     $this->courseWorkflow->apply($course'to_review');
  888.                     $this->addFlash('course_added_and_sent_to_review''Cours créé et envoyé à validation');
  889.                 } elseif ($form->has('saveAndPublished') && $form->get('saveAndPublished')->isClicked()) {
  890.                     $this->courseWorkflow->apply($course'publish');
  891.                     $course->setIsPublished(true);
  892.                     $this->addFlash('course_added_and_published''Cours créé et publié');
  893.                 } else {
  894.                     $message 'Cours crée';
  895.                     if ($course->isIsPublished()) $message .= ' et publié';
  896.                     $this->addFlash('course_added'$message);
  897.                 }
  898.                 $courseRepository->add($coursetrue);
  899.                 $modules $course->getModules();
  900.                 foreach ($modules as $module) {
  901.                     $moduleItem = new ModuleItem();
  902.                     $moduleItem->setModule($module);
  903.                     $moduleItem->setCourse($course);
  904.                     $moduleItem->setType('course');
  905.                     $moduleItemRepository->add($moduleItemtrue);
  906.                 }
  907.             } catch (LogicException $exception) {
  908.                 $this->addFlash('course_no_sent_to_review'"Erreur survenue lors de l'envoie du cours à la validation. Veuillez contacter l'administrateur");
  909.             }
  910.             return $this->redirectToRoute('app_front_course_page', ['profil' => $profil], Response::HTTP_SEE_OTHER);
  911.         }
  912.         return $this->renderForm('front/pages/dashboard/courses/create_course.html.twig', [
  913.             'course' => $course,
  914.             'form' => $form,
  915.             'profil' => $profil,
  916.         ]);
  917.     }
  918.     /**
  919.      * @Route("/{profil}/lives", name="app_dashboard_live_page")
  920.      */
  921.     public function livePage(Request $requestLiveRepository $liveRepositoryString $profil null): Response
  922.     {
  923.         $session $request->getSession();
  924.         if ($request->query->get('page') === null$session->remove('live_search_key');
  925.         $userRole $this->getUserActivedRole($profil);
  926.         if ($userRole === null) throw $this->createNotFoundException("La page demandée n'existe pas");
  927.         $live = new Live();
  928.         $page = (int)$request->query->get('page'1);
  929.         if ($page <= 0) throw $this->createNotFoundException("La page demandée n'existe pas");
  930.         // Search form
  931.         $searchKey $session->has('live_search_key') ? $session->get('live_search_key') : null;
  932.         $form $this->createFormBuilder()
  933.         ->add('searchKey'TextType::class, [
  934.             'label' => 'Rechercher: ',
  935.             'label_attr' => ['class' => 'text-grey'],
  936.             'attr' => [
  937.                 'style' => 'border: 1px solid transparent !important'
  938.             ],
  939.             'required' => false,
  940.             'data' => $session->has('live_search_key') ? $session->get('live_search_key') : ''
  941.         ])
  942.         ->getForm();
  943.         
  944.         $form->handleRequest($request);
  945.         if ($form->isSubmitted() && $form->isValid()) {
  946.             $searchKey $form->get('searchKey')->getData();
  947.             $session->remove('live_search_key');
  948.             if ($searchKey !== null$session->set('live_search_key'$searchKey);
  949.         }
  950.         $lives $liveRepository->findLives($this->getUser(), $pageConstants::PAGINATION_LIMIT$searchKey);
  951.         $totalLive $liveRepository->findLives($this->getUser(), nullnull$searchKey);
  952.         // $totalLive = $liveRepository->getTotalLive($this->getUser(), $userRole);
  953.         foreach($lives as $live) {
  954.             $records $live->getLiveRecords();
  955.             foreach($records as $record) {
  956.                 if(!$record->isIsAlreadyDownloaded()) {
  957.                     $live->removeLiveRecord($record);
  958.                 }
  959.             }
  960.         }
  961.         return $this->renderForm('front/pages/dashboard/lives/lives.html.twig', [
  962.             'live' => $live,
  963.             'lives' => $lives,
  964.             'totalLive' => $totalLive,
  965.             'limit' => Constants::PAGINATION_LIMIT,
  966.             'page' => $page,
  967.             'form' => $form
  968.         ]);
  969.     }
  970.     /**
  971.      * @Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_INTEGRATOR') or is_granted('ROLE_COACH')")
  972.      * 
  973.      * @Route("/{profil}/lives/creer-un-live", name="app_front_create_live_page")
  974.      */
  975.     public function createLive(Request $requestLiveRepository $liveRepositoryModuleItemRepository $moduleItemRepositoryString $profil): Response
  976.     {
  977.         // if (!$this->isGranted('ROLE_ADMIN') && !$this->isGranted('ROLE_INTEGRATOR') && !$this->isGranted('ROLE_COACH')) throw $this->createNotFoundException("La page demandée n'existe pas");
  978.         
  979.         $live = new Live();
  980.         $form $this->createForm(LiveType::class, $live);
  981.         $form->handleRequest($request);
  982.         if ($form->isSubmitted() && $form->isValid()) {
  983.             try {
  984.                 if ($form->has('saveAndSentToReview') && $form->get('saveAndSentToReview')->isClicked()) {
  985.                     $this->liveWorkflow->apply($live'to_review');
  986.                     $this->addFlash('live_added_and_sent_to_review''Live créé et envoyé à validation');
  987.                 }  elseif ($form->has('saveAndPublished') && $form->get('saveAndPublished')->isClicked()) {
  988.                     $this->liveWorkflow->apply($live'publish');
  989.                     $live->setIsPublished(true);
  990.                     $this->addFlash('live_added_and_published''Live créé et publié');
  991.                 } else {
  992.                     $message 'Live crée';
  993.                     if ($live->isIsPublished()) $message .= ' et publié';
  994.                     $this->addFlash('live_added'$message);
  995.                 }
  996.     
  997.                 if ($live->getTime() !== null) {
  998.                     $hour = (int)$live->getTime()->format('H');
  999.                     $minute = (int)$live->getTime()->format('i');
  1000.                     $second = (int)$live->getTime()->format('s');
  1001.         
  1002.                     $startDate = clone $live->getStartAt();
  1003.         
  1004.                     $endAt $startDate->add(new DateInterval('PT'.$hour.'H'.$minute.'M'.$second.'S'));
  1005.                     $live->setEndAt($endAt);
  1006.                 }
  1007.     
  1008.                 $liveRepository->add($livetrue);
  1009.     
  1010.                 $modules $live->getModules();
  1011.                 foreach ($modules as $module) {
  1012.                     $moduleItem = new ModuleItem();
  1013.                     $moduleItem->setModule($module);
  1014.                     $moduleItem->setLive($live);
  1015.                     $moduleItem->setType('live');
  1016.     
  1017.                     $moduleItemRepository->add($moduleItemtrue);
  1018.                 }
  1019.                 // /** @var DateTime $startAt */
  1020.                 // $startAt = $live->getStartAt();
  1021.                 // if ($startAt !== null && $live->isIsPublished()) {
  1022.                 //     $interval = new DateInterval('PT' . Constants::TIME_BEFORE_LIVE_SESSION_STARTING . 'M');
  1023.                 //     $notificationDateBeforeLiveStarting = clone $startAt;
  1024.                 //     $notificationDateBeforeLiveStarting->sub($interval);
  1025.                 //     $minutes = $notificationDateBeforeLiveStarting->format('i');
  1026.                 //     $hour = $notificationDateBeforeLiveStarting->format('H');
  1027.                 //     $atExpression = sprintf("%s:%s", $hour, $minutes);
  1028.                 //     // /** @var User $user The user object */
  1029.                 //     // $schedule = new \Zenstruck\ScheduleBundle\Schedule();
  1030.                 //     // $schedule->addCommand('app:live-session-starting:notification '.$live->getId())
  1031.                 //     //     ->description('Send notification to live ('.$live->getTitle().') participants')
  1032.                 //     //     ->at($atExpression)
  1033.                 //     // ;
  1034.                 //     // /** @var \Zenstruck\ScheduleBundle\Schedule $this->schedule */
  1035.                 //     // $this->schedule->addCommand('app:test-mail:sending')
  1036.                 //     //     ->description('Send mail test 2.')
  1037.                 //     //     ->everyMinute()
  1038.                 //     // ;
  1039.                 // }
  1040.             } catch (LogicException $exception) {
  1041.                 $this->addFlash('live_no_sent_to_review'"Erreur survenue lors de l'envoie du live à la validation. Veuillez contacter l'administrateur");
  1042.             }
  1043.             
  1044.             return $this->redirectToRoute('app_dashboard_live_page', ['profil' => $profil], Response::HTTP_SEE_OTHER);
  1045.             // return $this->redirectToRoute('app_front_lives_page', [], Response::HTTP_SEE_OTHER);
  1046.         }
  1047.         return $this->renderForm('front/pages/dashboard/lives/create_live.html.twig', [
  1048.             'live' => $live,
  1049.             'form' => $form,
  1050.             'profil' => $profil
  1051.         ]);
  1052.     }
  1053.     /**
  1054.      * @Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_INTEGRATOR')")
  1055.      * 
  1056.      * @Route("/{profil}/parametre/citations", name="app_front_quote_page")
  1057.      */
  1058.     public function quotePage(Request $requestQuoteRepository $quoteRepositoryString $profil): Response
  1059.     {
  1060.         $quote = new Quote();
  1061.         $page = (int)$request->query->get('page'1);
  1062.         if ($page <= 0) throw $this->createNotFoundException("La page demandée n'existe pas");
  1063.         $quotes $quoteRepository->findPaginateQuote($pageConstants::PAGINATION_LIMIT);
  1064.         $totalQuote $quoteRepository->getTotalQuote();
  1065.         return $this->renderForm('front/pages/dashboard/quotes/quotes.html.twig', [
  1066.             'quote' => $quote,
  1067.             'quotes' => $quotes,
  1068.             'totalQuote' => $totalQuote,
  1069.             'limit' => Constants::PAGINATION_LIMIT,
  1070.             'page' => $page,
  1071.         ]);
  1072.     }
  1073.     /**
  1074.      * @Security("is_granted('ROLE_ADMIN')")
  1075.      * 
  1076.      * @Route("/{profil}/parametre/creer-une-citation", name="app_front_create_quote_page")
  1077.      */
  1078.     public function createQuote(Request $requestQuoteRepository $quoteRepositoryString $profil): Response
  1079.     {
  1080.         if (!$this->isGranted('ROLE_ADMIN') && !$this->isGranted('ROLE_INTEGRATOR')) throw $this->createNotFoundException("La page demandée n'existe pas");
  1081.         $quote = new Quote();
  1082.         $form $this->createForm(QuoteType::class, $quote);
  1083.         $form->handleRequest($request);
  1084.         if ($form->isSubmitted() && $form->isValid()) {
  1085.             $quoteRepository->add($quotetrue);
  1086.             return $this->redirectToRoute('app_front_quote_page', ['profil' => $profil], Response::HTTP_SEE_OTHER);
  1087.         }
  1088.         return $this->renderForm('front/pages/dashboard/quotes/create_quote.html.twig', [
  1089.             'quote' => $quote,
  1090.             'form' => $form,
  1091.         ]);
  1092.     }
  1093.     /**
  1094.      * @Security("is_granted('ROLE_ADMIN')")
  1095.      * 
  1096.      * @Route("/{profil}/parametre/ajouter-un-mot-du-directeur", name="app_front_create_director_page")
  1097.      */
  1098.     public function createDirectorWord(Request $requestDirectorRepository $directorRepositoryString $profil): Response
  1099.     {
  1100.         // if (!$this->isGranted('ROLE_ADMIN') && !$this->isGranted('ROLE_INTEGRATOR')) throw $this->createNotFoundException("La page demandée n'existe pas");
  1101.         $director = new Director();
  1102.         $form $this->createForm(DirectorType::class, $director);
  1103.         $form->handleRequest($request);
  1104.         if ($form->isSubmitted() && $form->isValid()) {
  1105.             $directorRepository->add($directortrue);
  1106.             return $this->redirectToRoute('app_front_director_page', ['profil' => $profil], Response::HTTP_SEE_OTHER);
  1107.         }
  1108.         return $this->renderForm('front/pages/dashboard/directors/create_director.html.twig', [
  1109.             'director' => $director,
  1110.             'form' => $form,
  1111.             'profil' => $profil
  1112.         ]);
  1113.     }
  1114.     /**
  1115.      * @Security("is_granted('ROLE_ADMIN')")
  1116.      * 
  1117.      * @Route("/{profil}/parametre/mots-du-directeur", name="app_front_director_page")
  1118.      */
  1119.     public function directorPage(Request $requestDirectorRepository $directorRepositoryString $profil): Response
  1120.     {
  1121.         $director = new Director();
  1122.         $page = (int)$request->query->get('page'1);
  1123.         if ($page <= 0) throw $this->createNotFoundException("La page demandée n'existe pas");
  1124.         $directors $directorRepository->findPaginateDirector($pageConstants::PAGINATION_LIMIT);
  1125.         $totalDirector $directorRepository->getTotalDirector();
  1126.         return $this->renderForm('front/pages/dashboard/directors/directors.html.twig', [
  1127.             'director' => $director,
  1128.             'directors' => $directors,
  1129.             'totalDirector' => $totalDirector,
  1130.             'limit' => Constants::PAGINATION_LIMIT,
  1131.             'page' => $page,
  1132.             'profil' => $profil
  1133.         ]);
  1134.     }
  1135.     /**
  1136.      * @Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_INTEGRATOR')")
  1137.      * 
  1138.      * @Route("/{profil}/parametre/module-vedettes", name="app_front_featured_module_page")
  1139.      */
  1140.     public function featured(Request $requestFeaturedModuleRepository $featuredModuleRepositoryString $profil): Response
  1141.     {
  1142.         $featuredModules $featuredModuleRepository->findBy([], ['id' => 'DESC'], 10);
  1143.         $featuredModule = (empty($featuredModules)) ? new FeaturedModule() : $featuredModules[0];
  1144.         $form $this->createForm(FeaturedModuleType::class, $featuredModule);
  1145.         $form->handleRequest($request);
  1146.         if ($form->isSubmitted() && $form->isValid()) {
  1147.             $featuredModuleRepository->add($featuredModuletrue);
  1148.             return $this->redirectToRoute('app_front_featured_module_page', ['profil' => $profil], Response::HTTP_SEE_OTHER);
  1149.         }
  1150.         return $this->renderForm('front/pages/dashboard/modules/featured_module.html.twig', [
  1151.             'featured_module' => $featuredModule,
  1152.             'form' => $form,
  1153.         ]);
  1154.     }
  1155.     /**
  1156.      * @Route("/job/offices/{id}", name="job_offices")
  1157.      * @param Request $request
  1158.      * @param Job $job
  1159.      * @return JsonResponse
  1160.      */
  1161.     public function jobOffice(Request $requestJob $job)
  1162.     {
  1163.         $output = [];
  1164.         if ($job !== null) {
  1165.             $offices $job->getOffices();
  1166.             foreach ($offices as $key => $office) {
  1167.                 $output[] = [
  1168.                     'id' => $office->getId(),
  1169.                     'name' => $office->getName()
  1170.                 ];
  1171.             }
  1172.         }
  1173.         
  1174.         return $this->json($output);
  1175.     }
  1176.     /**
  1177.      * @Route("/job/offices", name="jobs_offices")
  1178.      * @param Request $request
  1179.      * @return JsonResponse
  1180.      */
  1181.     public function jobsOffice(Request $requestOfficeRepository $officeRepository)
  1182.     {
  1183.         $output = [];
  1184.         $ids $request->get('ids');
  1185.         if ($ids !== null && !empty($ids)) {
  1186.             $offices $officeRepository->findOffices($ids);
  1187.             foreach ($offices as $key => $office) {
  1188.                 $output[] = [
  1189.                     'id' => $office->getId(),
  1190.                     'text' => $office->getName()
  1191.                 ];
  1192.             }
  1193.         }
  1194.         
  1195.         return $this->json($output);
  1196.     }
  1197.     public function getUserActivedRole(String $profil null): String
  1198.     {
  1199.         $userRoles $this->skipDefaultRole($this->getUser()->getRoles());
  1200.         if ($profil === null)  {
  1201.             $userRole = (!empty($userRoles)) ? $userRoles[0] : null;
  1202.         } else $userRole $this->getRoleByProfil($profil);
  1203.         return $userRole;
  1204.     }
  1205.     /**
  1206.      * @Route("/{profil}", name="app_front_dashboard_kpi_page")
  1207.      */
  1208.     public function kpiPage(Request $requestUserRepository $userRepositoryProgramRepository $programRepositoryModuleRepository $moduleRepositoryPaginatorInterface $paginatorString $profil): Response
  1209.     {
  1210.         $page = (int)$request->query->get('page'1);
  1211.         if ($page <= 0) throw $this->createNotFoundException("La page demandée n'existe pas");
  1212.         if ($profil === 'apprenant') return $this->redirectToRoute('app_front_learner_dashboard_page');
  1213.         $user $this->getUser();
  1214.         $programs $programRepository->findPrograms($user);
  1215.         $modules $moduleRepository->findModules($usertrue);
  1216.         $program null;
  1217.         $module null;
  1218.         $session $request->getSession();
  1219.         // Filter form
  1220.         $form $this->createFormBuilder()
  1221.         ->add('program'EntityType::class, [
  1222.             'class' => Program::class,
  1223.             'label' => false,
  1224.             'choice_label' => 'label',
  1225.             'attr' => ['class' => 'form-select select-2-tags'],
  1226.             'placeholder' => 'Choisir un programme',
  1227.             'required' => false,
  1228.             'choices' => $programs,
  1229.         ])
  1230.         ->add('module'EntityType::class, [
  1231.             'class' => Module::class,
  1232.             'label' => false,
  1233.             'choice_label' => 'name',
  1234.             'attr' => ['class' => 'form-select select-2-tags'],
  1235.             'placeholder' => 'Choisir un module',
  1236.             'required' => false,
  1237.             'choices' => $modules
  1238.         ])
  1239.         ->add('filter'SubmitType::class, [
  1240.             'label' => 'Filtrer',
  1241.             'attr' => ['class' => 'custom-dash-select shadow-sm bg-white']
  1242.         ])
  1243.         ->getForm();
  1244.         
  1245.         $form->handleRequest($request);
  1246.         if ($form->isSubmitted() && $form->isValid()) {
  1247.             $program $form->get('program')->getData();
  1248.             $module $form->get('module')->getData();
  1249.             // if ($programData !== null) $session->set('__program', $programData->getId());
  1250.             // if ($moduleData !== null) $session->set('__module', $moduleData->getId());
  1251.         }
  1252.         // dump($this->getCompletionRate($program, $module, null)); die;
  1253.         $session->set('__profile'$profil);
  1254.         $currentRole $this->helperService->getUserCurrentRole();
  1255.         
  1256.         // $learners = $userRepository->findLearners($page, Constants::PAGINATION_LIMIT, $this->getUser(), $current_role);
  1257.         // $learnerWithCertificateCount = $userRepository->getLearnerWithCertificateCount();
  1258.         // $learnerCount = $this->getLearnerCount();
  1259.         // $learnerCount = count($userRepository->findLearners(null, null, $this->getUser(), $currentRole));
  1260.         //$em = $this->getDoctrine()->getRepository('App\Entity\UserModuleParticipation');
  1261.         //dd($em->getUserModuleItemCount());
  1262.         $learners $userRepository->findLearnersQuery($this->getUser(), $currentRole);
  1263.         // $learnerCount = $userRepository->getLearnersCount($this->getUser(), $currentRole);
  1264.         $pagination $paginator->paginate(
  1265.             $learners,
  1266.             $page,
  1267.             Constants::PAGINATION_LIMIT
  1268.         );
  1269.         return $this->render('front/pages/dashboard/kpi/index.html.twig', [
  1270.             // 'learners' => $learners,
  1271.             // 'total_learner' => $learnerCount,
  1272.             'limit' => Constants::PAGINATION_LIMIT,
  1273.             'page' => $page,
  1274.             'program' => $program,
  1275.             'module' => $module,
  1276.             //'user' => ($profil === 'integrateur' || $profil === 'administrateur') ? null : $this->getUser(),
  1277.             'user' => $this->getUser(),
  1278.             'programs' => $programs,
  1279.             'modules' => $modules,
  1280.             'form' => $form->createView(),
  1281.             'current_role' => $currentRole,
  1282.             'learners' => $pagination,
  1283.             // 'success_rate' => ($learnerWithCertificateCount / $learnerCount) * 100,
  1284.         ]);
  1285.     }
  1286.     /**
  1287.      * @Security("is_granted('ROLE_ADMIN')")
  1288.      * 
  1289.      * @Route("/{profil}/parametre/creer-un-partenaire", name="app_front_create_partenaire_page")
  1290.      */
  1291.     public function createPartenaire(Request $requestPartenaireRepository $partenaireRepositoryString $profil): Response
  1292.     {
  1293.         // if (!$this->isGranted('ROLE_ADMIN') && !$this->isGranted('ROLE_INTEGRATOR')) throw $this->createNotFoundException("La page demandée n'existe pas");
  1294.         $partenaire = new Partenaire();
  1295.         $form $this->createForm(PartenaireType::class, $partenaire);
  1296.         $form->handleRequest($request);
  1297.         if ($form->isSubmitted() && $form->isValid()) {
  1298.             $partenaireRepository->add($partenairetrue);
  1299.             return $this->redirectToRoute('app_dashboard_partner_page', ['profil' => $profil], Response::HTTP_SEE_OTHER);
  1300.         }
  1301.         return $this->renderForm('front/pages/dashboard/partenaires/create_partenaire.html.twig', [
  1302.             'partenaire' => $partenaire,
  1303.             'form' => $form,
  1304.             'profil' => $profil
  1305.         ]);
  1306.     }
  1307.     /**
  1308.      * @Security("is_granted('ROLE_ADMIN')")
  1309.      * 
  1310.      * @Route("/{profil}/parametre/partenaires", name="app_dashboard_partner_page")
  1311.      */
  1312.     public function partenairePage(Request $requestPartenaireRepository $partenaireRepositoryString $profil): Response
  1313.     {
  1314.         $partenaire = new Partenaire();
  1315.         $page = (int)$request->query->get('page'1);
  1316.         if ($page <= 0) throw $this->createNotFoundException("La page demandée n'existe pas");
  1317.         $partenaires $partenaireRepository->findPaginatePartenaire($pageConstants::PAGINATION_LIMIT);
  1318.         $totalPartenaire $partenaireRepository->getTotalPartenaire();
  1319.         return $this->renderForm('front/pages/dashboard/partenaires/partenaires.html.twig', [
  1320.             'partenaire' => $partenaire,
  1321.             'partenaires' => $partenaires,
  1322.             'totalPartenaire' => $totalPartenaire,
  1323.             'limit' => Constants::PAGINATION_LIMIT,
  1324.             'page' => $page,
  1325.             'profil' => $profil
  1326.         ]);
  1327.     }
  1328.     /**
  1329.      * @Route("/notification/as-read", name="notification_as_read")
  1330.      * @param Request $request
  1331.      * @return JsonResponse
  1332.      */
  1333.     public function notificationStatus(NotificationRepository $notificationRepositoryNotificationReceiverRepository $notificationReceiverRepository)
  1334.     {
  1335.         $notifications $notificationRepository->findUnreadNotifications($this->getUser());
  1336.         foreach ($notifications as $notification) {
  1337.             $notification->setIsRead(true);
  1338.             $notificationRepository->add($notificationtrue);
  1339.             $notificationReceivers $notification->getNotificationReceivers();
  1340.             foreach ($notificationReceivers as $notificationReceiver) {
  1341.                 $notificationReceiver->setIsRead(true);
  1342.                 $notificationReceiverRepository->add($notificationReceivertrue);
  1343.             }
  1344.         }
  1345.         
  1346.         return $this->json(['OK']);
  1347.     }
  1348.     /**
  1349.      * @Route("/apprenant/notifications", name="app_get_user_notifications")
  1350.      */
  1351.     public function getNotifications(Request $requestNotificationRepository $notificationRepositorySerializerInterface $serializer): Response
  1352.     {   
  1353.         $notificationPage = (int)$request->query->get('notificationPage'1);
  1354.         $user $this->getUser();
  1355.         // $unreadNotifications = $notificationRepository->findUnreadNotifications($user, $notificationPage, Constants::PAGINATION_LIMIT);
  1356.         $unreadNotificationCount $notificationRepository->getUnreadNotificationCount($user);
  1357.         // $notificationCount = $notificationRepository->findNotificationCount($user);
  1358.         $notifications $notificationRepository->findNotifications($user$notificationPageConstants::PAGINATION_LIMIT);
  1359.         $context = new SerializationContext();
  1360.         $context->setSerializeNull(true);
  1361.         // $output = $serializer->serialize($notifications, 'json', $context);
  1362.         //return $this->json(json_decode($output, true));
  1363.         return $this->json(['unreadNotificationCount' => $unreadNotificationCount'html' => $this->render('front/layouts/partials/notifications-response.html.twig', ['notifications' => $notifications])->getContent()]);
  1364.         // return $this->renderForm('front/layouts/partials/notifications-response.html.twig', ['notifications' => $notification]);
  1365.     }
  1366.     /**
  1367.      * @Route("/apprenant/notifications/redirect/{id}", name="app_redirect_user_notifications")
  1368.      */
  1369.     public function redirectNotification(Request $requestNotificationEntity $notificationNotificationRepository $notificationRepositorySubjectRepository $subjectRepositoryProgramRepository $programRepositoryModuleRepository $moduleRepositoryCommentRepository $commentRepository): Response
  1370.     {   
  1371.         if($notification->getObjectType() == 'program') {
  1372.             return $this->redirectToRoute('app_front_program_module', ['id' => $notification->getObjectId()]);
  1373.         } else if($notification->getObjectType() == 'subject') {
  1374.             $subject $subjectRepository->find($notification->getObjectId());
  1375.             if($subject != null) {
  1376.                 return $this->redirectToRoute('app_front_forum_page', ['module_slug' => $subject->getModule()->getSlug(), 'subject_slug' => $subject->getSlug()]);
  1377.             }
  1378.             return $this->redirectToRoute('app_front_forum_charter_page');
  1379.         } else if($notification->getObjectType() == 'module') {
  1380.             $module $moduleRepository->find($notification->getObjectId());
  1381.             return $this->redirectToRoute('app_front_library_module_details_page', ['slug' => $module->getSlug()]);
  1382.         } else if($notification->getObjectType() == 'comment') {
  1383.             $comment $commentRepository->find($notification->getObjectId());
  1384.             if($comment != null) {
  1385.                 $subject $comment->getSubject();
  1386.                 $url $this->generateUrl('app_front_forum_page', ['module_slug' => $subject->getModule()->getSlug(), 'subject_slug' => $subject->getSlug()]);
  1387.                 if($notification->getComment()) {
  1388.                     $url .= '#comment-ref_'.$notification->getComment()->getId();
  1389.                 }
  1390.                 return $this->redirect($url);
  1391.             }
  1392.         } else if($notification->getObjectType() == 'live') {
  1393.             $routeName 'app_front_live_meet_page';
  1394.             $parameters = ['id' => $notification->getObjectId()];
  1395.             if ($notification->getModule() !== null) {
  1396.                 $module $notification->getModule();
  1397.                 $routeName 'app_front_live_module_meet_page';
  1398.                 $parameters['module_slug'] = $module->getSlug();
  1399.             }
  1400.             return $this->redirectToRoute($routeName$parameters);
  1401.         } else if($notification->getObjectType() == 'quiz') {
  1402.             if ($notification->getModule() !== null) {
  1403.                 $module $notification->getModule();
  1404.                 return $this->redirectToRoute('app_front_library_module_details_page', ['slug' => $module->getSlug()]);
  1405.             }
  1406.         } else if($notification->getObjectType() == 'quote') {
  1407.             return $this->redirectToRoute('app_front_homepage');
  1408.         }
  1409.         return $this->redirectToRoute('app_front_learner_dashboard_page');
  1410.     }
  1411.     /**
  1412.      * @Route("/v2", name="app_front_dashboard_v2_page")
  1413.      */
  1414.     public function new_dash(): Response
  1415.     {
  1416.         return $this->render('front/pages/dashboard/new_dash.html.twig', [
  1417.             'user' => $this->getUser()
  1418.         ]);
  1419.     }
  1420.     /**
  1421.      * @Route("/apprenant/historique-notifications", name="app_front_dashboard_notification_page")
  1422.      */
  1423.     public function notification(NotificationRepository $notificationRepository): Response
  1424.     {
  1425.         $unreadNotificationCount $notificationRepository->getUnreadNotificationCount($this->getUser());
  1426.         return $this->render('front/pages/dashboard/notification.html.twig', [
  1427.             'unreadNotificationCount' => $unreadNotificationCount
  1428.         ]);
  1429.     }
  1430.     /**
  1431.      * @Route("/{profil}/badges", name="app_front_dashboard_badge_block")
  1432.      */
  1433.     public function badge(ModuleRepository $moduleRepository): Response
  1434.     {
  1435.         $terminatedModules $moduleRepository->findTerminatedModules($this->getUser());
  1436.         return $this->render('front/pages/dashboard/components/badge-block.html.twig', [
  1437.             'terminated_modules' => $terminatedModules,
  1438.         ]);
  1439.     }
  1440. }