1178 lines
36 KiB
JavaScript
1178 lines
36 KiB
JavaScript
// JScript File
|
|
function setsizedatables(gv, suma) {
|
|
var MyRows = $('table #'.concat(gv)).find('tbody').find('tr:eq(1)').find('td');
|
|
var MyRows2 = $('table #'.concat(gv.concat('Copy'))).find('tbody').find('tr:eq(0)').find('th');
|
|
for (var i = 0; i < MyRows.length; i++) {
|
|
|
|
var x = $(MyRows[i]).width() + ',' + $(MyRows2[i]).width();
|
|
alert(x);
|
|
$(MyRows2[i]).find('div').width('80%');
|
|
$(MyRows2[i]).width(0);
|
|
$(MyRows2[i]).width($(MyRows[i]).width() + suma);
|
|
}
|
|
}
|
|
function elementexist(element) {
|
|
if ($(element)) {
|
|
if ($(element).html()) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
function adddivpage(id,px) {
|
|
var divpage=$('<div style="min-width: '+px+'px; position: fixed; background-color: white; height: 100%; top: 0px; left: 0px; z-index: -4; "></div>');
|
|
$('#divContenido > .page-content').append(divpage);
|
|
$('#' + id).css({ 'min-width': px });
|
|
}
|
|
function addindicadortext(color, icono, titulo, comentario, link, objeto) {
|
|
var tpl = '';
|
|
tpl += "<div class='col-lg-4 col-md-4 col-sm-6 col-xs-12'>";
|
|
tpl += " <div class='dashboard-stat " + color + "'>";
|
|
tpl += " <div class='visual'>";
|
|
tpl += " <i class='" + icono + "''></i>";
|
|
tpl += " </div>";
|
|
tpl += " <div class='details'>";
|
|
tpl += " <div class='number'>";
|
|
tpl += " " + titulo;
|
|
tpl += " </div>";
|
|
tpl += " <div class='desc'>";
|
|
tpl += " " + comentario;
|
|
tpl += " </div>";
|
|
tpl += " </div>";
|
|
tpl += " <a class='more' href='" + link + "'>";
|
|
tpl += " Ver Más <i class='m-icon-swapright m-icon-white'></i>";
|
|
tpl += " </a>";
|
|
tpl += " </div>";
|
|
tpl += "</div>";
|
|
tpl = $(tpl);
|
|
objeto.append(tpl);
|
|
|
|
}
|
|
function changedatagrafica(idcontainer) {
|
|
var datosdiv = $("#" + idcontainer).data('serie');
|
|
var checkboxes = $('#'+idcontainer+' + div input');
|
|
var datos = [['', 0]];
|
|
for (var i = 0; i < datosdiv.length; i++) {
|
|
if (!($(checkboxes[i]).is(':checked'))) {
|
|
datos.push(datosdiv[i]);
|
|
}
|
|
}
|
|
var chart = $('#' + idcontainer).highcharts();
|
|
chart.series[0].update({data: datos });
|
|
}
|
|
function changedatagrafica2(idcontainer) {
|
|
var datosdiv = $("#" + idcontainer).data('serie');
|
|
var checkboxes = $('#' + idcontainer + ' + div input');
|
|
var datos = [['', 0]];
|
|
var intervalo = 0;
|
|
for (var i = 0; i < datosdiv.length; i++) {
|
|
if (!($(checkboxes[i]).is(':checked'))) {
|
|
datos.push(datosdiv[i]);
|
|
intervalo++;
|
|
}
|
|
}
|
|
var chart = $('#' + idcontainer).highcharts();
|
|
chart.series[0].update({ data: datos });
|
|
chart.series[1].update({ pointInterval: intervalo });
|
|
}
|
|
function graficahighcharts(idcontainer, titulo, subtitulo, ytitulo, datos, Yinterval, labelpoint) {
|
|
|
|
//var idcontainer = 'container';
|
|
//var titulo = 'Historic and Estimated Worldwide Population Growth by Region';
|
|
//var subtitulo = 'Source: Wikipedia.org';
|
|
//var xtitulos = ['1750', '1800', '1850', '1900', '1950', '1999', '2050'];
|
|
//var ytitulo = 'Billions';
|
|
//var datos = [502, 635, 809, 947, 1402, 3634, 5268];
|
|
//var Yinterval = 1000;
|
|
//var labelpoint = ' millions';
|
|
|
|
var numerodatos = 0;
|
|
$("<div class='chartcheckboxes' ><span></span></div>").insertAfter("#" + idcontainer);
|
|
if (datos.length > 0) {
|
|
var numerodatos = datos.length - 1;
|
|
//var media = (datos.reduce(function (a, b) { return a + b; })) / (numerodatos + 1);
|
|
for (var i = numerodatos; i >=0 ; i--) {
|
|
$("<input type='checkbox' id='" + idcontainer + i + "' class='overrydecheckbox' value='" + i + "' onchange=\"changedatagrafica('" + idcontainer + "');\" /><label for='" + idcontainer + i + "'>" + datos[i][0].substring(0, 3) + "</label>").insertAfter("#" + idcontainer + " + div span");
|
|
}
|
|
}
|
|
$("#" + idcontainer).data('serie', datos);
|
|
var margintop = 10;
|
|
|
|
var dataset=[{
|
|
name: ' ',
|
|
data: datos
|
|
} ];
|
|
|
|
$('#' + idcontainer).highcharts({
|
|
chart: {
|
|
type: 'area', spacingTop: margintop
|
|
},
|
|
title: {
|
|
text: titulo
|
|
},
|
|
subtitle: {
|
|
text: subtitulo
|
|
},
|
|
xAxis: {
|
|
type:"category"
|
|
|
|
},
|
|
yAxis: {
|
|
title: {
|
|
text: ytitulo
|
|
},
|
|
labels: {
|
|
formatter: function () {
|
|
return this.value / Yinterval;
|
|
}
|
|
}
|
|
},
|
|
tooltip: {
|
|
shared: true,
|
|
valueSuffix: labelpoint
|
|
},
|
|
plotOptions: {
|
|
area: {
|
|
color:'#FBC5C5',
|
|
fillColor:'#FBC5C5',
|
|
stacking: 'normal',
|
|
lineColor: '#F89F9F',
|
|
lineWidth: 0,
|
|
marker: {
|
|
radius: 5,
|
|
lineWidth: 2,
|
|
lineColor:'#FFF',
|
|
fillColor: '#F89F9F'
|
|
}
|
|
},
|
|
line: {
|
|
pointInterval: numerodatos,
|
|
lineColor: '#999999',
|
|
marker: {
|
|
enabled: false,
|
|
symbol: 'circle',
|
|
radius: 2,
|
|
states: {
|
|
hover: {
|
|
enabled: true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
series: dataset
|
|
});
|
|
}
|
|
function graficahighcharts2(idcontainer, titulo, subtitulo, ytitulo, datos, Yinterval, labelpoint, media, datospie1, datospie2) {
|
|
var Monedas='';
|
|
if (datospie1.length > 0) {
|
|
Monedas = 'Monedas';
|
|
}
|
|
var numerodatos = 0;
|
|
$("<div class='chartcheckboxes' ><span></span></div>").insertAfter("#" + idcontainer);
|
|
if (datos.length > 0) {
|
|
var numerodatos = datos.length - 1;
|
|
//var media = (datos.reduce(function (a, b) { return a + b; })) / (numerodatos + 1);
|
|
for (var i = numerodatos; i >= 0 ; i--) {
|
|
$("<input type='checkbox' id='" + idcontainer + i + "' class='overrydecheckbox' value='" + i + "' onchange=\" changedatagrafica2('" + idcontainer + "');\" /><label for='" + idcontainer + i + "'>" + datos[i][0].substring(0, 3) + "</label>").insertAfter("#" + idcontainer + " + div span");
|
|
}
|
|
}
|
|
$("#" + idcontainer).data('serie', datos);
|
|
|
|
var margintop = 80;
|
|
var dataset = [{
|
|
type: 'area',
|
|
lineColor: '#9ACAE6',
|
|
color: '#F1F7FD',
|
|
fillColor: '#F1F7FD',
|
|
lineWidth: 3,
|
|
marker: {
|
|
lineWidth: 2,
|
|
lineColor: '#9ACAE6',
|
|
fillColor: '#9ACAE6'
|
|
},
|
|
pointInterval: 1,
|
|
name: ' ',
|
|
data: datos
|
|
}, {
|
|
type: 'line',
|
|
lineWidth: 2,
|
|
lineColor: '#999',
|
|
marker: {
|
|
enabled: false
|
|
},
|
|
name: ' ',
|
|
data: [media, media]
|
|
}, {
|
|
type: 'pie',
|
|
name: 'Monedas',
|
|
colorByPoint: true,
|
|
data: datospie1,
|
|
center: [110, -50],
|
|
size: 60,
|
|
showInLegend: false,
|
|
dataLabels: {
|
|
enabled: false
|
|
}
|
|
}, {
|
|
type: 'pie',
|
|
name: 'Saldo Cuentas',
|
|
colorByPoint: true,
|
|
data:datospie2,
|
|
center: [30, -50],
|
|
size: 60,
|
|
showInLegend: false,
|
|
dataLabels: {
|
|
enabled: false
|
|
}
|
|
}];
|
|
|
|
$('#' + idcontainer).highcharts({
|
|
chart: {
|
|
type: 'area', spacingTop: margintop
|
|
},
|
|
title: {
|
|
text: titulo
|
|
},
|
|
subtitle: {
|
|
text: subtitulo
|
|
},
|
|
xAxis: {
|
|
type: "category"
|
|
|
|
},
|
|
yAxis: {
|
|
title: {
|
|
text: ytitulo
|
|
},
|
|
labels: {
|
|
formatter: function () {
|
|
return this.value / Yinterval;
|
|
}
|
|
}
|
|
},
|
|
labels: {
|
|
items: [{
|
|
html: 'Saldo Cuentas',
|
|
style: {
|
|
left: '10px',
|
|
top: '-80px',
|
|
color: (Highcharts.theme && Highcharts.theme.textColor) || 'black'
|
|
}
|
|
}, {
|
|
html: Monedas,
|
|
style: {
|
|
left: '110px',
|
|
top: '-80px',
|
|
color: (Highcharts.theme && Highcharts.theme.textColor) || 'black'
|
|
}
|
|
}]
|
|
},
|
|
tooltip: {
|
|
shared: true,
|
|
valueSuffix: labelpoint
|
|
},
|
|
plotOptions: {
|
|
area: {
|
|
color: '#FBC5C5',
|
|
fillColor: '#FBC5C5',
|
|
stacking: 'normal',
|
|
lineColor: '#F89F9F',
|
|
lineWidth: 0,
|
|
marker: {
|
|
radius: 5,
|
|
lineWidth: 2,
|
|
lineColor: '#FFF',
|
|
fillColor: '#F89F9F'
|
|
}
|
|
},
|
|
line: {
|
|
pointInterval: numerodatos,
|
|
lineColor: '#999999',
|
|
marker: {
|
|
enabled: false,
|
|
symbol: 'circle',
|
|
radius: 2,
|
|
states: {
|
|
hover: {
|
|
enabled: true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
series: dataset,
|
|
navigation: {
|
|
buttonOptions: {
|
|
y: -80
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
function graficaindex(datagrafica, iddiv, pestaña) {
|
|
|
|
if (!jQuery.plot) {
|
|
return;
|
|
}
|
|
function showChartTooltip(x, y, xValue, yValue) {
|
|
$('<div id="tooltip" class="chart-tooltip">' + yValue + '<\/div>').css({
|
|
position: 'absolute',
|
|
display: 'none',
|
|
top: y - 40,
|
|
left: x - 40,
|
|
border: '0px solid #ccc',
|
|
padding: '2px 6px',
|
|
'background-color': '#fff'
|
|
}).appendTo("body").fadeIn(200);
|
|
}
|
|
var previousPoint2 = null;
|
|
if ($('#'+iddiv).size() != 0) {
|
|
|
|
$('#'+iddiv+'_loading').hide();
|
|
$('#'+iddiv+'_content').show();
|
|
|
|
var plot_statistics = $.plot($("#"+iddiv),
|
|
[{
|
|
data: datagrafica,
|
|
lines: {
|
|
fill: 0.6,
|
|
lineWidth: 0
|
|
},
|
|
color: ['#BAD9F5']
|
|
}, {
|
|
data: datagrafica,
|
|
points: {
|
|
show: true,
|
|
fill: true,
|
|
radius: 5,
|
|
fillColor: "#9ACAE6",
|
|
lineWidth: 3
|
|
},
|
|
color: '#9ACAE6',
|
|
shadowSize: 0
|
|
}, {
|
|
data: datagrafica,
|
|
lines: {
|
|
show: true,
|
|
fill: false,
|
|
lineWidth: 3
|
|
},
|
|
color: '#9ACAE6',
|
|
shadowSize: 0
|
|
} ],
|
|
|
|
{
|
|
xaxis: {
|
|
tickLength: 0,
|
|
tickDecimals: 0,
|
|
mode: "categories",
|
|
min: 0,
|
|
font: {
|
|
lineHeight: 14,
|
|
style: "normal",
|
|
variant: "small-caps",
|
|
color: "#6F7B8A"
|
|
}
|
|
},
|
|
yaxis: {
|
|
ticks: 5,
|
|
tickDecimals: 0,
|
|
tickColor: "#eee",
|
|
font: {
|
|
lineHeight: 14,
|
|
style: "normal",
|
|
variant: "small-caps",
|
|
color: "#6F7B8A"
|
|
}
|
|
},
|
|
grid: {
|
|
hoverable: true,
|
|
clickable: true,
|
|
tickColor: "#eee",
|
|
borderColor: "#eee",
|
|
borderWidth: 1
|
|
}
|
|
});
|
|
|
|
$("#" + iddiv).bind("plothover", function (event, pos, item) {
|
|
$("#x").text(pos.x.toFixed(2));
|
|
$("#y").text(pos.y.toFixed(2));
|
|
if (item) {
|
|
if (previousPoint2 != item.dataIndex) {
|
|
previousPoint2 = item.dataIndex;
|
|
$("#tooltip").remove();
|
|
var x = item.datapoint[0].toFixed(2),
|
|
y = item.datapoint[1].toFixed(2);
|
|
showChartTooltip(item.pageX, item.pageY, item.datapoint[0], item.datapoint[1] +" " +pestaña);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
function graficaindex2(datagrafica, iddiv, pestaña, datagrafica2) {
|
|
if (!jQuery.plot) {
|
|
return;
|
|
}
|
|
function showChartTooltip(x, y, xValue, yValue) {
|
|
$('<div id="tooltip" class="chart-tooltip">' + yValue + '<\/div>').css({
|
|
position: 'absolute',
|
|
display: 'none',
|
|
top: y - 40,
|
|
left: x - 40,
|
|
border: '0px solid #ccc',
|
|
padding: '2px 6px',
|
|
'background-color': '#fff'
|
|
}).appendTo("body").fadeIn(200);
|
|
}
|
|
var previousPoint = null;
|
|
if ($('#' + iddiv).size() != 0) {
|
|
|
|
$('#' + iddiv + '_loading').hide();
|
|
$('#' + iddiv + '_content').show();
|
|
|
|
var plot_statistics = $.plot($("#" + iddiv),
|
|
[{
|
|
data: datagrafica,
|
|
lines: {
|
|
fill: 0.6,
|
|
lineWidth: 0
|
|
},
|
|
color: ['#E56B6A']
|
|
}, {
|
|
data: datagrafica,
|
|
points: {
|
|
show: true,
|
|
fill: true,
|
|
radius: 5,
|
|
fillColor: "#f89f9f",
|
|
lineWidth: 3
|
|
},
|
|
color: '#f89f9f',
|
|
shadowSize: 0
|
|
}, {
|
|
data: datagrafica,
|
|
lines: {
|
|
show: true,
|
|
fill: false,
|
|
lineWidth: 3
|
|
},
|
|
color: '#f89f9f',
|
|
shadowSize: 0
|
|
}, {
|
|
data: datagrafica2,
|
|
lines: {
|
|
show: true,
|
|
fill: false,
|
|
lineWidth: 1
|
|
},
|
|
color: '#e04a49',
|
|
shadowSize: 0
|
|
}],
|
|
|
|
{
|
|
xaxis: {
|
|
tickLength: 0,
|
|
tickDecimals: 0,
|
|
mode: "categories",
|
|
min: 0,
|
|
font: {
|
|
lineHeight: 14,
|
|
style: "normal",
|
|
variant: "small-caps",
|
|
color: "#6F7B8A"
|
|
}
|
|
},
|
|
yaxis: {
|
|
ticks: 5,
|
|
tickDecimals: 0,
|
|
tickColor: "#eee",
|
|
font: {
|
|
lineHeight: 14,
|
|
style: "normal",
|
|
variant: "small-caps",
|
|
color: "#6F7B8A"
|
|
}
|
|
},
|
|
grid: {
|
|
hoverable: true,
|
|
clickable: true,
|
|
tickColor: "#eee",
|
|
borderColor: "#eee",
|
|
borderWidth: 1
|
|
}
|
|
});
|
|
|
|
$("#" + iddiv).bind("plothover", function (event, pos, item) {
|
|
$("#x").text(pos.x.toFixed(2));
|
|
$("#y").text(pos.y.toFixed(2));
|
|
if (item) {
|
|
if (previousPoint != item.dataIndex) {
|
|
previousPoint = item.dataIndex;
|
|
$("#tooltip").remove();
|
|
var x = item.datapoint[0].toFixed(2),
|
|
y = item.datapoint[1].toFixed(2);
|
|
showChartTooltip(item.pageX, item.pageY, item.datapoint[0], item.datapoint[1] + " " + pestaña);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function gethtml(idname) {
|
|
var html = "<!DOCTYPE html><html>";
|
|
var head = "<head>"+$("head").html()+"</head>";
|
|
var mydiv = "<body>" + $('#' + idname).html() + "</body></html>";
|
|
var result = html + head + mydiv;
|
|
result=result.replace(/</g, '.|.').replace(/>/g, '.$.').replace(/"/g, "'");
|
|
return result;
|
|
}
|
|
function CheckArchivoExtension(sender, args) {
|
|
|
|
var Cadena = args.value;
|
|
//Cadena = Cadena.toLowerCase();
|
|
alert(args.get_fileName.toString);
|
|
var regex = /^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))+(.xls|.pdf|.xlsx|.doc|.docx)$/;
|
|
|
|
var re = new RegExp(regex);
|
|
}
|
|
|
|
function ValidaDecimal(val, args) {
|
|
if (args.Value.match(/^\$?\-?(\d{1,3},?(\d{3},?)*\d{3}(\.\d{0,2})?|\d{1,3}(\.\d{0,2})?|\.\d{1,2}?)$/))
|
|
args.IsValid = true;
|
|
else
|
|
args.IsValid = false;
|
|
}
|
|
function ValidaDecimal4digits(val, args) {
|
|
if (args.Value.match(/^\d+(\.\d{1,4})?$/))
|
|
args.IsValid = true;
|
|
else
|
|
args.IsValid = false;
|
|
}
|
|
function ValidaDecimal6digits(val, args) {
|
|
if (args.Value.match(/^\d+(\.\d{1,6})?$/))
|
|
args.IsValid = true;
|
|
else
|
|
args.IsValid = false;
|
|
}
|
|
|
|
function ValidaDecimal6digits(val, args) {
|
|
if (args.Value.match(/^\d+(\.\d{1,6})?$/))
|
|
args.IsValid = true;
|
|
else
|
|
args.IsValid = false;
|
|
}
|
|
function ValidaDecimal6digitsEmpty(val, args) {
|
|
if (args.Value.match(/^(\s{0}|\d+(\.\d{1,6})?)$/))
|
|
args.IsValid = true;
|
|
else
|
|
args.IsValid = false;
|
|
}
|
|
|
|
|
|
function MuestraAlerta(Titulo, Mensaje, Img, Botones, JSBtnAceptar) {
|
|
|
|
bootbox.dialog({
|
|
message: Mensaje, className: " header-green ", title: "<i class='fa fa-info-circle'></i> Información",
|
|
buttons: {
|
|
main: {
|
|
label: "Aceptar", className: " green",
|
|
callback: function () { eval(JSBtnAceptar); }
|
|
}
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
|
|
function TamañoVentana() {
|
|
var h = window.innerHeight
|
|
|| document.documentElement.clientHeight
|
|
|| document.getElementsByTagName('body')[0].clientHeight;
|
|
var w = window.innerWidth
|
|
|| document.documentElement.clientWidth
|
|
|| document.getElementsByTagName('body')[0].clientWidth;
|
|
|
|
return { width: w, height: h };
|
|
}
|
|
function gotourl(url) {
|
|
var reload=window.opener;
|
|
if (!reload) {
|
|
reload = parent;
|
|
|
|
}
|
|
if (!url) {
|
|
url = reload.location.href.replace("#", "");
|
|
}
|
|
reload.location = url;
|
|
window.close();
|
|
|
|
}
|
|
|
|
function OcultaAlert(Id) {
|
|
$("div#DivX" + Id).fadeOut("slow");
|
|
$("div#DivAlert1").fadeOut("slow");
|
|
$("div#DivAlert").fadeOut("slow");
|
|
}
|
|
// funcion que le da una marcara para formatear y ponerle separador de miles
|
|
function FormatoMoneda(t) {
|
|
var v = t.value.replace(/([^0-9\.]+)/g, '');
|
|
v = v.replace(/^[\.]/, '');
|
|
v = v.replace(/[\.][\.]/g, '');
|
|
v = v.replace(/\.(\d)(\d)(\d)/g, '.$1$2');
|
|
v = v.replace(/\.(\d{1,2})\./g, '.$1');
|
|
v = v.toString().split('').reverse().join('').replace(/(\d{3})/g, '$1,');
|
|
v = v.split('').reverse().join('').replace(/^[\,]/, '');
|
|
t.value = v;
|
|
}
|
|
function FormatoMoneda2(t) {
|
|
var v = t.val().replace(/([^0-9\.]+)/g, '');
|
|
v = v.replace(/^[\.]/, '');
|
|
v = v.replace(/[\.][\.]/g, '');
|
|
v = v.replace(/\.(\d)(\d)(\d)/g, '.$1$2');
|
|
v = v.replace(/\.(\d{1,2})\./g, '.$1');
|
|
v = v.toString().split('').reverse().join('').replace(/(\d{3})/g, '$1,');
|
|
v = v.split('').reverse().join('').replace(/^[\,]/, '');
|
|
t.val(v);
|
|
}
|
|
|
|
function ToDouble(num) {
|
|
//if (typeOf(num) != 'string') num = num.toString()
|
|
if (isNaN(parseFloat(num.toString().replace(/,/gi, "")))) return 0;
|
|
return parseFloat(num.toString().replace(/,/gi, ""));
|
|
|
|
}
|
|
|
|
function AbrirVentana(Pagina, Ancho, Alto, tmp, Titulo) {
|
|
Metronic.blockUI({ animate: true });
|
|
if (!(Ancho)) { Ancho = '801'; }
|
|
if (!(Alto)) { Alto = '601'; }
|
|
$('#ajaxidmodal #myFrame').css({ width: Ancho, height: Alto });
|
|
$('#ajaxidmodal ').css({ width: Ancho, height: Alto });
|
|
$("#ajax").modal();
|
|
$('#ajaxidmodal').removeClass("hidden");
|
|
$("#ajaxidmodal #myFrame").unbind("load");
|
|
$('#ajaxidmodal #myFrame').load(function () {
|
|
Metronic.unblockUI();
|
|
});
|
|
$('#ajaxidmodal #myFrame').prop('src', Pagina);
|
|
//$("#ajax").modal();
|
|
}
|
|
|
|
function CerrarVentana() {
|
|
window.parent.$("#ajax").modal('hide');
|
|
}
|
|
showPopup = function (div_id, width, height) {
|
|
//Generar URL para thickbox
|
|
debugger;
|
|
var thickboxURL = "#TB_inline?height=" + height + "&width=" + width + "&inlineId=" + div_id + ""; //&modal=true
|
|
//Llamar a método de thickbox que muestra un popup con la URL generada
|
|
tb_show(null, thickboxURL, null);
|
|
}
|
|
function PosicionaObjeto(ObjPrincipal, PopUp, Lugar, leftoffset, topoffset) {
|
|
var ObjPpal = $('#' + ObjPrincipal);
|
|
var ObjPopUp = $('#' + PopUp);
|
|
ObjPopUp.css({
|
|
"position": 'absolute',
|
|
"z-index": '50',
|
|
'margin-left': leftoffset + 'px',
|
|
'margin-top': topoffset + 'px',
|
|
|
|
});
|
|
ObjPpal.after(ObjPopUp);
|
|
}
|
|
//function PosicionaObjeto(ObjPrincipal, PopUp, Lugar, leftoffset, topoffset) {
|
|
// var ObjPpal = $('#' + ObjPrincipal);
|
|
// var ObjPopUp = $('#' + PopUp);
|
|
|
|
// if (ObjPpal) {
|
|
// var left = 0;
|
|
// var right = 0;
|
|
// var top = 0;
|
|
// var posPop = ObjPopUp.offset();
|
|
// var widthPop = ObjPopUp.outerWidth();
|
|
|
|
// var widthDoc = $(document).width();
|
|
// //var widthDoc = $('#TablaGeneral').width();
|
|
|
|
// if (ObjPpal.offset().left + ObjPpal.outerWidth() + widthPop > widthDoc)
|
|
// left = widthDoc - ObjPpal.outerWidth() - widthPop;
|
|
// else {
|
|
// left = ObjPpal.offset().left + ObjPpal.outerWidth();
|
|
// if (Lugar == 'right')
|
|
// left = left - 230;
|
|
// }
|
|
|
|
// if (ObjPpal.offset().top + ObjPpal.outerHeight() + ObjPopUp.outerHeight > $(document).height())
|
|
// top = $(document).Height() - ObjPpal.outerHeight() - ObjPopUp.outerHeight;
|
|
// else
|
|
// top = ObjPpal.offset().top + ObjPpal.outerHeight();
|
|
|
|
// if (leftoffset) left = left + leftoffset;
|
|
|
|
// if (topoffset) top = top + topoffset;
|
|
|
|
// ObjPopUp.css({
|
|
// "position": 'absolute',
|
|
// "left": parseInt(left) + "px",
|
|
// "top": parseInt(top) + "px"
|
|
// });
|
|
// }
|
|
//}
|
|
|
|
function ValidaLengthTextArea(TextArea, Length) {
|
|
if (TextArea.value.length >= Length)
|
|
TextArea.value = TextArea.value.substring(0, Length - 1);
|
|
}
|
|
|
|
|
|
// function string_literal conversion is the core of this program
|
|
// converts numbers to spanish strings, handling the general special
|
|
// cases in spanish language.
|
|
function string_literal_conversion(number) {
|
|
// first, divide your number in hundreds, tens and units, cascadig
|
|
// trough subsequent divisions, using the modulus of each division
|
|
// for the next.
|
|
|
|
centenas = ObtenerParteEntDiv(number, 100);
|
|
|
|
number = mod(number, 100);
|
|
|
|
decenas = ObtenerParteEntDiv(number, 10);
|
|
number = mod(number, 10);
|
|
|
|
unidades = ObtenerParteEntDiv(number, 1);
|
|
number = mod(number, 1);
|
|
string_hundreds = "";
|
|
string_tens = "";
|
|
string_units = "";
|
|
// cascade trough hundreds. This will convert the hundreds part to
|
|
// their corresponding string in spanish.
|
|
if (centenas == 1) {
|
|
string_hundreds = "ciento ";
|
|
}
|
|
|
|
|
|
if (centenas == 2) {
|
|
string_hundreds = "doscientos ";
|
|
}
|
|
|
|
if (centenas == 3) {
|
|
string_hundreds = "trescientos ";
|
|
}
|
|
|
|
if (centenas == 4) {
|
|
string_hundreds = "cuatrocientos ";
|
|
}
|
|
|
|
if (centenas == 5) {
|
|
string_hundreds = "quinientos ";
|
|
}
|
|
|
|
if (centenas == 6) {
|
|
string_hundreds = "seiscientos ";
|
|
}
|
|
|
|
if (centenas == 7) {
|
|
string_hundreds = "setecientos ";
|
|
}
|
|
|
|
if (centenas == 8) {
|
|
string_hundreds = "ochocientos ";
|
|
}
|
|
|
|
if (centenas == 9) {
|
|
string_hundreds = "novecientos ";
|
|
}
|
|
|
|
// end switch hundreds
|
|
|
|
// casgade trough tens. This will convert the tens part to corresponding
|
|
// strings in spanish. Note, however that the strings between 11 and 19
|
|
// are all special cases. Also 21-29 is a special case in spanish.
|
|
if (decenas == 1) {
|
|
//Special case, depends on units for each conversion
|
|
if (unidades == 1) {
|
|
string_tens = "once";
|
|
}
|
|
|
|
if (unidades == 2) {
|
|
string_tens = "doce";
|
|
}
|
|
|
|
if (unidades == 3) {
|
|
string_tens = "trece";
|
|
}
|
|
|
|
if (unidades == 4) {
|
|
string_tens = "catorce";
|
|
}
|
|
|
|
if (unidades == 5) {
|
|
string_tens = "quince";
|
|
}
|
|
|
|
if (unidades == 6) {
|
|
string_tens = "dieciseis";
|
|
}
|
|
|
|
if (unidades == 7) {
|
|
string_tens = "diecisiete";
|
|
}
|
|
|
|
if (unidades == 8) {
|
|
string_tens = "dieciocho";
|
|
}
|
|
|
|
if (unidades == 9) {
|
|
string_tens = "diecinueve";
|
|
}
|
|
}
|
|
//alert("STRING_TENS ="+string_tens);
|
|
|
|
if (decenas == 2) {
|
|
string_tens = "veinti";
|
|
|
|
}
|
|
if (decenas == 3) {
|
|
string_tens = "treinta";
|
|
}
|
|
if (decenas == 4) {
|
|
string_tens = "cuarenta";
|
|
}
|
|
if (decenas == 5) {
|
|
string_tens = "cincuenta";
|
|
}
|
|
if (decenas == 6) {
|
|
string_tens = "sesenta";
|
|
}
|
|
if (decenas == 7) {
|
|
string_tens = "setenta";
|
|
}
|
|
if (decenas == 8) {
|
|
string_tens = "ochenta";
|
|
}
|
|
if (decenas == 9) {
|
|
string_tens = "noventa";
|
|
}
|
|
|
|
// Fin de swicth decenas
|
|
|
|
|
|
// cascades trough units, This will convert the units part to corresponding
|
|
// strings in spanish. Note however that a check is being made to see wether
|
|
// the special cases 11-19 were used. In that case, the whole conversion of
|
|
// individual units is ignored since it was already made in the tens cascade.
|
|
|
|
if (decenas == 1) {
|
|
string_units = ""; // empties the units check, since it has alredy been handled on the tens switch
|
|
}
|
|
else {
|
|
if (unidades == 1) {
|
|
string_units = "un";
|
|
}
|
|
if (unidades == 2) {
|
|
string_units = "dos";
|
|
}
|
|
if (unidades == 3) {
|
|
string_units = "tres";
|
|
}
|
|
if (unidades == 4) {
|
|
string_units = "cuatro";
|
|
}
|
|
if (unidades == 5) {
|
|
string_units = "cinco";
|
|
}
|
|
if (unidades == 6) {
|
|
string_units = "seis";
|
|
}
|
|
if (unidades == 7) {
|
|
string_units = "siete";
|
|
}
|
|
if (unidades == 8) {
|
|
string_units = "ocho";
|
|
}
|
|
if (unidades == 9) {
|
|
string_units = "nueve";
|
|
}
|
|
// end switch units
|
|
} // end if-then-else
|
|
|
|
|
|
//final special cases. This conditions will handle the special cases which
|
|
//are not as general as the ones in the cascades. Basically four:
|
|
|
|
// when you've got 100, you dont' say 'ciento' you say 'cien'
|
|
// 'ciento' is used only for [101 >= number > 199]
|
|
if (centenas == 1 && decenas == 0 && unidades == 0) {
|
|
string_hundreds = "cien ";
|
|
}
|
|
|
|
// when you've got 10, you don't say any of the 11-19 special
|
|
// cases.. just say 'diez'
|
|
if (decenas == 1 && unidades == 0) {
|
|
string_tens = "diez ";
|
|
}
|
|
|
|
// when you've got 20, you don't say 'veinti', which is used
|
|
// only for [21 >= number > 29]
|
|
if (decenas == 2 && unidades == 0) {
|
|
string_tens = "veinte ";
|
|
}
|
|
|
|
// for numbers >= 30, you don't use a single word such as veintiuno
|
|
// (twenty one), you must add 'y' (and), and use two words. v.gr 31
|
|
// 'treinta y uno' (thirty and one)
|
|
if (decenas >= 3 && unidades >= 1) {
|
|
string_tens = string_tens + " y ";
|
|
}
|
|
|
|
// this line gathers all the hundreds, tens and units into the final string
|
|
// and returns it as the function value.
|
|
final_string = string_hundreds + string_tens + string_units;
|
|
|
|
|
|
return final_string;
|
|
|
|
} //end of function string_literal_conversion()================================
|
|
|
|
// handle some external special cases. Specially the millions, thousands
|
|
// and hundreds descriptors. Since the same rules apply to all number triads
|
|
// descriptions are handled outside the string conversion function, so it can
|
|
// be re used for each triad.
|
|
|
|
|
|
function covertirNumLetras(number) {
|
|
|
|
//number = number_format (number, 2);
|
|
number1 = number + '';
|
|
cent = number1.split(".");
|
|
centavos = cent[1];
|
|
number = cent[0];
|
|
|
|
if (centavos == 0 || centavos == undefined) {
|
|
centavos = "00";
|
|
}
|
|
|
|
if (number == 0 || number == "" || number == undefined) { // if amount = 0, then forget all about conversions,
|
|
centenas_final_string = " cero "; // amount is zero (cero). handle it externally, to
|
|
millions_final_string = "";
|
|
thousands_final_string = "";
|
|
// function breakdown
|
|
}
|
|
else {
|
|
millions = ObtenerParteEntDiv(number, 1000000); // first, send the millions to the string
|
|
number = mod(number, 1000000); // conversion function
|
|
|
|
if (millions != 0) {
|
|
// This condition handles the plural case
|
|
if (millions == 1) { // if only 1, use 'millon' (million). if
|
|
descriptor = " millon "; // > than 1, use 'millones' (millions) as
|
|
}
|
|
else { // a descriptor for this triad.
|
|
descriptor = " millones ";
|
|
}
|
|
}
|
|
else {
|
|
descriptor = " "; // if 0 million then use no descriptor.
|
|
}
|
|
millions_final_string = string_literal_conversion(millions) + descriptor;
|
|
|
|
thousands = ObtenerParteEntDiv(number, 1000); // now, send the thousands to the string
|
|
number = mod(number, 1000); // conversion function.
|
|
//print "Th:".thousands;
|
|
if (thousands != 1) { // This condition eliminates the descriptor
|
|
thousands_final_string = string_literal_conversion(thousands) + " mil ";
|
|
// descriptor = " mil "; // if there are no thousands on the amount
|
|
}
|
|
if (thousands == 1) {
|
|
thousands_final_string = " mil ";
|
|
}
|
|
if (thousands < 1) {
|
|
thousands_final_string = " ";
|
|
}
|
|
// this will handle numbers between 1 and 999 which
|
|
// need no descriptor whatsoever.
|
|
|
|
centenas = number;
|
|
centenas_final_string = string_literal_conversion(centenas);
|
|
|
|
} //end if (number ==0)
|
|
|
|
/*if (ereg("un",centenas_final_string))
|
|
{
|
|
centenas_final_string = ereg_replace("","o",centenas_final_string);
|
|
}*/
|
|
//finally, print the output.
|
|
|
|
/* Concatena los millones, miles y cientos*/
|
|
cad = millions_final_string + thousands_final_string + centenas_final_string;
|
|
|
|
/* Convierte la cadena a Mayúsculas*/
|
|
cad = cad.toUpperCase();
|
|
|
|
if (centavos.length > 2) {
|
|
if (centavos.substring(2, 3) >= 5) {
|
|
centavos = centavos.substring(0, 1) + (parseInt(centavos.substring(1, 2)) + 1).toString();
|
|
} else {
|
|
centavos = centavos.substring(0, 2);
|
|
}
|
|
}
|
|
/* Concatena a los centavos la cadena "/100" */
|
|
if (centavos.length == 1) {
|
|
centavos = centavos + "0";
|
|
}
|
|
centavos = centavos + "/100";
|
|
|
|
|
|
/* Asigna el tipo de moneda, para 1 = PESO, para distinto de 1 = PESOS*/
|
|
if (number == 1) {
|
|
moneda = " PESO ";
|
|
}
|
|
else {
|
|
moneda = " PESOS ";
|
|
}
|
|
/* Regresa el número en cadena entre paréntesis y con tipo de moneda y la fase M.N.*/
|
|
//alert("FINAL=" + cad + moneda + centavos + " 00/100 M.N. )");
|
|
|
|
return (cad + moneda + centavos);
|
|
}
|
|
|
|
|
|
function FormatNumber(num, decimalNum, bolLeadingZero, bolParens, bolCommas) {
|
|
if (isNaN(parseInt(num))) return "NaN";
|
|
|
|
var tmpNum = num;
|
|
var iSign = num < 0 ? -1 : 1; // Get sign of number
|
|
|
|
// Adjust number so only the specified number of numbers after
|
|
// the decimal point are shown.
|
|
tmpNum *= Math.pow(10, decimalNum);
|
|
tmpNum = Math.round(Math.abs(tmpNum))
|
|
tmpNum /= Math.pow(10, decimalNum);
|
|
tmpNum *= iSign; // Readjust for sign
|
|
|
|
|
|
// Create a string object to do our formatting on
|
|
var tmpNumStr = new String(tmpNum);
|
|
|
|
// See if we need to strip out the leading zero or not.
|
|
if (!bolLeadingZero && num < 1 && num > -1 && num != 0)
|
|
if (num > 0)
|
|
tmpNumStr = tmpNumStr.substring(1, tmpNumStr.length);
|
|
else
|
|
tmpNumStr = "-" + tmpNumStr.substring(2, tmpNumStr.length);
|
|
|
|
// See if we need to put in the commas
|
|
if (bolCommas && (num >= 1000 || num <= -1000)) {
|
|
var iStart = tmpNumStr.indexOf(".");
|
|
if (iStart < 0)
|
|
iStart = tmpNumStr.length;
|
|
|
|
iStart -= 3;
|
|
while (iStart >= 1) {
|
|
tmpNumStr = tmpNumStr.substring(0, iStart) + "," + tmpNumStr.substring(iStart, tmpNumStr.length);
|
|
iStart -= 3;
|
|
}
|
|
}
|
|
|
|
// See if we need to use parenthesis
|
|
if (bolParens && num < 0)
|
|
tmpNumStr = "(" + tmpNumStr.substring(1, tmpNumStr.length) + ")";
|
|
|
|
return tmpNumStr; // Return our formatted string!
|
|
}
|
|
|
|
function FormatoNumero(Importe, Decimales) {
|
|
if (isNaN(parseInt(Importe))) return "NaN";
|
|
Decimales = Decimales || 2; // parametro opcional, toma el valor 2 por default
|
|
// var tmpNum = Importe;
|
|
|
|
|
|
//var tmpNum = parseFloat(Importe).toFixed(Decimales) //se comenta por el redondeo de $3037.095
|
|
var tmpNum = +(Math.round(Importe + "e+" + Decimales) + "e-" + Decimales);
|
|
tmpNum = Number(tmpNum).toLocaleString('en');
|
|
|
|
//tmpNum = tmpNum.toFixed(2).replace(/./g, function (c, i, a) {
|
|
// return i && c !== "." && !((a.length - i) % 3) ? ',' + c : c;
|
|
//});
|
|
|
|
return tmpNum;
|
|
}
|
|
|
|
|
|
jQuery.fn.center = function() {
|
|
this.css("position", "absolute");
|
|
var widthh = $(this).width();
|
|
var heighth = $(this).height();
|
|
this.css("top", ($(window).height() - heighth) / 2 + $(window).scrollTop() + "px");
|
|
this.css("left", ($(window).width() / 2) - widthh + $(window).scrollLeft() + "px");
|
|
return this;
|
|
};
|
|
|
|
// override selector jquery 'contains' , busca en case insensitive
|
|
jQuery.expr[':'].contains = function (a, i, m) {
|
|
return jQuery(a).text().toUpperCase()
|
|
.indexOf(m[3].toUpperCase()) >= 0;
|
|
};
|
|
(function ($) {
|
|
jQuery.fn.extend({
|
|
|
|
ADScroll: function (options) {
|
|
var Alto = $(window).height(); -300;
|
|
if (Alto < 100) {
|
|
Alto = 100;
|
|
}
|
|
var defaults = {
|
|
height: Alto
|
|
};
|
|
var opt = $.extend(defaults, options);
|
|
|
|
if (!($($(this).parent()).hasClass("table-VH-container"))) {
|
|
var tablita = $(this);
|
|
var tablaid = tablita.attr('id');
|
|
var dataVScroll = tablita.data('adsvertical');
|
|
function createScrollbar() {
|
|
$('#' + tablaid + ' tr:first th').each(function (index) {
|
|
$(this).html("<div>" + $(this).html() + "</div>");
|
|
});
|
|
var verticalmargin = 0;
|
|
var style = "";
|
|
var cssclass = "";
|
|
if (dataVScroll) {
|
|
verticalmargin = $('table[data-adsvertical="1"] tr:first-child td:first-child').width();
|
|
style = 'padding-left:' + verticalmargin + 'px;';
|
|
cssclass = "ADVScroll";
|
|
}
|
|
var contenedor = $('<div class="table-VH"></div>');
|
|
var body = $('<div class="table-VH-container ' + cssclass + '" style="max-height:' + opt.height + 'px; ' + style + '"></div>');
|
|
tablita.before(contenedor);
|
|
contenedor.append(body);
|
|
body.append(tablita);
|
|
//limpio variables
|
|
contenedor = null;
|
|
body = null;
|
|
verticalmargin = null;
|
|
style = null;
|
|
cssclass = null;
|
|
//end limpio variables
|
|
}
|
|
|
|
createScrollbar();
|
|
//limpio variables why? nomas
|
|
tablita = null;
|
|
tablaid = null;
|
|
Alto = null;
|
|
}
|
|
}
|
|
});
|
|
jQuery.fn.extend({
|
|
ADScroll: jQuery.fn.ADScroll
|
|
});
|
|
})(jQuery); |