1 | /** |
---|
2 | * Funcion para refrescar el captcha |
---|
3 | * @param element Recibe el parametro |
---|
4 | */ |
---|
5 | |
---|
6 | function refresh_captcha(element) { |
---|
7 | $form = $(element).parents('form'); |
---|
8 | var url = location.protocol + "//" + window.location.hostname + ":" + location.port + "/captcha/refresh/"; |
---|
9 | |
---|
10 | $.getJSON(url, {}, function(json) { |
---|
11 | $form.find('input[name="captcha_0"]').val(json.key); |
---|
12 | $form.find('img.captcha').attr('src', json.image_url); |
---|
13 | }); |
---|
14 | |
---|
15 | return false; |
---|
16 | } |
---|
17 | |
---|
18 | /** |
---|
19 | * Función para obtener los usuarios de un evento |
---|
20 | */ |
---|
21 | function get_event_user() { |
---|
22 | var modal = false; |
---|
23 | var pasaporte = $('#id_pasaporte').val(); |
---|
24 | if (pasaporte!='') { |
---|
25 | var routes = $(location).attr('pathname').split('/'); |
---|
26 | var pk = routes[routes.length-1]; |
---|
27 | var url = URL_USUARIO_EVENTO+pk+"/"+pasaporte; |
---|
28 | $.getJSON(url, function(data){ |
---|
29 | if (Object.keys(data).length > 0) { |
---|
30 | construir_datos(data.datos); |
---|
31 | } |
---|
32 | else{ |
---|
33 | simple_modal('Lo sentimos, no esta registrado para firmar'); |
---|
34 | } |
---|
35 | }).fail(function(jqxhr, textStatus, error) { |
---|
36 | simple_modal('Petición fállida' + textStatus + ", " + error); |
---|
37 | }) |
---|
38 | } |
---|
39 | else{ |
---|
40 | simple_modal('Debe ingresar un pasaporte'); |
---|
41 | } |
---|
42 | } |
---|
43 | |
---|
44 | /** |
---|
45 | * Función para crear un modal sencillo |
---|
46 | */ |
---|
47 | function simple_modal(mensaje) { |
---|
48 | MaterialDialog.alert( |
---|
49 | mensaje, |
---|
50 | { |
---|
51 | title:'Alerta', |
---|
52 | buttons:{ |
---|
53 | close:{ |
---|
54 | text:'cerrar', |
---|
55 | className:'red', |
---|
56 | } |
---|
57 | } |
---|
58 | } |
---|
59 | ); |
---|
60 | } |
---|
61 | |
---|
62 | /** |
---|
63 | * Función para construir la data del participante |
---|
64 | * @param data Recibe los datos para crear la lista |
---|
65 | */ |
---|
66 | function construir_datos(data) { |
---|
67 | $('#datos_paricipante').html(''); |
---|
68 | html = '<ul class="collection">' |
---|
69 | html += '<li class="collection-item"><b>Nombre: </b>'+data.nombres+'</li>'; |
---|
70 | html += '<li class="collection-item"><b>Apellido: </b>'+data.apellidos+'</li>'; |
---|
71 | html += '<li class="collection-item"><b>Pasaporte: </b>'+data.pasaporte+'</li>'; |
---|
72 | html += '<li class="collection-item"><b>Correo: </b>'+data.correo+'</li>'; |
---|
73 | html += '</ul>'; |
---|
74 | $('#datos_paricipante').html(html); |
---|
75 | } |
---|