|
|
(function ($) { "use strict";
/*================================================================== [ Focus input ]*/ $('.input100').each(function(){ $(this).on('blur', function(){ if($(this).val().trim() != "") { $(this).addClass('has-val'); } else { $(this).removeClass('has-val'); } }) }) /*================================================================== [ Validate ]*/ var input = $('.validate-input .input100');
$('.validate-form').on('submit',function(){ var check = true;
for(var i=0; i<input.length; i++) { if(validate(input[i]) == false){ showValidate(input[i]); check=false; } }
return check; });
$('.validate-form .input100').each(function(){ $(this).focus(function(){ hideValidate(this); }); });
function validate (input) { if($(input).attr('type') == 'email' || $(input).attr('name') == 'email') { if($(input).val().trim().match(/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{1,5}|[0-9]{1,3})(\]?)$/) == null) { return false; } } else { if($(input).val().trim() == ''){ return false; } } }
function showValidate(input) { var thisAlert = $(input).parent();
$(thisAlert).addClass('alert-validate'); }
function hideValidate(input) { var thisAlert = $(input).parent();
$(thisAlert).removeClass('alert-validate'); } /*================================================================== [ Show pass ]*/ var showPass = 0; $('.btn-show-pass').on('click', function(){ if(showPass == 0) { $(this).next('input').attr('type','text'); $(this).addClass('active'); showPass = 1; } else { $(this).next('input').attr('type','password'); $(this).removeClass('active'); showPass = 0; } });
})(jQuery);
/* VARIABLES GLOBALES PARA FUNCIONAMIENTO DE SCRIPT*************************************************************************/ var lista_de_piletas = []; var lista_de_detalles_de_piletas; var lista_de_resultados;
/* PATH PARA USAR AJAX EN EL SCRIPT***************************************************/ //var path_piletas = "../ejemplo.json";
var path_piletas = "../prgdmug/saldos.php";
//var path_totales = "../totales.json";
var path_totales = "../prgdmug/totales.php";
//var path_detalles = "../detalles.json";
var path_detalles = "../prgdmug/detalles.php";
//var path_busqueda_por_totales= "../ejemplo.json";
var path_busqueda_por_totales = "../prgdmug/productos.php";
var path_busqueda = "../prgdmug/busqueda.php";
var path_stocks = "../prgdmug/stocks.php";
/* MOVIMIENTO DE BARRA PILETAS*************************************************************************/ /*function move(id2,valor) { var elem = document.getElementById(id2); var height = 0; var alturaABAJO = valor; var alturaARRIBA = 100-alturaABAJO; var id = setInterval(frame, 10); function frame() { if (height >= alturaARRIBA) { clearInterval(id); elem.innerHTML = (100-height) * 1 + '%'; } else { height++; elem.style.height = height + '%'; elem.innerHTML = (100-height) * 1 + '%'; } } }*/ function move(id2,valor) { var elem = document.getElementById(id2); var height = 101; /*altura total del div*/
if(valor > 100){ valor = 100; } var alturaARRIBA = 100-valor; /*altura a la que debe quedar el div*/
var id = setInterval(frame, 10); function frame() { if(height <= alturaARRIBA){ clearInterval(id); elem.innerHTML = (100-height) * 1 + '%'; } else { height--; elem.style.height = height + '%'; elem.innerHTML = (100-height) * 1 + '%'; } } }
/* FORMATO PARA NUMEROS*************************************************************************/ function number_format(amount, decimals) { amount += ''; // por si pasan un numero en vez de un string
amount = parseFloat(amount.replace(/[^0-9\.]/g, '')); // elimino cualquier cosa que no sea numero o punto
decimals = decimals || 0; // por si la variable no fue fue pasada
// si no es un numero o es igual a cero retorno el mismo cero
if (isNaN(amount) || amount === 0) return parseFloat(0).toFixed(decimals); // si es mayor o menor que cero retorno el valor formateado como numero
amount = '' + amount.toFixed(decimals); var amount_parts = amount.split('.'), regexp = /(\d+)(\d{3})/; while (regexp.test(amount_parts[0])) amount_parts[0] = amount_parts[0].replace(regexp, '$1' + '.' + '$2'); return amount_parts.join('.'); }
/* DESPLEGAR RESULTADO DE BUSQUEDA DE PILETAS*************************************************************************/
function buscar_lista_de_piletas(datos){ //menues
$("#piletasOption").hide();$("#totalesOption").show();$("#buscarPiletas").show(); //loader
$(".container-login100").addClass(".altoTotal"); $("#myContent").empty(); $(".wrap-login100").hide(); $("#myPreContent").show();
//console.log(datos);
$.ajax({url: path_busqueda_por_totales, type: 'POST', data: datos, dataType: 'json', success: function(response){ lista_de_piletas = response.pileta;
//console.log("El tag pileta es array: "+Array.isArray(response.pileta));
//console.log("La cantidad de piletas es: "+response.pileta.length);
//alert(response.pileta[0].desc);
// alert(lista_de_piletas[0].desc);
var valor =[]; var miKey =[]; $(".wrap-login100").show(); $("#myPreContent").hide(); $(".container-login100").removeClass(".altoTotal"); if(Array.isArray(response.pileta)){ for (var i = 0; i < response.pileta.length ; i++){
var headerList = '<div class="row myItem entrar" id="item-'+response.pileta[i].id+'"><div class="col-2 myProgress"><div class="myBar" id="myBar'+i+'"></div></div><div class="col-10"> <div class=" row"> <h5 class=" col-10 myItem-title">'+response.pileta[i].desc+'</h5> <h4 class=" col-2 myItem-title">'+response.pileta[i].id+'</h4>'; headerList +='<div class="col-3 myItem-element"> <div class="row"><small class="col-12 " style="color: #6c757d;" >saldo:</small><small class=" col-12 text-left text-nowrap "><b>'+number_format(response.pileta[i].saldo, 0)+'</b></small></div></div>'; headerList +='<div class="col-3 myItem-element"> <div class="row"><small class="col-12 " style="color: #6c757d;" >azucar:</small><small class=" col-12 text-left">'+response.pileta[i].azucar+'</small></div></div>'; headerList +='<div class="col-3 myItem-element"> <div class="row"><small class="col-12 " style="color: #6c757d;" >alcohol:</small><small class=" col-12 text-left">'+response.pileta[i].alcohol+'</small></div></div>'; headerList +='<div class="col-3 myItem-element"> <div class="row"><small class="col-12 " style="color: #6c757d;" >acvol:</small><small class=" col-12 text-left">'+response.pileta[i].acvol+'</small></div></div>'; $("#myContent").append(headerList);
valor[i] = (response.pileta[i].saldo*100)/response.pileta[i].cap; miKey[i] = 'myBar'+i; } for(var i = 0; i < response.pileta.length ; i++){ move(miKey[i],valor[i]); } }else{ var headerList = '<div class="row myItem entrar" id="item-'+response.pileta.id+'"><div class="col-2 myProgress"><div class="myBar" id="myBar0"></div></div><div class="col-10"> <div class=" row"> <h5 class=" col-10 myItem-title">'+response.pileta.desc+'</h5> <h4 class=" col-2 myItem-title">'+response.pileta.id+'</h4>'; headerList +='<div class="col-3 myItem-element"> <div class="row"><small class="col-12 " style="color: #6c757d;">saldo:</small><small class=" col-12 text-left text-nowrap "><b>'+number_format(response.pileta.saldo, 0)+'</b></small></div></div>'; headerList +='<div class="col-3 myItem-element"> <div class="row"><small class="col-12 " style="color: #6c757d;">azucar:</small><small class=" col-12 text-left">'+response.pileta.azucar+'</small></div></div>'; headerList +='<div class="col-3 myItem-element"> <div class="row"><small class="col-12 " style="color: #6c757d;">alcohol:</small><small class=" col-12 text-left">'+response.pileta.alcohol+'</small></div></div>'; headerList +='<div class="col-3 myItem-element"> <div class="row"><small class="col-12 " style="color: #6c757d;">acvol:</small><small class=" col-12 text-left">'+response.pileta.acvol+'</small></div></div>'; $("#myContent").append(headerList);
valor[0] = (response.pileta.saldo*100)/response.pileta.cap; miKey[0] = 'myBar0'; move(miKey[0],valor[0]); }
$(".myItem").click(function(){ var oID = $(this).attr("id"); var res = oID.split("-"); if(!document.getElementById( "details-"+res[1])){ var parametros = { "pileta" : res[1] }; crear_detalles_de_pileta(parametros, $(this)); } }); }}); }
function menuTogle(){ $("#myMenuIcon").toggleClass("menuIcon"); $("#myMenuIcon").toggleClass("cancelIcon"); $("#myNavy").toggle(); $("#myMenuDiv").toggleClass("backBlack"); }
$("#myMenuDiv").click(function(){ menuTogle(); }); $(".nav-item").click(function(){ menuTogle(); });
/* DESPLEGAR TOTALES*************************************************************************/
function crear_lista_de_totales(){ $("#totalesOption").hide();$("#piletasOption").show();$("#buscarPiletas").hide(); //loader
$(".container-login100").addClass(".altoTotal"); $("#myContent").empty(); $(".wrap-login100").hide(); $("#myPreContent").show(); var total_de_mosto, total_de_vino, lista_de_totales, nodo_aux; var lista_de_mosto= ''; var lista_de_vino= '';
$.ajax({url: path_totales, type: 'POST', dataType: 'json', success: function(response){ lista_de_totales = response.total;
/* quito efecto del loader y muestro container*/ $(".container-login100").removeClass(".altoTotal"); $("#myPreContent").hide();; $(".wrap-login100").show();
for (let i = 0; i < response.total.length; i++) {
nodo_aux = '<div class="row myTotalItem entrar totalItemContainer" id="'+response.total[i].codtipo+'|'+response.total[i].codcateg+'">'; if (response.total[i].tipo === 'Mosto') { if(response.total[i].categ === 'TODO'){ nodo_aux += '<h5 class=" col-12 " style="height: 40px; background-color: #339933; color: white; border-top-right-radius: 15px; padding-top:5px;">Totales de '+response.total[i].tipo+' - '+response.total[i].categ+'</h5>'; }else{ nodo_aux += '<h5 class=" col-12 " style="height: 40px; background-color: #9fdf9f; border-top-right-radius: 15px; padding-top:5px;">Totales de '+response.total[i].tipo+' - '+response.total[i].categ+'</h5>'; } } if (response.total[i].tipo === 'Vino') { if(response.total[i].categ === 'TODO'){ nodo_aux += '<h5 class=" col-12 " style="height: 40px; background-color: #0033cc; color: white; border-top-right-radius: 15px; padding-top:5px;">Totales de '+response.total[i].tipo+' - '+response.total[i].categ+'</h5>'; }else{ nodo_aux += '<h5 class=" col-12 " style="height: 40px; background-color: #99b3ff; border-top-right-radius: 15px; padding-top:5px;">Totales de '+response.total[i].tipo+' - '+response.total[i].categ+'</h5>'; } } nodo_aux += '<div class="col-12 col-sm-12 totalItem" style="color: #6c757d; height:30px;" >'; nodo_aux += '<small class="" style="">cantidad: </small>'; nodo_aux += '<small class=" valueSmall" style="position: relative;">'+number_format((parseFloat(response.total[i].cant)/100), 0)+'</small></div>'; nodo_aux += '<div class="col-6 col-sm-3 totalItem" style="color: #6c757d; height:30px;" >'; nodo_aux += '<small>azucar: </small>'; nodo_aux += '<small class="valueSmall">'+response.total[i].azucar+'</small></div>'; nodo_aux += '<div class="col-6 col-sm-3 totalItem" style="color: #6c757d; height:30px;" >'; nodo_aux += '<small>alco: </small>'; nodo_aux += '<small class="valueSmall">'+response.total[i].alco+'</small></div>'; nodo_aux += '<div class="col-6 col-sm-3 totalItem" style="color: #6c757d; height:30px;" >'; nodo_aux += '<small>acidez: </small>'; nodo_aux += '<small class="valueSmall">'+response.total[i].acidez+'</small></div>'; nodo_aux += '<div class="col-6 col-sm-3 totalItem" style="color: #6c757d; height:30px;" >'; nodo_aux += '<small>ph: </small>'; nodo_aux += '<small class="valueSmall">'+response.total[i].ph+'</small></div>'; nodo_aux += '<div class="col-6 col-sm-3 totalItem" style="color: #6c757d; height:30px;" >'; nodo_aux += '<small>acvol: </small>'; nodo_aux += '<small class="valueSmall">'+response.total[i].acvol+'</small></div>'; nodo_aux += '<div class="col-6 col-sm-3 totalItem" style="color: #6c757d; height:30px;" >'; nodo_aux += '<small>so2l: </small>'; nodo_aux += '<small class="valueSmall">'+response.total[i].so2l+'</small></div>'; nodo_aux += '<div class="col-6 col-sm-3 totalItem" style="color: #6c757d; height:30px;" >'; nodo_aux += '<small>so2t: </small>'; nodo_aux += '<small class="valueSmall">'+response.total[i].so2t+'</small></div>'; nodo_aux += '<div class="col-6 col-sm-3 totalItem" style="color: #6c757d; height:30px;" >'; nodo_aux += '<small>col420: </small>'; nodo_aux += '<small class="valueSmall">'+response.total[i].col420+'</small></div>'; nodo_aux += '<div class="col-6 col-sm-3 totalItem" style="color: #6c757d; height:30px;" >'; nodo_aux += '<small>col520: </small>'; nodo_aux += '<small class="valueSmall">'+response.total[i].col520+'</small></div>'; nodo_aux += '<div class="col-6 col-sm-3 totalItem" style="color: #6c757d; height:30px;" >'; nodo_aux += '<small>colsum: </small>'; nodo_aux += '<small class="valueSmall">'+response.total[i].colsum+'</small></div>'; nodo_aux += '<div class="col-6 col-sm-3 totalItem" style="color: #6c757d; height:30px;" >'; nodo_aux += '<small>colmat: </small>'; nodo_aux += '<small class="valueSmall">'+response.total[i].colmat+'</small></div>'; nodo_aux += '<div class="col-6 col-sm-3 totalItem" style="color: #6c757d; height:30px;" >'; nodo_aux += '<small>colind: </small>'; nodo_aux += '<small class="valueSmall">'+response.total[i].colind+'</small></div>'; nodo_aux += '</div>'; if (response.total[i].tipo === 'Mosto') { if(response.total[i].categ === 'TODO'){ total_de_mosto = nodo_aux; }else{ lista_de_mosto += nodo_aux; } } if (response.total[i].tipo === 'Vino') { if(response.total[i].categ === 'TODO'){ total_de_vino += nodo_aux; }else{ lista_de_vino += nodo_aux; } } } $("#myContent").append(lista_de_mosto); $("#myContent").append(total_de_mosto); $("#myContent").append(lista_de_vino); $("#myContent").append(total_de_vino);
$(".myTotalItem").click(function(){ var oID = $(this).attr("id"); var res = oID.split("|"); var parametros = { "codtipo" : res[0], "codcateg" : res[1] }; buscar_lista_de_piletas(parametros); }); } }); }
/* DESPLEGAR DETALLES DE PILETAS*************************************************************************/
function crear_detalles_de_pileta(nro,ido){ $.ajax({url: path_detalles, type: 'POST', data: nro, dataType: 'json', success: function(response){ //console.log(response.detalle);
var nodos = document.getElementsByClassName("salir"); if(nodos.length>0){ for(var i = 0 ; i < nodos.length ; i++){ nodos[i].remove(); } } /*ARMO PANTALLA*/ var detallesList = '<div class="col-12 myItem-details salir" style="" id="details-'+nro+'">'; detallesList += '<div class="row myItem-details-row">';
detallesList += '<div class="col-6 col-sm-4">'; detallesList += '<small style="color: #6c757d;">cap: </small>'; var cap_number = parseInt(response.detalle.cap, 10); detallesList += '<small class="valueSmall2">'+number_format(cap_number, 0)+'</small></div>';
detallesList += '<div class="col-6 col-sm-4">'; detallesList += '<small style="color: #6c757d;">saldo: </small>'; var saldo_number = parseInt(response.detalle.saldo, 10); detallesList += '<small class="valueSmall2"><b>'+(number_format(saldo_number, 0))+'</b></small></div>';
detallesList += '<div class="col-6 col-sm-4">'; detallesList += '<small style="color: #6c757d;">alco: </small>'; detallesList += '<small class="valueSmall2">'+response.detalle.alco+'</small></div>'; detallesList += '<div class="col-6 col-sm-4">'; detallesList += '<small style="color: #6c757d;">azucar: </small>'; detallesList += '<small class="valueSmall2">'+response.detalle.azucar+'</small></div>';
detallesList += '<div class="col-6 col-sm-4">'; detallesList += '<small style="color: #6c757d;">acidez: </small>'; detallesList += '<small class="valueSmall2">'+response.detalle.acidez+'</small></div>';
detallesList += '<div class="col-6 col-sm-4">'; detallesList += '<small style="color: #6c757d;">ph: </small>'; detallesList += '<small class="valueSmall2">'+response.detalle.ph+'</small></div>'; detallesList += '<div class="col-6 col-sm-4">'; detallesList += '<small style="color: #6c757d;">acvol: </small>'; detallesList += '<small class="valueSmall2">'+response.detalle.acvol+'</small></div>';
detallesList += '<div class="col-6 col-sm-4">'; detallesList += '<small style="color: #6c757d;">so2l: </small>'; detallesList += '<small class="valueSmall2">'+response.detalle.so2l+'</small></div>'; detallesList += '<div class="col-6 col-sm-4">'; detallesList += '<small style="color: #6c757d;">so2t: </small>'; detallesList += '<small class="valueSmall2">'+response.detalle.so2t+'</small></div>'; detallesList += '<div class="col-6 col-sm-4">'; detallesList += '<small style="color: #6c757d;">col420: </small>'; detallesList += '<small class="valueSmall2">'+response.detalle.col420+'</small></div>';
detallesList += '<div class="col-6 col-sm-4">'; detallesList += '<small style="color: #6c757d;">col520: </small>'; detallesList += '<small class="valueSmall2">'+response.detalle.col520+'</small></div>'; detallesList += '<div class="col-6 col-sm-4">'; detallesList += '<small style="color: #6c757d;">colsum: </small>'; detallesList += '<small class="valueSmall2">'+response.detalle.colsum+'</small></div>'; detallesList += '<div class="col-6 col-sm-4">'; detallesList += '<small style="color: #6c757d;">colmat: </small>'; detallesList += '<small class="valueSmall2">'+response.detalle.colmat+'</small></div>';
detallesList += '<div class="col-6 col-sm-4">'; detallesList += '<small style="color: #6c757d;">colind: </small>'; detallesList += '<small class="valueSmall2">'+response.detalle.colind+'</small></div>'; detallesList += '</div></div>'; ido.after(detallesList); $(".myItem-details").click(function(){ $(this).remove(); }); } }); }
/* DESPLEGAR LISTA DE PILETAS *************************************************************************/
function crear_lista_de_piletas(){ $("#piletasOption").hide();$("#totalesOption").show(); $("#buscarPiletas").show(); //loader
$(".container-login100").addClass(".altoTotal"); $("#myContent").empty(); $(".wrap-login100").hide(); $("#myPreContent").show();
$.ajax({url: path_piletas, type: 'POST', dataType: 'json', success: function(response){ lista_de_piletas = response.pileta; //console.log(response);
var valor =[]; var miKey =[]; $(".container-login100").removeClass(".altoTotal"); $("#myPreContent").hide();; $(".wrap-login100").show(); for (var i = 0; i < response.pileta.length ; i++){
var headerList = '<div class="row myItem entrar" id="item-'+response.pileta[i].id+'">'; headerList +='<div class="col-2 myProgress">'; headerList +='<div class="myBar" id="myBar'+i+'"></div></div>'; headerList +='<div class="col-10"> <div class=" row"> <h5 class=" col-10 myItem-title">'+response.pileta[i].desc+'</h5> <h4 class=" col-2 myItem-title">'+response.pileta[i].id+'</h4>';
headerList +='<div class="col-4 col-sm-2 myItem-element"> <div class="row"><small class="col-12 " style="color: #6c757d;">saldo:</small><small class=" col-12 text-left text-nowrap "><b>'+number_format(response.pileta[i].saldo, 0)+'</b></small></div></div>'; headerList +='<div class="col-4 col-sm-2 myItem-element"> <div class="row"><small class="col-12 " style="color: #6c757d;">azucar:</small><small class=" col-12 text-left">'+response.pileta[i].azucar+'</small></div></div>'; headerList +='<div class="col-4 col-sm-2 myItem-element"> <div class="row"><small class="col-12 " style="color: #6c757d;">alcohol:</small><small class=" col-12 text-left">'+response.pileta[i].alcohol+'</small></div></div>'; headerList +='<div class="col-6 col-sm-2 myItem-element"> <div class="row"><small class="col-12 " style="color: #6c757d;">acvol:</small><small class=" col-12 text-left">'+response.pileta[i].acvol+'</small></div></div>'; headerList +='<div class="col-6 col-sm-3 myItem-element"> <div class="row"><small class="col-12 " style="color: #6c757d;">ulmov.:</small><small class=" col-12 text-left">'+response.pileta[i].ulmov+'</small></div></div>'; $("#myContent").append(headerList);
valor[i] = (response.pileta[i].saldo*100)/response.pileta[i].cap; miKey[i] = 'myBar'+i; } for(var i = 0; i < response.pileta.length ; i++){ move(miKey[i],valor[i]); }
$(".myItem").click(function(){ var oID = $(this).attr("id"); var res = oID.split("-"); if(!document.getElementById( "details-"+res[1])){ var parametros = { "pileta" : res[1] }; crear_detalles_de_pileta(parametros, $(this)); } }); }}); }
$("#buscarPiletas").click(function(){ //$("#myQuest").toggleClass("invisible");
$("#myQuest").toggle(); }); $("#cerrarQuest").click(function(){ //$("#myQuest").toggleClass("invisible");
$("#myQuest").toggle(); });
/* ELEMENTOS DEL FORMULARIO BUSQUEDA ***********************************************************************************/ function agreagar_options_quest(obj){ while (obj.hasChildNodes()) { obj.removeChild(obj.firstChild); } var nombres = []; var agregar_item=" "; var misCampos = document.getElementsByClassName("selectColection"); for (i = 0; i < misCampos.length; i++) { //console.log(misCampos[i].value) ;
nombres.push (misCampos[i].value); } if (nombres.indexOf("alcohol") < 0) { agregar_item += '<option value="alcohol">Alcohol</option>';} if (nombres.indexOf("azucar") < 0) { agregar_item += '<option value="azucar">Azúcar</option>';} if (nombres.indexOf("acidez") < 0) { agregar_item += '<option value="acidez">Acidez</option>';} if (nombres.indexOf("ph") < 0) { agregar_item += '<option value="ph">Ph</option>';} if (nombres.indexOf("acvol") < 0) { agregar_item += '<option value="acvol">Volatil</option>';} if (nombres.indexOf("so2l") < 0) { agregar_item += '<option value="so2l">So2l</option>';} if (nombres.indexOf("so2t") < 0) { agregar_item += '<option value="so2t">So2t</option>';} if (nombres.indexOf("colsum") < 0) { agregar_item += '<option value="colsum">Colsum</option>';} if (nombres.indexOf("colmat") < 0) { agregar_item += '<option value="colmat">Colmat</option>';} if (nombres.indexOf("colin") < 0) { agregar_item += '<option value="colin">Colind</option>'; } $(obj).append(agregar_item); }
function agregar_item_quest(cant_item){
cant_item=cant_item+1; var agregar_item = '<form class="myFormQuest row" id="mySubFormQuest-'+cant_item+'">'; // agregar_item += '<select class=" form-control form-control-sm col-3 selectColection" id="myItemQuest-'+cant_item+'-1" name="campo" onclick="agreagar_options_quest(this)">';
agregar_item += '<select class=" form-control form-control-sm col-3 selectColection" id="myItemQuest-'+cant_item+'-1" name="campo" >'; var misCampos = document.getElementsByClassName("selectColection"); var nombres = []; for (i = 0; i < misCampos.length; i++) { //console.log(misCampos[i].value) ;
nombres.push (misCampos[i].value); } if (nombres.indexOf("alcohol") < 0) { agregar_item += '<option value="alcohol">Alcohol</option>';} if (nombres.indexOf("azucar") < 0) { agregar_item += '<option value="azucar">Azúcar</option>';} if (nombres.indexOf("acidez") < 0) { agregar_item += '<option value="acidez">Acidez</option>';} if (nombres.indexOf("ph") < 0) { agregar_item += '<option value="ph">Ph</option>';} if (nombres.indexOf("acvol") < 0) { agregar_item += '<option value="acvol">Volatil</option>';} if (nombres.indexOf("so2l") < 0) { agregar_item += '<option value="so2l">So2l</option>';} if (nombres.indexOf("so2t") < 0) { agregar_item += '<option value="so2t">So2t</option>';} if (nombres.indexOf("colsum") < 0) { agregar_item += '<option value="colsum">Colsum</option>';} if (nombres.indexOf("colmat") < 0) { agregar_item += '<option value="colmat">Colmat</option>';} if (nombres.indexOf("colin") < 0) { agregar_item += '<option value="colin">Colind</option>'; }
/* agregar_item += '<option value="alcohol">Alcohol</option>'; agregar_item += '<option value="azucar">Azúcar</option>'; agregar_item += '<option value="acidez">Acidez</option>'; agregar_item += '<option value="ph">Ph</option>'; agregar_item += '<option value="acvol">Volatil</option>'; agregar_item += '<option value="so2l">So2l</option>'; agregar_item += '<option value="so2t">So2t</option>'; agregar_item += '<option value="colsum">Colsum</option>'; agregar_item += '<option value="colmat">Colmat</option>'; agregar_item += '<option value="colin">Colind</option>'; */ agregar_item += '</select>'; agregar_item += '<select class="form-control form-control-sm col-4" id="myItemQuest-'+cant_item+'-2" name="operador">'; agregar_item += '<optionvalue="0">igual que</option><option value="2">mayor que</option><option value="4">menor que</option><option value="1">distinto que</option></select>'; agregar_item += '<input type="text" class="form-control form-control-sm col-3 col-sm-4" id="myItemQuest-'+cant_item+'-3" name="valor" placeholder="000.00">'; agregar_item += '<div class=" col-1 quitarFiltro" id="myItemQuest-'+cant_item+'-3" onclick="quitar_item_quest(this)"> -</div></form>';
$("#questingThings").append(agregar_item); return cant_item; }
function quitar_item_quest(obj){ var oID = obj.attributes[1].value; var res = oID.split("-"); var parent = document.getElementById("questingThings"); var child = document.getElementById("mySubFormQuest-"+res[1]); parent.removeChild(child); } function validar_input_isNum(){ var elems = document.body.getElementsByTagName("input"); var flag = true; for(i = 0; i < elems.length; i++) { var valor = elems[i].value; var res = valor.match(/^[0-9]+([.][0-9]+)?$/); if(!res) { flag = false; } } if(flag==false) alert("Los campos de entrada solo pueden tener números con el formato (000.00) y no deben estar vacíos"); return flag; }
function busqueda_de_filtros(){
var elems = document.body.getElementsByTagName("form"); var parametros = "{"; for(i = 0; i < elems.length; i++) { var aux = (elems[i].id).split("-"); var campoi = document.getElementById("myItemQuest-"+aux[1]+"-1").value; var operator = document.getElementById("myItemQuest-"+aux[1]+"-2").value; var values = document.getElementById("myItemQuest-"+aux[1]+"-3").value; var myObj = {campo: campoi, operador: operator, valor: values}; if (i==0) { parametros += '"'+i+'":'+JSON.stringify(myObj); }else{ parametros += ',"'+i+'":'+JSON.stringify(myObj); } //console.log(parametros);
} parametros += "}"; parametros2 = JSON.parse(parametros); /* var parametros = new Object(); for(i = 0; i < elems.length; i++) { var aux = (elems[i].id).split("-"); var campoi = document.getElementById("myItemQuest-"+aux[1]+"-1").value; var operator = document.getElementById("myItemQuest-"+aux[1]+"-2").value; var values = document.getElementById("myItemQuest-"+aux[1]+"-3").value; var myObj = {campo: campoi, operador: operator, valor: values}; parametros.i= myObj; } */ /* var parametros= { "codtipo" : res[0], "codcateg" : res[1] }; */ // console.log(parametros2);
//loader
$(".container-login100").addClass(".altoTotal"); $("#myContent").empty(); $(".wrap-login100").hide(); $("#myPreContent").show(); $("#myQuest").hide(); $.ajax({url: path_busqueda, type: 'POST', data: parametros2, dataType: 'json', success: function(response){ lista_de_piletas = response.pileta; // console.log(lista_de_piletas);
var valor =[]; var miKey =[]; $(".wrap-login100").show(); $("#myPreContent").hide(); $(".container-login100").removeClass(".altoTotal"); if(Array.isArray(response.pileta)){ for (var i = 0; i < response.pileta.length ; i++){
var headerList = '<div class="row myItem entrar" id="item-'+response.pileta[i].id+'"><div class="col-2 myProgress"><div class="myBar" id="myBar'+i+'"></div></div><div class="col-10"> <div class=" row"> <h5 class=" col-10 myItem-title">'+response.pileta[i].desc+'</h5> <h4 class=" col-2 myItem-title">'+response.pileta[i].id+'</h4>'; headerList +='<div class="col-3 myItem-element"> <div class="row"><small class="col-12 " style="color: #6c757d;" >saldo:</small><small class=" col-12 text-left text-nowrap "><b>'+number_format(response.pileta[i].saldo, 0)+'</b></small></div></div>'; headerList +='<div class="col-3 myItem-element"> <div class="row"><small class="col-12 " style="color: #6c757d;" >azucar:</small><small class=" col-12 text-left">'+response.pileta[i].azucar+'</small></div></div>'; headerList +='<div class="col-3 myItem-element"> <div class="row"><small class="col-12 " style="color: #6c757d;" >alcohol:</small><small class=" col-12 text-left">'+response.pileta[i].alcohol+'</small></div></div>'; headerList +='<div class="col-3 myItem-element"> <div class="row"><small class="col-12 " style="color: #6c757d;" >acvol:</small><small class=" col-12 text-left">'+response.pileta[i].acvol+'</small></div></div>'; $("#myContent").append(headerList);
valor[i] = (response.pileta[i].saldo*100)/response.pileta[i].cap; miKey[i] = 'myBar'+i; } for(var i = 0; i < response.pileta.length ; i++){ move(miKey[i],valor[i]); } }else{ var headerList = '<div class="row myItem entrar" id="item-'+response.pileta.id+'"><div class="col-2 myProgress"><div class="myBar" id="myBar0"></div></div><div class="col-10"> <div class=" row"> <h5 class=" col-10 myItem-title">'+response.pileta.desc+'</h5> <h4 class=" col-2 myItem-title">'+response.pileta.id+'</h4>'; headerList +='<div class="col-3 myItem-element"> <div class="row"><small class="col-12 " style="color: #6c757d;">saldo:</small><small class=" col-12 text-left text-nowrap "><b>'+number_format(response.pileta.saldo, 0)+'</b></small></div></div>'; headerList +='<div class="col-3 myItem-element"> <div class="row"><small class="col-12 " style="color: #6c757d;">azucar:</small><small class=" col-12 text-left">'+response.pileta.azucar+'</small></div></div>'; headerList +='<div class="col-3 myItem-element"> <div class="row"><small class="col-12 " style="color: #6c757d;">alcohol:</small><small class=" col-12 text-left">'+response.pileta.alcohol+'</small></div></div>'; headerList +='<div class="col-3 myItem-element"> <div class="row"><small class="col-12 " style="color: #6c757d;">acvol:</small><small class=" col-12 text-left">'+response.pileta.acvol+'</small></div></div>'; $("#myContent").append(headerList); valor[0] = (response.pileta.saldo*100)/response.pileta.cap; miKey[0] = 'myBar0'; move(miKey[0],valor[0]); }
$(".myItem").click(function(){ var oID = $(this).attr("id"); var res = oID.split("-"); if(!document.getElementById( "details-"+res[1])){ var parametros = { "pileta" : res[1] }; crear_detalles_de_pileta(parametros, $(this)); } }); }});
}
function openStock(evt, stockName) { // Declare all variables
var i, tabcontent, tablinks, aux; if (document.getElementById(stockName).style.display==="block") { aux=1; }
// Get all elements with class="tabcontent" and hide them
tabcontent = document.getElementsByClassName("tabcontent"); for (i = 0; i < tabcontent.length; i++) { tabcontent[i].style.display = "none"; }
// Get all elements with class="tablinks" and remove the class "active"
tablinks = document.getElementsByClassName("tablinks"); for (i = 0; i < tablinks.length; i++) { tablinks[i].className = tablinks[i].className.replace(" active", ""); }
// Show the current tab, and add an "active" class to the button that opened the tab
if (aux==1) { document.getElementById(stockName).style.display = "none"; }else{ document.getElementById(stockName).style.display = "block"; evt.currentTarget.className += " active"; } // console.log("igualdad es= "+document.getElementById(stockName).style.display);
} function formatNumber(num) { if (!num || num == 'NaN') return '-'; if (num == 'Infinity') return '∞'; num = num.toString().replace(/\$|\,/g, ''); if (isNaN(num)) num = "0"; sign = (num == (num = Math.abs(num))); num = Math.floor(num * 100 + 0.50000000001); cents = num % 100; num = Math.floor(num / 100).toString(); if (cents < 10) cents = "0" + cents; for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3) ; i++) num = num.substring(0, num.length - (4 * i + 3)) + '.' + num.substring(num.length - (4 * i + 3)); return (((sign) ? '' : '-') + num + ',' + cents); }
function verStocks(){
$("#piletasOption").show(); $("#totalesOption").show(); $("#buscarPiletas").hide(); $("#myQuest").hide();
//loader
$(".container-login100").addClass(".altoTotal"); $("#myContent").empty(); $(".wrap-login100").hide(); $("#myPreContent").show();
$.ajax({url: path_stocks, type: 'POST', dataType: 'json', success: function(response){ //lista_de_stocks = response.salsto;
//console.log(lista_de_stocks.estado);
var lista_de_stocks = response.salsto; //console.log(lista_de_stocks[1]);
console.log(lista_de_stocks);
$(".container-login100").removeClass(".altoTotal"); $("#myPreContent").hide();; $(".wrap-login100").show();
var aux= ''; var headerList = '<div class="tab">'; headerList += '<button class="tablinks col-6 active" onclick="openStock(event, \'Insumos\')">Insumos</button>'; headerList += '<button class="tablinks col-6" onclick="openStock(event, \'Planchadas\')">Planchadas</button></div>';
headerList += '<div id="Insumos" class="tabcontent" style="display: block;">';
for (i = 0; i < lista_de_stocks.length; i++) { if (lista_de_stocks[i].estado=="STKMP") { headerList += '<div class="row myItem" style="height:60px; font-size: 0.8rem;">'; headerList += '<div class="col-12" style="height:30px; padding-top: 5px;">'+lista_de_stocks[i].descprod+'</div>'; headerList += '<div class="col-4" style="height:30px;"><small style="color: #6c757d;">Cod.: </small>'+lista_de_stocks[i].producto+' '+lista_de_stocks[i].umed+'</div>'; headerList += '<div class="col-4" style="height:30px;"><small style="color: #6c757d;">Cant.: </small>'+number_format((lista_de_stocks[i].cant/100), 0)+'</div>'; headerList += '<div class="col-4" style="height:30px;"><small style="color: #6c757d;">Ult-mov.: </small>'+lista_de_stocks[i].ulfec+'</div>'; headerList += '</div>'; }else{ aux += '<div class="row myItem" style="height:60px; font-size: 0.8rem;">'; aux += '<div class="col-12" style="height:30px; padding-top: 5px;">'+lista_de_stocks[i].descprod+'</div>'; aux += '<div class="col-4" style="height:30px;"><small style="color: #6c757d;">Cod.: </small>'+lista_de_stocks[i].producto+' '+lista_de_stocks[i].umed+'</div>'; aux += '<div class="col-4" style="height:30px;"><small style="color: #6c757d;">Cant.: </small>'+number_format((lista_de_stocks[i].cant/100), 0)+'</div>'; aux += '<div class="col-4" style="height:30px;"><small style="color: #6c757d;">Ult-mov.: </small>'+lista_de_stocks[i].ulfec+'</div>'; aux += '</div>'; } } headerList += '</div>'; headerList += '<div id="Planchadas" class="tabcontent">'; headerList += aux; headerList += '</div>'; $("#myContent").append(headerList);
} }); }
function verStocks(){ //buttoms
$("#piletasOption").show(); $("#totalesOption").show(); $("#buscarPiletas").hide(); $("#myQuest").hide();
//loader
$(".container-login100").addClass(".altoTotal"); $("#myContent").empty(); $(".wrap-login100").hide(); $("#myPreContent").show();
$.ajax({url: path_stocks, type: 'POST', dataType: 'json', success: function(response){ var lista_de_stocks = response.salsto; console.log(lista_de_stocks); $(".container-login100").removeClass(".altoTotal"); $("#myPreContent").hide();; $(".wrap-login100").show();
var headerList = '<div class="tab row" style="margin-top:16px;">'; headerList += '<button class="tablinks col-12" id="tablink_planch" onclick="openStock(event, \'planch_id\')">Planchadas</button>'; headerList += '<button class="tablinks col-12 active" style="border-top: 1px solid gray;" id="tablink_ven" onclick="openStock(event, \'ven_id\')">Insumos Venta</button>'; headerList += '<button class="tablinks col-12" style="border-top: 1px solid gray;" id="tablink_bode" onclick="openStock(event, \'bode_id\')">Insumos Bodega</button>'; headerList += '<button class="tablinks col-12" style="border-top: 1px solid gray;" id="tablink_frac" onclick="openStock(event, \'frac_id\')">Insumos Fraccionamiento</button>'; headerList += '<button class="tablinks col-12" style="border-top: 1px solid gray;" id="tablink_gral" onclick="openStock(event, \'gral_id\')">Insumos General</button>'; headerList += '</div>'; var divs_planchadas = '<div id="planch_id" class="tabcontent">'; var divs_ventas = '<div id="ven_id" class="tabcontent">'; var divs_frac = '<div id="frac_id" class="tabcontent">'; var divs_bode = '<div id="bode_id" class="tabcontent">'; var divs_gral = '<div id="gral_id" class="tabcontent">'; for (i = 0; i < lista_de_stocks.length; i++) { var fecha = lista_de_stocks[i].ulfec; if (lista_de_stocks[i].estado=="STKMP") { if(lista_de_stocks[i].uso=="FRAC"){ divs_frac += '<div class="row myItem" style="height:60px; font-size: 0.8rem;">'; divs_frac += '<div class="col-md-12 col-7" style="height:30px; padding-top: 5px; text-align: left;">'+lista_de_stocks[i].descprod+'</div>'; divs_frac += '<div class="col-md-4 col-5" style="height:30px; text-align: left;"><small style="color: #6c757d; text-align: left;">Cod.: </small>'+lista_de_stocks[i].producto+'</div>'; divs_frac += '<div class="col-md-4 col-6" style="height:30px; text-align: left;"><small style="color: #6c757d; text-align: left;">Cant.: </small>'+number_format((lista_de_stocks[i].cant/100), 0)+' '+lista_de_stocks[i].umed+'</div>'; divs_frac += '<div class="col-md-4 col-6" style="height:30px;"><small style="color: #6c757d;">Ult-mov.: </small>'+fecha+'</div>'; divs_frac += '</div>'; }else if (lista_de_stocks[i].uso=="BODE") { divs_bode +='<div class="row myItem" style="height:60px; font-size: 0.8rem;">'; divs_bode += '<div class="col-md-12 col-7" style="height:30px; padding-top: 5px; text-align: left;">'+lista_de_stocks[i].descprod+'</div>'; divs_bode += '<div class="col-md-4 col-5" style="height:30px; text-align: left;"><small style="color: #6c757d; text-align: left;">Cod.: </small>'+lista_de_stocks[i].producto+'</div>'; divs_bode += '<div class="col-md-4 col-6" style="height:30px; text-align: left;"><small style="color: #6c757d; text-align: left;">Cant.: </small>'+number_format((lista_de_stocks[i].cant/100), 0)+' '+lista_de_stocks[i].umed+'</div>'; divs_bode += '<div class="col-md-4 col-6" style="height:30px;"><small style="color: #6c757d;">Ult-mov.: </small>'+fecha+'</div>'; divs_bode += '</div>'; }else if (lista_de_stocks[i].uso=="VENTA") { divs_ventas += '<div class="row myItem" style="height:60px; font-size: 0.8rem;">'; divs_ventas += '<div class="col-md-12 col-7" style="height:30px; padding-top: 5px; text-align: left;">'+lista_de_stocks[i].descprod+'</div>'; divs_ventas += '<div class="col-md-4 col-5" style="height:30px; text-align: left;"><small style="color: #6c757d; text-align: left;">Cod.: </small>'+lista_de_stocks[i].producto+'</div>'; divs_ventas += '<div class="col-md-4 col-6" style="height:30px; text-align: left;"><small style="color: #6c757d; text-align: left;">Cant.: </small>'+number_format((lista_de_stocks[i].cant/100), 0)+' '+lista_de_stocks[i].umed+'</div>'; divs_ventas += '<div class="col-md-4 col-6" style="height:30px;"><small style="color: #6c757d;">Ult-mov.: </small>'+fecha+'</div>'; divs_ventas += '</div>'; }else{ divs_gral += '<div class="row myItem" style="height:60px; font-size: 0.8rem;">'; divs_gral += '<div class="col-md-12 col-7" style="height:30px; padding-top: 5px; text-align: left;">'+lista_de_stocks[i].descprod+'</div>'; divs_gral += '<div class="col-md-4 col-5" style="height:30px; text-align: left;"><small style="color: #6c757d; text-align: left;">Cod.: </small>'+lista_de_stocks[i].producto+'</div>'; divs_gral += '<div class="col-md-4 col-6" style="height:30px; text-align: left;"><small style="color: #6c757d; text-align: left;">Cant.: </small>'+number_format((lista_de_stocks[i].cant/100), 0)+' '+lista_de_stocks[i].umed+'</div>'; divs_gral += '<div class="col-md-4 col-6" style="height:30px;"><small style="color: #6c757d;">Ult-mov.: </small>'+fecha+'</div>'; divs_gral += '</div>'; } }else{ divs_planchadas += '<div class="row myItem" style="height:60px; font-size: 0.8rem;">'; divs_planchadas += '<div class="col-md-12 col-7" style="height:30px; padding-top: 5px; text-align: left;">'+lista_de_stocks[i].descprod+'</div>'; divs_planchadas += '<div class="col-md-4 col-5" style="height:30px; text-align: left;"><small style="color: #6c757d; text-align: left;">Cod.: </small>'+lista_de_stocks[i].producto+'</div>'; divs_planchadas += '<div class="col-md-4 col-6" style="height:30px; text-align: left;"><small style="color: #6c757d; text-align: left;">Cant.: </small>'+number_format((lista_de_stocks[i].cant/100), 0)+' '+lista_de_stocks[i].umed+'</div>'; divs_planchadas += '<div class="col-md-4 col-6" style="height:30px;"><small style="color: #6c757d;">Ult-mov.: </small>'+fecha+'</div>'; divs_planchadas += '</div>'; } } divs_planchadas += '</div>'; divs_ventas += '</div>'; divs_frac += '</div>'; divs_bode += '</div>'; divs_gral += '</div>';
$("#myContent").append(headerList); $("#tablink_planch").append(divs_planchadas); $("#tablink_ven").append(divs_ventas); $("#tablink_bode").append(divs_bode); $("#tablink_frac").append(divs_frac); $("#tablink_gral").append(divs_gral);
} }); }
function topFunction() { document.body.scrollTop = 0; // For Safari
document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
}
/* COMIENZA LA CARGA DE COMPORTAMIENTO DE PAGINA ***************************************************************************************/ var cant_item= 1; $( document ).ready(function() { $("#myNavy").removeClass("invisible"); $("#myNavy").hide(); $("#myQuest").removeClass("invisible"); $("#myQuest").hide(); $("#totalesOption").hide(); $(".wrap-login100").removeClass("invisible"); $(".wrap-login100").hide(); $("#piletasOption").click(function(){ crear_lista_de_piletas(); }); $("#totalesOption").click(function(){ crear_lista_de_totales(); $("#buscarPiletas").hide(); }); $("#stocksOption").click(function(){ verStocks(); // getStocks();
}); $(".botonAgregar").click(function(){ cant_item= agregar_item_quest(cant_item); }); $(".botonBuscar").click(function(){ var isOk= validar_input_isNum(); if (isOk==true) busqueda_de_filtros(); }); $("#myMenuIcon2").hide(); crear_lista_de_totales();
$(window).scroll(function(){ if ($(this).scrollTop() > 250) { $('#boton-top').fadeIn(); } else { $('#boton-top').fadeOut(); } });
});
|