function getCart($idCart) { try { $cart = DAOFactory::getShoppingCartDAO()->load($idCart); if (!$cart) { return false; } $cart->apartamentoObj = json_decode($cart->apartamento); $cart->excursionesArray = json_decode($cart->excursiones); if ($cart->monedaId) { $cart->moneda = DAOFactory::getMonedaDAO()->load($cart->monedaId); } return $cart; } catch (Exception $e) { print_r($e); return false; } }
function getReservaByLocalizador($localizador, $withCardData = false) { try { $reservas = DAOFactory::getReservaDAO()->queryByLocalizador($localizador); if (!$reservas || !count($reservas)) { return false; } $reserva = $reservas[count($reservas) - 1]; $idReserva = $reserva->id; $reserva->productos = DAOFactory::getReservaProductoDAO()->queryByReservaId($idReserva); $reserva->usuario = getUsuario($reserva->usuarioId); $reserva->pagos = DAOFactory::getReservaPagoDAO()->queryByReservaId($idReserva); if ($reserva->pagos) { $clave = getClaveByHotel($reserva->hotelId); foreach ($reserva->pagos as $pago) { if ($pago->formaPago == 'tarjeta') { if (!$withCardData) { $pago->tarjetaNumero = false; $reserva->cardData = true; } else { if ($pago->tarjetaNumero && strlen(trim($pago->tarjetaNumero))) { $pago->tarjetaNumero = Encrypter::decrypt($pago->tarjetaNumero, $clave); } } if (!$withCardData) { $pago->cvv = false; } else { if ($pago->cvv && strlen(trim($pago->cvv))) { $pago->cvv = Encrypter::decrypt($pago->cvv, $clave); } } } } } $reserva->alojamiento = array(); $reserva->extras = array(); foreach ($reserva->productos as $kp => $p) { if (strcmp($p->tipo, 'apartamento') == 0) { $p->noches = ceil((strtotime($p->final) - strtotime($p->inicio)) / (24 * 60 * 60)); if (strpos($p->nombre, '(')) { $n = explode('(', $p->nombre); $pax = trim($n[count($n) - 1]); $reserva->productos[$kp]->pax = substr($pax, 0, strlen($pax) - 1); } array_push($reserva->alojamiento, $p); } else { if ($p->eventoTpv && strlen($p->eventoTpv)) { $p->eventoTpv = json_decode($p->eventoTpv); } if ($p->entradas) { $p->entradasList = json_decode($p->entradas); $cant = 0; foreach ($p->entradasList as $entrada) { $cant += $entrada->entradas; } $p->tickets = $cant; } array_push($reserva->extras, $p); } } if ($reserva->monedaId) { $reserva->moneda = DAOFactory::getMonedaDAO()->load($reserva->monedaId); } if ($reserva->idiomaId) { $reserva->idioma = DAOFactory::getIdiomaDAO()->load($reserva->idiomaId); } if ($reserva->cartId) { $reserva->cart = DAOFactory::getShoppingCartDAO()->load($reserva->cartId); $reserva->cart->apto = json_decode($reserva->cart->apartamento); } return $reserva; } catch (Exception $e) { return false; } }