src/MDS/GreenPatioBundle/Controller/ReservationsQuoteController.php line 595

Open in your IDE?
  1. <?php
  2. namespace App\MDS\GreenPatioBundle\Controller;
  3. use App\Entity\HtFile;
  4. use App\Entity\ReservationLoungeWebDescription;
  5. use App\Entity\WidgetNotes;
  6. use App\Form\WidgetNotesType;
  7. use App\MDS\AvexpressBundle\Entity\AveFiles;
  8. use App\MDS\GreenPatioBundle\Entity\Reservation;
  9. use App\MDS\GreenPatioBundle\Entity\ReservationLoungeSimple;
  10. use App\MDS\GreenPatioBundle\Entity\ReservationService;
  11. use App\MDS\GreenPatioBundle\Entity\ReservationGpPrice;
  12. use App\MDS\GreenPatioBundle\Entity\ReservationLounge;
  13. use App\MDS\GreenPatioBundle\Entity\ReservationLoungeDetails;
  14. use App\MDS\GreenPatioBundle\Entity\ReservationLoungeProfile;
  15. use App\MDS\GreenPatioBundle\Entity\ReservationPeriod;
  16. use App\MDS\GreenPatioBundle\Form\ReservationGpPriceType;
  17. use App\MDS\GreenPatioBundle\Form\ReservationLoungeDetailsType;
  18. use App\MDS\GreenPatioBundle\Form\ReservationLoungeProfileType;
  19. use App\MDS\GreenPatioBundle\Form\ReservationPeriodType;
  20. use App\MDS\GreenPatioBundle\Form\ReservationType;
  21. use App\Service\SincGpHtAvService;
  22. use Doctrine\ORM\EntityManagerInterface;
  23. use Symfony\Component\Routing\Annotation\Route;
  24. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  25. use Symfony\Component\HttpFoundation\Request;
  26. use DateTime;
  27. use DatePeriod;
  28. use DateInterval;
  29. use Google_Client;
  30. use Google_Service_Calendar;
  31. use Symfony\Contracts\Translation\TranslatorInterface;
  32. use Symfony\Component\HttpFoundation\JsonResponse;
  33. class ReservationsQuoteController extends AbstractController
  34. {
  35.     public function __construct(TranslatorInterface $translator,  SincGpHtAvService $sincGpHtAvService)
  36.     {
  37.         $redirect_uri 'https://' $_SERVER['HTTP_HOST']. '/calendar/token';
  38.         $googleCalendar = new Google_Client();
  39.         $googleCalendar->setApplicationName('Google Calendar API PHP Quickstart');
  40.         //campos a extraer de la base de datos User
  41.         $googleCalendar->setClientId('2790497987-57qc3vu4pr7vb0s8phpub2me58pe34lb.apps.googleusercontent.com');
  42.         $googleCalendar->setClientSecret('nj2C7unaTO68DRhyORsyipSj');
  43.         //fin campos user
  44. //        $api_key = "AIzaSyBR84cS1IU2BPvk5V3VnbqdkJESlv440Ac";
  45. //        $client->setDeveloperKey($api_key);
  46.         $googleCalendar->setRedirectUri($redirect_uri);
  47.         $googleCalendar->addScope(Google_Service_Calendar::CALENDAR);
  48.         $guzzleClient = new \GuzzleHttp\Client(array('curl' => array(CURLOPT_SSL_VERIFYPEER => false)));
  49.         $googleCalendar->setHttpClient($guzzleClient);
  50.         $this->googleCalendar $googleCalendar;
  51.         $this->translator $translator;
  52.         $this->sincGpHtAvService $sincGpHtAvService;
  53.     }
  54.     private $sincGpHtAvService;
  55.     /**
  56.      * @Route("/createsimplelounge/{id}", name="reservations_greenpatio_create_simple_lounge")
  57.      * Crea un Reservation Lounge Simple en la cotizacion
  58.      */
  59.     public function createSimpleLoungeAction($idEntityManagerInterface $emRequest $request)
  60.     {
  61.         $simpleLounge $request->request->get('reservation_sala');
  62.         $loungeProfile $em->getRepository(ReservationLoungeDetails::class)->findOneById($simpleLounge['salaPrecargadas']);
  63.         $loungeId $loungeProfile->getId();
  64.         $loungeDetails $em->getRepository(ReservationLoungeDetails::class)->findOneById($loungeId);
  65.         $previusLoungeSimple $em->getRepository(ReservationLoungeSimple::class)->findOneBy(array('idLounge' => $loungeId'idReservation' => $id'rankQuote' => $simpleLounge['idQuote']));
  66.         //Buscamos si hay ya alguna sala en la reserva
  67.         $anyLoungeSimple $em->getRepository(ReservationLoungeSimple::class)->findOneBy(array('idLounge' => $loungeId'idReservation' => $id));
  68.         $idioma 1;
  69.         if($anyLoungeSimple){
  70.             $idioma $anyLoungeSimple->getLanguage();
  71.         }
  72.         $loungeWebDescription $em->getRepository(ReservationLoungeWebDescription::class)->findOneBy(array('lounge' => $loungeProfile'language' => $idioma));
  73.         $loungeName $loungeDetails->getName();
  74.         $hourMinStart $simpleLounge['hourStart'];
  75.         $hourMinEnd $simpleLounge['hourEnd'];
  76.         $loungeSummaryDescription array_key_exists('importantDescription'$simpleLounge) ? $simpleLounge['importantDescription'] : null;
  77.         if (empty($previusLoungeSimple)) {
  78.             if (empty($loungeSummaryDescription)) { $loungeSummaryDescription $loungeWebDescription->getImportantDescription(); }
  79.             $loungeImportantDescGeneralText $loungeWebDescription->getImportantDescGeneralText();
  80.             $loungeImportantDescSchedules $loungeWebDescription->getImportantDescSchedules();
  81.             $loungeImportantDescParking $loungeWebDescription->getImportantDescParking();
  82.         } else {
  83.             $loungeSummaryDescription $previusLoungeSimple->getImportantDescription();
  84.             $loungeImportantDescGeneralText $previusLoungeSimple->getImportantDescGeneralText();
  85.             $loungeImportantDescSchedules $previusLoungeSimple->getImportantDescSchedules();
  86.             $loungeImportantDescParking $previusLoungeSimple->getImportantDescParking();
  87.         }
  88.         
  89.         $iva 21;
  90.         if (array_key_exists('iva'$simpleLounge)) {
  91.             if (empty($simpleLounge['iva']) && !is_numeric($simpleLounge['iva'])) {
  92.                 $iva 21;
  93.             } else {
  94.                 $iva $simpleLounge['iva'];
  95.             }
  96.         }
  97.         $qb $em->getRepository(ReservationLoungeSimple::class)->createQueryBuilder('r');
  98.         $reservationAll $qb->where('r.idReservation = :idReservation')
  99.             ->setParameter('idReservation'$id)
  100.             ->orderBy('r.rankQuote''ASC')
  101.             ->getQuery()
  102.             ->getResult();
  103.         $newRankId = (!empty($reservationAll)) ? (end($reservationAll)->getRankQuote() + 1) : 1;
  104.         if (!empty($simpleLounge['idQuote'])){ if (is_numeric($simpleLounge['idQuote'])){ $newRankId $simpleLounge['idQuote']; } }
  105.         // Autocompletacion HH:mm en Start
  106.         switch (strlen($hourMinStart)) {
  107.             case 0:
  108.                 // Vacio
  109.                 $hourStart '00'$minStart '00'$hourMinStart '00:00';
  110.                 break;
  111.             case 1:
  112.                 // H  -> 0H:00
  113.                 if (is_numeric($hourMinStart)){
  114.                     $hourStart '0'.$hourMinStart$minStart '00'$hourMinStart $hourStart.':'.$minStart;
  115.                 } else {
  116.                     $hourStart '00'$minStart '00'$hourMinStart '00:00';
  117.                 }
  118.                 break;
  119.             case 2:
  120.                 // HH  -> HH:00
  121.                 if (is_numeric($hourMinStart)){
  122.                     $hourStart $hourMinStart$minStart '00'$hourMinStart $hourStart.':'.$minStart;
  123.                 } else {
  124.                     $hourStart '00'$minStart '00'$hourMinStart '00:00';
  125.                 }
  126.                 break;
  127.             case 3:
  128.                 // Hmm  -> 0H:mm
  129.                 if (is_numeric($hourMinStart)){
  130.                     $hourStart '0'.substr($hourMinStart,0,1); $minStart substr($hourMinStart,1,2); $hourMinStart $hourStart.':'.$minStart;
  131.                 } else {
  132.                     $hourStart '00'$minStart '00'$hourMinStart '00:00';
  133.                 }
  134.                 break;
  135.             case 4:
  136.                 // HHmm  -> HH:mm
  137.                 if (is_numeric($hourMinStart)){
  138.                     $hourStart substr($hourMinStart,0,2); $minStart substr($hourMinStart,2,2); $hourMinStart $hourStart.':'.$minStart;
  139.                 } else {
  140.                     $hourStart '00'$minStart '00'$hourMinStart '00:00';
  141.                 }
  142.                 break;
  143.             case 5:
  144.                 // HH:mm
  145.                 if (is_numeric(substr($hourMinStart,0,2)) and (substr($hourMinStart,2,1)==':') and is_numeric(substr($hourMinStart,0,2))){
  146.                     $hourStart substr($hourMinStart,0,2); $minStart substr($hourMinStart,3,2); $hourMinStart $hourStart.':'.$minStart;
  147.                 } else {
  148.                     $hourStart '00'$minStart '00'$hourMinStart '00:00';
  149.                 }
  150.                 break;
  151.             default:
  152.                 // XXXXyyy
  153.                 $hourStart '00'$minStart '00'$hourMinStart '00:00';
  154.                 break;
  155.         }
  156.         // Autocompletacion HH:mm en End
  157.         switch (strlen($hourMinEnd)) {
  158.             case 0:
  159.                 // Vacio
  160.                 $hourEnd '00'$minEnd '00'$hourMinEnd '00:00';
  161.                 break;
  162.             case 1:
  163.                 // H  -> 0H:00
  164.                 if (is_numeric($hourMinEnd)){
  165.                     $hourEnd '0'.$hourMinEnd$minEnd '00'$hourMinEnd $hourEnd.':'.$minEnd;
  166.                 } else {
  167.                     $hourEnd '00'$minEnd '00'$hourMinEnd '00:00';
  168.                 }
  169.                 break;
  170.             case 2:
  171.                 // HH  -> HH:00
  172.                 if (is_numeric($hourMinEnd)){
  173.                     $hourEnd $hourMinEnd$minEnd '00'$hourMinEnd $hourEnd.':'.$minEnd;
  174.                 } else {
  175.                     $hourEnd '00'$minEnd '00'$hourMinEnd '00:00';
  176.                 }
  177.                 break;
  178.             case 3:
  179.                 // Hmm  -> 0H:mm
  180.                 if (is_numeric($hourMinEnd)){
  181.                     $hourEnd '0'.substr($hourMinEnd,0,1); $minEnd substr($hourMinEnd,1,2); $hourMinEnd $hourEnd.':'.$minEnd;
  182.                 } else {
  183.                     $hourEnd '00'$minEnd '00'$hourMinEnd '00:00';
  184.                 }
  185.                 break;
  186.             case 4:
  187.                 // HHmm  -> HH:mm
  188.                 if (is_numeric($hourMinEnd)){
  189.                     $hourEnd substr($hourMinEnd,0,2); $minEnd substr($hourMinEnd,2,2); $hourMinEnd $hourEnd.':'.$minEnd;
  190.                 } else {
  191.                     $hourEnd '00'$minEnd '00'$hourMinEnd '00:00';
  192.                 }
  193.                 break;
  194.             case 5:
  195.                 // HH:mm
  196.                 if (is_numeric(substr($hourMinEnd,0,2)) and (substr($hourMinEnd,2,1)==':') and is_numeric(substr($hourMinEnd,0,2))){
  197.                     $hourEnd substr($hourMinEnd,0,2); $minEnd substr($hourMinEnd,3,2); $hourMinEnd $hourEnd.':'.$minEnd;
  198.                 } else {
  199.                     $hourEnd '00'$minEnd '00'$hourMinEnd '00:00';
  200.                 }
  201.                 break;
  202.             default:
  203.                 // XXXXyyy
  204.                 $hourEnd '00'$minEnd '00'$hourMinEnd '00:00';
  205.                 break;
  206.         }
  207.         $dateStart = new DateTime($simpleLounge['dateStart'] . ' '$hourMinStart);
  208.         $dateEnd = new DateTime($simpleLounge['dateStart'] . ' '$hourMinEnd);   // Se usa DateStart por que solo hay un dia en el formulario
  209.         $idService 0;
  210.         $serviceName '';
  211.         $servicePrice = (empty($simpleLounge['servicePrice'])) ? :$simpleLounge['servicePrice'];
  212.         $idReservation $id;
  213.         /* Obtengo usuario logueado */
  214.         $user_logueado $this->get('security.token_storage')->getToken()->getUser();
  215.         $user_id $user_logueado->getId();
  216.         $createdAt = new DateTime('now');
  217.         $createdBy $user_id;
  218.         $updatedAt = new DateTime('now');
  219.         $updatedBy $user_id;
  220.         $pax $simpleLounge['pax']; if (empty($pax)){$pax 0;}
  221.         $lounge = new ReservationLoungeSimple();
  222.         $lounge->setIdLounge ($loungeId);
  223.         $lounge->setHourStart ($hourStart);
  224.         $lounge->setMinStart ($minStart);
  225.         $lounge->setHourEnd ($hourEnd);
  226.         $lounge->setMinEnd ($minEnd);
  227.         $lounge->setLoungeName ($loungeName);
  228.         $lounge->setDateStart ($dateStart);
  229.         $lounge->setDateEnd ($dateEnd);
  230.         $lounge->setRankQuote(1);
  231.         $lounge->setIdReservation ($idReservation);
  232.         $lounge->setIva($iva);
  233.         $lounge->setOpIva(1);
  234.         $lounge->setCreatedAt ($createdAt);
  235.         $lounge->setCreatedBy ($createdBy);
  236.         $lounge->setUpdatedAt ($updatedAt);
  237.         $lounge->setUpdatedBy ($updatedBy);
  238.         $lounge->setPax ($pax);
  239.         $lounge->setRankQuote($newRankId);
  240.         $lounge->setImportantDescription($loungeSummaryDescription);
  241.         $lounge->setImportantDescGeneralText($loungeImportantDescGeneralText);
  242.         $lounge->setImportantDescSchedules($loungeImportantDescSchedules);
  243.         $lounge->setImportantDescParking($loungeImportantDescParking);
  244.         $price $this->precioTarifario($dateStart$loungeId$servicePrice);
  245.         $lounge->setServicePrice($price);
  246. //    *-+*-+*-+*-+ agregar mensajereservationerror si choca con alguna sala en confirmado o facturado
  247.         try{
  248.             $em->persist($lounge);
  249.             $em->flush();
  250.             $event 'The Reservation has been updated.';
  251.             $successMessage $this->translator->trans($event);
  252.             $this->addFlash('mensajereservation'$successMessage);
  253.         } catch (\Exception $e){
  254.             $event 'An error occurred: '.$e->getMessage();
  255.             $errorMessage $this->translator->trans($event);
  256.             $this->addFlash('mensajereservationerror'$errorMessage);
  257.         }
  258.         // INICIO: Actualizacion de fecha de inicio y fin del evento, a partir de la info de la sala
  259.         $boolSincGpAv false;
  260.         $reserva $em->getRepository(Reservation::class)->findOneById($idReservation);
  261.         if ($reserva->getDateStart() > $dateStart){ $reserva->setDateStart($dateStart); $boolSincGpAv true; }
  262.         if ($reserva->getDateStart()->format('Y') == '2078' ){ $reserva->setDateStart($dateStart); $boolSincGpAv true; }
  263.         if ($reserva->getDateEnd() < $dateEnd){ $reserva->setDateEnd($dateEnd); $boolSincGpAv true; }
  264.         if ($reserva->getDateEnd()->format('Y') == '2000' ){ $reserva->setDateEnd($dateEnd); $boolSincGpAv true; }
  265.         try{
  266.             $em->persist($reserva);
  267.             $em->flush();
  268.             $event '';
  269.             $successMessage $this->translator->trans($event);
  270.             $this->addFlash('mensajereservation'$successMessage);
  271.         } catch (\Exception $e){}
  272.         // Sincronización global de todos los campos
  273.         if ($boolSincGpAv){
  274.             $data $this->sincGpHtAvService->sincGlobalGpHtAv($id);
  275.         }
  276.         // Sincronización con Av Express
  277.         if ($boolSincGpAv) {
  278.             $AveFile $em->getRepository(AveFiles::class)->findByReservation($reserva);
  279.             if (($reserva->getStatus() == 'Confirmed') or ($reserva->getStatus() == 'Cotizado') or ($reserva->getStatus() == 'Invoiced') or ($reserva->getStatus() == 'Bloqueo')) {
  280.                 if (empty($AveFile)) {
  281.                     // Si no se ha creado aun el expediente de Av Express debemos crearlo
  282.                     return $this->redirectToRoute('sinc_gp_ave', array('id' => $id,));
  283.                 }
  284.             }
  285.         }
  286.         // FIN: Actualizacion de fecha de inicio y fin del evento, a partir de la info de la sala
  287.         // Se debe redirigir para agregar el Servicio de limpieza
  288.         return $this->redirectToRoute('reservations_white_addservices_cleaning',
  289.             array(
  290.                 'resid' => $id,
  291.                 'loungesimpleid' => $lounge->getId(),
  292.             ));
  293.     }
  294.     /**
  295.      * @Route("/api/get-price", name="get_reservations_price_to_view", methods={"GET"})
  296.      */
  297.     public function getPrice(Request $request)
  298.     {
  299.         $loungeId $request->query->get('sala');
  300.         $dateStart $request->query->get('date');
  301.         if (!$loungeId || !$dateStart) {
  302.             return new JsonResponse(['error' => 'Missing parameters'], 400);
  303.         }
  304.         try {
  305.             $dateStartObj = new \DateTime($dateStart);
  306.         } catch (\Exception $e) {
  307.             return new JsonResponse(['error' => 'Invalid date'], 400);
  308.         }
  309.         $price $this->precioTarifario($dateStartObj$loungeId0);
  310.         return new JsonResponse(['price' => $price]);
  311.     }
  312.     /**
  313.      * @Route("/createsimpleloungemondes/{id}", name="reservations_greenpatio_create_simple_lounge_mondes")
  314.      * Se crea un dia de montaje o desmontaje
  315.      */
  316.     public function createSimpleLoungeMonDesAction($idEntityManagerInterface $emRequest $request)
  317.     {
  318.         $simpleLounge $request->request->get('reservation_sala_mondes');
  319.         $loungeId $simpleLounge['idLounge'];
  320.         $loungeDetails $em->getRepository(ReservationLoungeDetails::class)->findOneById($loungeId);
  321.         $previusLoungeSimple $em->getRepository(ReservationLoungeSimple::class)->findOneBy(array('idLounge' => $loungeId'idReservation' => $id'rankQuote' => $simpleLounge['idQuote']));
  322.         $loungeName $loungeDetails->getName();
  323.         $hourMinStart $simpleLounge['hourStart'];
  324.         $hourMinEnd $simpleLounge['hourEnd'];
  325.         $ivaNew = empty($simpleLounge['iva']) ? 21 $simpleLounge['iva'];
  326.         if (empty($previusLoungeSimple)) {
  327.             $loungeSummaryDescription $loungeDetails->getImportantDescription();
  328.             $loungeImportantDescGeneralText $loungeDetails->getImportantDescGeneralText();
  329.             $loungeImportantDescSchedules $loungeDetails->getImportantDescSchedules();
  330.             $loungeImportantDescParking $loungeDetails->getImportantDescParking();
  331.         } else {
  332.             $loungeSummaryDescription $previusLoungeSimple->getImportantDescription();
  333.             $loungeImportantDescGeneralText $previusLoungeSimple->getImportantDescGeneralText();
  334.             $loungeImportantDescSchedules $previusLoungeSimple->getImportantDescSchedules();
  335.             $loungeImportantDescParking $previusLoungeSimple->getImportantDescParking();
  336.         }
  337.         $qb $em->getRepository(ReservationLoungeSimple::class)->createQueryBuilder('r');
  338.         $reservationAll $qb->where('r.idReservation = :idReservation')
  339.             ->setParameter('idReservation'$id)
  340.             ->orderBy('r.rankQuote''ASC')
  341.             ->getQuery()
  342.             ->getResult();
  343.         $newRankId = (!empty($reservationAll)) ? (end($reservationAll)->getRankQuote() + 1) : 1;
  344.         if (!empty($simpleLounge['idQuote'])){ if (is_numeric($simpleLounge['idQuote'])){ $newRankId $simpleLounge['idQuote']; } }
  345.         // Autocompletacion HH:mm en Start
  346.         switch (strlen($hourMinStart)) {
  347.             case 0:
  348.                 // Vacio
  349.                 $hourStart '00'$minStart '00'$hourMinStart '00:00';
  350.                 break;
  351.             case 1:
  352.                 // H  -> 0H:00
  353.                 if (is_numeric($hourMinStart)){
  354.                     $hourStart '0'.$hourMinStart$minStart '00'$hourMinStart $hourStart.':'.$minStart;
  355.                 } else {
  356.                     $hourStart '00'$minStart '00'$hourMinStart '00:00';
  357.                 }
  358.                 break;
  359.             case 2:
  360.                 // HH  -> HH:00
  361.                 if (is_numeric($hourMinStart)){
  362.                     $hourStart $hourMinStart$minStart '00'$hourMinStart $hourStart.':'.$minStart;
  363.                 } else {
  364.                     $hourStart '00'$minStart '00'$hourMinStart '00:00';
  365.                 }
  366.                 break;
  367.             case 3:
  368.                 // Hmm  -> 0H:mm
  369.                 if (is_numeric($hourMinStart)){
  370.                     $hourStart '0'.substr($hourMinStart,0,1); $minStart substr($hourMinStart,1,2); $hourMinStart $hourStart.':'.$minStart;
  371.                 } else {
  372.                     $hourStart '00'$minStart '00'$hourMinStart '00:00';
  373.                 }
  374.                 break;
  375.             case 4:
  376.                 // HHmm  -> HH:mm
  377.                 if (is_numeric($hourMinStart)){
  378.                     $hourStart substr($hourMinStart,0,2); $minStart substr($hourMinStart,2,2); $hourMinStart $hourStart.':'.$minStart;
  379.                 } else {
  380.                     $hourStart '00'$minStart '00'$hourMinStart '00:00';
  381.                 }
  382.                 break;
  383.             case 5:
  384.                 // HH:mm
  385.                 if (is_numeric(substr($hourMinStart,0,2)) and (substr($hourMinStart,2,1)==':') and is_numeric(substr($hourMinStart,0,2))){
  386.                     $hourStart substr($hourMinStart,0,2); $minStart substr($hourMinStart,3,2); $hourMinStart $hourStart.':'.$minStart;
  387.                 } else {
  388.                     $hourStart '00'$minStart '00'$hourMinStart '00:00';
  389.                 }
  390.                 break;
  391.             default:
  392.                 // XXXXyyy
  393.                 $hourStart '00'$minStart '00'$hourMinStart '00:00';
  394.                 break;
  395.         }
  396.         // Autocompletacion HH:mm en End
  397.         switch (strlen($hourMinEnd)) {
  398.             case 0:
  399.                 // Vacio
  400.                 $hourEnd '00'$minEnd '00'$hourMinEnd '00:00';
  401.                 break;
  402.             case 1:
  403.                 // H  -> 0H:00
  404.                 if (is_numeric($hourMinEnd)){
  405.                     $hourEnd '0'.$hourMinEnd$minEnd '00'$hourMinEnd $hourEnd.':'.$minEnd;
  406.                 } else {
  407.                     $hourEnd '00'$minEnd '00'$hourMinEnd '00:00';
  408.                 }
  409.                 break;
  410.             case 2:
  411.                 // HH  -> HH:00
  412.                 if (is_numeric($hourMinEnd)){
  413.                     $hourEnd $hourMinEnd$minEnd '00'$hourMinEnd $hourEnd.':'.$minEnd;
  414.                 } else {
  415.                     $hourEnd '00'$minEnd '00'$hourMinEnd '00:00';
  416.                 }
  417.                 break;
  418.             case 3:
  419.                 // Hmm  -> 0H:mm
  420.                 if (is_numeric($hourMinEnd)){
  421.                     $hourEnd '0'.substr($hourMinEnd,0,1); $minEnd substr($hourMinEnd,1,2); $hourMinEnd $hourEnd.':'.$minEnd;
  422.                 } else {
  423.                     $hourEnd '00'$minEnd '00'$hourMinEnd '00:00';
  424.                 }
  425.                 break;
  426.             case 4:
  427.                 // HHmm  -> HH:mm
  428.                 if (is_numeric($hourMinEnd)){
  429.                     $hourEnd substr($hourMinEnd,0,2); $minEnd substr($hourMinEnd,2,2); $hourMinEnd $hourEnd.':'.$minEnd;
  430.                 } else {
  431.                     $hourEnd '00'$minEnd '00'$hourMinEnd '00:00';
  432.                 }
  433.                 break;
  434.             case 5:
  435.                 // HH:mm
  436.                 if (is_numeric(substr($hourMinEnd,0,2)) and (substr($hourMinEnd,2,1)==':') and is_numeric(substr($hourMinEnd,0,2))){
  437.                     $hourEnd substr($hourMinEnd,0,2); $minEnd substr($hourMinEnd,3,2); $hourMinEnd $hourEnd.':'.$minEnd;
  438.                 } else {
  439.                     $hourEnd '00'$minEnd '00'$hourMinEnd '00:00';
  440.                 }
  441.                 break;
  442.             default:
  443.                 // XXXXyyy
  444.                 $hourEnd '00'$minEnd '00'$hourMinEnd '00:00';
  445.                 break;
  446.         }
  447.         $dateStart = new DateTime($simpleLounge['dateStart'] . ' '$hourMinStart);
  448.         $dateEnd = new DateTime($simpleLounge['dateStart'] . ' '$hourMinEnd);   // Se usa DateStart por que solo hay un dia en el formulario
  449.         $servicePrice = empty($simpleLounge['servicePrice']) ? :$simpleLounge['servicePrice'];
  450.         $idReservation $id;
  451.         /* Obtengo usuario logueado */
  452.         $user_logueado $this->get('security.token_storage')->getToken()->getUser();
  453.         $user_id $user_logueado->getId();
  454.         $createdAt = new DateTime('now');
  455.         $createdBy $user_id;
  456.         $updatedAt = new DateTime('now');
  457.         $updatedBy $user_id;
  458.         $lounge = new ReservationLoungeSimple();
  459.         if ($simpleLounge['type'] == 'Montaje'){ $lounge->setType ('Montaje'); } else {  $lounge->setType ('Desmontaje'); }
  460.         $pax null;
  461.         $lounge->setIdLounge ($loungeId);
  462.         $lounge->setHourStart ($hourStart);
  463.         $lounge->setMinStart ($minStart);
  464.         $lounge->setHourEnd ($hourEnd);
  465.         $lounge->setMinEnd ($minEnd);
  466.         $lounge->setLoungeName ($loungeName);
  467.         $lounge->setDateStart ($dateStart);
  468.         $lounge->setDateEnd ($dateEnd);
  469.         $lounge->setRankQuote(1);
  470.         $lounge->setIva($ivaNew);
  471.         $lounge->setOpIva(1);
  472.         $lounge->setIdReservation ($idReservation);
  473.         $lounge->setCreatedAt ($createdAt);
  474.         $lounge->setCreatedBy ($createdBy);
  475.         $lounge->setUpdatedAt ($updatedAt);
  476.         $lounge->setUpdatedBy ($updatedBy);
  477.         $lounge->setPax ($pax);
  478.         $lounge->setRankQuote($newRankId);
  479.         $lounge->setImportantDescription($loungeSummaryDescription);
  480.         $lounge->setImportantDescGeneralText($loungeImportantDescGeneralText);
  481.         $lounge->setImportantDescSchedules($loungeImportantDescSchedules);
  482.         $lounge->setImportantDescParking($loungeImportantDescParking);
  483.         $price $this->precioPorFecha($dateStart$loungeId);
  484.         $servicePrice = ($price['price'] == 0) ? $servicePrice $price;
  485.         $lounge->setServicePrice($servicePrice);
  486.         try{
  487.             $em->persist($lounge);
  488.             $em->flush();
  489.             $event 'The Reservation has been updated.';
  490.             $successMessage $this->translator->trans($event);
  491.             $this->addFlash('mensajereservation'$successMessage);
  492.         } catch (\Exception $e){
  493.             $event 'An error occurred: '.$e->getMessage();
  494.             $errorMessage $this->translator->trans($event);
  495.             $this->addFlash('mensajereservationerror'$errorMessage);
  496.         }
  497.         $reservax $em->getRepository(Reservation::class)->findOneById($idReservation);
  498.         // INICIO: Verificamos si es necesario actualizar las fechas de la reserva
  499.         $boolReserva false;
  500.         if ($lounge->getDateStart() < $reservax->getDateStart()){
  501.             $reservax->setDateStart($lounge->getDateStart());
  502.             $boolReserva true;
  503.         }
  504.         if ($reservax->getDateEnd() < $lounge->getDateEnd()){
  505.             $reservax->setDateEnd($lounge->getDateEnd());
  506.             $boolReserva true;
  507.         }
  508.         if ($boolReserva){
  509.             $em->persist($reservax);
  510.             $em->flush();
  511.             // Sincronización global de todos los campos
  512.             $data $this->sincGpHtAvService->sincGlobalGpHtAv($id);
  513.         }
  514.         $boolSincGpAv $boolReserva;
  515.         // Sincronización con Av Express
  516.         if ($boolSincGpAv) {
  517.             $AveFile $em->getRepository(AveFiles::class)->findByReservation($reservax);
  518.             if (($reservax->getStatus() == 'Confirmed') or ($reservax->getStatus() == 'Cotizado') or ($reservax->getStatus() == 'Invoiced') or ($reservax->getStatus() == 'Bloqueo')) {
  519.                 if (empty($AveFile)) {
  520.                     // Si no se ha creado aun el expediente de Av Express debemos crearlo
  521.                     return $this->redirectToRoute('sinc_gp_ave', array('id' => $id,));
  522.                 }
  523.             }
  524.         }
  525.         // FIN: Verificamos si es necesario actualizar las fechas de la reserva
  526.         return $this->redirectToRoute('reservations_greenpatio_edit_simple',
  527.             array(
  528.                 'id' => $id,
  529.                 'token' => null,
  530.                 '_fragment' => 'btn_quotes'
  531.             ));
  532.     }
  533.     /**
  534.      * @Route("/duplicateday/{id}/{dayduplicate}/{idRankQuote}", name="reservations_greenpatio_duplicate_day")
  535.      * Duplica un elemento de la cotizacion para el dia siguiente
  536.      */
  537.     public function duplicateDayAction($id$dayduplicate$idRankQuoteEntityManagerInterface $emRequest $request)
  538.     {
  539.         $loungeSimples $em->getRepository(ReservationLoungeSimple::class)->findByIdReservation($id);
  540.         $reservax $em->getRepository(Reservation::class)->findOneById($id);
  541.         /* Obtengo usuario logueado */
  542.         $user_logueado $this->get('security.token_storage')->getToken()->getUser();
  543.         $user_id $user_logueado->getId();
  544.         $createdAt = new DateTime('now');
  545.         $createdBy $user_id;
  546.         $updatedAt = new DateTime('now');
  547.         $updatedBy $user_id;
  548.         if (!empty($loungeSimples)){
  549.             foreach ($loungeSimples as $item){
  550.                 if (($item->getDateStart()->format('d-m-Y') == $dayduplicate) and ($item->getRankQuote() == $idRankQuote)){
  551.                     // Se duplica y suma un dia
  552.                     $newLoungeSimple = new ReservationLoungeSimple();
  553.                     $newLoungeSimple->setDateStart($item->getDateStart()->modify('+1 day'));
  554.                     $newLoungeSimple->setDateEnd($item->getDateEnd()->modify('+1 day'));
  555.                     $newLoungeSimple->setHourStart($item->getHourStart());
  556.                     $newLoungeSimple->setHourEnd($item->getHourEnd());
  557.                     $newLoungeSimple->setMinStart($item->getMinStart());
  558.                     $newLoungeSimple->setMinEnd($item->getMinEnd());
  559.                     $newLoungeSimple->setIdLounge($item->getIdLounge());
  560.                     $newLoungeSimple->setIdReservation($item->getIdReservation());
  561.                     $newLoungeSimple->setLoungeName($item->getLoungeName());
  562.                     $newLoungeSimple->setPax($item->getPax());
  563.                     $newLoungeSimple->setServicePrice($item->getServicePrice());
  564.                     $newLoungeSimple->setIva($item->getIva());
  565.                     $newLoungeSimple->setOpIva($item->getOpIva());
  566.                     $newLoungeSimple->setType($item->getType());
  567.                     $newLoungeSimple->setLoungeDescription($item->getLoungeDescription());
  568.                     $newLoungeSimple->setImportantDescription($item->getImportantDescription());
  569.                     $newLoungeSimple->setImportantDescGeneralText($item->getImportantDescGeneralText());
  570.                     $newLoungeSimple->setImportantDescSchedules($item->getImportantDescSchedules());
  571.                     $newLoungeSimple->setImportantDescParking($item->getImportantDescParking());
  572.                     $newLoungeSimple->setRankQuote($idRankQuote);
  573.                     $newLoungeSimple->setCreatedAt($createdAt);
  574.                     $newLoungeSimple->setCreatedBy($createdBy);
  575.                     $newLoungeSimple->setUpdatedAt($updatedAt);
  576.                     $newLoungeSimple->setUpdatedBy($updatedBy);
  577.                     try{
  578.                         $em->persist($newLoungeSimple);
  579.                         $em->flush();
  580.                         $event 'The Item has been duplicated.';
  581.                         $successMessage $this->translator->trans($event);
  582.                         $this->addFlash('mensajereservation'$successMessage);
  583.                     } catch (\Exception $e){
  584.                         $event 'An error occurred: '.$e->getMessage();
  585.                         $errorMessage $this->translator->trans($event);
  586.                         $this->addFlash('mensajereservationerror'$errorMessage);
  587.                     }
  588.                     // INICIO: Verificamos si es necesario actualizar las fechas de la reserva
  589.                     $boolReserva false;
  590.                     if ($newLoungeSimple->getDateStart() < $reservax->getDateStart()){
  591.                         $reservax->setDateStart($newLoungeSimple->getDateStart());
  592.                         $boolReserva true;
  593.                     }
  594.                     if ($reservax->getDateEnd() < $newLoungeSimple->getDateEnd()){
  595.                         $reservax->setDateEnd($newLoungeSimple->getDateEnd());
  596.                         $boolReserva true;
  597.                     }
  598.                     if ($boolReserva){
  599.                         $em->persist($reservax);
  600.                         $em->flush();
  601.                         // Sincronización global de todos los campos
  602.                         $data $this->sincGpHtAvService->sincGlobalGpHtAv($id);
  603.                     }
  604.                     // FIN: Verificamos si es necesario actualizar las fechas de la reserva
  605.                 }
  606.             }
  607.         } else {
  608.             // registro antiguo, se pasara a los nuevos registros y luego duplicara
  609.             $loungeOld $em->getRepository(ReservationLounge::class)->findByIdReservation($id);
  610.             foreach ($loungeOld as $item){
  611.                 if ($item->getDateStart()->format('Y-m-d') == $item->getDateEnd()->format('Y-m-d')){
  612.                     // Es el mismo dia, se crea un registro simple
  613.                     $newLoungeSimple = new ReservationLoungeSimple();
  614.                     $newLoungeSimple->setDateStart($item->getDateStart());
  615.                     $newLoungeSimple->setDateEnd($item->getDateEnd());
  616.                     $newLoungeSimple->setHourStart($item->getHourStart());
  617.                     $newLoungeSimple->setHourEnd($item->getHourEnd());
  618.                     $newLoungeSimple->setMinStart($item->getMinStart());
  619.                     $newLoungeSimple->setMinEnd($item->getMinEnd());
  620.                     $newLoungeSimple->setIdLounge($item->getIdLounge());
  621.                     $newLoungeSimple->setIdReservation($item->getIdReservation());
  622.                     $newLoungeSimple->setLoungeName($item->getLoungeName());
  623.                     $newLoungeSimple->setPax($item->getPax());
  624.                     $newLoungeSimple->setServicePrice($item->getServicePrice());
  625.                     $newLoungeSimple->setIva($item->getIva());
  626.                     $newLoungeSimple->setOpIva($item->getOpIva());
  627.                     $newLoungeSimple->setType($item->getType());
  628.                     $newLoungeSimple->setRankQuote($item->getRankQuote());
  629.                     $newLoungeSimple->setLoungeDescription($item->getLoungeDescription());
  630.                     $newLoungeSimple->setImportantDescription($item->getImportantDescription());
  631.                     $newLoungeSimple->setCreatedAt($createdAt);
  632.                     $newLoungeSimple->setCreatedBy($createdBy);
  633.                     $newLoungeSimple->setUpdatedAt($updatedAt);
  634.                     $newLoungeSimple->setUpdatedBy($updatedBy);
  635.                     try{
  636.                         $em->persist($newLoungeSimple);
  637.                         $em->flush();
  638.                         $event 'The Item has been duplicated.';
  639.                         $successMessage $this->translator->trans($event);
  640.                         $this->addFlash('mensajereservation'$successMessage);
  641.                     } catch (\Exception $e){
  642.                         $event 'An error occurred: '.$e->getMessage();
  643.                         $errorMessage $this->translator->trans($event);
  644.                         $this->addFlash('mensajereservationerror'$errorMessage);
  645.                     }
  646.                     // INICIO: Verificamos si es necesario actualizar las fechas de la reserva
  647.                     $boolReserva false;
  648.                     if ($newLoungeSimple->getDateStart() < $reservax->getDateStart()){
  649.                         $reservax->setDateStart($newLoungeSimple->getDateStart());
  650.                         $boolReserva true;
  651.                     }
  652.                     if ($reservax->getDateEnd() < $newLoungeSimple->getDateEnd()){
  653.                         $reservax->setDateEnd($newLoungeSimple->getDateEnd());
  654.                         $boolReserva true;
  655.                     }
  656.                     if ($boolReserva){
  657.                         $em->persist($reservax);
  658.                         $em->flush();
  659.                     }
  660.                     // FIN: Verificamos si es necesario actualizar las fechas de la reserva
  661.                 } else {
  662.                     // Registro con varios dias, se calcula el numero de dias y se crean ese numero de registros nuevos
  663.                     $firstDay $item->getDateStart();
  664.                     $firstDay = new DateTime($firstDay->format('Y-m-d'));
  665.                     $lastDay $item->getDateEnd();
  666.                     $lastDay = new DateTime($lastDay->format('Y-m-d'));
  667.                     $numDays = ((($lastDay)->diff($firstDay))->days) +1;
  668.                     $actualDay $item->getDateStart();
  669.                     $actualStartDay $item->getDateStart();
  670.                     $actualEndDay $item->getDateEnd();
  671.                     for ($i=0$i<sizeof($numDays); $i++){
  672.                         // Se crea un registro por cada dia
  673.                         $newLoungeSimple = new ReservationLoungeSimple();
  674.                         if ($i == 0){
  675.                             // Primer dia
  676.                             $newLoungeSimple->setDateStart($actualStartDay);
  677.                             $actualStartDayEnd = new DateTime($actualStartDay->format('Y-m-d').' 23:59');
  678.                             $newLoungeSimple->setDateEnd($actualStartDayEnd);
  679.                             $newLoungeSimple->setHourStart($item->getHourStart());
  680.                             $newLoungeSimple->setHourEnd('23');
  681.                             $newLoungeSimple->setMinStart($item->getMinStart());
  682.                             $newLoungeSimple->setMinEnd('59');
  683.                         } else {
  684.                             if (($i 1) == sizeof($numDays)){
  685.                                 // Ultimo dia
  686.                                 $actualEndDayStart = new DateTime($actualEndDay->format('Y-m-d').' 00:00');
  687.                                 $newLoungeSimple->setDateStart($actualEndDayStart);
  688.                                 $newLoungeSimple->setDateEnd($actualEndDay);
  689.                                 $newLoungeSimple->setHourStart('00');
  690.                                 $newLoungeSimple->setHourEnd($item->getHourEnd());
  691.                                 $newLoungeSimple->setMinStart('00');
  692.                                 $newLoungeSimple->setMinEnd($item->getMinEnd());
  693.                             } else {
  694.                                 // Dia intermedio
  695.                                 $actualMidDayStart = new DateTime($actualDay->format('Y-m-d').' 00:00');
  696.                                 $actualMidDayEnd = new DateTime($actualDay->format('Y-m-d').' 23:59');
  697.                                 $newLoungeSimple->setDateStart($actualMidDayStart);
  698.                                 $newLoungeSimple->setDateEnd($actualMidDayEnd);
  699.                                 $newLoungeSimple->setHourStart('00');
  700.                                 $newLoungeSimple->setHourEnd('23');
  701.                                 $newLoungeSimple->setMinStart('00');
  702.                                 $newLoungeSimple->setMinEnd('59');
  703.                             }
  704.                         }
  705.                         $newLoungeSimple->setIdLounge($item->getIdLounge());
  706.                         $newLoungeSimple->setIdReservation($item->getIdReservation());
  707.                         $newLoungeSimple->setLoungeName($item->getLoungeName());
  708.                         $newLoungeSimple->setPax($item->getPax());
  709.                         $newLoungeSimple->setServicePrice($item->getServicePrice());
  710.                         $newLoungeSimple->setIva($item->getIva());
  711.                         $newLoungeSimple->setOpIva($item->getOpIva());
  712.                         $newLoungeSimple->setType($item->getType());
  713.                         $newLoungeSimple->setRankQuote($item->getRankQuote());
  714.                         $newLoungeSimple->setLoungeDescription($item->getLoungeDescription());
  715.                         $newLoungeSimple->setImportantDescription($item->getImportantDescription());
  716.                         $newLoungeSimple->setCreatedAt($createdAt);
  717.                         $newLoungeSimple->setCreatedBy($createdBy);
  718.                         $newLoungeSimple->setUpdatedAt($updatedAt);
  719.                         $newLoungeSimple->setUpdatedBy($updatedBy);
  720.                         $actualDay $actualDay->modify('+1 day');
  721.                         try{
  722.                             $em->persist($newLoungeSimple);
  723.                             $em->flush();
  724.                             $event 'The Item has been updated.';
  725.                             $successMessage $this->translator->trans($event);
  726.                             $this->addFlash('mensajereservation'$successMessage);
  727.                         } catch (\Exception $e){
  728.                             $event 'An error occurred: '.$e->getMessage();
  729.                             $errorMessage $this->translator->trans($event);
  730.                             $this->addFlash('mensajereservationerror'$errorMessage);
  731.                         }
  732.                         // INICIO: Verificamos si es necesario actualizar las fechas de la reserva
  733.                         $boolReserva false;
  734.                         if ($newLoungeSimple->getDateStart() < $reservax->getDateStart()){
  735.                             $reservax->setDateStart($newLoungeSimple->getDateStart());
  736.                             $boolReserva true;
  737.                         }
  738.                         if ($reservax->getDateEnd() < $newLoungeSimple->getDateEnd()){
  739.                             $reservax->setDateEnd($newLoungeSimple->getDateEnd());
  740.                             $boolReserva true;
  741.                         }
  742.                         if ($boolReserva){
  743.                             $em->persist($reservax);
  744.                             $em->flush();
  745.                         }
  746.                         // FIN: Verificamos si es necesario actualizar las fechas de la reserva
  747.                     }
  748.                 }
  749.             }
  750.             // Se vuelve a llamar a este mismo controlador ahora con los registros en la nueva tabla
  751.             return $this->redirectToRoute('reservations_greenpatio_duplicate_day', array( 'id' => $id'dayduplicate' => $dayduplicate, ));
  752.         }
  753.         // Se debe redirigir para agregar el Servicio de limpieza
  754.         return $this->redirectToRoute('reservations_white_addservices_cleaning',
  755.             array(
  756.                 'resid' => $id,
  757.                 'loungesimpleid' => $newLoungeSimple->getId(),
  758.             ));
  759.     }
  760.     /**
  761.      * @Route("/deleteitemsimple/{id}/{daydelete}", name="reservations_greenpatio_delete_simple_lounge")
  762.      * Elimina un Reservation Simple Lounge de la cotizacion
  763.      */
  764.     public function deleteSimpleLoungeAction($id$daydeleteEntityManagerInterface $emRequest $request)
  765.     {
  766.         $loungeSimple $em->getRepository(ReservationLoungeSimple::class)->findOneById($id);
  767.         $id $loungeSimple->getIdReservation();
  768.         $reserva $em->getRepository(Reservation::class)->findOneById($loungeSimple->getIdReservation());
  769.         try{
  770.             $em->remove($loungeSimple);
  771.             $em->flush();
  772.             $event 'The item has been deleted.';
  773.             $successMessage $this->translator->trans($event);
  774.             $this->addFlash('mensajereservation'$successMessage);
  775.         } catch (\Exception $e){
  776.             $event 'An error occurred: '.$e->getMessage();
  777.             $errorMessage $this->translator->trans($event);
  778.             $this->addFlash('mensajereservationerror'$errorMessage);
  779.         }
  780.         // Si se elimina el primer dia o el ultimo, se debe modificar las fechas de la reserva
  781.         if(($reserva->getDateStart()->format('Ymd') == $loungeSimple->getDateStart()->format('Ymd')) or ($reserva->getDateEnd()->format('Ymd') == $loungeSimple->getDateEnd()->format('Ymd'))){
  782.             $allLoungeSimples $em->getRepository(ReservationLoungeSimple::class)->findByIdReservation($reserva->getId());
  783.             if (!empty($allLoungeSimples)){
  784.                 $reserva->setDateStart(new DateTime('2078-01-01'));
  785.                 $reserva->setDateEnd(new DateTime('2000-01-01'));
  786.                 foreach ($allLoungeSimples as $newLoungeSimple){
  787.                     // INICIO: Verificamos si es necesario actualizar las fechas de la reserva
  788.                     $boolReserva false;
  789.                     if ($newLoungeSimple->getDateStart() < $reserva->getDateStart()){
  790.                         $reserva->setDateStart($newLoungeSimple->getDateStart());
  791.                         $boolReserva true;
  792.                     }
  793.                     if ($reserva->getDateEnd() < $newLoungeSimple->getDateEnd()){
  794.                         $reserva->setDateEnd($newLoungeSimple->getDateEnd());
  795.                         $boolReserva true;
  796.                     }
  797.                     if ($boolReserva){
  798.                         $em->persist($reserva);
  799.                         $em->flush();
  800.                     }
  801.                     // FIN: Verificamos si es necesario actualizar las fechas de la reserva
  802.                 }
  803.             } else {
  804.                 // Se elimino la ultima sala y la reserva queda vacia
  805.                 $reserva->setDateStart(new DateTime('2078-01-01'));
  806.                 $reserva->setDateEnd(new DateTime('2000-01-01'));
  807.                 $em->persist($reserva);
  808.                 $em->flush();
  809.             }
  810.             // Sincronización global de todos los campos
  811.             $data $this->sincGpHtAvService->sincGlobalGpHtAv($reserva->getId());
  812.         }
  813.         // Se elimina el servicio de horas de limpieza de la sala
  814.         return $this->redirectToRoute('reservations_greenpatio_delete_simple_lounge_cleaning',
  815.             array(
  816.                 'idRes' => $id,
  817.                 'idLng' => $loungeSimple->getIdLounge(),
  818.                 'dateInAt' => $loungeSimple->getDateStart()->format('Y-m-d\TH:i'),
  819.                 'dateOutAt' => $loungeSimple->getDateEnd()->format('Y-m-d\TH:i'),
  820.             ));
  821.     }
  822.     /**
  823.      * @Route("/deletequote/{idRes}/{idQuote}", name="reservations_delete_quote")
  824.      * Eliminar una cotizancion
  825.      */
  826.     public function deleteQuoteAction$idRes$idQuoteEntityManagerInterface $emRequest $request)
  827.     {
  828.         $qb $em->getRepository(ReservationLoungeSimple::class)->createQueryBuilder('r');
  829.         $reservation $qb->where('r.rankQuote = :rankQuote')
  830.             ->andWhere('r.idReservation = :idReservation')
  831.             ->setParameter('idReservation'$idRes)
  832.             ->setParameter('rankQuote'$idQuote)
  833.             ->getQuery()
  834.             ->getResult();
  835.         foreach ($reservation as $item){
  836.             try{
  837.                 $em->remove($item);
  838.                 $em->flush();
  839.                 $event 'Se ha eliminado la cotización';
  840.                 $successMessage $this->translator->trans($event);
  841.                 $this->addFlash('mensajereservation'$successMessage);
  842.             } catch (\Exception $e){
  843.                 $event 'An error occurred: '.$e->getMessage();
  844.                 $errorMessage $this->translator->trans($event);
  845.                 $this->addFlash('mensajereservationerror'$errorMessage);
  846.             }
  847.             //Se deben eliminar todas las horas de limpieza asociadas a las salas de la cotización
  848.             $loungeDetails $em->getRepository(ReservationLoungeDetails::class)->findOneById($item->getIdLounge());
  849.             $stringName 'HORAS ( '.$loungeDetails->getName().' )';
  850.             $serviceCatIdClean 21;
  851.             $dateInAt = new \DateTime($item->getDateStart()->format('Y-m-d\TH:i'));
  852.             $dateOutAt = new \DateTime($item->getDateEnd()->format('Y-m-d\TH:i'));
  853.             $qb $em->getRepository(ReservationService::class)->createQueryBuilder('rs');
  854.             $serviceClean $qb->where('rs.reservationId = :id')
  855.                 ->andWhere('rs.name = :name')
  856.                 ->andWhere('rs.dateInAt = :dateInAt')
  857.                 ->andWhere('rs.dateOutAt = :dateOutAt')
  858.                 ->andWhere('rs.serviceCatId = :serviceCatId')
  859.                 ->setParameter('id'$idRes)
  860.                 ->setParameter('name'$stringName)
  861.                 ->setParameter('dateInAt'$dateInAt)
  862.                 ->setParameter('dateOutAt'$dateOutAt)
  863.                 ->setParameter('serviceCatId'$serviceCatIdClean)
  864.                 ->getQuery()
  865.                 ->getResult();
  866.             if (!empty($serviceClean)) {
  867.                 // Se elimina el servicio de horas de limpieza de la sala
  868.                 $em->remove($serviceClean[0]);
  869.                 $em->flush();
  870.             }
  871.         }
  872.         // Recalculo de fechas del expediente
  873.         $data $this->recalculoFechas($idRes);
  874.         // Sincronización global de todos los campos
  875.         $data $this->sincGpHtAvService->sincGlobalGpHtAv($idRes);
  876.         return $this->redirectToRoute('reservations_greenpatio_edit_simple',
  877.             array(
  878.                 'id' => $idRes,
  879.                 'token' => null,
  880.                 '_fragment' => 'btn_quotes'
  881.             ));
  882.     }
  883.     /**
  884.      * @Route("/checkquote/{idRes}/{idQuote}", name="reservations_check_quote")
  885.      * Confirmación de que se ha aceptado la cotizancion, se eliminaran las otras cotizaciones del expediente
  886.      */
  887.     public function checkQuoteAction$idRes$idQuoteEntityManagerInterface $emRequest $request)
  888.     {
  889.         $qb $em->getRepository(ReservationLoungeSimple::class)->createQueryBuilder('r');
  890.         $reservation $qb->where('r.rankQuote <> :rankQuote')
  891.             ->andWhere('r.idReservation = :idReservation')
  892.             ->setParameter('idReservation'$idRes)
  893.             ->setParameter('rankQuote'$idQuote)
  894.             ->getQuery()
  895.             ->getResult();
  896.         foreach ($reservation as $item){
  897.             try{
  898.                 $em->remove($item);
  899.                 $em->flush();
  900.                 $event 'Se han eliminado las otras cotizaciones';
  901.                 $successMessage $this->translator->trans($event);
  902.                 $this->addFlash('mensajereservation'$successMessage);
  903.             } catch (\Exception $e){
  904.                 $event 'An error occurred: '.$e->getMessage();
  905.                 $errorMessage $this->translator->trans($event);
  906.                 $this->addFlash('mensajereservationerror'$errorMessage);
  907.             }
  908.         }
  909.         return $this->redirectToRoute('reservations_greenpatio_edit_simple',
  910.             array(
  911.                 'id' => $idRes,
  912.                 'token' => null,
  913.                 '_fragment' => 'btn_quotes'
  914.             ));
  915.     }
  916.     /**
  917.      * @Route("/duplicatequote", name="reservations_duplicate_quote")
  918.      * Duplicar una cotizacion
  919.      */
  920.     public function duplicateQuoteActionEntityManagerInterface $emRequest $request) {
  921.         $user_logueado $this->get('security.token_storage')->getToken()->getUser();
  922.         $user_id $user_logueado->getId();
  923.         $hoy = new \DateTime("now"NULL);
  924.         $reqDuplicateQuote $request->request->get('addquote');
  925.         $newLounge $em->getRepository(ReservationLoungeDetails::class)->findOneById($reqDuplicateQuote['salaPrecargadas']);
  926.         $qb $em->getRepository(ReservationLoungeSimple::class)->createQueryBuilder('r');
  927.         $reservationAll $qb->where('r.idReservation = :idReservation')
  928.             ->setParameter('idReservation'$reqDuplicateQuote['reservationId'])
  929.             ->orderBy('r.rankQuote''ASC')
  930.             ->getQuery()
  931.             ->getResult();
  932.         $newRankId = (!empty($reservationAll)) ? (end($reservationAll)->getRankQuote() + 1) : 1;
  933.         if (empty($reqDuplicateQuote['idQuote'])) { $reqDuplicateQuote['idQuote'] = reset($reservationAll)->getRankQuote(); }   //Si no elige cotización se duplica la primera
  934.         $qb $em->getRepository(ReservationLoungeSimple::class)->createQueryBuilder('r');
  935.         $reservation $qb->where('r.rankQuote = :rankQuote')
  936.             ->andWhere('r.idReservation = :idReservation')
  937.             ->setParameter('idReservation'$reqDuplicateQuote['reservationId'])
  938.             ->setParameter('rankQuote'$reqDuplicateQuote['idQuote'])
  939.             ->getQuery()
  940.             ->getResult();
  941.         $loungeWebDetail $em->getRepository(ReservationLoungeWebDescription::class)->findOneBy(array('lounge' => $newLounge->getId(), 'language' => 1));
  942.         $loungeWebDetail = empty($loungeWebDetail) ? $newLounge $loungeWebDetail;
  943.         foreach ($reservation as $item){
  944.             $newLoungeSimple = new ReservationLoungeSimple();
  945.             $newLoungeSimple->setDateStart($item->getDateStart());
  946.             $newLoungeSimple->setDateEnd($item->getDateEnd());
  947.             $newLoungeSimple->setIdReservation($reqDuplicateQuote['reservationId']);
  948.             $newLoungeSimple->setPax($item->getPax());
  949.             $newLoungeSimple->setType($item->getType());
  950.             $newLoungeSimple->setCreatedAt($hoy);
  951.             $newLoungeSimple->setCreatedBy($user_id);
  952.             $newLoungeSimple->setUpdatedAt($hoy);
  953.             $newLoungeSimple->setUpdatedBy($user_id);
  954.             $newLoungeSimple->setHourStart($item->getHourStart());
  955.             $newLoungeSimple->setMinStart($item->getMinStart());
  956.             $newLoungeSimple->setHourEnd($item->getHourEnd());
  957.             $newLoungeSimple->setMinEnd($item->getMinEnd());
  958.             $newLoungeSimple->setRankQuote($newRankId);
  959.             $newLoungeSimple->setIva($item->getIva());
  960.             $newLoungeSimple->setOpIva($item->getOpIva());
  961.             $newLoungeSimple->setIdLounge($newLounge->getId());
  962.             $newLoungeSimple->setLoungename($newLounge->getName());
  963. //            $newLoungeSimple->setLoungeDescription($item->getLoungeDescription());
  964.             $newLoungeSimple->setImportantDescription($loungeWebDetail->getImportantDescription());
  965.             $newLoungeSimple->setImportantDescGeneralText($loungeWebDetail->getImportantDescGeneralText());
  966.             $newLoungeSimple->setImportantDescSchedules($loungeWebDetail->getImportantDescSchedules());
  967.             $newLoungeSimple->setImportantDescParking($loungeWebDetail->getImportantDescParking());
  968.             if (!empty($reqDuplicateQuote['salaPrice'])){ $newLoungeSimple->setServicePrice($reqDuplicateQuote['salaPrice']); }  else { $newLoungeSimple->setServicePrice($item->getServicePrice());}
  969.             try{
  970.                 $em->persist($newLoungeSimple);
  971.                 $em->flush();
  972.                 $event 'Se ha agregado la nueva cotización';
  973.                 $successMessage $this->translator->trans($event);
  974.                 $this->addFlash('mensajereservation'$successMessage);
  975.             } catch (\Exception $e){
  976.                 $event 'An error occurred: '.$e->getMessage();
  977.                 $errorMessage $this->translator->trans($event);
  978.                 $this->addFlash('mensajereservationerror'$errorMessage);
  979.             }
  980.             // Rafa indica que se debe quitar esta asignación, mas adelante eliminaremos el codigo, despues de que prueben el sistema sin esta funcionalidad
  981.             if (false) {
  982.                 // Se debe agregar el servicio de limpieza por cada sala que se agregue
  983.                 $resLoungeSimple $newLoungeSimple;
  984.                 $service = new ReservationService();
  985.                 $service->setReservationId($reqDuplicateQuote['reservationId']);
  986.                 $service->setSupplierId(0);
  987.                 $service->setDateInAt($resLoungeSimple->getDateStart());
  988.                 $service->setDateOutAt($resLoungeSimple->getDateEnd());
  989.                 /* Obtengo usuario logueado */
  990.                 $user_logueado $this->get('security.token_storage')->getToken()->getUser();
  991.                 $user_id $user_logueado->getId();
  992.                 $service->setCreatedId($user_id);
  993.                 $service->setUpdatedId($user_id);
  994.                 $service->setCreatedAt(new \DateTime("now"));
  995.                 $service->setUpdatedAt(new \DateTime("now"));
  996.                 $service->setServiceCatId('21');
  997.                 $service->setServiceCatName('Limpieza');
  998.                 $service->setContcolor('green-300');
  999.                 $service->setName('HORAS ( ' $resLoungeSimple->getLoungeName() . ' )');
  1000.                 $service->setPrice('14');
  1001.                 $service->setCurrency('Euro');
  1002.                 $service->setUnits('8');
  1003.                 $service->setCommission('0');
  1004.                 $service->setIva('0');
  1005.                 $service->setPax('0');
  1006.                 $service->setOver('0');
  1007.                 $service->setIva('21');
  1008.                 $service->setOpIva('1');
  1009.                 $service->setOpCommission('1');
  1010.                 $service->setCommission('57.14');
  1011.                 $service->setViewInfo(0);
  1012.                 $service->setToinvoice(0);
  1013.                 $service->setServiceId(0);
  1014.                 $em->persist($service);
  1015.                 $em->flush();
  1016.             }
  1017.         }
  1018.         return $this->redirectToRoute('reservations_greenpatio_edit_simple',
  1019.             array(
  1020.                 'id' => $reqDuplicateQuote['reservationId'],
  1021.                 'token' => null,
  1022.                 '_fragment' => 'btn_quotes'
  1023.             ));
  1024.     }
  1025.     /**
  1026.      * @Route("/registerFormGpWeb/{yourEmail}/{yourReferral}/{yourEventDateDay}/{yourEventDateMonth}/{yourEventDateYear}/{yourName}/{yourPhone}/{yourAttendees}/{eventSpace}/{yourEventDetails}",
  1027.      *     name="registerformgpweb",
  1028.      *     defaults={"yourName"=null, "yourPhone"=null,"yourAttendees"=null,"eventSpace"=null,"yourEventDetails"=null,}
  1029.      * )
  1030.      * Crear una reserva con la información que llega desde la web
  1031.      */
  1032.     public function testGpWebAction$yourEmail$yourReferral$yourEventDateDay$yourEventDateMonth$yourEventDateYear$yourName$yourPhone$yourAttendees$eventSpace$yourEventDetailsEntityManagerInterface $emRequest $request) {
  1033.         $user_logueado $this->get('security.token_storage')->getToken()->getUser();
  1034.         $user_id $user_logueado->getId();
  1035.         $hoy = new \DateTime("now"NULL);
  1036.         $yourEventDate = new DateTime($yourEventDateDay'/'.$yourEventDateMonth.'/'.$yourEventDateYear);
  1037.         // Genera un token Ãºnico utilizando la función uniqid() de PHP
  1038.         $token uniqid();
  1039.         $reserva = new Reservation();
  1040.         $reserva->setTitle('Reserva ingresada en la web para el día: '$yourEventDate->format('d/m/Y'));
  1041.         $reserva->setClient(null);
  1042.         $reserva->setCreatedAt($hoy);
  1043.         $reserva->setPriority(1);
  1044. //        $reserva->setDateStart($yourEventDate);
  1045.         $reserva->setDateStart(new \DateTime('2078-01-01'));
  1046. //        $reserva->setDateEnd($yourEventDate);
  1047.         $reserva->setDateEnd(new \DateTime('2000-01-01'));
  1048.         $reserva->setCreatedBy($user_id);
  1049.         $reserva->setSupplier(4765);        // Higo&Trigo
  1050.         $reserva->setStatus('Cotizado');
  1051.         $reserva->setUpdatedAt($hoy);
  1052.         $reserva->setUpdatedBy($user_id);
  1053.         $reserva->setDaysBlock(7);
  1054.         $reserva->setAdvancePayment(null);
  1055.         $reserva->setIdProposal(null);
  1056.         $reserva->setCateringName('HIGO & TRIGO, S.L.');
  1057.         $reserva->setBoolCatering(null);
  1058.         if (!empty($yourAttendees) and is_numeric($yourAttendees)){ $reserva->setPax($yourAttendees); } else { $reserva->setPax(null); }
  1059.         $reserva->setDeposit(null);
  1060.         $reserva->setAccessKey(null);
  1061.         if (!empty($yourEventDetails)){ $reserva->setDescription($yourEventDetails); } else { $reserva->setDescription(null); }
  1062.         $reserva->setClientContact(null);
  1063.         $reserva->setContactUnregistered($yourEmail);       // Desde la web es requerido
  1064.         $reserva->setDays(null);
  1065.         $reserva->setContract(null);
  1066.         if (!empty($yourName)){ $reserva->setNameContactUnregistered($yourName); } else { $reserva->setNameContactUnregistered(null); }
  1067.         if (!empty($yourPhone)){ $reserva->setPhoneContactUnregistered($yourPhone); } else { $reserva->setPhoneContactUnregistered(null); }
  1068.         $reserva->setToken($token);
  1069.         $reserva->setComAvGp(null);
  1070.         $reserva->setComHtGp(null);
  1071.         $reserva->setInfoFormWeb($yourEmail .' || '$yourReferral .' || '$yourEventDate->format('d/m/Y') .' || '$yourName .' || '$yourPhone .' || '$yourAttendees .' || '$eventSpace);
  1072.         try{
  1073.             $em->persist($reserva);
  1074.             $em->flush();
  1075.             $event 'The Reservation has been updated.';
  1076.             $successMessage $this->translator->trans($event);
  1077.             $this->addFlash('mensajereservation'$successMessage);
  1078.         } catch (\Exception $e){
  1079.             $event 'An error occurred: '.$e->getMessage();
  1080.             $errorMessage $this->translator->trans($event);
  1081.             $this->addFlash('mensajereservationerror'$errorMessage);
  1082.         }
  1083.         $id $reserva->getId();
  1084.         // Sincronización con HT
  1085.         if (!empty($reserva)) {
  1086.             // Rafa indico que siempre se sincronice al abrir un expediente de GP
  1087.             if (in_array($reserva->getStatus(), [null'''Confirmed''Invoiced''Iniciado''Cotizado''Bloqueo'])) {
  1088.                 if ($reserva->getCateringName() == 'HIGO & TRIGO, S.L.') {
  1089.                     // Si no se ha creado aun el expediente de HT debemos crearlo
  1090.                     $htFile $em->getRepository(HtFile::class)->findByReservation($reserva);
  1091.                     if (empty($htFile)) { return $this->redirectToRoute('sinc_gp_ht', array('id' => $id,)); }
  1092.                 }
  1093.             }
  1094.         }
  1095.         return $this->redirectToRoute('reservations_greenpatio_edit_simple',
  1096.             array(
  1097.                 'id' => $id,
  1098.                 'token' => null,
  1099.                 '_fragment' => 'btn_quotes'
  1100.             ));
  1101.     }
  1102.     private function precioPorFecha($date$loungeId){
  1103.         return array( 'price' => 0, );
  1104.         $em $this->getDoctrine()->getManager();
  1105.         $price0 null;
  1106.         // Buscamos por año
  1107.         $parameters = array( 'dateYear' => $date->format('Y'), 'loungeId' => $loungeId'priceIsActive' => true, );
  1108.         $dql 'SELECT i
  1109.                 FROM GreenPatioBundle:ReservationLoungeProfile i
  1110.                 WHERE  ((i.year1 <= :dateYear and i.year2 >= :dateYear) ) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive';
  1111.         $query $em->createQuery($dql)->setParameters($parameters);
  1112.         $price1 $query->getResult();
  1113.         // Buscamos por año y mes
  1114.         $parameters = array( 'dateYear' => $date->format('Y'), 'month' => true'loungeId' => $loungeId'priceIsActive' => true, );
  1115.         switch ($date->format('m')) {
  1116.             case '01'//Enero
  1117.                 $dql 'SELECT i
  1118.                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1119.                     WHERE (
  1120.                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1121.                           AND (i.month1 = :month)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1122.                       ';
  1123.                 break;
  1124.             case '02'//Febrero
  1125.                 $dql 'SELECT i
  1126.                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1127.                     WHERE (
  1128.                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1129.                           AND (i.month2 = :month)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1130.                       ';
  1131.                 break;
  1132.             case '03'//Marzo
  1133.                 $dql 'SELECT i
  1134.                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1135.                     WHERE (
  1136.                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1137.                           AND (i.month3 = :month)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1138.                       ';
  1139.                 break;
  1140.             case '04'//Abril
  1141.                 $dql 'SELECT i
  1142.                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1143.                     WHERE (
  1144.                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1145.                           AND (i.month4 = :month)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1146.                       ';
  1147.                 break;
  1148.             case '05'//Mayo
  1149.                 $dql 'SELECT i
  1150.                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1151.                     WHERE (
  1152.                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1153.                           AND (i.month5 = :month)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1154.                       ';
  1155.                 break;
  1156.             case '06'//Junio
  1157.                 $dql 'SELECT i
  1158.                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1159.                     WHERE (
  1160.                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1161.                           AND (i.month6 = :month)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1162.                       ';
  1163.                 break;
  1164.             case '07'//Julio
  1165.                 $dql 'SELECT i
  1166.                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1167.                     WHERE (
  1168.                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1169.                           AND (i.month7 = :month)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1170.                       ';
  1171.                 break;
  1172.             case '08'//Agosto
  1173.                 $dql 'SELECT i
  1174.                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1175.                     WHERE (
  1176.                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1177.                           AND (i.month8 = :month)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1178.                       ';
  1179.                 break;
  1180.             case '09'//Septiembre
  1181.                 $dql 'SELECT i
  1182.                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1183.                     WHERE (
  1184.                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1185.                           AND (i.month9 = :month)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1186.                       ';
  1187.                 break;
  1188.             case '10'//Octubre
  1189.                 $dql 'SELECT i
  1190.                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1191.                     WHERE (
  1192.                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1193.                           AND (i.month10 = :month)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1194.                       ';
  1195.                 break;
  1196.             case '11'//Noviembre
  1197.                 $dql 'SELECT i
  1198.                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1199.                     WHERE (
  1200.                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1201.                           AND (i.month11 = :month)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1202.                       ';
  1203.                 break;
  1204.             case '12'//Diciembre
  1205.                 $dql 'SELECT i
  1206.                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1207.                     WHERE (
  1208.                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1209.                           AND (i.month12 = :month)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1210.                       ';
  1211.                 break;
  1212.             default:
  1213.                 break;
  1214.         }
  1215.         $query $em->createQuery($dql)->setParameters($parameters);
  1216.         $price2 $query->getResult();
  1217.         // Buscamos por año, mes y dia de la semana
  1218.         $parameters = array( 'dateYear' => $date->format('Y'), 'month' => true'day' => true'loungeId' => $loungeId'priceIsActive' => true, );
  1219.         switch ($date->format('m')) {
  1220.             case '01'//Enero
  1221.                 switch ($date->format('l')) {
  1222.                     case 'Monday'//Lunes
  1223.                         $dql 'SELECT i
  1224.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1225.                                     WHERE (
  1226.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1227.                                           AND (i.month1 = :month) AND (i.day1 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1228.                                       ';
  1229.                         break;
  1230.                     case 'Tuesday'//Martes
  1231.                         $dql 'SELECT i
  1232.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1233.                                     WHERE (
  1234.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1235.                                           AND (i.month1 = :month) AND (i.day2 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1236.                                       ';
  1237.                         break;
  1238.                     case 'Wednesday'//Miercoles
  1239.                         $dql 'SELECT i
  1240.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1241.                                     WHERE (
  1242.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1243.                                           AND (i.month1 = :month) AND (i.day3 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1244.                                       ';
  1245.                         break;
  1246.                     case 'Thursday'//Jueves
  1247.                         $dql 'SELECT i
  1248.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1249.                                     WHERE (
  1250.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1251.                                           AND (i.month1 = :month) AND (i.day4 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1252.                                       ';
  1253.                         break;
  1254.                     case 'Friday'//Viernes
  1255.                         $dql 'SELECT i
  1256.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1257.                                     WHERE (
  1258.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1259.                                           AND (i.month1 = :month) AND (i.day5 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1260.                                       ';
  1261.                         break;
  1262.                     case 'Saturday'//Sabado
  1263.                         $dql 'SELECT i
  1264.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1265.                                     WHERE (
  1266.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1267.                                           AND (i.month1 = :month) AND (i.day6 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1268.                                       ';
  1269.                         break;
  1270.                     case 'Sunday'//Domingo
  1271.                         $dql 'SELECT i
  1272.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1273.                                     WHERE (
  1274.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1275.                                           AND (i.month1 = :month) AND (i.day7 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1276.                                       ';
  1277.                         break;
  1278.                     default: break;
  1279.                 }
  1280.                 break;
  1281.             case '02'//Febrero
  1282.                 switch ($date->format('l')) {
  1283.                     case 'Monday'//Lunes
  1284.                         $dql 'SELECT i
  1285.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1286.                                     WHERE (
  1287.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1288.                                           AND (i.month2 = :month) AND (i.day1 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1289.                                       ';
  1290.                         break;
  1291.                     case 'Tuesday'//Martes
  1292.                         $dql 'SELECT i
  1293.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1294.                                     WHERE (
  1295.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1296.                                           AND (i.month2 = :month) AND (i.day2 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1297.                                       ';
  1298.                         break;
  1299.                     case 'Wednesday'//Miercoles
  1300.                         $dql 'SELECT i
  1301.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1302.                                     WHERE (
  1303.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1304.                                           AND (i.month2 = :month) AND (i.day3 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1305.                                       ';
  1306.                         break;
  1307.                     case 'Thursday'//Jueves
  1308.                         $dql 'SELECT i
  1309.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1310.                                     WHERE (
  1311.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1312.                                           AND (i.month2 = :month) AND (i.day4 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1313.                                       ';
  1314.                         break;
  1315.                     case 'Friday'//Viernes
  1316.                         $dql 'SELECT i
  1317.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1318.                                     WHERE (
  1319.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1320.                                           AND (i.month2 = :month) AND (i.day5 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1321.                                       ';
  1322.                         break;
  1323.                     case 'Saturday'//Sabado
  1324.                         $dql 'SELECT i
  1325.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1326.                                     WHERE (
  1327.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1328.                                           AND (i.month2 = :month) AND (i.day6 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1329.                                       ';
  1330.                         break;
  1331.                     case 'Sunday'//Domingo
  1332.                         $dql 'SELECT i
  1333.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1334.                                     WHERE (
  1335.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1336.                                           AND (i.month2 = :month) AND (i.day7 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1337.                                       ';
  1338.                         break;
  1339.                     default: break;
  1340.                 }
  1341.                 break;
  1342.             case '03'//Marzo
  1343.                 switch ($date->format('l')) {
  1344.                     case 'Monday'//Lunes
  1345.                         $dql 'SELECT i
  1346.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1347.                                     WHERE (
  1348.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1349.                                           AND (i.month3 = :month) AND (i.day1 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1350.                                       ';
  1351.                         break;
  1352.                     case 'Tuesday'//Martes
  1353.                         $dql 'SELECT i
  1354.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1355.                                     WHERE (
  1356.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1357.                                           AND (i.month3 = :month) AND (i.day2 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1358.                                       ';
  1359.                         break;
  1360.                     case 'Wednesday'//Miercoles
  1361.                         $dql 'SELECT i
  1362.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1363.                                     WHERE (
  1364.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1365.                                           AND (i.month3 = :month) AND (i.day3 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1366.                                       ';
  1367.                         break;
  1368.                     case 'Thursday'//Jueves
  1369.                         $dql 'SELECT i
  1370.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1371.                                     WHERE (
  1372.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1373.                                           AND (i.month3 = :month) AND (i.day4 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1374.                                       ';
  1375.                         break;
  1376.                     case 'Friday'//Viernes
  1377.                         $dql 'SELECT i
  1378.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1379.                                     WHERE (
  1380.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1381.                                           AND (i.month3 = :month) AND (i.day5 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1382.                                       ';
  1383.                         break;
  1384.                     case 'Saturday'//Sabado
  1385.                         $dql 'SELECT i
  1386.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1387.                                     WHERE (
  1388.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1389.                                           AND (i.month3 = :month) AND (i.day6 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1390.                                       ';
  1391.                         break;
  1392.                     case 'Sunday'//Domingo
  1393.                         $dql 'SELECT i
  1394.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1395.                                     WHERE (
  1396.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1397.                                           AND (i.month3 = :month) AND (i.day7 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1398.                                       ';
  1399.                         break;
  1400.                     default: break;
  1401.                 }
  1402.                 break;
  1403.             case '04'//Abril
  1404.                 switch ($date->format('l')) {
  1405.                     case 'Monday'//Lunes
  1406.                         $dql 'SELECT i
  1407.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1408.                                     WHERE (
  1409.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1410.                                           AND (i.month4 = :month) AND (i.day1 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1411.                                       ';
  1412.                         break;
  1413.                     case 'Tuesday'//Martes
  1414.                         $dql 'SELECT i
  1415.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1416.                                     WHERE (
  1417.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1418.                                           AND (i.month4 = :month) AND (i.day2 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1419.                                       ';
  1420.                         break;
  1421.                     case 'Wednesday'//Miercoles
  1422.                         $dql 'SELECT i
  1423.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1424.                                     WHERE (
  1425.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1426.                                           AND (i.month4 = :month) AND (i.day3 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1427.                                       ';
  1428.                         break;
  1429.                     case 'Thursday'//Jueves
  1430.                         $dql 'SELECT i
  1431.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1432.                                     WHERE (
  1433.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1434.                                           AND (i.month4 = :month) AND (i.day4 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1435.                                       ';
  1436.                         break;
  1437.                     case 'Friday'//Viernes
  1438.                         $dql 'SELECT i
  1439.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1440.                                     WHERE (
  1441.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1442.                                           AND (i.month4 = :month) AND (i.day5 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1443.                                       ';
  1444.                         break;
  1445.                     case 'Saturday'//Sabado
  1446.                         $dql 'SELECT i
  1447.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1448.                                     WHERE (
  1449.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1450.                                           AND (i.month4 = :month) AND (i.day6 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1451.                                       ';
  1452.                         break;
  1453.                     case 'Sunday'//Domingo
  1454.                         $dql 'SELECT i
  1455.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1456.                                     WHERE (
  1457.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1458.                                           AND (i.month4 = :month) AND (i.day7 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1459.                                       ';
  1460.                         break;
  1461.                     default: break;
  1462.                 }
  1463.                 break;
  1464.             case '05'//Mayo
  1465.                 switch ($date->format('l')) {
  1466.                     case 'Monday'//Lunes
  1467.                         $dql 'SELECT i
  1468.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1469.                                     WHERE (
  1470.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1471.                                           AND (i.month5 = :month) AND (i.day1 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1472.                                       ';
  1473.                         break;
  1474.                     case 'Tuesday'//Martes
  1475.                         $dql 'SELECT i
  1476.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1477.                                     WHERE (
  1478.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1479.                                           AND (i.month5 = :month) AND (i.day2 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1480.                                       ';
  1481.                         break;
  1482.                     case 'Wednesday'//Miercoles
  1483.                         $dql 'SELECT i
  1484.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1485.                                     WHERE (
  1486.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1487.                                           AND (i.month5 = :month) AND (i.day3 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1488.                                       ';
  1489.                         break;
  1490.                     case 'Thursday'//Jueves
  1491.                         $dql 'SELECT i
  1492.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1493.                                     WHERE (
  1494.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1495.                                           AND (i.month5 = :month) AND (i.day4 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1496.                                       ';
  1497.                         break;
  1498.                     case 'Friday'//Viernes
  1499.                         $dql 'SELECT i
  1500.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1501.                                     WHERE (
  1502.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1503.                                           AND (i.month5 = :month) AND (i.day5 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1504.                                       ';
  1505.                         break;
  1506.                     case 'Saturday'//Sabado
  1507.                         $dql 'SELECT i
  1508.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1509.                                     WHERE (
  1510.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1511.                                           AND (i.month5 = :month) AND (i.day6 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1512.                                       ';
  1513.                         break;
  1514.                     case 'Sunday'//Domingo
  1515.                         $dql 'SELECT i
  1516.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1517.                                     WHERE (
  1518.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1519.                                           AND (i.month5 = :month) AND (i.day7 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1520.                                       ';
  1521.                         break;
  1522.                     default: break;
  1523.                 }
  1524.                 break;
  1525.             case '06'//Junio
  1526.                 switch ($date->format('l')) {
  1527.                     case 'Monday'//Lunes
  1528.                         $dql 'SELECT i
  1529.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1530.                                     WHERE (
  1531.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1532.                                           AND (i.month6 = :month) AND (i.day1 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1533.                                       ';
  1534.                         break;
  1535.                     case 'Tuesday'//Martes
  1536.                         $dql 'SELECT i
  1537.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1538.                                     WHERE (
  1539.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1540.                                           AND (i.month6 = :month) AND (i.day2 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1541.                                       ';
  1542.                         break;
  1543.                     case 'Wednesday'//Miercoles
  1544.                         $dql 'SELECT i
  1545.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1546.                                     WHERE (
  1547.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1548.                                           AND (i.month6 = :month) AND (i.day3 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1549.                                       ';
  1550.                         break;
  1551.                     case 'Thursday'//Jueves
  1552.                         $dql 'SELECT i
  1553.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1554.                                     WHERE (
  1555.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1556.                                           AND (i.month6 = :month) AND (i.day4 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1557.                                       ';
  1558.                         break;
  1559.                     case 'Friday'//Viernes
  1560.                         $dql 'SELECT i
  1561.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1562.                                     WHERE (
  1563.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1564.                                           AND (i.month6 = :month) AND (i.day5 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1565.                                       ';
  1566.                         break;
  1567.                     case 'Saturday'//Sabado
  1568.                         $dql 'SELECT i
  1569.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1570.                                     WHERE (
  1571.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1572.                                           AND (i.month6 = :month) AND (i.day6 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1573.                                       ';
  1574.                         break;
  1575.                     case 'Sunday'//Domingo
  1576.                         $dql 'SELECT i
  1577.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1578.                                     WHERE (
  1579.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1580.                                           AND (i.month6 = :month) AND (i.day7 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1581.                                       ';
  1582.                         break;
  1583.                     default: break;
  1584.                 }
  1585.                 break;
  1586.             case '07'//Julio
  1587.                 switch ($date->format('l')) {
  1588.                     case 'Monday'//Lunes
  1589.                         $dql 'SELECT i
  1590.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1591.                                     WHERE (
  1592.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1593.                                           AND (i.month7 = :month) AND (i.day1 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1594.                                       ';
  1595.                         break;
  1596.                     case 'Tuesday'//Martes
  1597.                         $dql 'SELECT i
  1598.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1599.                                     WHERE (
  1600.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1601.                                           AND (i.month7 = :month) AND (i.day2 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1602.                                       ';
  1603.                         break;
  1604.                     case 'Wednesday'//Miercoles
  1605.                         $dql 'SELECT i
  1606.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1607.                                     WHERE (
  1608.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1609.                                           AND (i.month7 = :month) AND (i.day3 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1610.                                       ';
  1611.                         break;
  1612.                     case 'Thursday'//Jueves
  1613.                         $dql 'SELECT i
  1614.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1615.                                     WHERE (
  1616.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1617.                                           AND (i.month7 = :month) AND (i.day4 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1618.                                       ';
  1619.                         break;
  1620.                     case 'Friday'//Viernes
  1621.                         $dql 'SELECT i
  1622.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1623.                                     WHERE (
  1624.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1625.                                           AND (i.month7 = :month) AND (i.day5 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1626.                                       ';
  1627.                         break;
  1628.                     case 'Saturday'//Sabado
  1629.                         $dql 'SELECT i
  1630.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1631.                                     WHERE (
  1632.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1633.                                           AND (i.month7 = :month) AND (i.day6 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1634.                                       ';
  1635.                         break;
  1636.                     case 'Sunday'//Domingo
  1637.                         $dql 'SELECT i
  1638.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1639.                                     WHERE (
  1640.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1641.                                           AND (i.month7 = :month) AND (i.day7 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1642.                                       ';
  1643.                         break;
  1644.                     default: break;
  1645.                 }
  1646.                 break;
  1647.             case '08'//Agosto
  1648.                 switch ($date->format('l')) {
  1649.                     case 'Monday'//Lunes
  1650.                         $dql 'SELECT i
  1651.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1652.                                     WHERE (
  1653.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1654.                                           AND (i.month8 = :month) AND (i.day1 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1655.                                       ';
  1656.                         break;
  1657.                     case 'Tuesday'//Martes
  1658.                         $dql 'SELECT i
  1659.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1660.                                     WHERE (
  1661.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1662.                                           AND (i.month8 = :month) AND (i.day2 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1663.                                       ';
  1664.                         break;
  1665.                     case 'Wednesday'//Miercoles
  1666.                         $dql 'SELECT i
  1667.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1668.                                     WHERE (
  1669.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1670.                                           AND (i.month8 = :month) AND (i.day3 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1671.                                       ';
  1672.                         break;
  1673.                     case 'Thursday'//Jueves
  1674.                         $dql 'SELECT i
  1675.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1676.                                     WHERE (
  1677.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1678.                                           AND (i.month8 = :month) AND (i.day4 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1679.                                       ';
  1680.                         break;
  1681.                     case 'Friday'//Viernes
  1682.                         $dql 'SELECT i
  1683.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1684.                                     WHERE (
  1685.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1686.                                           AND (i.month8 = :month) AND (i.day5 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1687.                                       ';
  1688.                         break;
  1689.                     case 'Saturday'//Sabado
  1690.                         $dql 'SELECT i
  1691.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1692.                                     WHERE (
  1693.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1694.                                           AND (i.month8 = :month) AND (i.day6 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1695.                                       ';
  1696.                         break;
  1697.                     case 'Sunday'//Domingo
  1698.                         $dql 'SELECT i
  1699.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1700.                                     WHERE (
  1701.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1702.                                           AND (i.month8 = :month) AND (i.day7 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1703.                                       ';
  1704.                         break;
  1705.                     default: break;
  1706.                 }
  1707.                 break;
  1708.             case '09'//Septiembre
  1709.                 switch ($date->format('l')) {
  1710.                     case 'Monday'//Lunes
  1711.                         $dql 'SELECT i
  1712.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1713.                                     WHERE (
  1714.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1715.                                           AND (i.month9 = :month) AND (i.day1 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1716.                                       ';
  1717.                         break;
  1718.                     case 'Tuesday'//Martes
  1719.                         $dql 'SELECT i
  1720.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1721.                                     WHERE (
  1722.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1723.                                           AND (i.month9 = :month) AND (i.day2 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1724.                                       ';
  1725.                         break;
  1726.                     case 'Wednesday'//Miercoles
  1727.                         $dql 'SELECT i
  1728.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1729.                                     WHERE (
  1730.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1731.                                           AND (i.month9 = :month) AND (i.day3 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1732.                                       ';
  1733.                         break;
  1734.                     case 'Thursday'//Jueves
  1735.                         $dql 'SELECT i
  1736.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1737.                                     WHERE (
  1738.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1739.                                           AND (i.month9 = :month) AND (i.day4 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1740.                                       ';
  1741.                         break;
  1742.                     case 'Friday'//Viernes
  1743.                         $dql 'SELECT i
  1744.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1745.                                     WHERE (
  1746.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1747.                                           AND (i.month9 = :month) AND (i.day5 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1748.                                       ';
  1749.                         break;
  1750.                     case 'Saturday'//Sabado
  1751.                         $dql 'SELECT i
  1752.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1753.                                     WHERE (
  1754.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1755.                                           AND (i.month9 = :month) AND (i.day6 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1756.                                       ';
  1757.                         break;
  1758.                     case 'Sunday'//Domingo
  1759.                         $dql 'SELECT i
  1760.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1761.                                     WHERE (
  1762.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1763.                                           AND (i.month9 = :month) AND (i.day7 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1764.                                       ';
  1765.                         break;
  1766.                     default: break;
  1767.                 }
  1768.                 break;
  1769.             case '10'//Octubre
  1770.                 switch ($date->format('l')) {
  1771.                     case 'Monday'//Lunes
  1772.                         $dql 'SELECT i
  1773.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1774.                                     WHERE (
  1775.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1776.                                           AND (i.month10 = :month) AND (i.day1 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1777.                                       ';
  1778.                         break;
  1779.                     case 'Tuesday'//Martes
  1780.                         $dql 'SELECT i
  1781.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1782.                                     WHERE (
  1783.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1784.                                           AND (i.month10 = :month) AND (i.day2 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1785.                                       ';
  1786.                         break;
  1787.                     case 'Wednesday'//Miercoles
  1788.                         $dql 'SELECT i
  1789.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1790.                                     WHERE (
  1791.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1792.                                           AND (i.month10 = :month) AND (i.day3 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1793.                                       ';
  1794.                         break;
  1795.                     case 'Thursday'//Jueves
  1796.                         $dql 'SELECT i
  1797.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1798.                                     WHERE (
  1799.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1800.                                           AND (i.month10 = :month) AND (i.day4 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1801.                                       ';
  1802.                         break;
  1803.                     case 'Friday'//Viernes
  1804.                         $dql 'SELECT i
  1805.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1806.                                     WHERE (
  1807.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1808.                                           AND (i.month10 = :month) AND (i.day5 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1809.                                       ';
  1810.                         break;
  1811.                     case 'Saturday'//Sabado
  1812.                         $dql 'SELECT i
  1813.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1814.                                     WHERE (
  1815.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1816.                                           AND (i.month10 = :month) AND (i.day6 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1817.                                       ';
  1818.                         break;
  1819.                     case 'Sunday'//Domingo
  1820.                         $dql 'SELECT i
  1821.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1822.                                     WHERE (
  1823.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1824.                                           AND (i.month10 = :month) AND (i.day7 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1825.                                       ';
  1826.                         break;
  1827.                     default: break;
  1828.                 }
  1829.                 break;
  1830.             case '11'//Noviembre
  1831.                 switch ($date->format('l')) {
  1832.                     case 'Monday'//Lunes
  1833.                         $dql 'SELECT i
  1834.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1835.                                     WHERE (
  1836.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1837.                                           AND (i.month11 = :month) AND (i.day1 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1838.                                       ';
  1839.                         break;
  1840.                     case 'Tuesday'//Martes
  1841.                         $dql 'SELECT i
  1842.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1843.                                     WHERE (
  1844.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1845.                                           AND (i.month11 = :month) AND (i.day2 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1846.                                       ';
  1847.                         break;
  1848.                     case 'Wednesday'//Miercoles
  1849.                         $dql 'SELECT i
  1850.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1851.                                     WHERE (
  1852.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1853.                                           AND (i.month11 = :month) AND (i.day3 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1854.                                       ';
  1855.                         break;
  1856.                     case 'Thursday'//Jueves
  1857.                         $dql 'SELECT i
  1858.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1859.                                     WHERE (
  1860.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1861.                                           AND (i.month11 = :month) AND (i.day4 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1862.                                       ';
  1863.                         break;
  1864.                     case 'Friday'//Viernes
  1865.                         $dql 'SELECT i
  1866.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1867.                                     WHERE (
  1868.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1869.                                           AND (i.month11 = :month) AND (i.day5 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1870.                                       ';
  1871.                         break;
  1872.                     case 'Saturday'//Sabado
  1873.                         $dql 'SELECT i
  1874.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1875.                                     WHERE (
  1876.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1877.                                           AND (i.month11 = :month) AND (i.day6 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1878.                                       ';
  1879.                         break;
  1880.                     case 'Sunday'//Domingo
  1881.                         $dql 'SELECT i
  1882.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1883.                                     WHERE (
  1884.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1885.                                           AND (i.month11 = :month) AND (i.day7 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1886.                                       ';
  1887.                         break;
  1888.                     default: break;
  1889.                 }
  1890.                 break;
  1891.             case '12'//Diciembre
  1892.                 switch ($date->format('l')) {
  1893.                     case 'Monday'//Lunes
  1894.                         $dql 'SELECT i
  1895.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1896.                                     WHERE (
  1897.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1898.                                           AND (i.month12 = :month) AND (i.day1 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1899.                                       ';
  1900.                         break;
  1901.                     case 'Tuesday'//Martes
  1902.                         $dql 'SELECT i
  1903.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1904.                                     WHERE (
  1905.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1906.                                           AND (i.month12 = :month) AND (i.day2 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1907.                                       ';
  1908.                         break;
  1909.                     case 'Wednesday'//Miercoles
  1910.                         $dql 'SELECT i
  1911.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1912.                                     WHERE (
  1913.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1914.                                           AND (i.month12 = :month) AND (i.day3 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1915.                                       ';
  1916.                         break;
  1917.                     case 'Thursday'//Jueves
  1918.                         $dql 'SELECT i
  1919.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1920.                                     WHERE (
  1921.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1922.                                           AND (i.month12 = :month) AND (i.day4 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1923.                                       ';
  1924.                         break;
  1925.                     case 'Friday'//Viernes
  1926.                         $dql 'SELECT i
  1927.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1928.                                     WHERE (
  1929.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1930.                                           AND (i.month12 = :month) AND (i.day5 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1931.                                       ';
  1932.                         break;
  1933.                     case 'Saturday'//Sabado
  1934.                         $dql 'SELECT i
  1935.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1936.                                     WHERE (
  1937.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1938.                                           AND (i.month12 = :month) AND (i.day6 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1939.                                       ';
  1940.                         break;
  1941.                     case 'Sunday'//Domingo
  1942.                         $dql 'SELECT i
  1943.                                     FROM GreenPatioBundle:ReservationLoungeProfile i
  1944.                                     WHERE (
  1945.                                     ((i.year1 <= :dateYear and i.year2 >= :dateYear) or (i.year1 = :dateYear) or (i.year2 = :dateYear))
  1946.                                           AND (i.month12 = :month) AND (i.day7 = :day)) and i.loungeId = :loungeId and i.priceIsActive = :priceIsActive
  1947.                                       ';
  1948.                         break;
  1949.                     default: break;
  1950.                 }
  1951.                 break;
  1952.             default:
  1953.                 break;
  1954.         }
  1955.         $query $em->createQuery($dql)->setParameters($parameters);
  1956.         $price3 $query->getResult();
  1957.         foreach ($price3 as $item){
  1958.             if (empty($price0)){
  1959.                 $price0 $item;
  1960.             } else {
  1961.                 //Si los precios coinciden en fechas se tomara el que se haya cargado mas reciente en el sistema
  1962.                 if ($item->getCreatedAt() > $price0->getCreatedAt()){ $price0 $item; }
  1963.             }
  1964.         }
  1965.         if(empty($price0)){ $price 0; } else { $price $price0->getPrice(); }
  1966.         return array( 'price' => $price, );
  1967.     }
  1968.     private function precioTarifario($dateStart$loungeId$servicePrice){
  1969.         /*
  1970.          * Se busca el precio a Sugerir
  1971.          * $dateStart Fecha
  1972.          * $loungeId Id de  la sala
  1973.          * $servicePrice Preciointroducido por elusuario
  1974.          * */
  1975.         $em $this->getDoctrine()->getManager();
  1976.         $dateToFind = clone $dateStart;
  1977.         $dateToFind->setTime(000);
  1978.         $parameters = array(
  1979.             'loungeId' => $loungeId,
  1980.             'typePrice' => 'DIARIA',
  1981.             'dateToFind' => $dateToFind,
  1982.         );
  1983.         $dql 'SELECT p
  1984.                 FROM GreenPatioBundle:ReservationLoungeProfile p
  1985.                 WHERE p.typePrice = :typePrice AND p.dateStart = :dateToFind AND p.loungeId = :loungeId
  1986.                 ORDER BY p.levelPrice DESC';
  1987.         $query $em->createQuery($dql)->setParameters($parameters);
  1988.         $loungesPeriodsDaily $query->getResult();
  1989.         $priceTarifa = empty($loungesPeriodsDaily) ? $loungesPeriodsDaily[0]->getPrice();
  1990.         $price = ($servicePrice == 0) ? $priceTarifa $servicePrice;
  1991.         return $price;
  1992.     }
  1993.     private function recalculoFechas($id){
  1994.         /*
  1995.          * Se busca recalculan las fechas de incio y fin de la reserva
  1996.          * $id es el identificador de la reserva
  1997.          * */
  1998.         $em $this->getDoctrine()->getManager();
  1999.         $reserva $em->getRepository(Reservation::class)->findOneById($id);
  2000.         $allLoungeSimples $em->getRepository(ReservationLoungeSimple::class)->findByIdReservation($id);
  2001.         $dateStart = new DateTime('2078-01-01');
  2002.         $dateEnd = new DateTime('2000-01-01');
  2003.         if (!empty($allLoungeSimples)){
  2004.             foreach ($allLoungeSimples as $loungeSimple){
  2005.                 $dateStart = ($loungeSimple->getDateStart() < $dateStart) ? $loungeSimple->getDateStart() : $dateStart;
  2006.                 $dateEnd = ($loungeSimple->getDateEnd() > $dateEnd) ? $loungeSimple->getDateStart() : $dateEnd;
  2007.             }
  2008.         }
  2009.         $reserva->setDateStart($dateStart);
  2010.         $reserva->setDateEnd($dateEnd);
  2011.         try{
  2012.             $em->persist($reserva);
  2013.             $em->flush();
  2014.             $event 'The Reservation has been updated.';
  2015.             $successMessage $this->translator->trans($event);
  2016.             $this->addFlash('mensajereservation'$successMessage);
  2017.         } catch (\Exception $e){
  2018.             $event 'An error occurred: '.$e->getMessage();
  2019.             $errorMessage $this->translator->trans($event);
  2020.             $this->addFlash('mensajereservationerror'$errorMessage);
  2021.         }
  2022.         return true;
  2023.     }
  2024. }