From 040f9db30a92e798e240d4d5d4835cabaa409138 Mon Sep 17 00:00:00 2001 From: Edmar Moretti Date: Mon, 13 Aug 2018 16:36:04 -0300 Subject: [PATCH] Atualização do READ-ME e da interface da ferramenta tabela --- README.md | 10 +++++----- css/default.css | 16 +++++++++++++++- ferramentas/tabela/dicionario.js | 5 +++++ ferramentas/tabela/index.js | 1801 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ferramentas/tabela/templateLista_mst.html | 4 ++-- ferramentas/tabela/template_mst.html | 292 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------------------------------- ferramentas/tabela_old/dependencias.php | 24 ++++++++++++++++++++++++ ferramentas/tabela_old/dicionario.js | 253 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ferramentas/tabela_old/exec.php | 145 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ferramentas/tabela_old/index.js | 1203 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ferramentas/tabela_old/relatorio.php | 339 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ferramentas/tabela_old/templateLista_mst.html | 43 +++++++++++++++++++++++++++++++++++++++++++ ferramentas/tabela_old/templateVinculo_mst.html | 24 ++++++++++++++++++++++++ ferramentas/tabela_old/template_mst.html | 165 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ js/janela.js | 21 ++++++++++++++------- js/tema.js | 6 ++++-- js/template.js | 2 +- 17 files changed, 2989 insertions(+), 1364 deletions(-) create mode 100644 ferramentas/tabela_old/dependencias.php create mode 100644 ferramentas/tabela_old/dicionario.js create mode 100644 ferramentas/tabela_old/exec.php create mode 100644 ferramentas/tabela_old/index.js create mode 100644 ferramentas/tabela_old/relatorio.php create mode 100644 ferramentas/tabela_old/templateLista_mst.html create mode 100644 ferramentas/tabela_old/templateVinculo_mst.html create mode 100644 ferramentas/tabela_old/template_mst.html diff --git a/README.md b/README.md index c39e119..9303907 100755 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Alguns usuários reportaram problemas ao instalar o Apache em algumas versões d * Execute novamente o arquivo apache-install.bat * Para confirmar que tudo ocorreu bem, abra o navegador de internet e digite http:\\localhost -### i3Geo +### i3Geo Windows Para obter o código do i3Geo você tem duas opções, a primeira utiliza simplesmente o download de um arquivo e a segunda utiliza o Git. A vantagem da segunda opção é que você poderá atualizar sua instalação de forma mais fácil. @@ -100,7 +100,7 @@ git config --global user.name "Seu Nome" ``` -### PostGIS (opcional) +### PostGIS Windows (opcional) Para instalar o PostGIS siga o roteiro mostrado em http://postgis.net/windows_downloads @@ -218,7 +218,7 @@ service apache2 restart ``` -### i3Geo +### i3Geo Linux Para obter o código do i3Geo você tem duas opções, a primeira utiliza simplesmente o download de um arquivo e a segunda utiliza o Git. A vantagem da segunda opção é que você poderá atualizar sua instalação de forma mais fácil. @@ -277,7 +277,7 @@ git config --global user.email seuemail@example.com git config --global user.name "Seu Nome" ``` -### PostGIS (opcional) +### PostGIS Linux (opcional) Instale o PostgreSQL e PostGIS @@ -292,7 +292,7 @@ apt-get install postgresql-9.1-postgis Observações: -* Pependendo da versão do PostgreSQL alguns comandos podem ser diferentes. Veja a pasta /usr/share/postgresql para descobrir a versão instalada) +* Dependendo da versão do PostgreSQL alguns comandos podem ser diferentes. Veja a pasta /usr/share/postgresql para descobrir a versão instalada) * Pode ser necessário o uso de sudo, exemplo: sudo su - postgres -c "createdb i3geosaude" diff --git a/css/default.css b/css/default.css index 02bcdd4..5500a0f 100755 --- a/css/default.css +++ b/css/default.css @@ -1,4 +1,18 @@ - +.navbar .navbar-nav > li > a { + padding-top: 5px; + padding-bottom: 5px; +} + +.ui-resizable-n { + cursor: n-resize; + height: 12px; + width: 14px; + background-image: url("../pacotes/jquery/jquery-ui/images/ui-icons_444444_256x240.png"); + background-position: -50px -224px; + left: 0px; + right: 0px; + margin: auto; +} .glyphicon.normal-right-spinner { -webkit-animation: glyphicon-spin-r 2s infinite linear; diff --git a/ferramentas/tabela/dicionario.js b/ferramentas/tabela/dicionario.js index e19c6fc..a9ea1ff 100755 --- a/ferramentas/tabela/dicionario.js +++ b/ferramentas/tabela/dicionario.js @@ -249,5 +249,10 @@ i3GEOF.tabela.dicionario = { pt : "Selecione pelo menos um registro", en : "Select at least one record", es : "Seleccione al menos un registro" + } ], + 'operReg' : [ { + pt : "Operações que são executadas considerando a lista de registros marcados", + en : "", + es : "" } ] }; diff --git a/ferramentas/tabela/index.js b/ferramentas/tabela/index.js index e19b9ad..2804876 100755 --- a/ferramentas/tabela/index.js +++ b/ferramentas/tabela/index.js @@ -1,1203 +1,622 @@ if (typeof (i3GEOF) === 'undefined') { var i3GEOF = {}; } -/* - * Classe: i3GEOF.tabela - */ i3GEOF.tabela = { - /** - * Controla se o evento de atualizacao da lista de registros esta ativo ou nao E utilizado quando os graficos sao recuperados de um - * mapa que foi salvo - */ - LISTAREGATIVO : true, - /** - * Array com os ids das janelas ja criadas - */ - janelas : [], - /** - * Objeto com as propriedades de cada janela. A chave e o id da janela armazenado em i3GEO.tabela.janelas - */ - propJanelas : {}, - /** - * Template no formato mustache. E preenchido na carga do javascript com o programa dependencias.php - */ - MUSTACHE : "", - MUSTACHELISTA : "", - MUSTACHEVINCULO: "", - /** - * Susbtitutos para o template - */ - mustacheHash : function(idjanela) { - var dicionario = i3GEO.idioma.objetoIdioma(i3GEOF.tabela.dicionario); - dicionario["idjanela"] = idjanela; - dicionario["idjanelaA"] = '"' + idjanela + '"'; - dicionario["locaplic"] = i3GEO.configura.locaplic; - dicionario["propriedades"] = $trad('p13'); - dicionario["ini"] = $inputText("", "", idjanela + 'i3GEOtabelainicio', "", 5, "1"); - dicionario["fim"] = $inputText("", "", idjanela + 'i3GEOtabelafim', "", 5, "20"); - return dicionario; - }, - /** - * Configura a tabela conforme um objeto contendo parametros. Alguns parametros possuem definicoes padrao, usadas quando o valor nao - * e passado - * - * Qualquer outro campo de formulario pode ter seu valor passado como parametro, desde que use o mesmo ID, excluindo-se do nome do - * ID o prefixo (codigo da janela) - * - * parametros {objeto} com os seguintes elementos: - * - * idjanela - id da tabela. Usado como prefixo para inserir os identificadores dos elementos DOM que fazem parte da interface do - * tabela. Se existir um elemento dom esse id, a tabela sera inserido nesse elemento - * - * tema - codigo do tema existente no mapa e que sera a fonte para os dados - * - * atualiza true|false - a janela sera atualizada na navegacao do mapa ou nao - * - */ - configura : function(parametros) { - var idjanela; - if (!parametros.idjanela) { - idjanela = "tabela" + parseInt(Math.random() * 1000000, 10); - } else { - idjanela = parametros.idjanela; - } - i3GEOF.tabela.janelas.push(idjanela); - if (parametros) { - i3GEOF.tabela.propJanelas[idjanela] = parametros; - } else { - i3GEOF.tabela.propJanelas[idjanela] = {}; - } - if (!parametros.tema || parametros.tema == undefined) { - i3GEOF.tabela.propJanelas[idjanela].tema = i3GEO.temaAtivo; - } - if (!parametros.atualiza || parametros.atualiza == undefined) { - i3GEOF.tabela.propJanelas[idjanela].atualiza = true; - } - // guarda para essa tabela alguns valores default obtidos dos - // parametros gerais da ferramenta - if (!parametros.w || parametros.w == undefined) { - i3GEOF.tabela.propJanelas[idjanela].w = i3GEOF.tabela.w; - } - if (!parametros.h || parametros.h == undefined) { - i3GEOF.tabela.propJanelas[idjanela].h = i3GEOF.tabela.h; - } - i3GEOF.tabela.propJanelas[idjanela].colunas = { - "itens" : [], - "alias" : [] - }; - i3GEOF.tabela.propJanelas[idjanela].registros = []; - return idjanela; - }, - /** - * Aplica a tabela os parametros de configuracao definidos para cada interface que controla a tabela. Os parametros de configuracao - * sao obtidos na inicializacao, passados como parametros. Essa funcao deve ser executada apos os elementos html terem sido - * renderizados - */ - aplicaConfig : function(idjanela) { - var config, nomesIds, i, o, n, j; - config = i3GEOF.tabela.propJanelas[idjanela]; - nomesIds = i3GEO.util.listaChaves(config); - n = nomesIds.length; - for (j = 0; j < n; j++) { - i = nomesIds[j]; - if (config[i]) { - o = $i(i); - if (o && o.type) { - if (o.type.toLowerCase() === "radio" || o.type.toLowerCase() === "checkbox") { - o.checked = config[i]; - } else { - o.value = config[i]; - } - } - } - } - }, - /* - * Function: inicia - * - * Inicia a ferramenta. É chamado por criaJanelaFlutuante - * - * Parametro: - * - * iddiv {String} - id do div que receberá o conteudo HTML da ferramenta - */ - inicia : function(iddiv, idjanela) { - if(i3GEOF.tabela.MUSTACHE == ""){ - var t1 = i3GEO.configura.locaplic + "/ferramentas/tabela/template_mst.html", - t2 = i3GEO.configura.locaplic + "/ferramentas/tabela/templateLista_mst.html", - t3 = i3GEO.configura.locaplic + "/ferramentas/tabela/templateVinculo_mst.html"; + LISTAREGATIVO : true, + refreshOnNavigate : true, + renderFunction: i3GEO.janela.formModal, + _parameters: { + "tema": "", + "mustache": "", + "mustachelista": "", + "idContainer": "i3GEOtabelaContainer", + "idRegistros" : "i3GEOtabelaregistros", + "namespace": "tabela", + "colunas" :{ + "itens" : [], + "alias" : [] + }, + "registros": [] + }, + start : function(tema){ + var p = this._parameters, + i3f = this, + t1 = i3GEO.configura.locaplic + "/ferramentas/"+p.namespace+"/template_mst.html", + t2 = i3GEO.configura.locaplic + "/ferramentas/"+p.namespace+"/templateLista_mst.html"; + p.tema = tema; + if(p.mustache === ""){ + i3GEO.janela.abreAguarde(); + $.when( $.get(t1),$.get(t2)).done(function(r1,r2) { + p.mustache = r1[0]; + p.mustachelista = r2[0]; + i3f.html(); + i3GEO.janela.fechaAguarde(); + }).fail(function() { + i3GEO.janela.closeMsg($trad("erroTpl")); + return; + }); + } else { + i3f.html(); + } + }, + destroy: function(){ + //nao use this aqui + i3GEOF.tabela._parameters.mustache = ""; + i3GEOF.tabela._parameters.tema = ""; + i3GEOF.tabela._parameters.registros = []; + i3GEOF.tabela._parameters.colunas = { + "itens" : [], + "alias" : [] + }; - $.when( $.get(t1),$.get(t2),$.get(t3) ).done(function(r1,r2,r3) { - i3GEOF.tabela.MUSTACHE = r1[0]; - i3GEOF.tabela.MUSTACHELISTA = r2[0]; - i3GEOF.tabela.MUSTACHEVINCULO = r3[0]; - i3GEOF.tabela.inicia(iddiv, idjanela); - }).fail(function() { - i3GEO.janela.closeMsg($trad("erroTpl")); - return; - }); - return; - } - $i(iddiv).innerHTML = i3GEOF.tabela.html(idjanela); + i3GEO.eventos.removeEventos("NAVEGAMAPA", [ + "i3GEOF.tabela.atualizaListaDeRegistros()" + ]); - //i3GEO.janela.applyScrollBar(iddiv,".customScrollBar",{advanced:{ autoExpandHorizontalScroll: 2 }}); + }, + html:function() { + var p = this._parameters, + i3f = this, + hash = { + locaplic: i3GEO.configura.locaplic, + namespace: p.namespace, + idContainer: p.idContainer, + idRegistros: p.idRegistros, + propriedades: $trad("p13"), + opcoes: $trad("opcoes"), + ...i3GEO.idioma.objetoIdioma(i3f.dicionario) + }; + i3f.renderFunction.call( + this, + { + texto: Mustache.render(p.mustache, hash), + onclose: i3f.destroy, + resizable: { + disabled: false, + ghost: true, + handles: "se,n" + }, + css: {'cursor': 'pointer', 'width': '100%', 'height': '50%','position': 'fixed','top': '', 'left': 0, 'right': 0, 'margin': 'auto', 'bottom': 0} + }); - var b, onButtonClick = function(evt) { - var botao = evt.target; - if (botao) { - if (botao.value != "") { - i3GEO.mapa.ativaTema(botao.value); - i3GEOF.tabela.propJanelas[idjanela].tema = botao.value; - i3GEOF.tabela.inicia(iddiv, idjanela); - } - } - }; - if (!$i(idjanela + "i3GEOFtabelaComboCabecaSel")) { - i3GEO.janela.comboCabecalhoTemasBs( - idjanela + "i3GEOFtabelaComboCabeca", - idjanela + "i3GEOFtabelaComboCabecaSel", - "tabela", - "comTabela", - onButtonClick); - } - i3GEO.guias.mostraGuiaFerramenta(idjanela + "i3GEOtabelaguia1", idjanela + "i3GEOtabelaguia"); - // eventos das guias - $i(idjanela + "i3GEOtabelaguia6").onclick = function() { - i3GEO.guias.mostraGuiaFerramenta(idjanela + "i3GEOtabelaguia6", idjanela + "i3GEOtabelaguia"); - }; - $i(idjanela + "i3GEOtabelaguia1").onclick = function() { - i3GEO.guias.mostraGuiaFerramenta(idjanela + "i3GEOtabelaguia1", idjanela + "i3GEOtabelaguia"); - }; - $i(idjanela + "i3GEOtabelaguia3").onclick = function() { - i3GEO.guias.mostraGuiaFerramenta(idjanela + "i3GEOtabelaguia3", idjanela + "i3GEOtabelaguia"); - if (!$i(idjanela + "i3GEOtabelaComboItensGuia3")) { - i3GEOF.tabela.comboItensEstat(idjanela); - } - }; - // relatorio - $i(idjanela + "i3GEOtabelaguia5").onclick = - function() { - i3GEO.guias.mostraGuiaFerramenta(idjanela + "i3GEOtabelaguia5", idjanela + "i3GEOtabelaguia"); - i3GEO.util.checkItensEditaveis(i3GEOF.tabela.propJanelas[idjanela].tema, function(retorno) { - if (retorno.tipo === "dados") { - $i(idjanela + "i3GEOtabelaitensrelatorio").innerHTML = retorno.dados; - } - }, idjanela + "i3GEOtabelaitensrelatorio", "320px", "", "sim"); - i3GEO.util.comboItens(idjanela + "i3GEOtabelaagrupaItem", i3GEOF.tabela.propJanelas[idjanela].tema, function( - retorno) { - if (retorno.tipo === "erro") { - i3GEO.janela.closeMsg(''); - } else { - $i(idjanela + "i3GEOtabelaagrupamento").innerHTML = retorno.dados; - } - }, idjanela + "i3GEOtabelaagrupamento", "","sim","","form-control"); - }; + i3GEO.guias.mostraGuiaFerramenta("i3GEOtabelaguia1", "i3GEOtabelaguia"); + // + // eventos das guias + // + $i("i3GEOtabelaguia6").onclick = function() { + i3GEO.guias.mostraGuiaFerramenta("i3GEOtabelaguia6", "i3GEOtabelaguia"); + }; + $i("i3GEOtabelaguia1").onclick = function() { + i3GEO.guias.mostraGuiaFerramenta("i3GEOtabelaguia1", "i3GEOtabelaguia"); + }; + $i("i3GEOtabelaguia3").onclick = function() { + i3GEO.guias.mostraGuiaFerramenta("i3GEOtabelaguia3", "i3GEOtabelaguia"); + if (!$i("i3GEOtabelaComboItensGuia3")) { + i3GEOF.tabela.comboItensEstat(); + } + }; + // relatorio + $i("i3GEOtabelaguia5").onclick = function() { + i3GEO.guias.mostraGuiaFerramenta("i3GEOtabelaguia5", "i3GEOtabelaguia"); + i3GEO.util.comboItens("i3GEOtabelaagrupaItem", i3GEOF.tabela._parameters.tema, function( + retorno) { + if (retorno.tipo === "erro") { + i3GEO.janela.closeMsg(''); + } else { + $i("i3GEOtabelaagrupamento").innerHTML = retorno.dados; + } + }, "i3GEOtabelaagrupamento", "","sim","","form-control"); + }; + i3GEO.eventos.adicionaEventos("NAVEGAMAPA", [ + "i3GEOF.tabela.atualizaListaDeRegistros()" + ]); + i3GEOF.tabela.pegaRegistros(); + }, + comboJanelas : function(idcombo, funcao, w) { + }, + comboColunas : function(idJanela, idcombo, funcao) { + var i, c = i3GEOF.tabela._parameters.colunas, n = c.itens.length; + if (!funcao) { + funcao = ""; + } + ins = ""; + return ins; + }, + /* + * Function: ativaAutoAtualiza + * + * Ativa ou desativa a atualização automática da tabela quando o usuário navega no mapa + */ + atualizaListaDeRegistros : function() { + i3GEOF.tabela.pegaRegistros(); + }, + pegaRegistros : function(tipolista, dadosDaClasse, inicio, fim) { + var p = this._parameters, + i3f = this; + $i(p.idRegistros).innerHTML = ""; + var p, ext, tiporeg = "brasil", cp = new cpaint(); + // verifica se esta no modo de atualizacao automatica + if (i3GEOF.tabela.refreshOnNavigate === true) { + tiporeg = "mapa"; + } + if (!tipolista) { + if ($i("i3GEOtabelatipolista").checked) { + tipolista = "selecionados"; + } else { + tipolista = "tudo"; + } + } + if (!dadosDaClasse) { + if ($i("i3GEOtabelalegenda").checked) { + dadosDaClasse = "sim"; + } else { + dadosDaClasse = "nao"; + } + } + if (!inicio) { + inicio = $i("i3GEOtabelainicio").value - 1; + } else { + inicio = ""; + } + if (!fim) { + fim = $i("i3GEOtabelafim").value - 1; + } else { + fim = ""; + } + funcao = function(retorno) { + i3GEOF.tabela._parameters.registros = []; + i3GEOF.tabela.montaTabela(retorno); + }; + ext = i3GEO.parametros.mapexten; + ext = i3GEO.util.extOSM2Geo(ext); + p = + i3GEO.configura.locaplic + "/classesphp/mapa_controle.php?g_sid=" + + i3GEO.configura.sid + + "&funcao=listaregistros" + + "&inicio=" + + inicio + + "&fim=" + + fim + + "&tema=" + + p.tema + + "&tipo=" + + tiporeg + + "&tipolista=" + + tipolista + + "&ext=" + + ext + + "&dadosDaClasse=" + + dadosDaClasse; + cp.set_response_type("JSON"); + cp.call(p, "listaRegistros", funcao); + }, + /* + * Function: montaTabela + * + * Monta a visualização da tabela de atributos + */ + montaTabela : function(retorno) { + var p = this._parameters, + i3f = this; + if (retorno.data !== undefined) { + var mustache = { + "cabecalho": [{"classe":"hidden"},{"classe":"hidden"},{"classe":"hidden"},{"classe":"hidden"}], //4 colunas com icones + "linhas": [], + "ordena": $trad('ordena', i3GEOF.tabela.dicionario), + "excluir": $trad("t12") + }, + linha = { + "classezoom": "", + "ext": "", + "indice": "" + }, + ins, i, vals, cor, j, n, stat, imagem, registros = p.registros, i3GEOtabelalegenda = + $i("i3GEOtabelalegenda").checked; + // cabecalho da tabela + p.colunas = { + "itens" : retorno.data[0].itens, + "alias" : retorno.data[0].alias + }; + n = retorno.data[0].itens.length; + for (i = 0; i < n; i++) { + mustache.cabecalho.push({ + "idcoluna": i * 1 + 4, //pq tem 3 colunas com icones + "item": retorno.data[0].itens[i], + "alias": retorno.data[0].alias[i], + "classe": "" + }); + } + n = retorno.data[1].registros.length; + if ($i("i3GEOtabelafim").value === "") { + $i("i3GEOtabelafim").value = n - 1; + } + for (i = 0; i < n; i++) { + linha = {}; + linha.classezoom = "hidden"; + linha.ext = ""; + linha.indice = retorno.data[1].registros[i].indice; + if (retorno.data[1].registros[i].ext && retorno.data[1].registros[i].ext != "") { + linha.classezoom = ""; + linha.ext = retorno.data[1].registros[i].ext; + } + linha.stat = ""; + if (retorno.data[1].registros[i].status === "CHECKED") { + linha.stat = "CHECKED"; + } + if (registros[retorno.data[1].registros[i].indice]) { + if (registros[retorno.data[1].registros[i].indice] === true) { + linha.stat = "CHECKED"; + } else { + linha.stat = ""; + } + } + if (i3GEOtabelalegenda == true) { + linha.classelegenda = ""; + linha.nomeClasse = retorno.data[1].registros[i].classe["nome"]; + linha.imagemClasse = retorno.data.legenda[retorno.data[1].registros[i].classe["indice"]]; + imagem = retorno.data.legenda[retorno.data[1].registros[i].classe["indice"]]; + } else { + linha.classelegenda = "hidden"; + linha.nomeClasse = ""; + linha.imagemClasse = ""; + } + if (linha.stat === "CHECKED") { + registros[retorno.data[1].registros[i].indice] = true; + } + vals = retorno.data[1].registros[i].valores; + linha.colunas = ""; + for (j = 0; j < vals.length; j++) { + linha.colunas += "" + vals[j].valor + ""; + } + mustache.linhas.push(linha); + } + ins = Mustache.render(p.mustachelista, mustache); + $i(p.idRegistros).innerHTML = ins; + } + }, + /* + * Function: mais + * + * Avança o contador de registros para a listagem + */ + mais : function(idjanela) { + var i = $i("i3GEOtabelainicio").value * 1, f = $i("i3GEOtabelafim").value * 1, d = f - i; + $i("i3GEOtabelainicio").value = f + 1; + $i("i3GEOtabelafim").value = f + d + 1; + i3GEOF.tabela.pegaRegistros(); + }, + /* + * Function: todos + * + * Avança o contador de registros para o fim da listagem + */ + todos : function(idjanela) { + $i("i3GEOtabelainicio").value = 1; + $i("i3GEOtabelafim").value = ""; + i3GEOF.tabela.pegaRegistros(false, false, false, 1, false); + }, + /* + * Function: menos + * + * Retrocede o contador de registros para a listagem + */ + menos : function(idjanela) { + var i = $i("i3GEOtabelainicio").value * 1, f = $i("i3GEOtabelafim").value * 1, d = f - i; + $i("i3GEOtabelainicio").value = i - d - 1; + $i("i3GEOtabelafim").value = i - 1; + if ($i("i3GEOtabelainicio").value < 1) { + $i("i3GEOtabelainicio").value = 1; + $i("i3GEOtabelafim").value = 1 + d; + } + i3GEOF.tabela.pegaRegistros(); + }, + /* + * Function: excluiColuna + * + * Exclui uma coluna da visualização da tabela + */ + excluiColuna : function(coluna, cid, idjanela) { + try { + var tabela = $i("i3GEOtabelatabelai"), trs, tds, i, t, nt, ni; + // pega o indice correto + tds = coluna.parentNode.parentNode.getElementsByTagName("td"); + nt = tds.length; + for (t = 0; t < nt; t++) { + if (tds[t].accessKey == cid) { + cid = t; + break; + } + } + trs = tabela.getElementsByTagName("tr"); + nt = trs.length; + for (t = 0; t < nt; t++) { + i = trs[t]; + if (i.getElementsByTagName("td")[cid]) { + ni = i.getElementsByTagName("td")[cid]; + i.removeChild(ni); + } + } + } catch (e) { + if (typeof (console) !== 'undefined') { + console.error(e); + } + } + }, + /* + * Function: ordenaColuna + * + * Ordena uma coluna da tabela + */ + ordenaColuna : function(coluna, cid, idjanela) { + try { + var numero = false,tabela = $i("i3GEOtabelatabelai"), trs = tabela.getElementsByTagName("tr"), + ntrs = trs.length, tds, nt, psort = [], t, psortfim, npsortfim, ins, p, e, c; - if (i3GEO.parametros.r.toLowerCase() !== "sim") { - $i(idjanela + "i3GEOtabelaguia4obj").innerHTML = $trad("x22"); - } - i3GEOF.tabela.pegaRegistros(idjanela); - i3GEO.guias.ajustaGuiaFerramenta(idjanela, idjanela + "i3GEOtabela"); - // - // Apos todos os elementos HTML da ferramenta terem sido renderizados - // aplicam-se os parametros armazenados nas propriedades da janela atual - // Isso e necessario pois os parametros podem ter sido enviados na inicializacao da ferramenta, - // por exemplo, quando um mapa e salvo, os parametros sao armazenados e depois recuperados - // - i3GEOF.tabela.aplicaConfig(idjanela); - if ($i(idjanela)) { - $i(idjanela).style.visibility = "visible"; - } - }, - /* - * Function: html - * - * Gera o código html para apresentação das opções da ferramenta - * - * Retorno: - * - * String com o código html - */ - html : function(idjanela) { - var ins = Mustache.render(i3GEOF.tabela.MUSTACHE, i3GEOF.tabela.mustacheHash(idjanela)); - return ins; - }, - /* - * Function: criaJanelaFlutuante - * - * Cria a janela flutuante para controle da ferramenta. - */ - iniciaJanelaFlutuante : function(parametros) { - var duplica, minimiza, cabecalho, janela, divid, temp, titulo, id; - if (!parametros) { - parametros = {}; - } - // - // configura a tabela baseado no objeto parametros - // se em parametros existir um idjanela, o mesmo e retornado, caso contrario, e criado - // - id = i3GEOF.tabela.configura(parametros); - // - // se existir um elemento HTML com o mesmo ID da janela, a renderizacao ocorrera - // nesse elemento, caso contrario, sera criada uma janela flutuante - // - if (!$i(id) && !$i(id + "_corpo")) { - cabecalho = function() { - i3GEOF.tabela.ativaFoco(id); - }; - minimiza = function() { - i3GEO.janela.minimiza(id,200); - }; - duplica = function() { - i3GEOF.tabela.iniciaJanelaFlutuante(); - }; - // cria a janela flutuante - titulo = "" - + $trad('tabela', i3GEOF.tabela.dicionario) - + " (" + id + " )" - + ""; + // pega o indice correto + tds = coluna.parentNode.parentNode.getElementsByTagName("td"); + nt = tds.length; + for (t = 0; t < nt; t++) { + if (tds[t].accessKey == cid) { + cid = t; + break; + } + } + for (t = 1; t < ntrs; t++) { + c = trs[t].getElementsByTagName("td")[cid].innerHTML; + psort.push( c + "@$" + t); + if (c * 1) { + numero = true; + } + } + // recosntroi a tabela + if(numero){ + psortfim = psort.sort(function(a, b) { + return a.split("@$")[0]*1 - b.split("@$")[0]*1; + }); + } else { + psortfim = psort.sort(); + } - janela = i3GEO.janela.cria( - "610px", - "400px", - "", - "", - "", - titulo, - id, - false, - "hd", - cabecalho, - minimiza, - function() { i3GEO.guias.ajustaGuiaFerramenta(id, id + "i3GEOtabela");}, - true, - "", - duplica, - "", - "", - "39" - ); - divid = janela[2].id; - if (i3GEOF.tabela.janelas.length > 1) { - temp = janela[0].cfg.config; - janela[0] - .moveTo(temp.x.value + (i3GEOF.tabela.janelas.length * 50), temp.y.value + (i3GEOF.tabela.janelas.length * 15)); - } - $i(id + "_corpo").style.backgroundColor = "white"; - - temp = function() { - i3GEOF.tabela.janelas.remove(id); - i3GEOF.tabela.propJanelas[id] = null; - if (i3GEOF.tabela.janelas.length === 0) { - if (i3GEO.Interface.ATUAL === "openlayers") { - i3GEO.eventos.removeEventos("NAVEGAMAPA", [ - "i3GEOF.tabela.atualizaListaDeRegistros()" - ]); - } - if (i3GEO.Interface.ATUAL === "googlemaps") { - google.maps.event.removeListener(tabelaDragend); - google.maps.event.removeListener(tabelaZoomend); - } - } - }; - YAHOO.util.Event.addListener(janela[0].close, "click", temp); - janela[0].bringToTop(); - } else { - // sera renderizado em $i(id) - temp = 'i3GEOF.tabela.propJanelas["' + id + '"].atualiza = this.checked'; - $i(id + "_corpo").innerHTML = - "" - + "
" - + " " - + $trad("atualizaNavegacao", i3GEOF.tabela.dicionario) - + " (" - + id - + ")
"; - - divid = id + "_corpo"; - } - if ($i(id + "_imagemCabecalho")) { - i3GEOF.tabela.aguarde = $i(id + "_imagemCabecalho").style; - i3GEOF.tabela.propJanelas[id].aguarde = $i(id + "_imagemCabecalho").style; - i3GEOF.tabela.propJanelas[id].atualiza = true; - } - i3GEOF.tabela.inicia(divid, id); - // inicia os eventos - if (i3GEO.Interface.ATUAL === "openlayers") { - i3GEO.eventos.adicionaEventos("NAVEGAMAPA", [ - "i3GEOF.tabela.atualizaListaDeRegistros()" - ]); - } - if (i3GEO.Interface.ATUAL === "googlemaps" && !tabelaDragend) { - tabelaDragend = google.maps.event.addListener(i3GeoMap, "dragend", function() { - i3GEOF.tabela.atualizaListaDeRegistros(); - }); - tabelaZoomend = google.maps.event.addListener(i3GeoMap, "zoomend", function() { - i3GEOF.tebela.atualizaListaDeRegistros(); - }); - } - }, - /** - * Obtem os parametros de cada janela e converte em base64. Cada janela e inserida como um item em um objeto A compactacao e - * utilizada para salvar as configuracoes no mapfile atual - */ - compactaConfig : function() { - var c, g, par, janelas, i, n, novoid; - par = []; - janelas = i3GEOF.tabela.janelas; - n = janelas.length; - for (i = 0; i < n; i++) { - novoid = window.prompt($trad('idDaTabela', i3GEOF.tabela.dicionario), janelas[i]); - c = i3GEOF.tabela.retornaConfig(janelas[i], novoid); - par.push(c); - } - g = YAHOO.lang.JSON.stringify(par); - return i3GEO.util.base64encode(g); - }, - restauraTabelas : function(par) { - i3GEOF.tabela.LISTAREGATIVO = false; - var n, i; - par = i3GEO.util.base64decode(par); - par = JSON.parse(par); - n = par.length; - for (i = 0; i < n; i++) { - i3GEOF.tabela.iniciaJanelaFlutuante(par[i]); - } - }, - /** - * Retorna um objeto contendo os valores de todos os parametros utilizados na tabela de tal forma que possa ser renderizado - * novamente - * - * A funcao que salva o mapa no banco utiliza retornaConfig e cria um objeto que ira armazenar os parametros de cada janela - */ - retornaConfig : function(idjanela, novoid) { - // as chaves do objeto correspondem ao ID de cada elemento - var c, par; - - par = i3GEOF.tabela.propJanelas[idjanela]; - c = $i(idjanela); - // p = $i(idjanela+"i3GEOtabelaguia6obj"); - if (!novoid) { - novoid = idjanela; - } - // pega todos os elementos do tipo input - /* - * objs = p.getElementsByTagName("input"); for (obj in objs) { if (objs[obj].id && objs[obj].id != "") { tmpid = - * objs[obj].id.replace(idjanela,novoid); if (objs[obj].type === "text") { par[tmpid] = objs[obj].value; } else { par[tmpid] = - * objs[obj].checked; } } } // pega todos os elementos do tipo select objs = p.getElementsByTagName("select"); for (obj in objs) { - * if (objs[obj].id && objs[obj].id != "") { tmpid = objs[obj].id.replace(idjanela,novoid); par[tmpid] = objs[obj].value; } } - */ - par.dados = ""; - try { - par["i3GEOtabelainicio"] = $i(idjanela + "i3GEOtabelainicio").value; - par["i3GEOtabelafim"] = $i(idjanela + "i3GEOtabelafim").value; - par["idjanela"] = novoid; - par["w"] = c.style.width; - par["h"] = c.style.height; - } catch (e) { - } - return par; - }, - /* - * Function: ativaFoco - * - * Refaz a interface da ferramenta quando a janela flutuante tem seu foco ativado - */ - ativaFoco : function(id) { - - }, - vinculos : { - ligacoes : [], - /** - * Susbtitutos para o template - */ - mustacheHash : function() { - var dicionario = i3GEO.idioma.objetoIdioma(i3GEOF.tabela.dicionario); - dicionario["locaplic"] = i3GEO.configura.locaplic; - dicionario["comboJanelas1"] = i3GEOF.tabela.comboJanelas("i3GEOFTabelaOpcoesAdicionaVinculoT1", "i3GEOF.tabela.vinculos.comboColunasT1()"); - dicionario["comboJanelas2"] = i3GEOF.tabela.comboJanelas("i3GEOFTabelaOpcoesAdicionaVinculoT2", "i3GEOF.tabela.vinculos.comboColunasT2()"); - return dicionario; - }, - iniciaJanelaFlutuante : function() { - var janela, titulo; - // cria a janela flutuante - titulo = "" - + $trad('vinculos', i3GEOF.tabela.dicionario) - + ""; - janela = - i3GEO.janela.cria( - "400px", - "350px", - "", - "", - "", - titulo, - "i3GEOFtabelaVinculos", - false, - "hd", - "", - "", - "", - true, - "", - "", - "", - "", - "120" - ); - divid = janela[2].id; - if (i3GEOF.tabela.janelas.length > 1) { - temp = janela[0].cfg.config; - janela[0] - .moveTo(temp.x.value + (i3GEOF.tabela.janelas.length * 50), temp.y.value + (i3GEOF.tabela.janelas.length * 15)); - } - $i("i3GEOFtabelaVinculos_corpo").style.backgroundColor = "white"; - i3GEOF.tabela.vinculos.inicia(); - }, - html : function() { - var ins = Mustache.render(i3GEOF.tabela.MUSTACHEVINCULO, i3GEOF.tabela.vinculos.mustacheHash()); - return ins; - }, - vincular: function(){ - var t1 = $i("i3GEOFTabelaOpcoesAdicionaVinculoT1").value, t2 = - $i("i3GEOFTabelaOpcoesAdicionaVinculoT2").value, c1 = - $i("i3GEOFTabelaOpcoesAdicionaVinculoColunaT1").value, c2 = - $i("i3GEOFTabelaOpcoesAdicionaVinculoColunaT1").value; - if (t1 != "" && t2 != "" && c1 != "" && c2 != "") { - i3GEOF.tabela.vinculos.ligacoes.push({ - "t1" : t1, - "t2" : t2, - "c1" : c1, - "c2" : c2 - }); - } - i3GEOF.tabela.vinculos.lista(); - }, - inicia : function() { - var ins = i3GEOF.tabela.vinculos.html(); - $i("i3GEOFtabelaVinculos_corpo").innerHTML = ins; - i3GEOF.tabela.vinculos.lista(); - }, - comboColunasT1 : function() { - var colunas = ""; - if($i("i3GEOFTabelaOpcoesAdicionaVinculoT1").value != ""){ - colunas = i3GEOF.tabela.comboColunas($i("i3GEOFTabelaOpcoesAdicionaVinculoT1").value, "i3GEOFTabelaOpcoesAdicionaVinculoColunaT1"); - } - $i("i3GEOFTabelaVinculoT1Colunas").innerHTML = colunas; - }, - comboColunasT2 : function() { - var colunas = ""; - if($i("i3GEOFTabelaOpcoesAdicionaVinculoT2").value != ""){ - colunas = i3GEOF.tabela.comboColunas($i("i3GEOFTabelaOpcoesAdicionaVinculoT2").value, "i3GEOFTabelaOpcoesAdicionaVinculoColunaT2"); - } - $i("i3GEOFTabelaVinculoT2Colunas").innerHTML = colunas; - }, - lista : function() { - var v = i3GEOF.tabela.vinculos.ligacoes, n = v.length, ins = - "
" + $trad('vinculos', i3GEOF.tabela.dicionario) + "
", i; - for (i = 0; i < n; i++) { - ins += '' - + "
" + v[i].t1 - + " " - + v[i].c1 - + " ->
" - + v[i].t2 - + " " - + v[i].c2 - + "
"; - } - $i("i3GEOFtabelaVinculosLista").innerHTML = ins; - }, - excluir : function(i) { - i3GEOF.tabela.vinculos.ligacoes.splice(parseInt(i, 10), 1); - i3GEOF.tabela.vinculos.lista(); - }, - atualizaVinculos : function(tabelaOrigem, registro, marcado) { - var v = i3GEOF.tabela.vinculos.ligacoes, n = v.length, i, valor; - if (n > 0) { - for (i = 0; i < n; i++) { - // verifica se o vinculo existe - if (v[i].t1 === tabelaOrigem) { - // pega o valor do registro na tabela origem - valor = i3GEOF.tabela.vinculos.pegaValorRegistro(v[i].t1, v[i].c1, registro); - // marca o registro na tabela destino - i3GEOF.tabela.vinculos.registro(v[i].t2, v[i].c2, valor, marcado); - } - if (v[i].t2 === tabelaOrigem) { - // pega o valor do registro na tabela origem - valor = i3GEOF.tabela.vinculos.pegaValorRegistro(v[i].t2, v[i].c2, registro); - // marca o registro na tabela destino - i3GEOF.tabela.vinculos.registro(v[i].t1, v[i].c1, valor, marcado); - } - } - } - }, - // verifica qtas colunas devem ser puladas em cada linha - colunasVazias : function(idjanela) { - var tabela = $i(idjanela + "i3GEOtabelatabelai"), linhas = tabela.getElementsByTagName("tr"), pular = 0, colunas, n, i; - colunas = linhas[0].getElementsByTagName("td"); - n = colunas.length; - for (i = 0; i < n; i++) { - if (colunas[i].innerHTML == "") { - pular++; - } - } - return pular; - }, - // pega o indice de uma coluna em uma tabela buscando no cabecalho - // no valor de title em cada celula - indiceColuna : function(idjanela, t) { - var tabela = $i(idjanela + "i3GEOtabelatabelai"), linhas = tabela.getElementsByTagName("tr"), linha = linhas[0], colunas = - linha.getElementsByTagName("td"), indice = 0, n = colunas.length, i, s; - for (i = 0; i < n; i++) { - s = colunas[i].getElementsByTagName("span"); - if (s && s[0] && s[0].title && s[0].title == t) { - return i; - } - } - return indice; - }, - // retorna o indice de uma coluna que contem a tag input na tabela - // com a lista de valores - indiceColunaInput : function(idjanela) { - var tabela = $i(idjanela + "i3GEOtabelatabelai"), linhas = tabela.getElementsByTagName("tr"), linha = linhas[1], colunas = - linha.getElementsByTagName("td"), indice = 0, n = colunas.length, i; - for (i = 0; i < n; i++) { - if (colunas[i].getElementsByTagName("input").length > 0) { - return i; - } - } - return indice; - }, - // pega o valor da coluna em uma tabela com a lista de valores com - // base no codigo do registro - pegaValorRegistro : function(idjanela, coluna, registro) { - var tabela = $i(idjanela + "i3GEOtabelatabelai"), linhas = tabela.getElementsByTagName("tr"), n = linhas.length, indiceColuna = - i3GEOF.tabela.vinculos.indiceColuna(idjanela, coluna), indiceColunaInput = - i3GEOF.tabela.vinculos.indiceColunaInput(idjanela), i, linha, colunas; - for (i = 1; i < n; i++) { - linha = linhas[i]; - colunas = linha.getElementsByTagName("td"); - if (colunas[indiceColunaInput].getElementsByTagName("input")[0].name == registro) { - return colunas[indiceColuna].innerHTML; - } - } - return ""; - }, - registro : function(idjanela, coluna, valor, marcado) { - var tabela = $i(idjanela + "i3GEOtabelatabelai"), linhas = tabela.getElementsByTagName("tr"), n = linhas.length, indiceColuna = - i3GEOF.tabela.vinculos.indiceColuna(idjanela, coluna), indiceColunaInput = - i3GEOF.tabela.vinculos.indiceColunaInput(idjanela), i, linha, colunas, reg; - for (i = 1; i < n; i++) { - linha = linhas[i]; - colunas = linha.getElementsByTagName("td"); - if (colunas[indiceColuna].innerHTML == valor) { - reg = colunas[indiceColunaInput].getElementsByTagName("input")[0]; - reg.checked = marcado; - i3GEOF.tabela.propJanelas[idjanela].registros[reg.name] = marcado; - } - } - }, - }, - comboJanelas : function(idcombo, funcao, w) { - var i, n = i3GEOF.tabela.janelas.length; - if (!funcao) { - funcao = ""; - } - if (!w) { - w = 260; - } - ins = - "" + " "; - return ins; - }, - comboColunas : function(idJanela, idcombo, funcao) { - var i, c = i3GEOF.tabela.propJanelas[idJanela].colunas, n = c.itens.length; - if (!funcao) { - funcao = ""; - } - ins = ""; - return ins; - }, - /* - * Function: ativaAutoAtualiza - * - * Ativa ou desativa a atualização automática da tabela quando o usuário navega no mapa - */ - atualizaListaDeRegistros : function() { - var i, janelas = i3GEOF.tabela.janelas, propJanelas = i3GEOF.tabela.propJanelas, n = janelas.length; - for (i = 0; i < n; i++) { - if (propJanelas[janelas[i]].atualiza === true) { - i3GEOF.tabela.pegaRegistros(janelas[i]); - } - } - }, - /* - * Function: pegaRegistros - * - * Pega os registros da tabela de atributos do tema - * - * Veja: - * - * - */ - pegaRegistros : function(idjanela, tipolista, dadosDaClasse, inicio, fim, funcao) { - if (i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility === "visible") { - return; - } - if (!idjanela) { - idjanela = ""; - } - i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "visible"; - $i(idjanela + "i3GEOtabelaregistros").innerHTML = ""; - var p, ext, tiporeg = "brasil", cp = new cpaint(); - // verifica se esta no modo de atualizacao automatica - if (i3GEOF.tabela.propJanelas[idjanela].atualiza === true) { - tiporeg = "mapa"; - } - if (!tipolista) { - if ($i(idjanela + "i3GEOtabelatipolista").checked) { - tipolista = "selecionados"; - } else { - tipolista = "tudo"; - } - } - if (!dadosDaClasse) { - if ($i(idjanela + "i3GEOtabelalegenda").checked) { - dadosDaClasse = "sim"; - } else { - dadosDaClasse = "nao"; - } - } - if (!inicio) { - inicio = $i(idjanela + "i3GEOtabelainicio").value - 1; - } else { - inicio = ""; - } - if (!fim) { - fim = $i(idjanela + "i3GEOtabelafim").value - 1; - } else { - fim = ""; - } - if (!funcao) { - funcao = function(retorno) { - i3GEOF.tabela.propJanelas[idjanela].registros = []; - i3GEOF.tabela.montaTabela(retorno, idjanela); - }; - } - ext = i3GEO.parametros.mapexten; - ext = i3GEO.util.extOSM2Geo(ext); - p = - i3GEO.configura.locaplic + "/classesphp/mapa_controle.php?g_sid=" - + i3GEO.configura.sid - + "&funcao=listaregistros" - + "&inicio=" - + inicio - + "&fim=" - + fim - + "&tema=" - + i3GEOF.tabela.propJanelas[idjanela].tema - + "&tipo=" - + tiporeg - + "&tipolista=" - + tipolista - + "&ext=" - + ext - + "&dadosDaClasse=" - + dadosDaClasse; - cp.set_response_type("JSON"); - cp.call(p, "listaRegistros", funcao); - }, - /* - * Function: montaTabela - * - * Monta a visualização da tabela de atributos - */ - montaTabela : function(retorno, idjanela) { - if (retorno.data !== undefined) { - var mustache = { - "idjanela": "", - "cabecalho": [{"classe":"hidden"},{"classe":"hidden"},{"classe":"hidden"},{"classe":"hidden"}], //4 colunas com icones - "linhas": [], - "ordena": $trad('ordena', i3GEOF.tabela.dicionario), - "excluir": $trad("t12") - }, - linha = { - "classezoom": "", - "ext": "", - "indice": "", - "idjanela": "" - }, - ins, i, vals, cor, j, n, stat, imagem, registros = i3GEOF.tabela.propJanelas[idjanela].registros, i3GEOtabelalegenda = - $i(idjanela + "i3GEOtabelalegenda").checked; - // cabecalho da tabela - mustache["idjanela"] = idjanela; - i3GEOF.tabela.propJanelas[idjanela].colunas = { - "itens" : retorno.data[0].itens, - "alias" : retorno.data[0].alias - }; - n = retorno.data[0].itens.length; - for (i = 0; i < n; i++) { - mustache.cabecalho.push({ - "idcoluna": i * 1 + 4, //pq tem 3 colunas com icones - "idjanela": idjanela, - "item": retorno.data[0].itens[i], - "alias": retorno.data[0].alias[i], - "classe": "" - }); - } - n = retorno.data[1].registros.length; - if ($i(idjanela + "i3GEOtabelafim").value === "") { - $i(idjanela + "i3GEOtabelafim").value = n - 1; - } - for (i = 0; i < n; i++) { - linha = {}; - linha.classezoom = "hidden"; - linha.ext = ""; - linha.idjanela = idjanela; - linha.indice = retorno.data[1].registros[i].indice; - if (retorno.data[1].registros[i].ext && retorno.data[1].registros[i].ext != "") { - linha.classezoom = ""; - linha.ext = retorno.data[1].registros[i].ext; - } - linha.stat = ""; - if (retorno.data[1].registros[i].status === "CHECKED") { - linha.stat = "CHECKED"; - } - if (registros[retorno.data[1].registros[i].indice]) { - if (registros[retorno.data[1].registros[i].indice] === true) { - linha.stat = "CHECKED"; - } else { - linha.stat = ""; - } - } - if (i3GEOtabelalegenda == true) { - linha.classelegenda = ""; - linha.nomeClasse = retorno.data[1].registros[i].classe["nome"]; - linha.imagemClasse = retorno.data.legenda[retorno.data[1].registros[i].classe["indice"]]; - imagem = retorno.data.legenda[retorno.data[1].registros[i].classe["indice"]]; - } else { - linha.classelegenda = "hidden"; - linha.nomeClasse = ""; - linha.imagemClasse = ""; - } - if (linha.stat === "CHECKED") { - registros[retorno.data[1].registros[i].indice] = true; - } - vals = retorno.data[1].registros[i].valores; - linha.colunas = ""; - for (j = 0; j < vals.length; j++) { - linha.colunas += "" + vals[j].valor + ""; - } - mustache.linhas.push(linha); - } - ins = Mustache.render(i3GEOF.tabela.MUSTACHELISTA, mustache); - $i(idjanela + "i3GEOtabelaregistros").innerHTML = ins; - } - i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "hidden"; - }, - /* - * Function: mais - * - * Avança o contador de registros para a listagem - */ - mais : function(idjanela) { - if (i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility === "visible") { - return; - } - var i = $i(idjanela + "i3GEOtabelainicio").value * 1, f = $i(idjanela + "i3GEOtabelafim").value * 1, d = f - i; - $i(idjanela + "i3GEOtabelainicio").value = f + 1; - $i(idjanela + "i3GEOtabelafim").value = f + d + 1; - i3GEOF.tabela.pegaRegistros(idjanela); - }, - /* - * Function: todos - * - * Avança o contador de registros para o fim da listagem - */ - todos : function(idjanela) { - if (i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility === "visible") { - return; - } - $i(idjanela + "i3GEOtabelainicio").value = 1; - $i(idjanela + "i3GEOtabelafim").value = ""; - i3GEOF.tabela.pegaRegistros(idjanela, false, false, false, 1, false); - }, - /* - * Function: menos - * - * Retrocede o contador de registros para a listagem - */ - menos : function(idjanela) { - if (i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility === "visible") { - return; - } - var i = $i(idjanela + "i3GEOtabelainicio").value * 1, f = $i(idjanela + "i3GEOtabelafim").value * 1, d = f - i; - $i(idjanela + "i3GEOtabelainicio").value = i - d - 1; - $i(idjanela + "i3GEOtabelafim").value = i - 1; - if ($i(idjanela + "i3GEOtabelainicio").value < 1) { - $i(idjanela + "i3GEOtabelainicio").value = 1; - $i(idjanela + "i3GEOtabelafim").value = 1 + d; - } - i3GEOF.tabela.pegaRegistros(idjanela); - }, - /* - * Function: excluiColuna - * - * Exclui uma coluna da visualização da tabela - */ - excluiColuna : function(coluna, cid, idjanela) { - i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "visible"; - try { - var tabela = $i(idjanela + "i3GEOtabelatabelai"), trs, tds, i, t, nt, ni; - // pega o indice correto - tds = coluna.parentNode.parentNode.getElementsByTagName("td"); - nt = tds.length; - for (t = 0; t < nt; t++) { - if (tds[t].accessKey == cid) { - cid = t; - break; - } - } - trs = tabela.getElementsByTagName("tr"); - nt = trs.length; - for (t = 0; t < nt; t++) { - i = trs[t]; - if (i.getElementsByTagName("td")[cid]) { - ni = i.getElementsByTagName("td")[cid]; - i.removeChild(ni); - } - } - i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "hidden"; - } catch (e) { - i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "hidden"; - if (typeof (console) !== 'undefined') { - console.error(e); - } - } - }, - /* - * Function: ordenaColuna - * - * Ordena uma coluna da tabela - */ - ordenaColuna : function(coluna, cid, idjanela) { - i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "visible"; - try { - var numero = false,tabela = $i(idjanela + "i3GEOtabelatabelai"), trs = tabela.getElementsByTagName("tr"), - ntrs = trs.length, tds, nt, psort = [], t, psortfim, npsortfim, ins, p, e, c; - - // pega o indice correto - tds = coluna.parentNode.parentNode.getElementsByTagName("td"); - nt = tds.length; - for (t = 0; t < nt; t++) { - if (tds[t].accessKey == cid) { - cid = t; - break; - } - } - for (t = 1; t < ntrs; t++) { - c = trs[t].getElementsByTagName("td")[cid].innerHTML; - psort.push( c + "@$" + t); - if (c * 1) { - numero = true; - } - } - // recosntroi a tabela - if(numero){ - psortfim = psort.sort(function(a, b) { - return a.split("@$")[0]*1 - b.split("@$")[0]*1; - }); - } else { - psortfim = psort.sort(); - } - - ins = ""; - ins += "" + trs[0].innerHTML + ""; - npsortfim = psortfim.length; - for (p = 0; p < npsortfim; p++) { - e = psortfim[p].split("@$")[1] * 1; - if (trs[e] !== undefined) { - ins += "" + trs[e].innerHTML + ""; - } - } - $i(idjanela + "i3GEOtabelaregistros").innerHTML = ins + "
"; - i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "hidden"; - } catch (e) { - i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "hidden"; - if (typeof (console) !== 'undefined') { - console.error(e); - } - } - }, - excluiLinha : function(celula) { - var p = celula.parentNode.parentNode; - do { - p.removeChild(p.childNodes[0]); - } while (p.childNodes.length > 0); - p.parentNode.removeChild(p); - }, - zoomExt : function(ext, idjanela) { - if (i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility === "visible") { - return; - } - i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "visible"; - var funcao = function() { - i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "hidden"; - i3GEOF.tabela.pegaRegistros(idjanela); - i3GEO.atualiza(); - }; - i3GEO.php.mudaext(funcao, "nenhum", ext); - }, - registraLinha : function(linha, idjanela) { - i3GEOF.tabela.propJanelas[idjanela].registros[linha.name] = linha.checked; - i3GEOF.tabela.vinculos.atualizaVinculos(idjanela, linha.name, linha.checked); - }, - /* - * Function: listaMarcados - * - * Retorna um array com os índices dos registros que estão marcados. - */ - listaMarcados : function(idjanela) { - var lista = [], registros = i3GEOF.tabela.propJanelas[idjanela].registros, i, n = registros.length; - for (i = 0; i < n; i++) { - if (registros[i] === true) { - lista.push(i); - } - } - return lista; - }, - /* - * Function: ativaSelecao - * - * Seleciona no mapa os elementos que estiverem marcados na guia 2 - * - * Veja: - * - * - */ - ativaSelecao : function(idjanela) { - if (i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility === "visible") { - return; - } - i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "visible"; - var lista = i3GEOF.tabela.listaMarcados(idjanela), p, cp, temp = function(retorno) { - if (retorno) { - i3GEO.Interface.atualizaTema(retorno, i3GEOF.tabela.propJanelas[idjanela].tema); - i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "hidden"; - } - }; - p = - i3GEO.configura.locaplic + "/ferramentas/tabela/exec.php?g_sid=" - + i3GEO.configura.sid - + "&funcao=incluisel&tema=" - + i3GEOF.tabela.propJanelas[idjanela].tema - + "&ids=" - + lista.toString(); - cp = new cpaint(); - cp.set_response_type("JSON"); - cp.call(p, "incluiSel", temp); - }, - /* - * Function: limpaSelecao - * - * Limpa a seleção do tema da tabela - */ - limpaSelecao : function(idjanela) { - if (i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility === "visible") { - return; - } - i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "visible"; - i3GEO.tema.limpasel(i3GEOF.tabela.propJanelas[idjanela].tema); - i3GEOF.tabela.propJanelas[idjanela].registros = []; - var lista = $i(idjanela + "i3GEOtabelatabelai").getElementsByTagName("input"), n = lista.length, i; - for (i = 0; i < n; i++) { - lista[i].checked = false; - } - i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "hidden"; - }, - /* - * Function: criaNovoTema - * - * Cria um novo tema contendo a seleção existente - */ - criaNovoTema : function(idjanela) { - var camada = i3GEO.arvoreDeCamadas.pegaTema(i3GEOF.tabela.propJanelas[idjanela].tema); - if(camada.nsel == 0){ - i3GEO.janela.tempoMsg($trad("selUmReg",i3GEOF.tabela.dicionario)); - return; - } - - if (i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility === "visible") { - return; - } - i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "visible"; - var temp = function(retorno) { - i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "hidden"; - i3GEO.atualiza(retorno); - }; - i3GEO.php.criatemaSel(temp, i3GEOF.tabela.propJanelas[idjanela].tema); - }, - /* - * Function: comboItens - * - * Cria um combo para selecionar um item do tema escolhido - */ - comboItensEstat : function(idjanela) { - var tema = i3GEOF.tabela.propJanelas[idjanela].tema; - i3GEO.util.comboItens(idjanela + "i3GEOtabelaComboItensGuia3", tema, function(retorno) { - if (retorno.tipo === "erro") { - $i(idjanela + "i3GEOtabelaitensGuia3").innerHTML = - i3GEO.janela.closeMsg(''); - } else { - $i(idjanela + "i3GEOtabelaitensGuia3").innerHTML = retorno.dados; - } - }, idjanela + "i3GEOtabelaitensGuia3", "","sim","","form-control"); - }, - estatistica : function(idjanela) { - if ($i(idjanela + "i3GEOtabelaComboItensGuia3").value === "") { - i3GEO.janela.tempoMsg("Escolha um item!"); - return; - } - if (i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility === "visible") { - return; - } - i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "visible"; - try { - var monta = function(retorno) { - var ins = "", nome, valor, i, n; - if (retorno.data.indices !== undefined) { - if (retorno.data.indices) { - n = retorno.data.indices.length; - for (i = 0; i < n; i++) { - nome =retorno.data.variaveis[retorno.data.indices[i]]; - valor = retorno.data.valores[retorno.data.indices[i]]; - ins += '

