748 lines
26 KiB
JavaScript
748 lines
26 KiB
JavaScript
|
|
var CondicionesFormalizacionSolicitud = {};
|
|||
|
|
var informacion = {};
|
|||
|
|
var IsReadOnlyForm = false;
|
|||
|
|
|
|||
|
|
$("#FormDecisionFirma").EnableValidationToolTip();
|
|||
|
|
|
|||
|
|
jQuery(document).ready(function () {
|
|||
|
|
|
|||
|
|
$("#divDecisionHistorialAprobacion1").attr("style", "display:none;");
|
|||
|
|
$("#divDecisionHistorialAprobacion2").attr("style", "display:none;");
|
|||
|
|
$("#txtConclusionRecomendacion").attr('maxlength', '3000');
|
|||
|
|
|
|||
|
|
$("#chkEsCasoAprobado").change(function () {
|
|||
|
|
|
|||
|
|
$("#chkEsCasoAprobado").attr("checked", this.checked);
|
|||
|
|
$("#chkEsCasoPreAprobado").attr("checked", !this.checked);
|
|||
|
|
$("#chkEsCasoRechazado").attr("checked", !this.checked);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$("#chkEsCasoPreAprobado").change(function () {
|
|||
|
|
$("#chkEsCasoPreAprobado").attr("checked", this.checked);
|
|||
|
|
$("#chkEsCasoAprobado").attr("checked", !this.checked);
|
|||
|
|
$("#chkEsCasoRechazado").attr("checked", !this.checked);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$("#chkEsCasoRechazado").change(function () {
|
|||
|
|
$("#chkEsCasoPreAprobado").attr("checked", !this.checked);
|
|||
|
|
$("#chkEsCasoAprobado").attr("checked", !this.checked);
|
|||
|
|
$("#chkEsCasoRechazado").attr("checked", this.checked);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$("#radioSiTiene").change(function () {
|
|||
|
|
checkCondicion();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$("#radioNoTiene").change(function () {
|
|||
|
|
checkCondicion();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
switch ($("#hiddenStep").val()) {
|
|||
|
|
case "AU_Aprobacion_1":
|
|||
|
|
GetControlsSettings("Decision", "Decision", "FormDecisionFirma", true);
|
|||
|
|
break;
|
|||
|
|
case "AU_Aprobacion_2":
|
|||
|
|
GetControlsSettings("DecisionAprobacion2", "Decision", "FormDecisionFirma", true);
|
|||
|
|
break;
|
|||
|
|
case "AU_Vb_Modif_Caratula":
|
|||
|
|
GetControlsSettings("DecisionCaratula", "Decision", "FormDecisionFirma", true);
|
|||
|
|
break;
|
|||
|
|
case "AU_Vb_Aprob_Caratula":
|
|||
|
|
GetControlsSettings("DecisionAprobacionCaratula", "Decision", "FormDecisionFirma", true);
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
toastr.warning("Estimado usuario, no fue posible cargar la configuración del formulario para la etapa actual.<br>Contacte al administrador del sistema.", Message_Warning);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
this.checkCondicion = function () {
|
|||
|
|
|
|||
|
|
if ($("#radioSiTiene").attr("checked")) {
|
|||
|
|
//$("#txtEdificio").noRequired();
|
|||
|
|
GetControlsSettings("ExcepcionSi", "Decision", "FormDecisionFirma", false);
|
|||
|
|
}
|
|||
|
|
if ($("#radioNoTiene").attr("checked")) {
|
|||
|
|
GetControlsSettings("ExcepcionNo", "Decision", "FormDecisionFirma", false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.getDataModel = function () {
|
|||
|
|
if ($("#hiddenStep").val() == "AU_Aprobacion_2") {
|
|||
|
|
$("#btnFirma1Remove").unbind('click');
|
|||
|
|
}
|
|||
|
|
if ($("#hiddenStep").val() == "AU_Vb_Modif_Caratula") {
|
|||
|
|
$("#btnFirma1Remove").unbind('click');
|
|||
|
|
$("#btnFirma2Remove").unbind('click');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($("#hiddenTaskStatus").val() == 3) {
|
|||
|
|
$("#btnFirma1Remove").unbind('click');
|
|||
|
|
$("#btnFirma2Remove").unbind('click');
|
|||
|
|
$("#btnFirma3Remove").unbind('click');
|
|||
|
|
$("#btnFirma4Remove").unbind('click');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
ObtenerDatos($("#hiddensol_co_solicitud").val());
|
|||
|
|
obtenerItems($("#hiddensol_co_solicitud").val());
|
|||
|
|
|
|||
|
|
$('#btnDecision').unbind('click');
|
|||
|
|
$('#btnDecision').click(function () {
|
|||
|
|
CargarDataCatalogoDecision();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('#btnBuscar').unbind('click');
|
|||
|
|
$('#btnBuscar').click(function () {
|
|||
|
|
CargarDataCatalogoDecision();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
ENDREQUEST();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$("#btnGuardarDecision").click(function () {
|
|||
|
|
GuardarDatos(false);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$("#btnGuardar").click(function () {
|
|||
|
|
GuardarCondiciones();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$("#btnEnviar").click(function () {
|
|||
|
|
if ($("#hiddenDecision").val() != "") {
|
|||
|
|
if (!confirm("¿Enviar?"))
|
|||
|
|
return;
|
|||
|
|
GuardarDatos(true);
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
toastr.warning("Ingresar la Decisión.");
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$("#TabsClienteCentrico li a").click(function (event) {
|
|||
|
|
try {
|
|||
|
|
//Si etapa está activa
|
|||
|
|
if ($("#hiddenTaskStatus").val() == 1 && IsReadOnlyForm == false) {
|
|||
|
|
|
|||
|
|
event.preventDefault();
|
|||
|
|
var thisHREF = this.attributes["href"].nodeValue;
|
|||
|
|
|
|||
|
|
//Si es la primera vez que quiere salir o no ha guardado antes de quere salir.
|
|||
|
|
if ($("#hiddenFlagSalir").val() != "true" || $("#hiddenFlagGuardarDatos").val() != "true") {
|
|||
|
|
|
|||
|
|
//Activa el flag de salir
|
|||
|
|
$("#hiddenFlagSalir").val("true");
|
|||
|
|
|
|||
|
|
//Indica al usuario que debe guardar
|
|||
|
|
toastr.warning("Estimado usuario, debe guardar los datos antes de salir del formulario.", Message_Warning);
|
|||
|
|
ENDREQUEST();
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
document.location.href = thisHREF;
|
|||
|
|
}
|
|||
|
|
} catch (e) {
|
|||
|
|
ENDREQUEST();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$("#btnVolver").click(function () {
|
|||
|
|
|
|||
|
|
try {
|
|||
|
|
|
|||
|
|
if (IsReadOnlyForm == false) {
|
|||
|
|
|
|||
|
|
//Si etapa está activa
|
|||
|
|
if ($("#hiddenTaskStatus").val()) {
|
|||
|
|
//Si es la primera vez que quiere salir o no ha guardado antes de quere salir.
|
|||
|
|
if ($("#hiddenFlagSalir").val() != "true" || $("#hiddenFlagGuardarDatos").val() != "true") {
|
|||
|
|
|
|||
|
|
//Activa el flag de salir
|
|||
|
|
$("#hiddenFlagSalir").val("true");
|
|||
|
|
|
|||
|
|
//Indica al usuario que debe guardar
|
|||
|
|
toastr.warning("Estimado usuario, debe guardar los datos antes de salir del formulario.", Message_Warning);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
document.location.href = $("#hiddenHref").val();
|
|||
|
|
|
|||
|
|
} catch (e) {
|
|||
|
|
toastr.error("Estimado usuario ha ocurrido un problema al intentar volver al formulario. Vuelva a intentarlo mas tarde", Message_Error);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
this.CargarDataCatalogoDecision = function () {
|
|||
|
|
var proceso = $("#hiddenProcess").val();
|
|||
|
|
var etapa = $("#hiddenStep").val();
|
|||
|
|
var usuario = $("#hiddenUserID").val();
|
|||
|
|
var sol_co_cotizacion = $("#hiddensol_co_cotizacion").val();
|
|||
|
|
var DireccionAPI = $('#btnDecision').attr("Direccion_API");
|
|||
|
|
DireccionAPICatalogo = DireccionAPI;
|
|||
|
|
SelectedCatalog = "Decision";
|
|||
|
|
CargarDataCatalogo(DireccionAPI, $("#txtDescripcion").val(), proceso, etapa, usuario, sol_co_cotizacion);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.cargarCondiciones = function (filtro) {
|
|||
|
|
var uri = "api/AprobacionAPI/ObtenerCondicionesFormalizacion" + "?filtro=" + (filtro == null ? "" : filtro);
|
|||
|
|
$.getJSON(server + uri).done(function (data) {
|
|||
|
|
if (data != null) {
|
|||
|
|
lista = data;
|
|||
|
|
var Seleccionar = $("#btnseleccionar").html();
|
|||
|
|
var columnDefinition = [
|
|||
|
|
{ "data": "codigo" },
|
|||
|
|
{ "data": "descripcion" },
|
|||
|
|
{ "data": null, className: "center", defaultContent: Seleccionar }
|
|||
|
|
];
|
|||
|
|
$('#tableCondiciones').TableInit(0, false, true, false, false, columnDefinition, lista);
|
|||
|
|
|
|||
|
|
$('#tableCondiciones tbody tr').each(function () {
|
|||
|
|
var check = false;
|
|||
|
|
var id = $(this).find("td").eq(0).html();
|
|||
|
|
$.each(CondicionesFormalizacionSolicitud, function (key, item) {
|
|||
|
|
if (item.IdCondicionesFormalizacion == id) {
|
|||
|
|
check = true;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
$(this).find("td").eq(2)[0].all.chkSeleccionar.checked = check;
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
if ($.fn.DataTable.isDataTable('#tableCondiciones')) {
|
|||
|
|
LoadMessage();
|
|||
|
|
$('#tableCondiciones').DataTable().search('').draw();
|
|||
|
|
$('#modalCondiciones').modal('show');
|
|||
|
|
ENDREQUEST();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
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();
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.GuardarCondiciones = function () {
|
|||
|
|
var data = [];
|
|||
|
|
var cont = 0;
|
|||
|
|
$('#tableCondiciones tbody tr').each(function () {
|
|||
|
|
if ($(this).find("td").eq(2)[0].all.chkSeleccionar.checked == true) {
|
|||
|
|
data.push({
|
|||
|
|
IdCondicionesFormalizacion: $(this).find("td").eq(0).html(),
|
|||
|
|
IdSolicitud: $("#hiddensol_co_solicitud").val()
|
|||
|
|
});
|
|||
|
|
cont++;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
if (cont > 12) {
|
|||
|
|
toastr.warning("Solo puede seleccionar 12 Condiciones de Formalización.");
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
JsonCondicionesFormalizacion =
|
|||
|
|
{
|
|||
|
|
NoSolicitud: $("#hiddensol_co_solicitud").val(),
|
|||
|
|
CondicionesFormalizacionSolicitud: data
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var uri = 'api/AprobacionAPI/GuardarCondiciones/';
|
|||
|
|
var DTO = JSON.stringify(JsonCondicionesFormalizacion);
|
|||
|
|
|
|||
|
|
$.ajax({
|
|||
|
|
type: 'POST',
|
|||
|
|
url: server + uri,
|
|||
|
|
cache: false,
|
|||
|
|
data: DTO,
|
|||
|
|
contentType: 'application/json; charset=utf-8',
|
|||
|
|
dataType: 'json',
|
|||
|
|
success: function (data) {
|
|||
|
|
if (data.CodigoRespuesta == "EXITOSO") {
|
|||
|
|
toastr.info('Información guardada con exito', 'Completado');
|
|||
|
|
obtenerItems(data.NoSolicitud);
|
|||
|
|
$('#modalCondiciones').modal('hide');
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
toastr.error("Ha ocurrido un error.");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo.");
|
|||
|
|
ENDREQUEST();
|
|||
|
|
}).then(function (value) {
|
|||
|
|
ENDREQUEST();
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.obtenerItems = function (NoSolicitud) {
|
|||
|
|
var uri = 'api/AprobacionAPI/ObtenerCondicionesFormalizacionSolicitud?NoSolicitud=' + NoSolicitud
|
|||
|
|
$.getJSON(server + uri).done(function (data) {
|
|||
|
|
var TableItems = $('#TableItems').DataTable();
|
|||
|
|
if (data != null) {
|
|||
|
|
lista = data;
|
|||
|
|
CondicionesFormalizacionSolicitud = data;
|
|||
|
|
var columnDefinition = [
|
|||
|
|
{ "data": "IdCondicionesFormalizacion" },
|
|||
|
|
{ "data": "DescripsionCondicionesFormalizacion" },
|
|||
|
|
];
|
|||
|
|
$('#TableItems').TableInit(0, false, true, false, false, columnDefinition, lista);
|
|||
|
|
}
|
|||
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde");
|
|||
|
|
}).then(function (value) {
|
|||
|
|
ENDREQUEST();
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.Enviar = function () {
|
|||
|
|
var Incident = "0";
|
|||
|
|
|
|||
|
|
//**************************************
|
|||
|
|
//Decision Ir a Cotizacion
|
|||
|
|
//**************************************
|
|||
|
|
if ($("#hiddenDecision").val() == "14") {
|
|||
|
|
|
|||
|
|
//**************************************
|
|||
|
|
//Valida los motivos de devolucion
|
|||
|
|
//**************************************
|
|||
|
|
if (_HasMotivosDevolucion != true) {
|
|||
|
|
ENDREQUEST();
|
|||
|
|
toastr.warning("Estimado usuario debe registrar al menos un motivo de devolución.", Message_Warning);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (actualizarMotivo(3) == false) {
|
|||
|
|
ENDREQUEST();
|
|||
|
|
toastr.warning("Estimado usuario ha ocurrido un problema al registrar la información de los motivos de devolución. Por favor intente nuevamente.", Message_Warning);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
if ($("#hiddenIncident").val() != "")
|
|||
|
|
Incident = $("#hiddenIncident").val();
|
|||
|
|
|
|||
|
|
var JsonEnviarCotizacion =
|
|||
|
|
{
|
|||
|
|
IdCotizacion: $('#hiddensol_co_cotizacion').val(),
|
|||
|
|
UserId: $("#hiddenUserID").val(),
|
|||
|
|
TaskId: $("#hiddenTaskId").val(),
|
|||
|
|
Process: $("#hiddenProcess").val(),
|
|||
|
|
Step: $("#hiddenStep").val(),
|
|||
|
|
Incident: Incident,
|
|||
|
|
IdDecision: $("#hiddenDecision").val(),
|
|||
|
|
IdSolicitud: $("#hiddensol_co_solicitud").val(),
|
|||
|
|
IdMotivo: $("#hiddenMotivoRechazo").val()
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var uri = 'api/GlobalAPI/Enviar/';
|
|||
|
|
var DTO = JSON.stringify(JsonEnviarCotizacion);
|
|||
|
|
|
|||
|
|
$.ajax({
|
|||
|
|
type: 'POST',
|
|||
|
|
url: server + uri,
|
|||
|
|
cache: false,
|
|||
|
|
data: DTO,
|
|||
|
|
contentType: 'application/json; charset=utf-8',
|
|||
|
|
dataType: 'json',
|
|||
|
|
success: function (data) {
|
|||
|
|
if (data.CodigoRespuesta == "EXITOSO") {
|
|||
|
|
alert("Incidente enviado");
|
|||
|
|
|
|||
|
|
if (data.Alertas != null) {
|
|||
|
|
$.each(data.Alertas, function (index, value) {
|
|||
|
|
mensaje += "\n\n- " + value;
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
alert(mensaje);
|
|||
|
|
|
|||
|
|
window.open('', '_self', ''); window.close();
|
|||
|
|
}
|
|||
|
|
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) {
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo.");
|
|||
|
|
ENDREQUEST();
|
|||
|
|
}).then(function (value) {
|
|||
|
|
ENDREQUEST();
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.GuardarDatos = function (enviar) {
|
|||
|
|
if (!$("#FormDecisionFirma").valid()) {
|
|||
|
|
toastr.warning("Ingresar todos los campos que son requeridos.");
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var Exepcion = false;
|
|||
|
|
var Firma1 = "";
|
|||
|
|
var Firma2 = "";
|
|||
|
|
var Firma3 = "";
|
|||
|
|
var Firma4 = "";
|
|||
|
|
var IdTipoAprobacionCaso = null;
|
|||
|
|
|
|||
|
|
//TieneExcepcion
|
|||
|
|
if ($("#radioSiTiene").attr("checked")) {
|
|||
|
|
Exepcion = true;
|
|||
|
|
}
|
|||
|
|
else if ($("#radioNoTiene").attr("checked")) {
|
|||
|
|
Exepcion = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//TipoAprobacionCaso
|
|||
|
|
if ($("#chkEsCasoAprobado").attr("checked")) {
|
|||
|
|
IdTipoAprobacionCaso = 1;
|
|||
|
|
} else if ($("#chkEsCasoPreAprobado").attr("checked")) {
|
|||
|
|
IdTipoAprobacionCaso = 2;
|
|||
|
|
} else if ($("#chkEsCasoRechazado").attr("checked")) {
|
|||
|
|
IdTipoAprobacionCaso = 3;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (IdTipoAprobacionCaso == null) {
|
|||
|
|
toastr.warning("Estimado usuario, por favor marque un tipo de aprobación para el caso.");
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//Firma
|
|||
|
|
switch ($("#hiddenStep").val()) {
|
|||
|
|
case "AU_Aprobacion_1":
|
|||
|
|
Firma1 = $("#hiddenUserID").val();
|
|||
|
|
break;
|
|||
|
|
case "AU_Aprobacion_2":
|
|||
|
|
Firma2 = $("#hiddenUserID").val();
|
|||
|
|
break;
|
|||
|
|
case "AU_Vb_Modif_Caratula":
|
|||
|
|
Firma3 = $("#hiddenUserID").val();
|
|||
|
|
break;
|
|||
|
|
case "AU_Vb_Aprob_Caratula":
|
|||
|
|
Firma4 = $("#hiddenUserID").val();
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
toastr.warning("Estimado usuario, no fue posible cargar la configuración del formulario para la etapa actual.<br>Contacte al administrador del sistema.", Message_Warning);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
JsonAprobacion =
|
|||
|
|
{
|
|||
|
|
IdSolicitud: $("#hiddensol_co_solicitud").val(),
|
|||
|
|
DatosAprobacion: {
|
|||
|
|
TipoAprobacionCaso: IdTipoAprobacionCaso,
|
|||
|
|
ConclusionRecomendacion: $("#txtConclusionRecomendacion").val(),
|
|||
|
|
IdDecision: $("#hiddenDecision").val(),
|
|||
|
|
IdMotivo: $("#hiddenMotivoRechazo").val(),
|
|||
|
|
TieneExcepciones: Exepcion,
|
|||
|
|
IdExcepcion: $("#hiddenExcepciones").val(),
|
|||
|
|
Excepcion2: $("#hiddenExcepciones2").val(),
|
|||
|
|
IdRecomendacion: $("#hiddenRecomendacion").val(),
|
|||
|
|
LimiteRecomendado: $("#txtLimiteRecomendado").autoNumeric('get'),
|
|||
|
|
UsuarioFirma1: Firma1,
|
|||
|
|
UsuarioFirma2: Firma2,
|
|||
|
|
UsuarioFirma3: Firma3,
|
|||
|
|
UsuarioFirma4: Firma4
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var uri = 'api/AprobacionAPI/GuardarDatosDecision/';
|
|||
|
|
var DTO = JSON.stringify(JsonAprobacion);
|
|||
|
|
|
|||
|
|
$.ajax({
|
|||
|
|
type: 'POST',
|
|||
|
|
url: server + uri,
|
|||
|
|
cache: false,
|
|||
|
|
data: DTO,
|
|||
|
|
contentType: 'application/json; charset=utf-8',
|
|||
|
|
dataType: 'json',
|
|||
|
|
success: function (data) {
|
|||
|
|
if (data.CodigoRespuesta == "EXITOSO") {
|
|||
|
|
toastr.info('Información guardada con exito', 'Completado');
|
|||
|
|
|
|||
|
|
if ($("#hiddenFlagSalir").val() == "true") { $("#hiddenFlagGuardarDatos").val("true"); }
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
toastr.error("Ha ocurrido un error.");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo.");
|
|||
|
|
ENDREQUEST();
|
|||
|
|
}).then(function (value) {
|
|||
|
|
if (enviar)
|
|||
|
|
Enviar();
|
|||
|
|
else
|
|||
|
|
ENDREQUEST();
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.ObtenerDatos = function (NoSolicitud) {
|
|||
|
|
|
|||
|
|
var uri = 'api/AprobacionAPI/getDataModelDecision?NoSolicitud=' + NoSolicitud + '&etapa=' + $("#hiddenStep").val()
|
|||
|
|
|
|||
|
|
$.getJSON(server + uri).done(function (data) {
|
|||
|
|
informacion = data;
|
|||
|
|
if (informacion != null) {
|
|||
|
|
if (informacion.IdDecision != null)
|
|||
|
|
$("#hiddenDecision").val(informacion.IdDecision)
|
|||
|
|
|
|||
|
|
if (informacion.DescripcionDecision != null)
|
|||
|
|
$("#txtDecision").val(informacion.DescripcionDecision)
|
|||
|
|
|
|||
|
|
//??Ojo todo calculo de seguros debe actualizar el objeto de JsonCotizacionResponse.SegurosEnCotizacion
|
|||
|
|
if (!jQuery.isEmptyObject(informacion.historialDecision)) {
|
|||
|
|
$.each(informacion.historialDecision, function (key, item) {
|
|||
|
|
switch (item.Etapas.DescripcionEtapa) {
|
|||
|
|
case "AU_Aprobacion_1":
|
|||
|
|
if ($("#hiddenStep").val() != "AU_Aprobacion_1") {
|
|||
|
|
$("#txtDecisionHistorialAprobacion1").val(item.Decision != null ? item.Decision.Descripcion : "");
|
|||
|
|
$("#divDecisionHistorialAprobacion1").attr("style", "display:block;");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
break;
|
|||
|
|
case "AU_Aprobacion_2":
|
|||
|
|
if ($("#hiddenStep").val() != "AU_Aprobacion_2") {
|
|||
|
|
$("#txtDecisionHistorialAprobacion2").val(item.Decision != null ? item.Decision.Descripcion : "")
|
|||
|
|
$("#divDecisionHistorialAprobacion2").attr("style", "display:block;");
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case "AU_Vb_Modif_Caratula":
|
|||
|
|
|
|||
|
|
break;
|
|||
|
|
case "AU_Vb_Aprob_Caratula":
|
|||
|
|
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (informacion.IdMotivo != null)
|
|||
|
|
$("#hiddenMotivoRechazo").val(informacion.IdMotivo)
|
|||
|
|
|
|||
|
|
if (informacion.IdMotivo != null)
|
|||
|
|
$("#txtMotivoRechazo").val(informacion.DescripcionMotivo)
|
|||
|
|
|
|||
|
|
if (informacion.TieneExcepciones != null) {
|
|||
|
|
if (informacion.TieneExcepciones == true)
|
|||
|
|
$("#radioSiTiene").prop("checked", true);
|
|||
|
|
else if (informacion.TieneExcepciones == false)
|
|||
|
|
$("#radioNoTiene").prop("checked", true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (informacion.TieneExcepciones != null)
|
|||
|
|
$("#hiddenExcepciones").val(informacion.IdExcepcion)
|
|||
|
|
if (informacion.DescripcionExcepcion1 != null)
|
|||
|
|
$("#txtExcepciones").val(informacion.DescripcionExcepcion1)
|
|||
|
|
|
|||
|
|
if (informacion.Excepcion2 != null)
|
|||
|
|
$("#hiddenExcepciones2").val(informacion.Excepcion2)
|
|||
|
|
if (informacion.DescripcionExcepcion2 != null)
|
|||
|
|
$("#txtExcepciones2").val(informacion.DescripcionExcepcion2)
|
|||
|
|
|
|||
|
|
if (informacion.IdRecomendacion != null)
|
|||
|
|
$("#hiddenRecomendacion").val(informacion.IdRecomendacion)
|
|||
|
|
if (informacion.DescripcionRecomendacion != null)
|
|||
|
|
$("#txtRecomendacion").val(informacion.DescripcionRecomendacion)
|
|||
|
|
|
|||
|
|
if (informacion.LimiteRecomendado != null)
|
|||
|
|
$("#txtLimiteRecomendado").autoNumeric('set', informacion.LimiteRecomendado)
|
|||
|
|
|
|||
|
|
if (informacion.ConclusionRecomendacion != null)
|
|||
|
|
$("#txtConclusionRecomendacion").val(informacion.ConclusionRecomendacion);
|
|||
|
|
|
|||
|
|
if (informacion.Firma1 != null && informacion.Firma1 != "") {
|
|||
|
|
$("#divFirma1Container").hide();
|
|||
|
|
$("#divFirma1Image").show();
|
|||
|
|
$("#imgFirma1").attr("src", informacion.Firma1);
|
|||
|
|
$("#lblFirma1User").text(informacion.UsuarioFirma1);
|
|||
|
|
$("#pswFirma1").noRequired();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (informacion.Firma2 != null && informacion.Firma2 != "") {
|
|||
|
|
$("#divFirma2Container").hide();
|
|||
|
|
$("#divFirma2Image").show();
|
|||
|
|
$("#imgFirma2").attr("src", informacion.Firma2);
|
|||
|
|
$("#lblFirma2User").text(informacion.UsuarioFirma2);
|
|||
|
|
$("#pswFirma2").noRequired();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (informacion.Firma3 != null && informacion.Firma3 != "") {
|
|||
|
|
$("#divFirma3Container").hide();
|
|||
|
|
$("#divFirma3Image").show();
|
|||
|
|
$("#imgFirma3").attr("src", informacion.Firma3);
|
|||
|
|
$("#lblFirma3User").text(informacion.UsuarioFirma3);
|
|||
|
|
$("#pswFirma3").noRequired();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//BMU 01-09-2016
|
|||
|
|
if (informacion.Firma4 != null && informacion.Firma4 != "") {
|
|||
|
|
$("#divFirma4Container").hide();
|
|||
|
|
$("#divFirma4Image").show();
|
|||
|
|
$("#imgFirma4").attr("src", informacion.Firma4);
|
|||
|
|
$("#lblFirma4User").text(informacion.UsuarioFirma4);
|
|||
|
|
$("#pswFirma4").noRequired();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (informacion.TipoAprobacionCaso != null) {
|
|||
|
|
switch (informacion.TipoAprobacionCaso) {
|
|||
|
|
case 1:
|
|||
|
|
$("#chkEsCasoAprobado").prop("checked", true);
|
|||
|
|
$("#chkEsCasoPreAprobado").prop("checked", false);
|
|||
|
|
break;
|
|||
|
|
case 2:
|
|||
|
|
$("#chkEsCasoAprobado").prop("checked", false);
|
|||
|
|
$("#chkEsCasoPreAprobado").prop("checked", true);
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
$("#chkEsCasoAprobado").prop("checked", false);
|
|||
|
|
$("#chkEsCasoPreAprobado").prop("checked", false);
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
checkCondicion();
|
|||
|
|
CargarDataCatalogoAdicional();
|
|||
|
|
}
|
|||
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde");
|
|||
|
|
}).then(function (value) {
|
|||
|
|
SoloLectura();
|
|||
|
|
ENDREQUEST();
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.CargarDataCatalogoAdicional = function (control) {
|
|||
|
|
|
|||
|
|
try {
|
|||
|
|
if ($("#hiddenDecision").val() == 2) {
|
|||
|
|
$("#divMotivoRechazo").show();
|
|||
|
|
$("#txtMotivoRechazo").attr("required", true);
|
|||
|
|
$("#divMotivosDevolucion").hide();
|
|||
|
|
$("#FormDecisionFirma").valid();
|
|||
|
|
}
|
|||
|
|
else if ($("#hiddenDecision").val() == 14) {
|
|||
|
|
$("#divMotivosDevolucion").show();
|
|||
|
|
$("#divMotivoRechazo").hide();
|
|||
|
|
$("#txtMotivoRechazo").attr("required", false);
|
|||
|
|
$("#FormDecisionFirma").valid();
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
$("#divMotivoRechazo").hide();
|
|||
|
|
$("#txtMotivoRechazo").attr("required", false);
|
|||
|
|
$("#divMotivosDevolucion").hide();
|
|||
|
|
$("#FormDecisionFirma").valid();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
switch (control) {
|
|||
|
|
case "Recomendacion":
|
|||
|
|
if ($("#txtRecomendacion").val().toLowerCase() == "positiva") {
|
|||
|
|
$("#txtLimiteRecomendado").attr("disabled", false);
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
$("#txtLimiteRecomendado").attr("disabled", true);
|
|||
|
|
$("#txtLimiteRecomendado").autoNumeric('set', "0.00")
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (e) {
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$("#btnMotivosDevolucion").click(function () {
|
|||
|
|
initializeFormMotivos(9, false, "SOURCE");
|
|||
|
|
$('#modalMotivos').modal('show');
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
this.actualizarMotivo = function (_Estado) {
|
|||
|
|
|
|||
|
|
var bResult = false;
|
|||
|
|
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,
|
|||
|
|
async: false,
|
|||
|
|
contentType: 'application/json; charset=utf-8',
|
|||
|
|
dataType: 'json',
|
|||
|
|
success: function (data) {
|
|||
|
|
if (data == "EXITOSO") {
|
|||
|
|
toastr.info('Motivos actualizados con exito', 'Completado');
|
|||
|
|
bResult = true;
|
|||
|
|
}
|
|||
|
|
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) {
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
} catch (e) {
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado al intentar actualizar los motivos. Vuelva a intentarlo.");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return bResult;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.SoloLectura = function () {
|
|||
|
|
|
|||
|
|
try {
|
|||
|
|
|
|||
|
|
if ($("#hiddenTaskStatus").val() == 1) {
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
FormReadOnly();
|
|||
|
|
|
|||
|
|
$("button[direccion_api]").remove();
|
|||
|
|
$("#btnGuardarDecision").remove();
|
|||
|
|
$("#btnEnviar").remove();
|
|||
|
|
$("#btnFirma1Remove").unbind('click');
|
|||
|
|
$("#btnFirma2Remove").unbind('click');
|
|||
|
|
$("#btnFirma3Remove").unbind('click');
|
|||
|
|
$("#btnFirma4Remove").unbind('click');
|
|||
|
|
|
|||
|
|
$("#btnGuardarBitacoraComentario").remove();
|
|||
|
|
IsReadOnlyForm = true;
|
|||
|
|
|
|||
|
|
} catch (e) {
|
|||
|
|
toastr.error("Ha ocurrido un problema al cargar el formulario. Vuela a intentarlo mas tarde", Message_Error);
|
|||
|
|
}
|
|||
|
|
};
|