1367 lines
41 KiB
JavaScript
1367 lines
41 KiB
JavaScript
|
|
//#region Variables Globales
|
|||
|
|
var server = "http://" + location.host + "/ULA.Davivienda.ModuloMantenimiento/";
|
|||
|
|
var StarterTemplateVisible = true;
|
|||
|
|
var ControlsSettings = {};
|
|||
|
|
var SelectedCatalog = '';
|
|||
|
|
var DireccionAPICatalogo = '';
|
|||
|
|
var DataModel = false;
|
|||
|
|
var Frmnombre = '';
|
|||
|
|
var DateFormat = '';
|
|||
|
|
var MinDate = '';
|
|||
|
|
var MaxDate = '';
|
|||
|
|
var RangoFecha = false;
|
|||
|
|
var Finde = false;
|
|||
|
|
var params = new Array();
|
|||
|
|
|
|||
|
|
var JsonCotizacionResponse = {};
|
|||
|
|
|
|||
|
|
var isMobile = {
|
|||
|
|
Android: function () {
|
|||
|
|
return navigator.userAgent.match(/Android/i);
|
|||
|
|
},
|
|||
|
|
BlackBerry: function () {
|
|||
|
|
return navigator.userAgent.match(/BlackBerry/i);
|
|||
|
|
},
|
|||
|
|
iOS: function () {
|
|||
|
|
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
|
|||
|
|
},
|
|||
|
|
Opera: function () {
|
|||
|
|
return navigator.userAgent.match(/Opera Mini/i);
|
|||
|
|
},
|
|||
|
|
Windows: function () {
|
|||
|
|
return navigator.userAgent.match(/IEMobile/i);
|
|||
|
|
},
|
|||
|
|
any: function () {
|
|||
|
|
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//#endregion
|
|||
|
|
|
|||
|
|
//#region MOMENT CONFIGURATION (DATE AND TIME CONFIGURATION)
|
|||
|
|
|
|||
|
|
moment.lang('es-PA', {
|
|||
|
|
months: [
|
|||
|
|
"Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio",
|
|||
|
|
"Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"
|
|||
|
|
]
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
moment.lang('es-PA');
|
|||
|
|
|
|||
|
|
//#endregion
|
|||
|
|
|
|||
|
|
//#region ULTIMUS DATEPIKER CONFIGURATION
|
|||
|
|
|
|||
|
|
jQuery(function ($) {
|
|||
|
|
$.datepicker.regional['es'] = {
|
|||
|
|
closeText: 'Cerrar',
|
|||
|
|
prevText: '<Ant',
|
|||
|
|
nextText: 'Sig>',
|
|||
|
|
currentText: 'Hoy',
|
|||
|
|
monthNames: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio',
|
|||
|
|
'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
|
|||
|
|
monthNamesShort: ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun',
|
|||
|
|
'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'],
|
|||
|
|
dayNames: ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'],
|
|||
|
|
dayNamesShort: ['Dom', 'Lun', 'Mar', 'Mié', 'Juv', 'Vie', 'Sáb'],
|
|||
|
|
dayNamesMin: ['Do', 'Lu', 'Ma', 'Mi', 'Ju', 'Vi', 'Sá'],
|
|||
|
|
weekHeader: 'Sm',
|
|||
|
|
dateFormat: 'dd-MM-yy',
|
|||
|
|
firstDay: 1,
|
|||
|
|
isRTL: false,
|
|||
|
|
showMonthAfterYear: false,
|
|||
|
|
yearSuffix: '',
|
|||
|
|
yearRange: '1945:' + (new Date).getFullYear(),
|
|||
|
|
changeMonth: true,
|
|||
|
|
changeYear: true
|
|||
|
|
};
|
|||
|
|
$.datepicker.setDefaults($.datepicker.regional['es']);
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//#endregion
|
|||
|
|
|
|||
|
|
//#region GENERIC MESSAGE
|
|||
|
|
|
|||
|
|
var Message_Success = "PROCESO COMPLETADO";
|
|||
|
|
var Message_Warning = "ADVERTENCIA DEL SISTEMA";
|
|||
|
|
var Message_Info = "INFORMACIÓN DEL SISTEMA";
|
|||
|
|
var Message_Error = "ERROR INESPERADO";
|
|||
|
|
|
|||
|
|
var MessageFull_Error = "Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde";
|
|||
|
|
|
|||
|
|
//#endregion
|
|||
|
|
|
|||
|
|
//#region JQUERY.VALIDATE CONFIGURATION
|
|||
|
|
|
|||
|
|
jQuery.extend(jQuery.validator.messages, {
|
|||
|
|
required: "CAMPO REQUERIDO",
|
|||
|
|
email: "CORREO INCORRECTO: Por favor introducir un correo electrónico valido. Asegúrese de no tener espacios en blanco ni caracteres especiales",
|
|||
|
|
number: "NUMERO INCORRECTO: Por favor introducir un numero valido. Asegúrese de no tener espacios en blanco ni caracteres especiales",
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
jQuery.validator.addMethod("lettersonly", function (value, element) {
|
|||
|
|
return this.optional(element) || /^[a-zñ\s]+$/i.test(value);
|
|||
|
|
}, "SOLO LETRAS");
|
|||
|
|
|
|||
|
|
jQuery.validator.addMethod("currencyRequired", function (value, element) {
|
|||
|
|
|
|||
|
|
return ($("#" + element.id).autoNumeric('get') > 0);
|
|||
|
|
|
|||
|
|
}, "El MONTO DEBE SER MAYOR A CERO");
|
|||
|
|
|
|||
|
|
//#endregion
|
|||
|
|
|
|||
|
|
//#region Genericos
|
|||
|
|
|
|||
|
|
$("#btnDesarrollo").click(function () {
|
|||
|
|
|
|||
|
|
LoadMessage("REDIRECCIONANDO A LOCALHOST...");
|
|||
|
|
|
|||
|
|
var urlLocalhost = location.href;
|
|||
|
|
|
|||
|
|
urlLocalhost = urlLocalhost.replace("pasapr053", "LOCALHOST");
|
|||
|
|
|
|||
|
|
location.href = urlLocalhost;
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$("#btnHeaderToggle").click(function () {
|
|||
|
|
|
|||
|
|
|
|||
|
|
HeaderToggle();
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
this.HeaderToggle = function () {
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (isMobile.any()) {
|
|||
|
|
|
|||
|
|
$("#btnHeaderToggle").find('i').toggleClass('fa-chevron-circle-down fa-chevron-circle-up');
|
|||
|
|
|
|||
|
|
if (StarterTemplateVisible) {
|
|||
|
|
|
|||
|
|
$("#divStarterTemplate").css({ "padding": "20px 0 0 0" });
|
|||
|
|
|
|||
|
|
|
|||
|
|
$('#divHeader').hide();
|
|||
|
|
$('#divMenuBar').hide();
|
|||
|
|
|
|||
|
|
StarterTemplateVisible = false;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
|
|||
|
|
$("#divStarterTemplate").css({ "padding": "120px 0 0 0" });
|
|||
|
|
|
|||
|
|
$('#divHeader').show();
|
|||
|
|
$('#divMenuBar').show();
|
|||
|
|
|
|||
|
|
StarterTemplateVisible = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
|
|||
|
|
$('#divHeader').slideToggle("fast");
|
|||
|
|
$('#divMenuBar').slideToggle("fast");
|
|||
|
|
|
|||
|
|
$("#btnHeaderToggle").find('i').toggleClass('fa-chevron-circle-down fa-chevron-circle-up');
|
|||
|
|
|
|||
|
|
if (StarterTemplateVisible) {
|
|||
|
|
|
|||
|
|
$("#divStarterTemplate").animate({ paddingTop: "-=100px" });
|
|||
|
|
|
|||
|
|
StarterTemplateVisible = false;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
|
|||
|
|
$("#divStarterTemplate").animate({ paddingTop: "+=100px" });
|
|||
|
|
|
|||
|
|
StarterTemplateVisible = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$(document).ajaxStart(function () {
|
|||
|
|
|
|||
|
|
LoadMessage();
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
jQuery(document).ready(function () {
|
|||
|
|
|
|||
|
|
if (isMobile.any()) {
|
|||
|
|
|
|||
|
|
HeaderToggle();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
$(function () {
|
|||
|
|
FastClick.attach(document.body);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (navigator.appName.indexOf("Internet Explorer") == -1) { //yeah, he's using IE
|
|||
|
|
|
|||
|
|
if (window.matchMedia("(orientation: portrait)").matches) {
|
|||
|
|
$('#modalMensajeMobile').modal('show');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (window.matchMedia("(orientation: landscape)").matches) {
|
|||
|
|
// you're in LANDSCAPE mode
|
|||
|
|
$('#modalMensajeMobile').modal('hide');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
toastr.options = {
|
|||
|
|
"closeButton": true,
|
|||
|
|
"debug": false,
|
|||
|
|
"positionClass": "toast-top-right",
|
|||
|
|
"onclick": null,
|
|||
|
|
"showDuration": "300",
|
|||
|
|
"hideDuration": "1000",
|
|||
|
|
"timeOut": "10000",
|
|||
|
|
"extendedTimeOut": "1000",
|
|||
|
|
"showEasing": "swing",
|
|||
|
|
"hideEasing": "swing",
|
|||
|
|
"showMethod": "slideDown",
|
|||
|
|
"hideMethod": "slideUp"
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//ULT = new Ultimus.UI();
|
|||
|
|
//ULT.DataTable_Spanish("#tableBitacora", 0, "asc", false, false, false);
|
|||
|
|
//tableBitacora = $('#tableBitacora').DataTable();
|
|||
|
|
|
|||
|
|
$("form").submit(function () {
|
|||
|
|
if (!$(this).valid()) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
|
|||
|
|
LoadMessage();
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$("[data-toggle=tooltip]").tooltip({ placement: 'right' });
|
|||
|
|
|
|||
|
|
$('[data-toggle="popover"]').popover({ trigger: 'hover', 'placement': 'top' });
|
|||
|
|
|
|||
|
|
jQuery('[data-confirm]').click(function (e) {
|
|||
|
|
if (!confirm(jQuery(this).attr("data-confirm"))) {
|
|||
|
|
e.preventDefault();
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
|
|||
|
|
LoadMessage();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
jQuery('[data-toggle="tab"]').click(function (e) {
|
|||
|
|
|
|||
|
|
jQuery('[class="nav-active"]').attr("class", "");
|
|||
|
|
jQuery(this).attr("class", "nav-active");
|
|||
|
|
|
|||
|
|
window.scrollTo(0, 0);
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
this.LoadToastContainer = function (form) {
|
|||
|
|
|
|||
|
|
if ($("#toast-container").length > 0) {
|
|||
|
|
var $div = $('<div />').appendTo('body');
|
|||
|
|
$div.attr('id', 'toast-container');
|
|||
|
|
$div.attr('class', 'toast-top-right');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
this.ToMoney = function (value) {
|
|||
|
|
|
|||
|
|
return value.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
this.LoadMessage = function (Message) {
|
|||
|
|
|
|||
|
|
if (Message == null) {
|
|||
|
|
|
|||
|
|
Message = "Cargando Datos, Espere por favor!";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($("#toast-container").length > 0) {
|
|||
|
|
var $div = $('<div />').appendTo('body');
|
|||
|
|
$div.attr('id', 'toast-container');
|
|||
|
|
$div.attr('class', 'toast-top-right');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$("#toast-container").empty();
|
|||
|
|
|
|||
|
|
var stringHtml = "";
|
|||
|
|
|
|||
|
|
stringHtml += "<div id=\"loadingGif\" class=\"toast toast-default\" style=\"font-size:14px;\">";
|
|||
|
|
stringHtml += "<table>";
|
|||
|
|
stringHtml += "<tr>";
|
|||
|
|
stringHtml += "<td><img src=\"../../../../ULA.Davivienda.PrestamoAutos/Images/ajax-loader.gif\" alt=\"loading\" height=\"50\" width=\"50\"></td>";
|
|||
|
|
//stringHtml += "<td><i class=\"fa fa-spinner fa-spin fa-4x\"></i></td>";
|
|||
|
|
stringHtml += "<td> </td>";
|
|||
|
|
stringHtml += "<td>";
|
|||
|
|
stringHtml += "<div class=\"toast-title\">" + Message + "</div>";
|
|||
|
|
stringHtml += "</td>";
|
|||
|
|
stringHtml += "</tr>";
|
|||
|
|
stringHtml += "</table>";
|
|||
|
|
stringHtml += "</div>";
|
|||
|
|
|
|||
|
|
$("#toast-container").append(stringHtml);
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
this.ENDREQUEST = function (text) {
|
|||
|
|
$("#loadingGif").hide();
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
this.IsNullOrEmpty = function (value) {
|
|||
|
|
|
|||
|
|
if (value == null || $.trim(value)) return true;
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
this.lockViewContent = function () {
|
|||
|
|
var status = $("#hiddenTaskStatus").val();
|
|||
|
|
|
|||
|
|
if (status != 1) {
|
|||
|
|
|
|||
|
|
FormReadOnly();
|
|||
|
|
$('button').attr('disabled', true);
|
|||
|
|
$('button').each(
|
|||
|
|
function () {
|
|||
|
|
if ($(this).attr('id') != null) {
|
|||
|
|
if ($(this).attr('id').toLowerCase().indexOf("imprim") != -1) {
|
|||
|
|
$(this).attr('disabled', false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($(this).attr('id').toLowerCase().indexOf("envia") != -1 || $(this).attr('id').toLowerCase().indexOf("send") != -1) {
|
|||
|
|
$(this).hide();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.FormDisable = function () {
|
|||
|
|
|
|||
|
|
//$('input,select').attr('disabled', true);
|
|||
|
|
|
|||
|
|
$('input,select').removeAttr('disabled');
|
|||
|
|
|
|||
|
|
$('input,select').addClass("is-disabled");
|
|||
|
|
|
|||
|
|
$('input,select').focus(function () {
|
|||
|
|
this.blur();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('select').dblclick(function (e) {
|
|||
|
|
alert('No puede seleccionar esto.');
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$('input').datepicker("destroy");
|
|||
|
|
|
|||
|
|
$('input:radio').attr('disabled', true);
|
|||
|
|
$('input:checkbox').attr('disabled', true);
|
|||
|
|
|
|||
|
|
$('input,select').removeAttr('required', true);
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// Permitir Letras y numeros
|
|||
|
|
this.LettersNumbersOnly = function (evt) {
|
|||
|
|
evt = (evt) ? evt : event;
|
|||
|
|
|
|||
|
|
var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode :
|
|||
|
|
((evt.which) ? evt.which : 0));
|
|||
|
|
|
|||
|
|
if ((charCode >= 48 && charCode <= 57) ||
|
|||
|
|
(charCode >= 65 && charCode <= 90) ||
|
|||
|
|
(charCode >= 97 && charCode <= 122) ||
|
|||
|
|
(charCode >= 192 && charCode <= 255) ||
|
|||
|
|
charCode == 8 || charCode == 32 || charCode == 180 || // 8 = backspace, 32 = space, 180 = apostrofe
|
|||
|
|
charCode == 46 || charCode == 44 || charCode == 45 || charCode == 59) { // 188 = dot, 189 = colon, 190 = guion ,semi colon
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// Permitir Letras, numeros y punto
|
|||
|
|
this.LettersNumbersAndGuionOnly = function (evt) {
|
|||
|
|
evt = (evt) ? evt : event;
|
|||
|
|
|
|||
|
|
var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode :
|
|||
|
|
((evt.which) ? evt.which : 0));
|
|||
|
|
|
|||
|
|
if ((charCode >= 48 && charCode <= 57) ||
|
|||
|
|
(charCode >= 65 && charCode <= 90) ||
|
|||
|
|
(charCode >= 97 && charCode <= 122) ||
|
|||
|
|
charCode == 8 || charCode == 32 || charCode == 45) // 8 = backspace, 32 = space,45 = guion
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// Permitir Letras, numeros y punto
|
|||
|
|
this.LettersNumbersAndDotOnly = function (evt) {
|
|||
|
|
evt = (evt) ? evt : event;
|
|||
|
|
|
|||
|
|
var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode :
|
|||
|
|
((evt.which) ? evt.which : 0));
|
|||
|
|
|
|||
|
|
if ((charCode >= 48 && charCode <= 57) ||
|
|||
|
|
(charCode >= 65 && charCode <= 90) ||
|
|||
|
|
(charCode >= 97 && charCode <= 122) ||
|
|||
|
|
charCode == 8 || charCode == 32 || charCode == 46) // 8 = backspace, 32 = space, 44 = dot
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
};
|
|||
|
|
// Permitir solo Letras
|
|||
|
|
this.LettersOnly = function (evt) {
|
|||
|
|
evt = (evt) ? evt : event;
|
|||
|
|
var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode :
|
|||
|
|
((evt.which) ? evt.which : 0));
|
|||
|
|
if (charCode > 32 && (charCode < 65 || charCode > 90) &&
|
|||
|
|
(charCode < 97 || charCode > 122)) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
return true;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// formato numero telefonico residencial
|
|||
|
|
this.VerifyPhoneNumber = function (id) {
|
|||
|
|
|
|||
|
|
if ($("#" + id).val() != "") {
|
|||
|
|
|
|||
|
|
var formatoCorrectoNumeroTelefono = ($("#" + id).val().match(/\b\d{3}[-]\d{4}\b/)) ? true : false;
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (formatoCorrectoNumeroTelefono == false) {
|
|||
|
|
var numeroTelefono = $("#" + id).val();
|
|||
|
|
|
|||
|
|
if (numeroTelefono.indexOf("-") != -1) {
|
|||
|
|
numeroTelefono = numeroTelefono.replace("-", "");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($("#hiddenResidente").val() == "false") {//
|
|||
|
|
if (numeroTelefono.length <= 11) {
|
|||
|
|
|
|||
|
|
//reformat phone number
|
|||
|
|
//$("#" + id).val(numeroTelefono.replace(/(\d{3})(\d{4})/, "$1-$2"));
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
toastr.warning("Verifique haya introducido hasta 11 números", "Ingresar Datos Requeridos");
|
|||
|
|
$("#" + id).val("");
|
|||
|
|
$("#" + id).focus();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
if (numeroTelefono.length == 8) {
|
|||
|
|
var validanumero = $("#" + id).val().split("");
|
|||
|
|
|
|||
|
|
if (validanumero[0] == 0 || $("#" + id).val() == "1111111") {
|
|||
|
|
|
|||
|
|
toastr.warning("Ingresar un número valido", "Ingresar Datos Requeridos");
|
|||
|
|
$("#" + id).val("");
|
|||
|
|
$("#" + id).focus();
|
|||
|
|
|
|||
|
|
} else {
|
|||
|
|
//reformat phone number
|
|||
|
|
//$("#" + id).val(numeroTelefono.replace(/(\d{3})(\d{4})/, "$1-$2"));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
toastr.warning("Verifique haya introducido 8 números", "Ingresar Datos Requeridos");
|
|||
|
|
$("#" + id).val("");
|
|||
|
|
$("#" + id).focus();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// formato numero de celular
|
|||
|
|
this.VerifyMobileNumber = function (id) {
|
|||
|
|
|
|||
|
|
if ($("#" + id).val() != "") {
|
|||
|
|
|
|||
|
|
var formatoCorrectoNumeroCelular = ($("#" + id).val().match(/\b\d{4}[-]\d{4}\b/)) ? true : false;
|
|||
|
|
//alert(formatoCorrecto);
|
|||
|
|
|
|||
|
|
if (formatoCorrectoNumeroCelular == false) {
|
|||
|
|
var numeroCelular = $("#" + id).val();
|
|||
|
|
|
|||
|
|
if (numeroCelular.indexOf("-") != -1) {
|
|||
|
|
numeroCelular = numeroCelular.replace("-", "");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($("#hiddenResidente").val() == "false") {//
|
|||
|
|
if (numeroCelular.length <= 11) {
|
|||
|
|
|
|||
|
|
//reformat phone number
|
|||
|
|
//$("#" + id).val(numeroCelular.replace(/(\d{4})(\d{4})/, "$1-$2"));
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
|
|||
|
|
toastr.warning("Verifique haya introducido hasta 11 números", "Ingresar Datos Requeridos");
|
|||
|
|
$("#" + id).val("");
|
|||
|
|
$("#" + id).focus();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
if (numeroCelular.length == 8) {
|
|||
|
|
//var validanumero = $("#" + id).val().split("");
|
|||
|
|
//if (validanumero[0] != 6) {
|
|||
|
|
// toastr.warning("El número debe iniciar con 6", "Ingresar Datos Requeridos");
|
|||
|
|
// $("#" + id).val("");
|
|||
|
|
// $("#" + id).focus();
|
|||
|
|
//}
|
|||
|
|
//} else {
|
|||
|
|
// $("#" + id).val(numeroCelular.replace(/(\d{4})(\d{4})/, "$1-$2"));
|
|||
|
|
//}
|
|||
|
|
//reformat phone number
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
|
|||
|
|
toastr.warning("Verifique haya introducido 8 números", "Ingresar Datos Requeridos");
|
|||
|
|
$("#" + id).val("");
|
|||
|
|
$("#" + id).focus();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Solo permite numeros -- Segun Caracteres
|
|||
|
|
this.OnlyNumbers = function (event) {
|
|||
|
|
var charCode = (event.which) ? event.which : event.keyCode
|
|||
|
|
|
|||
|
|
if (charCode > 31 && (charCode < 48 || charCode > 57))
|
|||
|
|
return false;
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.OnlyNumerosyGuiones = function (event) {
|
|||
|
|
var charCode = (event.which) ? event.which : event.keyCode
|
|||
|
|
if (charCode == 45)
|
|||
|
|
return true;
|
|||
|
|
if (charCode > 31 && (charCode < 48 || charCode > 57))
|
|||
|
|
return false;
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Solo permite numeros -- Segun Caracteres
|
|||
|
|
this.OnlyNumbersAndDot = function (event, id) {
|
|||
|
|
var charCode = (event.which) ? event.which : event.keyCode
|
|||
|
|
|
|||
|
|
if (charCode == 46) {
|
|||
|
|
|
|||
|
|
var valor = $("#" + id).val();
|
|||
|
|
|
|||
|
|
var permitirPunto = (valor.indexOf('.') != -1) ? false : true;
|
|||
|
|
|
|||
|
|
return permitirPunto;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (charCode > 31 && (charCode < 48 || charCode > 57))
|
|||
|
|
return false;
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.replaceAll = function (find, replace, str) {
|
|||
|
|
return str.replace(new RegExp(find.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), 'g'), replace);
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
this.FormReadOnly = function () {
|
|||
|
|
$('input,select').attr('disabled', true);
|
|||
|
|
$('input,select').removeAttr('required', true);
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
this.Today = function () {
|
|||
|
|
|
|||
|
|
return moment(new Date());
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
|
|||
|
|
//#endregion
|
|||
|
|
|
|||
|
|
//#region ULTIMUS PROPERTIES AND EXTENTION
|
|||
|
|
|
|||
|
|
//#region General Control extentions
|
|||
|
|
|
|||
|
|
$.fn.disable = function () {
|
|||
|
|
|
|||
|
|
this.attr('disabled', true);
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
$.fn.enable = function () {
|
|||
|
|
|
|||
|
|
this.attr('disabled', false);
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
$.fn.required = function () {
|
|||
|
|
|
|||
|
|
this.attr('required', true);
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
$.fn.noRequired = function () {
|
|||
|
|
|
|||
|
|
this.attr('required', false);
|
|||
|
|
this.removeClass('inputWarning');
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
$.fn.EnableValidationToolTip = function () {
|
|||
|
|
|
|||
|
|
this.validate({
|
|||
|
|
|
|||
|
|
ignore: "not:hidden",
|
|||
|
|
|
|||
|
|
showErrors: function (errorMap, errorList) {
|
|||
|
|
|
|||
|
|
|
|||
|
|
$.each(this.validElements(), function (index, element) {
|
|||
|
|
var $element = $(element);
|
|||
|
|
|
|||
|
|
if ($element.prop("type") == "select-one") {
|
|||
|
|
if ($element.attr('required')) {
|
|||
|
|
$element.removeClass("selectWarning").addClass("inputSuccess");
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
$element.removeClass("selectWarning");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
|
|||
|
|
if ($element.attr('required')) {
|
|||
|
|
$element.removeClass("inputWarning").addClass("inputSuccess");
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
$element.removeClass("inputWarning");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
$element.data("title", "").removeClass("error").tooltip("destroy");
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$.each(errorList, function (index, error) {
|
|||
|
|
var $element = $(error.element);
|
|||
|
|
|
|||
|
|
if ($element.prop("type") == "select-one") {
|
|||
|
|
$element.removeClass("inputSuccess").addClass("selectWarning");
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
$element.removeClass("inputSuccess").addClass("inputWarning");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//if ($element.data("role") != undefined) {
|
|||
|
|
// $("#" + $element.data("role")).tooltip("destroy").data("title", error.message).addClass("error").tooltip({ placement: 'right', trigger: 'hover', container: 'body' });
|
|||
|
|
//} else {
|
|||
|
|
$element.tooltip("destroy").data("title", error.message).addClass("error").tooltip({ placement: 'right', trigger: 'hover', container: 'body' });
|
|||
|
|
//}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
$.fn.TableInit = function (columnOrder, order, bPaginate, bFilter, bInfo, columnDefinition, data) {
|
|||
|
|
this.dataTable({
|
|||
|
|
"language": {
|
|||
|
|
"sProcessing": "Procesando...",
|
|||
|
|
"sLengthMenu": "Mostrar _MENU_ registros",
|
|||
|
|
"sZeroRecords": "No se encontraron resultados",
|
|||
|
|
"sEmptyTable": "Ningún dato disponible",
|
|||
|
|
"sInfo": "Mostrando registros del _START_ al _END_ de un total de _TOTAL_ registros",
|
|||
|
|
"sInfoEmpty": "Mostrando registros del 0 al 0 de un total de 0 registros",
|
|||
|
|
"sInfoFiltered": "(filtrado de un total de _MAX_ registros)",
|
|||
|
|
"sInfoPostFix": "",
|
|||
|
|
"sSearch": "Buscar:",
|
|||
|
|
"sUrl": "",
|
|||
|
|
"sInfoThousands": ",",
|
|||
|
|
"sLoadingRecords": "Cargando...",
|
|||
|
|
"oPaginate": {
|
|||
|
|
"sFirst": "Primero",
|
|||
|
|
"sLast": "Último",
|
|||
|
|
"sNext": "Siguiente",
|
|||
|
|
"sPrevious": "Anterior"
|
|||
|
|
},
|
|||
|
|
"oAria": {
|
|||
|
|
"sSortAscending": ": Activar para ordenar la columna de manera ascendente",
|
|||
|
|
"sSortDescending": ": Activar para ordenar la columna de manera descendente"
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
"order": [[columnOrder, order]],
|
|||
|
|
"destroy": true,
|
|||
|
|
"bPaginate": bPaginate,
|
|||
|
|
"bFilter": bFilter,
|
|||
|
|
"bInfo": bInfo,
|
|||
|
|
"data": data,
|
|||
|
|
"columns": columnDefinition,
|
|||
|
|
"lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
|
|||
|
|
});
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
$.fn.validateElement = function (controlId) {
|
|||
|
|
|
|||
|
|
var validator = this.validate();
|
|||
|
|
validator.element(controlId);
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
$.fn.reset = function () {
|
|||
|
|
$(this).each(function () { this.reset(); });
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$.fn.setByText = function (value) {
|
|||
|
|
|
|||
|
|
if (value != '')
|
|||
|
|
$(this.selector + " option:contains(" + value + ")").attr('selected', 'selected');
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//#endregion
|
|||
|
|
|
|||
|
|
//#region Date time extentions
|
|||
|
|
|
|||
|
|
$.fn.dateFormatNoTime = function (value) {
|
|||
|
|
|
|||
|
|
if (value != null && value != '' && value != '0001-01-01T00:00:00') {
|
|||
|
|
|
|||
|
|
try { value = value.substring(0, 19); }
|
|||
|
|
catch (ex) { }
|
|||
|
|
|
|||
|
|
var fecha = new Date(value);
|
|||
|
|
this.val(moment(fecha.toUTCString()).utc().format("DD-MMMM-YYYY"));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
return '';
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
$.fn.CalculateAge = function (controlYear, controlMonth) {
|
|||
|
|
|
|||
|
|
var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|||
|
|
|
|||
|
|
var mayoriaEdad = 18;
|
|||
|
|
|
|||
|
|
var fechaActual = new Date();
|
|||
|
|
var mesActual = fechaActual.getUTCMonth() + 1;
|
|||
|
|
var diaActual = fechaActual.getDate();
|
|||
|
|
var añoActual = fechaActual.getUTCFullYear();
|
|||
|
|
|
|||
|
|
var momentfecha = moment(this.val(), "DD-MMMM-YYYY");
|
|||
|
|
var DayOfBirthString = monthNames[momentfecha._a[1]] + " " + momentfecha._a[2] + ", " + momentfecha._a[0];
|
|||
|
|
|
|||
|
|
var fecha = new Date(DayOfBirthString);
|
|||
|
|
var mesFechaNacimiento = fecha.getUTCMonth() + 1;
|
|||
|
|
var diaFechaNacimiento = fecha.getDate();
|
|||
|
|
var añoFechaNacimiento = fecha.getUTCFullYear();
|
|||
|
|
|
|||
|
|
var edad = añoActual - añoFechaNacimiento;
|
|||
|
|
|
|||
|
|
if (edad >= mayoriaEdad) {
|
|||
|
|
|
|||
|
|
var mesesCumplidos = 0;
|
|||
|
|
var mesVerificar;
|
|||
|
|
|
|||
|
|
var verificarAñoSiguiente = (mesFechaNacimiento >= mesActual) ? true : false;
|
|||
|
|
|
|||
|
|
if (verificarAñoSiguiente) {
|
|||
|
|
mesActual = 12; // refleja un año entero a verificar
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
mesVerificar = mesFechaNacimiento + 1;
|
|||
|
|
|
|||
|
|
while (mesVerificar <= mesActual) {
|
|||
|
|
|
|||
|
|
if (mesVerificar == mesActual) {
|
|||
|
|
if ((diaActual >= diaFechaNacimiento) ? true : false) {
|
|||
|
|
|
|||
|
|
if (verificarAñoSiguiente) {
|
|||
|
|
mesActual = fechaActual.getUTCMonth() + 1;
|
|||
|
|
mesVerificar = 1;
|
|||
|
|
verificarAñoSiguiente = false;
|
|||
|
|
mesesCumplidos++;
|
|||
|
|
if (mesesCumplidos != 12) // Año cumplido
|
|||
|
|
edad--;
|
|||
|
|
else if (mesesCumplidos == 12)
|
|||
|
|
mesesCumplidos = 0;
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
mesVerificar++;
|
|||
|
|
mesesCumplidos++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
|
|||
|
|
if (verificarAñoSiguiente) {
|
|||
|
|
mesActual = fechaActual.getUTCMonth() + 1;
|
|||
|
|
mesVerificar = 1;
|
|||
|
|
|
|||
|
|
verificarAñoSiguiente = false;
|
|||
|
|
mesesCumplidos++;
|
|||
|
|
if (mesesCumplidos != 12) // Año cumplido
|
|||
|
|
edad--;
|
|||
|
|
else if (mesesCumplidos == 12)
|
|||
|
|
mesesCumplidos = 0;
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
mesVerificar++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
mesesCumplidos++;
|
|||
|
|
mesVerificar++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$(controlYear).val(edad);
|
|||
|
|
$(controlMonth).val(mesesCumplidos);
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
$(controlYear).val('');
|
|||
|
|
$(controlMonth).val('');
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$.fn.CalculateLaboralAgeActual = function (controlYear, controlMonth) {
|
|||
|
|
|
|||
|
|
var txtFechaInicioEmpleo = moment(this.val(), "DD-MMMM-YYYY");
|
|||
|
|
|
|||
|
|
var years = moment().diff(txtFechaInicioEmpleo, 'years');
|
|||
|
|
var months = moment().diff(txtFechaInicioEmpleo, 'months');
|
|||
|
|
|
|||
|
|
months = months - (years * 12);
|
|||
|
|
|
|||
|
|
$(controlYear).val(years);
|
|||
|
|
$(controlMonth).val(months);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$.fn.dotNetFormat = function () {
|
|||
|
|
|
|||
|
|
if (this.val() != null && this.val() != '') {
|
|||
|
|
|
|||
|
|
var momentDate = moment(this.val(), "DD-MMMM-YYYY");
|
|||
|
|
var dotNetFormatDate = momentDate.format("MM-DD-YYYY");
|
|||
|
|
|
|||
|
|
return dotNetFormatDate;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
return '';
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
$.fn.CalculateLaboralAge = function (controlYear, controlMonth, controlEndDate) {
|
|||
|
|
|
|||
|
|
var txtFechaInicioEmpleo = moment(this.val(), "DD-MMMM-YYYY");
|
|||
|
|
var txtFechaFinEmpleo = moment($(controlEndDate).val(), "DD-MMMM-YYYY");
|
|||
|
|
|
|||
|
|
var years = txtFechaFinEmpleo.diff(txtFechaInicioEmpleo, 'years');
|
|||
|
|
var months = txtFechaFinEmpleo.diff(txtFechaInicioEmpleo, 'months');
|
|||
|
|
|
|||
|
|
months = months - (years * 12);
|
|||
|
|
|
|||
|
|
$(controlYear).val(years);
|
|||
|
|
$(controlMonth).val(months);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$.fn.DatepickerPast = function (ControlId) {
|
|||
|
|
|
|||
|
|
/// <summary>Method for asing Datepciker that start from 18 year ago to a text input html control.</summary>
|
|||
|
|
/// <param name="ControlId" type="text">Control ID of text input control</param>
|
|||
|
|
|
|||
|
|
var _dateObject = new Date();
|
|||
|
|
var _yearInit = _dateObject.getFullYear();
|
|||
|
|
|
|||
|
|
_dateObject.setFullYear(_yearInit);
|
|||
|
|
|
|||
|
|
if (RangoFecha == false && Finde == false)
|
|||
|
|
this.datepicker({ yearRange: '1945:' + (new Date).getFullYear(), defaultDate: _dateObject, dateFormat: DateFormat }).datepicker('widget').wrap('<div class="ll-skin-cangas"/>');
|
|||
|
|
|
|||
|
|
if (Finde == true)
|
|||
|
|
this.datepicker({
|
|||
|
|
dateFormat: DateFormat,
|
|||
|
|
beforeShowDay: noFinesDeSemanaNiFestivos
|
|||
|
|
}).datepicker('widget').wrap('<div class="ll-skin-cangas"/>');
|
|||
|
|
|
|||
|
|
if (RangoFecha == true)
|
|||
|
|
this.datepicker({
|
|||
|
|
dateFormat: DateFormat,
|
|||
|
|
minDate: MinDate,
|
|||
|
|
maxDate: MaxDate
|
|||
|
|
}).datepicker('widget').wrap('<div class="ll-skin-cangas"/>');
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
function noFinesDeSemanaNiFestivos(date) {
|
|||
|
|
|
|||
|
|
var noWeekend = $.datepicker.noWeekends(date);
|
|||
|
|
|
|||
|
|
if (noWeekend[0]) {
|
|||
|
|
return nationalDays(date);
|
|||
|
|
} else {
|
|||
|
|
return noWeekend;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
natDays = [
|
|||
|
|
[11, 26]
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
function nationalDays(date) {
|
|||
|
|
for (i = 0; i < natDays.length; i++) {
|
|||
|
|
if (date.getMonth() == natDays[i][0] - 1
|
|||
|
|
&& date.getDate() == natDays[i][1]) {
|
|||
|
|
return [false, natDays[i][2] + '_day'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return [true, ''];
|
|||
|
|
}
|
|||
|
|
//#endregion
|
|||
|
|
|
|||
|
|
//#endregion
|
|||
|
|
|
|||
|
|
//#region CONTROLSETTINGS
|
|||
|
|
|
|||
|
|
this.GetControlsSettings = function (keyfiltro, keyformulario, form, DataModel) {
|
|||
|
|
var uri = "api/GlobalAPI/GetControlsSettings?keyfiltro=" + keyfiltro + "&keyformulario=" + keyformulario;
|
|||
|
|
$.getJSON(server + uri).done(function (data) {
|
|||
|
|
|
|||
|
|
if (data != null) {
|
|||
|
|
if (data.CodRespuesta == "ERROR") {
|
|||
|
|
alert(data.DescripcionRespuesta)
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
ControlsSettings = data;
|
|||
|
|
if (data.Controls != null) {
|
|||
|
|
$.each(data.Controls, function (key, item) {
|
|||
|
|
if (typeof $("#div" + item.IdControl).val() !== 'undefined') {
|
|||
|
|
var validator = $("#" + form).validate();
|
|||
|
|
FORM_VALIDATOR = validator;
|
|||
|
|
|
|||
|
|
//#region DIV
|
|||
|
|
if (item.Hidden == true)
|
|||
|
|
|
|||
|
|
$("#div" + item.IdControl).hide();
|
|||
|
|
else
|
|||
|
|
|
|||
|
|
$("#div" + item.IdControl).show();
|
|||
|
|
//#endregion
|
|||
|
|
|
|||
|
|
//#region CALENDAR
|
|||
|
|
if (item.DescripcionTipoDato == "calendar") {
|
|||
|
|
|
|||
|
|
$('#txt' + item.IdControl).attr("required", item.Requerido);
|
|||
|
|
$('#txt' + item.IdControl).attr("disabled", item.Disabled);
|
|||
|
|
$('#txt' + item.IdControl).attr("readonly", item.Readonly);
|
|||
|
|
|
|||
|
|
DateFormat = item.DateFormat;
|
|||
|
|
MinDate = item.MinDate;
|
|||
|
|
MaxDate = item.MaxDate;
|
|||
|
|
if (MinDate != null && MaxDate != null)
|
|||
|
|
RangoFecha = true;
|
|||
|
|
Finde = item.Findesemana;
|
|||
|
|
|
|||
|
|
|
|||
|
|
$('#txt' + item.IdControl).DatepickerPast();
|
|||
|
|
//#endregion
|
|||
|
|
|
|||
|
|
//#region NUMBER
|
|||
|
|
} else if (item.DescripcionTipoDato == "percent" || item.DescripcionTipoDato == "currency"
|
|||
|
|
|| item.DescripcionTipoDato == "whole" || item.DescripcionTipoDato == "number") {
|
|||
|
|
|
|||
|
|
$('#txt' + item.IdControl).attr("required", item.Requerido);
|
|||
|
|
$('#txt' + item.IdControl).attr("disabled", item.Disabled);
|
|||
|
|
$('#txt' + item.IdControl).attr("readonly", item.Readonly);
|
|||
|
|
|
|||
|
|
|
|||
|
|
GetTypeNumeric(item.IdControl, item.DescripcionTipoDato)
|
|||
|
|
if (item.DescripcionTipoDato != "number")
|
|||
|
|
$('#txt' + item.IdControl).autoNumeric('set', '0');
|
|||
|
|
//#endregion
|
|||
|
|
|
|||
|
|
//#region EMAIL
|
|||
|
|
} else if (item.DescripcionTipoDato == "email") {
|
|||
|
|
$('#txt' + item.IdControl).attr("required", item.Requerido);
|
|||
|
|
$('#txt' + item.IdControl).attr("disabled", item.Disabled);
|
|||
|
|
$('#txt' + item.IdControl).attr("readonly", item.Readonly);
|
|||
|
|
$('#txt' + item.IdControl).attr("email", true);
|
|||
|
|
//#endregion
|
|||
|
|
|
|||
|
|
//#region CATALOGO
|
|||
|
|
} else if (item.DescripcionTipoDato == "catalogo") {
|
|||
|
|
|
|||
|
|
$('#txt' + item.IdControl).attr("required", item.Requerido);
|
|||
|
|
$('#txt' + item.IdControl).attr("disabled", item.Disabled);
|
|||
|
|
$('#txt' + item.IdControl).attr("readonly", item.Readonly);
|
|||
|
|
$('#btn' + item.IdControl).attr("disabled", item.Disabled);
|
|||
|
|
|
|||
|
|
if (item.DireccionAPI != null && item.DireccionAPI != "" && item.DireccionAPI != null && item.DireccionAPI.trim() != "") {
|
|||
|
|
$('#btn' + item.IdControl).click(function () {
|
|||
|
|
DireccionAPICatalogo = item.DireccionAPI
|
|||
|
|
SelectedCatalog = item.IdControl;
|
|||
|
|
|
|||
|
|
|
|||
|
|
CargarDataCatalogo(item.DireccionAPI);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//#endregion
|
|||
|
|
|
|||
|
|
//#region PHONE
|
|||
|
|
} else if (item.DescripcionTipoDato == "phone") {
|
|||
|
|
|
|||
|
|
$('#txt' + item.IdControl).attr("required", item.Requerido);
|
|||
|
|
$('#txt' + item.IdControl).attr("disabled", item.Disabled);
|
|||
|
|
$('#txt' + item.IdControl).attr("readonly", item.Readonly);
|
|||
|
|
|
|||
|
|
if (item.Hidden == true) {
|
|||
|
|
$("#div" + item.IdControl).show()
|
|||
|
|
$("#span" + item.IdControl).hide();
|
|||
|
|
}
|
|||
|
|
else if (item.Hidden == false)
|
|||
|
|
$("#span" + item.IdControl).show();
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//#endregion
|
|||
|
|
|
|||
|
|
//#region TEXT
|
|||
|
|
} else if (item.DescripcionTipoDato == "text") {
|
|||
|
|
$('#txt' + item.IdControl).attr("required", item.Requerido);
|
|||
|
|
$('#txt' + item.IdControl).attr("disabled", item.Disabled);
|
|||
|
|
$('#txt' + item.IdControl).attr("readonly", item.Readonly);
|
|||
|
|
//#endregion
|
|||
|
|
|
|||
|
|
//#region CHECKBOX
|
|||
|
|
} else if (item.DescripcionTipoDato == "checkbox") {
|
|||
|
|
$("#chk" + item.IdControl).attr("disabled", item.Disabled);
|
|||
|
|
//#endregion
|
|||
|
|
|
|||
|
|
//#region PMAID
|
|||
|
|
} else if (item.DescripcionTipoDato == "pmaid") {
|
|||
|
|
|
|||
|
|
if (item.Pmaid == true) {
|
|||
|
|
$("#radioCedula" + item.IdControl).attr('checked', true);
|
|||
|
|
$("#divCedula" + item.IdControl).show();
|
|||
|
|
$("#divPasaporte" + item.IdControl).hide();
|
|||
|
|
$("#txtPasaporte" + item.IdControl).attr("required", false);
|
|||
|
|
$("#txtCatalogo" + item.IdControl).attr("required", false);
|
|||
|
|
$("#txtCatalogo" + item.IdControl).attr("readonly", true);
|
|||
|
|
|
|||
|
|
if (item.DireccionAPI.trim() != "") {
|
|||
|
|
$('#btnCatalogo' + item.IdControl).click(function () {
|
|||
|
|
DireccionAPICatalogo = item.DireccionAPI
|
|||
|
|
SelectedCatalog = "Catalogo" + item.IdControl;
|
|||
|
|
CargarDataCatalogo(item.DireccionAPI);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
$("#divBuscar" + item.IdControl).show();
|
|||
|
|
|
|||
|
|
$("#radioCedula" + item.IdControl).change(function () {
|
|||
|
|
$("#radioPasaporte" + item.IdControl).attr('checked', false);
|
|||
|
|
$("#divCedula" + item.IdControl).show();
|
|||
|
|
$("#divPasaporte" + item.IdControl).hide();
|
|||
|
|
$("#txtPasaporte" + item.IdControl).attr("required", false);
|
|||
|
|
$("#txtCatalogo" + item.IdControl).attr("required", false);
|
|||
|
|
$("#txtCatalogo" + item.IdControl).attr("readonly", true);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
$("#radioPasaporte" + item.IdControl).change(function () {
|
|||
|
|
$("#radioCedula" + item.IdControl).attr('checked', false);
|
|||
|
|
$("#divCedula" + item.IdControl).hide();
|
|||
|
|
$("#divPasaporte" + item.IdControl).show();
|
|||
|
|
$("#txtPasaporte" + item.IdControl).attr("required", true);
|
|||
|
|
$("#txtCatalogo" + item.IdControl).attr("required", true);
|
|||
|
|
$("#txtCatalogo" + item.IdControl).attr("readonly", true);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
//#endregion
|
|||
|
|
|
|||
|
|
//#region RADIO
|
|||
|
|
} else if (item.DescripcionTipoDato == "radio") {
|
|||
|
|
$("#radio" + item.IdControl).attr('checked', item.Checked);
|
|||
|
|
//#endregion
|
|||
|
|
|
|||
|
|
//#region Signature
|
|||
|
|
} else if (item.DescripcionTipoDato == "Signature") {
|
|||
|
|
|
|||
|
|
$('#psw' + item.IdControl).attr("required", item.Requerido);
|
|||
|
|
$('#psw' + item.IdControl).attr("disabled", item.Disabled);
|
|||
|
|
$('#psw' + item.IdControl).attr("readonly", item.Readonly);
|
|||
|
|
GenerateSignatureControl(item.IdControl, validator);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
//#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
DataModel = item.DataModel
|
|||
|
|
});
|
|||
|
|
$("#" + form).valid();
|
|||
|
|
Frmnombre = form;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
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) {
|
|||
|
|
|
|||
|
|
if (typeof getDataModel !== 'undefined' && $.isFunction(getDataModel)) {
|
|||
|
|
if (DataModel == true) {
|
|||
|
|
getDataModel();
|
|||
|
|
ENDREQUEST();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
else
|
|||
|
|
ENDREQUEST();
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
|
|||
|
|
ENDREQUEST();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.GetTypeNumeric = function (id, type) {
|
|||
|
|
if (type == "currency") {
|
|||
|
|
$("#txt" + id).autoNumeric('init', { aSign: '' });
|
|||
|
|
} else if (type == "percent") {
|
|||
|
|
$("#txt" + id).autoNumeric('init', { aSign: ' %', pSign: 's' });
|
|||
|
|
} else if (type == "whole") {
|
|||
|
|
$("#txt" + id).autoNumeric('init');
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.CargarDataCatalogo = function (Direccion, filtro, validator) {
|
|||
|
|
|
|||
|
|
var uri = Direccion.trim() + (filtro == null ? "" : "?filtro=" + filtro);
|
|||
|
|
|
|||
|
|
|
|||
|
|
$.getJSON(server + uri).done(function (data) {
|
|||
|
|
|
|||
|
|
if (data != null) {
|
|||
|
|
|
|||
|
|
lista = data;
|
|||
|
|
|
|||
|
|
var Seleccionar = $("#ucBtnSeleccionar").html();
|
|||
|
|
|
|||
|
|
var columnDefinition = [
|
|||
|
|
{ "data": null, className: "center", defaultContent: Seleccionar },
|
|||
|
|
{ "data": "codigo" },
|
|||
|
|
{ "data": "descripcion" }
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
$('#tableCatalogo').TableInit(0, false, true, false, false, columnDefinition, lista);
|
|||
|
|
|
|||
|
|
|
|||
|
|
if ($.fn.DataTable.isDataTable('#tableCatalogo')) {
|
|||
|
|
|
|||
|
|
LoadMessage();
|
|||
|
|
|
|||
|
|
$('#tableCatalogo').DataTable().search('').draw();
|
|||
|
|
|
|||
|
|
$('#divmodalCatalogo').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();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$('#tableCatalogo').on('click', 'button', function () {
|
|||
|
|
|
|||
|
|
var data = $('#tableCatalogo').DataTable().row($(this).parents('tr')).data();
|
|||
|
|
|
|||
|
|
$("#hidden" + SelectedCatalog).val(data.codigo);
|
|||
|
|
$("#txt" + SelectedCatalog).val(data.descripcion);
|
|||
|
|
|
|||
|
|
FORM_VALIDATOR.element('#txt' + SelectedCatalog);
|
|||
|
|
|
|||
|
|
$('#divmodalCatalogo').modal('hide');
|
|||
|
|
|
|||
|
|
if ($.isFunction(DataCatalogo)) {
|
|||
|
|
DataCatalogo(SelectedCatalog, "#hidden" + SelectedCatalog);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (typeof CargarDataCatalogoAdicional !== 'undefined' && $.isFunction(CargarDataCatalogoAdicional)) {
|
|||
|
|
CargarDataCatalogoAdicional(SelectedCatalog, data.codigo);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
$("#btnBuscar").click(function () {
|
|||
|
|
CargarDataCatalogo(DireccionAPICatalogo, $("#txtDescripcion").val());
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
this.GenerateSignatureControl = function (id, validator) {
|
|||
|
|
|
|||
|
|
|
|||
|
|
$("#btn" + id).click(function () {
|
|||
|
|
AutenticateUserSignature(id);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$("#btn" + id + "Remove").click(function () {
|
|||
|
|
|
|||
|
|
if (confirm("¿Desea remover la firma?")) {
|
|||
|
|
|
|||
|
|
$("#psw" + id).val("");
|
|||
|
|
$("#lbl" + id + "User").text("");
|
|||
|
|
$("#div" + id + "Container").show();
|
|||
|
|
$("#div" + id + "Image").hide();
|
|||
|
|
|
|||
|
|
validator.element('#psw' + id);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.AutenticateUserSignature = function (id) {
|
|||
|
|
|
|||
|
|
var uri = 'api/GlobalAPI/UserAutenticate';
|
|||
|
|
|
|||
|
|
CredencialesUsuario = {
|
|||
|
|
Usuario: $("#hiddenUserID").val(),
|
|||
|
|
Contrasena: $("#psw" + id).val()
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
var DTO = JSON.stringify(CredencialesUsuario);
|
|||
|
|
|
|||
|
|
$.ajax({
|
|||
|
|
type: 'POST',
|
|||
|
|
url: server + uri,
|
|||
|
|
cache: false,
|
|||
|
|
data: DTO,
|
|||
|
|
contentType: 'application/json; charset=utf-8',
|
|||
|
|
dataType: 'json',
|
|||
|
|
success: function (data) {
|
|||
|
|
if (data.ResultadoTransaccion.Resultado) {
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (!data.Autenticado) {
|
|||
|
|
|
|||
|
|
$("#div" + id + "Container").hide();
|
|||
|
|
|
|||
|
|
$("#div" + id + "Image").show();
|
|||
|
|
$("#img" + id).attr("src", data.RutaFirma);
|
|||
|
|
$("#lbl" + id + "User").text($("#hiddenUserID").val());
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
toastr.warning("La Contraseña es incorrecta", Message_Warning);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado. Vuela a intentarlo mas tarde", Message_Error);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|||
|
|
|
|||
|
|
toastr.error("Ha ocurrido un error inesperado. Vuela a intentarlo mas tarde", Message_Error);
|
|||
|
|
|
|||
|
|
ENDREQUEST();
|
|||
|
|
|
|||
|
|
}).then(function (value) {
|
|||
|
|
|
|||
|
|
|
|||
|
|
ENDREQUEST();
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.getUrlParameter = function (sParam) {
|
|||
|
|
var sPageURL = window.location.search.substring(1);
|
|||
|
|
var sURLVariables = sPageURL.split('&');
|
|||
|
|
for (var i = 0; i < sURLVariables.length; i++) {
|
|||
|
|
var sParameterName = sURLVariables[i].split('=');
|
|||
|
|
if (sParameterName[0] == sParam) {
|
|||
|
|
return sParameterName[1];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
//#endregion
|