Example #1
0
function getHotelById($id, $convertirMonedas = true)
{
    try {
        $hotel = DAOFactory::getHotelDAO()->load($id);
        $hotel->direccion = getDireccionByHotel($hotel->id);
        if ($hotel->configuracionId) {
            $configuracion = DAOFactory::getConfiguracionDAO()->load($hotel->configuracionId);
        }
        if ($hotel->configuracionId) {
            $hotel->config = getConfiguracionById($hotel->configuracionId);
        }
        if ($hotel->campaniaId) {
            $hotel->campania = getCampania($hotel->campaniaId);
            if ($hotel->campania->empresaId) {
                $hotel->empresa = getEmpresaById($hotel->campania->empresaId);
            }
            if ($hotel->campania->empresaDistribuidoraId) {
                $hotel->distribuidor = getEmpresaById($hotel->campania->empresaDistribuidoraId);
            }
        }
        $hotel->idiomas = getAllIdiomas();
        $hotel->monedas = getMonedasByHotelId($hotel->id);
        $hotel->condiciones = getCondicionesByHotelId($hotel->id);
        if ($hotel->nombre && strlen(trim($hotel->nombre)) > 2 && $hotel->nombre[0] == '{' && $hotel->nombre[strlen($hotel->nombre) - 1] == '}') {
            $hotel->nombre = json_decode(trim($hotel->nombre))->es;
        }
        if ($hotel->descripcionCorta && strlen(trim($hotel->descripcionCorta)) > 0) {
            $hotel->descripcionesCortas = json_decode(trim($hotel->descripcionCorta));
        }
        if ($hotel->descripcionLarga && strlen(trim($hotel->descripcionLarga)) > 0) {
            $hotel->descripcionesLargas = json_decode(trim($hotel->descripcionLarga));
        }
        if ($hotel->informacionCompra && strlen(trim($hotel->informacionCompra)) > 0) {
            $hotel->informacionesCompra = json_decode(trim($hotel->informacionCompra));
        }
        if ($hotel->tituloSeo && strlen(trim($hotel->tituloSeo)) > 0) {
            $hotel->titulosSeo = json_decode(trim($hotel->tituloSeo));
        }
        if ($hotel->keywordsSeo && strlen(trim($hotel->keywordsSeo)) > 0) {
            $hotel->jkeywordsSeo = json_decode(trim($hotel->keywordsSeo));
        }
        $hotel->fechas = DAOFactory::getHotelFechasDAO()->queryByHotelId($hotel->id);
        if ($hotel->logoId) {
            $hotel->logo = DAOFactory::getArchivoDAO()->load($hotel->logoId);
        }
        $hotel->dominios = DAOFactory::getHotelDominiosDAO()->queryByHotelId($hotel->id);
        $hotel->promociones = DAOFactory::getPromocionDAO()->queryByHotelId($hotel->id);
        if ($hotel->promociones) {
            $hotel->promocionActual = false;
            foreach ($hotel->promociones as $p) {
                $now = time();
                if ($now >= strtotime($p->inicio) && $now <= strtotime($p->fin) + 24 * 60 * 60) {
                    $hotel->promocionActual = $p;
                }
            }
        }
        if ($hotel->monedaId) {
            $hotel->moneda = getMoneda($hotel->monedaId);
        }
        global $money;
        $preciosMinimos = DAOFactory::getHotelPrecioDAO()->queryByHotelId($hotel->id);
        if ($preciosMinimos && count($preciosMinimos)) {
            $precio_minimo_val = $preciosMinimos[0]->precioMinimo;
            if ($convertirMonedas) {
                $precio_moneda_seleccionada = convertFromMonedaToMoneda($precio_minimo_val, $hotel->moneda->codigo, $money);
                $preciosMinimos[0]->precioMinimo = $precio_moneda_seleccionada;
            } else {
                $preciosMinimos[0]->precioMinimo = $precio_minimo_val;
            }
            $hotel->precioMinimo = $preciosMinimos[0];
        }
        $hotel->blacklist = DAOFactory::getBlacklistDAO()->queryByHotelId($hotel->id);
        if ($hotel->destinoId) {
            $hotel->destino = getDestino($hotel->destinoId);
            if ($hotel->destino->descripcion) {
                $hotel->destino->descripciones = json_decode($hotel->destino->descripcion);
            }
            if ($hotel->mostrarHotelesRelacionados) {
                $hoteles = DAOFactory::getHotelDAO()->queryByDestinoId($hotel->destinoId);
                $keys = array_rand($hoteles, count($hoteles) > 10 ? 10 : count($hoteles));
                if (!is_array($keys)) {
                    $keys = array($keys);
                }
                $relacionados = array();
                foreach ($keys as $k) {
                    $h = $hoteles[$k];
                    if ($h->id != $hotel->id) {
                        $precioMinimo = DAOFactory::getHotelPrecioDAO()->queryByHotelId($h->id);
                        $logoHotel = getHotelLogo($h->id);
                        if ($precioMinimo && count($precioMinimo)) {
                            $precio_minimo_val = $precioMinimo[0]->precioMinimo;
                            $precio_moneda_seleccionada = convertFromMonedaToMoneda($precio_minimo_val, $hotel->moneda->codigo, $money);
                            $precioMinimo[0]->precioMinimo = $precio_moneda_seleccionada;
                            $h->precioMinimo = $precioMinimo[0];
                            $h->logo = $logoHotel;
                        }
                        $h->campania = DAOFactory::getCampaniaDAO()->load($h->campaniaId);
                        if (strlen($logoHotel->ruta) > 0) {
                            $relacionados[] = $h;
                        }
                    }
                }
                $hotel->relacionados = $relacionados;
            }
        }
        return $hotel;
    } catch (Exception $e) {
        return false;
    }
}
Example #2
0
<?php

