860 lines
31 KiB
JavaScript
860 lines
31 KiB
JavaScript
|
|
//#region GLOBALES
|
|||
|
|
$("#formCrearOperacion").EnableValidationToolTip();
|
|||
|
|
var CrearOperacion = {};
|
|||
|
|
var tableItemsCondicionesTasa;
|
|||
|
|
var IsReadOnlyForm = false;
|
|||
|
|
var IsAplicaIntegracionConCartera = false;
|
|||
|
|
//#endregion
|
|||
|
|
|
|||
|
|
//#region READY
|
|||
|
|
|
|||
|
|
jQuery(document).ready(function () {
|
|||
|
|
$("#btnCrearActualizarCodeudor").attr("style", "display:none");
|
|||
|
|
|
|||
|
|
tableItemsCondicionesTasa = $('#TableItemsCondicionesTasa').DataTable();
|
|||
|
|
GetControlsSettings("CrearOperacion", "CrearOperacion", "formCrearOperacion", true);
|
|||
|
|
|
|||
|
|
$("#chkCrearCuenta").change(function () {
|
|||
|
|
checkCuenta();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$("#chkEmailAAbogado").change(function (){
|
|||
|
|
checkEmailAAbogado();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$("#btnGuardar").click(function (){
|
|||
|
|
GuardarDatos();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$("#btnCuentaNo").click(function () {
|
|||
|
|
CargarCuentas();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$("#btnCrearCuenta").click(function () {
|
|||
|
|
|
|||
|
|
if($("#chkCrearCuenta").attr("checked"))
|
|||
|
|
{
|
|||
|
|
if (CrearCuenta() == false) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
toastr.warning("Estimado usuario, debe marcar el check de crear cuenta.", Message_Warning);
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
//#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
$("#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();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//#region getDataModel
|
|||
|
|
this.getDataModel = function () {
|
|||
|
|
try {
|
|||
|
|
|
|||
|
|
$('#btnEnviarA').unbind('click');
|
|||
|
|
$('#btnEnviarA').click(function () {
|
|||
|
|
CargarDataCatalogoDecision();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('#btnBuscar').unbind('click');
|
|||
|
|
$('#btnBuscar').click(function () {
|
|||
|
|
CargarDataCatalogoDecision();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$("#btnEnviar").click(function () {
|
|||
|
|
if ($("#hiddenEnviarA").val() != "") {
|
|||
|
|
if (!confirm("¿Enviar?"))
|
|||
|
|
return;
|
|||
|
|
Enviar();
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
toastr.warning("Debe especificar a donde enviar la solicitud.");
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
if ($("#hiddenIdAseguradoraAuto").val() == "3") { // Steven Rojas
|
|||
|
|
$('#txtPolizaAuto').noRequired();
|
|||
|
|
$('#txtPolizaAuto').attr("disabled", true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var uri = 'api/CreaOperacionAPI/getDataModel?NoSolicitud=' + $("#hiddensol_co_solicitud").val() + '&etapa=' + $("#hiddenStep").val()
|
|||
|
|
|
|||
|
|
$.getJSON(server + uri).done(function (data) {
|
|||
|
|
|
|||
|
|
if (data != null) {
|
|||
|
|
CrearOperacion = data;
|
|||
|
|
|
|||
|
|
IsAplicaIntegracionConCartera = CrearOperacion.Solicitud.AplicaIntegracionConCartera == null ? false : CrearOperacion.Solicitud.AplicaIntegracionConCartera;
|
|||
|
|
|
|||
|
|
if (CrearOperacion.HistorialDecision != null) {
|
|||
|
|
HistorialDecision = CrearOperacion.HistorialDecision;
|
|||
|
|
$("#hiddenEnviarA").val(HistorialDecision.Decision.IdDecision);
|
|||
|
|
$("#txtEnviarA").val(HistorialDecision.Decision.Descripcion);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (CrearOperacion.Solicitud.DataFaseII[0] != null) {
|
|||
|
|
var DataFaseII = CrearOperacion.Solicitud.DataFaseII;
|
|||
|
|
|
|||
|
|
//Tipo de Operacion
|
|||
|
|
if (DataFaseII[0].TipoOperacion != null && DataFaseII[0].TipoOperacion != "")
|
|||
|
|
$("#txtTipoOperacion").val(DataFaseII[0].TipoOperacion)
|
|||
|
|
else
|
|||
|
|
$("#txtTipoOperacion").val(CrearOperacion.TipoOperacion)
|
|||
|
|
|
|||
|
|
//Numero de Linea
|
|||
|
|
if (DataFaseII[0].NLinea != null && DataFaseII[0].NLinea != "")
|
|||
|
|
$("#txtNoLinea").val(DataFaseII[0].NLinea);
|
|||
|
|
else
|
|||
|
|
$("#txtNoLinea").val(CrearOperacion.LineaCredito);
|
|||
|
|
|
|||
|
|
//Casificacion
|
|||
|
|
if (DataFaseII[0].Clasificacion != null)
|
|||
|
|
$("#txtClasificacion").val(DataFaseII[0].Clasificacion);
|
|||
|
|
|
|||
|
|
$("#txtNoOperacion").val(DataFaseII[0].NoOperacion)
|
|||
|
|
|
|||
|
|
if (DataFaseII[0].FechaInicio != null)
|
|||
|
|
$("#txtFechaInicio").val(moment(DataFaseII[0].FechaInicio).format("DD/MM/YYYY"));
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (DataFaseII[0].CrearCuenta) {
|
|||
|
|
$("#chkCrearCuenta").prop("checked", true);
|
|||
|
|
} else {
|
|||
|
|
$("#chkCrearCuenta").prop("checked", false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
checkCuenta();
|
|||
|
|
|
|||
|
|
if (DataFaseII[0].IdTipoCuenta != null)
|
|||
|
|
$("#hiddenTipoCuentaNueva").val(DataFaseII[0].IdTipoCuenta)
|
|||
|
|
|
|||
|
|
if (DataFaseII[0].IdTipoEnvioCuenta != null)
|
|||
|
|
$("#hiddenTipoEnvioCuenta").val(DataFaseII[0].IdTipoEnvioCuenta)
|
|||
|
|
|
|||
|
|
if (DataFaseII[0].TipoCuenta != null)
|
|||
|
|
$("#txtTipoCuentaNueva").val(DataFaseII[0].TipoCuenta.Descripcion)
|
|||
|
|
|
|||
|
|
if (DataFaseII[0].TipoEnvioCuenta != null)
|
|||
|
|
$("#txtTipoEnvioCuenta").val(DataFaseII[0].TipoEnvioCuenta.Descripcion)
|
|||
|
|
|
|||
|
|
if (DataFaseII[0].NumeroGarantia != null)
|
|||
|
|
$("#txtGarantia").val(DataFaseII[0].NumeroGarantia)
|
|||
|
|
|
|||
|
|
if (DataFaseII[0].PolizaAuto != null)
|
|||
|
|
$("#txtPolizaAuto").val(DataFaseII[0].PolizaAuto)
|
|||
|
|
|
|||
|
|
if (DataFaseII[0].ConsecutivoBien != null)
|
|||
|
|
$("#txtConsecutivoBien").val(DataFaseII[0].ConsecutivoBien)
|
|||
|
|
|
|||
|
|
if (DataFaseII[0].IdFormaPago != null)
|
|||
|
|
$("#hiddenFormaPago").val(DataFaseII[0].IdFormaPago)
|
|||
|
|
|
|||
|
|
if (DataFaseII[0].CuentasInternas != null) {
|
|||
|
|
$("#txtCuentaNo").val(DataFaseII[0].CuentasInternas.Ncuenta == null ? "" : DataFaseII[0].CuentasInternas.Ncuenta);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (DataFaseII[0].FormaPago.Descripcion != null)
|
|||
|
|
$("#txtFormaPago").val(DataFaseII[0].FormaPago.Descripcion)
|
|||
|
|
|
|||
|
|
if (DataFaseII[0].IdCuenta != null)
|
|||
|
|
$("#hiddenCuentaNo").val(DataFaseII[0].IdCuenta)
|
|||
|
|
|
|||
|
|
if (DataFaseII[0].InstruccionesEspeciales != null)
|
|||
|
|
$("#txtInstruccionesEspeciales").val(DataFaseII[0].InstruccionesEspeciales)
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
$("#txtTipoOperacion").val(CrearOperacion.TipoOperacion);
|
|||
|
|
$("#txtNoLinea").val(CrearOperacion.LineaCredito);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$.each(CrearOperacion.Solicitud.Solicitante, function (key, item) {
|
|||
|
|
if (item.IdTipoSolicitante == 1) {
|
|||
|
|
|
|||
|
|
var _primerNombreDeudor = item.Cliente.PrimerNombre != null ? item.Cliente.PrimerNombre.trim() + " " : "";
|
|||
|
|
var _segundoNombreDeudor = item.Cliente.SegundoNombre != null ? item.Cliente.SegundoNombre.trim() + " " : "";
|
|||
|
|
var _primerApellidoDeudor = item.Cliente.PrimerApellido != null ? item.Cliente.PrimerApellido.trim() + " " : "";
|
|||
|
|
var _segundoApellidoDeudor = item.Cliente.SegundoApellido != null ? item.Cliente.SegundoApellido.trim() + " " : "";
|
|||
|
|
|
|||
|
|
$("#txtEnteDeudor").val(item.Cliente.Ente);
|
|||
|
|
$("#txtDeudor").val(_primerNombreDeudor + _segundoNombreDeudor + _primerApellidoDeudor + _segundoApellidoDeudor);
|
|||
|
|
$("#txtCliente").val(_primerNombreDeudor + _segundoNombreDeudor + _primerApellidoDeudor + _segundoApellidoDeudor);
|
|||
|
|
$("#txtClasificacion").val(item.Cliente.IdCategoriaRiesgo);
|
|||
|
|
|
|||
|
|
if (item.Cliente.InformacionLaboralCliente.length > 0)
|
|||
|
|
$("#txtEmpresa").val(item.Cliente.InformacionLaboralCliente[0].NombreEmpresa);
|
|||
|
|
}
|
|||
|
|
else if (item.IdTipoSolicitante == 2) {
|
|||
|
|
|
|||
|
|
var _primerNombreCodeudor = item.Cliente.PrimerNombre != null ? item.Cliente.PrimerNombre.trim() + " " : "";
|
|||
|
|
var _segundoNombreCodeudor = item.Cliente.SegundoNombre != null ? item.Cliente.SegundoNombre.trim() + " " : "";
|
|||
|
|
var _primerApellidoCodeudor = item.Cliente.PrimerApellido != null ? item.Cliente.PrimerApellido.trim() + " " : "";
|
|||
|
|
var _segundoApellidoCodeudor = item.Cliente.SegundoApellido != null ? item.Cliente.SegundoApellido.trim() + " " : "";
|
|||
|
|
|
|||
|
|
$("#txtEnteCodeudor").val(item.Cliente.Ente);
|
|||
|
|
$("#txtCodeudor").val(_primerNombreCodeudor + _segundoNombreCodeudor + _primerApellidoCodeudor + _segundoApellidoCodeudor);
|
|||
|
|
|
|||
|
|
$("#divClienteCodeudor").attr("style", "display:block");
|
|||
|
|
$("#btnCrearActualizarCodeudor").attr("style", "display:block");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
//Cotizacion
|
|||
|
|
if (CrearOperacion.Solicitud.Cotizacion != null)
|
|||
|
|
{
|
|||
|
|
//Oficial
|
|||
|
|
$("#hiddenOficial").val(CrearOperacion.Solicitud.Cotizacion.EjecutivoCotizacion.CodOficial)
|
|||
|
|
$("#txtOficial").val(CrearOperacion.Solicitud.Cotizacion.EjecutivoCotizacion.NombreEjecutivo)
|
|||
|
|
|
|||
|
|
//PolizaVehiculoGratis
|
|||
|
|
$("#chk" + "PolizaVehiculoGratis").attr("checked", CrearOperacion.Solicitud.Cotizacion.AplicaPolizaVehiculoGratis != true ? false : true);
|
|||
|
|
|
|||
|
|
//PlazoMesesPolizaVehiculoGratis
|
|||
|
|
$("#hidden" + "PlazoMesesPolizaVehiculoGratis").val(CrearOperacion.Solicitud.Cotizacion.PeriodoMesesGracia == 0 ? '' : CrearOperacion.Solicitud.Cotizacion.PeriodoMesesGracia);
|
|||
|
|
$("#txt" + "PlazoMesesPolizaVehiculoGratis").val(CrearOperacion.Solicitud.Cotizacion.PeriodoMesesGracia == 0 ? '' : CrearOperacion.Solicitud.Cotizacion.PeriodoMesesGracia);
|
|||
|
|
|
|||
|
|
$("#txtMoneda").val(CrearOperacion.Solicitud.Cotizacion.Moneda.Descripcion)
|
|||
|
|
$("#txtMonto").val(CrearOperacion.Solicitud.Cotizacion.MontoPrestamo)
|
|||
|
|
|
|||
|
|
$("#txtPlazo").val(CrearOperacion.Solicitud.Cotizacion.PeriodoMesesCredito);
|
|||
|
|
$("#txtCuotaPactada").val(CrearOperacion.Solicitud.Cotizacion.CuotaPrestamo)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
$("#hiddenPropositoCredito").val(CrearOperacion.Solicitud.IdPropositoCredito);
|
|||
|
|
if (CrearOperacion.Solicitud.PropositoCredito != null)
|
|||
|
|
$("#txtDestino").val(CrearOperacion.Solicitud.PropositoCredito.Descripcion);
|
|||
|
|
|
|||
|
|
|
|||
|
|
$("#txtSucursal").val(CrearOperacion.Solicitud.Sucursal.Descripcion)
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (CrearOperacion.JsonProgramaCrediticio[0] != null) {
|
|||
|
|
if (CrearOperacion.JsonProgramaCrediticio[0].Descripcion != null)
|
|||
|
|
$("#txtProgCrediticio").val(CrearOperacion.JsonProgramaCrediticio[0].Descripcion);
|
|||
|
|
|
|||
|
|
var columnDefinition = [
|
|||
|
|
{ "data": "Periodo" },
|
|||
|
|
{ "data": "PlazoMeses" },
|
|||
|
|
{ "data": "DescripcionTipoTasa" },
|
|||
|
|
{ "data": "DescripcionTipoTasaReferencia" },
|
|||
|
|
{ "data": "TasaInteresFinal" },
|
|||
|
|
{ "data": "TasaMinima" },
|
|||
|
|
{ "data": "DescripcionPeriodoReajuste" }
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
$('#TableItemsCondicionesTasa').TableInit(0, false, true, false, false, columnDefinition, CrearOperacion.JsonProgramaCrediticio[0].ProgramaCrediticioCondicionesTasaAdapted);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
InicializarDesembolso();
|
|||
|
|
|
|||
|
|
ComportamientoFormaPago();
|
|||
|
|
|
|||
|
|
$("#formCrearOperacion").valid();
|
|||
|
|
}
|
|||
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde");
|
|||
|
|
}).then(function (value) {
|
|||
|
|
SoloLectura();
|
|||
|
|
if ($("#hiddenTaskStatus").val() == 1) ObtenerFechaProceso();
|
|||
|
|
ENDREQUEST();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
} catch (e) {
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado al cargar el formulario. Vuelva a intentarlo mas tarde");
|
|||
|
|
ENDREQUEST();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
//#endregion
|
|||
|
|
|
|||
|
|
this.ObtenerFechaProceso = function()
|
|||
|
|
{
|
|||
|
|
var fechaProcesoCobis = "";
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
fechaProcesoCobis = ObtenerFechaProcesoCobis();
|
|||
|
|
if (fechaProcesoCobis != "")
|
|||
|
|
{
|
|||
|
|
var arrFehaProcesoCobis = fechaProcesoCobis.split("/");
|
|||
|
|
$("#txtFechaInicio").val(arrFehaProcesoCobis[0] + "/" + arrFehaProcesoCobis[1] + "/" + arrFehaProcesoCobis[2]);
|
|||
|
|
|
|||
|
|
$("#formCrearOperacion").validateElement("#txtFechaInicio");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
} catch (e) {
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
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 = $('#btnEnviarA').attr("Direccion_API");
|
|||
|
|
DireccionAPICatalogo = DireccionAPI;
|
|||
|
|
SelectedCatalog = "EnviarA";
|
|||
|
|
CargarDataCatalogo(DireccionAPI, $("#txtDescripcion").val(), proceso, etapa, usuario, sol_co_cotizacion);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.Enviar = function ()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
if (!$("#formCrearOperacion").valid()) {
|
|||
|
|
toastr.warning("Ingresar todos los campos que son requeridos.");
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//*****************************************
|
|||
|
|
//Solo si aplica la integración con Cartera
|
|||
|
|
//*****************************************
|
|||
|
|
if (IsAplicaIntegracionConCartera == true)
|
|||
|
|
{
|
|||
|
|
if (ValidarCuadreFormasDesembolso() == false) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//if ($("#chkEmailAAgencia").attr("checked") || $("#chkEmailAAbogado").attr("checked")) {
|
|||
|
|
// if (enviarDocumentPrenda() == false) {
|
|||
|
|
// //return false;
|
|||
|
|
// }
|
|||
|
|
//}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
var Incident = "0";
|
|||
|
|
if ($("#hiddenIncident").val() != "")
|
|||
|
|
Incident = $("#hiddenIncident").val();
|
|||
|
|
|
|||
|
|
|
|||
|
|
//Si no se guardaron los datos correctamente entonces no continua
|
|||
|
|
if (GuardarDatos() == false) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
var JsonEnviarCotizacion =
|
|||
|
|
{
|
|||
|
|
IdCotizacion: $('#hiddensol_co_cotizacion').val(),
|
|||
|
|
UserId: $("#hiddenUserID").val(),
|
|||
|
|
TaskId: $("#hiddenTaskId").val(),
|
|||
|
|
Process: $("#hiddenProcess").val(),
|
|||
|
|
Step: $("#hiddenStep").val(),
|
|||
|
|
Incident: Incident,
|
|||
|
|
IdDecision: $("#hiddenEnviarA").val(),
|
|||
|
|
IdSolicitud: $("#hiddensol_co_solicitud").val(),
|
|||
|
|
DocumentoPrenda: enviarDocumentPrenda()
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var uri = 'api/CreaOperacionAPI/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");
|
|||
|
|
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);
|
|||
|
|
toastr.warning(data.DescripcionRespuesta, Message_Warning);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (data.Alertas != null)
|
|||
|
|
{
|
|||
|
|
$.each(data.Alertas, function (key, item) {
|
|||
|
|
if (item.trim() != "") {
|
|||
|
|
toastr.warning(item, Message_Warning);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo.");
|
|||
|
|
ENDREQUEST();
|
|||
|
|
}).then(function (value) {
|
|||
|
|
ENDREQUEST();
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.cargarDesembolso = function () {
|
|||
|
|
LoadMessage();
|
|||
|
|
$("#modalFormaDesembolso").modal("show");
|
|||
|
|
ENDREQUEST();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.checkCuenta = function () {
|
|||
|
|
if ($("#chkCrearCuenta").attr("checked")) {
|
|||
|
|
GetControlsSettings("CrearCuentaSi", "CrearOperacion", "formCrearOperacion", false);
|
|||
|
|
} else {
|
|||
|
|
GetControlsSettings("CrearCuentaNo", "CrearOperacion", "formCrearOperacion", false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.checkEmailAAbogado = function () {
|
|||
|
|
if ($("#chkEmailAAbogado").attr("checked")) {
|
|||
|
|
$("#txtCorreoDestinatarioAdicional").attr("disabled", false)
|
|||
|
|
$("#txtCorreoDestinatarioAdicional").required();
|
|||
|
|
} else {
|
|||
|
|
$("#txtCorreoDestinatarioAdicional").val("");
|
|||
|
|
$("#txtCorreoDestinatarioAdicional").noRequired();
|
|||
|
|
$("#txtCorreoDestinatarioAdicional").attr("disabled", true)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.GuardarDatos = function () {
|
|||
|
|
|
|||
|
|
var statusSave = false;
|
|||
|
|
|
|||
|
|
try {
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (!$("#formCrearOperacion").valid()) {
|
|||
|
|
toastr.warning("Ingresar todos los campos que son requeridos.");
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var cuentanueva = false;
|
|||
|
|
if ($("#chkCrearCuenta").attr("checked"))
|
|||
|
|
cuentanueva = true
|
|||
|
|
else
|
|||
|
|
cuentanueva = false
|
|||
|
|
|
|||
|
|
var DataFaseII = {
|
|||
|
|
IdSolicitud: $("#hiddensol_co_solicitud").val(),
|
|||
|
|
TipoOperacion: $("#txtTipoOperacion").val(),
|
|||
|
|
Clasificacion: $("#txtClasificacion").val(),
|
|||
|
|
NoOperacion: $("#txtNoOperacion").val(),
|
|||
|
|
FechaInicio: $('#txtFechaInicio').val() == "" ? null : moment($('#txtFechaInicio').val(), "DD/MM/YYYY").toJSON(),
|
|||
|
|
NLinea: $("#txtNoLinea").val(),
|
|||
|
|
CrearCuenta: cuentanueva,
|
|||
|
|
IdTipoCuenta: $("#hiddenTipoCuentaNueva").val(),
|
|||
|
|
IdTipoEnvioCuenta: $("#hiddenTipoEnvioCuenta").val(),
|
|||
|
|
NumeroGarantia: $("#txtGarantia").val(),
|
|||
|
|
PolizaAuto: $("#txtPolizaAuto").val(),
|
|||
|
|
ConsecutivoBien: $("#txtConsecutivoBien").val(),
|
|||
|
|
IdFormaPago: $("#hiddenFormaPago").val(),
|
|||
|
|
IdCuenta: $("#hiddenCuentaNo").val(),
|
|||
|
|
InstruccionesEspeciales: $("#txtInstruccionesEspeciales").val(),
|
|||
|
|
Solicitud: {
|
|||
|
|
IdPropositoCredito: $("#hiddenPropositoCredito").val()
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var uri = 'api/CreaOperacionAPI/GuardarDatos/';
|
|||
|
|
var DTO = JSON.stringify(DataFaseII);
|
|||
|
|
|
|||
|
|
$.ajax({
|
|||
|
|
type: 'POST',
|
|||
|
|
url: server + uri,
|
|||
|
|
cache: false,
|
|||
|
|
data: DTO,
|
|||
|
|
contentType: 'application/json; charset=utf-8',
|
|||
|
|
dataType: 'json',
|
|||
|
|
async: false,
|
|||
|
|
success: function (data) {
|
|||
|
|
if (data.CodigoRespuesta == "EXITOSO") {
|
|||
|
|
statusSave = true;
|
|||
|
|
|
|||
|
|
$("#hiddenFlagGuardarDatos").val(true)
|
|||
|
|
toastr.info('Información guardada con exito', 'Completado');
|
|||
|
|
|
|||
|
|
if ($("#hiddenFlagSalir").val() == "true") { $("#hiddenFlagGuardarDatos").val("true"); }
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado al guardar la información. Por favor contacte al administrador del sistema.");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo.");
|
|||
|
|
ENDREQUEST();
|
|||
|
|
}).then(function (value) {
|
|||
|
|
ENDREQUEST();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
} catch (e)
|
|||
|
|
{
|
|||
|
|
ENDREQUEST();
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado al intentar guardar la información del formulario. Por favor contacte al admnistrador del sistema.");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return statusSave;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.CargarCuentas = function () {
|
|||
|
|
var uri = "api/GlobalAPI/ObtenerCuenta?sol_co_solicitud=" + $("#hiddensol_co_solicitud").val();
|
|||
|
|
$.getJSON(server + uri).done(function (data) {
|
|||
|
|
if (data != null) {
|
|||
|
|
lista = data;
|
|||
|
|
var Seleccionar = $("#btnSeleccionarCuenta").html();
|
|||
|
|
var columnDefinition = [
|
|||
|
|
{ "data": null, className: "center", defaultContent: Seleccionar },
|
|||
|
|
{ "data": "Codigo" },
|
|||
|
|
{ "data": "Cuenta" },
|
|||
|
|
{ "data": "Moneda" }
|
|||
|
|
];
|
|||
|
|
$('#tableCuentas').TableInit(0, false, true, false, false, columnDefinition, lista);
|
|||
|
|
if ($.fn.DataTable.isDataTable('#tableCuentas')) {
|
|||
|
|
LoadMessage();
|
|||
|
|
$('#tableCuentas').DataTable().search('').draw();
|
|||
|
|
$('#modalCuentas').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();
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$(document).on('click', '#tableCuentas tbody td', function (event) {
|
|||
|
|
var data = $('#tableCuentas').DataTable().row($(this).parents('tr')).data();
|
|||
|
|
$("#hiddenCuentaNo").val(data.Codigo);
|
|||
|
|
$("#txtCuentaNo").val(data.Cuenta);
|
|||
|
|
$('#modalCuentas').modal('hide');
|
|||
|
|
$("#formCrearOperacion").validateElement("#txtCuentaNo");
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
this.enviarDocumentPrenda = function () {
|
|||
|
|
|
|||
|
|
var status = false;
|
|||
|
|
var _model = null;
|
|||
|
|
var _isEmailInputList = false;
|
|||
|
|
var _isEmailAgenciaList = false;
|
|||
|
|
|
|||
|
|
try {
|
|||
|
|
|
|||
|
|
|
|||
|
|
if ($("#chkEmailAAgencia").attr("checked") || $("#chkEmailAAbogado").attr("checked")) {
|
|||
|
|
|
|||
|
|
if ($("#chkEmailAAbogado").attr("checked")) { _isEmailInputList = true; }
|
|||
|
|
if ($("#chkEmailAAgencia").attr("checked")) { _isEmailAgenciaList = true; }
|
|||
|
|
|
|||
|
|
_model = {
|
|||
|
|
|
|||
|
|
IdCotizacion: $('#hiddensol_co_cotizacion').val(),
|
|||
|
|
IsEmailInputList: _isEmailInputList,
|
|||
|
|
IsEmailAgenciaList: _isEmailAgenciaList,
|
|||
|
|
EmailsInputList: [$('#txtCorreoDestinatarioAdicional').val()]
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//var uri = 'api/CreaOperacionAPI/EnviarDocumentoPrenda/';
|
|||
|
|
//var DTO = JSON.stringify(_model);
|
|||
|
|
|
|||
|
|
//$.ajax({
|
|||
|
|
// type: 'POST',
|
|||
|
|
// url: server + uri,
|
|||
|
|
// cache: false,
|
|||
|
|
// data: DTO,
|
|||
|
|
// contentType: 'application/json; charset=utf-8',
|
|||
|
|
// dataType: 'json',
|
|||
|
|
// async: false,
|
|||
|
|
// success: function (data) {
|
|||
|
|
// if (data != null) {
|
|||
|
|
// if (data.CodigoRespuesta == "EXITOSO") {
|
|||
|
|
// status = true;
|
|||
|
|
// }
|
|||
|
|
// else if (data.CodigoRespuesta == "ADVERTENCIA") {
|
|||
|
|
// toastr.warning(data.DescripcionRespuesta, Message_Warning);
|
|||
|
|
// status = true;
|
|||
|
|
// }
|
|||
|
|
// else {
|
|||
|
|
// toastr.error("Ha ocurrido un error inesperado al enviar el correo electrónico a los destinatarios. Por favor contacte al administrador del Sistema.", Message_Error);
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
//}).fail(function (jqxhr, textStatus, error) {
|
|||
|
|
// ENDREQUEST();
|
|||
|
|
// toastr.error("Ha ocurrido un error inesperado al enviar el correo electrónico a los destinatarios. Vuelva a intentarlo mas tarde", Message_Error);
|
|||
|
|
//}).then(function (value) {
|
|||
|
|
// ENDREQUEST();
|
|||
|
|
//});
|
|||
|
|
|
|||
|
|
} catch (e) {
|
|||
|
|
ENDREQUEST();
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado al intentar invocar el método de envío de correo electrónico. Vuelva a intentarlo mas tarde", Message_Error);
|
|||
|
|
}
|
|||
|
|
return _model;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//this.AtualizarDatosMISDeudor = function () {
|
|||
|
|
// var BaseJsonMetadata = {
|
|||
|
|
// NoSolicitud: $("#hiddensol_co_solicitud").val(),
|
|||
|
|
// Incident: $("#hiddenIncident").val(),
|
|||
|
|
// Process: $("#hiddenProcess").val(),
|
|||
|
|
// UserID: $("#hiddenUserID").val(),
|
|||
|
|
// TipoCambio: $("#hiddenTasaTipoCambio").val(),
|
|||
|
|
// TipoCliente: "1",
|
|||
|
|
// }
|
|||
|
|
|
|||
|
|
// var uri = 'api/CreaOperacionAPI/AtualizarDatosMIS/';
|
|||
|
|
// var DTO = JSON.stringify(BaseJsonMetadata);
|
|||
|
|
|
|||
|
|
// $.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');
|
|||
|
|
// }
|
|||
|
|
// else {
|
|||
|
|
// toastr.error("Ha ocurrido un error inesperado al crear el deudor en MIS.");
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
// }).fail(function (jqxhr, textStatus, error) {
|
|||
|
|
// toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo.");
|
|||
|
|
// ENDREQUEST();
|
|||
|
|
// }).then(function (value) {
|
|||
|
|
// ENDREQUEST();
|
|||
|
|
// });
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
//this.AtualizarDatosMISCodeudor = function () {
|
|||
|
|
// var BaseJsonMetadata = {
|
|||
|
|
// NoSolicitud: $("#hiddensol_co_solicitud").val(),
|
|||
|
|
// Incident: $("#hiddenIncident").val(),
|
|||
|
|
// Process: $("#hiddenProcess").val(),
|
|||
|
|
// UserID: $("#hiddenUserID").val(),
|
|||
|
|
// TipoCambio: $("#hiddenTasaTipoCambio").val(),
|
|||
|
|
// TipoCliente: "2",
|
|||
|
|
// }
|
|||
|
|
|
|||
|
|
// var uri = 'api/CreaOperacionAPI/AtualizarDatosMIS/';
|
|||
|
|
// var DTO = JSON.stringify(DataFaseII);
|
|||
|
|
|
|||
|
|
// $.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');
|
|||
|
|
// }
|
|||
|
|
// else {
|
|||
|
|
// toastr.error("Ha ocurrido un error al crear el Codeudor en MIS.");
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
// }).fail(function (jqxhr, textStatus, error) {
|
|||
|
|
// toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo.");
|
|||
|
|
// ENDREQUEST();
|
|||
|
|
// }).then(function (value) {
|
|||
|
|
// ENDREQUEST();
|
|||
|
|
// });
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
//$("#btnCrearActualizarCliente").click(function () {
|
|||
|
|
// AtualizarDatosMISDeudor();
|
|||
|
|
//});
|
|||
|
|
|
|||
|
|
//$("#btnCrearActualizarCodeudor").click(function () {
|
|||
|
|
// AtualizarDatosMISCodeudor();
|
|||
|
|
//});
|
|||
|
|
|
|||
|
|
this.CrearCuenta = function ()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
var JsonCrearCuenta =
|
|||
|
|
{
|
|||
|
|
IdSolicitud: $('#hiddensol_co_solicitud').val(),
|
|||
|
|
envioEstadoCuenta: $("#hiddenTipoEnvioCuenta").val(),
|
|||
|
|
usuario: $('#hiddenUserID').val().split("/")[1],
|
|||
|
|
proceso: $('#hiddenProcess').val(),
|
|||
|
|
tipoCuenta: $("#hiddenTipoCuentaNueva").val(),
|
|||
|
|
noOperacion: $("#txtNoOperacion").val()
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var uri = 'api/CreaOperacionAPI/CrearCuenta/';
|
|||
|
|
var DTO = JSON.stringify(JsonCrearCuenta);
|
|||
|
|
|
|||
|
|
var status = false;
|
|||
|
|
$.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('Se ha creado la cuenta satisfactoriamente', 'Completado');
|
|||
|
|
status = true;
|
|||
|
|
$("#btnCrearCuenta").attr("disabled", true);
|
|||
|
|
}
|
|||
|
|
else if (data.CodigoRespuesta == "ADVERTENCIA") {
|
|||
|
|
toastr.warning(data.DescripcionRespuesta, Message_Warning);
|
|||
|
|
$("#btnCrearCuenta").attr("disabled", false);
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error);
|
|||
|
|
$("#btnCrearCuenta").attr("disabled", false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo.");
|
|||
|
|
ENDREQUEST();
|
|||
|
|
}).then(function (value) {
|
|||
|
|
ENDREQUEST();
|
|||
|
|
});
|
|||
|
|
return status;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
this.SoloLectura = function ()
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//*******************************************
|
|||
|
|
//Siempre solo lectura
|
|||
|
|
//*******************************************
|
|||
|
|
$("#txtTipoOperacion").attr("disabled", true);
|
|||
|
|
|
|||
|
|
|
|||
|
|
//*******************************************
|
|||
|
|
//Si no hay integración con cartera entonces
|
|||
|
|
//remueve el boton de crear cuenta
|
|||
|
|
//*******************************************
|
|||
|
|
if (IsAplicaIntegracionConCartera == false) { $("#btnCrearCuenta").remove(); }
|
|||
|
|
|
|||
|
|
|
|||
|
|
if ($("#hiddenTaskStatus").val() == 1) { return;}
|
|||
|
|
|
|||
|
|
|
|||
|
|
FormReadOnly();
|
|||
|
|
|
|||
|
|
$("button[direccion_api]").remove();
|
|||
|
|
$("#btnGuardar").remove();
|
|||
|
|
$("#btnEnviar").remove();
|
|||
|
|
|
|||
|
|
$("#btnGuardarBitacoraComentario").remove();
|
|||
|
|
|
|||
|
|
IsReadOnlyForm = true;
|
|||
|
|
|
|||
|
|
} catch (e) {
|
|||
|
|
toastr.error("Ha ocurrido un problema al cargar el formulario. Vuela a intentarlo mas tarde", Message_Error);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
this.CargarDataCatalogoAdicional = function (control) {
|
|||
|
|
|
|||
|
|
try {
|
|||
|
|
|
|||
|
|
var controlsCalculo = ["FormaPago"];
|
|||
|
|
|
|||
|
|
if (jQuery.inArray(control, controlsCalculo) !== -1) {
|
|||
|
|
|
|||
|
|
|
|||
|
|
switch (control)
|
|||
|
|
{
|
|||
|
|
case "FormaPago":
|
|||
|
|
ComportamientoFormaPago();
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
} catch (e) {
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado al obtener las configuraciones para la forma de pago. Vuelva a intentarlo mas tarde", Message_Error);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
this.ComportamientoFormaPago = function ()
|
|||
|
|
{
|
|||
|
|
try {
|
|||
|
|
var IdFormaPago = $("#hiddenFormaPago").val();
|
|||
|
|
switch (IdFormaPago) {
|
|||
|
|
case "1": //PAGO EN CAJA
|
|||
|
|
$("#txtCuentaNo").noRequired();
|
|||
|
|
$("#divCuentaNo").attr("disabled", true);
|
|||
|
|
break;
|
|||
|
|
case "2": //DEPOSITO A CUENTA
|
|||
|
|
$("#divCuentaNo").attr("disabled", false);
|
|||
|
|
$("#txtCuentaNo").required();
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
} catch (e) {
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado al configurar la forma de pago. Vuelva a intentarlo mas tarde", Message_Error);
|
|||
|
|
}
|
|||
|
|
}
|