180 lines
5.5 KiB
JavaScript
180 lines
5.5 KiB
JavaScript
$("#formIncluirClienteSAP").EnableValidationToolTip();
|
|
var IdSolicitud = $("#hidden_co_solicitud").val();
|
|
var model = {};
|
|
|
|
|
|
jQuery(document).ready(function () {
|
|
if ($("#hiddenTaskStatus").val() == 3)
|
|
GetControlsSettings("Cathay_IncluirClienteSAPReadOnly", "Cathay_FrmIncluirClienteSAP", "formIncluirClienteSAP", true);
|
|
else
|
|
GetControlsSettings("Cathay_IncluirClienteSAP", "Cathay_FrmIncluirClienteSAP", "formIncluirClienteSAP", true);
|
|
|
|
|
|
});
|
|
|
|
this.getDataModel = function () {
|
|
|
|
$('#btnCompletarTarea').unbind('click');
|
|
$('#btnCompletarTarea').click(function () {
|
|
GuardarSolicitud();
|
|
});
|
|
|
|
|
|
|
|
$('#btnBuscarClienteSAP').click(function () {
|
|
|
|
if ($("#formIncluirClienteSAP").valid()) {
|
|
|
|
ResultadoComparativoBPMySAP(false);
|
|
}
|
|
else {
|
|
toastr.warning("Ingresar todos los campos que son requeridos.");
|
|
}
|
|
});
|
|
|
|
$("#btnCompletarTarea").disable();
|
|
|
|
ObtenerSolicitud();
|
|
|
|
|
|
}
|
|
|
|
this.ResultadoComparativoBPMySAP = function (END) {
|
|
|
|
|
|
var uri = "api/IncluirClienteSapAPI/ConsultarDatosCaratula/"
|
|
var Item = {
|
|
NumeroSolicitud: IdSolicitud,
|
|
NumeroCliente: $("#txtCodigoBP").val(),
|
|
Identificacion: null,
|
|
NumeroLinea: null,
|
|
TipoConsulta: 0
|
|
};
|
|
|
|
var DTO = JSON.stringify(Item);
|
|
|
|
|
|
$.ajax({
|
|
type: 'POST',
|
|
url: server + uri,
|
|
cache: false,
|
|
data: DTO,
|
|
contentType: 'application/json; charset=utf-8',
|
|
dataType: 'json',
|
|
async: END == true ? false : END,
|
|
success: function (data) {
|
|
if (data != null) {
|
|
|
|
$("#btnCompletarTarea").enable();
|
|
|
|
$.each(data.ValoresComparativos, function (id, item) {
|
|
item.Iguales = item.Iguales == true ? "Correcto" : "Incorrecto"
|
|
});
|
|
|
|
|
|
$("#GvComparativoBPMySAP").Grid("RenderGrid", data.ValoresComparativos, null);
|
|
}
|
|
}
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|
if (typeof AjaxFailEvent !== 'undefined' && $.isFunction(AjaxFailEvent) && !AjaxFailEvent(jqxhr, textStatus, error))
|
|
return;
|
|
toastr.error("Ha ocurrido un error inesperado.");
|
|
|
|
ENDREQUEST();
|
|
}).then(function (value) {
|
|
|
|
ENDREQUEST();
|
|
});
|
|
}
|
|
|
|
this.ObtenerSolicitud = function () {
|
|
try {
|
|
|
|
if (IdSolicitud != "0") {
|
|
|
|
var uri = "api/IncluirClienteSapAPI/ObtenerSolicitud?IdSolicitud=" + IdSolicitud
|
|
$.ajax({
|
|
type: 'GET',
|
|
url: server + uri,
|
|
cache: false,
|
|
contentType: 'application/json; charset=utf-8',
|
|
dataType: 'json',
|
|
async: true,
|
|
success: function (data) {
|
|
|
|
if (data == null || data.length == 0)
|
|
return;
|
|
|
|
model = data;
|
|
if (model.CaratulaCredito.IdEstadoCaratula == 6) {
|
|
$("#divEnviarEpower").attr("style", "display:block;");
|
|
$("#btnsEnviarEpower").ButtonSwitch('set', model.GuardarEpower == null ? 1 : (model.GuardarEpower == true ? 0 : 1));
|
|
|
|
|
|
}
|
|
|
|
$.each(model.Solicitante, function (id, item) {
|
|
if (item.Cliente.CodigoBP != null && item.Cliente.CodigoBP != "") {
|
|
$("#txtCodigoBP").val(item.Cliente.CodigoBP)
|
|
$("#txtCodigoBP").disable();
|
|
$("#formIncluirClienteSAP").validateElement("#txtCodigoBP");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|
if (typeof AjaxFailEvent !== 'undefined' && $.isFunction(AjaxFailEvent) && !AjaxFailEvent(jqxhr, textStatus, error))
|
|
return;
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error);
|
|
HabilitarMenu();
|
|
ENDREQUEST();
|
|
|
|
}).then(function (value) {
|
|
if ($("#txtCodigoBP").val() != "")
|
|
ResultadoComparativoBPMySAP(true);
|
|
else
|
|
ENDREQUEST();
|
|
|
|
});
|
|
}
|
|
|
|
}
|
|
catch (e) {
|
|
toastr.error("Ha ocurrido un error inesperado al intentar cargar la información en el formulario. Por favor contacte al Administrador del Sistema");
|
|
}
|
|
|
|
};
|
|
|
|
this.GuardarSolicitud = function () {
|
|
var uri = "api/IncluirClienteSapAPI/GuardarSolicitud/"
|
|
|
|
model.GuardarEpower = $("#btnsEnviarEpower").val() == "0" ? true : (IsNullOrEmpty($("#btnsEnviarEpower").val()) ? null : false);
|
|
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 != null && data.CodigoRespuesta == "EXITOSO") {
|
|
EnviarIncidente(false, true);
|
|
} else {
|
|
toastr.error("Ha ocurrido un error inesperado. Vuela 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.");
|
|
|
|
ENDREQUEST();
|
|
}).then(function (value) {
|
|
ENDREQUEST();
|
|
});
|
|
}
|
|
|