delete sio; sio = new Object(); if (sio == undefined) { sio = new Object(); } jQuery(document).ready(function() { if (sio.ajax == undefined) { sio.ajax = new Object(); } if (sio.form == undefined) { sio.form = new Object(); } sio.form.input = new Array(); sio.reloadweb=function() { location.reload(); //redirect_url = encodeURIComponent(window.location.href); //url = window.location.href + "account/login?redirect_url=" + redirect_url; //window.location.replace(url); //.location.href="http://192.168.0.37/passwordtool/jobboards.php"; //window.location.reload(); } sio.actualizarweb=function(web) {alert("1111"); location.href = web; location.reload(); alert("222"); } sio.form_get_actualizar=function(idformuraio,retaregreso) { var esperarrespuesta; $.ajax({ url: retaregreso, method: 'GET', data: $("#"+idformuraio).serialize(), cache: false,    async: false, success: function (response) { //alert('Your form has been sent successfully.'); console.log(response); if(response.proceso_exito>0) { Swal.fire({ position: "top-end", icon: "success", title: "Guardodo con exito", showConfirmButton: false, timer: 1500, timerProgressBar: true, didOpen: () => { }, willClose: () => { if(response.proceso_exito>0) { sio.reloadweb(); } } }).then((result) => { }); } esperarrespuesta=response; }, error: function (xhr, status, error) { // alert('NO SE LOGRO EJECUTAR LA SOLICITUD'); Swal.fire({ position: "top-end", icon: "error", title: "No logro cargar la infomacion", showConfirmButton: false, timer: 1500 }); console.error(error); } }); return esperarrespuesta; } sio.ultimo_proceso=function(informacion) { //se recibe un array y lo convertimos en json y de ahi vamos vamos a extraer algunas variables que nos intenresen... var json = $.parseJSON(informacion); // para reiniciar la pagina vamos a preguntar por la variable erro de login si ya tiene mas de 3 intentos entonces se reinicia para el proceso // php muestre lo que tenga que mostrar... if(json.intentossession>=5) {sio.reloadweb(); } } sio.ajax.reload2=function(dir,div) { //alert(div); if (div) { div=div; } else { div='div_NULL'; } var destruir_cadena_replace= 'on='+dir; destruir_cadena_replace=destruir_cadena_replace; $.ajax({ data: null, url: 'https://servicioportuario.com/ajax2.php?'+destruir_cadena_replace, type: 'post', contentType: false, processData: false, beforeSend: function () { $('#'+div).html('Cargando....'); }, success: function (response) { $('#'+div).html(response); } }); } sio.ajax.reload3=function(rutaon,dir,div) { var valor_tomar; //alert(div); if (div) { div=div; } else { div='div_NULL'; } //alert(div); //var destruir_cadena_replace= 'on='+dir; //destruir_cadena_replace=destruir_cadena_replace; $.ajax({ data: dir, url: rutaon,    async: false, type: 'post', contentType: false, processData: false, beforeSend: function () { $('#'+div).html(''); }, success: function (response) { $('#'+div).html(response); //alert("respuesta:"+response); valor_tomar=response; } }); return valor_tomar; } /*para realizar multibles id en debug*/ sio.increment_debug=1; sio.ajax.reload = function(dir,div) { if (div) { div=div; } else { div='div_NULL'; } var destruir_cadena_replace= 'on='+dir; destruir_cadena_replace=destruir_cadena_replace; $.ajax({ data: destruir_cadena_replace, url: 'https://servicioportuario.com/ajax.php', type: 'post', beforeSend: function () { $('#'+div).html(''); }, success: function (response) { $('#'+div).html(response); } }); }; sio.form.post = function(hId, hDomToLoad) { sio.quitar_autoNumeric(); var data = new FormData(); oForm = document.getElementById(hId); if (oForm) { //alert(oForm); //console.log(oForm); if (oForm.target) { aElements = oForm.elements; sFormPostValues = ''; for (i=0; i < aElements.length; i++) { oElement = aElements[i]; sElementID = oElement.getAttribute("id"); if ((sElementID != null)&&(sElementID != '')) { bSendLocal = true; if (oElement.type == 'file') { jQuery.each($('#'+sElementID)[0].files, function(i, file) { //para array seria algo asi //data.append('file2-'+i, file); data.append(sElementID, file); // alert(file); }); } if (oElement.type == 'textarea') { // $('#'+sElementID).val($('#'+sElementID).val()); data.append(sElementID, $('#'+sElementID).val()); } if ((oElement.type == 'text')||(oElement.type == 'password') ||(oElement.type == 'number')) { //data.append(sElementID, $('#'+sElementID).val()); data.append(sElementID,oElement.value); // data.append(sElementID, $('#'+sElementID).attr('value')); // data.append(sElementID,{key1 : value1 , key2 : value2 }); //jQuery.each($('#'+sElementID), function(key, value) { // data.append('sElementID['+key+']', value); //}); // jQuery.each($('#'+sElementID).files, function(i, file) { // data.append(sElementID+"["+i+"]", file); // data.append(sElementID, file); // }); } //alert(oElement.value); if((oElement.type =='select-one') ) { data.append(sElementID,oElement.value); //alert(sElementID+":::"+oElement.value); } if((oElement.type == 'select-multiple')) { var value = $('#'+sElementID).val(); var contenedor = value ? ''+value+'' : value; data.append(sElementID,contenedor); delete value; delete contenedor; } if((oElement.type == 'checkbox') ||(oElement.type == 'radio') ) { if(oElement.checked==true) { data.append(sElementID,oElement.value); } else { data.append(sElementID,''); } //alert(sElementID+":::"+oElement.checked); } } } data.append("on", oForm.target); if(hDomToLoad == undefined) { //alert('rrrrrrrrrrrrrrr'); return sio.ajax.reload3(oForm.target,data); } else { var temx=hDomToLoad.toString(); return sio.ajax.reload3(oForm.target,data,temx); } } } }; sio.form.post3 = function(hId, hDomToLoad) { sio.quitar_autoNumeric(); var data = new FormData(); oForm = document.getElementById(hId); if (oForm) { //alert(oForm); //console.log(oForm); if (oForm.target) { aElements = oForm.elements; sFormPostValues = ''; for (i=0; i < aElements.length; i++) { oElement = aElements[i]; sElementID = oElement.getAttribute("id"); if ((sElementID != null)&&(sElementID != '')) { bSendLocal = true; if (oElement.type == 'file') { //IMPORTANTE este es solo los archivos unicos no esta preparado para los array que no es dificil pero no esta actualmente preparado jQuery.each($('#'+sElementID)[0].files, function(i, file) { //para array seria algo asi //data.append('file2-'+i, file); data.append(sElementID, file); // alert(file); }); } if (oElement.type == 'textarea') { if($('#'+sElementID).hasClass("tinymce")) { data.append(sElementID,tinymce.get(sElementID).getContent()); } else{ // $('#'+sElementID).val($('#'+sElementID).val()); data.append(sElementID, $('#'+sElementID).val()); } } if ((oElement.type == 'text')||(oElement.type == 'password') ||(oElement.type == 'number')) { //data.append(sElementID, $('#'+sElementID).val()); data.append(sElementID,oElement.value); // data.append(sElementID, $('#'+sElementID).attr('value')); // data.append(sElementID,{key1 : value1 , key2 : value2 }); //jQuery.each($('#'+sElementID), function(key, value) { // data.append('sElementID['+key+']', value); //}); // jQuery.each($('#'+sElementID).files, function(i, file) { // data.append(sElementID+"["+i+"]", file); // data.append(sElementID, file); // }); } //alert(oElement.value); if((oElement.type =='select-one') ) { data.append(sElementID,oElement.value); //alert(sElementID+":::"+oElement.value); } if((oElement.type == 'select-multiple')) { var value = $('#'+sElementID).val(); var contenedor = value ? ''+value+'' : value; data.append(sElementID,contenedor); delete value; delete contenedor; } if((oElement.type == 'checkbox') ||(oElement.type == 'radio') ) { if(oElement.checked==true) { data.append(sElementID,oElement.value); } else { data.append(sElementID,''); } //alert(sElementID+":::"+oElement.checked); } } } data.append("on", oForm.target); if(hDomToLoad == undefined) { //alert('rrrrrrrrrrrrrrr'); return sio.ajax.reload3(oForm.target,data); } else { var temx=hDomToLoad.toString(); return sio.ajax.reload3(oForm.target,data,temx); } } } }; aArray_Localx= new Array; aArray_Localx[0]= new Array; aArray_Localx[0]["omar"]="omarsillo"; aArray_Localx[0]["aaa"]="jajjajaj"; sio.readyAllArray=function (aArray_Local) { var elements=""; //alert( aArray_Local); $.each(aArray_Local, function(i, n) { //alert( "Name: " + i + ", Value: " + n ); if(n==Array) { elements=elements+"##"+sio_readyAllArray(n); } else{ elements=elements+"
-----"+i+":"+n; } }); return elements; } //alert(sio.readyAllArray(aArray_Localx)); sio.degub_load=function(sNameTitle_Local,sElement_Local) { var cadena='---------x--'+sNameTitle_Local+"--"+sio.increment_debug+'
'+sio.readyAllArray(sElement_Local); cadena=cadena+'
'; $('#debug_dialog #debug_elemet').append(cadena); sio.increment_debug++; } sio.alerta_info=function(stitulo,scadena) { var notice = '
' + '
' + '' + '

'+stitulo+'

' + '

'+scadena+'

' + '
' + '
' + '
' + '
'; //alert(stitulo+scadena); alertify.success(scadena); //noty({text: notice, layout: 'topRight', type: 'success'}); //$.mpb('destroy'); var topSpotInt = setInterval( function () { // Check to see if our notice is the first non-sticky notice in the list if ( $('.not-sticky').length == 0 ) { // Stop checking once the condition is met clearInterval( topSpotInt ); // Call the close action after the timeout set in options setTimeout( function () { // $.noty.closeAll(); } ); } }, 5000 ); } sio.alerta_error=function(stitulo,scadena) { var notice = '
' + '
' + '' + '

'+stitulo+'

' + '

'+scadena+'

' + '
' + '
' + '
' + '
'; // alertify.error(scadena); //alert(stitulo+scadena); //noty({text: notice, layout: 'topRight', type: 'success'}); var topSpotInt = setInterval( function () { // Check to see if our notice is the first non-sticky notice in the list if ( $('.not-sticky').length == 0 ) { // Stop checking once the condition is met clearInterval( topSpotInt ); // Call the close action after the timeout set in options setTimeout( function () { //$.noty.closeAll(); } ); } }, 5000 ); } sio.alerta_alert=function(stitulo,scadena) { var notice = '
' + '
' + '' + '

'+stitulo+'

' + '

'+scadena+'

' + '
' + '
' + '
' + '
'; //alert(stitulo+scadena); alertify.log(scadena); //noty({text: notice, layout: 'topRight', type: 'success'}); //$.mpb('show',{value: [0,60],speed: 10,state: 'warning'}); var topSpotInt = setInterval( function () { // Check to see if our notice is the first non-sticky notice in the list if ( $('.not-sticky').length == 0 ) { // Stop checking once the condition is met clearInterval( topSpotInt ); // Call the close action after the timeout set in options setTimeout( function () { // $.noty.closeAll(); } ); } }, 5000 ); } sio.quitar_autoNumeric=function() { $(".autoNumeric").each(function() { $(this).val($(this).autoNumericGet()); }); $(".autoNumeric1").each(function() { $(this).val($(this).autoNumericGet()); }); } sio.quitar_numero=function(nombreclase) { $("."+nombreclase).each(function() { $(this).val($(this).autoNumericGet()); }); } sio.mascara_numero=function(nombreclase) { $('.'+nombreclase).formatCurrency({ roundToDecimalPlace: 2 }); } sio.poner_autoNumeric=function() { $(".autoNumeric").autoNumeric({aSep: ',', aDec: '.'}); } sio.mascara_autoNumeric=function() { $('.autoNumeric').formatCurrency({ roundToDecimalPlace: 2 }); $('.autoNumeric1').formatCurrency({ roundToDecimalPlace: 2 }); } sio.mascara_autoNumeric_4=function() { $('.autoNumeric').formatCurrency({ roundToDecimalPlace: 4}); $('.autoNumeric1').formatCurrency({ roundToDecimalPlace: 4 }); } sio.poner_teclado_numerico=function() { $('.autoNumeric') .keyboard({ layout : 'num', restrictInput : true, selectvalue:true, numerico:true, preventPaste : true, autoAccept : true }) .addTyping(); } sio.poner_teclado_completo=function() { $('.teclado_completo') .keyboard({ layout : 'qwerty', lockInput: false }) .addTyping(); } sio.parseDate=function(id) { // var m = str.match(/^(\d\d)\.(\d\d)\.(\d{4}) (\d\d):(\d\d)$/); //return (m) ? new Date(m[3], m[2]-1, m[1], m[4], m[5]) : null; if($('#'+id).val()!='') { var datos = $('#'+id).val().split(" "); var datos1 = datos[0].split("-"); var datos2 = datos[1].split(":"); // alert(datos2[0]); $('#'+id).datetimepicker('setDate', (new Date(datos1[0], Number(datos1[1])-Number(1), datos1[2], datos2[0],datos2[1]))); delete datos; delete datos1; delete datos2; } //$('#input_fecha').datetimepicker('setDate', (new Date(2010, 11, 20, 16, 03))); } /* NUEVOS METODOS CON ESTE PROCESO */ /* ##################################################### ##########################################################################################################*/ /* ##################################################### ##########################################################################################################*/ /* ##################################################### ##########################################################################################################*/ /* ##################################################### ##########################################################################################################*/ /* ##################################################### ##########################################################################################################*/ /* ##################################################### ##########################################################################################################*/ // este metodo es par validar todo los input que se considern de email y poder seguir dar el ok para enviar el formulario sio.validar_correo_electronico=function(id_form,id_input) { var breturn=false; if ($("#"+id_form+" #"+id_input).val() == '') { $('.invalid-feedback').html("Ingresa un correo"); $("#"+id_form+" #"+id_input+'.email').addClass('is-invalid'); $("#"+id_form+" #"+id_input+'.email').keypress(function(){ $("#"+id_form+" #"+id_input+'.email').removeClass('is-invalid'); $("#"+id_form+'.invalid-feedback').html(""); }); $("#input_email_1").focus(); } else { $("#"+id_form+" #"+id_input+'.email').keypress(function(){ $("#"+id_form+" #"+id_input+'.email').removeClass('is-invalid'); $("#"+id_form+'.invalid-feedback').html(""); }); var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; if( !emailReg.test( $("#"+id_form+" #"+id_input).val() ) ) { $("#"+id_form+'.invalid-feedback').html("Ingresa un correo valido"); $("#"+id_form+" #"+id_input+'.email').addClass('is-invalid'); } else { $("#"+id_form+" #"+id_input+'.email').removeClass('is-invalid'); $("#"+id_form+'.invalid-feedback').html(""); breturn=true; } } return breturn; } sio.validar_input_vacio=function(input,mensaje_positivo,mensaje_negativo) { if($(input).val().trim()=="") { if(mensaje_negativo!="") { sio.alerta_error("Error",mensaje_negativo); } $(input).focus(); return false; } else { if(mensaje_positivo!="") { sio.alerta_info("Error",mensaje_positivo); } return true; } } sio.function_enter=function(formulario,class_enter) { $("#"+formulario+" ."+class_enter).bind("keydown", function(e) { var n = $("#"+formulario+" ."+class_enter).length; if (e.which == 13 || e.which==9 ) { //Enter key e.preventDefault(); //to skip default behavior of the enter key var nextIndex = $("#"+formulario+" ."+class_enter).index(this) + 1; if(nextIndex < n) $("#"+formulario+" ."+class_enter)[nextIndex].focus(); else { // $('#{{{$id_formulario}}} .input-enter')[nextIndex-1].blur(); // alert("listo final"); //$('#select_tipo_pago_id').focus(); } } }); } sio.enter_input=function(input_oigen,input_destino) { document.getElementById(input_oigen).addEventListener('keydown', function(event){ if (event.keyCode == 13) { document.getElementById(input_destino).focus(); } }); } }); //Dropzone.autoDiscover = false; sio.crear_dropzone=function(id_input_creador,do_form_id,donde_viene,donde_viene_tipo,archivos_plantilla,listaimagenes) { var temarchivos=""; if(archivos_plantilla=="imagen") { temarchivos=".png, .jpg, .jpeg"; } if(archivos_plantilla=="archivo") { temarchivos=".pdf, .xml, .xlsx, .xltx, .docx, .docm"; } if(archivos_plantilla=="mixto") { temarchivos=".png, .jpg, .jpeg, .pdf, .xml, .xlsx, .xltx, .docx, .docm"; } var myDropzone = new Dropzone(do_form_id, { url: "https://servicioportuario.com/herramientas/subir_archivo", parallelUploads: 10, maxFiles: 10, maxFilesize: 10, addRemoveLinks: true, dictRemoveFile: "Eliminar", acceptedFiles: temarchivos, dictInvalidFileType : "Este tipo de archivo no esta permitido", dictMaxFilesExceeded : "No puedes subir mas archivos", dictDefaultMessage: "

Busca el archivo que deseas buscar

", init: function() { var thisDropzone = this; $.getJSON("ajax2.php?on=Herramientas/leer_imagenes/"+listaimagenes).done(function (data) { $.each(data, function (index, item) { // Create the mock file: var mockFile = { name: item.name, size: item.size, type: item.ext, ruta_limpia: item.ruta_limpia, nominationId: item.nominationId, serverId: item.serverId, media: "evaluation_files" }; thisDropzone.emit("addedfile", mockFile); // CREATE THUMBNAIL IF THE FILE TYPE IS IMAGE if (item.ext == "jpg" || item.ext == "jpeg" || item.ext == "png") { // thisDropzone.emit("thumbnail", mockFile, "timthumb.php?src=uploads/" + item.file + "&w=40&h=40"); thisDropzone.emit("thumbnail", mockFile, "https://servicioportuario.com/"+mockFile.ruta_limpia); // thisDropzone.emit("complete", mockFile); } thisDropzone.emit("complete", mockFile); $(do_form_id).append(""); }); }); this.on("maxfilesexceeded", function(file) { // alert("No more files please!"); }); this.on("success", function(file, response) { const obj = JSON.parse(response); // console.log(obj); $(do_form_id).append(""); // alert("zzzz"+response.id); file.serverId = obj.id_creado; $(file.previewTemplate).find('.dz-custom-download').attr("href", "https://servicioportuario.com/herramientas/subir_archivo/" + file.serverId); $(file.previewTemplate).find('.dz-custom-delete').off().on("click", function(e) { e.preventDefault(); myDropzone.emit("removedfile", file); }); if(obj.error_id==1) { sio.alerta_error("error",obj.error_descripcion); //eliminar si no se logo guardar // myDropzone.options.maxFiles = myDropzone.options.maxFiles + 1; var _ref; return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0; } }); this.on("addedfile", function(file) { var preview = $(file.previewTemplate); //console.log(file); preview.append(''); preview.find('.dz-custom-download').attr("href","https://servicioportuario.com/herramientas/subir_imagenes/" + file.serverId); $(file.previewTemplate).find('.dz-custom-delete').off().on("click", function(e) { e.preventDefault(); myDropzone.emit("removedfile", file); }); }); this.on("removedfile", function(file) { $("."+id_input_creador+"_tem_"+file.serverId+"").remove(); var name = file.name; console.log(file); $.ajax({ type: 'POST', url: 'https://servicioportuario.com/herramientas/eliminar_archivo_antes_subir', data: {name: name,request: 2,id_archivo:file.serverId}, sucess: function(data){ console.log('success: ' + data); } }); //var _ref; // return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0; }); // aqui voy a ver que parametros voy a mandar para guardar ....... this.on("sending", function(file, xhr, formData) { formData.append('donde_viene',donde_viene); formData.append('donde_viene_tipo', donde_viene_tipo); formData.append('archivos_plantilla', archivos_plantilla); }); }, esizeThumbnail :false // Tells Dropzone whether it should resize the image first }); /* var mockFile = { name: "2024-05-04_1189518379_68669.pdf", size: 3000, token_creado: 22222222, id_creado: 444444444, serverId: 3333333 }; myDropzone.options.addedfile.call(myDropzone, mockFile); myDropzone.options.thumbnail.call(myDropzone, mockFile,"{{{$DIRECCION_WEB}}}/media/empresa/35/2024//05/2024-05-04_1807290138_EPU850L-p.png"); $(do_form_id).append(""); */ } sio.elimnar_imagen_ya_guardada=function(do1,do2,do3) { Swal.fire({ title: "Estas segur@?", text: "Queres Eliminar el registro:"+do3, icon: "warning", showCancelButton: true, confirmButtonColor: "#3085d6", cancelButtonColor: "#d33", cancelButtonText: "No", confirmButtonText: "Si" }).then((result) => { if (result.isConfirmed) { const obj = JSON.parse(sio.ajax.reload3('https://servicioportuario.com/herramientas/eliminar_archivo_registrado/'+do1+'/'+do2)); if(obj.error_id==1 || obj.error_id==2) { Swal.fire({ icon: "error", title: "Error", text: obj.error_descripcion }); // obj.error_descripcion } else { Swal.fire({ icon: "success", closeClick: false, allowOutsideClick: false, title: "Muy bien.", text: obj.bien_descripcion }).then(function(e) { $(".archivo_creado_dropzone_"+do1).remove(); // location.href ="https://servicioportuario.com"; //return false; }) // obj.bien_descripcion } } }); }