Example #1
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 #2
0
function actualizarCambioMoneda()
{
    try {
        set_time_limit(0);
        $moneda = getMonedaByCodigo('USD');
        $hoy = strtotime(date('Y-m-d'));
        $lastUpdate = strtotime(date('Y-m-d', $moneda->ultimaModificacion ? strtotime($moneda->ultimaModificacion) : 0));
        if ($hoy > $lastUpdate) {
            $monedas = getAllMonedas();
            $transaction = new Transaction();
            $change_url = 'https://www.google.com/finance/converter';
            $cant = 1;
            $from = 'EUR';
            foreach ($monedas as $moneda) {
                $content = file_get_contents($change_url . '?a=' . $cant . '&from=' . $from . '&to=' . $moneda->codigo);
                $dom = new DOMDocument();
                @$dom->loadHTML($content);
                $x = new DOMXPath($dom);
                foreach ($x->query('//span[@class="bld"]') as $node) {
                    $rate = floatval(trim(str_replace($moneda->codigo, '', $node->nodeValue)));
                    $m = DAOFactory::getMonedaDAO()->prepare(array('tasaCambio' => $rate, 'ultimaModificacion' => date('Y-m-d')), $moneda->id);
                    DAOFactory::getMonedaDAO()->update($m);
                }
            }
            $transaction->commit();
        }
        return true;
    } catch (Exception $e) {
        print_r($e);
        if ($transaction) {
            $transaction->rollback();
        }
        return false;
    }
}