diff --git a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/EmisorPN.js b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/EmisorPN.js index 25f952f0d..b61933f8f 100644 --- a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/EmisorPN.js +++ b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/EmisorPN.js @@ -1,7 +1,7 @@ //$("#formCatalogo").EnableValidationToolTip(); var DataCatalogo; var id_column = 1; -var Item = {}; +var model = {}; //#region READY @@ -47,74 +47,8 @@ this.getDataModel = function () { this.obtenerItems = function () { - var uri = CatalogosWCF + '/api/ObtenerEmisoresPN'; - - var DTO = JSON.stringify(Item); - STARTREQUEST(); - //$.getJSON(uri).done(function (data) { - - $.ajax({ - type: 'POST', - url: uri, - cache: false, - data: DTO, - contentType: 'application/json; charset=utf-8', - dataType: 'json', - success: function (data) { - - $('#TableItems').TableInit(0, false, true, true, false, null, null); - - var TableItems = $('#TableItems').DataTable(); - var lista = data.d.ListaEmisores; - - $.each(lista, function (key, item) { - - - var option = $("#ucItemsCatalogo").html(); - - option = replaceAll("[$CodItem]", item.id_emisor, option); - - var stateIcon = $("#ucItemsIcon").html(); - - if (item.Estado == false) { - stateIcon = replaceAll("[$icon]", "fa-check-circle", stateIcon); - stateIcon = replaceAll("[$state_color]", "muted", stateIcon); - - option = replaceAll("[$opcion]", "Habilitar", option); - option = replaceAll("[$icon]", "fa-check", option); - option = replaceAll("[$value]", "1", option); - } - else { - stateIcon = replaceAll("[$icon]", "fa-check-circle", stateIcon); - stateIcon = replaceAll("[$state_color]", "success", stateIcon); - - option = replaceAll("[$opcion]", "Deshabilitar", option); - option = replaceAll("[$icon]", "fa-times", option); - option = replaceAll("[$value]", "0", option); - } - - TableItems.row.add([stateIcon, - item.id_emisor, - item.titulo, - option]).draw(); - - }); - - ENDREQUEST(); - } - }).fail(function (jqxhr, textStatus, error) { - - toastr.error("Ha ocurrido un error inesperado. Vuela a intentarlo mas tarde"); - - console.log("Request Failed: " + textStatus + ', ' + error); - - ENDREQUEST(); - - }).then(function (value) { - - ENDREQUEST(); - }); + AjaxPostData(uri, model, true, true, CargarEmisores, null, null); } @@ -163,14 +97,14 @@ this.toggleEnabledItem = function (id, value) { TableItems = $('#TableItems').DataTable(); - Item = { + model = { IdEmisor: id, Estado: value, } var uri = CatalogosWCF + '/api/ModificarEstadoEmisorPN'; - var DTO = JSON.stringify(Item); + var DTO = JSON.stringify(model); $.ajax({ type: 'POST', @@ -223,13 +157,13 @@ this.ActualizarItem = function () { TableItems = $('#TableItems').DataTable(); - Item = { - IdTipoEmisor: $('#hiddenId').val(), - Descripcion: $('#txtDescripcion').val(), + model = { + id_emisor: $('#hiddenId').val(), + titulo: $('#txtDescripcion').val(), } var uri = CatalogosWCF + '/api/ModificarEmisoresPN'; - var DTO = JSON.stringify(Item); + var DTO = JSON.stringify(model); $.ajax({ type: 'POST', @@ -337,4 +271,44 @@ this.limpiar = function () { $('#lbTituloAccion').append('Ingresar Nuevo Emisor PN'); } +this.CargarEmisores = function(data){ + $('#TableItems').TableInit(0, false, true, true, false, null, null); + + var TableItems = $('#TableItems').DataTable(); + var lista = data.d.ListaEmisores; + + $.each(lista, function (key, item) { + + + var option = $("#ucItemsCatalogo").html(); + + option = replaceAll("[$CodItem]", item.id_emisor, option); + + var stateIcon = $("#ucItemsIcon").html(); + + if (item.Estado == false) { + stateIcon = replaceAll("[$icon]", "fa-check-circle", stateIcon); + stateIcon = replaceAll("[$state_color]", "muted", stateIcon); + + option = replaceAll("[$opcion]", "Habilitar", option); + option = replaceAll("[$icon]", "fa-check", option); + option = replaceAll("[$value]", "1", option); + } + else { + stateIcon = replaceAll("[$icon]", "fa-check-circle", stateIcon); + stateIcon = replaceAll("[$state_color]", "success", stateIcon); + + option = replaceAll("[$opcion]", "Deshabilitar", option); + option = replaceAll("[$icon]", "fa-times", option); + option = replaceAll("[$value]", "0", option); + } + + TableItems.row.add([stateIcon, + item.id_emisor, + item.titulo, + option]).draw(); + + }); + +} diff --git a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Global.js b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Global.js index c9fad9c99..21bf983f5 100644 --- a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Global.js +++ b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Global.js @@ -1,74 +1,8 @@ var CatalogosWCF = $("#hiddenSinortCatalogosWCF").val(); var SinortWCF = $("#hiddenSinortWCF").val(); -var server = "http://" + location.host + "/AYA.SlnSynor.WCF/"; var TipoRespuesta = { EXITOSO: "1", FALLIDO: "0" }; var LoadMessageThreadCounter = 0; -function Mensajes(mensaje) { - if (mensaje.CodigoRespuesta === "1") { - toastr.options = { - "closeButton": true, - "debug": false, - "newestOnTop": false, - "progressBar": false, - "positionClass": "toast-bottom-full-width", - "preventDuplicates": true, - "onclick": null, - "showDuration": "300", - "hideDuration": "1000", - "timeOut": "5000", - "extendedTimeOut": "1000", - "showEasing": "swing", - "hideEasing": "linear", - "showMethod": "fadeIn", - "hideMethod": "fadeOut" - }; - - toastr["success"]("Operación procesada exitosamente", "SINORT"); - } - - if (mensaje.CodigoRespuesta === "0") { - toastr.options = { - "closeButton": true, - "debug": false, - "newestOnTop": false, - "progressBar": false, - "positionClass": "toast-bottom-full-width", - "preventDuplicates": true, - "onclick": null, - "showDuration": "300", - "hideDuration": "1000", - "timeOut": "5000", - "extendedTimeOut": "1000", - "showEasing": "swing", - "hideEasing": "linear", - "showMethod": "fadeIn", - "hideMethod": "fadeOut" - }; - - toastr["warning"]("Error al procesar la operación", "SINORT"); - } - toastr.options = { - "closeButton": true, - "debug": false, - "newestOnTop": false, - "progressBar": false, - "positionClass": "toast-bottom-full-width", - "preventDuplicates": true, - "onclick": null, - "showDuration": "300", - "hideDuration": "1000", - "timeOut": "5000", - "extendedTimeOut": "1000", - "showEasing": "swing", - "hideEasing": "linear", - "showMethod": "fadeIn", - "hideMethod": "fadeOut" - }; - - toastr["error"](mensaje.DescripcionRespuesta, "SINORT"); -} - function STARTREQUEST(Message) { if (IsNullOrEmpty(Message)) { @@ -252,13 +186,124 @@ $.fn.EnableValidationToolTip = function () { }; -IsNullOrEmpty = function (value) { + +//FRAMEWORK + +this.LoadToastContainer = function () { + if ($('#toast-container').length > 0) { + var n = $('
').appendTo('body'); + n.attr('id', 'toast-container'); + n.attr('class', 'toast-top-right') + } +}; +this.LoadMessage = function (n) { + var r, + t, + i; + n == null && (n = 'Cargando Datos, Espere por favor!'); + $('#toast-container').length > 0 && (r = $('').appendTo('body'), r.attr('id', 'toast-container'), r.attr('class', 'toast-top-right')); + $('#toast-container').empty(); + t = ''; + t += '![]() | ";
+ t += ''; + t += ' | ';
+ t += ' ' + n + ' ';
+ t += ' | ';
+ t += '