Changeset 452668a in firmaeventos for static/js/funciones.js
- Timestamp:
- Nov 27, 2017, 10:46:54 AM (6 years ago)
- Branches:
- master
- Children:
- 163d273
- Parents:
- 2b66ea3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
static/js/funciones.js
r3ae7c21 r452668a 80 80 } 81 81 else{ 82 html += '<a type="button" id="firmar" class="btn waves-effect blue darken-1" onclick=" ObtenerCertificadoFirmanteMultiples(\''+data.documento+'\')">';82 html += '<a type="button" id="firmar" class="btn waves-effect blue darken-1" onclick="comprobarFirma(\''+data.documento+'\')">'; 83 83 html += '<i class="material-icons left">mode_edit</i> Firmar</a>'; 84 84 } … … 87 87 88 88 /** 89 * Función para comprobar firma 90 * @param fileId Recibe el id del documento 91 */ 92 function comprobarFirma(fileId){ 93 var routes = $(location).attr('pathname').split('/'); 94 var pk = routes[routes.length-1]; 95 $.ajax({ 96 type: 'GET', 97 async: false, 98 url:URL_COMPROBAR_FIRMA+pk, 99 success: function(datos){ 100 if (datos.validate==true) { 101 simple_modal(datos.mensaje); 102 } 103 else{ 104 $.ajax({ 105 type: 'POST', 106 async: false, 107 url:URL_COMPROBAR_FIRMA+pk, 108 success: function(datos){ 109 if (datos.validate==true) { 110 ObtenerCertificadoFirmanteMultiples(fileId,pk); 111 } 112 else{ 113 simple_modal("Ocurrió un error al actualizar los datos"); 114 } 115 }, 116 error: function(jqXHR, textStatus, errorThrown){ 117 console.log('error: ' + textStatus); 118 } 119 }); 120 } 121 }, 122 error: function(jqXHR, textStatus, errorThrown){ 123 console.log('error: ' + textStatus); 124 } 125 }); 126 } 127 128 /** 89 129 * Función para obtener el certificado del participante 90 130 * @param fileId Recibe el id del documento 91 */ 92 function ObtenerCertificadoFirmanteMultiples(fileId){ 131 * @param pk Recibe el id del evento 132 */ 133 function ObtenerCertificadoFirmanteMultiples(fileId,pk){ 93 134 var xPos = yPos= signaturePage = ""; 94 135 var lastSignature = false; 95 var routes = $(location).attr('pathname').split('/');96 var pk = routes[routes.length-1];97 136 98 137 $.ajax({ … … 125 164 126 165 // ahora llamar al ajax de obtener la resena del pdf 127 ObtenerHashPDFServerMultiples(parameters, cert );166 ObtenerHashPDFServerMultiples(parameters, cert, pk); 128 167 129 168 }, … … 139 178 error = "No hay soporte para el manejo del certificado"; 140 179 } 180 $.ajax({ 181 type: 'POST', 182 async: false, 183 url:URL_COMPROBAR_FIRMA+pk, 184 success: function(datos){ 185 console.log(datos); 186 }, 187 error: function(jqXHR, textStatus, errorThrown){ 188 console.log('error: ' + textStatus); 189 } 190 }); 141 191 simple_modal(error); 142 192 } … … 155 205 * @param parameters Recibe los parametros 156 206 * @param cert Recibe los certificados 157 */ 158 function ObtenerHashPDFServerMultiples(parameters,cert){ 207 * @param pk Recibe el id del evento 208 */ 209 function ObtenerHashPDFServerMultiples(parameters,cert,pk){ 159 210 160 211 $.ajax({ … … 175 226 window.hwcrypto.sign(cert, {type: hashtype, hex: hash}, {lang: lang}).then( 176 227 function(signature) { 177 FinalizarFirmaMultiples(signature.hex );228 FinalizarFirmaMultiples(signature.hex, pk); 178 229 }, 179 230 function(err) { … … 188 239 error = "No hay soporte para el manejo del certificado"; 189 240 } 241 $.ajax({ 242 type: 'POST', 243 async: false, 244 url:URL_COMPROBAR_FIRMA+pk, 245 success: function(datos){ 246 console.log(datos); 247 }, 248 error: function(jqXHR, textStatus, errorThrown){ 249 console.log('error: ' + textStatus); 250 } 251 }); 190 252 simple_modal(error); 191 253 }); … … 202 264 * Función para enviar la firma al servidor 203 265 * @param signature Recibe la firma 204 */ 205 function FinalizarFirmaMultiples(signature){ 266 * @param pk Recibe el id del evento 267 */ 268 function FinalizarFirmaMultiples(signature, pk){ 206 269 207 270 $.ajax({ … … 215 278 success: function(data, textStatus, jqXHR){ 216 279 actualizar_participante(data['signedFileId']); 280 $.ajax({ 281 type: 'POST', 282 async: false, 283 url:URL_COMPROBAR_FIRMA+pk, 284 success: function(datos){ 285 console.log(datos); 286 }, 287 error: function(jqXHR, textStatus, errorThrown){ 288 console.log('error: ' + textStatus); 289 } 290 }); 217 291 }, 218 292 error: function(jqXHR, textStatus, errorThrown){ 219 293 console.log('error en pdfs/resenas: ' + textStatus); 294 $.ajax({ 295 type: 'POST', 296 async: false, 297 url:URL_COMPROBAR_FIRMA+pk, 298 success: function(datos){ 299 console.log(datos); 300 }, 301 error: function(jqXHR, textStatus, errorThrown){ 302 console.log('error: ' + textStatus); 303 } 304 }); 220 305 } 221 306 });
Note: See TracChangeset
for help on using the changeset viewer.