<?php
$assets_template = Yii::app()->params->assets_template;
$idAgencia = Yii::app()->params->agenciaUsuario;
$model_agencia_lite = Agencia::model()->findByPk($idAgencia);

// $model_sucursales = Sucursales::model()->find();

// $splitReferenciaRMT = explode("A", $model_agencia_lite->referenciaRMT);
// $id_usuario = str_replace("U", "", $splitReferenciaRMT[0]);
// $id_agencia = $splitReferenciaRMT[1];
// $modelAgenciasRMT = Agencias::model()->findByPk($id_agencia);


Yii::app()->params->shared_title = $model_agencia_lite->nom_agencia . ' - Internacionales';
$this->pageTitle = "Internacionales";
// Yii::app()->params->shared_image = 'https://one.cdnmega.com/images/viajes/covers/gran-triangulo-del-este-42327.jpg';
// Yii::app()->params->shared_description = 'Promociones internacionales ' . date('Y') . "<br>" . $model_agencia_lite->nosotros;



$list = array("13", "10", "5", "6");

if ($_GET == null) {
    $url = "https://q.megatravel.com.mx/tools/ofertas-viaje.php";
} else {
    $url = "https://q.megatravel.com.mx/tools/ofertas-viaje.php?Dest=" . $_GET['Dest'];
    if (in_array($_GET['Dest'], $list)) {
        $urlCruceros = "https://q.megatravel.com.mx/tools/vi.php?Dest=" . $_GET['Dest'];
        $html = file_get_contents($urlCruceros);
        libxml_use_internal_errors(true); //Prevents Warnings, remove if desired
        $dom = new DOMDocument();
        $dom->loadHTML($html);
        $remplazo2Cruceros = "";

        foreach ($dom->getElementsByTagName("body")->item(0)->childNodes as $child) {
            $remplazo2Cruceros .= $dom->saveHTML($child);
        }

        $remplazo2Cruceros = str_replace('href="circuito.php?', 'href="' . Yii::app()->baseUrl . '/site/circuito?', $remplazo2Cruceros);
    }
}





$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
$contBody = strstr($data, "<body>", false);
$contSinBody = str_replace("<body>", "", $contBody);
$contSinfinBody = str_replace("</body>", "", $contSinBody);
$remplazo = str_replace('action="https://www.megatravel.com.mx/tools/ofertas-viaje.php"', 'action="' . Yii::app()->baseUrl . '/servicios"', $contSinfinBody);
$remplazo = str_replace('action="https://q.megatravel.com.mx/tools/ofertas-viaje.php"', 'action="' . Yii::app()->baseUrl . '/servicios"', $remplazo);
$remplazo = str_replace('href="https://www.megatravel.com.mx/tools/circuito.php?', 'href="' . Yii::app()->baseUrl . '/site/circuito?', $remplazo);
$remplazo2 = str_replace('href="https://q.megatravel.com.mx/tools/circuito.php?', 'href="' . Yii::app()->baseUrl . '/site/circuito?', $remplazo);
?>

