155 lines
No EOL
3.2 KiB
JavaScript
155 lines
No EOL
3.2 KiB
JavaScript
$("#formCatalogo").EnableValidationToolTip();
|
|
var DataCatalogo;
|
|
var id_column = 0;
|
|
var Item = {};
|
|
|
|
|
|
//#region READY
|
|
|
|
jQuery(document).ready(function () {
|
|
|
|
GetControlsSettings("Cathay_TiemposEjecucionNotificacionesCompletionTime", "Cathay_TiemposEjecucionNotificacionesCompletionTime", "formCatalogo");
|
|
|
|
|
|
|
|
obtenerItems();
|
|
|
|
$('#btnLimpiar').click(function () {
|
|
limpiar();
|
|
});
|
|
|
|
$('#btnGuardar').click(function () {
|
|
ActualizarItem();
|
|
});
|
|
|
|
|
|
});
|
|
|
|
//#endregion
|
|
|
|
this.obtenerItems = function () {
|
|
|
|
try {
|
|
var uri = 'api/TiemposEjecucionNotificacionesCompletionTimeAPI/ObtenerItems/';
|
|
|
|
$.getJSON(server + uri).done(function (data) {
|
|
|
|
|
|
var TableItems = $('#TableItems').DataTable();
|
|
|
|
$.each(data, function (key, item) {
|
|
|
|
|
|
var option = $("#ucItemsCatalogo").html();
|
|
|
|
option = replaceAll("[$CodItem]", item.IdTiempo, option);
|
|
|
|
TableItems.row.add([ item.IdTiempo, item.Descripcion,item.Dias, option]).draw();
|
|
|
|
});
|
|
|
|
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|
|
|
toastr.error("Ha ocurrido un error inesperado. Vuela a intentarlo mas tarde");
|
|
|
|
console.log("Request Failed: " + textStatus + ', ' + error);
|
|
|
|
}).then(function (value) {
|
|
|
|
ENDREQUEST();
|
|
});
|
|
|
|
|
|
} catch (e) {
|
|
toastr.error("Ha ocurrido un error inesperado al obtener datos. Contacte al Administrador del Sistema." + "<br>" + e.message)
|
|
}
|
|
|
|
}
|
|
|
|
this.EditarItem = function (id) {
|
|
|
|
TableItems = $('#TableItems').DataTable();
|
|
limpiar();
|
|
var indexes = getRowIndex(TableItems, id_column, id);
|
|
|
|
if (indexes != null) {
|
|
|
|
$('#hiddenId').val(id)
|
|
$('#txtTiempoDias').val(TableItems.cell(indexes, 2).data());
|
|
|
|
$("#formCatalogo").validateElement("#txtTiempoDias");
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
this.ActualizarItem = function () {
|
|
|
|
if (!$("#formCatalogo").valid()) {
|
|
toastr.warning("Ingresar todos los campos que son requeridos.");
|
|
return false;
|
|
}
|
|
|
|
if (!confirm("Se guardarán los cambios.\n ¿Desea continuar?"))
|
|
{ return; }
|
|
|
|
TableItems = $('#TableItems').DataTable();
|
|
|
|
|
|
|
|
Item = {
|
|
IdTiempo: $('#hiddenId').val(),
|
|
Dias: $('#txtTiempoDias').val(),
|
|
UsuarioModificado: $("#hiddenUserID").val()
|
|
|
|
}
|
|
|
|
var uri = 'api/TiemposEjecucionNotificacionesCompletionTimeAPI/ModificarItem/';
|
|
var DTO = JSON.stringify(Item);
|
|
|
|
$.ajax({
|
|
type: 'POST',
|
|
url: server + uri,
|
|
cache: false,
|
|
data: DTO,
|
|
contentType: 'application/json; charset=utf-8',
|
|
dataType: 'json',
|
|
success: function (data) {
|
|
|
|
|
|
|
|
if (data == "EXITOSO") {
|
|
toastr.info('Información guardada con exito', 'Completado');
|
|
limpiar();
|
|
TableItems.clear().draw();
|
|
obtenerItems();
|
|
|
|
}
|
|
else {
|
|
toastr.error("Ha ocurrido un error.");
|
|
}
|
|
|
|
}
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|
|
|
toastr.error("Ha ocurrido un error inesperado. Vuela a intentarlo.");
|
|
|
|
}).then(function (value) {
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
this.limpiar = function () {
|
|
|
|
|
|
|
|
$('#txtTiempoDias').val('');
|
|
$("#formCatalogo").validateElement("#txtTiempoDias");
|
|
|
|
} |