$logged = $usuario_core->validateUser();
if ($logged) {
    $usuario = $usuario_core->getUsuario();
    if (strcmp(strtolower($usuario->status), 'activado') == 0) {
        $idiomas = getAllIdiomas();
        $monedas = getAllMonedas();
        $smarty->assign('idiomas', $idiomas);
        $smarty->assign('monedas', $monedas);
        $empresas = getEmpresasByUsuario($usuario->id);
        if ($empresas) {
            $empresa = $empresas[0];
            $empresa->direccion = getDireccion($empresa->direccionId);
            $smarty->assign('empresa', $empresa);
        }
        $smarty->display('admin/form_wizard.tpl');
    } else {
        header('Location:' . $base_url . '/admin-hotel-lista');
    }
}
Example #3
0
$logged = $usuario_core->validateUser();
if ($logged && ($usuario_core->getUsuario()->usuarioGrupoId == 1 || $usuario_core->getUsuario()->usuarioGrupoId == 3)) {
    $dir = $app_dir . '/configs/';
    $files = scandir($dir);
    $dictionary = array();
    $idiomas = array();
    foreach ($files as $file_dir) {
        if (strpos($file_dir, '.conf') && file_exists($dir . $file_dir)) {
            $lang = str_replace('.conf', '', $file_dir);
            $content = file($dir . $file_dir, FILE_IGNORE_NEW_LINES);
            $idioma = getIdiomaByCodigo($lang);
            if ($idioma) {
                $dictionary[$lang] = array();
                $idiomas[] = $idioma;
                foreach ($content as $line) {
                    $c = explode('=', $line);
                    $dictionary[$lang][trim($c[0])] = trim($c[1]);
                }
            }
        }
    }
    $languages = getAllIdiomas();
    $smarty->assign('languages', $languages);
    $smarty->assign('idiomas', $idiomas);
    $smarty->assign('config', $dictionary);
    $smarty->assign('usuario', $usuario_core->getUsuario());
    $smarty->display('admin/idioma/gestion.tpl');
} else {
    header('Location:' . $base_url . '/admin-login');
}