Example #1
0
function getReservasValidadasByHotel($idHotel, $moneda = false)
{
    try {
        actualizarPaxReservas();
        $rows = DAOFactory::getReservaDAO()->queryByValidadas($idHotel);
        $reservas = array();
        $hotel = getHotelById($idHotel);
        foreach ($rows as $row) {
            if (!$reservas[$row['reserva_id']]) {
                foreach ($row as $k => $value) {
                    $key = explode('_', $k);
                    if (strcmp($key[0], 'reserva') == 0) {
                        $reservas[$row['reserva_id']][$key[1]] = $value;
                    } else {
                        $reservas[$row['reserva_id']][$key[0]][$key[1]] = $value;
                    }
                }
                if ($moneda && $reservas[$row['reserva_id']]['moneda']['codigo'] != $moneda) {
                    $precio = convertFromMonedaToMoneda($reservas[$row['reserva_id']]['producto']['precioUnitario'], $reservas[$row['reserva_id']]['moneda']['codigo'], $moneda);
                    $m = getMonedaByCodigo($moneda);
                    $reservas[$row['reserva_id']]['producto']['precioUnitario'] = $precio;
                    $reservas[$row['reserva_id']]['moneda']['id'] = $m->id;
                    $reservas[$row['reserva_id']]['moneda']['codigo'] = $m->codigo;
                    $reservas[$row['reserva_id']]['moneda']['nombre'] = $m->nombre;
                    $reservas[$row['reserva_id']]['moneda']['simbolo'] = $m->simbolo;
                }
                $precio = $reservas[$row['reserva_id']]['producto']['precioUnitario'];
                $comision = $precio * $hotel->distribuidor->porcentajeBeneficio / 100;
                $reservas[$row['reserva_id']]['producto']['comision'] = $comision;
            }
        }
        return $reservas;
    } catch (Exception $e) {
        var_dump($e);
        return false;
    }
}
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;
    }
}
Example #3
0
<?php

$results = array('msg' => 'error', 'data' => '');
if (isset($_POST['id'])) {
    $excursionId = $_POST['id'];
    $client = new nusoap_client($service_url . "/soap-evento");
    $distribuidor = getParametrosVikaByHotelId($hotel->id);
    $params = $distribuidor;
    $params['id'] = $excursionId;
    $client->debug_flag = true;
    $result = $client->call('get', array('params' => $params));
    $result = json_decode($result);
    $excursion = $result->data;
    if (isset($_GET['m']) && strcmp($_GET['m'], 'EUR') != 0) {
        $excursion->precio->precio = convertFromMonedaToMoneda($excursion->precio->precio, 'EUR', $_GET['m']);
        $smarty->assign('currency', getMonedaByCodigo($_GET['m'])->simbolo);
    }
    $smarty->assign('excursion', $excursion);
    $html = $smarty->fetch('detalle.tpl');
    $results['msg'] = 'ok';
    $results['html'] = $html;
}
echo json_encode($results);
Example #4
0
    //$end_url .= '/m:' . $_REQUEST['m'];
} elseif (isset($_SESSION['money'])) {
    $money = $_SESSION['money'];
} else {
    $usar_moneda_hotel = true;
}
$hotel = getHotelByDominio($hotel_domain);
if (!$hotel) {
    $hotel = getHotelByUrl($hotel_url);
}
if ($hotel) {
    $moneda = getMoneda($hotel->monedaId);
    if ($usar_moneda_hotel && $hotel->monedaId) {
        $money = $moneda->codigo;
    }
    $m = getMonedaByCodigo($money);
    $currency = $m->simbolo;
    $showSubPrice = $currency != $moneda->simbolo;
    $smarty->assign('money', $money);
    $smarty->assign('moneda', $m);
    $smarty->assign('currency', $currency);
    $smarty->assign('showSubPrice', $showSubPrice);
    //actualizarCambioMoneda();
    $campania = getCampania($hotel->campaniaId);
    $redirect_to = addhttp($hotel->dominioOficial);
    if ($campania && $campania->estado == 'Aprobada') {
        $timeInicio = strtotime($hotel->campania->inicio);
        $timeFin = strtotime($hotel->campania->fin);
        $now = time();
        if ($now < $timeInicio || $now > $timeFin + 24 * 60 * 60) {
            $login_url = $base_url . '/hoteles';