274 lines
8.4 KiB
JavaScript
274 lines
8.4 KiB
JavaScript
|
|
//#region GLOBALES
|
|||
|
|
$("#formMotivos").EnableValidationToolTip();
|
|||
|
|
var IdTipoMotivoModEnCaratula = null;
|
|||
|
|
var tableItemsModificacionEnCaratula = null;
|
|||
|
|
var IdMotivoSolicitudModEnCaratula = 0;
|
|||
|
|
|
|||
|
|
//#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
//#region READY
|
|||
|
|
jQuery(document).ready(function () {
|
|||
|
|
|
|||
|
|
tableItemsModificacionEnCaratula = $('#tableModificacionEnCaratula').DataTable();
|
|||
|
|
});
|
|||
|
|
//#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
$("#btnGuardarModificacionEnCaratula").click(function () {
|
|||
|
|
guardarMotivoModificacionCaratula(1);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
this.initializeFormMotivosModificacionEnCaratula = function (_IdTipoMotivoModEnCaratula, _IsReadOnly) {
|
|||
|
|
|
|||
|
|
try {
|
|||
|
|
|
|||
|
|
IdTipoMotivoModEnCaratula = _IdTipoMotivoModEnCaratula;
|
|||
|
|
|
|||
|
|
//switch (_IsReadOnly) {
|
|||
|
|
// case true:
|
|||
|
|
// $("#divSelectorMotivoAgregar").attr("style", "display:none;");
|
|||
|
|
// break;
|
|||
|
|
// case false:
|
|||
|
|
// $("#divSelectorMotivoAgregar").attr("style", "display:block;");
|
|||
|
|
// break;
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
obtenerMotivoModificacionCaratula(_IdTipoMotivoModEnCaratula);
|
|||
|
|
|
|||
|
|
obtenerMotivoModificacionCaratulaSolicitud();
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
} catch (e) {
|
|||
|
|
IdTipoMotivoModEnCaratula = null;
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
this.guardarMotivoModificacionCaratula = function (_Estado) {
|
|||
|
|
|
|||
|
|
try {
|
|||
|
|
|
|||
|
|
|
|||
|
|
var _model = [{
|
|||
|
|
IdMotivoSolicitud: IdMotivoSolicitudModEnCaratula,
|
|||
|
|
IdMotivoSolicitudSec: null,
|
|||
|
|
IdSolicitud: $("#hiddensol_co_solicitud").val(),
|
|||
|
|
IdMotivo: 0,
|
|||
|
|
Comentario: null,
|
|||
|
|
EtapaOrigen: $("#hiddenStep").val(),
|
|||
|
|
EtapaDestino: null,
|
|||
|
|
UsuarioOrigen: $("#hiddenUserID").val().split('/')[1],
|
|||
|
|
UsuarioDestino: null,
|
|||
|
|
FeRegistro: null,
|
|||
|
|
Estado: _Estado,
|
|||
|
|
}]
|
|||
|
|
|
|||
|
|
|
|||
|
|
$('#tableModificacionEnCaratula tbody tr').each(function ()
|
|||
|
|
{
|
|||
|
|
if ($(this).find("td").eq(2)[0].all.chkSeleccionarEnabled.checked == true) {
|
|||
|
|
_model.push({
|
|||
|
|
IdMotivoSolicitud: IdMotivoSolicitudModEnCaratula,
|
|||
|
|
IdMotivoSolicitudSec: null,
|
|||
|
|
IdSolicitud: $("#hiddensol_co_solicitud").val(),
|
|||
|
|
IdMotivo: $(this).find("td").eq(0).html(),
|
|||
|
|
Comentario: null,
|
|||
|
|
EtapaOrigen: $("#hiddenStep").val(),
|
|||
|
|
EtapaDestino: null,
|
|||
|
|
UsuarioOrigen: $("#hiddenUserID").val().split('/')[1],
|
|||
|
|
UsuarioDestino: null,
|
|||
|
|
FeRegistro: null,
|
|||
|
|
Estado: _Estado,
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
//$.each($('#tableItemsModificacionEnCaratula tbody tr'), function (key, item) {
|
|||
|
|
// var data = $('#tableItemsModificacionEnCaratula').DataTable().row(key).data();
|
|||
|
|
|
|||
|
|
// _model.DetMotivoSolicitud.push({
|
|||
|
|
// IdMotivoSolicitud: IdMotivoSolicitud,
|
|||
|
|
// IdDetMotivoSolicitud: null,
|
|||
|
|
// IdMotivo: data[0],
|
|||
|
|
// IdTipoMotivoModEnCaratula: IdTipoMotivoModEnCaratula
|
|||
|
|
// });
|
|||
|
|
//});
|
|||
|
|
|
|||
|
|
|
|||
|
|
var uri = 'api/MotivosAPI/InsertarMotivoSolicitudLista/';
|
|||
|
|
var DTO = JSON.stringify(_model);
|
|||
|
|
|
|||
|
|
$.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');
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado al guardar el motivo. Vuelva a intentarlo.");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|||
|
|
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo.");
|
|||
|
|
ENDREQUEST();
|
|||
|
|
|
|||
|
|
}).then(function (value) {
|
|||
|
|
ENDREQUEST();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
} catch (e) {
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado al intentar guardar el motivo. Vuelva a intentarlo.");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
this.actualizarMotivoModificacionCaratula = function (_Estado) {
|
|||
|
|
|
|||
|
|
try {
|
|||
|
|
|
|||
|
|
|
|||
|
|
var _model = {
|
|||
|
|
IdMotivoSolicitud: IdMotivoSolicitud,
|
|||
|
|
Comentario: $("#txtComentarioMotivo").val(),
|
|||
|
|
Estado: _Estado
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
var uri = 'api/MotivosAPI/ActualizarMotivoSolicitud/';
|
|||
|
|
var DTO = JSON.stringify(_model);
|
|||
|
|
|
|||
|
|
$.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 actualizada con exito', 'Completado');
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado al actualizar los motivos. Vuelva a intentarlo.");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|||
|
|
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo.");
|
|||
|
|
ENDREQUEST();
|
|||
|
|
|
|||
|
|
}).then(function (value) {
|
|||
|
|
ENDREQUEST();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
} catch (e) {
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado al intentar actualizar los motivos. Vuelva a intentarlo.");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
this.obtenerMotivoModificacionCaratula = function (_IdTipoMotivoModEnCaratula) {
|
|||
|
|
|
|||
|
|
try {
|
|||
|
|
var uri = "api/MotivosAPI/ObtenerMotivo?IdTipoMotivo=" + _IdTipoMotivoModEnCaratula;
|
|||
|
|
|
|||
|
|
$.getJSON(server + uri).done(function (data) {
|
|||
|
|
if (data != null)
|
|||
|
|
{
|
|||
|
|
var _chkSeleccionarEnabled = $("#divSeleccionarEnabled").html();
|
|||
|
|
var columnDefinition = [
|
|||
|
|
{ "data": "codigo" },
|
|||
|
|
{ "data": "descripcion" },
|
|||
|
|
{ "data": null, className: "center", defaultContent: _chkSeleccionarEnabled }
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
$('#tableModificacionEnCaratula').TableInit(0, false, true, true, false, columnDefinition, data);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error);
|
|||
|
|
}
|
|||
|
|
}).fail(function (jqxhr, textStatus, error)
|
|||
|
|
{
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error);
|
|||
|
|
}).then(function (value) {
|
|||
|
|
ENDREQUEST();
|
|||
|
|
});
|
|||
|
|
} catch (e) {
|
|||
|
|
ENDREQUEST();
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
this.obtenerMotivoModificacionCaratulaSolicitud = function ()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
var IdSolicitud = $("#hiddensol_co_solicitud").val();
|
|||
|
|
var EtapaOrigen = $("#hiddenStep").val();
|
|||
|
|
var Estado = $("#hiddenTaskStatus").val();
|
|||
|
|
|
|||
|
|
var uri = 'api/MotivosAPI/ObtenerMotivoSolicitud?IdSolicitud=' + IdSolicitud +
|
|||
|
|
'&EtapaOrigen=' + EtapaOrigen +
|
|||
|
|
'&IdTipoMotivo=' + IdTipoMotivoModEnCaratula +
|
|||
|
|
'&Estado=' + Estado +
|
|||
|
|
'&OrigenOrDestino=SOURCE';
|
|||
|
|
|
|||
|
|
$.getJSON(server + uri).done(function (data)
|
|||
|
|
{
|
|||
|
|
if (data != null)
|
|||
|
|
{
|
|||
|
|
$('#tableModificacionEnCaratula tbody tr').each(function () {
|
|||
|
|
var _IsChecked = false;
|
|||
|
|
var _IdMotivo = $(this).find("td").eq(0).html();
|
|||
|
|
|
|||
|
|
$.each(data, function (key, item) {
|
|||
|
|
|
|||
|
|
if (item.IdMotivo == _IdMotivo) {
|
|||
|
|
_IsChecked = true;
|
|||
|
|
IdMotivoSolicitudModEnCaratula = item.IdMotivoSolicitud;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$(this).find("td").eq(2)[0].all.chkSeleccionarEnabled.checked = _IsChecked;
|
|||
|
|
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error);
|
|||
|
|
}
|
|||
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|||
|
|
ENDREQUEST();
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error);
|
|||
|
|
}).then(function (value) {
|
|||
|
|
ENDREQUEST();
|
|||
|
|
});
|
|||
|
|
}
|