1 /************************************************************ 2 ** este archivo contiene funciones de validacion de datos, 3 ** cedulas, ruc, nombres 4 ************************************************************/ 5 6 // use identification card as password // validate number identification 7 8 fun_identification_pass = function (pass, identification, typeidentification) { 9 let a = $("#" + identification).val(); 10 11 if ($("#" + identification).val() != '') { 12 let ad_identification = $("#" + identification).val(); 13 14 ad_identification = ad_identification.toString(); 15 if (ad_identification.length == 10) { 16 if (validate_identification(ad_identification) == true) { 17 // console.log(typeidentification); 18 $("#" + typeidentification).val('05'); 19 } 20 } else if (ad_identification.length == 13 && ad_identification.substring(10, 13) == '001') { 21 let ad_identification_new = ad_identification.substring(0, 10) 22 if (validate_identification(ad_identification_new) == true) { 23 $("#" + typeidentification).val('04'); 24 } 25 } else { 26 $("#" + typeidentification).val(""); 27 }; 28 }; 29 }; 30 fun_data_config = function (number) { 31 fecha = new Date(); 32 fecha.setTime(number); 33 let year = fecha.getFullYear(); 34 let month = fecha.getMonth(); 35 let day = fecha.getDay(); 36 if (month < 10) { 37 month = '0' + month.toString(); 38 } 39 if (day < 10) { 40 day = '0' + day.toString(); 41 } 42 let data = year.toString() + "-" + month.toString() + "" + day.toString(); 43 return data; 44 } 45 // convert string to uppercase 46 function fun_toUpperCase(e) { 47 e.value = e.value.toUpperCase(); 48 } 49 50 // convert string to lowercase 51 function fun_toLowerCase(e) { 52 e.value = e.value.toLowerCase(); 53 } 54 55 // validate identification number 56 function validate_identification(cad) { 57 // console.log(cad); 58 let total = 0; 59 let longitud = cad.length; 60 let longcheck = longitud - 1; 61 62 if (cad !== "" && longitud === 10) { 63 for (i = 0; i < longcheck; i++) { 64 if (i % 2 === 0) { 65 let aux = cad.charAt(i) * 2; 66 if (aux > 9) aux -= 9; 67 total += aux; 68 } else { 69 total += parseInt(cad.charAt(i)); // parseInt o concatenará en lugar de sumar 70 } 71 } 72 73 total = total % 10 ? 10 - total % 10 : 0; 74 75 if (cad.charAt(longitud - 1) == total) { 76 return true; 77 } else { 78 return false; 79 } 80 } 81 } 82 83 84 function isValidDate(day, month, year) { 85 var dteDate; 86 month = month - 1; 87 // Establecemos un objeto Data con los valore recibidos 88 // Los parametros son: año, mes, dia, hora, minuto y segundos 89 // getDate(); devuelve el dia como un entero entre 1 y 31 90 // getDay(); devuelve un num del 0 al 6 indicando siel dia es lunes, 91 // martes, miercoles ... 92 // getHours(); Devuelve la hora 93 // getMinutes(); Devuelve los minutos 94 // getMonth(); devuelve el mes como un numero de 0 a 11 95 // getTime(); Devuelve el tiempo transcurrido en milisegundos desde el 1 96 // de enero de 1970 hasta el momento definido en el objeto date 97 // setTime(); Establece una fecha pasandole en milisegundos el valor de esta. 98 // getYear(); devuelve el año 99 // getFullYear(); devuelve el año 100 dteDate = new Date(year, month, day); 101 102 //Devuelva true o false... 103 return ((day == dteDate.getDate()) && (month == dteDate.getMonth()) && (year == dteDate.getFullYear())); 104 } 105 106 /** 107 * Funcion para validar una fecha 108 * Tiene que recibir: 109 * La fecha en formato ingles yyyy-mm-dd 110 * Devuelve: 111 * true-Fecha correcta 112 * false-Fecha Incorrecta 113 */ 114 function validate_fecha(fecha) { 115 var patron = new RegExp("^(19|20)+([0-9]{2})([-])([0-9]{1,2})([-])([0-9]{1,2})$"); 116 117 if (fecha.search(patron) == 0) { 118 var values = fecha.split("-"); 119 if (isValidDate(values[2], values[1], values[0])) { 120 return true; 121 } 122 } 123 return false; 124 } 125 126 function calculate_age(fecha, param) { 127 // var fecha = document.getElementById("ad_birthdate").value; 128 if (validate_fecha(fecha) == true) { 129 // Si la fecha es correcta, calculamos la edad 130 var values = fecha.split("-"); 131 var dia = values[2]; 132 var mes = values[1]; 133 var ano = values[0]; 134 135 // valores actuales 136 var fecha_hoy = new Date(); 137 var ahora_ano = fecha_hoy.getYear(); 138 var ahora_mes = fecha_hoy.getMonth(); 139 var ahora_dia = fecha_hoy.getDate(); 140 141 // realizamos el calculo 142 var edad = (ahora_ano + 1900) - ano; 143 if (ahora_mes < (mes - 1)) { 144 edad--; 145 } 146 if (((mes - 1) == ahora_mes) && (ahora_dia < dia)) { 147 edad--; 148 } 149 if (edad > 1900) { 150 edad -= 1900; 151 } 152 153 if (edad == 0) { 154 $("#" + param).val(edad); 155 } else if (edad < 0) { 156 swal('Fecha de nacimiento inválida', 'La fecha de nacimiento no puede ser mayor que la fecha actual', 'info') 157 $("#" + param).val(''); 158 $("#ad_birthdate").val(''); 159 } else { 160 $("#" + param).val(edad); 161 } 162 } else { 163 $("#ad_age").val(edad); 164 } 165 } 166 167 168 function validarSiNumero(numero) { 169 if (!/^([0-9])*$/.test(numero)) 170 alert("El valor " + numero + " no es un número"); 171 } 172 173 174 // funcion para permitir el ingreso solo de letras en un input 175 // function to allow the entry of only letters in an input 176 fun_only_letters = function (e) { 177 let key = e.keyCode || e.which; 178 let tecla = String.fromCharCode(key).toLowerCase(); 179 let letras = " áéÃóúabcdefghijklmnñopqrstuvwxyz"; 180 let especiales = ""; 181 182 let tecla_especial = false 183 for (var i in especiales) { 184 if (key == especiales[i]) { 185 tecla_especial = true; 186 break; 187 } 188 } 189 190 if (letras.indexOf(tecla) == -1 && !tecla_especial) { 191 return false; 192 } 193 } 194 195 fun_activar_modal_entry = function (event) { 196 if (event.keyCode == 13 || event.keyCode == 9) { 197 setTimeout(() => { 198 $("#modalDriversEntry").modal(); 199 }); 200 } 201} 202 203fun_activar_modal_exit = function (event) { 204 if (event.keyCode == 13 || event.keyCode == 9) { 205 setTimeout(() => { 206 $("#modalDriversExit").modal(); 207 }); 208 } 209} 210 211 212 213 214 215 function isValidEmail(mail) { 216 return /^\w+([\.\+\-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(mail); 217 } 218 219 function fun_imprimir_detalle() { 220 var doc = new jsPDF('landscape'); 221 var specialElementHandlers = { 222 '#editor': function (element, renderer) { 223 return true; 224 } 225 }; 226 227 228 229 // $('#cmd').click(function () { 230 doc.fromHTML($('#content').html(), 35, 35, { 231 'width': 800, 232 'elementHandlers': specialElementHandlers 233 }); 234 doc.save('sample-file.pdf'); 235 // }); 236} 237 238function Imprimir_sugerida_entrada() { 239 var pdf = new jsPDF('p', 'pt', 'a4'); 240 source = $('#contentE')[0]; 241 242 specialElementHandlers = { 243 '#bypassme': function (element, renderer) { 244 // true = "handled elsewhere, bypass text extraction" 245 return true 246 } 247 }; 248 margins = { 249 top: 40, 250 bottom: 15, 251 left: 30, 252 width: 600 253 }; 254 pdf.fromHTML( 255 source, // HTML string or DOM elem ref. 256 margins.left, // x coord 257 margins.top, { // y coord 258 'width': margins.width, // max width of content on PDF 259 'elementHandlers': specialElementHandlers 260 }, 261 262 function (dispose) { 263 pdf.save('RutaSugeridaEntrada.pdf'); 264 }, margins); 265} 266 267function Imprimir_sugerida_salida() { 268 var pdf = new jsPDF('p', 'pt', 'a4'); 269 source = $('#contentS')[0]; 270 271 specialElementHandlers = { 272 '#bypassme': function (element, renderer) { 273 // true = "handled elsewhere, bypass text extraction" 274 return true 275 } 276 }; 277 margins = { 278 top: 40, 279 bottom: 15, 280 left: 30, 281 width: 600 282 }; 283 pdf.fromHTML( 284 source, // HTML string or DOM elem ref. 285 margins.left, // x coord 286 margins.top, { // y coord 287 'width': margins.width, // max width of content on PDF 288 'elementHandlers': specialElementHandlers 289 }, 290 291 function (dispose) { 292 pdf.save('RutaSugeridaSalida.pdf'); 293 }, margins); 294} 295 296function startTime() { 297 today = new Date(); 298 299 d = today.getDate(); 300 mo = today.getMonth() + 1; 301 y = today.getFullYear(); 302 303 h = today.getHours(); 304 m = today.getMinutes(); 305 s = today.getSeconds(); 306 307 d = checkTime(d); 308 mo = checkTime(mo); 309 310 m = checkTime(m); 311 s = checkTime(s); 312 313 if (document.getElementById('currentDate')) { 314 $("#currentDate").val(y + "-" + mo + "-" + d); 315 } 316 317 if (document.getElementById('currentTime')) { 318 $("#currentTime").val(h + ":" + m + ":" + s); 319 } 320 321 t = setTimeout('startTime()', 500); 322} 323 324function checkTime(i) { 325 if (i < 10) { 326 i = "0" + i; 327 } 328 return i; 329} 330 331window.onload = function () { 332 startTime(); 333} 334 335 336 337 338 339 340 341
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.