'+nome+'

'+valor+'

'; - ins += '
 
'; - } - } - } else { - ins = retorno.data; - } - $i(idjanela + "i3GEOtabelaoperacoes").innerHTML = ins + "
"; - i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "hidden"; - }, exclui = "", cp = new cpaint(), p; - if ($i(idjanela + "i3GEOtabelafiltro1").value !== "") { - exclui = $i("i3GEOtabelafiltro1").value; - } - p = - i3GEO.configura.locaplic + "/ferramentas/tabela/exec.php?g_sid=" - + i3GEO.configura.sid - + "&funcao=estatistica&item=" - + $i(idjanela + "i3GEOtabelaComboItensGuia3").value - + "&tema=" - + i3GEOF.tabela.propJanelas[idjanela].tema - + "&exclui=" - + exclui - + "&ext=" - + i3GEO.parametros.mapexten; - cp.set_response_type("JSON"); - cp.call(p, "estatDescritivas", monta); - } catch (e) { - i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "hidden"; - $i("operacoes").innerHTML = "Ocorreu um erro: " + e; - } - }, - tabelaTexto : function() { - }, - /* - * Function: relatorioTabela - * - * Monta o relatório padrão em uma nova janela - */ - relatorioTabela : function(idjanela) { - try { - $i(idjanela + "i3GEOtabelatiporelh").value = ""; - $i(idjanela + "i3GEOtabelaarearelh").value = $i(idjanela + "i3GEOtabelacalculaarea").checked; - $i(idjanela + "i3GEOtabelastatrelh").value = $i(idjanela + "i3GEOtabelacalculaestat").checked; - $i(idjanela + "i3GEOtabelaexcluirvalorh").value = $i(idjanela + "i3GEOtabelaexcestat").value; - $i(idjanela + "i3GEOtabelatemarelh").value = i3GEOF.tabela.propJanelas[idjanela].tema; - $i(idjanela + "i3GEOtabelag_sidh").value = i3GEO.configura.sid; - $i(idjanela + "i3GEOtabelaitemagruparelh").value = $i(idjanela + "i3GEOtabelaagrupaItem").value; - var inputs = $i(idjanela + "i3GEOtabelaitensrelatorio").getElementsByTagName("input"), listai = [], listaordem = [], listanomes = - [], nome, ordem, i, temp, n = inputs.length; - for (i = 0; i < n; i++) { - if (inputs[i].type === "checkbox" && inputs[i].checked == true) { - listai.push(inputs[i].id + "|" + inputs[i].name); - nome = $i(inputs[i].id + inputs[i].name).value; - listanomes.push(nome); - ordem = $i("ordem_" + inputs[i].id + inputs[i].name).value; - if (ordem === "") { - ordem = 0; - } - listaordem.push(ordem); - } - } - $i(idjanela + "i3GEOtabelaordemrel").value = listaordem; - $i(idjanela + "i3GEOtabelanomesrelh").value = listanomes; - $i(idjanela + "i3GEOtabelaitensrelh").value = listai; - temp = $i(idjanela + "i3GEOtabelarelatorio").action; - $i(idjanela + "i3GEOtabelarelatorio").action += "?ext=" + i3GEO.parametros.mapexten; - $i(idjanela + "i3GEOtabelarelatorio").submit(); - $i(idjanela + "i3GEOtabelarelatorio").action = temp; - } catch (e) { - i3GEO.janela.tempoMsg(e); - } - }, - /* - * Function: relatorioTexto - * - * Gera o relatório no formato CSV - */ - relatorioTexto : function(idjanela) { - $i(idjanela + "i3GEOtabelaarearelh").value = $i(idjanela + "i3GEOtabelacalculaarea").checked; - $i(idjanela + "i3GEOtabelastatrelh").value = $i(idjanela + "i3GEOtabelacalculaestat").checked; - $i(idjanela + "i3GEOtabelaexcluirvalorh").value = $i(idjanela + "i3GEOtabelaexcestat").value; - $i(idjanela + "i3GEOtabelatemarelh").value = i3GEOF.tabela.propJanelas[idjanela].tema; - $i(idjanela + "i3GEOtabelag_sidh").value = i3GEO.configura.sid; - $i(idjanela + "i3GEOtabelaitemagruparelh").value = $i(idjanela + "i3GEOtabelaagrupaItem").value; - $i(idjanela + "i3GEOtabelatiporelh").value = "csv"; - var inputs = $i(idjanela + "i3GEOtabelaitensrelatorio").getElementsByTagName("input"), listai = [], listanomes = [], nome, i, temp, n = - inputs.length; - for (i = 0; i < n; i++) { - if (inputs[i].checked === true) { - listai.push(inputs[i].id + "|" + inputs[i].name); - nome = $i(inputs[i].id + inputs[i].name).value; - listanomes.push(nome); - } - } - $i(idjanela + "i3GEOtabelanomesrelh").value = listanomes; - $i(idjanela + "i3GEOtabelaitensrelh").value = listai; - temp = $i(idjanela + "i3GEOtabelarelatorio").action; - $i(idjanela + "i3GEOtabelarelatorio").action += "?ext=" + i3GEO.parametros.mapexten; - $i(idjanela + "i3GEOtabelarelatorio").submit(); - $i(idjanela + "i3GEOtabelarelatorio").action = temp; - } + ins = ""; + ins += "" + trs[0].innerHTML + ""; + npsortfim = psortfim.length; + for (p = 0; p < npsortfim; p++) { + e = psortfim[p].split("@$")[1] * 1; + if (trs[e] !== undefined) { + ins += "" + trs[e].innerHTML + ""; + } + } + $i("i3GEOtabelaregistros").innerHTML = ins + "
"; + } catch (e) { + if (typeof (console) !== 'undefined') { + console.error(e); + } + } + }, + excluiLinha : function(celula) { + var p = celula.parentNode.parentNode; + do { + p.removeChild(p.childNodes[0]); + } while (p.childNodes.length > 0); + p.parentNode.removeChild(p); + }, + zoomExt : function(ext, idjanela) { + var funcao = function() { + i3GEOF.tabela.pegaRegistros(); + i3GEO.atualiza(); + }; + i3GEO.php.mudaext(funcao, "nenhum", ext); + }, + registraLinha : function(linha, idjanela) { + i3GEOF.tabela._parameters.registros[linha.name] = linha.checked; + }, + /* + * Function: listaMarcados + * + * Retorna um array com os índices dos registros que estão marcados. + */ + listaMarcados : function(idjanela) { + var lista = [], registros = i3GEOF.tabela._parameters.registros, i, n = registros.length; + for (i = 0; i < n; i++) { + if (registros[i] === true) { + lista.push(i); + } + } + return lista; + }, + /* + * Function: ativaSelecao + * + * Seleciona no mapa os elementos que estiverem marcados na guia 2 + * + * Veja: + * + * + */ + ativaSelecao : function() { + var lista = i3GEOF.tabela.listaMarcados(), p, cp, temp = function(retorno) { + if (retorno) { + i3GEO.Interface.atualizaTema(retorno, i3GEOF.tabela._parameters.tema); + } + }; + p = + i3GEO.configura.locaplic + "/ferramentas/tabela/exec.php?g_sid=" + + i3GEO.configura.sid + + "&funcao=incluisel&tema=" + + i3GEOF.tabela._parameters.tema + + "&ids=" + + lista.toString(); + cp = new cpaint(); + cp.set_response_type("JSON"); + cp.call(p, "incluiSel", temp); + }, + /* + * Function: limpaSelecao + * + * Limpa a seleção do tema da tabela + */ + limpaSelecao : function() { + i3GEO.tema.limpasel(i3GEOF.tabela._parameters.tema); + i3GEOF.tabela._parameters.registros = []; + var lista = $i("i3GEOtabelatabelai").getElementsByTagName("input"), n = lista.length, i; + for (i = 0; i < n; i++) { + lista[i].checked = false; + } + }, + /* + * Function: criaNovoTema + * + * Cria um novo tema contendo a seleção existente + */ + criaNovoTema : function(idjanela) { + var camada = i3GEO.arvoreDeCamadas.pegaTema(i3GEOF.tabela._parameters.tema); + if(camada.nsel == 0){ + i3GEO.janela.tempoMsg($trad("selUmReg",i3GEOF.tabela.dicionario)); + return; + } + var temp = function(retorno) { + i3GEO.atualiza(retorno); + }; + i3GEO.php.criatemaSel(temp, i3GEOF.tabela._parameters.tema); + }, + /* + * Function: comboItens + * + * Cria um combo para selecionar um item do tema escolhido + */ + comboItensEstat : function(idjanela) { + var tema = i3GEOF.tabela._parameters.tema; + i3GEO.util.comboItens("i3GEOtabelaComboItensGuia3", tema, function(retorno) { + if (retorno.tipo === "erro") { + $i("i3GEOtabelaitensGuia3").innerHTML = + i3GEO.janela.closeMsg(''); + } else { + $i("i3GEOtabelaitensGuia3").innerHTML = retorno.dados; + } + }, "i3GEOtabelaitensGuia3", "","sim","","form-control"); + }, + estatistica : function(idjanela) { + if ($i("i3GEOtabelaComboItensGuia3").value === "") { + i3GEO.janela.tempoMsg("Escolha um item!"); + return; + } + try { + var monta = function(retorno) { + var ins = "", nome, valor, i, n; + if (retorno.data.indices !== undefined) { + if (retorno.data.indices) { + n = retorno.data.indices.length; + for (i = 0; i < n; i++) { + nome =retorno.data.variaveis[retorno.data.indices[i]]; + valor = retorno.data.valores[retorno.data.indices[i]]; + ins += '