<style type="text/css">
    #filtro_destinos {
        display: none;
    }

    .active {
        background-color: var(--primary-text-color) !important;
        border: none;
    }

    .list-group-item {
        border-color: none;
        color: #013d7c;
        font-weight: bold;
        font-size: 17px;
    }

    .list-group-item-action:hover {
        background-color: var(--primary-text-color);
        color: white;
    }

    body {
        /* font-family: Arial, sans-serif; */
        margin: 0px;
        padding: 0px;
    }

    #cont_of {
        width: auto;
        display: block;
        margin: 0 auto;
        text-align: center;
    }

    .Item {
        width: 250px;
        height: 320px;
        margin: 5px;
        font-size: 14px;
        display: inline-block;
        vertical-align: top;
        text-align: left;
        border: 1px solid #E4E4E4;
        background-color: #eeeeee;
    }

    .Item a {
        color: #000000;
        text-decoration: none;
    }

    .Item:hover {
        background-color: #2c3e50;
    }

    .Item a:hover {
        color: #ffffff;
    }

    .ImPaquete {
        width: 250px;
        height: 170px;
        padding: 0 !important;
        display: block;
        overflow: hidden;
    }

    .ImPaquete img {
        width: 100%;
    }

    .Item .DPaquete {
        width: auto;
        height: 138px;
        overflow: hidden;
        box-sizing: border-box;
        padding: 5px 10px;
        line-height: 136%;
    }

    .Item h3 {
        width: 100%;
        margin: 8px 0;
        color: #00b3ff;
    }

    .Item h3:hover {
        color: #00b3ff;
    }

    .cont_filtros_barra {
        width: 70%;
        height: auto;
        margin: 10px auto;
        padding: 10px;
        text-align: center;
        display: block;
    }

    #btn_filtros {
        width: 160px;
        font-weight: bold;
        text-decoration: none;
        padding: 12px 0;
        margin: 15px auto;
        color: #FFFFFF;
        cursor: pointer;
        background-color: #00b3ff;
        -webkit-box-shadow: 3px 3px 3px -1px rgba(0, 0, 0, 0.59);
        -moz-box-shadow: 3px 3px 3px -1px rgba(0, 0, 0, 0.59);
        box-shadow: 3px 3px 3px -1px rgba(0, 0, 0, 0.59);
        display: none;
    }

    #btn_filtros:hover {
        background-color: #00b3ff;
    }

    #show_filtros {
        display: inline-block;
        width: 100%;
    }

    .dblock {
        display: inline-block !important;
    }

    .filtros {
        width: auto;
        font-family: Arial, Helvetica, sans-serif;
        font-size: 15px;
        font-weight: bold;
        color: #00b3ff;
        margin: 10px;
        display: inline-block;
        vertical-align: middle;
    }

    .etiqueta_rango {
        width: 80%;
        border: 0;
        color: #ff7200;
        font-weight: bold;
        font-size: 15px;
        margin: 5px auto;
        text-align: center;
        background-color: transparent;
    }

    .barra_filtro {
        width: 120px;
        text-align: center;
        margin: 0 auto;
        padding: 0;
        touch-action: manipulation !important;
    }

    #filtro_destinos select {
        width: 240px;
        height: 41px;
        padding: 0 0 0 10px;
        font-size: 15px;
        font-weight: bold;
        color: #000000;
        border: solid 1px #C0C0C0;
        background-image: url(https://www.tools.megatravel.com.mx/puntos-de-venta/icono-list.jpg);
        background-position: bottom right;
        background-repeat: no-repeat;
        -moz-appearance: none;
        -webkit-appearance: none;
    }

    @media screen and (max-width: 1050px) {}

    @media only screen and (max-width: 768px) {
        .cont_filtros_barra {
            width: 100%;
            padding: 10px 5px;
        }

        #btn_filtros {
            display: block;
        }

        #show_filtros {
            display: none;
        }

        #filtro_destinos select {
            width: 200px;
        }
    }

    @media only screen and (max-width: 300px) {
        .cont_filtros_barra {
            width: 100%;
            padding: 10px 0;
        }

        .filtros {
            width: 100%;
            margin: 10px 0;
        }

        #filtro_destinos select {
            width: 100%;
            font-size: 12px;
            font-weight: bold;
        }

        .Item {
            width: 90%;
            height: auto;
        }

        .ImPaquete {
            width: 100%;
            height: auto;
        }
    }

    h3 {
        font-size: 15px;
    }
</style>

<section class="breadcrumb-area bg-img bg-overlay jarallax" style="background-image: url('<?= $assets_template ?>/template_3/img/banner-seccion/internacionales.jpg');">
        <div class="container h-100">
            <div class="row h-100 align-items-center">
                <div class="col-12">
                    <div class="breadcrumb-content">
                        <h2>Internacionales</h2>
                        <nav aria-label="breadcrumb">
                            <ol class="breadcrumb">
                                <li class="breadcrumb-item"><a href="<?= Yii::app()->createUrl('site/index') ?>">Inicio</a></li>
                                <li class="breadcrumb-item active" aria-current="page" style="background-color: transparent !important;">Internacionales</li>
                            </ol>
                        </nav>
                    </div>
                </div>
            </div>
        </div>
    </section>

