Skip to content
Snippets Groups Projects
Commit 693c21a2 authored by mc16's avatar mc16
Browse files

Adicionar mais de um cardápio ao mesmo tempo

parent ce83d6cc
No related branches found
No related tags found
No related merge requests found
......@@ -95,7 +95,6 @@ function alertPublicoEmpresa(e){
colunas="";
vetor=[]
vetor = dados.getNecessidadesNutr().getIdades()
console.log(vetor)
for(var object in vetor)
{
faixaIdade= vetor[object]
......@@ -151,7 +150,6 @@ function alertCardapioEmpresa(e){
}
function alertConjuntoEmpresa(empresa, cardapio){
//console.log(object);
dados = ListaEmpresas[empresa];
conjuntos = dados.getConjunto()
conjunto = conjuntos[cardapio];
......@@ -187,19 +185,25 @@ function alertConjuntoEmpresa(empresa, cardapio){
}
$("#adicionaCardapioEmpresa").click(function(){
backupValues = [];
numFaixas = $("#tnovo").children().length;
for (var i = 0; i < numFaixas; i++){
for (var i = 0; i < numFaixas; i++)
{
valor = [];
valor.push(document.getElementById("nomeCardapio"+i).value);
for(var element in tiposDePreparo)
{
valor.push(document.getElementById((tiposDePreparo[element].replace(" ",""))+i).checked);
checkBox = document.getElementById( tiposDePreparo[element].replace(" ","")+ i);
if(checkBox.checked)
{
valor.push(1);
}
else {
valor.push(0);
}
}
backupValues.push(valor);
......@@ -211,19 +215,25 @@ $("#adicionaCardapioEmpresa").click(function(){
colunas+="<input id = \""+tiposDePreparo[element].replace(" ","")+numFaixas+"\"type=checkbox>"+tiposDePreparo[element]+"</br>"
}
colunas += "</td></tr>"
document.getElementById("tnovo").innerHTML += colunas;
for (var i = 0; i < numFaixas; i++){
numero =0;
console.log(backupValues[i][numero]);
document.getElementById("nomeCardapio"+i).value = backupValues[i][numero];
cardapio = backupValues[i];
document.getElementById("nomeCardapio"+i).value = cardapio[numero];
console.log( "Nome: "+ cardapio[numero]+" Valor: "+document.getElementById("nomeCardapio"+i).value);
for(var element in tiposDePreparo)
{
numero++;
console.log(backupValues[i][numero]);
document.getElementById((tiposDePreparo[element].replace(" ",""))+i).checked = backupValues[i][numero];
if(cardapio[numero])
{
document.getElementById((tiposDePreparo[element].replace(" ",""))+i).checked = cardapio[numero];
console.log( "Nome: "+ cardapio[numero]+" Valor: "+document.getElementById((tiposDePreparo[element].replace(" ",""))+i).value);
}
}
console.log("dentro do for Valor: "+document.getElementById("nomeCardapio"+i).value);
}
document.getElementById("tnovo").innerHTML += colunas;
console.log( " Valor: "+document.getElementById("nomeCardapio"+i).value);
});
......@@ -316,32 +326,32 @@ $("#editaPublicoEmpresa").click( function(){
$("#editaCardapioEmpresa").click( function(){
dados = ListaEmpresas[ $("#cardapioEmpresa_id").val() ];
tabelaPreparacao=[]
tabelasConjunto =[]
if(dados.getConjunto())
{
tabelasConjunto = dados.getConjunto();
}
numFaixas = $("#tnovo").children().length;
for(var i=0; i< numFaixas; i++)
{
tabelaPreparacao=[]
for(var element in tiposDePreparo)
{
console.log(tiposDePreparo[element].replace(" ","")+ i);
checkBox = document.getElementById( tiposDePreparo[element].replace(" ","")+ i);
if(checkBox.checked)
{
tabelaPreparacao.push(tiposDePreparo[element]+i);
tabelaPreparacao.push(tiposDePreparo[element]);
}
}
conjunto = new Conjunto($("#nomeCardapio"+i).val(), tabelaPreparacao);
tabelasConjunto.push(conjunto);
}
tabelasConjunto =[]
if(dados.getTiposCardapios())
{
conjunto = new Conjunto( $("#nomeCardapio").val(),tabelaPreparacao)
tabelasConjunto = dados.getConjunto()
tabelasConjunto.push(conjunto);
dados.setConjunto(tabelasConjunto);
console.log(dados.getConjunto())
dados.setTiposCardapios(new TipoCardapio($("#cardapioEmpresa_precoInd").val(), $("#cardapioEmpresa_precoTotal").val()) );
}
else {
conjunto = new Conjunto( $("#nomeCardapio").val(),tabelaPreparacao)
tabelasConjunto.push(conjunto);
dados.setConjunto(tabelasConjunto);
console.log(dados.getConjunto());
dados.setTiposCardapios(new TipoCardapio($("#cardapioEmpresa_precoInd").val(), $("#cardapioEmpresa_precoTotal").val()) );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment