src/Controller/ResourcesController.php line 29

  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Block;
  4. use App\Entity\General;
  5. use App\Entity\User;
  6. use App\Entity\Status;
  7. use App\Entity\Resource;
  8. use App\Entity\Reservation;
  9. use App\Entity\OccupationPerHour;
  10. use App\Entity\GroupAncestorDetails;
  11. use Doctrine\Persistence\ManagerRegistry;
  12. use Symfony\Component\Serializer\Serializer;
  13. use Symfony\Component\HttpFoundation\Request;
  14. use Symfony\Component\HttpFoundation\Response;
  15. use Symfony\Component\Routing\Annotation\Route;
  16. use Symfony\Component\HttpFoundation\JsonResponse;
  17. use Symfony\Component\Serializer\SerializerInterface;
  18. use Symfony\Contracts\Translation\TranslatorInterface;
  19. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  20. class ResourcesController extends AbstractController
  21. {
  22.     #[Route('/'name'app_default')]
  23.     public function index(ManagerRegistry $doctrineSerializerInterface $serializerRequest $request,TranslatorInterface $translator): Response
  24.     {
  25.         $localisations Json_decode($serializer->serialize($doctrine->getRepository(GroupAncestorDetails::class)->findBy(['groupTypeName' => 'Localisation'], ['groupLevelId' => 'ASC']), 'json',['groups' => 'groupAncestor']),true);
  26.         $typeResources Json_decode($serializer->serialize($doctrine->getRepository(GroupAncestorDetails::class)->findBy(['groupTypeName' => 'Type'], ['groupLevelId' => 'ASC']), 'json',['groups' => 'groupAncestor']),true);
  27.         $status $doctrine->getRepository(Status::class)->findAllStatus($request->getLocale());
  28.         $users $doctrine->getRepository(User::class)->findUsers();
  29.         $general $doctrine->getRepository(General::class)->find(1);
  30.         $resources $doctrine->getRepository(Resource::class)->findGroupped();
  31.         $localisationsTree = [];
  32.         $allSites[] = [
  33.             "id" => -999,
  34.             "groupAncestorId" => -999,
  35.             "groupName" => $translator->trans("All sites"),
  36.             "groupLevelId" => 0,
  37.             "groupLevelName" => "Site",
  38.             "groupTypeName" => "Localisation"
  39.         ];
  40.         array_push($allSites,...array_map(function($item) {
  41.             if ($item['id'] == $item['groupAncestorId']) {
  42.                 $item['groupAncestorId'] = -999;
  43.             }
  44.             return $item;
  45.         },$localisations));
  46.         foreach ($allSites as $item) {
  47.             if ($item['id'] == $item['groupAncestorId']) {
  48.                 $localisationsTree[] = array(
  49.                     'name' => $item['groupName'],
  50.                     'value' => $item['id'],
  51.                     'children' => array(),
  52.                 );
  53.             } else {
  54.                 $this->buildTree($localisationsTree,$item,'localisation');
  55.             }
  56.         }
  57.         $typeResourcesTree = [];
  58.         $allTypeResources[] = [
  59.             "id" => -999,
  60.             "groupAncestorId" => -999,
  61.             "groupName" => $translator->trans("All resources"),
  62.             "groupLevelId" => 0,
  63.             "groupLevelName" => "Type",
  64.             "groupTypeName" => "Type"
  65.         ];
  66.         
  67.         array_push($allTypeResources,...array_map(function($item) {
  68.             if ($item['id'] == $item['groupAncestorId']) {
  69.                 $item['groupAncestorId'] = -999;
  70.             }
  71.             return $item;
  72.         },$typeResources));
  73.         foreach ($allTypeResources as $item) {
  74.             if ($item['id'] == $item['groupAncestorId']) {
  75.                 $typeResourcesTree[] = array(
  76.                     'name' => $item['groupName'],
  77.                     'value' => $item['id'],
  78.                     'children' => array(),
  79.                 );
  80.             } else {
  81.                 $this->buildTree($typeResourcesTree,$item,'resourceType',true);
  82.             }
  83.         }
  84.         return $this->render('statistiques/resources.html.twig', [
  85.             'localisationsTree' => $localisationsTree,
  86.             'typeResourcesTree' => $typeResourcesTree,
  87.             'typeResources' => $typeResources,
  88.             'localisations' => $localisations,
  89.             'resources' => $resources,
  90.             'users' => $users,
  91.             'status' => $status,
  92.             'general' => $general,
  93.         ]);
  94.     }
  95.     // Fonction récursive pour construire l'arbre
  96.     function buildTree(&$parents$item$type$checked false)
  97.     {
  98.         foreach ($parents as &$parent) {
  99.             if (isset($parent['value']) && $parent['value'] == $item['groupAncestorId']) {
  100.                 // Ajouter l'objet enfant au tableau children de l'objet principal correspondant
  101.                 $parent['children'][] = array(
  102.                     'name' => $item['groupName'],
  103.                     'value' => $item['id'],
  104.                     'children' => array(),
  105.                 );
  106.             } else {
  107.                 $this->buildTree($parent['children'],$item,$type);
  108.             }
  109.         }
  110.     }
  111.     #[Route('/get-reservation'name'getReservation')]
  112.     public function getReservation(ManagerRegistry $doctrineRequest $requestTranslatorInterface $translator): Response
  113.     {
  114.         $reservation $doctrine->getRepository(Reservation::class)->findByFilter$request->request->get('localisation'), $request->request->get('user'), $request->request->get('startDate'), $request->request->get('endDate'),$request->request->get('status'), $request->getLocale(),$request->request->get('resource'),$request->request->get('resourceType'));
  115.         return new JsonResponse([
  116.             'totalReservations' => $reservation[0]['value'],
  117.         ]);
  118.     } 
  119.     #[Route('/get-status'name'getStatus')]
  120.     public function getStatus(ManagerRegistry $doctrineRequest $requestTranslatorInterface $translator): Response
  121.     {
  122.         $status $doctrine->getRepository(Reservation::class)->findByFilter$request->request->get('localisation'), $request->request->get('user'), $request->request->get('startDate'), $request->request->get('endDate'),$request->request->get('status'), $request->getLocale(),$request->request->get('resource'),$request->request->get('resourceType'),'status');
  123.         foreach ($status as $key => $value) {
  124.             $status[$key]['item'] =  $translator->trans($value['item']);
  125.         }
  126.         return new JsonResponse([
  127.             'reservationStatus' => $status,
  128.         ]);
  129.     }
  130.     #[Route('/get-origin'name'getOrigin')]
  131.     public function getOrigin(ManagerRegistry $doctrineRequest $requestTranslatorInterface $translator): Response
  132.     {
  133.         $origins $doctrine->getRepository(Reservation::class)->findByFilter$request->request->get('localisation'), $request->request->get('user'), $request->request->get('startDate'), $request->request->get('endDate'),$request->request->get('status'), $request->getLocale(),$request->request->get('resource'),$request->request->get('resourceType'),'origin');
  134.         foreach ($origins as $key => $value) {
  135.             $origins[$key]['item'] =  $translator->trans($value['item']);
  136.         }
  137.         return new JsonResponse([
  138.             'reservationOrigin' => $origins,
  139.         ]);
  140.     }
  141.     #[Route('/get-immediate'name'getImmediate')]
  142.     public function getImmediate(ManagerRegistry $doctrineRequest $requestTranslatorInterface $translator): Response
  143.     {
  144.         $immediate $doctrine->getRepository(Reservation::class)->findByFilter$request->request->get('localisation'), $request->request->get('user'), $request->request->get('startDate'), $request->request->get('endDate'),$request->request->get('status'), $request->getLocale(),$request->request->get('resource'),$request->request->get('resourceType'),'immediat_use');
  145.         //Translate immadiateUse
  146.         foreach ($immediate as $key => $value) {
  147.             $immediate[$key]['item'] =  $translator->trans($value['item']);
  148.         }
  149.         return new JsonResponse([
  150.             'immediateReservation' => $immediate,
  151.         ]);
  152.     }
  153.     #[Route('/get-type-site'name'getTypeSite')]
  154.     public function getTypeSite(ManagerRegistry $doctrineRequest $requestTranslatorInterface $translator): Response
  155.     {
  156.         $resourceBySite $doctrine->getRepository(Reservation::class)->findByFilter$request->request->get('localisation'), $request->request->get('user'), $request->request->get('startDate'), $request->request->get('endDate'),$request->request->get('status'), $request->getLocale(),$request->request->get('resource'),$request->request->get('resourceType'),'resourceBySite',10);
  157.         return new JsonResponse([
  158.             'resourceBySite' => $resourceBySite,
  159.         ]);
  160.     }
  161.     #[Route('/get-by-stage'name'getByStage')]
  162.     public function getByStage(ManagerRegistry $doctrineRequest $requestTranslatorInterface $translator): Response
  163.     {
  164.         $resourceByStage $doctrine->getRepository(Reservation::class)->findByFilter$request->request->get('localisation'), $request->request->get('user'), $request->request->get('startDate'), $request->request->get('endDate'),$request->request->get('status'), $request->getLocale(),$request->request->get('resource'),$request->request->get('resourceType'),'resourceByStage');
  165.         $resourceByStage array_reduce($resourceByStage, function ($carry$item) use ($translator) {
  166.             // Vérifiez si l'élément existe déjà dans le tableau de regroupement
  167.             $key $item["item"];
  168.             if (!array_key_exists($key$carry)) {
  169.                 $carry[$key] = ["item" => $key$translator->trans('Refused') => 0$translator->trans("Cancelled") => 0$translator->trans("Pending") => 0$translator->trans("Confirmed") => 0];
  170.             }
  171.             
  172.             // Incrémentez le total du statut correspondant
  173.             if ($item['status'] == -1)
  174.                 $carry[$key][$translator->trans("Refused")] += $item["value"];
  175.             else if ($item['status'] == 0)
  176.                 $carry[$key][$translator->trans("Cancelled")] += $item["value"];
  177.             else if ($item['status'] == 1)
  178.                 $carry[$key][$translator->trans("Pending")] += $item["value"];
  179.             else
  180.                 $carry[$key][$translator->trans("Confirmed")] += $item["value"];
  181.             
  182.             return $carry;
  183.         }, []);
  184.         return new JsonResponse([
  185.             'resourceByStage' => array_values($resourceByStage),
  186.         ]);
  187.     }
  188.     #[Route('/get-without-site'name'getWithoutSite')]
  189.     public function getWithoutSite(ManagerRegistry $doctrineRequest $requestTranslatorInterface $translator): Response
  190.     {
  191.         $resourceByStackingDiagram $doctrine->getRepository(Reservation::class)->findByFilter$request->request->get('localisation'), $request->request->get('user'), $request->request->get('startDate'), $request->request->get('endDate'),$request->request->get('status'), $request->getLocale(),$request->request->get('resource'),$request->request->get('resourceType'),'resourceByType');
  192.         $resourceByStackingType=[];
  193.         $resourceWithoutSite=[];
  194.         foreach ($resourceByStackingDiagram as $item) {
  195.             $site $item['site'];
  196.             $value $item['value'];
  197.             $itemName $item['item'];
  198.             if(!isset($resourceByStackingType[$site])){
  199.                 $resourceByStackingType[$site]['item'] = $site;
  200.             }
  201.             $resourceByStackingType[$site][$itemName] = $value;
  202.             $resourceWithoutSite[$itemName] = $value;
  203.         }
  204.         $resourceByStackingType array_values($resourceByStackingType);
  205.         return new JsonResponse([
  206.             'resourceByStackingDiagram' => $resourceByStackingType,
  207.             'resourceWithoutSite' => $resourceWithoutSite,
  208.         ]);
  209.     }
  210.     #[Route('/get-type-zone'name'getByZone')]
  211.     public function getTypeZone(ManagerRegistry $doctrineRequest $requestTranslatorInterface $translator): Response
  212.     {
  213.         $resourceByZone $doctrine->getRepository(Reservation::class)->findByFilter$request->request->get('localisation'), $request->request->get('user'), $request->request->get('startDate'), $request->request->get('endDate'),$request->request->get('status'), $request->getLocale(),$request->request->get('resource'),$request->request->get('resourceType'),'resourceByZone');
  214.         return new JsonResponse([
  215.             'resourceByZone' => $resourceByZone,
  216.         ]);
  217.     }
  218.     #[Route('/get-by-type'name'getByType')]
  219.     public function getByType(ManagerRegistry $doctrineRequest $requestTranslatorInterface $translator): Response
  220.     {
  221.         $resourceByType $doctrine->getRepository(Reservation::class)->findByFilter$request->request->get('localisation'), $request->request->get('user'), $request->request->get('startDate'), $request->request->get('endDate'),$request->request->get('status'), $request->getLocale(),$request->request->get('resource'),$request->request->get('resourceType'),'resourceByType');
  222.         return new JsonResponse([
  223.             'resourceByType' => $resourceByType,
  224.         ]);
  225.     }
  226.     #[Route('/get-creneau'name'getCreneau')]
  227.     public function getCreneau(ManagerRegistry $doctrineRequest $request,TranslatorInterface $translator): Response
  228.     {
  229.         $weekDays = [
  230.             => 'Lundi',
  231.             => 'Mardi',
  232.             => 'Mercredi',
  233.             => 'Jeudi',
  234.             => 'Vendredi',
  235.             => 'Samedi',
  236.             => 'Dimanche',
  237.         ];
  238.         $topResources $doctrine->getRepository(Reservation::class)->findByFilter$request->request->get('localisation'), $request->request->get('user'), $request->request->get('startDate'), $request->request->get('endDate'),$request->request->get('status'), $request->getLocale(),$request->request->get('resource'),$request->request->get('resourceType'),'resources',5);
  239.         $topResources array_reduce($topResources, function ($carry$item) use ($translator) {
  240.             // Vérifiez si l'élément existe déjà dans le tableau de regroupement
  241.             $key $item["item"];
  242.             if (!array_key_exists($key$carry)) {
  243.                 $carry[$key] = ["item" => $key$translator->trans('Refused') => 0$translator->trans("Cancelled") => 0$translator->trans("Pending") => 0$translator->trans("Confirmed") => 0];
  244.             }
  245.             
  246.             // Incrémentez le total du statut correspondant
  247.             if ($item['status'] == -1)
  248.                 $carry[$key][$translator->trans("Refused")] += $item["value"];
  249.             else if ($item['status'] == 0)
  250.                 $carry[$key][$translator->trans("Cancelled")] += $item["value"];
  251.             else if ($item['status'] == 1)
  252.                 $carry[$key][$translator->trans("Pending")] += $item["value"];
  253.             else
  254.                 $carry[$key][$translator->trans("Confirmed")] += $item["value"];
  255.             
  256.             return $carry;
  257.         }, []);
  258.         asort($topResources);
  259.         $creneau $doctrine->getRepository(OccupationPerHour::class)->findCreneau($request->request->get('resource'),$request->request->get('resourceType'), $request->request->get('localisation'), $request->request->get('startDate'), $request->request->get('endDate'), $request->request->get('user'),2);
  260.         $reservationByDay $doctrine->getRepository(OccupationPerHour::class)->findReservationByDay($request->request->get('resource'),$request->request->get('resourceType'), $request->request->get('localisation'), $request->request->get('startDate'), $request->request->get('endDate'), $request->request->get('user'),2);
  261.         $findResourceByDatesTime $doctrine->getRepository(Resource::class)->findResourceByDatesTimes($request->request->get('startDate'), $request->request->get('endDate'),$request->request->get('localisation'), $request->request->get('resourceType'),$request->request->get('resource'));
  262.         $tauxOccupation = [];
  263.         $tauxOccupationByDate = [];
  264.         $resourceDispoTotal 0;
  265.         $totalReservation 0;
  266.         $interval = new \DateInterval('PT30M');
  267.         foreach ($findResourceByDatesTime as $item) {
  268.             
  269.             $currentHour = new \DateTime($item['open']);
  270.             $endHour = new \DateTime($item['close']);
  271.             while ($currentHour $endHour) {
  272.                 if (in_array($currentHour->format('H:i'),array_column($tauxOccupation,'hour'))) {
  273.                     $index array_search($currentHour->format('H:i'),array_column($tauxOccupation,'hour'));
  274.                     $tauxOccupation[$index]['resourceDispo'] += $item['count'];
  275.                 }else {
  276.                     $tauxOccupation[] = [
  277.                         'hour' => $currentHour->format('H:i'),
  278.                         'reservation' => 0,
  279.                         'reservation_reel' => 0,
  280.                         'resourceDispo' => $item['count'],
  281.                         'tauxOccupation' => 0,
  282.                         'tauxOccupationReal' => 0
  283.                     ];
  284.                 }
  285.                 
  286.                 $indexDay null;
  287.                 foreach ($tauxOccupationByDate as $key => $value) {
  288.                     if (
  289.                         $value['date'] === $item['date'] && 
  290.                         $value['hour'] === $currentHour->format('H:i')) {
  291.                         $indexDay $key;
  292.                         break;
  293.                     }
  294.                 }
  295.                 
  296.                 if ($indexDay) {
  297.                     $tauxOccupationByDate[$indexDay]['resourceDispo'] += $item['count'];
  298.                 }else {
  299.                     $tauxOccupationByDate[] = [
  300.                         'date' => $item['date'],
  301.                         'hour' => $currentHour->format('H:i'),
  302.                         'reservation' => 0,
  303.                         'reservation_reel' => 0,
  304.                         'resourceDispo' => $item['count'],
  305.                         'tauxOccupation' => 0,
  306.                         'tauxOccupationReal' => 0
  307.                     ];
  308.                 }
  309.                 $resourceDispoTotal += $item['count'];
  310.                 $currentHour->add($interval);
  311.             }
  312.         }
  313.         foreach ($creneau as $item) {
  314.             $indexDay null;
  315.             foreach ($tauxOccupationByDate as $key => $value) {
  316.                 if ($value['date'] === $item['date'] && $value['hour'] === $item['hour']) {
  317.                     $indexDay $key;
  318.                     break;
  319.                 }
  320.             }
  321.             if ($indexDay != null) {
  322.                 $tauxOccupationByDate[$indexDay]['reservation'] += $item['value'];
  323.                 $tauxOccupationByDate[$indexDay]['reservation_reel'] += $item['value_reel'];
  324.                 $tauxOccupationByDate[$indexDay]['tauxOccupation'] =  round(($tauxOccupationByDate[$indexDay]['reservation'] * 100) / $tauxOccupationByDate[$indexDay]['resourceDispo'],2);
  325.                 $tauxOccupationByDate[$indexDay]['tauxOccupationReal'] =  round(($tauxOccupationByDate[$indexDay]['reservation_reel'] * 100) / $tauxOccupationByDate[$indexDay]['resourceDispo'],2);
  326.             }
  327.             $index array_search($item['hour'],array_column($tauxOccupation,'hour'));
  328.             $tauxOccupation[$index]['reservation'] += $item['value'];
  329.             $tauxOccupation[$index]['reservation_reel'] += $item['value_reel'];
  330.             $tauxOccupation[$index]['tauxOccupation'] =  round(($tauxOccupation[$index]['reservation'] * 100) / $tauxOccupation[$index]['resourceDispo'],2);
  331.             $tauxOccupation[$index]['tauxOccupationReal'] =  round(($tauxOccupation[$index]['reservation_reel'] * 100) / $tauxOccupation[$index]['resourceDispo'],2);
  332.             $totalReservation += $item['value'];
  333.         }
  334.         $tauxOccupationDesPickByDate = [];
  335.         foreach ($tauxOccupationByDate as $item) {
  336.             $date = (new \DateTime($item['date']))->format('Y-m-d');
  337.             if (in_array($date,array_column($tauxOccupationDesPickByDate,'date'))) {
  338.                 $index array_search($date,array_column($tauxOccupationDesPickByDate,'date'));
  339.                 if ($tauxOccupationDesPickByDate[$index]['tauxOccupation'] < $item['tauxOccupation']) {
  340.                     $tauxOccupationDesPickByDate[$index]['tauxOccupation'] = $item['tauxOccupation'];
  341.                     $tauxOccupationDesPickByDate[$index]['tauxOccupationReal'] = $item['tauxOccupationReal'];
  342.                 };
  343.             }else {
  344.                 $tauxOccupationDesPickByDate[] = [
  345.                     'date' => $date,
  346.                     'tauxOccupation' => $item['tauxOccupation'],
  347.                     'tauxOccupationReal' => $item['tauxOccupationReal'],
  348.                 ];
  349.             }
  350.         }
  351.         $tauxOccupationDesPickByDateTotal 0;
  352.         foreach ($tauxOccupationDesPickByDate as $item) {
  353.             $tauxOccupationDesPickByDateTotal += $item['tauxOccupation'];
  354.         }
  355.         $tauxOccupationDesPickByDateTotal round($tauxOccupationDesPickByDateTotal sizeof($tauxOccupationDesPickByDate),2);
  356.         
  357.         $tauxOccupationByWeekDay = [];
  358.         foreach ($tauxOccupationByDate as $item) {
  359.             $dayIndex = (new \DateTime($item['date']))->format('N');
  360.             $day $weekDays[$dayIndex];
  361.             if (in_array($day,array_column($tauxOccupationByWeekDay,'day'))) {
  362.                 $index array_search($day,array_column($tauxOccupationByWeekDay,'day'));
  363.                 
  364.                 $tauxOccupationByWeekDay[$index]['reservation'] += $item['reservation'];
  365.                 $tauxOccupationByWeekDay[$index]['reservation_reel'] += $item['reservation_reel'];
  366.                 $tauxOccupationByWeekDay[$index]['resourceDispo'] += $item['resourceDispo'];
  367.             }else {
  368.                 $tauxOccupationByWeekDay[] = [
  369.                     'dayIndex' => $dayIndex,
  370.                     'day' => $day,
  371.                     'reservation' => $item['reservation'],
  372.                     'reservation_reel' => $item['reservation_reel'],
  373.                     'resourceDispo' => $item['resourceDispo'],
  374.                     'tauxOccupation' => 0,
  375.                     'tauxOccupationReal' => 0
  376.                 ];
  377.             }
  378.         }
  379.         foreach ($tauxOccupationByWeekDay as $key => $value) {
  380.             $tauxOccupationByWeekDay[$key]['tauxOccupation'] = round(($value['reservation'] * 100) / $value['resourceDispo'],2);
  381.             $tauxOccupationByWeekDay[$key]['tauxOccupationReal'] = round(($value['reservation_reel'] * 100) / $value['resourceDispo'],2);
  382.         }
  383.         $openMatin = new \DateTime('09:00');
  384.         $closeMatin = new \DateTime('12:00');
  385.         $openAprem = new \DateTime('14:00');
  386.         $closeAprem = new \DateTime('17:00');
  387.         $tauxOccupationReal array_filter($tauxOccupation,function($item) use ($openMatin$closeMatin$openAprem$closeAprem) {
  388.             $hour = new \DateTime($item['hour']);
  389.             return ($hour >= $openMatin && $hour <= $closeMatin) || ($hour >= $openAprem && $hour <= $closeAprem);
  390.         });
  391.         $tauxOccupationTotal 0;
  392.         $tauxOccupationRealTotal 0;
  393.         $totalResourceDispo 0;
  394.         $totalReservationDispo 0;
  395.         foreach ($tauxOccupationReal as $obj) {
  396.             $totalReservationDispo += $obj['reservation'];
  397.             $totalResourceDispo += $obj['resourceDispo'];
  398.         }
  399.         $tauxOccupationRealTotal round(($totalReservationDispo 100) / $totalResourceDispo,2);
  400.         if ($resourceDispoTotal 0)
  401.             $tauxOccupationTotal round(($totalReservation 100) / $resourceDispoTotal,2);
  402.         array_multisort(array_column($tauxOccupation'hour'), SORT_ASC$tauxOccupation);
  403.         array_multisort(array_column($tauxOccupationReal'hour'), SORT_ASC$tauxOccupationReal);
  404.         array_multisort(array_column($tauxOccupationByWeekDay'dayIndex'), SORT_ASC$tauxOccupationByWeekDay);
  405.         array_multisort(array_column($tauxOccupationDesPickByDate'date'), SORT_ASC$tauxOccupationDesPickByDate);
  406.         return new JsonResponse([
  407.             'reservationByDay' => $reservationByDay,
  408.             'topResources' => array_values($topResources),
  409.             'tauxOccupation' => $tauxOccupation,
  410.             'tauxOccupationByWeekDay' => $tauxOccupationByWeekDay,
  411.             'tauxOccupationDesPickByDate' => $tauxOccupationDesPickByDate,
  412.             'tauxOccupationDesPickByDateTotal' => $tauxOccupationDesPickByDateTotal,
  413.             'tauxOccupationReal' => $tauxOccupationReal,
  414.             'tauxOccupationRealTotal' => round($tauxOccupationRealTotal2),
  415.             'tauxOccupationTotal' => round($tauxOccupationTotal2)
  416.         ]);
  417.     }
  418.     public function getBlock() {
  419.         
  420.         //Blocages
  421.         $blocages = []; // $doctrine->getRepository(Block::class)->getBlockageByFilters($request->request->get('resource'),$request->request->get('resourceType'), $request->request->get('localisation'), $request->request->get('startDate'), $request->request->get('endDate'));
  422.         $blockBySite = []; // $doctrine->getRepository(Block::class)->getBlockagesGroppedByResource($request->request->get('resource'),$request->request->get('resourceType'), $request->request->get('localisation'), $request->request->get('startDate'), $request->request->get('endDate'),'Localisation');
  423.         $blockByTypeResource = []; // $doctrine->getRepository(Block::class)->getBlockagesGroppedByResource($request->request->get('resource'),$request->request->get('resourceType'), $request->request->get('localisation'), $request->request->get('startDate'), $request->request->get('endDate'),'Type');
  424.         $blockByType =  []; //$doctrine->getRepository(Block::class)->getBlockageByType($request->request->get('resource'),$request->request->get('resourceType'), $request->request->get('localisation'), $request->request->get('startDate'), $request->request->get('endDate'), $request->getLocale());
  425.         $blockByDates = []; // $doctrine->getRepository(Block::class)->getBlockByDates($request->request->get('resource'),$request->request->get('resourceType'), $request->request->get('localisation'), $request->request->get('startDate'), $request->request->get('endDate'));
  426.         return new JsonResponse([
  427.             'totalBlocks' => sizeof($blocages),
  428.             'blockBySite' => $blockBySite,
  429.             'blockByTypeResource' => $blockByTypeResource,
  430.             'blockByType' => $blockByType,
  431.             'blockByDates' => $blockByDates
  432.         ]);
  433.     }
  434.     #[Route('/getResourcesByFilters'name'getResourcesByFilters')]
  435.     public function getResourcesByFilters(ManagerRegistry $doctrineRequest $request): Response
  436.     {
  437.         $resources $doctrine->getRepository(Resource::class)->findGroupped($request->request->get('localisation'),$request->request->get('resourceType'));
  438.         return $this->render('components/resources-options.html.twig', [
  439.             'resources' => $resources,
  440.         ]);
  441.     }
  442.     #[Route('/getResourceByDates'name'getResourceByDates')]
  443.     public function getResourceByDates(ManagerRegistry $doctrineRequest $request): Response
  444.     {
  445.         $resources $doctrine->getRepository(Resource::class)->getResourceByDates($request->request->get('localisation'),$request->request->get('resourceType'));
  446.         return $this->render('components/resources-options.html.twig', [
  447.             'resources' => $resources,
  448.         ]);
  449.     }
  450. }