src/Controller/Front/DashboardController.php line 443

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, $allModulesPage, Constants::PAGINATION_LIMIT);
  411.         // $allModuleCount = $moduleRepository->findAllModule($user)->count();
  412.         $allModulesQb $moduleRepository->findAllModuleQueryBuilder($user$allModulesPageConstants::PAGINATION_LIMIT);
  413.         $programParticipationWithCertificate $user->getProgramParticipations()->filter(function($programParticipation) {
  414.             return ($programParticipation->getCertificate() !== null);
  415.         });
  416.         return $this->render('front/layouts/partials/all-certificates-dashboard.html.twig', [
  417.             'allModules' => $allModulesQb,
  418.             'program_participation_with_certificate' => $programParticipationWithCertificate,
  419.             'user' => $user
  420.         ]);
  421.     }
  422.     /**
  423.      * @Route("/{profil}/list-apprenants", name="app_front_learner_page")
  424.      */
  425.     public function learnerPage(Request $requestUserRepository $userRepositoryProgramRepository $programRepositoryModuleRepository $moduleRepositoryString $profil): Response
  426.     {
  427.         $page = (int)$request->query->get('page'1);
  428.         if ($page <= 0) throw $this->createNotFoundException("La page demandée n'existe pas");
  429.         $programs $programRepository->findActivePrograms($this->getUser());
  430.         $modules $moduleRepository->searchModule(nullnull$this->getUser());
  431.         $session $request->getSession();
  432.         // Filter form
  433.         $form $this->createFormBuilder()
  434.         ->add('program'EntityType::class, [
  435.             'class' => Program::class,
  436.             'label' => false,
  437.             'choice_label' => 'label',
  438.             'attr' => ['class' => 'form-select fw-bold border-0 shadow-sm height-50'],
  439.             'placeholder' => 'Choisir un programme',
  440.             'required' => false,
  441.             'choices' => $programs,
  442.         ])
  443.         ->add('module'EntityType::class, [
  444.             'class' => Module::class,
  445.             'label' => false,
  446.             'choice_label' => 'name',
  447.             'attr' => ['class' => 'form-select fw-bold border-0 shadow-sm height-50'],
  448.             'placeholder' => 'Choisir un module',
  449.             'required' => false,
  450.             'choices' => $modules
  451.         ])
  452.         ->add('filter'SubmitType::class, [
  453.             'label' => 'Filtrer',
  454.             'attr' => ['class' => 'custom-dash-select shadow-sm bg-white']
  455.         ])
  456.         ->getForm();
  457.         
  458.         $form->handleRequest($request);
  459.         if ($form->isSubmitted() && $form->isValid()) {
  460.             $programData $form->get('program')->getData();
  461.             $module $form->get('module')->getData();
  462.             $session->set('__program'$programData->getId());
  463.             $session->set('__module'$module->getId());
  464.         }
  465.         $current_role $this->helperService->getUserCurrentRole();
  466.         $learners $userRepository->findLearners($pageConstants::PAGINATION_LIMIT$this->getUser(), $current_role);
  467.         // $learnerWithCertificateCount = $userRepository->getLearnerWithCertificateCount();
  468.         $learnerCount $this->getLearnerCount();
  469.         
  470.         
  471.         return $this->render('front/pages/dashboard/learners/learners.html.twig', [
  472.             'learners' => $learners,
  473.             'total_learner' => $learnerCount,
  474.             'limit' => Constants::PAGINATION_LIMIT,
  475.             'page' => $page,
  476.             'program' => ($session->has('__program') ? $programRepository->findOneById($session->get('__program')) : null),
  477.             'module' => ($session->has('__module') ? $moduleRepository->findOneById($session->get('__module')) : null),
  478.             'user' => ($profil === 'integrateur' || $profil === 'administrateur') ? null $this->getUser(),
  479.             'programs' => $programs,
  480.             'modules' => $modules,
  481.             'form' => $form->createView(),
  482.             'current_role' => $current_role
  483.             // 'success_rate' => ($learnerWithCertificateCount / $learnerCount) * 100,
  484.         ]);
  485.     }
  486.     /**
  487.      * @Route("/{profil}/utilisateurs", name="app_front_user_page")
  488.      */
  489.     public function utilisateurPage(): Response
  490.     {
  491.         return $this->render('front/pages/dashboard/users/users.html.twig', [
  492.             'controller_name' => 'users',
  493.         ]);
  494.     }
  495.     /**
  496.      * @Route("/{profil}/programmes", name="app_front_program_page")
  497.      * @Route("/{profil}/programmes-termines", name="app_front_terminated_program_page")
  498.      * @Route("/{profil}/{id}/programmes", name="app_front_learner_program_page")
  499.      * @Route("/{profil}/{id}/programmes-termines", name="app_front_learner_terminated_program_page")
  500.      */
  501.     public function programPage(Request $requestProgramRepository $programRepositoryPaginatorInterface $paginatorUser $learner null): Response
  502.     {
  503.         $session $request->getSession();
  504.         if ($request->query->get('page') === null$session->remove('program_search_key');
  505.         $program = new Program();
  506.         $page = (int)$request->query->get('page'1);
  507.         if ($page <= 0) throw $this->createNotFoundException("La page demandée n'existe pas");
  508.         // Search form
  509.         $searchKey $session->has('program_search_key') ? $session->get('program_search_key') : null;
  510.         $form $this->createFormBuilder()
  511.         ->add('searchKey'TextType::class, [
  512.             'label' => 'Rechercher: ',
  513.             'label_attr' => ['class' => 'text-grey'],
  514.             'attr' => [
  515.                 'style' => 'border: 1px solid transparent !important'
  516.             ],
  517.             'required' => false,
  518.             'data' => $session->has('program_search_key') ? $session->get('program_search_key') : ''
  519.         ])
  520.         ->getForm();
  521.          
  522.         $form->handleRequest($request);
  523.         if ($form->isSubmitted() && $form->isValid()) {
  524.             $searchKey $form->get('searchKey')->getData();
  525.             $session->remove('program_search_key');
  526.             if ($searchKey !== null$session->set('program_search_key'$searchKey);
  527.         }
  528.         $user = ($learner !== null) ? $learner $this->getUser();
  529.         // $programs = $programRepository->findPrograms($user, $page, Constants::PAGINATION_LIMIT, $searchKey);
  530.         $programs $programRepository->findProgramsQuery($usertrue$searchKey);
  531.         // $totalProgram = $programRepository->getTotalProgram($user, $searchKey);
  532.         $pagination $paginator->paginate(
  533.             $programs,
  534.             $page,
  535.             10
  536.         );
  537.         return $this->renderForm('front/pages/dashboard/program/program.html.twig', [
  538.             'program' => $program,
  539.             'programs' => $pagination,
  540.             //'totalProgram' => $totalProgram,
  541.             'limit' => Constants::PAGINATION_LIMIT,
  542.             'page' => $page,
  543.             'form' => $form
  544.         ]);
  545.     }
  546.     /**
  547.      * @Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_INTEGRATOR')")
  548.      * 
  549.      * @Route("/{profil}/programmes/creer-un-programme", name="app_front_create_program_page")
  550.      */
  551.     public function createProgram(Request $requestProgramRepository $programRepositoryString $profil): Response
  552.     {
  553.         // if (!$this->isGranted('ROLE_ADMIN') && !$this->isGranted('ROLE_INTEGRATOR')) throw $this->createNotFoundException("La page demandée n'existe pas");
  554.         // if (!in_array($this->helperService->getUserCurrentRole(), Constants::MANAGER_ROLES)) throw $this->createNotFoundException("La page demandée n'existe pas");
  555.         $program = new Program();
  556.         $form $this->createForm(ProgramType::class, $program);
  557.         $form->handleRequest($request);
  558.         if ($form->isSubmitted() && $form->isValid()) {
  559.             $programRepository->add($programtrue);
  560.         
  561.             $subsidiaryCompanies = ($program->isIsAllSubsidiaryCompanies()) ? "Toutes les filiales" $program->getSubsidiaryCompanies()->toArray();
  562.             $jobs = ($program->isIsAllJobs()) ? "Tous les métiers" $program->getJobs()->toArray();
  563.             $offices = ($program->isIsAllOffices()) ? "Toutes les fonctions" $program->getOffices()->toArray();
  564.             $contracts = ($program->isIsAllContracts()) ? "Tous les types de contrat" $program->getContracts()->toArray();
  565.             $toAddresses = [];
  566.             $topics = [];
  567.             if (is_array($subsidiaryCompanies)) {
  568.                 foreach ($subsidiaryCompanies as $subsidiaryCompany) {
  569.                     $toAddresses [] = $subsidiaryCompany->getMailingListAllStaff();
  570.                 }
  571.             } else {
  572.                 $toAddresses [] = $this->getParameter('cofina_all_subsidiary_companies_recipient_mail');
  573.                 $topics [] = Constants::DEFAULT_TOPIC;
  574.             }
  575.             $deviceTokens = [];
  576.             foreach ($program->getUsers() as $user) {
  577.                 $toAddresses [] = $user->getEmail();
  578.                 $deviceTokens array_diff($deviceTokens, ($user->getDeviceTokens() ?? []));
  579.             }
  580.             if ($toAddresses !== null && count($toAddresses) > 0) {
  581.                 $okUrl $_ENV['SECURE_SCHEME'].':'.$this->generateUrl('app_admin_program_participation_page', ['id' => $program->getId()], UrlGeneratorInterface::NETWORK_PATH);
  582.                 $nokUrl $_ENV['SECURE_SCHEME'].':'.$this->generateUrl('app_admin_program_participant_unavailable_page', ['id' => $program->getId()], UrlGeneratorInterface::NETWORK_PATH);
  583.                 $mail = (new TemplatedEmail())
  584.                     ->from(new Address($this->getParameter('cofina_sender_mail'), 'Cofina Academy'))
  585.                     ->to(...$toAddresses)
  586.                     ->subject('Invitation au Programme')
  587.                     ->htmlTemplate('front/pages/dashboard/program/mail.html.twig')
  588.                     ->context([
  589.                         'subsidiaryCompanies' => $subsidiaryCompanies,
  590.                         'jobs' => $jobs,
  591.                         'offices' => $offices,
  592.                         'contracts' => $contracts,
  593.                         'objective' => $program->getObjective(),
  594.                         'name' => $program->getLabel(),
  595.                         'startAt' => $program->getStartAt(),
  596.                         'endAt' => $program->getEndAt(),
  597.                         'program_participation_url' => $okUrl,
  598.                         'nok_url' => $nokUrl
  599.                     ]);
  600.                 try {
  601.                     $this->mailer->send($mail);
  602.                 } catch (TransportExceptionInterface $e) {
  603.                     // dump($e->getMessage()); die;
  604.                 }
  605.             }  
  606.             try {
  607.                 $this->bus->dispatch(new Notification($program->getId(), 'Program''new_program'$program->getCreatedBy()->getId()));
  608.             } catch (Exception $e) {
  609.                 // dump($e->getMessage()); die;
  610.             }
  611.             return $this->redirectToRoute('app_front_program_page', ['profil' => $profil], Response::HTTP_SEE_OTHER);
  612.         }
  613.         return $this->renderForm('front/pages/dashboard/program/create_program.html.twig', [
  614.             'program' => $program,
  615.             'form' => $form,
  616.             'profil' => $profil
  617.         ]);
  618.     }
  619.     /**
  620.      * @Route("/{profil}/modules", name="app_front_module_page")
  621.      * @Route("/{profil}/modules-termines", name="app_front_terminated_module_page")
  622.      * @Route("/{profil}/{id}/modules", name="app_front_learner_module_page")
  623.      * @Route("/{profil}/{id}/modules-termines", name="app_front_learner_terminated_module_page")
  624.      */
  625.     public function modulePage(Request $requestModuleRepository $moduleRepositoryPaginatorInterface $paginatorUser $learner null): Response
  626.     {
  627.         $session $request->getSession();
  628.         if ($request->query->get('page') === null$session->remove('module_search_key');
  629.         // $module = new Module();
  630.         $page = (int)$request->query->get('page'1);
  631.         if ($page <= 0) throw $this->createNotFoundException("La page demandée n'existe pas");
  632.         // Search form
  633.         $searchKey $session->has('module_search_key') ? $session->get('module_search_key') : null;
  634.         $form $this->createFormBuilder()
  635.         ->add('searchKey'TextType::class, [
  636.             'label' => 'Rechercher: ',
  637.             'label_attr' => ['class' => 'text-grey'],
  638.             'attr' => [
  639.                 'style' => 'border: 1px solid transparent !important'
  640.             ],
  641.             'required' => false,
  642.             'data' => $session->has('module_search_key') ? $session->get('module_search_key') : ''
  643.         ])
  644.         ->getForm();
  645.         
  646.         $form->handleRequest($request);
  647.         if ($form->isSubmitted() && $form->isValid()) {
  648.             $searchKey $form->get('searchKey')->getData();
  649.             $session->remove('module_search_key');
  650.             if ($searchKey !== null$session->set('module_search_key'$searchKey);
  651.         }
  652.         //$modules = $moduleRepository->findPaginateModule($page, Constants::PAGINATION_LIMIT);
  653.         $user = ($learner !== null) ? $learner $this->getUser();
  654.         $modules $moduleRepository->findModulesQuery($usertrue$searchKey);
  655.         //$totalModule = $moduleRepository->findModules($this->getUser(), false, null, null, $searchKey);
  656.         //$totalModule = $moduleRepository->getTotalModule($this->getUser());
  657.         //dd($totalModule);
  658.         $pagination $paginator->paginate(
  659.             $modules,
  660.             $page,
  661.             10
  662.         );
  663.         return $this->renderForm('front/pages/dashboard/modules/modules.html.twig', [
  664.             //'module' => $module,
  665.             'modules' => $pagination,
  666.             // 'totalModule' => $totalModule,
  667.             'limit' => Constants::PAGINATION_LIMIT,
  668.             'page' => $page,
  669.             'form' => $form
  670.         ]);
  671.     }
  672.     /**
  673.      * @Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_INTEGRATOR')")
  674.      * 
  675.      * @Route("/{profil}/modules/creer-un-module", name="app_front_create_module_page")
  676.      */
  677.     public function createModule(Request $requestModuleRepository $moduleRepositoryModuleItemRepository $moduleItemRepositoryString $profil): Response
  678.     {
  679.         // if (!$this->isGranted('ROLE_ADMIN') && !$this->isGranted('ROLE_INTEGRATOR')) throw $this->createNotFoundException("La page demandée n'existe pas");
  680.         if (!in_array($this->helperService->getUserCurrentRole(), Constants::MANAGER_ROLES)) throw $this->createNotFoundException("La page demandée n'existe pas");
  681.         $module = new Module();
  682.         $form $this->createForm(ModuleType::class, $module);
  683.         $form->handleRequest($request);
  684.         if ($form->isSubmitted() && $form->isValid()) {
  685.             if ($module->isIsPublished()) $module->setPublishedAt(new DateTime());
  686.             $moduleRepository->add($moduletrue);
  687.             $courses $module->getCourses();
  688.             foreach ($courses as $course) {
  689.                 // $moduleItem = $moduleItemRepository->findOneBy(['module' => $module, 'course' => $course]);
  690.                 // if ($moduleItem === null) {
  691.                     $moduleItem = new ModuleItem();
  692.                     $moduleItem->setModule($module);
  693.                     $moduleItem->setCourse($course);
  694.                     $moduleItem->setType('course');
  695.                     $moduleItemRepository->add($moduleItemtrue);
  696.                 // }
  697.             }
  698.             $_quiz $module->getQuiz();
  699.             foreach ($_quiz as $quiz) {
  700.                 // $moduleItem = $moduleItemRepository->findOneBy(['module' => $module, 'quiz' => $quiz]);
  701.                 // if ($moduleItem === null) {
  702.                     $moduleItem = new ModuleItem();
  703.                     $moduleItem->setModule($module);
  704.                     $moduleItem->setQuiz($quiz);
  705.                     $moduleItem->setType('quiz');
  706.                     $moduleItemRepository->add($moduleItemtrue);
  707.                 // }
  708.             }
  709.             return $this->redirectToRoute('app_front_module_page', ['profil' => $profil], Response::HTTP_SEE_OTHER);
  710.         }
  711.         return $this->renderForm('front/pages/dashboard/modules/create_module.html.twig', [
  712.             'module' => $module,
  713.             'form' => $form,
  714.             'profil' => $profil
  715.         ]);
  716.     }
  717.     /**
  718.      * @Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_INTEGRATOR')")
  719.      * 
  720.      * @Route("/{profil}/modules/organiser-le-module/{slug}", name="app_front_module_arrange_page")
  721.      */
  722.     public function arrangeModulePage(ModuleItemRepository $moduleItemRepositoryModule $module): Response
  723.     {
  724.         // if (!$this->isGranted('ROLE_ADMIN') && !$this->isGranted('ROLE_INTEGRATOR')) throw $this->createNotFoundException("La page demandée n'existe pas");
  725.         // if (!in_array($this->helperService->getUserCurrentRole(), Constants::MANAGER_ROLES)) throw $this->createNotFoundException("La page demandée n'existe pas");
  726.         $items $moduleItemRepository->findItems($module);
  727.         // dump($items); die;
  728.         return $this->renderForm('front/pages/dashboard/modules/arrange.html.twig', [
  729.             'items' => $items,
  730.             'module' => $module
  731.         ]);
  732.     }
  733.     /**
  734.      * @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')")
  735.      * 
  736.      * @Route("/{profil}/quiz", name="app_front_quiz_page")
  737.      */
  738.     public function quizPage(Request $requestQuizRepository $quizRepositoryString $profil null): Response
  739.     {
  740.         $session $request->getSession();
  741.         if ($request->query->get('page') === null$session->remove('quiz_search_key');
  742.         $userRole $this->getUserActivedRole($profil);
  743.         if ($userRole === null) throw $this->createNotFoundException("La page demandée n'existe pas");
  744.         $quiz = new Quiz();
  745.         $page = (int)$request->query->get('page'1);
  746.         if ($page <= 0) throw $this->createNotFoundException("La page demandée n'existe pas");
  747.         // Search form
  748.         $searchKey $session->has('quiz_search_key') ? $session->get('quiz_search_key') : null;
  749.         $form $this->createFormBuilder()
  750.         ->add('searchKey'TextType::class, [
  751.             'label' => 'Rechercher: ',
  752.             'label_attr' => ['class' => 'text-grey'],
  753.             'attr' => [
  754.                 'style' => 'border: 1px solid transparent !important'
  755.             ],
  756.             'required' => false,
  757.             'data' => $session->has('quiz_search_key') ? $session->get('quiz_search_key') : ''
  758.         ])
  759.         ->getForm();
  760.         
  761.         $form->handleRequest($request);
  762.         if ($form->isSubmitted() && $form->isValid()) {
  763.             $searchKey $form->get('searchKey')->getData();
  764.             $session->remove('quiz_search_key');
  765.             if ($searchKey !== null$session->set('quiz_search_key'$searchKey);
  766.         }
  767.         $quizs $quizRepository->findQuiz($this->getUser(), $pageConstants::PAGINATION_LIMIT$searchKey);
  768.         $totalQuiz $quizRepository->findQuiz($this->getUser(), nullnull$searchKey);
  769.         // $totalQuiz = $quizRepository->getTotalQuiz($this->getUser());
  770.         return $this->renderForm('front/pages/dashboard/quiz/quiz.html.twig', [
  771.             'quizs' => $quizs,
  772.             'quiz' => $quiz,
  773.             'totalQuiz' => $totalQuiz,
  774.             'limit' => Constants::PAGINATION_LIMIT,
  775.             'page' => $page,
  776.             'form' => $form
  777.         ]);
  778.     }
  779.     /**
  780.      * @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')")
  781.      * 
  782.      * @Route("/{profil}/quiz/creer-un-quiz", name="app_front_create_quiz_page")
  783.      */
  784.     public function createQuiz(Request $requestQuizRepository $quizRepositoryModuleItemRepository $moduleItemRepositoryString $profil): Response
  785.     {
  786.         // if (!$this->isGranted('ROLE_ADMIN') && !$this->isGranted('ROLE_INTEGRATOR') && !$this->isGranted('ROLE_COACH')) throw $this->createNotFoundException("La page demandée n'existe pas");
  787.         $quiz = new Quiz();
  788.         $form $this->createForm(QuizType::class, $quiz);
  789.         $form->handleRequest($request);
  790.         if ($form->isSubmitted() && $form->isValid()) {
  791.             // $hour = (int)$quiz->getTime()->format('H');
  792.             // $minute = (int)$quiz->getTime()->format('i');
  793.             // $second = (int)$quiz->getTime()->format('s');
  794.             // $curentDate = clone (new DateTime());
  795.             // $endAt = $curentDate->add(new DateInterval('PT'.$hour.'H'.$minute.'M'.$second.'S'));
  796.             // $quiz->setAutomaticEndAt($endAt);
  797.             try {
  798.                 if ($form->has('saveAndSentToReview') && $form->get('saveAndSentToReview')->isClicked()) {
  799.                     $this->quizWorkflow->apply($quiz'to_review');
  800.                     $this->addFlash('quiz_added_and_sent_to_review''Quiz créé et envoyé à validation');
  801.                 } elseif ($form->has('saveAndPublished') && $form->get('saveAndPublished')->isClicked()) {
  802.                     $this->quizWorkflow->apply($quiz'publish');
  803.                     $quiz->setIsPublished(true);
  804.                     $this->addFlash('quiz_added_and_published''Quiz créé et publié');
  805.                 } else {
  806.                     $message 'Quiz crée';
  807.                     if ($quiz->isIsPublished()) $message .= ' et publié';
  808.                     $this->addFlash('quiz_added'$message);
  809.                 }
  810.                 $quizRepository->add($quiztrue);
  811.                 $modules $quiz->getModules();
  812.                 foreach ($modules as $module) {
  813.                     $moduleItem = new ModuleItem();
  814.                     $moduleItem->setModule($module);
  815.                     $moduleItem->setQuiz($quiz);
  816.                     $moduleItem->setType('quiz');
  817.                     $moduleItemRepository->add($moduleItemtrue);
  818.                 }
  819.             } catch (LogicException $exception) {
  820.                 $this->addFlash('quiz_no_sent_to_review'"Erreur survenue lors de l'envoie du quiz à la validation. Veuillez contacter l'administrateur");
  821.             }
  822.             return $this->redirectToRoute('app_front_quiz_page', ['profil' => $profil], Response::HTTP_SEE_OTHER);
  823.         }
  824.         return $this->renderForm('front/pages/dashboard/quiz/create_quiz.html.twig', [
  825.             'quiz' => $quiz,
  826.             'form' => $form,
  827.             'profil' => $profil,
  828.         ]);
  829.     }
  830.     /**
  831.      * @Route("/{profil}/cours", name="app_front_course_page")
  832.      */
  833.     public function coursePage(Request $requestCourseRepository $courseRepositoryString $profil null): Response
  834.     {
  835.         // $userRole = $this->getUserActivedRole($profil);
  836.         // if ($userRole === null) throw $this->createNotFoundException("La page demandée n'existe pas");
  837.         $session $request->getSession();
  838.         if ($request->query->get('page') === null$session->remove('course_search_key');
  839.         $course = new Course();
  840.         $page = (int)$request->query->get('page'1);
  841.         if ($page <= 0) throw $this->createNotFoundException("La page demandée n'existe pas");
  842.         // Search form
  843.         $searchKey $session->has('course_search_key') ? $session->get('course_search_key') : null;
  844.         $form $this->createFormBuilder()
  845.         ->add('searchKey'TextType::class, [
  846.             'label' => 'Rechercher: ',
  847.             'label_attr' => ['class' => 'text-grey'],
  848.             'attr' => [
  849.                 'style' => 'border: 1px solid transparent !important'
  850.             ],
  851.             'required' => false,
  852.             'data' => $session->has('course_search_key') ? $session->get('course_search_key') : ''
  853.         ])
  854.         ->getForm();
  855.         
  856.         $form->handleRequest($request);
  857.         if ($form->isSubmitted() && $form->isValid()) {
  858.             $searchKey $form->get('searchKey')->getData();
  859.             $session->remove('course_search_key');
  860.             if ($searchKey !== null$session->set('course_search_key'$searchKey);
  861.         }
  862.         $courses $courseRepository->findCourses($this->getUser(), $pageConstants::PAGINATION_LIMIT$searchKey);
  863.         $totalCourse $courseRepository->findCourses($this->getUser(), nullnull$searchKey);
  864.         // $totalCourse = $courseRepository->getTotalCourse($this->getUser());
  865.         return $this->renderForm('front/pages/dashboard/courses/courses.html.twig', [
  866.             'course' => $course,
  867.             'courses' => $courses,
  868.             'totalCourse' => $totalCourse,
  869.             'limit' => Constants::PAGINATION_LIMIT,
  870.             'page' => $page,
  871.             'form' => $form
  872.         ]);
  873.     }
  874.     /**
  875.      * @Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_INTEGRATOR') or is_granted('ROLE_COACH')")
  876.      * 
  877.      * @Route("/{profil}/cours/creer-un-cours", name="app_front_create_course_page")
  878.      */
  879.     public function createCourse(Request $requestCourseRepository $courseRepositoryModuleItemRepository $moduleItemRepositoryString $profil): Response
  880.     {
  881.         // if (!$this->isGranted('ROLE_ADMIN') && !$this->isGranted('ROLE_INTEGRATOR') && !$this->isGranted('ROLE_COACH')) throw $this->createNotFoundException("La page demandée n'existe pas");
  882.         $course = new Course();
  883.         $form $this->createForm(CourseType::class, $course);
  884.         $form->handleRequest($request);
  885.         if ($form->isSubmitted() && $form->isValid()) {
  886.             try {
  887.                 if ($form->has('saveAndSentToReview') && $form->get('saveAndSentToReview')->isClicked()) {
  888.                     $this->courseWorkflow->apply($course'to_review');
  889.                     $this->addFlash('course_added_and_sent_to_review''Cours créé et envoyé à validation');
  890.                 } elseif ($form->has('saveAndPublished') && $form->get('saveAndPublished')->isClicked()) {
  891.                     $this->courseWorkflow->apply($course'publish');
  892.                     $course->setIsPublished(true);
  893.                     $this->addFlash('course_added_and_published''Cours créé et publié');
  894.                 } else {
  895.                     $message 'Cours crée';
  896.                     if ($course->isIsPublished()) $message .= ' et publié';
  897.                     $this->addFlash('course_added'$message);
  898.                 }
  899.                 $courseRepository->add($coursetrue);
  900.                 $modules $course->getModules();
  901.                 foreach ($modules as $module) {
  902.                     $moduleItem = new ModuleItem();
  903.                     $moduleItem->setModule($module);
  904.                     $moduleItem->setCourse($course);
  905.                     $moduleItem->setType('course');
  906.                     $moduleItemRepository->add($moduleItemtrue);
  907.                 }
  908.             } catch (LogicException $exception) {
  909.                 $this->addFlash('course_no_sent_to_review'"Erreur survenue lors de l'envoie du cours à la validation. Veuillez contacter l'administrateur");
  910.             }
  911.             return $this->redirectToRoute('app_front_course_page', ['profil' => $profil], Response::HTTP_SEE_OTHER);
  912.         }
  913.         return $this->renderForm('front/pages/dashboard/courses/create_course.html.twig', [
  914.             'course' => $course,
  915.             'form' => $form,
  916.             'profil' => $profil,
  917.         ]);
  918.     }
  919.     /**
  920.      * @Route("/{profil}/lives", name="app_dashboard_live_page")
  921.      */
  922.     public function livePage(Request $requestLiveRepository $liveRepositoryString $profil null): Response
  923.     {
  924.         $session $request->getSession();
  925.         if ($request->query->get('page') === null$session->remove('live_search_key');
  926.         $userRole $this->getUserActivedRole($profil);
  927.         if ($userRole === null) throw $this->createNotFoundException("La page demandée n'existe pas");
  928.         $live = new Live();
  929.         $page = (int)$request->query->get('page'1);
  930.         if ($page <= 0) throw $this->createNotFoundException("La page demandée n'existe pas");
  931.         // Search form
  932.         $searchKey $session->has('live_search_key') ? $session->get('live_search_key') : null;
  933.         $form $this->createFormBuilder()
  934.         ->add('searchKey'TextType::class, [
  935.             'label' => 'Rechercher: ',
  936.             'label_attr' => ['class' => 'text-grey'],
  937.             'attr' => [
  938.                 'style' => 'border: 1px solid transparent !important'
  939.             ],
  940.             'required' => false,
  941.             'data' => $session->has('live_search_key') ? $session->get('live_search_key') : ''
  942.         ])
  943.         ->getForm();
  944.         
  945.         $form->handleRequest($request);
  946.         if ($form->isSubmitted() && $form->isValid()) {
  947.             $searchKey $form->get('searchKey')->getData();
  948.             $session->remove('live_search_key');
  949.             if ($searchKey !== null$session->set('live_search_key'$searchKey);
  950.         }
  951.         $lives $liveRepository->findLives($this->getUser(), $pageConstants::PAGINATION_LIMIT$searchKey);
  952.         $totalLive $liveRepository->findLives($this->getUser(), nullnull$searchKey);
  953.         // $totalLive = $liveRepository->getTotalLive($this->getUser(), $userRole);
  954.         foreach($lives as $live) {
  955.             $records $live->getLiveRecords();
  956.             foreach($records as $record) {
  957.                 if(!$record->isIsAlreadyDownloaded()) {
  958.                     $live->removeLiveRecord($record);
  959.                 }
  960.             }
  961.         }
  962.         return $this->renderForm('front/pages/dashboard/lives/lives.html.twig', [
  963.             'live' => $live,
  964.             'lives' => $lives,
  965.             'totalLive' => $totalLive,
  966.             'limit' => Constants::PAGINATION_LIMIT,
  967.             'page' => $page,
  968.             'form' => $form
  969.         ]);
  970.     }
  971.     /**
  972.      * @Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_INTEGRATOR') or is_granted('ROLE_COACH')")
  973.      * 
  974.      * @Route("/{profil}/lives/creer-un-live", name="app_front_create_live_page")
  975.      */
  976.     public function createLive(Request $requestLiveRepository $liveRepositoryModuleItemRepository $moduleItemRepositoryString $profil): Response
  977.     {
  978.         // if (!$this->isGranted('ROLE_ADMIN') && !$this->isGranted('ROLE_INTEGRATOR') && !$this->isGranted('ROLE_COACH')) throw $this->createNotFoundException("La page demandée n'existe pas");
  979.         
  980.         $live = new Live();
  981.         $form $this->createForm(LiveType::class, $live);
  982.         $form->handleRequest($request);
  983.         if ($form->isSubmitted() && $form->isValid()) {
  984.             try {
  985.                 if ($form->has('saveAndSentToReview') && $form->get('saveAndSentToReview')->isClicked()) {
  986.                     $this->liveWorkflow->apply($live'to_review');
  987.                     $this->addFlash('live_added_and_sent_to_review''Live créé et envoyé à validation');
  988.                 }  elseif ($form->has('saveAndPublished') && $form->get('saveAndPublished')->isClicked()) {
  989.                     $this->liveWorkflow->apply($live'publish');
  990.                     $live->setIsPublished(true);
  991.                     $this->addFlash('live_added_and_published''Live créé et publié');
  992.                 } else {
  993.                     $message 'Live crée';
  994.                     if ($live->isIsPublished()) $message .= ' et publié';
  995.                     $this->addFlash('live_added'$message);
  996.                 }
  997.     
  998.                 if ($live->getTime() !== null) {
  999.                     $hour = (int)$live->getTime()->format('H');
  1000.                     $minute = (int)$live->getTime()->format('i');
  1001.                     $second = (int)$live->getTime()->format('s');
  1002.         
  1003.                     $startDate = clone $live->getStartAt();
  1004.         
  1005.                     $endAt $startDate->add(new DateInterval('PT'.$hour.'H'.$minute.'M'.$second.'S'));
  1006.                     $live->setEndAt($endAt);
  1007.                 }
  1008.     
  1009.                 $liveRepository->add($livetrue);
  1010.     
  1011.                 $modules $live->getModules();
  1012.                 foreach ($modules as $module) {
  1013.                     $moduleItem = new ModuleItem();
  1014.                     $moduleItem->setModule($module);
  1015.                     $moduleItem->setLive($live);
  1016.                     $moduleItem->setType('live');
  1017.     
  1018.                     $moduleItemRepository->add($moduleItemtrue);
  1019.                 }
  1020.                 // /** @var DateTime $startAt */
  1021.                 // $startAt = $live->getStartAt();
  1022.                 // if ($startAt !== null && $live->isIsPublished()) {
  1023.                 //     $interval = new DateInterval('PT' . Constants::TIME_BEFORE_LIVE_SESSION_STARTING . 'M');
  1024.                 //     $notificationDateBeforeLiveStarting = clone $startAt;
  1025.                 //     $notificationDateBeforeLiveStarting->sub($interval);
  1026.                 //     $minutes = $notificationDateBeforeLiveStarting->format('i');
  1027.                 //     $hour = $notificationDateBeforeLiveStarting->format('H');
  1028.                 //     $atExpression = sprintf("%s:%s", $hour, $minutes);
  1029.                 //     // /** @var User $user The user object */
  1030.                 //     // $schedule = new \Zenstruck\ScheduleBundle\Schedule();
  1031.                 //     // $schedule->addCommand('app:live-session-starting:notification '.$live->getId())
  1032.                 //     //     ->description('Send notification to live ('.$live->getTitle().') participants')
  1033.                 //     //     ->at($atExpression)
  1034.                 //     // ;
  1035.                 //     // /** @var \Zenstruck\ScheduleBundle\Schedule $this->schedule */
  1036.                 //     // $this->schedule->addCommand('app:test-mail:sending')
  1037.                 //     //     ->description('Send mail test 2.')
  1038.                 //     //     ->everyMinute()
  1039.                 //     // ;
  1040.                 // }
  1041.             } catch (LogicException $exception) {
  1042.                 $this->addFlash('live_no_sent_to_review'"Erreur survenue lors de l'envoie du live à la validation. Veuillez contacter l'administrateur");
  1043.             }
  1044.             
  1045.             return $this->redirectToRoute('app_dashboard_live_page', ['profil' => $profil], Response::HTTP_SEE_OTHER);
  1046.             // return $this->redirectToRoute('app_front_lives_page', [], Response::HTTP_SEE_OTHER);
  1047.         }
  1048.         return $this->renderForm('front/pages/dashboard/lives/create_live.html.twig', [
  1049.             'live' => $live,
  1050.             'form' => $form,
  1051.             'profil' => $profil
  1052.         ]);
  1053.     }
  1054.     /**
  1055.      * @Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_INTEGRATOR')")
  1056.      * 
  1057.      * @Route("/{profil}/parametre/citations", name="app_front_quote_page")
  1058.      */
  1059.     public function quotePage(Request $requestQuoteRepository $quoteRepositoryString $profil): Response
  1060.     {
  1061.         $quote = new Quote();
  1062.         $page = (int)$request->query->get('page'1);
  1063.         if ($page <= 0) throw $this->createNotFoundException("La page demandée n'existe pas");
  1064.         $quotes $quoteRepository->findPaginateQuote($pageConstants::PAGINATION_LIMIT);
  1065.         $totalQuote $quoteRepository->getTotalQuote();
  1066.         return $this->renderForm('front/pages/dashboard/quotes/quotes.html.twig', [
  1067.             'quote' => $quote,
  1068.             'quotes' => $quotes,
  1069.             'totalQuote' => $totalQuote,
  1070.             'limit' => Constants::PAGINATION_LIMIT,
  1071.             'page' => $page,
  1072.         ]);
  1073.     }
  1074.     /**
  1075.      * @Security("is_granted('ROLE_ADMIN')")
  1076.      * 
  1077.      * @Route("/{profil}/parametre/creer-une-citation", name="app_front_create_quote_page")
  1078.      */
  1079.     public function createQuote(Request $requestQuoteRepository $quoteRepositoryString $profil): Response
  1080.     {
  1081.         if (!$this->isGranted('ROLE_ADMIN') && !$this->isGranted('ROLE_INTEGRATOR')) throw $this->createNotFoundException("La page demandée n'existe pas");
  1082.         $quote = new Quote();
  1083.         $form $this->createForm(QuoteType::class, $quote);
  1084.         $form->handleRequest($request);
  1085.         if ($form->isSubmitted() && $form->isValid()) {
  1086.             $quoteRepository->add($quotetrue);
  1087.             return $this->redirectToRoute('app_front_quote_page', ['profil' => $profil], Response::HTTP_SEE_OTHER);
  1088.         }
  1089.         return $this->renderForm('front/pages/dashboard/quotes/create_quote.html.twig', [
  1090.             'quote' => $quote,
  1091.             'form' => $form,
  1092.         ]);
  1093.     }
  1094.     /**
  1095.      * @Security("is_granted('ROLE_ADMIN')")
  1096.      * 
  1097.      * @Route("/{profil}/parametre/ajouter-un-mot-du-directeur", name="app_front_create_director_page")
  1098.      */
  1099.     public function createDirectorWord(Request $requestDirectorRepository $directorRepositoryString $profil): Response
  1100.     {
  1101.         // if (!$this->isGranted('ROLE_ADMIN') && !$this->isGranted('ROLE_INTEGRATOR')) throw $this->createNotFoundException("La page demandée n'existe pas");
  1102.         $director = new Director();
  1103.         $form $this->createForm(DirectorType::class, $director);
  1104.         $form->handleRequest($request);
  1105.         if ($form->isSubmitted() && $form->isValid()) {
  1106.             $directorRepository->add($directortrue);
  1107.             return $this->redirectToRoute('app_front_director_page', ['profil' => $profil], Response::HTTP_SEE_OTHER);
  1108.         }
  1109.         return $this->renderForm('front/pages/dashboard/directors/create_director.html.twig', [
  1110.             'director' => $director,
  1111.             'form' => $form,
  1112.             'profil' => $profil
  1113.         ]);
  1114.     }
  1115.     /**
  1116.      * @Security("is_granted('ROLE_ADMIN')")
  1117.      * 
  1118.      * @Route("/{profil}/parametre/mots-du-directeur", name="app_front_director_page")
  1119.      */
  1120.     public function directorPage(Request $requestDirectorRepository $directorRepositoryString $profil): Response
  1121.     {
  1122.         $director = new Director();
  1123.         $page = (int)$request->query->get('page'1);
  1124.         if ($page <= 0) throw $this->createNotFoundException("La page demandée n'existe pas");
  1125.         $directors $directorRepository->findPaginateDirector($pageConstants::PAGINATION_LIMIT);
  1126.         $totalDirector $directorRepository->getTotalDirector();
  1127.         return $this->renderForm('front/pages/dashboard/directors/directors.html.twig', [
  1128.             'director' => $director,
  1129.             'directors' => $directors,
  1130.             'totalDirector' => $totalDirector,
  1131.             'limit' => Constants::PAGINATION_LIMIT,
  1132.             'page' => $page,
  1133.             'profil' => $profil
  1134.         ]);
  1135.     }
  1136.     /**
  1137.      * @Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_INTEGRATOR')")
  1138.      * 
  1139.      * @Route("/{profil}/parametre/module-vedettes", name="app_front_featured_module_page")
  1140.      */
  1141.     public function featured(Request $requestFeaturedModuleRepository $featuredModuleRepositoryString $profil): Response
  1142.     {
  1143.         $featuredModules $featuredModuleRepository->findBy([], ['id' => 'DESC'], 10);
  1144.         $featuredModule = (empty($featuredModules)) ? new FeaturedModule() : $featuredModules[0];
  1145.         $form $this->createForm(FeaturedModuleType::class, $featuredModule);
  1146.         $form->handleRequest($request);
  1147.         if ($form->isSubmitted() && $form->isValid()) {
  1148.             $featuredModuleRepository->add($featuredModuletrue);
  1149.             return $this->redirectToRoute('app_front_featured_module_page', ['profil' => $profil], Response::HTTP_SEE_OTHER);
  1150.         }
  1151.         return $this->renderForm('front/pages/dashboard/modules/featured_module.html.twig', [
  1152.             'featured_module' => $featuredModule,
  1153.             'form' => $form,
  1154.         ]);
  1155.     }
  1156.     /**
  1157.      * @Route("/job/offices/{id}", name="job_offices")
  1158.      * @param Request $request
  1159.      * @param Job $job
  1160.      * @return JsonResponse
  1161.      */
  1162.     public function jobOffice(Request $requestJob $job)
  1163.     {
  1164.         $output = [];
  1165.         if ($job !== null) {
  1166.             $offices $job->getOffices();
  1167.             foreach ($offices as $key => $office) {
  1168.                 $output[] = [
  1169.                     'id' => $office->getId(),
  1170.                     'name' => $office->getName()
  1171.                 ];
  1172.             }
  1173.         }
  1174.         
  1175.         return $this->json($output);
  1176.     }
  1177.     /**
  1178.      * @Route("/job/offices", name="jobs_offices")
  1179.      * @param Request $request
  1180.      * @return JsonResponse
  1181.      */
  1182.     public function jobsOffice(Request $requestOfficeRepository $officeRepository)
  1183.     {
  1184.         $output = [];
  1185.         $ids $request->get('ids');
  1186.         if ($ids !== null && !empty($ids)) {
  1187.             $offices $officeRepository->findOffices($ids);
  1188.             foreach ($offices as $key => $office) {
  1189.                 $output[] = [
  1190.                     'id' => $office->getId(),
  1191.                     'text' => $office->getName()
  1192.                 ];
  1193.             }
  1194.         }
  1195.         
  1196.         return $this->json($output);
  1197.     }
  1198.     public function getUserActivedRole(String $profil null): String
  1199.     {
  1200.         $userRoles $this->skipDefaultRole($this->getUser()->getRoles());
  1201.         if ($profil === null)  {
  1202.             $userRole = (!empty($userRoles)) ? $userRoles[0] : null;
  1203.         } else $userRole $this->getRoleByProfil($profil);
  1204.         return $userRole;
  1205.     }
  1206.     /**
  1207.      * @Route("/{profil}", name="app_front_dashboard_kpi_page")
  1208.      */
  1209.     public function kpiPage(Request $requestUserRepository $userRepositoryProgramRepository $programRepositoryModuleRepository $moduleRepositoryPaginatorInterface $paginatorString $profil): Response
  1210.     {
  1211.         $page = (int)$request->query->get('page'1);
  1212.         if ($page <= 0) throw $this->createNotFoundException("La page demandée n'existe pas");
  1213.         if ($profil === 'apprenant') return $this->redirectToRoute('app_front_learner_dashboard_page');
  1214.         $user $this->getUser();
  1215.         $programs $programRepository->findPrograms($user);
  1216.         $modules $moduleRepository->findModules($usertrue);
  1217.         $program null;
  1218.         $module null;
  1219.         $session $request->getSession();
  1220.         // Filter form
  1221.         $form $this->createFormBuilder()
  1222.         ->add('program'EntityType::class, [
  1223.             'class' => Program::class,
  1224.             'label' => false,
  1225.             'choice_label' => 'label',
  1226.             'attr' => ['class' => 'form-select select-2-tags'],
  1227.             'placeholder' => 'Choisir un programme',
  1228.             'required' => false,
  1229.             'choices' => $programs,
  1230.         ])
  1231.         ->add('module'EntityType::class, [
  1232.             'class' => Module::class,
  1233.             'label' => false,
  1234.             'choice_label' => 'name',
  1235.             'attr' => ['class' => 'form-select select-2-tags'],
  1236.             'placeholder' => 'Choisir un module',
  1237.             'required' => false,
  1238.             'choices' => $modules
  1239.         ])
  1240.         ->add('filter'SubmitType::class, [
  1241.             'label' => 'Filtrer',
  1242.             'attr' => ['class' => 'custom-dash-select shadow-sm bg-white']
  1243.         ])
  1244.         ->getForm();
  1245.         
  1246.         $form->handleRequest($request);
  1247.         if ($form->isSubmitted() && $form->isValid()) {
  1248.             $program $form->get('program')->getData();
  1249.             $module $form->get('module')->getData();
  1250.             // if ($programData !== null) $session->set('__program', $programData->getId());
  1251.             // if ($moduleData !== null) $session->set('__module', $moduleData->getId());
  1252.         }
  1253.         // dump($this->getCompletionRate($program, $module, null)); die;
  1254.         $session->set('__profile'$profil);
  1255.         $currentRole $this->helperService->getUserCurrentRole();
  1256.         
  1257.         // $learners = $userRepository->findLearners($page, Constants::PAGINATION_LIMIT, $this->getUser(), $current_role);
  1258.         // $learnerWithCertificateCount = $userRepository->getLearnerWithCertificateCount();
  1259.         // $learnerCount = $this->getLearnerCount();
  1260.         // $learnerCount = count($userRepository->findLearners(null, null, $this->getUser(), $currentRole));
  1261.         //$em = $this->getDoctrine()->getRepository('App\Entity\UserModuleParticipation');
  1262.         //dd($em->getUserModuleItemCount());
  1263.         $learners $userRepository->findLearnersQuery($this->getUser(), $currentRole);
  1264.         // $learnerCount = $userRepository->getLearnersCount($this->getUser(), $currentRole);
  1265.         $pagination $paginator->paginate(
  1266.             $learners,
  1267.             $page,
  1268.             Constants::PAGINATION_LIMIT
  1269.         );
  1270.         return $this->render('front/pages/dashboard/kpi/index.html.twig', [
  1271.             // 'learners' => $learners,
  1272.             // 'total_learner' => $learnerCount,
  1273.             'limit' => Constants::PAGINATION_LIMIT,
  1274.             'page' => $page,
  1275.             'program' => $program,
  1276.             'module' => $module,
  1277.             //'user' => ($profil === 'integrateur' || $profil === 'administrateur') ? null : $this->getUser(),
  1278.             'user' => $this->getUser(),
  1279.             'programs' => $programs,
  1280.             'modules' => $modules,
  1281.             'form' => $form->createView(),
  1282.             'current_role' => $currentRole,
  1283.             'learners' => $pagination,
  1284.             // 'success_rate' => ($learnerWithCertificateCount / $learnerCount) * 100,
  1285.         ]);
  1286.     }
  1287.     /**
  1288.      * @Security("is_granted('ROLE_ADMIN')")
  1289.      * 
  1290.      * @Route("/{profil}/parametre/creer-un-partenaire", name="app_front_create_partenaire_page")
  1291.      */
  1292.     public function createPartenaire(Request $requestPartenaireRepository $partenaireRepositoryString $profil): Response
  1293.     {
  1294.         // if (!$this->isGranted('ROLE_ADMIN') && !$this->isGranted('ROLE_INTEGRATOR')) throw $this->createNotFoundException("La page demandée n'existe pas");
  1295.         $partenaire = new Partenaire();
  1296.         $form $this->createForm(PartenaireType::class, $partenaire);
  1297.         $form->handleRequest($request);
  1298.         if ($form->isSubmitted() && $form->isValid()) {
  1299.             $partenaireRepository->add($partenairetrue);
  1300.             return $this->redirectToRoute('app_dashboard_partner_page', ['profil' => $profil], Response::HTTP_SEE_OTHER);
  1301.         }
  1302.         return $this->renderForm('front/pages/dashboard/partenaires/create_partenaire.html.twig', [
  1303.             'partenaire' => $partenaire,
  1304.             'form' => $form,
  1305.             'profil' => $profil
  1306.         ]);
  1307.     }
  1308.     /**
  1309.      * @Security("is_granted('ROLE_ADMIN')")
  1310.      * 
  1311.      * @Route("/{profil}/parametre/partenaires", name="app_dashboard_partner_page")
  1312.      */
  1313.     public function partenairePage(Request $requestPartenaireRepository $partenaireRepositoryString $profil): Response
  1314.     {
  1315.         $partenaire = new Partenaire();
  1316.         $page = (int)$request->query->get('page'1);
  1317.         if ($page <= 0) throw $this->createNotFoundException("La page demandée n'existe pas");
  1318.         $partenaires $partenaireRepository->findPaginatePartenaire($pageConstants::PAGINATION_LIMIT);
  1319.         $totalPartenaire $partenaireRepository->getTotalPartenaire();
  1320.         return $this->renderForm('front/pages/dashboard/partenaires/partenaires.html.twig', [
  1321.             'partenaire' => $partenaire,
  1322.             'partenaires' => $partenaires,
  1323.             'totalPartenaire' => $totalPartenaire,
  1324.             'limit' => Constants::PAGINATION_LIMIT,
  1325.             'page' => $page,
  1326.             'profil' => $profil
  1327.         ]);
  1328.     }
  1329.     /**
  1330.      * @Route("/notification/as-read", name="notification_as_read")
  1331.      * @param Request $request
  1332.      * @return JsonResponse
  1333.      */
  1334.     public function notificationStatus(NotificationRepository $notificationRepositoryNotificationReceiverRepository $notificationReceiverRepository)
  1335.     {
  1336.         $notifications $notificationRepository->findUnreadNotifications($this->getUser());
  1337.         foreach ($notifications as $notification) {
  1338.             $notification->setIsRead(true);
  1339.             $notificationRepository->add($notificationtrue);
  1340.             $notificationReceivers $notification->getNotificationReceivers();
  1341.             foreach ($notificationReceivers as $notificationReceiver) {
  1342.                 $notificationReceiver->setIsRead(true);
  1343.                 $notificationReceiverRepository->add($notificationReceivertrue);
  1344.             }
  1345.         }
  1346.         
  1347.         return $this->json(['OK']);
  1348.     }
  1349.     /**
  1350.      * @Route("/apprenant/notifications", name="app_get_user_notifications")
  1351.      */
  1352.     public function getNotifications(Request $requestNotificationRepository $notificationRepositorySerializerInterface $serializer): Response
  1353.     {   
  1354.         $notificationPage = (int)$request->query->get('notificationPage'1);
  1355.         $user $this->getUser();
  1356.         // $unreadNotifications = $notificationRepository->findUnreadNotifications($user, $notificationPage, Constants::PAGINATION_LIMIT);
  1357.         $unreadNotificationCount $notificationRepository->getUnreadNotificationCount($user);
  1358.         // $notificationCount = $notificationRepository->findNotificationCount($user);
  1359.         $notifications $notificationRepository->findNotifications($user$notificationPageConstants::PAGINATION_LIMIT);
  1360.         $context = new SerializationContext();
  1361.         $context->setSerializeNull(true);
  1362.         // $output = $serializer->serialize($notifications, 'json', $context);
  1363.         //return $this->json(json_decode($output, true));
  1364.         return $this->json(['unreadNotificationCount' => $unreadNotificationCount'html' => $this->render('front/layouts/partials/notifications-response.html.twig', ['notifications' => $notifications])->getContent()]);
  1365.         // return $this->renderForm('front/layouts/partials/notifications-response.html.twig', ['notifications' => $notification]);
  1366.     }
  1367.     /**
  1368.      * @Route("/apprenant/notifications/redirect/{id}", name="app_redirect_user_notifications")
  1369.      */
  1370.     public function redirectNotification(Request $requestNotificationEntity $notificationNotificationRepository $notificationRepositorySubjectRepository $subjectRepositoryProgramRepository $programRepositoryModuleRepository $moduleRepositoryCommentRepository $commentRepository): Response
  1371.     {   
  1372.         if($notification->getObjectType() == 'program') {
  1373.             return $this->redirectToRoute('app_front_program_module', ['id' => $notification->getObjectId()]);
  1374.         } else if($notification->getObjectType() == 'subject') {
  1375.             $subject $subjectRepository->find($notification->getObjectId());
  1376.             if($subject != null) {
  1377.                 return $this->redirectToRoute('app_front_forum_page', ['module_slug' => $subject->getModule()->getSlug(), 'subject_slug' => $subject->getSlug()]);
  1378.             }
  1379.             return $this->redirectToRoute('app_front_forum_charter_page');
  1380.         } else if($notification->getObjectType() == 'module') {
  1381.             $module $moduleRepository->find($notification->getObjectId());
  1382.             return $this->redirectToRoute('app_front_library_module_details_page', ['slug' => $module->getSlug()]);
  1383.         } else if($notification->getObjectType() == 'comment') {
  1384.             $comment $commentRepository->find($notification->getObjectId());
  1385.             if($comment != null) {
  1386.                 $subject $comment->getSubject();
  1387.                 $url $this->generateUrl('app_front_forum_page', ['module_slug' => $subject->getModule()->getSlug(), 'subject_slug' => $subject->getSlug()]);
  1388.                 if($notification->getComment()) {
  1389.                     $url .= '#comment-ref_'.$notification->getComment()->getId();
  1390.                 }
  1391.                 return $this->redirect($url);
  1392.             }
  1393.         } else if($notification->getObjectType() == 'live') {
  1394.             $routeName 'app_front_live_meet_page';
  1395.             $parameters = ['id' => $notification->getObjectId()];
  1396.             if ($notification->getModule() !== null) {
  1397.                 $module $notification->getModule();
  1398.                 $routeName 'app_front_live_module_meet_page';
  1399.                 $parameters['module_slug'] = $module->getSlug();
  1400.             }
  1401.             return $this->redirectToRoute($routeName$parameters);
  1402.         } else if($notification->getObjectType() == 'quiz') {
  1403.             if ($notification->getModule() !== null) {
  1404.                 $module $notification->getModule();
  1405.                 return $this->redirectToRoute('app_front_library_module_details_page', ['slug' => $module->getSlug()]);
  1406.             }
  1407.         } else if($notification->getObjectType() == 'quote') {
  1408.             return $this->redirectToRoute('app_front_homepage');
  1409.         }
  1410.         return $this->redirectToRoute('app_front_learner_dashboard_page');
  1411.     }
  1412.     /**
  1413.      * @Route("/v2", name="app_front_dashboard_v2_page")
  1414.      */
  1415.     public function new_dash(): Response
  1416.     {
  1417.         return $this->render('front/pages/dashboard/new_dash.html.twig', [
  1418.             'user' => $this->getUser()
  1419.         ]);
  1420.     }
  1421.     /**
  1422.      * @Route("/apprenant/historique-notifications", name="app_front_dashboard_notification_page")
  1423.      */
  1424.     public function notification(NotificationRepository $notificationRepository): Response
  1425.     {
  1426.         $unreadNotificationCount $notificationRepository->getUnreadNotificationCount($this->getUser());
  1427.         return $this->render('front/pages/dashboard/notification.html.twig', [
  1428.             'unreadNotificationCount' => $unreadNotificationCount
  1429.         ]);
  1430.     }
  1431.     /**
  1432.      * @Route("/{profil}/badges", name="app_front_dashboard_badge_block")
  1433.      */
  1434.     public function badge(ModuleRepository $moduleRepository): Response
  1435.     {
  1436.         $terminatedModules $moduleRepository->findTerminatedModules($this->getUser());
  1437.         return $this->render('front/pages/dashboard/components/badge-block.html.twig', [
  1438.             'terminated_modules' => $terminatedModules,
  1439.         ]);
  1440.     }
  1441. }