src/Controller/Etudiant/EtudiantController.php line 158

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Etudiant;
  3. use App\Entity\EnseignantSemestre;
  4. use App\Entity\Rapport;
  5. use Doctrine\Persistence\ManagerRegistry;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. use Symfony\Contracts\HttpClient\HttpClientInterface;
  10. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  11. #[Route('/etudiant')]
  12. class EtudiantController extends AbstractController
  13. {
  14.     private $client;
  15.     private $em;
  16.     public function __construct(HttpClientInterface $clientManagerRegistry $em)
  17.     {
  18.         $this->client $client;
  19.         $this->em $em->getManager();
  20.     }
  21.     #[Route('/'name'etudiant_index')]
  22.     public function index(Request $request): Response
  23.     {
  24.         $table null;
  25.         // dd('test');
  26.         if(in_array('ROLE_ENSEIGNANT'$this->getUser()->getRoles())) {
  27.            $sessions $this->em->getRepository(EnseignantSemestre::class)->getEnseignantSemestresByClosedTime($this->getUser());
  28.         //    dd($sessions);
  29.            return $this->render('etudiant/intro.html.twig', [
  30.                'sessions' => $sessions
  31.            ]);
  32.         }
  33.         // $response = $this->client->request('GET', $this->getParameter("api")."/getetablissement");
  34.         // $etablissements = $response->toArray();
  35.         return $this->redirectToRoute("rapport_index");
  36.         // return $this->render('etudiant/index.html.twig', [
  37.         //     'etablissements' => $etablissements,
  38.         //     'table' => $table
  39.         // ]);
  40.     }
  41.     #[Route('/list/{session}'name'etudiant_list')]
  42.     public function rapports(EnseignantSemestre $sessionRequest $request): Response
  43.     {
  44.         $table null;
  45.         // echo ('En cours de maintenance');
  46.         // dd($session);
  47.         $table $this->list($request$session->getSemestre(),$session->getNiveau());
  48.         return $this->render('etudiant/index.html.twig', [
  49.             'table' => $table
  50.         ]);
  51.     }
  52.     
  53.     public function list($request$id,$niveau)
  54.     {
  55.         // dd("test");
  56.         $response $this->client->request('GET'$this->getParameter("api")."/getlistofstagebysemestrebyniveau/$id/$niveau");
  57.         $session $request->getSession();
  58.         $data $response->toArray();
  59.         // echo ('En Cours de maintenance!');
  60.         // dd($data);
  61.         $inscriptions $data['inscriptions'];
  62.         // dd($inscriptions);
  63.         $cycles $data['cycles'];
  64.         $etab $inscriptions[0]['etab'];
  65.         $form $inscriptions[0]['frm'];
  66.         // echo 'En Cours De Maintenance!.. merci de patienté.';
  67.         
  68.         //dd($cycles);
  69.         $stageSimulation $stageClinique $stageSDentaire $stagePharmacy $stagePharmacyHopital $stagePharmacyStaff $stageFmaGlobal $stageFpaGlobal $stageFdaGlobal null;
  70.         
  71.         $data = [];
  72.         foreach ($inscriptions as $key => $inscription) {
  73.             // if($inscription['id'] == "12105" or $inscription['id'] == "12156") {
  74.                 $arrayOfStage = [];
  75.                 foreach ($cycles as $cycle) {
  76.                     $checkifexits $this->em->getRepository(Rapport::class)->findOneBy(['inscription'=>$inscription["id"], 'stage'=> $cycle['stages']]);
  77.                     if(!$checkifexits){
  78.                         array_push($arrayOfStage, [
  79.                             'clinique' => NULL,
  80.                             'simulation' => NULL,
  81.                             'pharmacy' => NULL,
  82.                             'dentaire' => NULL,
  83.                             'staff' => NULL,
  84.                             'hopital' => NULL,
  85.                             'fmaglobal' => NULL,
  86.                             'fdaglobal' => NULL,
  87.                             'fpaglobal' => NULL,
  88.                         ]);
  89.                         continue;
  90.                     }
  91.                     //dd($checkifexits);
  92.                     // $stageClinique = $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "clinique");
  93.                     // $stageSimulation = $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "simulation");
  94.                     // $stagePharmacy = $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "pharmacy");
  95.                     // $stageSDentaire = $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "dentaire");
  96.                     // $stagePharmacyStaff = $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "staff");
  97.                     // $stagePharmacyHopital = $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "hopital");
  98.                     // $stageFdaGlobal = $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "global");
  99.                     // $stageFpaGlobal = $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "global");
  100.                     // $stageFmaGlobal = $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "global");
  101.                     
  102.                     switch ($etab) {
  103.                         case 'FMDA':
  104.                             if (str_contains($form'Résidanat')) {
  105.                                 $stageFdaGlobal $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "global");
  106.                             }else{
  107.                                 $stageSDentaire $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "dentaire");
  108.                                 $stageSimulation $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "simulation");
  109.                                 $stageClinique $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "clinique");
  110.                             }
  111.                             break;
  112.                         case 'FPA':
  113.                             if (str_contains($form'Résidanat')) {
  114.                                 $stageFpaGlobal $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "global");
  115.                             }else{
  116.                                 $stagePharmacyHopital $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "hopital");
  117.                                 $stagePharmacy $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "pharmacy");
  118.                                 $stagePharmacyStaff $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "staff");
  119.                                 $stageSimulation $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "simulation");
  120.                             }
  121.                             break;
  122.                         default:
  123.                             if (str_contains($form'Résidanat')) {
  124.                                 $stageFmaGlobal $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "global");
  125.                             }else{
  126.                                 $stageSimulation $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "simulation");
  127.                                 $stageClinique $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "clinique");
  128.                             }
  129.                             break;
  130.                     }
  131.                     
  132.                     array_push($arrayOfStage, [
  133.                         'clinique' => $stageClinique,
  134.                         'simulation' => $stageSimulation,
  135.                         'pharmacy' => $stagePharmacy,
  136.                         'dentaire' => $stageSDentaire,
  137.                         'staff' => $stagePharmacyStaff,
  138.                         'hopital' => $stagePharmacyHopital,
  139.                         'fmaglobal' => $stageFmaGlobal,
  140.                         'fdaglobal' => $stageFdaGlobal,
  141.                         'fpaglobal' => $stageFpaGlobal,
  142.                     ]);
  143.                 }
  144.                 array_push($data, [
  145.                     'inscription' => $inscription,
  146.                     'stages' => $arrayOfStage
  147.                 ]);
  148.             // }
  149.         }
  150.         // dd($cycles);
  151.         $html $this->render("rapport/page/table.html.twig", [
  152.             'datas' => $data,
  153.             'cycles' => $cycles
  154.         ])->getContent();
  155.         $session->set("inscriptions"$inscriptions);
  156.         return $html;
  157.     }
  158. }