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

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