src/Controller/HomeController.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Doctrine\ORM\EntityManagerInterface;
  8. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  9. use App\Service\ExcelExporter;
  10. use App\Repository\ConsultactiviteRepository// Assurez-vous d'importer le repository
  11. class HomeController extends AbstractController
  12. {
  13.    
  14.     
  15.     /**
  16.      * @Route("/", name="app_home")
  17.      */
  18.     public function index(EntityManagerInterface $entityManager): Response
  19.     {
  20.       
  21.         if ($this->isGranted('ROLE_PARENT')) {
  22.             // Redirection vers la route "app_notification" si l'utilisateur est un parent
  23.             return $this->redirectToRoute('app_notification',[], Response::HTTP_SEE_OTHER);
  24.         }else{
  25.             return $this->redirectToRoute('app_product_back_new', [], Response::HTTP_SEE_OTHER);
  26.         }
  27.     }
  28.     /**
  29.      * @Route("/template-login", name="app_template_login")
  30.      */
  31.     public function templatesLogin(EntityManagerInterface $entityManager): Response
  32.     {
  33.         return $this->render('backView/templates_login.html.twig', [
  34.             
  35.         ]);
  36.     }
  37.     
  38.     
  39.     /**
  40.      * @Route("/template-administration", name="app_template_admin")
  41.      */
  42.     public function templatesAdmin(EntityManagerInterface $entityManager): Response
  43.     {
  44.        
  45.       
  46.         return $this->render('backView/templates_admin_two.html.twig', [
  47.            
  48.         ]);
  49.     }
  50.     /**
  51.      * @Route("/export-excel", name="app_template_export")
  52.      */
  53.     public function exportToExcel(): Response
  54.     {
  55.         // Simuler des donnĂ©es de la table
  56.         $data = [
  57.             ['Data 1''Data 2''Data 3'],
  58.             ['Data 4''Data 5''Data 6'],
  59.         ];
  60.         // Exporter les donnĂ©es vers un fichier Excel
  61.         ExcelExporter::exportTableToExcel($data'exported_data.xlsx');
  62.         return new Response();
  63.     }
  64.     /**
  65.      * @Route("/access-denied", name="app_home_access_denied")
  66.      */
  67.     public function accessDenied(EntityManagerInterface $entityManager): Response
  68.     {
  69.      
  70.         return $this->render('security/error403.html.twig', [
  71.           
  72.         ]);
  73.     }
  74. }