'+nome+'

'+valor+'

'; + ins += '
 
'; + } + } + } else { + ins = retorno.data; + } + $i("i3GEOtabelaoperacoes").innerHTML = ins + "
"; + }, exclui = "", cp = new cpaint(), p; + if ($i("i3GEOtabelafiltro1").value !== "") { + exclui = $i("i3GEOtabelafiltro1").value; + } + p = + i3GEO.configura.locaplic + "/ferramentas/tabela/exec.php?g_sid=" + + i3GEO.configura.sid + + "&funcao=estatistica&item=" + + $i("i3GEOtabelaComboItensGuia3").value + + "&tema=" + + i3GEOF.tabela._parameters.tema + + "&exclui=" + + exclui + + "&ext=" + + i3GEO.parametros.mapexten; + cp.set_response_type("JSON"); + cp.call(p, "estatDescritivas", monta); + } catch (e) { + $i("operacoes").innerHTML = "Ocorreu um erro: " + e; + } + }, + tabelaTexto : function() { + }, + /* + * Function: relatorioTabela + * + * Monta o relatório padrão em uma nova janela + */ + relatorioTabela : function() { + try { + $i("i3GEOtabelatiporelh").value = ""; + $i("i3GEOtabelaarearelh").value = $i("i3GEOtabelacalculaarea").checked; + $i("i3GEOtabelastatrelh").value = $i("i3GEOtabelacalculaestat").checked; + $i("i3GEOtabelaexcluirvalorh").value = $i("i3GEOtabelaexcestat").value; + $i("i3GEOtabelatemarelh").value = i3GEOF.tabela._parameters.tema; + $i("i3GEOtabelag_sidh").value = i3GEO.configura.sid; + $i("i3GEOtabelaitemagruparelh").value = $i("i3GEOtabelaagrupaItem").value; + var inputs = $i("i3GEOtabelaitensrelatorio").getElementsByTagName("input"), listai = [], listaordem = [], listanomes = + [], nome, ordem, i, temp, n = inputs.length; + for (i = 0; i < n; i++) { + if (inputs[i].type === "checkbox" && inputs[i].checked == true) { + listai.push(inputs[i].id + "|" + inputs[i].name); + nome = $i(inputs[i].id + inputs[i].name).value; + listanomes.push(nome); + ordem = $i("ordem_" + inputs[i].id + inputs[i].name).value; + if (ordem === "") { + ordem = 0; + } + listaordem.push(ordem); + } + } + $i("i3GEOtabelaordemrel").value = listaordem; + $i("i3GEOtabelanomesrelh").value = listanomes; + $i("i3GEOtabelaitensrelh").value = listai; + temp = $i("i3GEOtabelarelatorio").action; + $i("i3GEOtabelarelatorio").action += "?ext=" + i3GEO.parametros.mapexten; + $i("i3GEOtabelarelatorio").submit(); + $i("i3GEOtabelarelatorio").action = temp; + } catch (e) { + i3GEO.janela.tempoMsg(e); + } + }, + /* + * Function: relatorioTexto + * + * Gera o relatório no formato CSV + */ + relatorioTexto : function(idjanela) { + $i("i3GEOtabelaarearelh").value = $i("i3GEOtabelacalculaarea").checked; + $i("i3GEOtabelastatrelh").value = $i("i3GEOtabelacalculaestat").checked; + $i("i3GEOtabelaexcluirvalorh").value = $i("i3GEOtabelaexcestat").value; + $i("i3GEOtabelatemarelh").value = i3GEOF.tabela._parameters.tema; + $i("i3GEOtabelag_sidh").value = i3GEO.configura.sid; + $i("i3GEOtabelaitemagruparelh").value = $i("i3GEOtabelaagrupaItem").value; + $i("i3GEOtabelatiporelh").value = "csv"; + var inputs = $i("i3GEOtabelaitensrelatorio").getElementsByTagName("input"), listai = [], listanomes = [], nome, i, temp, n = + inputs.length; + for (i = 0; i < n; i++) { + if (inputs[i].checked === true) { + listai.push(inputs[i].id + "|" + inputs[i].name); + nome = $i(inputs[i].id + inputs[i].name).value; + listanomes.push(nome); + } + } + $i("i3GEOtabelanomesrelh").value = listanomes; + $i("i3GEOtabelaitensrelh").value = listai; + temp = $i("i3GEOtabelarelatorio").action; + $i("i3GEOtabelarelatorio").action += "?ext=" + i3GEO.parametros.mapexten; + $i("i3GEOtabelarelatorio").submit(); + $i("i3GEOtabelarelatorio").action = temp; + } }; \ No newline at end of file diff --git a/ferramentas/tabela/templateLista_mst.html b/ferramentas/tabela/templateLista_mst.html index d68b06d..8612b6e 100755 --- a/ferramentas/tabela/templateLista_mst.html +++ b/ferramentas/tabela/templateLista_mst.html @@ -1,4 +1,4 @@ - +
{{#cabecalho}} "; + } + mustache.linhas.push(linha); + } + ins = Mustache.render(i3GEOF.tabela.MUSTACHELISTA, mustache); + $i(idjanela + "i3GEOtabelaregistros").innerHTML = ins; + } + i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "hidden"; + }, + /* + * Function: mais + * + * Avança o contador de registros para a listagem + */ + mais : function(idjanela) { + if (i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility === "visible") { + return; + } + var i = $i(idjanela + "i3GEOtabelainicio").value * 1, f = $i(idjanela + "i3GEOtabelafim").value * 1, d = f - i; + $i(idjanela + "i3GEOtabelainicio").value = f + 1; + $i(idjanela + "i3GEOtabelafim").value = f + d + 1; + i3GEOF.tabela.pegaRegistros(idjanela); + }, + /* + * Function: todos + * + * Avança o contador de registros para o fim da listagem + */ + todos : function(idjanela) { + if (i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility === "visible") { + return; + } + $i(idjanela + "i3GEOtabelainicio").value = 1; + $i(idjanela + "i3GEOtabelafim").value = ""; + i3GEOF.tabela.pegaRegistros(idjanela, false, false, false, 1, false); + }, + /* + * Function: menos + * + * Retrocede o contador de registros para a listagem + */ + menos : function(idjanela) { + if (i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility === "visible") { + return; + } + var i = $i(idjanela + "i3GEOtabelainicio").value * 1, f = $i(idjanela + "i3GEOtabelafim").value * 1, d = f - i; + $i(idjanela + "i3GEOtabelainicio").value = i - d - 1; + $i(idjanela + "i3GEOtabelafim").value = i - 1; + if ($i(idjanela + "i3GEOtabelainicio").value < 1) { + $i(idjanela + "i3GEOtabelainicio").value = 1; + $i(idjanela + "i3GEOtabelafim").value = 1 + d; + } + i3GEOF.tabela.pegaRegistros(idjanela); + }, + /* + * Function: excluiColuna + * + * Exclui uma coluna da visualização da tabela + */ + excluiColuna : function(coluna, cid, idjanela) { + i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "visible"; + try { + var tabela = $i(idjanela + "i3GEOtabelatabelai"), trs, tds, i, t, nt, ni; + // pega o indice correto + tds = coluna.parentNode.parentNode.getElementsByTagName("td"); + nt = tds.length; + for (t = 0; t < nt; t++) { + if (tds[t].accessKey == cid) { + cid = t; + break; + } + } + trs = tabela.getElementsByTagName("tr"); + nt = trs.length; + for (t = 0; t < nt; t++) { + i = trs[t]; + if (i.getElementsByTagName("td")[cid]) { + ni = i.getElementsByTagName("td")[cid]; + i.removeChild(ni); + } + } + i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "hidden"; + } catch (e) { + i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "hidden"; + if (typeof (console) !== 'undefined') { + console.error(e); + } + } + }, + /* + * Function: ordenaColuna + * + * Ordena uma coluna da tabela + */ + ordenaColuna : function(coluna, cid, idjanela) { + i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "visible"; + try { + var numero = false,tabela = $i(idjanela + "i3GEOtabelatabelai"), trs = tabela.getElementsByTagName("tr"), + ntrs = trs.length, tds, nt, psort = [], t, psortfim, npsortfim, ins, p, e, c; + + // pega o indice correto + tds = coluna.parentNode.parentNode.getElementsByTagName("td"); + nt = tds.length; + for (t = 0; t < nt; t++) { + if (tds[t].accessKey == cid) { + cid = t; + break; + } + } + for (t = 1; t < ntrs; t++) { + c = trs[t].getElementsByTagName("td")[cid].innerHTML; + psort.push( c + "@$" + t); + if (c * 1) { + numero = true; + } + } + // recosntroi a tabela + if(numero){ + psortfim = psort.sort(function(a, b) { + return a.split("@$")[0]*1 - b.split("@$")[0]*1; + }); + } else { + psortfim = psort.sort(); + } + + ins = "
@@ -21,7 +21,7 @@ diff --git a/ferramentas/tabela/template_mst.html b/ferramentas/tabela/template_mst.html index 472a211..0a83b74 100755 --- a/ferramentas/tabela/template_mst.html +++ b/ferramentas/tabela/template_mst.html @@ -1,165 +1,147 @@ - - -
-
- -
-
- -
-
- -
-
- -
-
- -
- -
- {{{de}}}   - -   {{{ate}}}   - -   - - - - + +
+ +
+
{{{operReg}}}
+ +
{{{opcoes}}}
+
+ +
+
+ +
+
+ +
+
+ +
+
+ {{{de}}}   + +   {{{ate}}}   + +   + + + + +
+
+
+ + - - - -
-
- -
-
-
- -
-
+
{{{paraqueas}}}
+
+ +
+
+ +
+
+
+ +
+
-
- - -
+
+ + +
-
- -
+
+ +
-
- -
+
+ +
- - + + - -
+ +
\ No newline at end of file diff --git a/ferramentas/tabela_old/dependencias.php b/ferramentas/tabela_old/dependencias.php new file mode 100644 index 0000000..fc41816 --- /dev/null +++ b/ferramentas/tabela_old/dependencias.php @@ -0,0 +1,24 @@ + ou com a funcao scripttag do i3Geo + * Alem de carregar os scripts, carrega tambem o template no formato MUSTACHE, definindo a variavel + * javascript i3GEOF.tabela.MUSTACHE + * O template e substituido pelos valores definidos em index.js no momento da inicializacao da ferramenta + */ +if(extension_loaded('zlib')){ + ob_start('ob_gzhandler'); +} +header("Content-type: text/javascript"); +include("index.js"); +include("dicionario.js"); +echo "\n"; + +if(extension_loaded('zlib')){ + ob_end_flush(); +} +?> \ No newline at end of file diff --git a/ferramentas/tabela_old/dicionario.js b/ferramentas/tabela_old/dicionario.js new file mode 100644 index 0000000..e19c6fc --- /dev/null +++ b/ferramentas/tabela_old/dicionario.js @@ -0,0 +1,253 @@ +//+$trad(1,i3GEOF.tabela.dicionario)+ +i3GEOF.tabela.dicionario = { + 'tabela' : [ { + pt : "Tabela", + en : "Table", + es : "Tabla" + } ], + 'erroTemaOrigem' : [ { + pt : "erro ao ler os itens do tema de origem", + en : "error reading fields from source theme", + es : "error al leer los campos del tema de origen" + } ], + "registros" : [ { + pt : "Registros", + en : "Records", + es : "Registros" + } ], + "estatisticas" : [ { + pt : "Estatísticas", + en : "Statistics", + es : "Estadísticas" + } ], + "relat" : [ { + pt : "Relatórios", + en : "Reports", + es : "Informes" + } ], + 6 : [ { + pt : "Considerar na listagem a região mostrada no mapa (se essa opção for desmarcada, será considerada a extensão geográfica do mapa inicial)", + en : "The area shown on the map will be included in the list (the geographic extent of the initial map will be used if this option is disabled)", + es : "Considerar en la lista el área que se muestra en el mapa (si esta opción es desactivada se considerará la extensión geográfica del mapa inicial)" + } ], + 7 : [ { + pt : "Atualiza a tabela após navegar no mapa", + en : "Refreshes the table after browsing the map", + es : "Actualiza la tabla después de navegar en el mapa" + } ], + "atuatab" : [ { + pt : "Mostrar na listagem apenas os selecionados", + en : "Show selected only", + es : "Mostrar solo los seleccionados" + } ], + "colleg" : [ { + pt : "Mostrar coluna com a legenda da classe", + en : "Show column with class legend", + es : "Mostrar columna con la leyenda de la clase" + } ], + "sellinhas" : [ { + pt : "Seleciona no mapa as linhas marcadas", + en : "Selects marked lines on the map", + es : "Selecciona en el mapa las líneas marcadas" + } ], + "atvsel" : [ { + pt : "Selecionar", + en : "Select", + es : "Seleccionar" + } ], + "limpselmap" : [ { + pt : "Limpa a seleção do mapa", + en : "Clear selection from map", + es : "Limpia la selección del mapa" + } ], + "limpsel" : [ { + pt : "Limpar", + en : "Clear", + es : "Limpiar" + } ], + "criatemasel" : [ { + pt : "Cria um novo tema no mapa contendo a seleção", + en : "Creates a new theme on the map containing the selection", + es : "Crea un tema nuevo en el mapa que contiene la selección" + } ], + "criatema" : [ { + pt : "Criar tema", + en : "Create theme", + es : "Crear tema" + } ], + "de" : [ { + pt : "de", + en : "from", + es : "de" + } ], + "ate" : [ { + pt : "até", + en : "until", + es : "hasta" + } ], + "atuareg" : [ { + pt : "Atualiza a lista de registros", + en : "Updates record list", + es : "Actualiza la lista de registros" + } ], + "listar" : [ { + pt : "Listar", + en : "List", + es : "Crear lista" + } ], + "itemcalc" : [ { + pt : "Item para aplicar os cálculos", + en : "Field to apply calculations", + es : "Campo para aplicar los cálculos" + } ], + "excluicalc" : [ { + pt : "Excluir dos cálculos o valor", + en : "Exclude from calculations the value", + es : "Excluir de los cálculos el valor" + } ], + "calc" : [ { + pt : "Calcular", + en : "Calculate", + es : "Calcular" + } ], + "paraqueas" : [ { + pt : "Para que as operações atuem apenas sobre os elementos selecionados ative a seleção no mapa, para isso utilize, na guia Registros a opção Ativa a seleção", + en : "In order that operations execute only on selected features, enable selection on the map. To do that use Enable selection option on the Record tab", + es : "Para que las operaciones actúen solo sobre las entidades seleccionadas, active la selección en el mapa, para ello utilice la opción Activa la selección en la pestaña Registros" + } ], + "itensrel" : [ { + pt : "Escolha os itens que deverão constar no relatório. Você pode alterar os nomes originais das colunas para melhorar o cabeçalho do relatório e também definir a ordem das colunas no relatório", + en : "Select fields that should appear in the report. You can change column order and names to improve the report header", + es : "Seleccione los campos que deben estar presente en el informe. Usted puede cambiar los nombres originales de las columnas para mejorar el encabezado del informe y cambiar también el orden de las columnas en el informe" + } ], + "itensagr" : [ { + pt : "Escolha o item que você quer utilizar para agrupar valores (opcional)", + en : "Select a field you want to use to group values (optional)", + es : "Seleccione el campo que desea utilizar para agrupar valores (opcional)" + } ], + "incarea" : [ { + pt : "Incluir cálculo de área", + en : "Include area calculation", + es : "Incluir cálculo de área" + } ], + "incestat" : [ { + pt : "Incluir cálculo de estatísticas", + en : "Include statistics calculation", + es : "Incluir cálculo de estadísticas" + } ], + "excvalor" : [ { + pt : "Excluir das estatísticas o valor", + en : "Delete value from statistics", + es : "Excluir de las estadísticas el valor" + } ], + "relattext" : [ { + pt : "Relatório no formato texto", + en : "Report in text format", + es : "Informe en formato de texto" + } ], + 'temaNaoExisteMais' : [ { + pt : "O tema já não existe mais no mapa", + en : "El tema ya no está disponible en el mapa", + es : "El tema ya no existe en el mapa" + } ], + 'ordena' : [ { + pt : "ordena", + en : "sort", + es : "ordenar" + } ], + 'erroTemaOrigem2' : [ { + pt : "erro ao ler os itens do tema de origem", + en : "error reading fields from source theme", + es : "error al leer los campos del tema de origen" + } ], + 33 : [ { + pt : "A representação gráfica dos dados tabulares utiliza todos os elementos da tabela ou os selecionados, se estiverem ativos no mapa", + en : "Graphical representation of tabular data uses all or selected fields if they are active on the map", + es : "La representación gráfica de los datos en tablas utiliza todos los campos de la tabla o los seleccionados si están activos en el mapa" + } ], + 34 : [ { + pt : "Os gráficos são gerados com o software R, mas vc pode optar por usar a ferramenta de gráficos interativos que possuem outras opções e geram gráficos em Flash.", + en : "Charts are generated with R software, but you can use the interactive chart tool that has other options and allows you to create Flash charts.", + es : "Los gráficos se generan con el software R, pero usted puede optar por usar la herramienta de gráficos interactivos que tienen otras opciones que crean gráficos en Flash." + } ], + 35 : [ { + pt : "Se você optar por usar o R, nas telas seguintes defina o tipo e as opções do gráfico", + en : "If you choose to use R, in the following screens define a chart type and options", + es : "Si opta por utilizar R, en las siguientes pantallas defina el tipo y las opciones del gráfico" + } ], + 36 : [ { + pt : "abrir em uma janela separada", + en : "open in a detached window", + es : "abrir en una ventana separada" + } ], + 37 : [ { + pt : "Marque uma coluna para vincular com outras tabelas. Marque uma linha para localizar em todas as tabelas abertas", + en : "Check a column to link to other tables. Check one line to search in all open tables", + es : "Marque una columna para enlazar con otras tablas. Marque una línea para buscar en todas las tablas abiertas" + } ], + 'msgDadosRegiaoAtual' : [ { + pt : "Os dados utilizados referem-se apenas à região atual mostrada no mapa", + en : "Data in use is only related to the current region shown on the map", + es : "Los datos utilizados se relacionan solo con la región actual mostrada en el mapa" + } ], + 39 : [ { + pt : "Marque uma coluna primeiro", + en : "Check first a column", + es : "Marque una columna primero" + } ], + "vertodos" : [ { + pt : "Ver todos", + en : "See all", + es : "Ver todos" + } ], + 'atualizaAoNavegar' : [ { + pt : "Atualiza a listagem ao navegar", + en : "Refresh listing when browsing", + es : "Actualiza la lista al navegar" + } ], + "grafico" : [ { + pt : "Gráfico", + en : "Chart", + es : "Gráfico" + } ], + "vinctab" : [ { + pt : "Vínculos entre as tabelas abertas", + en : "Links between open tables", + es : "Vínculos entre las tablas abiertas" + } ], + "vinculos" : [ { + pt : "Vínculos", + en : "Links", + es : "Vínculos" + } ], + "selecionaTabela" : [ { + pt : "Escolha uma tabela", + en : "Select a table", + es : "Seleccione una tabla" + } ], + "selecionaSegundaTabela" : [ { + pt : "Escolha uma segunda tabela", + en : "Select a second table", + es : "Seleccione una segunda tabla" + } ], + "criaVinculo" : [ { + pt : "Criar vínculo", + en : "Create link", + es : "Crear vínculo" + } ], + 'colunaLigacao' : [ { + pt : "Coluna de ligação", + en : "Connection column", + es : "Columna de conexión" + } ], + 'idDaTabela' : [ { + pt : "Identificador da tabela", + en : "Table identifier", + es : "Identificador de tabla" + } ], + 'selUmReg' : [ { + pt : "Selecione pelo menos um registro", + en : "Select at least one record", + es : "Seleccione al menos un registro" + } ] +}; diff --git a/ferramentas/tabela_old/exec.php b/ferramentas/tabela_old/exec.php new file mode 100644 index 0000000..905b8af --- /dev/null +++ b/ferramentas/tabela_old/exec.php @@ -0,0 +1,145 @@ +incluiSel> +*/ + case "INCLUISEL": + include_once(dirname(__FILE__)."/../../classesphp/classe_selecao.php"); + $m = new Selecao($map_file,$tema); + $retorno = $m->incluiSel($_GET["ids"]); + // + //é necessário obter os parâmetros do mapa para remontar a árvore de camadas + // + $_SESSION["contadorsalva"]++; + redesenhaMapa(); + break; +/* +Valor: ESTATISTICA + +Calcula estatísticas básicas de uma tabela de um tema. + +estatDescritivas> +*/ + case "ESTATISTICA": + include_once(dirname(__FILE__)."/../../classesphp/classe_atributos.php"); + $m = new Atributos($map_file,$tema,$locaplic,$ext); + $retorno = $m->estatDescritivas($_GET["item"],$_GET["exclui"]); + break; +/* +Valor: GRAFICOPIZZA + +Cria um gráfico de pizza. + + +*/ + case "GRAFICOPIZZA": + include_once(dirname(__FILE__)."/../../classesphp/graficos.php"); + $retorno = graficoPizza(); + break; +/* +Valor: GRAFICOESTRELA + +Cria um gráfico do tipo estrela. + + +*/ + case "GRAFICOESTRELA": + include_once(dirname(__FILE__)."/../../classesphp/graficos.php"); + $retorno = graficoEstrela(); + break; +/* +Valor: GRAFICOSCATTER + +Cria um gráfico de distribuição de pontos. + + +*/ + case "GRAFICOSCATTER": + include_once(dirname(__FILE__)."/../../classesphp/graficos.php"); + $retorno = graficoScatter(); + break; +/* +Valor: GRAFICOSCATTERBINS + +Cria um gráfico de distribuição de pontos com agrupamento em pixels (bins). + + +*/ + case "GRAFICOSCATTERBINS": + include_once(dirname(__FILE__)."/../../classesphp/graficos.php"); + $retorno = graficoScatterBins(); + break; +/* +Valor: GRAFICOLINHAS + +Cria um gráfico de linhas. + + +*/ + case "GRAFICOLINHAS": + include_once(dirname(__FILE__)."/../../classesphp/graficos.php"); + $retorno = graficoLinhas(); + break; +/* +Valor: GRAFICOHIST + +Cria um gráfico de histograma. + + +*/ + case "GRAFICOHIST": + include_once(dirname(__FILE__)."/../../classesphp/graficos.php"); + $retorno = graficoHist(); + break; +/* +Valor: GRAFICOBARRAS + +Cria um gráfico de barras. + + +*/ + case "GRAFICOBARRAS": + include_once(dirname(__FILE__)."/../../classesphp/graficos.php"); + $retorno = graficoBarras(); + break; +/* +Valor: FUSAOGRAFICO + +Faz a fusão da imagem de um gráfico com a imagem do mapa atual. + + +*/ + case "FUSAOGRAFICO": + include_once(dirname(__FILE__)."/../../classesphp/graficos.php"); + restauraCon($map_file,$postgis_mapa); + include_once(dirname(__FILE__)."/../../classesphp/classe_imagem.php"); + if($map_file != "") + { + $mapa = ms_newMapObj($map_file); + $imgo = $mapa->draw(); + $nome = ($imgo->imagepath).nomeRandomico().".png"; + $imgo->saveImage($nome); + $imagem = ($imgo->imageurl).basename($nome); + } + $m = new Imagem(dirname($dir_tmp).$imagem); + $i = $m->fundeIm(dirname($dir_tmp).$grafico); + imagepng($i,dirname($dir_tmp).$imagem); + $retorno = $imagem; + break; +} +if(isset($map_file) && isset($postgis_mapa) && $map_file != ""){ + restauraCon($map_file,$postgis_mapa); +} +cpjson($retorno); +?> \ No newline at end of file diff --git a/ferramentas/tabela_old/index.js b/ferramentas/tabela_old/index.js new file mode 100644 index 0000000..e19b9ad --- /dev/null +++ b/ferramentas/tabela_old/index.js @@ -0,0 +1,1203 @@ +if (typeof (i3GEOF) === 'undefined') { + var i3GEOF = {}; +} +/* + * Classe: i3GEOF.tabela + */ +i3GEOF.tabela = +{ + /** + * Controla se o evento de atualizacao da lista de registros esta ativo ou nao E utilizado quando os graficos sao recuperados de um + * mapa que foi salvo + */ + LISTAREGATIVO : true, + /** + * Array com os ids das janelas ja criadas + */ + janelas : [], + /** + * Objeto com as propriedades de cada janela. A chave e o id da janela armazenado em i3GEO.tabela.janelas + */ + propJanelas : {}, + /** + * Template no formato mustache. E preenchido na carga do javascript com o programa dependencias.php + */ + MUSTACHE : "", + MUSTACHELISTA : "", + MUSTACHEVINCULO: "", + /** + * Susbtitutos para o template + */ + mustacheHash : function(idjanela) { + var dicionario = i3GEO.idioma.objetoIdioma(i3GEOF.tabela.dicionario); + dicionario["idjanela"] = idjanela; + dicionario["idjanelaA"] = '"' + idjanela + '"'; + dicionario["locaplic"] = i3GEO.configura.locaplic; + dicionario["propriedades"] = $trad('p13'); + dicionario["ini"] = $inputText("", "", idjanela + 'i3GEOtabelainicio', "", 5, "1"); + dicionario["fim"] = $inputText("", "", idjanela + 'i3GEOtabelafim', "", 5, "20"); + return dicionario; + }, + /** + * Configura a tabela conforme um objeto contendo parametros. Alguns parametros possuem definicoes padrao, usadas quando o valor nao + * e passado + * + * Qualquer outro campo de formulario pode ter seu valor passado como parametro, desde que use o mesmo ID, excluindo-se do nome do + * ID o prefixo (codigo da janela) + * + * parametros {objeto} com os seguintes elementos: + * + * idjanela - id da tabela. Usado como prefixo para inserir os identificadores dos elementos DOM que fazem parte da interface do + * tabela. Se existir um elemento dom esse id, a tabela sera inserido nesse elemento + * + * tema - codigo do tema existente no mapa e que sera a fonte para os dados + * + * atualiza true|false - a janela sera atualizada na navegacao do mapa ou nao + * + */ + configura : function(parametros) { + var idjanela; + if (!parametros.idjanela) { + idjanela = "tabela" + parseInt(Math.random() * 1000000, 10); + } else { + idjanela = parametros.idjanela; + } + i3GEOF.tabela.janelas.push(idjanela); + if (parametros) { + i3GEOF.tabela.propJanelas[idjanela] = parametros; + } else { + i3GEOF.tabela.propJanelas[idjanela] = {}; + } + if (!parametros.tema || parametros.tema == undefined) { + i3GEOF.tabela.propJanelas[idjanela].tema = i3GEO.temaAtivo; + } + if (!parametros.atualiza || parametros.atualiza == undefined) { + i3GEOF.tabela.propJanelas[idjanela].atualiza = true; + } + // guarda para essa tabela alguns valores default obtidos dos + // parametros gerais da ferramenta + if (!parametros.w || parametros.w == undefined) { + i3GEOF.tabela.propJanelas[idjanela].w = i3GEOF.tabela.w; + } + if (!parametros.h || parametros.h == undefined) { + i3GEOF.tabela.propJanelas[idjanela].h = i3GEOF.tabela.h; + } + i3GEOF.tabela.propJanelas[idjanela].colunas = { + "itens" : [], + "alias" : [] + }; + i3GEOF.tabela.propJanelas[idjanela].registros = []; + return idjanela; + }, + /** + * Aplica a tabela os parametros de configuracao definidos para cada interface que controla a tabela. Os parametros de configuracao + * sao obtidos na inicializacao, passados como parametros. Essa funcao deve ser executada apos os elementos html terem sido + * renderizados + */ + aplicaConfig : function(idjanela) { + var config, nomesIds, i, o, n, j; + config = i3GEOF.tabela.propJanelas[idjanela]; + nomesIds = i3GEO.util.listaChaves(config); + n = nomesIds.length; + for (j = 0; j < n; j++) { + i = nomesIds[j]; + if (config[i]) { + o = $i(i); + if (o && o.type) { + if (o.type.toLowerCase() === "radio" || o.type.toLowerCase() === "checkbox") { + o.checked = config[i]; + } else { + o.value = config[i]; + } + } + } + } + }, + /* + * Function: inicia + * + * Inicia a ferramenta. É chamado por criaJanelaFlutuante + * + * Parametro: + * + * iddiv {String} - id do div que receberá o conteudo HTML da ferramenta + */ + inicia : function(iddiv, idjanela) { + if(i3GEOF.tabela.MUSTACHE == ""){ + var t1 = i3GEO.configura.locaplic + "/ferramentas/tabela/template_mst.html", + t2 = i3GEO.configura.locaplic + "/ferramentas/tabela/templateLista_mst.html", + t3 = i3GEO.configura.locaplic + "/ferramentas/tabela/templateVinculo_mst.html"; + + $.when( $.get(t1),$.get(t2),$.get(t3) ).done(function(r1,r2,r3) { + i3GEOF.tabela.MUSTACHE = r1[0]; + i3GEOF.tabela.MUSTACHELISTA = r2[0]; + i3GEOF.tabela.MUSTACHEVINCULO = r3[0]; + i3GEOF.tabela.inicia(iddiv, idjanela); + }).fail(function() { + i3GEO.janela.closeMsg($trad("erroTpl")); + return; + }); + return; + } + $i(iddiv).innerHTML = i3GEOF.tabela.html(idjanela); + + //i3GEO.janela.applyScrollBar(iddiv,".customScrollBar",{advanced:{ autoExpandHorizontalScroll: 2 }}); + + var b, onButtonClick = function(evt) { + var botao = evt.target; + if (botao) { + if (botao.value != "") { + i3GEO.mapa.ativaTema(botao.value); + i3GEOF.tabela.propJanelas[idjanela].tema = botao.value; + i3GEOF.tabela.inicia(iddiv, idjanela); + } + } + }; + if (!$i(idjanela + "i3GEOFtabelaComboCabecaSel")) { + i3GEO.janela.comboCabecalhoTemasBs( + idjanela + "i3GEOFtabelaComboCabeca", + idjanela + "i3GEOFtabelaComboCabecaSel", + "tabela", + "comTabela", + onButtonClick); + } + i3GEO.guias.mostraGuiaFerramenta(idjanela + "i3GEOtabelaguia1", idjanela + "i3GEOtabelaguia"); + // eventos das guias + $i(idjanela + "i3GEOtabelaguia6").onclick = function() { + i3GEO.guias.mostraGuiaFerramenta(idjanela + "i3GEOtabelaguia6", idjanela + "i3GEOtabelaguia"); + }; + $i(idjanela + "i3GEOtabelaguia1").onclick = function() { + i3GEO.guias.mostraGuiaFerramenta(idjanela + "i3GEOtabelaguia1", idjanela + "i3GEOtabelaguia"); + }; + $i(idjanela + "i3GEOtabelaguia3").onclick = function() { + i3GEO.guias.mostraGuiaFerramenta(idjanela + "i3GEOtabelaguia3", idjanela + "i3GEOtabelaguia"); + if (!$i(idjanela + "i3GEOtabelaComboItensGuia3")) { + i3GEOF.tabela.comboItensEstat(idjanela); + } + }; + // relatorio + $i(idjanela + "i3GEOtabelaguia5").onclick = + function() { + i3GEO.guias.mostraGuiaFerramenta(idjanela + "i3GEOtabelaguia5", idjanela + "i3GEOtabelaguia"); + i3GEO.util.checkItensEditaveis(i3GEOF.tabela.propJanelas[idjanela].tema, function(retorno) { + if (retorno.tipo === "dados") { + $i(idjanela + "i3GEOtabelaitensrelatorio").innerHTML = retorno.dados; + } + }, idjanela + "i3GEOtabelaitensrelatorio", "320px", "", "sim"); + i3GEO.util.comboItens(idjanela + "i3GEOtabelaagrupaItem", i3GEOF.tabela.propJanelas[idjanela].tema, function( + retorno) { + if (retorno.tipo === "erro") { + i3GEO.janela.closeMsg(''); + } else { + $i(idjanela + "i3GEOtabelaagrupamento").innerHTML = retorno.dados; + } + }, idjanela + "i3GEOtabelaagrupamento", "","sim","","form-control"); + }; + + + if (i3GEO.parametros.r.toLowerCase() !== "sim") { + $i(idjanela + "i3GEOtabelaguia4obj").innerHTML = $trad("x22"); + } + i3GEOF.tabela.pegaRegistros(idjanela); + i3GEO.guias.ajustaGuiaFerramenta(idjanela, idjanela + "i3GEOtabela"); + // + // Apos todos os elementos HTML da ferramenta terem sido renderizados + // aplicam-se os parametros armazenados nas propriedades da janela atual + // Isso e necessario pois os parametros podem ter sido enviados na inicializacao da ferramenta, + // por exemplo, quando um mapa e salvo, os parametros sao armazenados e depois recuperados + // + i3GEOF.tabela.aplicaConfig(idjanela); + if ($i(idjanela)) { + $i(idjanela).style.visibility = "visible"; + } + }, + /* + * Function: html + * + * Gera o código html para apresentação das opções da ferramenta + * + * Retorno: + * + * String com o código html + */ + html : function(idjanela) { + var ins = Mustache.render(i3GEOF.tabela.MUSTACHE, i3GEOF.tabela.mustacheHash(idjanela)); + return ins; + }, + /* + * Function: criaJanelaFlutuante + * + * Cria a janela flutuante para controle da ferramenta. + */ + iniciaJanelaFlutuante : function(parametros) { + var duplica, minimiza, cabecalho, janela, divid, temp, titulo, id; + if (!parametros) { + parametros = {}; + } + // + // configura a tabela baseado no objeto parametros + // se em parametros existir um idjanela, o mesmo e retornado, caso contrario, e criado + // + id = i3GEOF.tabela.configura(parametros); + // + // se existir um elemento HTML com o mesmo ID da janela, a renderizacao ocorrera + // nesse elemento, caso contrario, sera criada uma janela flutuante + // + if (!$i(id) && !$i(id + "_corpo")) { + cabecalho = function() { + i3GEOF.tabela.ativaFoco(id); + }; + minimiza = function() { + i3GEO.janela.minimiza(id,200); + }; + duplica = function() { + i3GEOF.tabela.iniciaJanelaFlutuante(); + }; + // cria a janela flutuante + titulo = "" + + $trad('tabela', i3GEOF.tabela.dicionario) + + " (" + id + " )" + + "
"; + + janela = i3GEO.janela.cria( + "610px", + "400px", + "", + "", + "", + titulo, + id, + false, + "hd", + cabecalho, + minimiza, + function() { i3GEO.guias.ajustaGuiaFerramenta(id, id + "i3GEOtabela");}, + true, + "", + duplica, + "", + "", + "39" + ); + divid = janela[2].id; + if (i3GEOF.tabela.janelas.length > 1) { + temp = janela[0].cfg.config; + janela[0] + .moveTo(temp.x.value + (i3GEOF.tabela.janelas.length * 50), temp.y.value + (i3GEOF.tabela.janelas.length * 15)); + } + $i(id + "_corpo").style.backgroundColor = "white"; + + temp = function() { + i3GEOF.tabela.janelas.remove(id); + i3GEOF.tabela.propJanelas[id] = null; + if (i3GEOF.tabela.janelas.length === 0) { + if (i3GEO.Interface.ATUAL === "openlayers") { + i3GEO.eventos.removeEventos("NAVEGAMAPA", [ + "i3GEOF.tabela.atualizaListaDeRegistros()" + ]); + } + if (i3GEO.Interface.ATUAL === "googlemaps") { + google.maps.event.removeListener(tabelaDragend); + google.maps.event.removeListener(tabelaZoomend); + } + } + }; + YAHOO.util.Event.addListener(janela[0].close, "click", temp); + janela[0].bringToTop(); + } else { + // sera renderizado em $i(id) + temp = 'i3GEOF.tabela.propJanelas["' + id + '"].atualiza = this.checked'; + $i(id + "_corpo").innerHTML = + "" + + "
" + + " " + + $trad("atualizaNavegacao", i3GEOF.tabela.dicionario) + + " (" + + id + + ")
"; + + divid = id + "_corpo"; + } + if ($i(id + "_imagemCabecalho")) { + i3GEOF.tabela.aguarde = $i(id + "_imagemCabecalho").style; + i3GEOF.tabela.propJanelas[id].aguarde = $i(id + "_imagemCabecalho").style; + i3GEOF.tabela.propJanelas[id].atualiza = true; + } + i3GEOF.tabela.inicia(divid, id); + // inicia os eventos + if (i3GEO.Interface.ATUAL === "openlayers") { + i3GEO.eventos.adicionaEventos("NAVEGAMAPA", [ + "i3GEOF.tabela.atualizaListaDeRegistros()" + ]); + } + if (i3GEO.Interface.ATUAL === "googlemaps" && !tabelaDragend) { + tabelaDragend = google.maps.event.addListener(i3GeoMap, "dragend", function() { + i3GEOF.tabela.atualizaListaDeRegistros(); + }); + tabelaZoomend = google.maps.event.addListener(i3GeoMap, "zoomend", function() { + i3GEOF.tebela.atualizaListaDeRegistros(); + }); + } + }, + /** + * Obtem os parametros de cada janela e converte em base64. Cada janela e inserida como um item em um objeto A compactacao e + * utilizada para salvar as configuracoes no mapfile atual + */ + compactaConfig : function() { + var c, g, par, janelas, i, n, novoid; + par = []; + janelas = i3GEOF.tabela.janelas; + n = janelas.length; + for (i = 0; i < n; i++) { + novoid = window.prompt($trad('idDaTabela', i3GEOF.tabela.dicionario), janelas[i]); + c = i3GEOF.tabela.retornaConfig(janelas[i], novoid); + par.push(c); + } + g = YAHOO.lang.JSON.stringify(par); + return i3GEO.util.base64encode(g); + }, + restauraTabelas : function(par) { + i3GEOF.tabela.LISTAREGATIVO = false; + var n, i; + par = i3GEO.util.base64decode(par); + par = JSON.parse(par); + n = par.length; + for (i = 0; i < n; i++) { + i3GEOF.tabela.iniciaJanelaFlutuante(par[i]); + } + }, + /** + * Retorna um objeto contendo os valores de todos os parametros utilizados na tabela de tal forma que possa ser renderizado + * novamente + * + * A funcao que salva o mapa no banco utiliza retornaConfig e cria um objeto que ira armazenar os parametros de cada janela + */ + retornaConfig : function(idjanela, novoid) { + // as chaves do objeto correspondem ao ID de cada elemento + var c, par; + + par = i3GEOF.tabela.propJanelas[idjanela]; + c = $i(idjanela); + // p = $i(idjanela+"i3GEOtabelaguia6obj"); + if (!novoid) { + novoid = idjanela; + } + // pega todos os elementos do tipo input + /* + * objs = p.getElementsByTagName("input"); for (obj in objs) { if (objs[obj].id && objs[obj].id != "") { tmpid = + * objs[obj].id.replace(idjanela,novoid); if (objs[obj].type === "text") { par[tmpid] = objs[obj].value; } else { par[tmpid] = + * objs[obj].checked; } } } // pega todos os elementos do tipo select objs = p.getElementsByTagName("select"); for (obj in objs) { + * if (objs[obj].id && objs[obj].id != "") { tmpid = objs[obj].id.replace(idjanela,novoid); par[tmpid] = objs[obj].value; } } + */ + par.dados = ""; + try { + par["i3GEOtabelainicio"] = $i(idjanela + "i3GEOtabelainicio").value; + par["i3GEOtabelafim"] = $i(idjanela + "i3GEOtabelafim").value; + par["idjanela"] = novoid; + par["w"] = c.style.width; + par["h"] = c.style.height; + } catch (e) { + } + return par; + }, + /* + * Function: ativaFoco + * + * Refaz a interface da ferramenta quando a janela flutuante tem seu foco ativado + */ + ativaFoco : function(id) { + + }, + vinculos : { + ligacoes : [], + /** + * Susbtitutos para o template + */ + mustacheHash : function() { + var dicionario = i3GEO.idioma.objetoIdioma(i3GEOF.tabela.dicionario); + dicionario["locaplic"] = i3GEO.configura.locaplic; + dicionario["comboJanelas1"] = i3GEOF.tabela.comboJanelas("i3GEOFTabelaOpcoesAdicionaVinculoT1", "i3GEOF.tabela.vinculos.comboColunasT1()"); + dicionario["comboJanelas2"] = i3GEOF.tabela.comboJanelas("i3GEOFTabelaOpcoesAdicionaVinculoT2", "i3GEOF.tabela.vinculos.comboColunasT2()"); + return dicionario; + }, + iniciaJanelaFlutuante : function() { + var janela, titulo; + // cria a janela flutuante + titulo = "" + + $trad('vinculos', i3GEOF.tabela.dicionario) + + "
"; + janela = + i3GEO.janela.cria( + "400px", + "350px", + "", + "", + "", + titulo, + "i3GEOFtabelaVinculos", + false, + "hd", + "", + "", + "", + true, + "", + "", + "", + "", + "120" + ); + divid = janela[2].id; + if (i3GEOF.tabela.janelas.length > 1) { + temp = janela[0].cfg.config; + janela[0] + .moveTo(temp.x.value + (i3GEOF.tabela.janelas.length * 50), temp.y.value + (i3GEOF.tabela.janelas.length * 15)); + } + $i("i3GEOFtabelaVinculos_corpo").style.backgroundColor = "white"; + i3GEOF.tabela.vinculos.inicia(); + }, + html : function() { + var ins = Mustache.render(i3GEOF.tabela.MUSTACHEVINCULO, i3GEOF.tabela.vinculos.mustacheHash()); + return ins; + }, + vincular: function(){ + var t1 = $i("i3GEOFTabelaOpcoesAdicionaVinculoT1").value, t2 = + $i("i3GEOFTabelaOpcoesAdicionaVinculoT2").value, c1 = + $i("i3GEOFTabelaOpcoesAdicionaVinculoColunaT1").value, c2 = + $i("i3GEOFTabelaOpcoesAdicionaVinculoColunaT1").value; + if (t1 != "" && t2 != "" && c1 != "" && c2 != "") { + i3GEOF.tabela.vinculos.ligacoes.push({ + "t1" : t1, + "t2" : t2, + "c1" : c1, + "c2" : c2 + }); + } + i3GEOF.tabela.vinculos.lista(); + }, + inicia : function() { + var ins = i3GEOF.tabela.vinculos.html(); + $i("i3GEOFtabelaVinculos_corpo").innerHTML = ins; + i3GEOF.tabela.vinculos.lista(); + }, + comboColunasT1 : function() { + var colunas = ""; + if($i("i3GEOFTabelaOpcoesAdicionaVinculoT1").value != ""){ + colunas = i3GEOF.tabela.comboColunas($i("i3GEOFTabelaOpcoesAdicionaVinculoT1").value, "i3GEOFTabelaOpcoesAdicionaVinculoColunaT1"); + } + $i("i3GEOFTabelaVinculoT1Colunas").innerHTML = colunas; + }, + comboColunasT2 : function() { + var colunas = ""; + if($i("i3GEOFTabelaOpcoesAdicionaVinculoT2").value != ""){ + colunas = i3GEOF.tabela.comboColunas($i("i3GEOFTabelaOpcoesAdicionaVinculoT2").value, "i3GEOFTabelaOpcoesAdicionaVinculoColunaT2"); + } + $i("i3GEOFTabelaVinculoT2Colunas").innerHTML = colunas; + }, + lista : function() { + var v = i3GEOF.tabela.vinculos.ligacoes, n = v.length, ins = + "
" + $trad('vinculos', i3GEOF.tabela.dicionario) + "
", i; + for (i = 0; i < n; i++) { + ins += '' + + "
" + v[i].t1 + + " " + + v[i].c1 + + " ->
" + + v[i].t2 + + " " + + v[i].c2 + + "
"; + } + $i("i3GEOFtabelaVinculosLista").innerHTML = ins; + }, + excluir : function(i) { + i3GEOF.tabela.vinculos.ligacoes.splice(parseInt(i, 10), 1); + i3GEOF.tabela.vinculos.lista(); + }, + atualizaVinculos : function(tabelaOrigem, registro, marcado) { + var v = i3GEOF.tabela.vinculos.ligacoes, n = v.length, i, valor; + if (n > 0) { + for (i = 0; i < n; i++) { + // verifica se o vinculo existe + if (v[i].t1 === tabelaOrigem) { + // pega o valor do registro na tabela origem + valor = i3GEOF.tabela.vinculos.pegaValorRegistro(v[i].t1, v[i].c1, registro); + // marca o registro na tabela destino + i3GEOF.tabela.vinculos.registro(v[i].t2, v[i].c2, valor, marcado); + } + if (v[i].t2 === tabelaOrigem) { + // pega o valor do registro na tabela origem + valor = i3GEOF.tabela.vinculos.pegaValorRegistro(v[i].t2, v[i].c2, registro); + // marca o registro na tabela destino + i3GEOF.tabela.vinculos.registro(v[i].t1, v[i].c1, valor, marcado); + } + } + } + }, + // verifica qtas colunas devem ser puladas em cada linha + colunasVazias : function(idjanela) { + var tabela = $i(idjanela + "i3GEOtabelatabelai"), linhas = tabela.getElementsByTagName("tr"), pular = 0, colunas, n, i; + colunas = linhas[0].getElementsByTagName("td"); + n = colunas.length; + for (i = 0; i < n; i++) { + if (colunas[i].innerHTML == "") { + pular++; + } + } + return pular; + }, + // pega o indice de uma coluna em uma tabela buscando no cabecalho + // no valor de title em cada celula + indiceColuna : function(idjanela, t) { + var tabela = $i(idjanela + "i3GEOtabelatabelai"), linhas = tabela.getElementsByTagName("tr"), linha = linhas[0], colunas = + linha.getElementsByTagName("td"), indice = 0, n = colunas.length, i, s; + for (i = 0; i < n; i++) { + s = colunas[i].getElementsByTagName("span"); + if (s && s[0] && s[0].title && s[0].title == t) { + return i; + } + } + return indice; + }, + // retorna o indice de uma coluna que contem a tag input na tabela + // com a lista de valores + indiceColunaInput : function(idjanela) { + var tabela = $i(idjanela + "i3GEOtabelatabelai"), linhas = tabela.getElementsByTagName("tr"), linha = linhas[1], colunas = + linha.getElementsByTagName("td"), indice = 0, n = colunas.length, i; + for (i = 0; i < n; i++) { + if (colunas[i].getElementsByTagName("input").length > 0) { + return i; + } + } + return indice; + }, + // pega o valor da coluna em uma tabela com a lista de valores com + // base no codigo do registro + pegaValorRegistro : function(idjanela, coluna, registro) { + var tabela = $i(idjanela + "i3GEOtabelatabelai"), linhas = tabela.getElementsByTagName("tr"), n = linhas.length, indiceColuna = + i3GEOF.tabela.vinculos.indiceColuna(idjanela, coluna), indiceColunaInput = + i3GEOF.tabela.vinculos.indiceColunaInput(idjanela), i, linha, colunas; + for (i = 1; i < n; i++) { + linha = linhas[i]; + colunas = linha.getElementsByTagName("td"); + if (colunas[indiceColunaInput].getElementsByTagName("input")[0].name == registro) { + return colunas[indiceColuna].innerHTML; + } + } + return ""; + }, + registro : function(idjanela, coluna, valor, marcado) { + var tabela = $i(idjanela + "i3GEOtabelatabelai"), linhas = tabela.getElementsByTagName("tr"), n = linhas.length, indiceColuna = + i3GEOF.tabela.vinculos.indiceColuna(idjanela, coluna), indiceColunaInput = + i3GEOF.tabela.vinculos.indiceColunaInput(idjanela), i, linha, colunas, reg; + for (i = 1; i < n; i++) { + linha = linhas[i]; + colunas = linha.getElementsByTagName("td"); + if (colunas[indiceColuna].innerHTML == valor) { + reg = colunas[indiceColunaInput].getElementsByTagName("input")[0]; + reg.checked = marcado; + i3GEOF.tabela.propJanelas[idjanela].registros[reg.name] = marcado; + } + } + }, + }, + comboJanelas : function(idcombo, funcao, w) { + var i, n = i3GEOF.tabela.janelas.length; + if (!funcao) { + funcao = ""; + } + if (!w) { + w = 260; + } + ins = + "" + " "; + return ins; + }, + comboColunas : function(idJanela, idcombo, funcao) { + var i, c = i3GEOF.tabela.propJanelas[idJanela].colunas, n = c.itens.length; + if (!funcao) { + funcao = ""; + } + ins = ""; + return ins; + }, + /* + * Function: ativaAutoAtualiza + * + * Ativa ou desativa a atualização automática da tabela quando o usuário navega no mapa + */ + atualizaListaDeRegistros : function() { + var i, janelas = i3GEOF.tabela.janelas, propJanelas = i3GEOF.tabela.propJanelas, n = janelas.length; + for (i = 0; i < n; i++) { + if (propJanelas[janelas[i]].atualiza === true) { + i3GEOF.tabela.pegaRegistros(janelas[i]); + } + } + }, + /* + * Function: pegaRegistros + * + * Pega os registros da tabela de atributos do tema + * + * Veja: + * + * + */ + pegaRegistros : function(idjanela, tipolista, dadosDaClasse, inicio, fim, funcao) { + if (i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility === "visible") { + return; + } + if (!idjanela) { + idjanela = ""; + } + i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "visible"; + $i(idjanela + "i3GEOtabelaregistros").innerHTML = ""; + var p, ext, tiporeg = "brasil", cp = new cpaint(); + // verifica se esta no modo de atualizacao automatica + if (i3GEOF.tabela.propJanelas[idjanela].atualiza === true) { + tiporeg = "mapa"; + } + if (!tipolista) { + if ($i(idjanela + "i3GEOtabelatipolista").checked) { + tipolista = "selecionados"; + } else { + tipolista = "tudo"; + } + } + if (!dadosDaClasse) { + if ($i(idjanela + "i3GEOtabelalegenda").checked) { + dadosDaClasse = "sim"; + } else { + dadosDaClasse = "nao"; + } + } + if (!inicio) { + inicio = $i(idjanela + "i3GEOtabelainicio").value - 1; + } else { + inicio = ""; + } + if (!fim) { + fim = $i(idjanela + "i3GEOtabelafim").value - 1; + } else { + fim = ""; + } + if (!funcao) { + funcao = function(retorno) { + i3GEOF.tabela.propJanelas[idjanela].registros = []; + i3GEOF.tabela.montaTabela(retorno, idjanela); + }; + } + ext = i3GEO.parametros.mapexten; + ext = i3GEO.util.extOSM2Geo(ext); + p = + i3GEO.configura.locaplic + "/classesphp/mapa_controle.php?g_sid=" + + i3GEO.configura.sid + + "&funcao=listaregistros" + + "&inicio=" + + inicio + + "&fim=" + + fim + + "&tema=" + + i3GEOF.tabela.propJanelas[idjanela].tema + + "&tipo=" + + tiporeg + + "&tipolista=" + + tipolista + + "&ext=" + + ext + + "&dadosDaClasse=" + + dadosDaClasse; + cp.set_response_type("JSON"); + cp.call(p, "listaRegistros", funcao); + }, + /* + * Function: montaTabela + * + * Monta a visualização da tabela de atributos + */ + montaTabela : function(retorno, idjanela) { + if (retorno.data !== undefined) { + var mustache = { + "idjanela": "", + "cabecalho": [{"classe":"hidden"},{"classe":"hidden"},{"classe":"hidden"},{"classe":"hidden"}], //4 colunas com icones + "linhas": [], + "ordena": $trad('ordena', i3GEOF.tabela.dicionario), + "excluir": $trad("t12") + }, + linha = { + "classezoom": "", + "ext": "", + "indice": "", + "idjanela": "" + }, + ins, i, vals, cor, j, n, stat, imagem, registros = i3GEOF.tabela.propJanelas[idjanela].registros, i3GEOtabelalegenda = + $i(idjanela + "i3GEOtabelalegenda").checked; + // cabecalho da tabela + mustache["idjanela"] = idjanela; + i3GEOF.tabela.propJanelas[idjanela].colunas = { + "itens" : retorno.data[0].itens, + "alias" : retorno.data[0].alias + }; + n = retorno.data[0].itens.length; + for (i = 0; i < n; i++) { + mustache.cabecalho.push({ + "idcoluna": i * 1 + 4, //pq tem 3 colunas com icones + "idjanela": idjanela, + "item": retorno.data[0].itens[i], + "alias": retorno.data[0].alias[i], + "classe": "" + }); + } + n = retorno.data[1].registros.length; + if ($i(idjanela + "i3GEOtabelafim").value === "") { + $i(idjanela + "i3GEOtabelafim").value = n - 1; + } + for (i = 0; i < n; i++) { + linha = {}; + linha.classezoom = "hidden"; + linha.ext = ""; + linha.idjanela = idjanela; + linha.indice = retorno.data[1].registros[i].indice; + if (retorno.data[1].registros[i].ext && retorno.data[1].registros[i].ext != "") { + linha.classezoom = ""; + linha.ext = retorno.data[1].registros[i].ext; + } + linha.stat = ""; + if (retorno.data[1].registros[i].status === "CHECKED") { + linha.stat = "CHECKED"; + } + if (registros[retorno.data[1].registros[i].indice]) { + if (registros[retorno.data[1].registros[i].indice] === true) { + linha.stat = "CHECKED"; + } else { + linha.stat = ""; + } + } + if (i3GEOtabelalegenda == true) { + linha.classelegenda = ""; + linha.nomeClasse = retorno.data[1].registros[i].classe["nome"]; + linha.imagemClasse = retorno.data.legenda[retorno.data[1].registros[i].classe["indice"]]; + imagem = retorno.data.legenda[retorno.data[1].registros[i].classe["indice"]]; + } else { + linha.classelegenda = "hidden"; + linha.nomeClasse = ""; + linha.imagemClasse = ""; + } + if (linha.stat === "CHECKED") { + registros[retorno.data[1].registros[i].indice] = true; + } + vals = retorno.data[1].registros[i].valores; + linha.colunas = ""; + for (j = 0; j < vals.length; j++) { + linha.colunas += "
" + vals[j].valor + "
"; + ins += "" + trs[0].innerHTML + ""; + npsortfim = psortfim.length; + for (p = 0; p < npsortfim; p++) { + e = psortfim[p].split("@$")[1] * 1; + if (trs[e] !== undefined) { + ins += "" + trs[e].innerHTML + ""; + } + } + $i(idjanela + "i3GEOtabelaregistros").innerHTML = ins + "
"; + i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "hidden"; + } catch (e) { + i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "hidden"; + if (typeof (console) !== 'undefined') { + console.error(e); + } + } + }, + excluiLinha : function(celula) { + var p = celula.parentNode.parentNode; + do { + p.removeChild(p.childNodes[0]); + } while (p.childNodes.length > 0); + p.parentNode.removeChild(p); + }, + zoomExt : function(ext, idjanela) { + if (i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility === "visible") { + return; + } + i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "visible"; + var funcao = function() { + i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "hidden"; + i3GEOF.tabela.pegaRegistros(idjanela); + i3GEO.atualiza(); + }; + i3GEO.php.mudaext(funcao, "nenhum", ext); + }, + registraLinha : function(linha, idjanela) { + i3GEOF.tabela.propJanelas[idjanela].registros[linha.name] = linha.checked; + i3GEOF.tabela.vinculos.atualizaVinculos(idjanela, linha.name, linha.checked); + }, + /* + * Function: listaMarcados + * + * Retorna um array com os índices dos registros que estão marcados. + */ + listaMarcados : function(idjanela) { + var lista = [], registros = i3GEOF.tabela.propJanelas[idjanela].registros, i, n = registros.length; + for (i = 0; i < n; i++) { + if (registros[i] === true) { + lista.push(i); + } + } + return lista; + }, + /* + * Function: ativaSelecao + * + * Seleciona no mapa os elementos que estiverem marcados na guia 2 + * + * Veja: + * + * + */ + ativaSelecao : function(idjanela) { + if (i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility === "visible") { + return; + } + i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "visible"; + var lista = i3GEOF.tabela.listaMarcados(idjanela), p, cp, temp = function(retorno) { + if (retorno) { + i3GEO.Interface.atualizaTema(retorno, i3GEOF.tabela.propJanelas[idjanela].tema); + i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "hidden"; + } + }; + p = + i3GEO.configura.locaplic + "/ferramentas/tabela/exec.php?g_sid=" + + i3GEO.configura.sid + + "&funcao=incluisel&tema=" + + i3GEOF.tabela.propJanelas[idjanela].tema + + "&ids=" + + lista.toString(); + cp = new cpaint(); + cp.set_response_type("JSON"); + cp.call(p, "incluiSel", temp); + }, + /* + * Function: limpaSelecao + * + * Limpa a seleção do tema da tabela + */ + limpaSelecao : function(idjanela) { + if (i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility === "visible") { + return; + } + i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "visible"; + i3GEO.tema.limpasel(i3GEOF.tabela.propJanelas[idjanela].tema); + i3GEOF.tabela.propJanelas[idjanela].registros = []; + var lista = $i(idjanela + "i3GEOtabelatabelai").getElementsByTagName("input"), n = lista.length, i; + for (i = 0; i < n; i++) { + lista[i].checked = false; + } + i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "hidden"; + }, + /* + * Function: criaNovoTema + * + * Cria um novo tema contendo a seleção existente + */ + criaNovoTema : function(idjanela) { + var camada = i3GEO.arvoreDeCamadas.pegaTema(i3GEOF.tabela.propJanelas[idjanela].tema); + if(camada.nsel == 0){ + i3GEO.janela.tempoMsg($trad("selUmReg",i3GEOF.tabela.dicionario)); + return; + } + + if (i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility === "visible") { + return; + } + i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "visible"; + var temp = function(retorno) { + i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "hidden"; + i3GEO.atualiza(retorno); + }; + i3GEO.php.criatemaSel(temp, i3GEOF.tabela.propJanelas[idjanela].tema); + }, + /* + * Function: comboItens + * + * Cria um combo para selecionar um item do tema escolhido + */ + comboItensEstat : function(idjanela) { + var tema = i3GEOF.tabela.propJanelas[idjanela].tema; + i3GEO.util.comboItens(idjanela + "i3GEOtabelaComboItensGuia3", tema, function(retorno) { + if (retorno.tipo === "erro") { + $i(idjanela + "i3GEOtabelaitensGuia3").innerHTML = + i3GEO.janela.closeMsg(''); + } else { + $i(idjanela + "i3GEOtabelaitensGuia3").innerHTML = retorno.dados; + } + }, idjanela + "i3GEOtabelaitensGuia3", "","sim","","form-control"); + }, + estatistica : function(idjanela) { + if ($i(idjanela + "i3GEOtabelaComboItensGuia3").value === "") { + i3GEO.janela.tempoMsg("Escolha um item!"); + return; + } + if (i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility === "visible") { + return; + } + i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "visible"; + try { + var monta = function(retorno) { + var ins = "", nome, valor, i, n; + if (retorno.data.indices !== undefined) { + if (retorno.data.indices) { + n = retorno.data.indices.length; + for (i = 0; i < n; i++) { + nome =retorno.data.variaveis[retorno.data.indices[i]]; + valor = retorno.data.valores[retorno.data.indices[i]]; + ins += '

'+nome+'

'+valor+'

'; + ins += '
 
'; + } + } + } else { + ins = retorno.data; + } + $i(idjanela + "i3GEOtabelaoperacoes").innerHTML = ins + "
"; + i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "hidden"; + }, exclui = "", cp = new cpaint(), p; + if ($i(idjanela + "i3GEOtabelafiltro1").value !== "") { + exclui = $i("i3GEOtabelafiltro1").value; + } + p = + i3GEO.configura.locaplic + "/ferramentas/tabela/exec.php?g_sid=" + + i3GEO.configura.sid + + "&funcao=estatistica&item=" + + $i(idjanela + "i3GEOtabelaComboItensGuia3").value + + "&tema=" + + i3GEOF.tabela.propJanelas[idjanela].tema + + "&exclui=" + + exclui + + "&ext=" + + i3GEO.parametros.mapexten; + cp.set_response_type("JSON"); + cp.call(p, "estatDescritivas", monta); + } catch (e) { + i3GEOF.tabela.propJanelas[idjanela].aguarde.visibility = "hidden"; + $i("operacoes").innerHTML = "Ocorreu um erro: " + e; + } + }, + tabelaTexto : function() { + }, + /* + * Function: relatorioTabela + * + * Monta o relatório padrão em uma nova janela + */ + relatorioTabela : function(idjanela) { + try { + $i(idjanela + "i3GEOtabelatiporelh").value = ""; + $i(idjanela + "i3GEOtabelaarearelh").value = $i(idjanela + "i3GEOtabelacalculaarea").checked; + $i(idjanela + "i3GEOtabelastatrelh").value = $i(idjanela + "i3GEOtabelacalculaestat").checked; + $i(idjanela + "i3GEOtabelaexcluirvalorh").value = $i(idjanela + "i3GEOtabelaexcestat").value; + $i(idjanela + "i3GEOtabelatemarelh").value = i3GEOF.tabela.propJanelas[idjanela].tema; + $i(idjanela + "i3GEOtabelag_sidh").value = i3GEO.configura.sid; + $i(idjanela + "i3GEOtabelaitemagruparelh").value = $i(idjanela + "i3GEOtabelaagrupaItem").value; + var inputs = $i(idjanela + "i3GEOtabelaitensrelatorio").getElementsByTagName("input"), listai = [], listaordem = [], listanomes = + [], nome, ordem, i, temp, n = inputs.length; + for (i = 0; i < n; i++) { + if (inputs[i].type === "checkbox" && inputs[i].checked == true) { + listai.push(inputs[i].id + "|" + inputs[i].name); + nome = $i(inputs[i].id + inputs[i].name).value; + listanomes.push(nome); + ordem = $i("ordem_" + inputs[i].id + inputs[i].name).value; + if (ordem === "") { + ordem = 0; + } + listaordem.push(ordem); + } + } + $i(idjanela + "i3GEOtabelaordemrel").value = listaordem; + $i(idjanela + "i3GEOtabelanomesrelh").value = listanomes; + $i(idjanela + "i3GEOtabelaitensrelh").value = listai; + temp = $i(idjanela + "i3GEOtabelarelatorio").action; + $i(idjanela + "i3GEOtabelarelatorio").action += "?ext=" + i3GEO.parametros.mapexten; + $i(idjanela + "i3GEOtabelarelatorio").submit(); + $i(idjanela + "i3GEOtabelarelatorio").action = temp; + } catch (e) { + i3GEO.janela.tempoMsg(e); + } + }, + /* + * Function: relatorioTexto + * + * Gera o relatório no formato CSV + */ + relatorioTexto : function(idjanela) { + $i(idjanela + "i3GEOtabelaarearelh").value = $i(idjanela + "i3GEOtabelacalculaarea").checked; + $i(idjanela + "i3GEOtabelastatrelh").value = $i(idjanela + "i3GEOtabelacalculaestat").checked; + $i(idjanela + "i3GEOtabelaexcluirvalorh").value = $i(idjanela + "i3GEOtabelaexcestat").value; + $i(idjanela + "i3GEOtabelatemarelh").value = i3GEOF.tabela.propJanelas[idjanela].tema; + $i(idjanela + "i3GEOtabelag_sidh").value = i3GEO.configura.sid; + $i(idjanela + "i3GEOtabelaitemagruparelh").value = $i(idjanela + "i3GEOtabelaagrupaItem").value; + $i(idjanela + "i3GEOtabelatiporelh").value = "csv"; + var inputs = $i(idjanela + "i3GEOtabelaitensrelatorio").getElementsByTagName("input"), listai = [], listanomes = [], nome, i, temp, n = + inputs.length; + for (i = 0; i < n; i++) { + if (inputs[i].checked === true) { + listai.push(inputs[i].id + "|" + inputs[i].name); + nome = $i(inputs[i].id + inputs[i].name).value; + listanomes.push(nome); + } + } + $i(idjanela + "i3GEOtabelanomesrelh").value = listanomes; + $i(idjanela + "i3GEOtabelaitensrelh").value = listai; + temp = $i(idjanela + "i3GEOtabelarelatorio").action; + $i(idjanela + "i3GEOtabelarelatorio").action += "?ext=" + i3GEO.parametros.mapexten; + $i(idjanela + "i3GEOtabelarelatorio").submit(); + $i(idjanela + "i3GEOtabelarelatorio").action = temp; + } +}; \ No newline at end of file diff --git a/ferramentas/tabela_old/relatorio.php b/ferramentas/tabela_old/relatorio.php new file mode 100644 index 0000000..7b9cabc --- /dev/null +++ b/ferramentas/tabela_old/relatorio.php @@ -0,0 +1,339 @@ + + + + + +i3Geo + + 0){ + $itensrelTemp = explode(",",$itensrel); + $itensrel = array(); + $colunas = array(); + $n = count($colunasTemp); + for($i=0;$i<$n;$i++){ + $colunas[$ordem[$i]] = $colunasTemp[$i]; + $t1[$ordem[$i]] = $t1Temp[$i]; + $itensrel[$ordem[$i]] = $itensrelTemp[$i]; + } + if(count($colunas) == count($colunasTemp)){ + ksort($colunas); + ksort($t1); + ksort($itensrel); + $itensrel = implode(",",$itensrel); + } +} +else{ + $colunas = $colunasTemp; + $t1 = $t1Temp; +} + +if($itemagruparel != "" && !in_array($itemagruparel,$colunas)){ + $colunas[] = $itemagruparel; +} + +$temp = explode(",",$itensrel); +$itensrel = array(); +foreach($temp as $t) +{ + $t1=explode("|",$t); + $itensrel[] = $t1[0]; +} +if($itemagruparel != "" && !in_array($itemagruparel,$itensrel)) +{$itensrel[] = $itemagruparel;} + +$mapa = ms_newMapObj($map_file); +substituiConObj($mapa,$postgis_mapa); +if($ext && $ext != ""){ + $e = explode(" ",$ext); + $extatual = $mapa->extent; + $extatual->setextent((min($e[0],$e[2])),(min($e[1],$e[3])),(max($e[0],$e[2])),(max($e[1],$e[3]))); +} + +$layer = $mapa->getlayerbyname($temarel); +$layer->set("template","none.html"); +//$layer->set("data",$layer->data."options='-c client_encoding=LATIN1'"); +$existesel = "nao"; + +/* +if (file_exists($map_file."qy")) +{$mapa->loadquery($map_file."qy");} +*/ +carregaquery2($map_file,$layer,$mapa); + +if ($layer->getNumresults() > 0){ + $existesel = "sim"; +} +if ($existesel == "nao"){ + $layer->querybyrect($mapa->extent); +} + +$layer->open(); +if(strtoupper($layer->getmetadata("convcaracter")) == "NAO"){ + $convC = false; +} +else{ + $convC = true; +} + +//$registros[] = array(); +$res_count = $layer->getNumresults(); +for ($i = 0; $i < $res_count; $i++){ + $valitem = array(); + if($versao >= 6){ + $shape = $layer->getShape($layer->getResult($i)); + } + else{ + $shape = $layer->getFeature($layer->getResult($i)->shapeindex); + } + $grupo = ""; + foreach ($itensrel as $item){ + $v = trim($shape->values[$item]); + //$v = mb_convert_encoding($v,mb_detect_encoding($v),"ISO-8859-1"); + if (function_exists("mb_convert_encoding") && $convC == true){ + //$v = mb_convert_encoding($v,"UTF-8","ISO-8859-1"); + } + $valitem[$item] = $v; + } + + if ($itemagruparel != ""){ + $grupo = $valitem[$itemagruparel]; + } + if($arearel == "true"){ + $valitem["area"] = calculaarea($shape); + } + if ($itemagruparel == "") + $registros[] = $valitem; + else{ + if(!$registros[$grupo]) + $registros[$grupo]=array($valitem); + else + array_push($registros[$grupo],$valitem); + } +} +$fechou = $layer->close(); + +restauraCon($map_file,$postgis_mapa); + +if(isset($_GET["tiporel"]) && $_GET["tiporel"] == "csv"){ + ob_end_clean(); + header("Content-type: text/csv"); + echo implode(";",explode(",",$nomesrel)); + if($arearel == "true"){ + echo ";área em ha \n"; + } + else{ + echo "\n"; + } + foreach ($registros as $linhas){ + echo converte(implode(";",$linhas))."\n"; + } + exit; +} +?> + + + +Relatório do tema: ".converte($layer->getmetadata("TEMA"))."
"; +$ocorrencias = count($registros); +echo "ocorrências: ".$ocorrencias."
"; +if ($itemagruparel == "") +{ + echo ""; + $cor = "rgb(240,240,240)"; + echo ""; + if($statrel == "true"){echo "";} + foreach ($colunas as $c) + {echo "";} + if($arearel == "true") + {echo "";} + foreach ($registros as $linhas) + { + if(count($linhas)>0){ + echo ""; + if ($statrel == "true") + echo ""; + $conta = 0; + foreach($linhas as $v){ + if(is_numeric(trim($v))){ + echo ""; + } + else{ + echo ""; + } + if ($statrel == "true"){ + $v = trim($v); + if(!is_numeric($v)){$v = 0;} + if ($v == $excluirvalor){$v = 0;} + $soma[$conta] = $soma[$conta] + $v; + } + $conta++; + } + echo ""; + if ($cor == "rgb(240,240,240)") + {$cor = "rgb(220,220,220)";} + else + {$cor = "rgb(240,240,240)";} + } + } + if ($statrel == "true") + { + echo ""; + echo ""; + foreach($soma as $s) + echo ""; + echo ""; + echo ""; + echo ""; + foreach($soma as $s) + echo ""; + echo ""; + } + echo "
$cárea em ha
".number_format($v,2,",",".")."".converte($v)."
soma".number_format($s,2,",",".")."
média".number_format(($s / $ocorrencias),2,",",".")."
"; +} +else +{ + $conta = -1; + $chaves = array_keys($registros); + sort($chaves); + foreach ($chaves as $chave) + { + //if(count($registro) < 1){continue;} + //var_dump($registros[$conta]); + $ocorrencias = count($registros[$chave]); + echo "

".$itemagruparel.": ".$chave."
ocorrências: ".$ocorrencias."
"; + //echo "
";var_dump($registro);
+		echo "";
+		$cor = "rgb(240,240,240)";
+		echo "";
+		if ($statrel == "true")
+		echo "";
+		foreach ($colunas as $c)
+		{
+			echo "";
+		}
+		$soma = array();
+		if($arearel == "true")
+		{echo "";}
+		echo "";
+		foreach ($registros[$chave] as $linhas)
+		{
+			if (count($linhas) > 0 )
+			{
+				//echo "
";var_dump($linhas);
+				echo "
"; + if ($statrel == "true") + echo ""; + $conta = 0; + foreach($linhas as $v) + { + if(is_numeric(trim($v))) + {echo "";} + else + {echo "";} + if ($statrel == "true") + { + $v = trim($v); + if(!is_numeric($v)){$v = 0;} + if ($v == $excluirvalor){$v = 0;} + $soma[$conta] = $soma[$conta] + $v; + } + $conta++; + } + echo ""; + if ($cor == "rgb(240,240,240)") + {$cor = "rgb(220,220,220)";} + else + {$cor = "rgb(240,240,240)";} + } + } + if ($statrel == "true" && $ocorrencias>1 ) + { + echo ""; + echo ""; + foreach($soma as $s) + echo ""; + echo ""; + echo ""; + echo ""; + foreach($soma as $s) + echo ""; + echo ""; + } + echo "
$cárea em ha
".number_format($v,2,",",".")."".converte($v)."
soma".number_format($s,2,",",".")."
média".number_format(($s / $ocorrencias),2,",",".")."
"; + } + +} +function calculaarea($geo) +{ + global $postgis_con; + $v = versao(); + if (($v["principal"] < 5) && ($postgis_con == "")) + {return ("erro. É necessária uma versão maior que 5.0 do Mapserver.");} + $g = $geo->towkt(); + $shape = ms_shapeObjFromWkt($g); + $rect = $shape->bounds; + $projInObj = ms_newprojectionobj("proj=longlat,ellps=WGS84,datum=WGS84,no_defs"); + $projOutObj = ms_newprojectionobj("proj=laea,lat_0=".$rect->miny.",lon_0=".$rect->minx.",x_0=500000,y_0=10000000,ellps=GRS67,units=m,no_defs"); + $shape->project($projInObj, $projOutObj); + $s = $shape->towkt(); + $shape = ms_shapeObjFromWkt($s); + $area = $shape->getArea(); + return $area / 10000; +} +function converte($texto) +{ + if (!mb_detect_encoding($texto,"UTF-8",true)) + { + $texto = mb_convert_encoding($texto,"UTF-8","ISO-8859-1"); + } + return $texto; +} +?> \ No newline at end of file diff --git a/ferramentas/tabela_old/templateLista_mst.html b/ferramentas/tabela_old/templateLista_mst.html new file mode 100644 index 0000000..d68b06d --- /dev/null +++ b/ferramentas/tabela_old/templateLista_mst.html @@ -0,0 +1,43 @@ + + + {{#cabecalho}} + + {{/cabecalho}} + + {{#linhas}} + + + + + + {{{colunas}}} + + {{/linhas}} +
+ +
+ {{{alias}}} +
+ + + + +
+ +
+
+ +
\ No newline at end of file diff --git a/ferramentas/tabela_old/templateVinculo_mst.html b/ferramentas/tabela_old/templateVinculo_mst.html new file mode 100644 index 0000000..8c8d4e6 --- /dev/null +++ b/ferramentas/tabela_old/templateVinculo_mst.html @@ -0,0 +1,24 @@ +
+
+ +
{{{comboJanelas1}}}
+
+
+ +
+
+
+
+
+ +
{{{comboJanelas2}}}
+
+
+ +
+
+
+
+ +
+
\ No newline at end of file diff --git a/ferramentas/tabela_old/template_mst.html b/ferramentas/tabela_old/template_mst.html new file mode 100644 index 0000000..472a211 --- /dev/null +++ b/ferramentas/tabela_old/template_mst.html @@ -0,0 +1,165 @@ + + + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ +
+ {{{de}}}   + +   {{{ate}}}   + +   + + + + +
+ +
+
+ + + +
+
+ +
+
+
+ +
+
+ +
+ + +
+ +
+ +
+ +
+ +
+ + + + + +
diff --git a/js/janela.js b/js/janela.js index 4e50fbe..0f53be4 100755 --- a/js/janela.js +++ b/js/janela.js @@ -679,7 +679,10 @@ i3GEO.janela = }, _formModal: false, //utilizado para mensagens de ferramentas com botao de close e outros parametros - formModal : function({texto = false, footer = false, header = false, onclose = false, backdrop = false, draggable = "enable", css = {'cursor': 'pointer', 'width': '', 'height': '','position': 'fixed','top': 0, 'left': 0, 'right': 0, 'margin': 'auto'}} = {}) { + formModal : function({resizable = {disabled: true, ghost: true, handles: "se"}, texto = false, footer = false, header = false, onclose = false, backdrop = false, draggable = "enable", css = false} = {}) { + if(css == false){ + css = {'cursor': 'pointer', 'width': '', 'height': '','position': 'fixed','top': 0, 'left': 0, 'right': 0, 'margin': 'auto'}; + } if(draggable == "enable"){ css.cursor = "move"; } @@ -691,15 +694,16 @@ i3GEO.janela = $("#i3GEOToolFormModal").html(""); $("#i3GEOToolFormModalHeader").html(""); }); - i3GEO.janela._formModal.resizable({ - ghost: true, - handles: "se" - }); + i3GEO.janela._formModal.resizable(resizable); + if(resizable.disabled == true){ + i3GEO.janela._formModal.resizable( "destroy" ); + } i3GEO.janela._formModal.draggable({ handle: ".handleDraggable" }); + i3GEO.janela._formModal.css(css); i3GEO.janela._formModal.draggable(draggable); - $(i3GEO.janela._formModal).appendTo("body"); + $(i3GEO.janela._formModal).appendTo("#" + i3GEO.Interface.IDCORPO); } if(texto == false){ i3GEO.janela._formModal.modal("hide"); @@ -716,13 +720,16 @@ i3GEO.janela = backdrop: backdrop }); i3GEO.janela._formModal.draggable(draggable); + i3GEO.janela._formModal.resizable(resizable); + if(resizable.disabled == true){ + i3GEO.janela._formModal.resizable( "destroy" ); + } } //fecha as guias em dispositivos com tela pequena if(i3GEO.parametros.w < 420){ i3GEO.guias.abreFecha("fecha"); } if(onclose != false){ - if (typeof (console) !== 'undefined') console.info("onclose janela._formModal"); diff --git a/js/tema.js b/js/tema.js index ee7cb07..98a1d20 100755 --- a/js/tema.js +++ b/js/tema.js @@ -737,13 +737,15 @@ i3GEO.tema = return; } } - i3GEO.mapa.ativaTema(idtema); + var temp = function(){ + i3GEOF.tabela.start(idtema); + }; i3GEO.util.dialogoFerramenta( "i3GEO.tema.dialogo.tabela()", "tabela", "tabela", "dependencias.php", - "i3GEOF.tabela.iniciaJanelaFlutuante()"); + temp); }, /** * Function: etiquetas diff --git a/js/template.js b/js/template.js index 1ab78c0..6672a48 100755 --- a/js/template.js +++ b/js/template.js @@ -24,7 +24,7 @@ i3GEO.template = { aguarde: "", msg: "", closemsg: "", - formModal: "" + formModal: "" }, //lista generica de opcoes listaopcoes: '
{{{opcional}}}

', -- libgit2 0.21.2