<div class="container" style="padding-top:50px;">
    <div class="row">
        <div class="col-12 col-sm-6 col-md-4 col-lg-3">
            <div class="list-group list-group-border-0 g-mb-40" id="list-group-menu">
            </div>
            <?= $this->renderPartial("/site/template_agencia/renders/_bannerAvanzados", array("tipo_segmento" => "Internacionales")); ?>
        </div>
        <div class="col-12 col-sm-6 col-md-8 col-lg-9">

            <?php
            echo $remplazo2;
            if (in_array($_GET['Dest'], $list)) {
                echo $remplazo2Cruceros;
            }
            ?>

        </div>
    </div>
</div>


<?php

Yii::app()->clientScript->registerScript('js_oferta_1', '
$(function(){ $("#input_destino").change(function(){ var input_destino=this.value; location.href="servicios?Dest=" + input_destino;}); $("#btn_filtros").click(function(){ $("#show_filtros").toggleClass("dblock");});});
', CClientScript::POS_END);
Yii::app()->clientScript->registerScriptFile('//code.jquery.com/ui/1.11.4/jquery-ui.min.js', CClientScript::POS_END);
Yii::app()->clientScript->registerScriptFile('//cdnjs.cloudflare.com/ajax/libs/jqueryui-touch-punch/0.2.2/jquery.ui.touch-punch.min.js', CClientScript::POS_END);
Yii::app()->clientScript->registerScript('myjavascript', '
/*----------------inicia funcion barra que filtra por precio-----------------------*/
var  $min_duration = 4;
var $max_duration = 31;
var $min_price 	  = 99.0000;
var $max_price 	  = 23139.0000;

$(function() {
		function showProducts(minPrice, maxPrice) {
			//$("tbody tr").hide().filter(function() {
			$(".Item").hide().filter(function() {
			var price = parseInt($(this).data("price"), 10);
			return price >= minPrice && price <= maxPrice;
			}).show();
		}

    var options = {
        range: true,
        min: $min_price,
        max: $max_price,
        values: [$min_price, $max_price],
        slide: function(event, ui) {
            var min = ui.values[0],
                max = ui.values[1];

            $("#amount").val("$" + min + " - $" + max);
            showProducts(min, max);
        }
    }, min, max;

    $("#slider-range").slider(options);

    min = $("#slider-range").slider("values", 0);
    max = $("#slider-range").slider("values", 1);

    $("#amount").val("$" + min + " - $" + max);
    showProducts(min, max);
});
/*----------------termina funcion barra que filtra por precio-----------------------*/
/*----------------inicia funcion barra que filtra por dias-----------------------*/

$(function() {

   function showProducts(minDuration, maxDuration) {
    $(".Item").hide().filter(function() {
        var duration = parseInt($(this).data("duration"), 10);
        return duration >= minDuration && duration <= maxDuration;
    }).show();
   }

    var options = {
        range: true,
        min: $min_duration,
        max: $max_duration,
        values: [$min_duration, $max_duration],
        slide: function(event, ui) {
            var min = ui.values[0],
                max = ui.values[1];

            $("#amount2").val(min + " días - " + max + " días");
            showProducts(min, max);
        }
    }, min, max;

    $("#slider-range2").slider(options);

    min = $("#slider-range2").slider("values", 0);
    max = $("#slider-range2").slider("values", 1);

    $("#amount2").val(min + " días - " + max + " días");

    showProducts(min, max);
});
/*----------------termina funcion barra que filtra por dias-----------------------*/


', CClientScript::POS_END);


Yii::app()->clientScript->registerScript('getMenuHtml', '
var baseUrl = "' . Yii::app()->baseUrl . '";
var destinos = document.querySelectorAll("#input_destino option");
    var newArray = Array.apply(null, destinos);
    var array = [];
    var htmlMenu = "";
    for (let i = 0; i < newArray.length; i++) {

        if(i > 0){
        htmlMenu += `
            <a href="${baseUrl}/servicios?Dest=${newArray[i].value}" class="list-group-item list-group-item-action justify-content-between">
                <span>
                    <i class="icon-cursor g-pos-rel g-top-1 g-mr-8"></i>
                    ${newArray[i].innerText}
                </span>
            </a>
        `;
         }

        // array.push({
        //     value: newArray[i].value,
        //     nombre: newArray[i].innerText
        // })
    }
    $("#list-group-menu").html(htmlMenu);
', CClientScript::POS_END);

if (in_array($_GET['Dest'], $list)) {
    Yii::app()->clientScript->registerScript('removeHTML', '
    document.getElementById("cont_of").remove();
    ', CClientScript::POS_END);
    Yii::app()->clientScript->registerCss('table_megatravel', '

body {
    font-family: Arial, sans-serif;
    color: #;
    margin: 0px;
    padding: 0px;
        }
body .city_iframe{
  display: none;
}
body table .city_iframe{
  display: initial;
}
label, legend {
    font-family: Arial, Helvetica, sans-serif;
    color: #;
    font-size: 12px;
    }
#activa_filtros{
    width:127px;
    margin:20px auto 10px auto;
    display:none;
}
.cont_filtros_barra{
    width:20%;
    height:auto;
    margin:10px 5px 10px 20px;
    padding:10px;
    text-align:center;
    /*background-color:#EFBE2E;*/
    border: dashed 1px #B4B4B4;
    display: block;
    float:left;
            }
.filtros {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    width:auto;
    margin:10px auto 10px auto;
    /*background-color:#7FE7DF;*/
    display:inline-block;"
    }
.etiqueta_rango{
    width:80%;
    border:0;
    color: #666666;
    font-weight:bold;
    font-size:13px;
    margin:5px auto;
    text-align:center;
    background-color:transparent;
    /*background-color:#8CC2E9;*/
}
.barra_filtro{
    width:120px;
    text-align: center;
    margin:0 auto;
    padding:0;
    /*background-color:#DB9E9F;*/
}
/*.ui-widget { font-size: 1em; }*/
.cont_botones_check{
    width:70%;
    height:auto;
    text-align:left;
    margin:10px 20px 10px 5px;
    padding:10px;
    border: dashed 1px #B4B4B4;
    display:block;
    float: right;
}
.botones_check{
    width:auto;
    min-width:70px;
    display: inline-block;
    margin:5px;
    text-align:left;
    /*border:solid 1px #B4B4B4;*/
}
.botones_mostrar_filtros{
    height:30px;
    display:inline-block;
    vertical-align: bottom;
    margin:5px 5px 5px 5px
}
#table-rp{
    width:100%;
    border:none;
    padding:5px 0;
    margin:0;
    border-collapse: separate;
    border-spacing:0;
}
#table-rp th {
    font-size: 15px;
    letter-spacing:-1px;
    font-weight: normal;
    padding:0; margin:0;
    /*border:solid 1px #C40003;*/
    border:none;
    background-color: #666666;
    color: #CCCCCC;

        }
#table-rp tr {
    padding:0; margin:0;
    border:none;
}
#table-rp td {
    font-size: 13px;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: #CCCCCC;
    padding:10px 5px;
    text-align:center;
}
#table-rp a{ text-decoration:none;  }
.nom_paquete{ text-align:left; padding:0 0 0 10px; }
.ShortMsg {
    font-size: 13px;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: #CCCCCC;
    font-style: italic;
    font-weight: bold;
    text-align: right;
    margin-right: 15px;
    color: #;
}
tr.alt td {
  background-image: url("https://img2.mtmedia.com.mx/bg-td-mega-enlace.png");
    background-repeat: repeat;
}
a {
    color: #;
    font-size: 13px;
}
a:hover {
    color: #;
}
#imageField {
    padding-top: 0px;
}
/*Por debajo de 1050px yellow2*/
@media  screen and (max-width: 1050px){

    .cont_filtros_barra{ width:25%;
                }
    .cont_botones_check{ width:60%; }
}
/*Por debajo de 768px green*/
@media  only screen and (max-width: 768px){
    #ciudades{ display: none; }
    #tit_ciudades_visitadas{ display: none; }

#activa_filtros{
    display: block;
}
.cont_filtros_barra{
    width:90%;
    padding:0;
    margin:0 auto;
    float:none;
    display:none;
}
.filtros {
    display:block;
}
.cont_botones_check{
    float:none;
    margin:10px auto 10px auto;
    padding:0;
    width:90%;
    display:none;
}
.nom_paquete{ text-align:left; padding:0 0 0 0; }
}


');
}
?>