454 lines
No EOL
16 KiB
JavaScript
454 lines
No EOL
16 KiB
JavaScript
|
|
jQuery(document).ready(function () {
|
|
ObtenerAlertasViewBag();
|
|
});
|
|
|
|
|
|
//#region IDENTIFICACION
|
|
function ShowDiv(id) {
|
|
$(format("#ddtipo_{0} option", id)).each(function () {
|
|
var code = $(this).val();
|
|
var div = $(format("#div_{0}_{1}", code, id));
|
|
if (div != null) {
|
|
div.hide();
|
|
}
|
|
});
|
|
var code = $(format("#ddtipo_{0}", id)).val();
|
|
var div = $(format("#div_{0}_{1}", code, id));
|
|
if (div != null) {
|
|
div.show();
|
|
}
|
|
}
|
|
|
|
function format(fmtstr) {
|
|
var args = Array.prototype.slice.call(arguments, 1);
|
|
return fmtstr.replace(/\{(\d+)\}/g, function (match, index) {
|
|
return args[index];
|
|
});
|
|
}
|
|
|
|
function valida_enteros(evento) {
|
|
var key = evento.keyCode;
|
|
if (key >= 48 && key <= 57)
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
|
|
function alfanumerico(evento) {
|
|
var key = evento.keyCode;
|
|
if ((key >= 48 && key <= 57) || (key >= 65 && key <= 90) || (key >= 97 && key <= 122)) {
|
|
evento.keyCode = String.fromCharCode(key).toUpperCase().charCodeAt(0)
|
|
return true;
|
|
}
|
|
else
|
|
return false;
|
|
}
|
|
|
|
function pad(str, max) {
|
|
str = str.toString();
|
|
return str.length < max ? pad("0" + str, max) : str;
|
|
}
|
|
|
|
function identificacion(obj) {
|
|
var val = $(obj).val();
|
|
var max = $(obj).attr("maxlength");
|
|
var valpad = pad(val, max);
|
|
$(obj).val(valpad);
|
|
}
|
|
|
|
function obtener_identificacion(id_control) {
|
|
var ret = "";
|
|
var code = $(format("#ddtipo_{0}", id_control)).val();
|
|
switch (code) {
|
|
case "1":
|
|
var parte1 = $(format("#txt_ced_nac1_{0}", id_control)).val();
|
|
var parte2 = $(format("#txt_ced_nac2_{0}", id_control)).val();
|
|
var parte3 = $(format("#txt_ced_nac3_{0}", id_control)).val();
|
|
if (parseInt(parte1) < 10)
|
|
parte1 = "0" + parte1;
|
|
ret = parte1 + "-" + parte2 + "-" + parte3;
|
|
break;
|
|
case "2":
|
|
var parte1 = $(format("#txt_ced_resperm1_{0}", id_control)).val();
|
|
var parte2 = $(format("#txt_ced_resperm2_{0}", id_control)).val();
|
|
var parte3 = $(format("#txt_ced_resperm3_{0}", id_control)).val();
|
|
ret = parseInt(parte1) + "-" + parte2 + parte3;
|
|
break;
|
|
case "3":
|
|
var parte1 = $(format("#txt_ced_restemp1_{0}", id_control)).val();
|
|
var parte2 = $(format("#txt_ced_restemp2_{0}", id_control)).val();
|
|
var parte3 = $(format("#lbl_ced_restemp3_{0}", id_control)).val();
|
|
var parte4 = $(format("#txt_ced_restemp4_{0}", id_control)).val();
|
|
ret = parte1 + parte2 + parte3 + parte4;
|
|
break;
|
|
case "4":
|
|
var parte1 = $(format("#txt_ced_resapol1_{0}", id_control)).val();
|
|
var parte2 = $(format("#lbl_ced_resapol2_{0}", id_control)).val();
|
|
var parte3 = $(format("#txt_ced_resapol3_{0}", id_control)).val();
|
|
var parte4 = $(format("#txt_ced_resapol4_{0}", id_control)).val();
|
|
ret = parte1 + parte2 + parte3 + parte4;
|
|
break;
|
|
case "5":
|
|
var parte1 = $(format("#txt_ced_re1_{0}", id_control)).val();
|
|
var parte2 = $(format("#lbl_ced_re2_{0}", id_control)).val();
|
|
var parte3 = $(format("#txt_ced_re3_{0}", id_control)).val();
|
|
var parte4 = $(format("#txt_ced_re4_{0}", id_control)).val();
|
|
var parte5 = $(format("#txt_ced_re5_{0}", id_control)).val();
|
|
ret = parte1 + parte2 + parte3 + parte4 + parte5;
|
|
break;
|
|
case "6":
|
|
var parte1 = $(format("#txt_ced_ren1_{0}", id_control)).val();
|
|
var parte2 = $(format("#txt_ced_ren2_{0}", id_control)).val();
|
|
ret = parte1 + parte2;
|
|
break;
|
|
case "7":
|
|
var parte1 = $(format("#lbl_ced_ref1_{0}", id_control)).val();
|
|
var parte2 = $(format("#txt_ced_ref2_{0}", id_control)).val();
|
|
var parte3 = $(format("#txt_ced_ref3_{0}", id_control)).val();
|
|
var parte4 = $(format("#txt_ced_ref4_{0}", id_control)).val();
|
|
ret = parte1 + parte2 + parte3 + parte4;
|
|
break;
|
|
case "8":
|
|
ret = $(format("#txt_ced_pas_fisica_{0}", id_control)).val();
|
|
break;
|
|
case "9":
|
|
var parte1 = $(format("#txt_ced_jurnac1_{0}", id_control)).val();
|
|
var parte2 = $(format("#txt_ced_jurnac2_{0}", id_control)).val();
|
|
var parte3 = $(format("#txt_ced_jurnac3_{0}", id_control)).val();
|
|
ret = parte1 + parte2 + parte3;
|
|
break;
|
|
case "10":
|
|
ret = $(format("#txt_ced_pas_jur_{0}", id_control)).val();
|
|
break;
|
|
case "11":
|
|
ret = $(format("#txt_ced_unica_fisica_{0}", id_control)).val();
|
|
break;
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
function obtener_tipo_identificacion(id_control) {
|
|
return $(format("#ddtipo_{0}", id_control)).val();
|
|
}
|
|
|
|
function impostar_tipo_identificacion(id_control, code) {
|
|
$(format("#ddtipo_{0}", id_control)).val(code);
|
|
}
|
|
|
|
function impostar_identificacion(id_control, identificacion) {
|
|
var code = $(format("#ddtipo_{0}", id_control)).val();
|
|
ShowDiv(id_control);
|
|
switch (code) {
|
|
case "1":
|
|
if (identificacion.length == 12) {
|
|
var parte1 = identificacion.substring(1, 2);
|
|
var parte2 = identificacion.substring(3, 7);
|
|
var parte3 = identificacion.substring(8, 12);
|
|
$(format("#txt_ced_nac1_{0}", id_control)).val(parte1);
|
|
$(format("#txt_ced_nac2_{0}", id_control)).val(parte2);
|
|
$(format("#txt_ced_nac3_{0}", id_control)).val(parte3);
|
|
}
|
|
else
|
|
alert("Se esperaban 12 carácteres para el tipo de indentificación 1");
|
|
break;
|
|
case "2":
|
|
if (identificacion.length == 18) {
|
|
var parte1 = identificacion.substring(0, 3);
|
|
var parte2 = identificacion.substring(4, 11);
|
|
var parte3 = identificacion.substring(11, 18);
|
|
$(format("#txt_ced_resperm1_{0}", id_control)).val(parte1);
|
|
$(format("#txt_ced_resperm2_{0}", id_control)).val(parte2);
|
|
$(format("#txt_ced_resperm3_{0}", id_control)).val(parte3);
|
|
}
|
|
else
|
|
alert("Se esperaban 18 carácteres para el tipo de indentificación 2");
|
|
break;
|
|
case "3":
|
|
if (identificacion.length == 19) {
|
|
var parte1 = identificacion.substring(0, 7);
|
|
var parte2 = identificacion.substring(7, 10);
|
|
var parte3 = identificacion.substring(10, 12);
|
|
var parte4 = identificacion.substring(12, 19);
|
|
$(format("#txt_ced_restemp1_{0}", id_control)).val(parte1);
|
|
$(format("#txt_ced_restemp2_{0}", id_control)).val(parte2);
|
|
$(format("#lbl_ced_restemp3_{0}", id_control)).val(parte3);
|
|
$(format("#txt_ced_restemp4_{0}", id_control)).val(parte4);
|
|
}
|
|
else
|
|
alert("Se esperaban 19 carácteres para el tipo de indentificación 3");
|
|
break;
|
|
case "4":
|
|
if (identificacion.length == 12) {
|
|
var parte1 = identificacion.substring(0, 2);
|
|
var parte2 = identificacion.substring(2, 3);
|
|
var parte3 = identificacion.substring(3, 9);
|
|
var parte4 = identificacion.substring(9, 12);
|
|
$(format("#txt_ced_resapol1_{0}", id_control)).val(parte1);
|
|
$(format("#lbl_ced_resapol2_{0}", id_control)).val(parte2);
|
|
$(format("#txt_ced_resapol3_{0}", id_control)).val(parte3);
|
|
$(format("#txt_ced_resapol4_{0}", id_control)).val(parte4);
|
|
}
|
|
else
|
|
alert("Se esperaban 12 carácteres para el tipo de indentificación 4");
|
|
break;
|
|
case "5":
|
|
if (identificacion.length == 17) {
|
|
var parte1 = identificacion.substring(0, 3);
|
|
var parte2 = identificacion.substring(3, 5);
|
|
var parte3 = identificacion.substring(5, 11);
|
|
var parte4 = identificacion.substring(11, 13);
|
|
var parte5 = identificacion.substring(13, 17);
|
|
$(format("#txt_ced_re1_{0}", id_control)).val(parte1);
|
|
$(format("#lbl_ced_re2_{0}", id_control)).val(parte2);
|
|
$(format("#txt_ced_re3_{0}", id_control)).val(parte3);
|
|
$(format("#txt_ced_re4_{0}", id_control)).val(parte4);
|
|
$(format("#txt_ced_re5_{0}", id_control)).val(parte5);
|
|
}
|
|
else
|
|
alert("Se esperaban 17 carácteres para el tipo de indentificación 5");
|
|
break;
|
|
case "6":
|
|
if (identificacion.length == 5) {
|
|
var parte1 = identificacion.substring(0, 4);
|
|
var parte2 = identificacion.substring(4, 5);
|
|
$(format("#txt_ced_ren1_{0}", id_control)).val(parte1);
|
|
$(format("#txt_ced_ren2_{0}", id_control)).val(parte2);
|
|
}
|
|
else
|
|
alert("Se esperaban 5 carácteres para el tipo de indentificación 6");
|
|
break;
|
|
case "7":
|
|
if (identificacion.length == 15) {
|
|
var parte1 = identificacion.substring(0, 3);
|
|
var parte2 = identificacion.substring(3, 6);
|
|
var parte3 = identificacion.substring(6, 13);
|
|
var parte4 = identificacion.substring(13, 15);
|
|
$(format("#lbl_ced_ref1_{0}", id_control)).val(parte1);
|
|
$(format("#txt_ced_ref2_{0}", id_control)).val(parte2);
|
|
$(format("#txt_ced_ref3_{0}", id_control)).val(parte3);
|
|
$(format("#txt_ced_ref4_{0}", id_control)).val(parte4);
|
|
}
|
|
else
|
|
alert("Se esperaban 15 carácteres para el tipo de indentificación 7");
|
|
break;
|
|
case "8":
|
|
$(format("#txt_ced_pas_fisica_{0}", id_control)).val(identificacion);
|
|
break;
|
|
case "9":
|
|
if (identificacion.length == 10) {
|
|
var parte1 = identificacion.substring(0, 1);
|
|
var parte2 = identificacion.substring(1, 4);
|
|
var parte3 = identificacion.substring(4, 10);
|
|
$(format("#txt_ced_jurnac1_{0}", id_control)).val(parte1);
|
|
$(format("#txt_ced_jurnac2_{0}", id_control)).val(parte2);
|
|
$(format("#txt_ced_jurnac3_{0}", id_control)).val(parte3);
|
|
}
|
|
else
|
|
alert("Se esperaban 10 carácteres para el tipo de indentificación 10");
|
|
break;
|
|
case "10":
|
|
$(format("#txt_ced_pas_jur_{0}", id_control)).val(identificacion);
|
|
break;
|
|
case "11":
|
|
$(format("#txt_ced_unica_fisica_{0}", id_control)).val(identificacion);
|
|
break;
|
|
}
|
|
}
|
|
//#endregion
|
|
|
|
this.ToMoney = function (value) {
|
|
try {
|
|
|
|
value = value == null ? "0" : value;
|
|
|
|
return value.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
|
|
}
|
|
catch (ex) {
|
|
return "0.00";
|
|
}
|
|
};
|
|
|
|
this.StartSelectControlRequest = function (_selectId) {
|
|
$(_selectId).empty();
|
|
listItems = "<option value='-1' ><i class=\"fa fa-spinner fa-spin\"></i>Cargando catalogos, Por favor Espere...</option>";
|
|
$(_selectId).append(listItems);
|
|
};
|
|
|
|
this.CleanSelectControl = function (_selectId) {
|
|
$(_selectId).empty();
|
|
listItems = "<option value='' ></option>";
|
|
$(_selectId).append(listItems);
|
|
$(_selectId).val("");
|
|
};
|
|
|
|
this.AddSelectOption = function (_selectId, _optionId, _text) {
|
|
$(_selectId)
|
|
.append($("<option></option>")
|
|
.attr("value", _optionId)
|
|
.text(_text));
|
|
};
|
|
|
|
this.ConsultaTasaTipoCambio = function()
|
|
{
|
|
try {
|
|
|
|
var _usuario = $("#hiddenUserID").val().split("/")[1];
|
|
var _proceso = $("#hiddenProcess").val();
|
|
|
|
|
|
var _model = { Usuario: _usuario, Procesos: _proceso };
|
|
|
|
var uri = 'api/GlobalAPI/ConsultarTasaCambio/';
|
|
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")
|
|
{
|
|
$("#hiddenTasaTipoCambio").val(data.TipoCambioVenta);
|
|
}
|
|
else {
|
|
toastr.error("Ha ocurrido un error inesperado al consultar la tasa de tipo de cambio.<br>" + data.DescripcionRespuesta);
|
|
}
|
|
}
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo al consultar la tasa de tipo de cambio.");
|
|
ENDREQUEST();
|
|
}).then(function (value) {
|
|
ENDREQUEST();
|
|
});
|
|
} catch (e) {
|
|
toastr.error("Ha ocurrido un error inesperado a intentar invocar el metodo de consulta de tasa de tipo de cambio. Vuelva a intentarlo mas tarde", Message_Error);
|
|
ENDREQUEST();
|
|
}
|
|
|
|
|
|
}
|
|
|
|
this.ObtenerAlertasViewBag = function()
|
|
{
|
|
try {
|
|
var message = $("#hiddenErrorTasaTipoCambio").val();
|
|
var arrError = message.split('|');
|
|
|
|
$.each(arrError, function (key, item) {
|
|
if (item.trim() != "")
|
|
{
|
|
toastr.warning(item, Message_Warning);
|
|
}
|
|
});
|
|
} catch (e) {
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
this.ValidarCuadreFormasDesembolso = function () {
|
|
var status = false;
|
|
//return true;
|
|
try {
|
|
|
|
var JsonValidar =
|
|
{
|
|
IdSolicitud: $('#hiddensol_co_solicitud').val()
|
|
}
|
|
|
|
var uri = 'api/CreaOperacionAPI/ValidarCuadreFormasDesembolso/';
|
|
var DTO = JSON.stringify(JsonValidar);
|
|
|
|
$.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") {
|
|
status = true;
|
|
}
|
|
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();
|
|
});
|
|
|
|
} catch (e) {
|
|
toastr.error("Ha ocurrido un error inesperado. Constacte al Administrador del Sistema.", Message_Error);
|
|
ENDREQUEST();
|
|
}
|
|
|
|
return status;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.ObtenerFechaProcesoCobis = function () {
|
|
|
|
var returnFechaProceso = "";
|
|
|
|
try {
|
|
|
|
var JsonFechaProcesoCobis =
|
|
{
|
|
UserId: $("#hiddenUserID").val().split("/")[1]
|
|
}
|
|
|
|
var uri = 'api/GlobalAPI/ObtenerFechaProcesoCobis/';
|
|
var DTO = JSON.stringify(JsonFechaProcesoCobis);
|
|
|
|
$.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") {
|
|
returnFechaProceso = data.FechaProceso;
|
|
}
|
|
else if (data.CodigoRespuesta == "ADVERTENCIA") {
|
|
toastr.warning(data.DescripcionRespuesta, Message_Warning);
|
|
}
|
|
else {
|
|
toastr.error("Ha ocurrido un error inesperado al consultar la fecha de proceso de cobis. 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();
|
|
});
|
|
|
|
} catch (e) {
|
|
toastr.error("Ha ocurrido un error inesperado al tratar de consumir el metodo de consulta de fecha de proceso de cobis. Constacte al Administrador del Sistema.", Message_Error);
|
|
ENDREQUEST();
|
|
}
|
|
|
|
return returnFechaProceso;
|
|
|
|
} |