var bMobile = false;
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) { bMobile = true; }
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
var bGeneralError = false;
(function($) {
$(document).ready(function() {
var myURL = window.location.pathname.replace('/pasonw', '');
myURL = myURL.replace('/', '');
var aParams = myURL.split('-');
var sOrigin = aParams[0];
console.log ( 'File: index' );
//var $button = $("li a[title='Mi Viaje']"),
var $button = $("#hdr_miviaje,#menu_miviaje");
var ql_bg = '#quick-login-bg';
var ql_pnl = '#quick-login-panel';
var pS_bg = '#darkenwrapper';
var $buttonNews = $("#newsletterregister2");
if ( sOrigin!="gestion" ) {
if ($(pS_bg).length) {
ql_bg = pS_bg;
}
$button.click(function(e){
//console.log("Button");
e.preventDefault();
$(ql_bg + ', ' + ql_pnl).fadeIn(300);
$("#quick-login-bg").attr('style', 'display: block;');
});
/*
var $buttonResponsive = $(".wsmenu-click");
$buttonResponsive.click(function(e){
//console.log("ButtonResponsive");
e.preventDefault();
$(ql_bg + ', ' + ql_pnl).fadeIn(300);
$("#quick-login-bg").attr('style', 'display: block;');
});
*/
$buttonNews.click(function(e){
//console.log("ButtonNews");
e.preventDefault();
$(ql_bg + ', ' + ql_pnl).fadeIn(300);
$("#quick-login-bg").attr('style', 'display: block;');
});
$(ql_bg + ', #quick-login-panel .close').click(function () {
//console.log("Button Close");
$(ql_bg + ', ' + ql_pnl).fadeOut(300);
$("#quick-login-bg").attr('style', 'display: none;');
});
// Enter Key
$(document).keypress(function(event){
if (event.which=='13') {
event.preventDefault();
}
});
// ESC Key
$(document).keyup(function(event){
if(event.which=='27'){
//$(ql_bg + ', ' + ql_pnl).fadeOut(300);
//$("#quick-login-bg").attr('style', 'display: none;');
}
});
}
btnWeb();
//console.log ( window.location.pathname.replace('/pasonw/', '') );
if ( sOrigin=="gestion" ) {
/*
$(ql_bg + ', ' + ql_pnl).fadeIn(300);
$("#quick-login-bg").attr('style', 'display: block;');
*/
validate(myURL);
} else if ( getParameterByName('validate')!="" ) {
$(ql_bg + ', ' + ql_pnl).fadeIn(300);
$("#quick-login-bg").attr('style', 'display: block;');
validate( 'init-' + getParameterByName('validate') );
} else {
validate('init');
}
btnCallback();
});
})(jQuery);
function btnWeb () {
console.log("Web");
$("#newsletterregister2").each(function(){
//console.log("Newsletter "+this.id);
$("#"+this.id).off('click').click(function(e){
e.preventDefault();
bGeneralError = false;
console.log("newsletterregister2 Clicked");
validate("newsletterregister2");
console.log("Validating newsletterregister2");
});
});
$(".btnReserva").each(function(){
//console.log("Book "+this.id);
$("#"+this.id).off('click').click(function(e){
e.preventDefault();
bGeneralError = false;
//console.log("Book Clicked "+this.id);
validate("booking-"+this.id.replace("VM","")); // 20230619 Botón Header Versión Móvil
validate("booking-"+this.id.replace("V",""));
//console.log("Validating booking-"+this.id);
});
});
$(".btnDeseo").each(function(){
//console.log("whislist "+this.id);
$("#"+this.id).off('click').click(function(e){
e.preventDefault();
bGeneralError = false;
validate("wishlist-"+this.id.replace("W",""));
});
});
}
function validate(sAction,bPartialField='') {
console.log(sAction);
if ( bGeneralError==true ) {
console.log ("General Error. Review");
return false;
}
if ( sAction!="init" ) {
var ql_bg = '#quick-login-bg';
var ql_pnl = '#quick-login-panel';
$(ql_bg + ', ' + ql_pnl).fadeIn(300);
}
var myobject = $("#appForm");
var data = myobject.serialize();
console.log (data);
data += ( $('#token').length ) ? "&token=" + $("#token").val() : "";
data += ( $('#tokenize').length ) ? "&tokenize=" + $("#tokenize").val() : "";
data += '&action=' + sAction;
data += '&path=' + window.location.pathname;
console.log( "Action: " + sAction + ' - ' + bPartialField );
console.log( "Data: " + data );
if ( sAction!="" || ( sAction=="serviceme" && data=="" ) ) {
$.ajax({
url: 'https://www.pasonoroeste.com/oficinator/releases/20231212/class/user_callback.php',
type: 'POST',
data: data,
cache: false,
beforeSend: function() {
$("#info").html('');
$("#info").fadeOut();
if ( sAction=="login" ) {
$("#login").html('Comprobando datos
');
if ( sAction=="logout" ) { $("#miviaje").css('background-color','transparent'); }
}
},
success: function (response) {
var iFadeIn = 0;
var bAction = true;
var aResponse;
aResponse = response.split('|');
var url = "";
console.log( "Action: " + sAction );
console.log( "Response: " + response );
if ( bPartialField!='' ) {
if ( aResponse[0]=="ok" ) {
console.log ("Partial: " + bPartialField + " > " + aResponse[4]);
if ( aResponse[4]=="" ) {
$("#"+bPartialField).html("");
} else {
$("#"+bPartialField).html(aResponse[4]);
}
}
} else {
switch ( aResponse[0] ) {
case "ok":
case "formwindow":
break;
case "redirect":
url = aResponse[6];
$(location).attr('href',url);
break;
case "newwindow":
url = aResponse[6];
console.log(url);
window.open(url, '_blank');
break;
case "error":
case "warning":
break;
default:
bAction = false;
$("#info").fadeIn(iFadeIn, function(){ $("#info").html(""); });
$("#appbody").html("");
$("#myitems").html("");
console.log( "No Action: " + aResponse[0] );
}
// App Header
$("#appmenu").html(aResponse[2]);
$("#appfooter").html(aResponse[5]);
if ( bAction==true ) {
// App
//$("#info").fadeIn(iFadeIn, function(){ $("#info").html(aResponse[3]); });
if (aResponse[3]!="") {
appDGC(aResponse[3]);
}
$("#appbody").html(aResponse[4]);
$("#myitems").html(aResponse[1]);
// Header (button)
$("#miviaje").css("background-color", "");
if ( $('#token').length ) {
if ( $("#token").val()!="" ) {
$("#miviaje").attr('style', 'background-color: #5a9ad1 !important');
}
}
switch ( aResponse[0] ) {
case "formwindow":
if ( $("#my_payment").length ) {
//setTimeout(' $("#my_payment")[0].click(); ', 3000 );
}
break;
default:
}
var mywidth = 50;
if ( !bMobile && $(window).width()>768 ) {
mywidth = ( aResponse[7]=="" || aResponse[7]==0 ) ? 40 : aResponse[7];
} else {
mywidth = 95;
}
// App Width
//https://www.w3schools.com/jquery/eff_animate.asp
$("#quick-login-panel").animate({ "width": mywidth + "%"}, 1500);
// App Log
$("#mylog").html(aResponse[8]);
switch ( sAction ) {
case "start":
if ( 1 ) {
}
break;
default:
}
}
}
$("#"+sAction).prop("disabled",false);
btnCallback();
}
});
} else {
console.log("Fatal Error");
exit;
}
return false;
}
function checkMySession2025() {
var aResponse = "";
$.ajax({
url: 'https://www.pasonoroeste.com/oficinator/releases/20231212/class/modes.php',
type: 'POST',
dataType: "html",
data: {
action: 'checkAppSession',
},
success: function (response)
{
var aResponse = response.split("|");
var iNextCheck = 30;
if ( aResponse[0]=="ERROR" ) {
console.log(aResponse[1]);
} else if ( aResponse[0]=="OK" ) {
iNextCheck = 10;
if ( aResponse[2]!="" ) {
console.log(aResponse[1]);
eval(aResponse[2]);
}
}
setTimeout(function() {
checkMySession2025();
}, iNextCheck*1000);
},
error: function(XMLHttpRequest, textStatus, exception) { alert("Ajax failure\n" + errortext); },
async: false
});
}
setTimeout(function() {
checkMySession2025();
}, 3000);
function btnCallback() {
windowHeight = $(window).height();
windowWidth = $(window).width();
console.log("btnCallback");
var ql_bg = '#quick-login-bg', ql_pnl = '#quick-login-panel';
/*documentHeight = $(document).height();
documentWidth = $(document).width();
screenHeight = screen.height;
screenWidth = screen.width;
windowHeightAvailable = window.innerHeight;
windowWidthAvailable = window.innerWidth;*/
appHeaderHeight = ( $(".mytheme1header").height() == 0 ) ? $(".mytheme1header").height() : 40;
appHeaderWidth = $(".mytheme1header").width();
appFooterHeight = ( $(".mytheme1footer").height() == 0 ) ? $(".mytheme1footer").height() : 40;
appFooterWidth = $(".mytheme1footer").width();
var calcMaxHeight = ( windowHeight-appHeaderHeight-appFooterHeight-45 ); // 10px por encima y por abajo. 10px del margin appbody a appheader y 10px del margin appbody a appfooter
$(".scroll").css('maxHeight', calcMaxHeight + 'px');
if ( windowWidth<900 ) {
calcMaxWidth = windowWidth-20;
$("#quick-login-panel").css('width', calcMaxWidth + 'px');
} else {
calcMaxWidth = windowWidth;
}
/*alertDGC( "Window: H: " + windowHeight + " W: " + windowWidth + "
" +
"App Header: H: " + appHeaderHeight + " W: " + '' + "
" +
"App Footer: H: " + appFooterHeight + " W: " + '' + "
" +
"App Calc: H: " + calcMaxHeight + " W: " + calcMaxWidth);
*/
/*
alertDGC( "Window: H: " + windowHeight + " W: " + windowWidth + "
" +
"App Header: H: " + appHeaderHeight + " W: " + '' + "
" +
"App Footer: H: " + appFooterHeight + " W: " + '' + "
" +
"App Calc: H: " + calcMaxHeight + " W: " + calcMaxWidth + "
" +
"Document: H: " + documentHeight + " W: " + documentWidth + "
" +
"Screen: H: " + screenHeight + " W: " + screenWidth);
});*/
$('button[id^="verdatos"]').off('click').click(function(e){
e.preventDefault();
var sId = this.id;
var i = sId.replace("verdatos", '');
$('div[id^="datousuario"]').removeClass("data-selected");
$('button[id^="verdatos"]').removeClass("btn-selected");
$("#datousuario" + i).addClass("data-selected");
$("#verdatos" + i).addClass("btn-selected");
});
jQuery('.mDetalle').each(function(){
var data = jQuery(this).attr('data-url');
var aData = data.split("-");
var type = aData.shift();
var destination = aData.join("-");
var contenido = jQuery(this).html();
jQuery(this).replaceWith(jQuery(''+contenido+''));
});
$("#appForm .ajCheck").each(function(){
//console.log ( $(this).attr("name") + ' > ' + this.id );
$("#"+this.id).on('click', function () {
console.log("callAjax(" + $(this.id) + ",'checkbox')");
callAjax(this.id,'checkbox');
});
});
$("#appForm .ajCheckDisable").each(function(){
//console.log ( $(this).attr("name") + ' > ' + this.id );
$("#"+this.id).on('click', function () {
console.log("callAjax(" + this.id + ",'checkbox','disable')");
callAjax(this.id,'checkbox','disable');
});
});
$("#appForm .ajInput").each(function(){
var bInputError;
bInputError = false;
//console.log ( $(this).attr("name") + ' > ' + this.id );
$("#"+this.id).on('change', function () {
console.log("try to change '" + $("#"+this.id).attr("name") + "' > callAjax(" + $(this.id) + ",'input')");
var sName = $("#"+this.id).attr("name");
if ( sName=="iban_coordinador" || sName=="iban_viajero" ) {
var myiban = $("#"+this.id).val()
var myibanTmp = myiban.replaceAll(" ", "");
if ( myibanTmp!="" && fn_ValidateIBAN(myibanTmp) == false ) {
bInputError = true;
alertDGC("
');
$("#btnAceptar").hide();
$("#saving").text("Guardando. Espera por favor ...");
$.ajax({
url: "releases/20231212/class/user_save.php", // Save Data
type: 'POST',
data: formData,
async: false, // Stop here until get response back
cache: false,
contentType: false,
processData: false,
success: function(response) {
console.log ("Success: "+ response);
var aReason;
aReason = response.split('|');
if ( aReason[0]!="ok" ) {
if ( aReason[0]=="warning" ) {
$("#saving").text(aReason[1]);
} else {
var sReasonTxt = "";
if ( aReason[1]=="" ) {
sReasonTxt = "Error: ha habido un fallo al guardar";
} else {
sReasonTxt = "Error: " + aReason[1];
}
console.log(sReasonTxt);
alertDGC(sReasonTxt);
}
$("#btnAceptar").show();
$("#saving_icon").hide();
} else {
console.log ("Información guardada");
//$("#saving").text("Información Guardada");
$("#MyDataSaved").val('saved');
}
//console.log ("Status Response: " + aReason[0]);
if ( aReason[0]=="ok" ) {
if ( $('#fileToUpload1' ).length ) {
//console.log ( $('#fileToUpload1' ).length );
var MyFileData = $('#fileToUpload1').prop('files')[0];
if ( MyFileData==undefined ) {
console.log ("No hay imagen");
$("#saving").html("Guardado correctamente