/**
  * @Route("/admin/hotel/find/tarifas/by/dates", name="hotel_find_tarifas_by_date")
  * @Method("POST")
  */
 public function findRateHotelByDateAction(Request $request)
 {
     $fechaInicio = DateUtil::formatDate($request->get('fechaInicio'));
     $fechaFin = DateUtil::formatDate($request->get('fechaFin'));
     $idContrato = $request->get('idContrato');
     $idHabitacion = $request->get('idHabitacion');
     $idHotel = $request->get('idHotel');
     $rateList = $this->getDoctrine()->getRepository('VisitaYucatanBundle:HotelTarifa')->findRateByRangeDate($fechaInicio, $fechaFin, $idHotel, $idContrato, $idHabitacion);
     return new Response($this->get('serializer')->serialize($rateList, Generalkeys::JSON_STRING));
 }
Example #2
0
 public static function getHotelReserva($fechaInicio, $fechaFin, $adultos, $menores, $hotel, $tarifa)
 {
     $reserva = new HotelReservaTO();
     $reserva->setNombreHotel($hotel['nombrehotel']);
     $reserva->setTipoHabitacion($tarifa['nombre']);
     $reserva->setSimboloMoneda($tarifa['simbolomoneda']);
     $reserva->setIdIdioma($tarifa['ididioma']);
     $reserva->setIdMoneda($tarifa['moneda']);
     $reserva->setTipoCambio($tarifa['tipocambiomoneda']);
     $reserva->setFechaInicio($fechaInicio);
     $reserva->setFechaFin($fechaFin);
     $reserva->setAdultos($adultos);
     $reserva->setMenores($menores);
     $costo = self::getRateByPersons($adultos, $tarifa['costosencillo'], $tarifa['costodoble'], $tarifa['costotriple'], $tarifa['costocuadruple']);
     $costoTotal = self::getTotalRate($costo, $tarifa['ish'], $tarifa['markup'], $tarifa['iva'], $tarifa['fee'], $tarifa['aplicaimpuesto']);
     $reserva->setTarifaAdulto(number_format($costoTotal, 2));
     $reserva->setTarifaMenor(floatval(0));
     $dias = DateUtil::diffDays(DateUtil::formatDate($fechaInicio), DateUtil::formatDate($fechaFin));
     $reserva->setEstadiaDias($dias);
     $reserva->setCostoTotal(ceil($costoTotal * ($dias - 1)));
     $reserva->setEstadiaNoches($dias - Generalkeys::NUMBER_ONE);
     return $reserva;
 }
 /**
  * @Route("/hotel/find/rates", name="web_hotel_rates")
  * @Method("POST")
  */
 public function getPricesRoom(Request $request)
 {
     try {
         // obtiene los datos de session moneda e idioma
         $datos = $this->getParamsTour($request);
         $adults = $request->get('adults');
         $minors = $request->get('minors');
         $dateFrom = $request->get('from');
         $dateTo = $request->get('to');
         $idHotel = $request->get('idHotel');
         //echo "adultos = ".$adults;
         //TODO path test = http://localhost/visitayucatan2.0/hotel/find/rates?adults=2&minors=3&from=08/05/2016&to=31/05/2016&idHotel=1
         $idContract = $this->getDoctrine()->getRepository('VisitaYucatanBundle:HotelContrato')->findIdContractActiveByHotel($idHotel);
         //echo "idcontrado activo = ".$idContract." <br>";
         $dateClosing = $this->getDoctrine()->getRepository('VisitaYucatanBundle:HotelFechaCierre')->findClosingDateByContractAndHotel($idHotel, $idContract);
         //echo "fechas cierre = ".print_r($dateClosing); echo " <br>";
         $costosRoom = $this->getDoctrine()->getRepository('VisitaYucatanBundle:HotelTarifa')->getRateByRooms(DateUtil::formatDate($dateFrom), DateUtil::subtractOneDayTodate(DateUtil::formatDate($dateTo)), $idHotel, $datos[Generalkeys::NUMBER_ZERO], $datos[Generalkeys::NUMBER_ONE], $idContract);
         $costs = HotelUtils::getCotizationRoom($costosRoom, $adults, $minors, $dateClosing);
         //print_r($costs);
         $response = new ResponseTO(Generalkeys::RESPONSE_TRUE, Generalkeys::EMPTY_STRING, Generalkeys::RESPONSE_SUCCESS, Generalkeys::RESPONSE_CODE_OK);
         $response->setData($costs);
         // TODO siguiente codigo comentado para impresion de fechas y costos mas rapido
         /*foreach ($response->getData() as $value) {
                         echo "habitacion = ".$value->getNombre()."<br> descripcion = ".$value->getDescripcion()."<br>";
                         echo "<br><br>";
                         foreach ($value->getHotelTarifasTOCollection() as $item) {
                             echo "capacidad maxima = ".$item->getCapacidadMaxima()." fecha = ".$item->getSmallDate()." costo = ".$item->getCosto()." disponible = ".$item->getIsAvailable()." msj = ".$item->getMsjAvailable();
                             echo "<br>";
                         }
                         echo "GRAND TOTAL = ".$value->getTotalCostoHabitacion();
                         echo "<br><br>";
                         echo "cambio de habitacion *****************************************************************************************************************************";
                         echo "<br><br>";
         
                     }*/
         return new Response($this->get('serializer')->serialize($response, Generalkeys::JSON_STRING));
     } catch (\Exception $e) {
         return new Response($this->get('serializer')->serialize(new ResponseTO(Generalkeys::RESPONSE_FALSE, $e->getMessage(), Generalkeys::RESPONSE_ERROR, $e->getCode()), Generalkeys::JSON_STRING));
     }
 }