src/Controller/DefaultController.php line 175

  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Actualite;
  4. use App\Entity\Chercheur;
  5. use App\Entity\DomaineScientifique;
  6. use App\Entity\Etablissement;
  7. use App\Entity\Membre;
  8. use App\Entity\Projet;
  9. use App\Entity\Publication;
  10. use App\Entity\StructureRecherche;
  11. use App\Repository\StructureRechercheRepository;
  12. use Doctrine\Persistence\ManagerRegistry;
  13. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  14. use Symfony\Component\HttpFoundation\Request;
  15. use Symfony\Component\HttpFoundation\Response;
  16. use Symfony\Component\Routing\Annotation\Route;
  17. use DateTime;
  18. class DefaultController extends AbstractController
  19. {
  20.     #[Route('/'name'app_home')]
  21.     public function index(ManagerRegistry $doctrine): Response
  22.     {
  23.         $dateAuj = new DateTime();
  24.         $projets $doctrine->getRepository(Projet::class)->findProjetActive($dateAuj);
  25.         // Récupération des actualités triées
  26.         $actualites $doctrine->getRepository(Actualite::class)->findActualiteAsc($dateAuj);
  27.        // dump($actualites,$projets);die;
  28.         $nbrProjet $doctrine->getRepository(Projet::class)->countProjet();
  29.         $nbrChercheurs count($doctrine->getRepository(Chercheur::class)->findAll());
  30.         $nbrPublications $doctrine->getRepository(Publication::class)->countPublication();
  31.         $nbrStructureRecherche $doctrine->getRepository(StructureRecherche::class)->countStructureRecherche();
  32.         return $this->render('default/index.html.twig', [
  33.             'controller_name' => 'DefaultController',
  34.             'projets'=>$projets,
  35.             'actualites'=>$actualites,
  36.             'nbrProjet'=>$nbrProjet[0] ? $nbrProjet[0]['nbr'] : 0,
  37.             'nbrChercheurs'=>$nbrChercheurs,
  38.             'nbrPublications'=>$nbrPublications[0] ? $nbrPublications[0]['nbr'] : 0,
  39.             'nbrStructureRecherche'=>$nbrStructureRecherche[0] ? $nbrStructureRecherche[0]['nbr'] : 0,
  40.         ]);
  41.     }
  42.     #[Route('/list/laboratoire'name'app_laboratoire')]
  43.     public function listLabo(ManagerRegistry $doctrine ,Request $request,StructureRechercheRepository $structureLaboRepository ): Response
  44.     {
  45.         //$structuresLabo = $doctrine->getRepository(StructureRecherche::class)->findBy(['type' => 2 ,'etat'=>1]);
  46.         $structuresLabo $doctrine->getRepository(StructureRecherche::class)->findBy(['etat'=>1]);
  47.         $nbrChercheursInscrit $doctrine->getRepository(Chercheur::class)->countChercheursInscrit();
  48.         $nbrStructureRechercheUnite $doctrine->getRepository(StructureRecherche::class)->countStructureRechercheUnite();
  49.         $nbrStructureRechercheLabo $doctrine->getRepository(StructureRecherche::class)->countStructureRechercheLabo();
  50.         $nbrProjet $doctrine->getRepository(Projet::class)->countProjet(); 
  51.      
  52.         // Récupérez les établissements et les domaines pour les filtres
  53.         $etablissements $doctrine->getRepository(Etablissement::class)->findAll();
  54.         $domaines $doctrine->getRepository(DomaineScientifique::class)->findAll();
  55.         return $this->render('fronts/list_laboratoires.html.twig', [
  56.             'structureLabo' => $structuresLabo,
  57.             'etablissements' => $etablissements,
  58.             'domaines' => $domaines,
  59.             'nbrChercheursInscrit'=>$nbrChercheursInscrit[0]['nbr'],
  60.             'nbrStructureRechercheUnite'=>$nbrStructureRechercheUnite[0]['nbr'],
  61.             'nbrStructureRechercheLabo'=>$nbrStructureRechercheLabo[0]['nbr'],
  62.             'nbrProjet'=>$nbrProjet[0]['nbr'],
  63.         ]);
  64.     }
  65.       
  66.     #[Route('/{id}/laboratoire'name'app_laboratoire_details')]
  67.     public function detailsLabo(ManagerRegistry $doctrine ,$id ): Response
  68.     {
  69.         $labo $doctrine->getRepository(StructureRecherche::class)->find($id);
  70.         $projetsOfStructure  =$doctrine->getRepository(Projet::class)->findBy(['structure'=>$labo]);
  71.        
  72.        
  73.         $nbrChercheurs $doctrine->getRepository(Chercheur::class)->countChercheursStruc($id);        
  74.         $nbrProjet $doctrine->getRepository(Projet::class)->countProjetStruc($id);
  75.         $nbrPublications $doctrine->getRepository(Publication::class)->countPublicationStruc($id);
  76.         return $this->render('fronts/labo_details.html.twig', [
  77.             'controller_name' => 'DefaultController',
  78.             'labo' =>$labo,
  79.             'projets'=>$projetsOfStructure,
  80.             'nbrPublications'=> $nbrPublications[0]['nbr'],           
  81.             'nbrChercheurs'=>$nbrChercheurs[0]['nbr'],
  82.             'nbrProjet'=>$nbrProjet[0]['nbr'],
  83.         ]);
  84.     }
  85.     #[Route('/list/projets/{idStructure?}'name'app_projets')]
  86.     public function listProjet(ManagerRegistry $doctrine$idStructure null): Response
  87.     {
  88.         if ($idStructure) {
  89.             $structure $doctrine->getRepository(StructureRecherche::class)->find($idStructure);        
  90.             $projets $doctrine->getRepository(Projet::class)->findBy(['etat' => 2'structure' => $structure]);
  91.         } else {
  92.             $structure null;
  93.             $projets $doctrine->getRepository(Projet::class)->findBy(['etat' => 2]);
  94.         }
  95.         
  96.         $structures $doctrine->getRepository(StructureRecherche::class)->findBy(['etat'=>1]);
  97.         return $this->render('fronts/list_projets.html.twig', [
  98.             'controller_name' => 'DefaultController',
  99.             'projets' => $projets,
  100.             'structure'=>$structure ,
  101.             'structures'=>$structures
  102.         ]);
  103.     }
  104.     
  105.     #[Route('/{id}/projet'name'app_projet_details')]
  106.     public function detailsProjet(ManagerRegistry $doctrine ,$id ): Response
  107.     {
  108.         $projet $doctrine->getRepository(Projet::class)->find($id);
  109.        // $chercheursProjet = $doctrine->getRepository(Membre::class)->membreProjets($id);
  110.         $chercheursProjet $doctrine->getRepository(Membre::class)->findBy(['projet'=>$projet]);
  111. //dump($chercheursProjet);die;
  112.         return $this->render('fronts/projet_details.html.twig', [
  113.             'controller_name' => 'DefaultController',
  114.             'projet' =>$projet,
  115.             'chercheursProjet'=>$chercheursProjet
  116.         ]);
  117.     }
  118.     #[Route('/list/chercheurs/{idStructure?}'name'app_chercheurs')]
  119.     public function listChercheurs(ManagerRegistry $doctrine,$idStructure null ): Response
  120.     {
  121.         $nomStructure=null;
  122.         if ($idStructure) {
  123.             $structure $doctrine->getRepository(StructureRecherche::class)->find($idStructure); 
  124.             $nomStructure=$structure->getNomLong();       
  125.             $chercheurs $doctrine->getRepository(Chercheur::class)->findBy(['structure' => $structure],['prenom'=>'ASC']);
  126.         } else {
  127.             $structure null;
  128.             $chercheurs $doctrine->getRepository(Chercheur::class)->findBy([],['prenom'=>'ASC']);
  129.         }
  130.         $structures $doctrine->getRepository(StructureRecherche::class)->findBy(['etat'=>1]);
  131.         $etablissements $doctrine->getRepository(Etablissement::class)->findAll();
  132.         return $this->render('fronts/list_chercheurs.html.twig', [
  133.            // 'controller_name' => 'DefaultController',
  134.             'chercheurs' =>$chercheurs,
  135.             'structures'=>$structures,
  136.             'nomStructure'=>$nomStructure,
  137.             'etablissements'=>$etablissements
  138.         ]);
  139.     }
  140.     #[Route('/{idChercheur}/chercheur/details'name'app_chercheurs_details')]
  141.     public function detailsChercheurs(ManagerRegistry $doctrine ,$idChercheur): Response
  142.     {
  143.         $chercheur $doctrine->getRepository(Chercheur::class)->find($idChercheur);
  144.         return $this->render('fronts/details_chercheur.html.twig', [
  145.            // 'controller_name' => 'DefaultController',
  146.             'chercheur' =>$chercheur
  147.         ]);
  148.     }
  149.     #[Route('/list/publications'name'app_publications')]
  150.     public function listPublications(ManagerRegistry $doctrine ): Response
  151.     {
  152.         $publications $doctrine->getRepository(Publication::class)->findAll();
  153.         $structures $doctrine->getRepository(StructureRecherche::class)->findBy(['etat'=>1]);
  154.         $annees array_unique(array_map(function($pub) {
  155.             return $pub->getAnnee();
  156.         }, $publications));
  157.         sort($annees);
  158.         return $this->render('fronts/list_publications.html.twig', [
  159.             'controller_name' => 'DefaultController',
  160.             'publications' =>$publications,
  161.             'structures'=>$structures,
  162.             'annees'=>$annees
  163.         ]);
  164.     }
  165. }