diff --git a/prototipo.html b/prototipo.html index a20fef8c37063027441053f0d58a625b6ec97918..2bb10281f548bdb9236b6e9338d0e7a8faf7e248 100644 --- a/prototipo.html +++ b/prototipo.html @@ -197,6 +197,16 @@ function atualizaEmpresas(){ </table> </div> +<div id="conjuntoEmpresa" title="Cardápio empresa" style="display:none"> + <table> + <input type=hidden id="dadosEmpresa_id"> + <input type=hidden id="conjuntoEmpresa_id"> + <tr><td>Nome: </td> <td><input type=text id="conjuntoEmpresa_nome"></td></tr> + <tr><td id="checkBoxesConjunto"></td></tr> + <tr><td colspan=2><center><button id="editaConjuntoEmpresa">Salvar</button> <button class="cancelaEditaEmpresa">Cancelar</button></center></td> </tr> + </table> +</div> + <div id="cardapioEmpresa" title="Cardapio da empresa" style="display:none"> <table> <input type=hidden id="cardapioEmpresa_id"> @@ -331,14 +341,17 @@ function alertCardapioEmpresa(e){ $("#cardapioEmpresa_precoTotal").val(dados.getTiposCardapios().getPrecoTotal()); tabs = dados.getConjunto() colunas=""; - for(var e in tabs) + for(var object in tabs) { - colunas += "<tr><td>"+tabs[e].getNome()+"</td><td>" - aux = tabs[e].getCombinacao(); + colunas += "<tr><td>"+tabs[object].getNome()+"</td><td>" + aux = tabs[object].getCombinacao(); for(var element in aux) { colunas+=aux[element] + " " } + conjuntos=[]; + + colunas+="</td><td><button onClick=alertConjuntoEmpresa("+object+");>Editar</button></td>" colunas+= "</td></tr>" } @@ -347,6 +360,51 @@ function alertCardapioEmpresa(e){ document.getElementById("tcardapio").innerHTML += colunas; } +function alertConjuntoEmpresa(object){ + /*console.log(object); + dados = ListaEmpresas[object[0]]; + conjuntos = dados.getConjunto() + e = object[1]; + for(var element in conjuntos) + { + if(element == e) + { + conjunto = conjuntos[element]; + } + } + $("#conjuntoEmpresa").dialog(); + $("#dadosEmpresa_id").val(e); + $("#conjuntoEmpresa_id").val(object); + $("#conjuntoEmpresa_nome").val( conjunto.getNome() ); + htmlCheckBoxes = "<ul>"; + igual =0; + tabs = conjunto.getCombinacao(); + for(var element in tiposDePreparo) + { + for (var e in tabs) + { + if(tabs[e] == tiposDePreparo[element]) + { + igual = 1; + } + + } + if(igual) + { + htmlCheckBoxes+="<li> <input checked id = "+tiposDePreparo[element]+ " type=checkbox>"+tiposDePreparo[element]+" </li><br>" + } + else + { + htmlCheckBoxes+="<li> <input id = "+tiposDePreparo[element]+ " type=checkbox>"+tiposDePreparo[element]+" </li><br>" + } + igual =0; + } + $("#checkBoxesConjunto").html(htmlCheckBoxes+"</ul>");*/ + +} + + + $("#adicionaCardapioEmpresa").click(function(){ var colunas = "<tr><td> <input type=text id = nomeCardapio></td><td>"; for(var element in tiposDePreparo) @@ -367,6 +425,33 @@ $("#editaDadosEmpresa").click( function(){ $(".ui-button").click(); }); + +$("#editaConjuntoEmpresa").click( function(){ + dados = ListaEmpresas[ $("#dadosEmpresa_id").val() ].getDados(); + conjuntos = dados.getConjunto() + for(var element in conjuntos) + { + if(element == e) + { + conjunto = conjuntos[element]; + } + } + conjunto.setNome($("#conjuntoEmpresa_nome").val()); + tabelaPreparacao=[] + for(var element in tiposDePreparo) + { + checkBox = document.getElementById( tiposDePreparo[element]); + if(checkBox.checked) + { + tabelaPreparacao.push(tiposDePreparo[element]); + } + } + conjunto.setCombinacao(tabelaPreparacao); + atualizaEmpresas(); + $(".ui-button").click(); +}); + + $("#editaPublicoEmpresa").click( function(){ dados = ListaEmpresas[ $("#publicoEmpresa_id").val() ]; dados.setMediaRef( new MediaRef(