jQuery(document).ready(function () { try { $('#btnGenDocCaratulaCredito').click(function () { GenerarDocumento("CaratulaCredito"); }); $('#btnGenDocCartaAprobacion').click(function () { GenerarDocumento("CartaAprobacion"); }); $('#btnGenDocSolicitudSeguroINS').click(function () { GenerarDocumento("SolicitudIns"); }); $('#btnGenDocCartaExclusionFlotilla').click(function () { GenerarDocumento("AutorizacionExclusionFlotilla"); }); $('#btnGenDocComprobanteEntregaDocumentos').click(function () { GenerarDocumento("ComprobanteEntregaDocumentos"); }); $('#btnGenDocDeberInformacion').click(function () { GenerarDocumento("DeberInformacion"); }); $('#btnGenDocPrenda').click(function () { GenerarDocumento("Prenda"); }); } catch (e) { toastr.error("Ha ocurrido un error inesperado al inicializar el formulario de informa. Vuelva a intentarlo mas tarde", Message_Error); } }); this.GenerarDocumento = function (tipoDocumento) { var uri = "api/DocumentosAPI/Adjuntar" + tipoDocumento + "?IdSolicitud=" + $('#hiddensol_co_solicitud').val() + "&IdCotizacion=" + $('#hiddensol_co_cotizacion').val() + "&process=" + $('#hiddenProcess').val(); $.getJSON(server + uri).done(function (data) { if (data != null) { if (data.CodigoRespuesta == "EXITOSO") { window.open(data.url); } else if (data.CodigoRespuesta == "ADVERTENCIA") { toastr.warning(data.DescripcionRespuesta, Message_Warning); } else { toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error); } } }).fail(function (jqxhr, textStatus, error) { if (typeof AjaxFailEvent !== 'undefined' && $.isFunction(AjaxFailEvent) && !AjaxFailEvent(jqxhr, textStatus, error)) return; toastr.error("Ha ocurrido un error inesperado. Vuela a intentarlo mas tarde"); ENDREQUEST(); }).then(function (value) { ENDREQUEST(); }); };