Ejemplo n.º 1
0
function getPromocionPalabrasClave($id)
{
    try {
        $promo = DAOFactory::getPromocionPalabrasClavesDAO()->load($id);
        $hoteles = DAOFactory::getPromocionPalabrasClavesHotelDAO()->queryByPromocionId($id);
        $hs = array();
        if ($hoteles) {
            foreach ($hoteles as $hp) {
                $h = DAOFactory::getHotelDAO()->load($hp->hotelId);
                $hs[] = $h;
            }
        }
        $promo->hoteles = $hs;
        return $promo;
    } catch (Exception $e) {
        return false;
    }
}
Ejemplo n.º 2
0
function getEmpresasByTipo($tipo)
{
    try {
        $empresas = DAOFactory::getEmpresaDAO()->queryByEmpresaTipoId($tipo);
        foreach ($empresas as $empresa) {
            $empresa->hoteles = count(DAOFactory::getHotelDAO()->queryByEmpresaId($empresa->id));
        }
        return $empresas;
    } catch (Exception $e) {
        return false;
    }
}
Ejemplo n.º 3
0
function getReservasByQuery($query, $args = array())
{
    try {
        if ($query) {
            if (!strlen(trim($query))) {
                return false;
            }
            $query = explode(':', $query);
            if (count($query) != 2) {
                return false;
            }
            switch ($query[0]) {
                case 'hotel':
                    $reservas = DAOFactory::getReservaDAO()->queryByHotelId($query[1], $args);
                    break;
                case 'usuario':
                    $reservas = DAOFactory::getReservaDAO()->queryByUsuarioId($query[1], $args);
                    break;
                case 'reserva':
                    $reservas = array(DAOFactory::getReservaDAO()->load($query[1]));
                    break;
                default:
                    break;
            }
        } else {
            global $usuario_core;
            $logged_user = $usuario_core->getUsuario();
            if ($logged_user->usuarioGrupoId == 1) {
                $reservas = DAOFactory::getReservaDAO()->queryByArgs($args);
            } else {
                $reservas = DAOFactory::getReservaDAO()->queryByUsuarioAutenticadoId($logged_user->id, $args);
            }
        }
        $hotel = false;
        foreach ($reservas as $reserva) {
            $reserva->usuario = DAOFactory::getUsuarioDAO()->load($reserva->usuarioId);
            $reserva->productos = DAOFactory::getReservaProductoDAO()->queryByReservaId($reserva->id);
            if (!$hotel || $hotel->id != $reserva->hotelId) {
                $hotel = DAOFactory::getHotelDAO()->load($reserva->hotelId);
            }
            $reserva->hotel = $hotel;
            $reserva->moneda = DAOFactory::getMonedaDAO()->load($reserva->monedaId);
            $reserva->alojamiento = array();
            $reserva->extras = array();
            foreach ($reserva->productos as $p) {
                if (strcmp($p->tipo, 'apartamento') == 0) {
                    array_push($reserva->alojamiento, $p);
                } else {
                    array_push($reserva->extras, $p);
                }
            }
        }
        return $reservas;
    } catch (Exception $e) {
        print_r($e);
        return false;
    }
}
Ejemplo n.º 4
0
function getHotelByCampaniaId($id)
{
    try {
        $hoteles = DAOFactory::getHotelDAO()->queryByCampaniaId($id);
        return $hoteles;
    } catch (Exception $e) {
        var_dump($e);
        return false;
    }
}
Ejemplo n.º 5
0
function getHotelLogotipo($idHotel)
{
    try {
        $archivo = null;
        $hotel = DAOFactory::getHotelDAO()->load($idHotel);
        if ($hotel) {
            if ($hotel->logoId) {
                $archivo = DAOFactory::getArchivoDAO()->load($hotel->logoId);
            }
        }
        return $archivo;
    } catch (Exception $e) {
        return false;
    }
}
Ejemplo n.º 6
0
function actualizarSEO($id = 0)
{
    try {
        if ($id) {
            $hotel = DAOFactory::getHotelDAO()->load($id);
            $hotel->descripciones = json_decode($hotel->descripcionLarga);
            $tituloSeo = $hotel->nombre;
            if ($hotel->destinoId) {
                $destino = DAOFactory::getDestinoTuristicoDAO()->load($hotel->destinoId);
                $tituloSeo .= ' | ' . $destino->nombre;
            }
            $descripcionesSeo = array();
            $keywordsSeo = array();
            foreach (get_object_vars($hotel->descripciones) as $k => $value) {
                $endD = strlen($value) > 150 ? '...' : '';
                $descripcionesSeo[$k] = strip_tags(substr($value, 0, 150)) . $endD;
                $keywordsSeo[$k] = $tituloSeo . ' ' . str_replace('...', '', $descripcionesSeo[$k]);
            }
            $hotel->tituloSeo = json_encode(array('es' => $tituloSeo));
            $hotel->descripcionCorta = json_encode($descripcionesSeo);
            $hotel->keywordsSeo = json_encode($keywordsSeo);
            DAOFactory::getHotelDAO()->update($hotel);
        } else {
            $transaction = new Transaction();
            $hoteles = DAOFactory::getHotelDAO()->queryAll();
            foreach ($hoteles as $hotel) {
                actualizarSeo($hotel->id);
            }
            $transaction->commit();
        }
        return true;
    } catch (Exception $e) {
        var_dump($e);
        if ($transaction) {
            $transaction->rollback();
        }
        return false;
    }
}
Ejemplo n.º 7
0
function deleteConfiguracion($idConfiguracion, $transactional = true)
{
    try {
        if ($transactional) {
            $transaction = new Transaction();
        }
        $hoteles = DAOFactory::getHotelDAO()->queryByConfiguracionId($idConfiguracion);
        foreach ($hoteles as $h) {
            $hotel = DAOFactory::getHotelDAO()->prepare(array('configuracionId' => NULL), $h->id);
            DAOFactory::getHotelDAO()->update($hotel);
        }
        $reglas = DAOFactory::getReglasCuponesDAO()->queryByConfiguracionId($id);
        if (count($reglas)) {
            foreach ($reglas as $r_k => $regla) {
                DAOFactory::getCuponDAO()->deleteByReglasCuponesId($regla->id);
            }
        }
        DAOFactory::getReglasCuponesDAO()->deleteByConfiguracionId($idConfiguracion);
        DAOFactory::getConfiguracionDAO()->delete($idConfiguracion);
        if ($transactional) {
            $transaction->commit();
        }
        return true;
    } catch (Exception $e) {
        print_r($e);
        if ($transaction) {
            $transaction->rollback();
        }
        return false;
    }
}