src/Controller/Etudiant/RapportController.php line 189

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Etudiant;
  3. use ZipArchive;
  4. use SplFileObject;
  5. use App\Entity\Rapport;
  6. use Selective\Rar\RarFileReader;
  7. use Doctrine\Persistence\ManagerRegistry;
  8. use phpDocumentor\Reflection\Types\This;
  9. use Symfony\Component\HttpFoundation\Request;
  10. use Symfony\Component\HttpFoundation\Response;
  11. use Symfony\Component\Routing\Annotation\Route;
  12. use Symfony\Component\HttpFoundation\JsonResponse;
  13. use Symfony\Contracts\HttpClient\HttpClientInterface;
  14. use Symfony\Component\String\Slugger\SluggerInterface;
  15. use Symfony\Component\Finder\Exception\AccessDeniedException;
  16. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  17. use Symfony\Component\HttpFoundation\File\Exception\FileException;
  18. use PhpOffice\PhpSpreadsheet\Spreadsheet;
  19. use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
  20. use Symfony\Component\HttpFoundation\ResponseHeaderBag;
  21. #[Route('/etudiant/rapport')]
  22. class RapportController extends AbstractController
  23. {
  24.     private $client;
  25.     private $em;
  26.     public function __construct(HttpClientInterface $clientManagerRegistry $em)
  27.     {
  28.         $this->client $client;
  29.         $this->em $em->getManager();
  30.     }
  31.     #[Route('/'name'rapport_index')]
  32.     public function index(): Response
  33.     {
  34.         $response $this->client->request('GET'$this->getParameter("api")."/getetablissement");
  35.         $etablissements $response->toArray();
  36.         return $this->render('rapport/index.html.twig', [
  37.             'etablissements' => $etablissements
  38.         ]);
  39.     }
  40.     #[Route('/import'name'rapport_import')]
  41.     public function import(Request $requestSluggerInterface $slugger): Response
  42.     {
  43.         $files $request->files->get('file');
  44.         foreach ($files as $file) {
  45.             if($file->guessExtension() !== 'pdf'){
  46.                 return new JsonResponse('Prière d\'enregister des fichiers pdf!'500);            
  47.             }
  48.         }
  49.         
  50.         foreach ($files as $file) {
  51.             $name $file->getClientOriginalName();
  52.             $data explode("_"$name);
  53.             $stage $data[1];
  54.             $inscription $data[2];
  55.             $type $data[3];
  56.             $originalFilename pathinfo($namePATHINFO_FILENAME);
  57.             $safeFilename $slugger->slug($originalFilename);
  58.             $newFilename $safeFilename.'-'.uniqid().'.'.$file->guessExtension();
  59.             // dd($originalFilename, $newFilename);
  60.             
  61.             try {
  62.                 // dd("hi");
  63.                 $file->move(
  64.                     $this->getParameter('rapport_directory'),
  65.                     $newFilename
  66.                 );
  67.                 $rapportExist $this->em->getRepository(Rapport::class)->findOneBy(['stage' => $stage'inscription' => $inscription'type' => $type]);
  68.                 // dd($rapportExist);
  69.                 if($rapportExist){
  70.                     $rapportExist->setUrl($newFilename);
  71.                     $rapportExist->setDateUpdated(new \DateTime("now"));
  72.                 } else {
  73.                     $rapport = new Rapport();
  74.                     $rapport->setStage($stage);
  75.                     $rapport->setInscription($inscription);
  76.                     $rapport->setType($type);
  77.                     $rapport->setDateCreated(new \DateTime("now"));
  78.                     $rapport->setDateUpdated(new \DateTime("now"));
  79.                     $rapport->setUrl($newFilename);
  80.                     $this->em->persist($rapport);
  81.                 }
  82.                 $this->em->flush();
  83.             } catch (FileException $e) {
  84.                 return new JsonResponse($e500);
  85.             }
  86.         }
  87.         
  88.         return new JsonResponse("Bien enregistre");
  89.     }
  90.     #[Route('/list/{id}/{cyclekey}'name'rapport_list')]
  91.     public function list(Request $request$id$cyclekey): Response
  92.     {
  93.         // dd("test");
  94.         ini_set("pcre.backtrack_limit""5000000000");
  95.         ini_set('max_execution_time''-1');
  96.         // dd(ini_get('max_execution_time'));
  97.         // set_time_limit(0);
  98.         $response $this->client->request('GET'$this->getParameter("api")."/getlistofstagebysemestreannee/$id");
  99.         $session $request->getSession();
  100.         $data $response->toArray();
  101.         $inscriptions $data['inscriptions'];
  102.         // dd($inscriptions);
  103.         $cycles $data['cycles'];
  104.         // $ncycles = [];
  105.         // if($cycles[$cyclekey]){
  106.         //     array_push($ncycles[$cyclekey], $cycles[$cyclekey]);
  107.         // }
  108.         // $ncycles[$cyclekey] = $ncycles[0];
  109.         $ncycles[$cyclekey]= $cycles[$cyclekey];
  110.         // dd($cycles);
  111.         
  112.         $etab $inscriptions[0]['etab'];
  113.         $data = [];
  114.         $c 0;
  115.         $stageSimulation $stageClinique $stageSDentaire $stagePharmacy $stagePharmacyHopital $stagePharmacyStaff $stageFmaGlobal $stageFpaGlobal $stageFdaGlobal null;
  116.         foreach ($inscriptions as $key => $inscription) {
  117.             // if($inscription['id'] == "19265") {
  118.                 $arrayOfStage = [];
  119.                 // if($inscription['id'] == "17835"){
  120.                 //     dd($cycles);
  121.                     
  122.                 // }
  123.                 foreach ($ncycles as $key => $cycle) {
  124.                 //     if($key != $cyclekey){
  125.                 //         continue;
  126.                 //     }
  127.                     switch ($etab) {
  128.                         case 'FMDA':
  129.                             $stageFdaGlobal $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "global");
  130.                             $stageSDentaire $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "dentaire");
  131.                             $stageSimulation $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "simulation");
  132.                             $stageClinique $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "clinique");
  133.                             break;
  134.                         case 'FPA':
  135.                             $stageFpaGlobal $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "global");
  136.                             $stagePharmacyHopital $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "hopital");
  137.                             $stagePharmacy $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "pharmacy");
  138.                             $stagePharmacyStaff $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "staff");
  139.                             $stageSimulation $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "simulation");
  140.                             break;
  141.                         default:
  142.                             $stageFmaGlobal $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "global");
  143.                             $stageSimulation $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "simulation");
  144.                             $stageClinique $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "clinique");
  145.                             break;
  146.                     }
  147.                     
  148.                     // $stageSimulation = $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "simulation");
  149.                     // $stageClinique = $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "clinique");
  150.                     // $stageSDentaire = $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "dentaire");
  151.                     // $stagePharmacy = $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "pharmacy");
  152.                     // $stagePharmacyHopital = $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "hopital");
  153.                     // $stagePharmacyStaff = $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "staff");
  154.                     // dd($stagePharmacyHopital);
  155.                     array_push($arrayOfStage, [
  156.                         'clinique' => $stageClinique,
  157.                         'simulation' => $stageSimulation,
  158.                         'pharmacy' => $stagePharmacy,
  159.                         'dentaire' => $stageSDentaire,
  160.                         'staff' => $stagePharmacyStaff,
  161.                         'hopital' => $stagePharmacyHopital,
  162.                         'fmaglobal' => $stageFmaGlobal,
  163.                         'fdaglobal' => $stageFdaGlobal,
  164.                         'fpaglobal' => $stageFpaGlobal,
  165.                     ]);
  166.                 }
  167.                 
  168.                 // dd($arrayOfStage);
  169.                 array_push($data, [
  170.                     'inscription' => $inscription,
  171.                     'stages' => $arrayOfStage
  172.                 ]);
  173.             // }
  174.         }
  175.         // dd($data);
  176.         $html $this->render("rapport/page/table.html.twig", [
  177.             'datas' => $data,
  178.             'cycles' => $ncycles
  179.         ])->getContent();
  180.         // dd($cycles);
  181.         $session->set("inscriptions"$inscriptions);
  182.         return new JsonResponse($html);
  183.     }
  184.     #[Route('/stageDetails/{rapport}'name'rapport_stageDetails')]
  185.     public function stageDetails(Request $requestRapport $rapport): Response
  186.     {
  187.         $session $request->getSession();
  188.         $inscriptions $session->get("inscriptions");
  189.         $inscription $inscriptions[array_search($rapport->getInscription(), array_column($inscriptions'id'))];
  190.         // dd($rapport);
  191.         return $this->render("rapport/detail.html.twig", [
  192.             'rapport' => $rapport,
  193.             'inscription' => $inscription
  194.         ]);
  195.     }
  196.     #[Route('/rapportsave/{rapport}'name'rapport_rapport_save')]
  197.     public function rapport_save(Request $requestRapport $rapport): Response
  198.     {
  199.         // dd($request);
  200.         if(!in_array('ROLE_ENSEIGNANT'$this->getUser()->getRoles())) {
  201.             throw new AccessDeniedException("Vous avez pas le droit!");
  202.         }
  203.         $rapport->setNote(floatval($request->get('note')));
  204.         $rapport->setObservation($request->get('observation'));
  205.         $rapport->setProf($this->getUser());
  206.         $this->em->flush();
  207.         return $this->redirectToRoute('rapport_stageDetails', [
  208.             'rapport' => $rapport->getId()
  209.         ]);
  210.     }
  211.     #[Route('/export_etat_Notes/{semestre}/{cyclekey}'name'export_etat_Notes')]
  212.     public function export_etat_Notes(Request $request$semestre,$cyclekey)
  213.     {
  214.         // set_time_limit(0);
  215.         // set_time_limit(0);
  216.         // ini_set('max_execution_time', '0');
  217.         // dd(ini_get('max_execution_time'));
  218.         
  219.         $response $this->client->request('GET'$this->getParameter("api")."/getlistofstagebysemestreannee/$semestre")->toArray();
  220.         $abreviations $this->client->request('GET'$this->getParameter("api")."/getabreviationsbysemestre/$semestre")->toArray();
  221.         $inscriptions $response['inscriptions'];
  222.         $cycles $response['cycles'];
  223.         $etab $inscriptions[0]['etab'];
  224.         $stageSimulation $stageClinique $stageDentaire $stagePharmacy $stagePharmacyHopital $stagePharmacyStaff $stageFmaGlobal $stageFpaGlobal $stageFdaGlobal null;
  225.         // dd($cycles,$semestre,$cyclekey);
  226.         $spreadsheet = new Spreadsheet();
  227.         $sheet $spreadsheet->getActiveSheet();
  228.         $sheet->setCellValue('A1''ORD');
  229.         // $values = [];
  230.         $i=2;
  231.         $j=1;
  232.         $headers = [];
  233.         foreach ($inscriptions as $inscription) {
  234.             // if($inscription['id'] == "19274" || $inscription['id'] == "19265") {
  235.             $sheet->setCellValue('A'.$i$j);
  236.             $sheet->fromArray(
  237.                 $inscription,
  238.                 null,
  239.                 'B'.$i
  240.             );
  241.             $k $cyclekey 1;
  242.             // $k = 1;
  243.             foreach ($cycles as $key => $cycle) { 
  244.                 if($key != $cyclekey){
  245.                     continue;
  246.                     // dd($cycles,$cycle);
  247.                 }
  248.                     switch ($etab) {
  249.                         case 'FMDA':
  250.                             $stageFdaGlobal $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "global");
  251.                             $stageDentaire $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "dentaire");
  252.                             $stageSimulation $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "simulation");
  253.                             $stageClinique $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "clinique");
  254.                             break;
  255.                         case 'FPA':
  256.                             $stageFpaGlobal $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "global");
  257.                             $stagePharmacyHopital $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "hopital");
  258.                             $stagePharmacy $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "pharmacy");
  259.                             $stagePharmacyStaff $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "staff");
  260.                             $stageSimulation $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "simulation");
  261.                             break;
  262.                         default:
  263.                             $stageFmaGlobal $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "global");
  264.                             $stageSimulation $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "simulation");
  265.                             $stageClinique $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "clinique");
  266.                             break;
  267.                     }
  268.                     
  269.                     if (($stageClinique != null || $stageSimulation != null || $stageFmaGlobal != null) && $stagePharmacyHopital == null ) {
  270.                         // dd($stageSimulation);
  271.                         $inscription['stage'.$k] = $cycle['designation'][0];
  272.                         // $inscription['P-Cli'.$k] = $stageClinique->getProf() == null ? 'null' : $stageClinique->getProf()->getNom() . " " .$stageClinique->getProf()->getPrenom();
  273.                         $inscription['P-Cli'.$k] = $stageClinique != null ? ($stageClinique->getProf() == null 'null' $stageClinique->getProf()->getNom() . " " .$stageClinique->getProf()->getPrenom()) : "";
  274.                         $inscription['N-Cli'.$k] = $stageClinique != null ? ($stageClinique->getNote() == "0" $stageClinique->getNote()) : "";
  275.                         $inscription['OBS Cli'.$k] = $stageClinique != null $stageClinique->getObservation() : "";
  276.                         $inscription['P-Sim'.$k] = $stageSimulation != null ? ($stageSimulation->getProf() == null 'null' $stageSimulation->getProf()->getNom() . " " .$stageSimulation->getProf()->getPrenom()) : "";
  277.                         $inscription['N-Sim'.$k] = $stageSimulation != null ? ($stageSimulation->getNote() == "0" $stageSimulation->getNote()) : "";
  278.                         $inscription['OBS Sim'.$k] = $stageSimulation != null $stageSimulation->getObservation() : "";
  279.                         $inscription['P-Glb'.$k] = $stageFmaGlobal != null ? ($stageFmaGlobal->getProf() == null 'null' $stageFmaGlobal->getProf()->getNom() . " " .$stageFmaGlobal->getProf()->getPrenom()) : "";
  280.                         $inscription['N-Glb'.$k] = $stageFmaGlobal != null ? ($stageFmaGlobal->getNote() == "0" $stageFmaGlobal->getNote()) : "";
  281.                         $inscription['OBS Glb'.$k] = $stageFmaGlobal != null $stageFmaGlobal->getObservation() : "";
  282.                     }
  283.                     
  284.                     elseif ($stageSimulation != null || $stagePharmacyHopital != null || $stageFpaGlobal != null) {
  285.                         $inscription['stage'.$k] = $cycle['designation'][0];
  286.                         $inscription['P-Simulation'.$k] = $stageSimulation != null ? ($stageSimulation->getProf() == null 'null' $stageSimulation->getProf()->getNom() . " " .$stageSimulation->getProf()->getPrenom()) : "";
  287.                         $inscription['N-Simulation'.$k] = $stageSimulation != null ? ($stageSimulation->getNote() == "0" $stageSimulation->getNote()) : "";
  288.                         $inscription['OBS Simulation'.$k] = $stageSimulation != null $stageSimulation->getObservation() : "";
  289.                         $inscription['P-Hopital'.$k] = $stagePharmacyHopital != null ? ($stagePharmacyHopital->getProf() == null 'null' $stagePharmacyHopital->getProf()->getNom() . " " .$stagePharmacyHopital->getProf()->getPrenom()) : "";
  290.                         $inscription['N-Hopital'.$k] = $stagePharmacyHopital != null ? ($stagePharmacyHopital->getNote() == "0" $stagePharmacyHopital->getNote()) : "";
  291.                         $inscription['OBS Hopital'.$k] = $stagePharmacyHopital != null $stagePharmacyHopital->getObservation() : "";
  292.                         $inscription['P-Glb'.$k] = $stageFpaGlobal != null ? ($stageFpaGlobal->getProf() == null 'null' $stageFpaGlobal->getProf()->getNom() . " " .$stageFpaGlobal->getProf()->getPrenom()) : "";
  293.                         $inscription['N-Glb'.$k] = $stageFpaGlobal != null ? ($stageFpaGlobal->getNote() == "0" $stageFpaGlobal->getNote()) : "";
  294.                         $inscription['OBS Glb'.$k] = $stageFpaGlobal != null $stageFpaGlobal->getObservation() : "";
  295.                     }
  296.                     elseif ($stagePharmacy != null) {
  297.                         $inscription['stage'.$k] = $cycle['designation'][0];
  298.                         $inscription['P-Phar'.$k] = $stagePharmacy->getProf() == null 'null' $stagePharmacy->getProf()->getNom() . " " .$stagePharmacy->getProf()->getPrenom();
  299.                         $inscription['N-Phar'.$k] = $stagePharmacy->getNote() == "0" $stagePharmacy->getNote();  
  300.                         $inscription['OBS Phar'.$k] = $stagePharmacy->getObservation();
  301.                     }elseif ($stageDentaire != null || $stageFdaGlobal != null) {
  302.                         $inscription['stage'.$k] = $cycle['designation'][0];
  303.                         $inscription['P-Dent'.$k] = $stageDentaire->getProf() == null 'null' $stageDentaire->getProf()->getNom() . " " .$stageDentaire->getProf()->getPrenom();
  304.                         $inscription['N-Dent'.$k] = $stageDentaire->getNote() == "0" $stageDentaire->getNote();
  305.                         $inscription['OBS Dent'.$k] = $stageDentaire->getObservation();
  306.                         $inscription['P-Glb'.$k] = $stageFdaGlobal->getProf() == null 'null' $stageFdaGlobal->getProf()->getNom() . " " .$stageFdaGlobal->getProf()->getPrenom();
  307.                         $inscription['N-Glb'.$k] = $stageFdaGlobal->getNote() == "0" $stageFdaGlobal->getNote();
  308.                         $inscription['OBS Glb'.$k] = $stageFdaGlobal->getObservation();
  309.                     }else{
  310.                         // $inscription['stage'.$k] = $cycle['designation'][0];
  311.                         $inscription['stage'.$k] = "";
  312.                         $inscription['P-Phar'.$k] = "";
  313.                         $inscription['N-Phar'.$k] = "";  
  314.                         $inscription['OBS Phar'.$k] = "";
  315.                     }
  316.                     if (count($inscription) >= count($headers)) {
  317.                         $headers $inscription;
  318.                     }
  319.                 $k++;
  320.             }
  321.             $sheet->fromArray(
  322.                 $inscription,
  323.                 null,
  324.                 'B'.$i
  325.             );
  326.             $i++;
  327.             $j++;
  328.             }
  329.         // }
  330.         $sheet->fromArray(
  331.             array_keys($headers),
  332.             null,
  333.             'B1'
  334.         );
  335.         $writer = new Xlsx($spreadsheet);
  336.         $fileName 'Extraction Des Notes.xlsx';
  337.         $temp_file tempnam(sys_get_temp_dir(), $fileName);
  338.         $writer->save($temp_file);
  339.         return $this->file($temp_file$fileNameResponseHeaderBag::DISPOSITION_INLINE);
  340.     }
  341.     
  342.     // #[Route('/export_etat_Notes/{semestre}', name: 'export_etat_Notes')]
  343.     // public function export_etat_Notes(Request $request, $semestre)
  344.     // {
  345.     //     $response = $this->client->request('GET', $this->getParameter("api")."/getlistofstagebysemestreannee/$semestre")->toArray();
  346.     //     $abreviations = $this->client->request('GET', $this->getParameter("api")."/getabreviationsbysemestre/$semestre")->toArray();
  347.     //     // dd($response);
  348.     //     $inscriptions = $response['inscriptions'];
  349.     //     $cycles = $response['cycles'];
  350.     //     // dd($cycles);
  351.     //     // dd($inscriptions);
  352.     //     $spreadsheet = new Spreadsheet();
  353.     //     $sheet = $spreadsheet->getActiveSheet();
  354.     //     $sheet->setCellValue('A1', 'ORD');
  355.     //     $sheet->fromArray(
  356.     //         array_keys($inscriptions[0]),
  357.     //         null,
  358.     //         'B1'
  359.     //     );
  360.     //     // $sheet->setCellValue('S1', 'CYCLE 1');
  361.     //     // $sheet->setCellValue('T1', 'N-Cli');
  362.     //     // $sheet->setCellValue('U1', 'N-Sim');
  363.     //     // $sheet->setCellValue('V1', 'OBS Cli');
  364.     //     // $sheet->setCellValue('W1', 'OBS Sim');
  365.     //     // $sheet->setCellValue('R1', 'CYCLE 1');
  366.     //     // $sheet->setCellValue('S1', 'N-Cli');
  367.     //     // $sheet->setCellValue('T1', 'N-Sim');
  368.     //     // $sheet->setCellValue('U1', 'N-Phar');
  369.     //     // $sheet->setCellValue('V1', 'N-Dent');
  370.     //     // $sheet->setCellValue('W1', 'OBS Cli');
  371.     //     // $sheet->setCellValue('X1', 'OBS Sim');
  372.     //     // $sheet->setCellValue('Y1', 'OBS Phar');
  373.     //     // $sheet->setCellValue('Z1', 'OBS Dent');
  374.     //     // $sheet->setCellValue('AA1', 'CYCLE 2');
  375.     //     // $sheet->setCellValue('AB1', 'N-Cli');
  376.     //     // $sheet->setCellValue('AC1', 'N-Sim');
  377.     //     // $sheet->setCellValue('AD1', 'N-Phar');
  378.     //     // $sheet->setCellValue('AE1', 'N-Dent');
  379.     //     // $sheet->setCellValue('AF1', 'OBS Cli');
  380.     //     // $sheet->setCellValue('AG1', 'OBS Sim');
  381.     //     // $sheet->setCellValue('AH1', 'OBS Phar');
  382.     //     // $sheet->setCellValue('AI1', 'OBS Dent');
  383.     //     // $sheet->setCellValue('AJ1', 'CYCLE 3');
  384.     //     // $sheet->setCellValue('AK1', 'N-Cli');
  385.     //     // $sheet->setCellValue('AL1', 'N-Sim');
  386.     //     // $sheet->setCellValue('AM1', 'N-Phar');
  387.     //     // $sheet->setCellValue('AN1', 'N-Dent');
  388.     //     // $sheet->setCellValue('AO1', 'OBS Cli');
  389.     //     // $sheet->setCellValue('AP1', 'OBS Sim');
  390.     //     // $sheet->setCellValue('AQ1', 'OBS Phar');
  391.     //     // $sheet->setCellValue('AR1', 'OBS Dent');
  392.     //     // $sheet->setCellValue('AS1', 'CYCLE 4');
  393.     //     // $sheet->setCellValue('AT1', 'N-Cli');
  394.     //     // $sheet->setCellValue('AU1', 'N-Sim');
  395.     //     // $sheet->setCellValue('AV1', 'N-Phar');
  396.     //     // $sheet->setCellValue('AW1', 'N-Dent');
  397.     //     // $sheet->setCellValue('AX1', 'OBS Cli');
  398.     //     // $sheet->setCellValue('AY1', 'OBS Sim');
  399.     //     // $sheet->setCellValue('AZ1', 'OBS Phar');
  400.     //     // $sheet->setCellValue('BA1', 'OBS Dent');
  401.     //     $i=2;
  402.     //     $j=1;
  403.     //     foreach ($inscriptions as $inscription) {
  404.     //         // dd($infoBYinscription);
  405.     //         $sheet->setCellValue('A'.$i, $j);
  406.     //         $sheet->fromArray(
  407.     //             $inscription,
  408.     //             null,
  409.     //             'B'.$i
  410.     //         );
  411.     //         $k = 1;
  412.     //         foreach ($cycles as $cycle) {
  413.     //             if ($k == 1) {
  414.     //                 $stageClinique = $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "clinique");
  415.     //                 // dd($cycle['designation']);
  416.     //                 $stageSimulation = $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "simulation");
  417.     //                 $stagePharmacy = $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "pharmacy");
  418.     //                 $stageDentaire = $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "dentaire");
  419.     //                 $stagePharmacy = $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "pharmacy");
  420.     //                 $stageSDentaire = $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "dentaire");
  421.     //                 $stagePharmacyStaff = $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "staff");
  422.     //                 // dd($stagePharmacyStaff);
  423.     //                 $stagePharmacyHopital = $this->em->getRepository(Rapport::class)->findStage($inscription["id"], $cycle['stages'], "hopital");
  424.     //                 $sheet->setCellValue('S1', 'stage'.$k);
  425.     //                 $sheet->setCellValue('S'.$i,$cycle['designation'][0]);
  426.     //                 if ($stageClinique != null || $stageSimulation != null) {
  427.     //                     $sheet->setCellValue('T1', 'N-Cli');
  428.     //                     $sheet->setCellValue('U1', 'N-Sim');
  429.     //                     $sheet->setCellValue('V1', 'OBS Cli');
  430.     //                     $sheet->setCellValue('W1', 'OBS Sim');
  431.     //                     $sheet->setCellValue('T'.$i, $stageClinique->getNote());
  432.     //                     $sheet->setCellValue('U'.$i, $stageSimulation->getNote());
  433.     //                     $sheet->setCellValue('V'.$i, $stageClinique->getObservation());
  434.     //                     $sheet->setCellValue('W'.$i, $stageSimulation->getObservation());
  435.     //                 }elseif ($stagePharmacyStaff != null || $stagePharmacyHopital != null) {
  436.     //                     $sheet->setCellValue('T1', 'N-Staf');
  437.     //                     $sheet->setCellValue('U1', 'N-Hopital');
  438.     //                     $sheet->setCellValue('V1', 'OBS Staf');
  439.     //                     $sheet->setCellValue('W1', 'OBS Hopital');
  440.     //                     $sheet->setCellValue('T'.$i, $stagePharmacyStaff->getNote());
  441.     //                     $sheet->setCellValue('U'.$i, $stagePharmacyHopital->getNote());
  442.     //                     $sheet->setCellValue('V'.$i, $stagePharmacyStaff->getObservation());
  443.     //                     $sheet->setCellValue('W'.$i, $stagePharmacyHopital->getObservation());
  444.     //                 }elseif ($stagePharmacy != null) {
  445.     //                     $sheet->setCellValue('T1', 'N-Phar');
  446.     //                     $sheet->setCellValue('U1', 'OBS Phar');
  447.     //                     $sheet->setCellValue('T'.$i, $stagePharmacy->getNote());
  448.     //                     $sheet->setCellValue('U'.$i, $stagePharmacy->getObservation());
  449.     //                 }elseif ($stageDentaire != null) {
  450.     //                     $sheet->setCellValue('T1', 'N-Dent');
  451.     //                     $sheet->setCellValue('U1', 'OBS Dent');
  452.     //                     $sheet->setCellValue('T'.$i, $stageDentaire->getNote());
  453.     //                     $sheet->setCellValue('U'.$i, $stageDentaire->getObservation());
  454.     //                 }
  455.     //             }
  456.     //             $k++;
  457.     //         }
  458.     //         $i++;
  459.     //         $j++;
  460.     //     }
  461.         
  462.     //     // $sheet = $spreadsheet->getActiveSheet();
  463.         
  464.         
  465.     //     $writer = new Xlsx($spreadsheet);
  466.     //     $fileName = 'Extraction Des Notes.xlsx';
  467.     //     $temp_file = tempnam(sys_get_temp_dir(), $fileName);
  468.     //     $writer->save($temp_file);
  469.     //     return $this->file($temp_file, $fileName, ResponseHeaderBag::DISPOSITION_INLINE);
  470.     // }
  471.     
  472.     
  473. }