Commit 35d519bc598eb6a07dd58a571d1aff0602158ca9

Authored by Edmar Moretti
1 parent 040f9db3

Atuzaliação do README

Showing 2 changed files with 495 additions and 498 deletions   Show diff stats
README.md
... ... @@ -108,7 +108,7 @@ Instale também o pgAdmin, que é uma interface gráfica para o PostGIS: http://
108 108  
109 109 Caso deseje, carregue no PostGIS o banco de dados do i3GeoSaúde. Esse banco é utilizado em alguns dos tutoriais do i3Geo e pode servir de teste para uso com o SAIKU.
110 110  
111   -* Primeiro baixe o arquivo https://softwarepublico.gov.br/gitlab/i3geo/i3geosaude/blob/master/databasei3geosaude.backup
  111 +* Primeiro baixe o arquivo https://softwarepublico.gov.br/gitlab/i3geo/i3geosaude/raw/master/databasei3geosaude.backup
112 112 * Abra o pgAdmin e crie uma nova conexão com o banco de dados. Em nome do host utilize "localhost" e o login e senha que você usou na istalação, normalmente "postgres".
113 113 * Utilize as opções do pgAdmin para criar um novo banco de dados chamado i3geosaude. Ao criá-lo, utilize o banco de dados postgres como template e login e senha "postgres".
114 114 * Clicando sobre o novo banco de dados, localize a opção "restore" e faça a carga do banco de dados que foi baixado no início.
... ... @@ -285,7 +285,7 @@ Instale o PostgreSQL e PostGIS
285 285  
286 286 ```
287 287 apt-get install postgresql postgis pgadmin3
288   -apt-get install postgresql-9.1-postgis
  288 +service postgresql start
289 289 ```
290 290  
291 291 #### Instalando o banco de dados i3GeoSaude para testes
... ... @@ -311,6 +311,8 @@ Observações:
311 311 Comandos para instalação:
312 312  
313 313 ```
  314 +cd /var/www
  315 +wget https://softwarepublico.gov.br/gitlab/i3geo/i3geosaude/raw/master/databasei3geosaude.backup
314 316 su - postgres -c "psql -c \"ALTER USER postgres WITH PASSWORD 'postgres'\""
315 317 su - postgres -c "createdb i3geosaude"
316 318 su - postgres -c "createlang -d i3geosaude plpgsql"
... ...
ferramentas/tabela/index.js
... ... @@ -53,7 +53,6 @@ i3GEOF.tabela =
53 53 i3GEO.eventos.removeEventos("NAVEGAMAPA", [
54 54 "i3GEOF.tabela.atualizaListaDeRegistros()"
55 55 ]);
56   -
57 56 },
58 57 html:function() {
59 58 var p = this._parameters,
... ... @@ -99,524 +98,520 @@ i3GEOF.tabela =
99 98 // relatorio
100 99 $i("i3GEOtabelaguia5").onclick = function() {
101 100 i3GEO.guias.mostraGuiaFerramenta("i3GEOtabelaguia5", "i3GEOtabelaguia");
102   -
103 101 i3GEO.util.comboItens("i3GEOtabelaagrupaItem", i3GEOF.tabela._parameters.tema, function(
104 102 retorno) {
105   - if (retorno.tipo === "erro") {
106   - i3GEO.janela.closeMsg('<div class="alert alert-danger" role="alert">' + $trad('erroTemaOrigem',i3GEOF.tabela.dicionario) + '</div>');
107   - } else {
108   - $i("i3GEOtabelaagrupamento").innerHTML = retorno.dados;
109   - }
110   - }, "i3GEOtabelaagrupamento", "","sim","","form-control");
111   - };
112   - i3GEO.eventos.adicionaEventos("NAVEGAMAPA", [
113   - "i3GEOF.tabela.atualizaListaDeRegistros()"
114   - ]);
115   - i3GEOF.tabela.pegaRegistros();
116   - },
117   - comboJanelas : function(idcombo, funcao, w) {
118   - },
119   - comboColunas : function(idJanela, idcombo, funcao) {
120   - var i, c = i3GEOF.tabela._parameters.colunas, n = c.itens.length;
121   - if (!funcao) {
122   - funcao = "";
123   - }
124   - ins = "<select class='form-control' id='"
125   - + idcombo
126   - + "' onchange='"
127   - + funcao
128   - + "'>"
129   - + " <option value='' >---</option>";
130   - for (i = 0; i < n; i++) {
131   - ins += "<option value='" + c.itens[i] + "' >" + c.alias[i] + "</option>";
132   - }
133   - ins += "</select>";
134   - return ins;
  103 + $i("i3GEOtabelaagrupamento").innerHTML = retorno.dados;
  104 + }
  105 + }, "i3GEOtabelaagrupamento", "","sim","","form-control");
  106 + };
  107 + i3GEO.eventos.adicionaEventos("NAVEGAMAPA", [
  108 + "i3GEOF.tabela.atualizaListaDeRegistros()"
  109 + ]);
  110 + i3GEOF.tabela.pegaRegistros();
  111 +},
  112 +comboJanelas : function(idcombo, funcao, w) {
  113 +},
  114 +comboColunas : function(idJanela, idcombo, funcao) {
  115 + var i, c = i3GEOF.tabela._parameters.colunas, n = c.itens.length;
  116 + if (!funcao) {
  117 + funcao = "";
  118 + }
  119 + ins = "<select class='form-control' id='"
  120 + + idcombo
  121 + + "' onchange='"
  122 + + funcao
  123 + + "'>"
  124 + + " <option value='' >---</option>";
  125 + for (i = 0; i < n; i++) {
  126 + ins += "<option value='" + c.itens[i] + "' >" + c.alias[i] + "</option>";
  127 + }
  128 + ins += "</select>";
  129 + return ins;
  130 +},
  131 +/*
  132 + * Function: ativaAutoAtualiza
  133 + *
  134 + * Ativa ou desativa a atualiza&ccedil;&atilde;o autom&aacute;tica da tabela quando o usu&aacute;rio navega no mapa
  135 + */
  136 +atualizaListaDeRegistros : function() {
  137 + i3GEOF.tabela.pegaRegistros();
  138 +},
  139 +pegaRegistros : function(tipolista, dadosDaClasse, inicio, fim) {
  140 + var p = this._parameters,
  141 + i3f = this;
  142 + $i(p.idRegistros).innerHTML = "";
  143 + var p, ext, tiporeg = "brasil", cp = new cpaint();
  144 + // verifica se esta no modo de atualizacao automatica
  145 + if (i3GEOF.tabela.refreshOnNavigate === true) {
  146 + tiporeg = "mapa";
  147 + }
  148 + if (!tipolista) {
  149 + if ($i("i3GEOtabelatipolista").checked) {
  150 + tipolista = "selecionados";
  151 + } else {
  152 + tipolista = "tudo";
  153 + }
  154 + }
  155 + if (!dadosDaClasse) {
  156 + if ($i("i3GEOtabelalegenda").checked) {
  157 + dadosDaClasse = "sim";
  158 + } else {
  159 + dadosDaClasse = "nao";
  160 + }
  161 + }
  162 + if (!inicio) {
  163 + inicio = $i("i3GEOtabelainicio").value - 1;
  164 + } else {
  165 + inicio = "";
  166 + }
  167 + if (!fim) {
  168 + fim = $i("i3GEOtabelafim").value - 1;
  169 + } else {
  170 + fim = "";
  171 + }
  172 + funcao = function(retorno) {
  173 + i3GEOF.tabela._parameters.registros = [];
  174 + i3GEOF.tabela.montaTabela(retorno);
  175 + };
  176 + ext = i3GEO.parametros.mapexten;
  177 + ext = i3GEO.util.extOSM2Geo(ext);
  178 + p =
  179 + i3GEO.configura.locaplic + "/classesphp/mapa_controle.php?g_sid="
  180 + + i3GEO.configura.sid
  181 + + "&funcao=listaregistros"
  182 + + "&inicio="
  183 + + inicio
  184 + + "&fim="
  185 + + fim
  186 + + "&tema="
  187 + + p.tema
  188 + + "&tipo="
  189 + + tiporeg
  190 + + "&tipolista="
  191 + + tipolista
  192 + + "&ext="
  193 + + ext
  194 + + "&dadosDaClasse="
  195 + + dadosDaClasse;
  196 + cp.set_response_type("JSON");
  197 + cp.call(p, "listaRegistros", funcao);
  198 +},
  199 +/*
  200 + * Function: montaTabela
  201 + *
  202 + * Monta a visualiza&ccedil;&atilde;o da tabela de atributos
  203 + */
  204 +montaTabela : function(retorno) {
  205 + var p = this._parameters,
  206 + i3f = this;
  207 + if (retorno.data !== undefined) {
  208 + var mustache = {
  209 + "cabecalho": [{"classe":"hidden"},{"classe":"hidden"},{"classe":"hidden"},{"classe":"hidden"}], //4 colunas com icones
  210 + "linhas": [],
  211 + "ordena": $trad('ordena', i3GEOF.tabela.dicionario),
  212 + "excluir": $trad("t12")
135 213 },
136   - /*
137   - * Function: ativaAutoAtualiza
138   - *
139   - * Ativa ou desativa a atualiza&ccedil;&atilde;o autom&aacute;tica da tabela quando o usu&aacute;rio navega no mapa
140   - */
141   - atualizaListaDeRegistros : function() {
142   - i3GEOF.tabela.pegaRegistros();
  214 + linha = {
  215 + "classezoom": "",
  216 + "ext": "",
  217 + "indice": ""
143 218 },
144   - pegaRegistros : function(tipolista, dadosDaClasse, inicio, fim) {
145   - var p = this._parameters,
146   - i3f = this;
147   - $i(p.idRegistros).innerHTML = "";
148   - var p, ext, tiporeg = "brasil", cp = new cpaint();
149   - // verifica se esta no modo de atualizacao automatica
150   - if (i3GEOF.tabela.refreshOnNavigate === true) {
151   - tiporeg = "mapa";
  219 + ins, i, vals, cor, j, n, stat, imagem, registros = p.registros, i3GEOtabelalegenda =
  220 + $i("i3GEOtabelalegenda").checked;
  221 + // cabecalho da tabela
  222 + p.colunas = {
  223 + "itens" : retorno.data[0].itens,
  224 + "alias" : retorno.data[0].alias
  225 + };
  226 + n = retorno.data[0].itens.length;
  227 + for (i = 0; i < n; i++) {
  228 + mustache.cabecalho.push({
  229 + "idcoluna": i * 1 + 4, //pq tem 3 colunas com icones
  230 + "item": retorno.data[0].itens[i],
  231 + "alias": retorno.data[0].alias[i],
  232 + "classe": ""
  233 + });
  234 + }
  235 + n = retorno.data[1].registros.length;
  236 + if ($i("i3GEOtabelafim").value === "") {
  237 + $i("i3GEOtabelafim").value = n - 1;
  238 + }
  239 + for (i = 0; i < n; i++) {
  240 + linha = {};
  241 + linha.classezoom = "hidden";
  242 + linha.ext = "";
  243 + linha.indice = retorno.data[1].registros[i].indice;
  244 + if (retorno.data[1].registros[i].ext && retorno.data[1].registros[i].ext != "") {
  245 + linha.classezoom = "";
  246 + linha.ext = retorno.data[1].registros[i].ext;
152 247 }
153   - if (!tipolista) {
154   - if ($i("i3GEOtabelatipolista").checked) {
155   - tipolista = "selecionados";
156   - } else {
157   - tipolista = "tudo";
158   - }
  248 + linha.stat = "";
  249 + if (retorno.data[1].registros[i].status === "CHECKED") {
  250 + linha.stat = "CHECKED";
159 251 }
160   - if (!dadosDaClasse) {
161   - if ($i("i3GEOtabelalegenda").checked) {
162   - dadosDaClasse = "sim";
  252 + if (registros[retorno.data[1].registros[i].indice]) {
  253 + if (registros[retorno.data[1].registros[i].indice] === true) {
  254 + linha.stat = "CHECKED";
163 255 } else {
164   - dadosDaClasse = "nao";
  256 + linha.stat = "";
165 257 }
166 258 }
167   - if (!inicio) {
168   - inicio = $i("i3GEOtabelainicio").value - 1;
  259 + if (i3GEOtabelalegenda == true) {
  260 + linha.classelegenda = "";
  261 + linha.nomeClasse = retorno.data[1].registros[i].classe["nome"];
  262 + linha.imagemClasse = retorno.data.legenda[retorno.data[1].registros[i].classe["indice"]];
  263 + imagem = retorno.data.legenda[retorno.data[1].registros[i].classe["indice"]];
169 264 } else {
170   - inicio = "";
  265 + linha.classelegenda = "hidden";
  266 + linha.nomeClasse = "";
  267 + linha.imagemClasse = "";
171 268 }
172   - if (!fim) {
173   - fim = $i("i3GEOtabelafim").value - 1;
174   - } else {
175   - fim = "";
  269 + if (linha.stat === "CHECKED") {
  270 + registros[retorno.data[1].registros[i].indice] = true;
176 271 }
177   - funcao = function(retorno) {
178   - i3GEOF.tabela._parameters.registros = [];
179   - i3GEOF.tabela.montaTabela(retorno);
180   - };
181   - ext = i3GEO.parametros.mapexten;
182   - ext = i3GEO.util.extOSM2Geo(ext);
183   - p =
184   - i3GEO.configura.locaplic + "/classesphp/mapa_controle.php?g_sid="
185   - + i3GEO.configura.sid
186   - + "&funcao=listaregistros"
187   - + "&inicio="
188   - + inicio
189   - + "&fim="
190   - + fim
191   - + "&tema="
192   - + p.tema
193   - + "&tipo="
194   - + tiporeg
195   - + "&tipolista="
196   - + tipolista
197   - + "&ext="
198   - + ext
199   - + "&dadosDaClasse="
200   - + dadosDaClasse;
201   - cp.set_response_type("JSON");
202   - cp.call(p, "listaRegistros", funcao);
203   - },
204   - /*
205   - * Function: montaTabela
206   - *
207   - * Monta a visualiza&ccedil;&atilde;o da tabela de atributos
208   - */
209   - montaTabela : function(retorno) {
210   - var p = this._parameters,
211   - i3f = this;
212   - if (retorno.data !== undefined) {
213   - var mustache = {
214   - "cabecalho": [{"classe":"hidden"},{"classe":"hidden"},{"classe":"hidden"},{"classe":"hidden"}], //4 colunas com icones
215   - "linhas": [],
216   - "ordena": $trad('ordena', i3GEOF.tabela.dicionario),
217   - "excluir": $trad("t12")
218   - },
219   - linha = {
220   - "classezoom": "",
221   - "ext": "",
222   - "indice": ""
223   - },
224   - ins, i, vals, cor, j, n, stat, imagem, registros = p.registros, i3GEOtabelalegenda =
225   - $i("i3GEOtabelalegenda").checked;
226   - // cabecalho da tabela
227   - p.colunas = {
228   - "itens" : retorno.data[0].itens,
229   - "alias" : retorno.data[0].alias
230   - };
231   - n = retorno.data[0].itens.length;
232   - for (i = 0; i < n; i++) {
233   - mustache.cabecalho.push({
234   - "idcoluna": i * 1 + 4, //pq tem 3 colunas com icones
235   - "item": retorno.data[0].itens[i],
236   - "alias": retorno.data[0].alias[i],
237   - "classe": ""
238   - });
239   - }
240   - n = retorno.data[1].registros.length;
241   - if ($i("i3GEOtabelafim").value === "") {
242   - $i("i3GEOtabelafim").value = n - 1;
243   - }
244   - for (i = 0; i < n; i++) {
245   - linha = {};
246   - linha.classezoom = "hidden";
247   - linha.ext = "";
248   - linha.indice = retorno.data[1].registros[i].indice;
249   - if (retorno.data[1].registros[i].ext && retorno.data[1].registros[i].ext != "") {
250   - linha.classezoom = "";
251   - linha.ext = retorno.data[1].registros[i].ext;
252   - }
253   - linha.stat = "";
254   - if (retorno.data[1].registros[i].status === "CHECKED") {
255   - linha.stat = "CHECKED";
256   - }
257   - if (registros[retorno.data[1].registros[i].indice]) {
258   - if (registros[retorno.data[1].registros[i].indice] === true) {
259   - linha.stat = "CHECKED";
260   - } else {
261   - linha.stat = "";
262   - }
263   - }
264   - if (i3GEOtabelalegenda == true) {
265   - linha.classelegenda = "";
266   - linha.nomeClasse = retorno.data[1].registros[i].classe["nome"];
267   - linha.imagemClasse = retorno.data.legenda[retorno.data[1].registros[i].classe["indice"]];
268   - imagem = retorno.data.legenda[retorno.data[1].registros[i].classe["indice"]];
269   - } else {
270   - linha.classelegenda = "hidden";
271   - linha.nomeClasse = "";
272   - linha.imagemClasse = "";
273   - }
274   - if (linha.stat === "CHECKED") {
275   - registros[retorno.data[1].registros[i].indice] = true;
276   - }
277   - vals = retorno.data[1].registros[i].valores;
278   - linha.colunas = "";
279   - for (j = 0; j < vals.length; j++) {
280   - linha.colunas += "<td style='min-width: 150px;' title='" + vals[j].item + "' >" + vals[j].valor + "</td>";
281   - }
282   - mustache.linhas.push(linha);
283   - }
284   - ins = Mustache.render(p.mustachelista, mustache);
285   - $i(p.idRegistros).innerHTML = ins;
  272 + vals = retorno.data[1].registros[i].valores;
  273 + linha.colunas = "";
  274 + for (j = 0; j < vals.length; j++) {
  275 + linha.colunas += "<td style='min-width: 150px;' title='" + vals[j].item + "' >" + vals[j].valor + "</td>";
286 276 }
287   - },
288   - /*
289   - * Function: mais
290   - *
291   - * Avan&ccedil;a o contador de registros para a listagem
292   - */
293   - mais : function(idjanela) {
294   - var i = $i("i3GEOtabelainicio").value * 1, f = $i("i3GEOtabelafim").value * 1, d = f - i;
295   - $i("i3GEOtabelainicio").value = f + 1;
296   - $i("i3GEOtabelafim").value = f + d + 1;
297   - i3GEOF.tabela.pegaRegistros();
298   - },
299   - /*
300   - * Function: todos
301   - *
302   - * Avan&ccedil;a o contador de registros para o fim da listagem
303   - */
304   - todos : function(idjanela) {
305   - $i("i3GEOtabelainicio").value = 1;
306   - $i("i3GEOtabelafim").value = "";
307   - i3GEOF.tabela.pegaRegistros(false, false, false, 1, false);
308   - },
309   - /*
310   - * Function: menos
311   - *
312   - * Retrocede o contador de registros para a listagem
313   - */
314   - menos : function(idjanela) {
315   - var i = $i("i3GEOtabelainicio").value * 1, f = $i("i3GEOtabelafim").value * 1, d = f - i;
316   - $i("i3GEOtabelainicio").value = i - d - 1;
317   - $i("i3GEOtabelafim").value = i - 1;
318   - if ($i("i3GEOtabelainicio").value < 1) {
319   - $i("i3GEOtabelainicio").value = 1;
320   - $i("i3GEOtabelafim").value = 1 + d;
  277 + mustache.linhas.push(linha);
  278 + }
  279 + ins = Mustache.render(p.mustachelista, mustache);
  280 + $i(p.idRegistros).innerHTML = ins;
  281 + }
  282 +},
  283 +/*
  284 + * Function: mais
  285 + *
  286 + * Avan&ccedil;a o contador de registros para a listagem
  287 + */
  288 +mais : function(idjanela) {
  289 + var i = $i("i3GEOtabelainicio").value * 1, f = $i("i3GEOtabelafim").value * 1, d = f - i;
  290 + $i("i3GEOtabelainicio").value = f + 1;
  291 + $i("i3GEOtabelafim").value = f + d + 1;
  292 + i3GEOF.tabela.pegaRegistros();
  293 +},
  294 +/*
  295 + * Function: todos
  296 + *
  297 + * Avan&ccedil;a o contador de registros para o fim da listagem
  298 + */
  299 +todos : function(idjanela) {
  300 + $i("i3GEOtabelainicio").value = 1;
  301 + $i("i3GEOtabelafim").value = "";
  302 + i3GEOF.tabela.pegaRegistros(false, false, false, 1, false);
  303 +},
  304 +/*
  305 + * Function: menos
  306 + *
  307 + * Retrocede o contador de registros para a listagem
  308 + */
  309 +menos : function(idjanela) {
  310 + var i = $i("i3GEOtabelainicio").value * 1, f = $i("i3GEOtabelafim").value * 1, d = f - i;
  311 + $i("i3GEOtabelainicio").value = i - d - 1;
  312 + $i("i3GEOtabelafim").value = i - 1;
  313 + if ($i("i3GEOtabelainicio").value < 1) {
  314 + $i("i3GEOtabelainicio").value = 1;
  315 + $i("i3GEOtabelafim").value = 1 + d;
  316 + }
  317 + i3GEOF.tabela.pegaRegistros();
  318 +},
  319 +/*
  320 + * Function: excluiColuna
  321 + *
  322 + * Exclui uma coluna da visualiza&ccedil;&atilde;o da tabela
  323 + */
  324 +excluiColuna : function(coluna, cid, idjanela) {
  325 + try {
  326 + var tabela = $i("i3GEOtabelatabelai"), trs, tds, i, t, nt, ni;
  327 + // pega o indice correto
  328 + tds = coluna.parentNode.parentNode.getElementsByTagName("td");
  329 + nt = tds.length;
  330 + for (t = 0; t < nt; t++) {
  331 + if (tds[t].accessKey == cid) {
  332 + cid = t;
  333 + break;
321 334 }
322   - i3GEOF.tabela.pegaRegistros();
323   - },
324   - /*
325   - * Function: excluiColuna
326   - *
327   - * Exclui uma coluna da visualiza&ccedil;&atilde;o da tabela
328   - */
329   - excluiColuna : function(coluna, cid, idjanela) {
330   - try {
331   - var tabela = $i("i3GEOtabelatabelai"), trs, tds, i, t, nt, ni;
332   - // pega o indice correto
333   - tds = coluna.parentNode.parentNode.getElementsByTagName("td");
334   - nt = tds.length;
335   - for (t = 0; t < nt; t++) {
336   - if (tds[t].accessKey == cid) {
337   - cid = t;
338   - break;
339   - }
340   - }
341   - trs = tabela.getElementsByTagName("tr");
342   - nt = trs.length;
343   - for (t = 0; t < nt; t++) {
344   - i = trs[t];
345   - if (i.getElementsByTagName("td")[cid]) {
346   - ni = i.getElementsByTagName("td")[cid];
347   - i.removeChild(ni);
348   - }
349   - }
350   - } catch (e) {
351   - if (typeof (console) !== 'undefined') {
352   - console.error(e);
353   - }
  335 + }
  336 + trs = tabela.getElementsByTagName("tr");
  337 + nt = trs.length;
  338 + for (t = 0; t < nt; t++) {
  339 + i = trs[t];
  340 + if (i.getElementsByTagName("td")[cid]) {
  341 + ni = i.getElementsByTagName("td")[cid];
  342 + i.removeChild(ni);
354 343 }
355   - },
356   - /*
357   - * Function: ordenaColuna
358   - *
359   - * Ordena uma coluna da tabela
360   - */
361   - ordenaColuna : function(coluna, cid, idjanela) {
362   - try {
363   - var numero = false,tabela = $i("i3GEOtabelatabelai"), trs = tabela.getElementsByTagName("tr"),
364   - ntrs = trs.length, tds, nt, psort = [], t, psortfim, npsortfim, ins, p, e, c;
365   -
366   - // pega o indice correto
367   - tds = coluna.parentNode.parentNode.getElementsByTagName("td");
368   - nt = tds.length;
369   - for (t = 0; t < nt; t++) {
370   - if (tds[t].accessKey == cid) {
371   - cid = t;
372   - break;
373   - }
374   - }
375   - for (t = 1; t < ntrs; t++) {
376   - c = trs[t].getElementsByTagName("td")[cid].innerHTML;
377   - psort.push( c + "@$" + t);
378   - if (c * 1) {
379   - numero = true;
380   - }
381   - }
382   - // recosntroi a tabela
383   - if(numero){
384   - psortfim = psort.sort(function(a, b) {
385   - return a.split("@$")[0]*1 - b.split("@$")[0]*1;
386   - });
387   - } else {
388   - psortfim = psort.sort();
389   - }
  344 + }
  345 + } catch (e) {
  346 + if (typeof (console) !== 'undefined') {
  347 + console.error(e);
  348 + }
  349 + }
  350 +},
  351 +/*
  352 + * Function: ordenaColuna
  353 + *
  354 + * Ordena uma coluna da tabela
  355 + */
  356 +ordenaColuna : function(coluna, cid, idjanela) {
  357 + try {
  358 + var numero = false,tabela = $i("i3GEOtabelatabelai"), trs = tabela.getElementsByTagName("tr"),
  359 + ntrs = trs.length, tds, nt, psort = [], t, psortfim, npsortfim, ins, p, e, c;
390 360  
391   - ins = "<table id=" + "i3GEOtabelatabelai class=lista8 >";
392   - ins += "<tr>" + trs[0].innerHTML + "</tr>";
393   - npsortfim = psortfim.length;
394   - for (p = 0; p < npsortfim; p++) {
395   - e = psortfim[p].split("@$")[1] * 1;
396   - if (trs[e] !== undefined) {
397   - ins += "<tr>" + trs[e].innerHTML + "</tr>";
398   - }
399   - }
400   - $i("i3GEOtabelaregistros").innerHTML = ins + "</table>";
401   - } catch (e) {
402   - if (typeof (console) !== 'undefined') {
403   - console.error(e);
404   - }
405   - }
406   - },
407   - excluiLinha : function(celula) {
408   - var p = celula.parentNode.parentNode;
409   - do {
410   - p.removeChild(p.childNodes[0]);
411   - } while (p.childNodes.length > 0);
412   - p.parentNode.removeChild(p);
413   - },
414   - zoomExt : function(ext, idjanela) {
415   - var funcao = function() {
416   - i3GEOF.tabela.pegaRegistros();
417   - i3GEO.atualiza();
418   - };
419   - i3GEO.php.mudaext(funcao, "nenhum", ext);
420   - },
421   - registraLinha : function(linha, idjanela) {
422   - i3GEOF.tabela._parameters.registros[linha.name] = linha.checked;
423   - },
424   - /*
425   - * Function: listaMarcados
426   - *
427   - * Retorna um array com os &iacute;ndices dos registros que est&atilde;o marcados.
428   - */
429   - listaMarcados : function(idjanela) {
430   - var lista = [], registros = i3GEOF.tabela._parameters.registros, i, n = registros.length;
431   - for (i = 0; i < n; i++) {
432   - if (registros[i] === true) {
433   - lista.push(i);
434   - }
435   - }
436   - return lista;
437   - },
438   - /*
439   - * Function: ativaSelecao
440   - *
441   - * Seleciona no mapa os elementos que estiverem marcados na guia 2
442   - *
443   - * Veja:
444   - *
445   - * <INCLUISEL>
446   - */
447   - ativaSelecao : function() {
448   - var lista = i3GEOF.tabela.listaMarcados(), p, cp, temp = function(retorno) {
449   - if (retorno) {
450   - i3GEO.Interface.atualizaTema(retorno, i3GEOF.tabela._parameters.tema);
451   - }
452   - };
453   - p =
454   - i3GEO.configura.locaplic + "/ferramentas/tabela/exec.php?g_sid="
455   - + i3GEO.configura.sid
456   - + "&funcao=incluisel&tema="
457   - + i3GEOF.tabela._parameters.tema
458   - + "&ids="
459   - + lista.toString();
460   - cp = new cpaint();
461   - cp.set_response_type("JSON");
462   - cp.call(p, "incluiSel", temp);
463   - },
464   - /*
465   - * Function: limpaSelecao
466   - *
467   - * Limpa a sele&ccedil;&atilde;o do tema da tabela
468   - */
469   - limpaSelecao : function() {
470   - i3GEO.tema.limpasel(i3GEOF.tabela._parameters.tema);
471   - i3GEOF.tabela._parameters.registros = [];
472   - var lista = $i("i3GEOtabelatabelai").getElementsByTagName("input"), n = lista.length, i;
473   - for (i = 0; i < n; i++) {
474   - lista[i].checked = false;
475   - }
476   - },
477   - /*
478   - * Function: criaNovoTema
479   - *
480   - * Cria um novo tema contendo a sele&ccedil;&atilde;o existente
481   - */
482   - criaNovoTema : function(idjanela) {
483   - var camada = i3GEO.arvoreDeCamadas.pegaTema(i3GEOF.tabela._parameters.tema);
484   - if(camada.nsel == 0){
485   - i3GEO.janela.tempoMsg($trad("selUmReg",i3GEOF.tabela.dicionario));
486   - return;
  361 + // pega o indice correto
  362 + tds = coluna.parentNode.parentNode.getElementsByTagName("td");
  363 + nt = tds.length;
  364 + for (t = 0; t < nt; t++) {
  365 + if (tds[t].accessKey == cid) {
  366 + cid = t;
  367 + break;
487 368 }
488   - var temp = function(retorno) {
489   - i3GEO.atualiza(retorno);
490   - };
491   - i3GEO.php.criatemaSel(temp, i3GEOF.tabela._parameters.tema);
492   - },
493   - /*
494   - * Function: comboItens
495   - *
496   - * Cria um combo para selecionar um item do tema escolhido
497   - */
498   - comboItensEstat : function(idjanela) {
499   - var tema = i3GEOF.tabela._parameters.tema;
500   - i3GEO.util.comboItens("i3GEOtabelaComboItensGuia3", tema, function(retorno) {
501   - if (retorno.tipo === "erro") {
502   - $i("i3GEOtabelaitensGuia3").innerHTML =
503   - i3GEO.janela.closeMsg('<div class="alert alert-danger" role="alert">' + $trad('erroTemaOrigem2',i3GEOF.tabela.dicionario) + '</div>');
504   - } else {
505   - $i("i3GEOtabelaitensGuia3").innerHTML = retorno.dados;
506   - }
507   - }, "i3GEOtabelaitensGuia3", "","sim","","form-control");
508   - },
509   - estatistica : function(idjanela) {
510   - if ($i("i3GEOtabelaComboItensGuia3").value === "") {
511   - i3GEO.janela.tempoMsg("Escolha um item!");
512   - return;
  369 + }
  370 + for (t = 1; t < ntrs; t++) {
  371 + c = trs[t].getElementsByTagName("td")[cid].innerHTML;
  372 + psort.push( c + "@$" + t);
  373 + if (c * 1) {
  374 + numero = true;
513 375 }
514   - try {
515   - var monta = function(retorno) {
516   - var ins = "", nome, valor, i, n;
517   - if (retorno.data.indices !== undefined) {
518   - if (retorno.data.indices) {
519   - n = retorno.data.indices.length;
520   - for (i = 0; i < n; i++) {
521   - nome =retorno.data.variaveis[retorno.data.indices[i]];
522   - valor = retorno.data.valores[retorno.data.indices[i]];
523   - ins += '<div class="row-content"><h4 class="list-group-item-heading">'+nome+'</h4><p class="list-group-item-text">'+valor+'</p></div>';
524   - ins += '<div class="list-group-separator">&nbsp;</div>';
525   - }
526   - }
527   - } else {
528   - ins = retorno.data;
529   - }
530   - $i("i3GEOtabelaoperacoes").innerHTML = ins + "<br>";
531   - }, exclui = "", cp = new cpaint(), p;
532   - if ($i("i3GEOtabelafiltro1").value !== "") {
533   - exclui = $i("i3GEOtabelafiltro1").value;
534   - }
535   - p =
536   - i3GEO.configura.locaplic + "/ferramentas/tabela/exec.php?g_sid="
537   - + i3GEO.configura.sid
538   - + "&funcao=estatistica&item="
539   - + $i("i3GEOtabelaComboItensGuia3").value
540   - + "&tema="
541   - + i3GEOF.tabela._parameters.tema
542   - + "&exclui="
543   - + exclui
544   - + "&ext="
545   - + i3GEO.parametros.mapexten;
546   - cp.set_response_type("JSON");
547   - cp.call(p, "estatDescritivas", monta);
548   - } catch (e) {
549   - $i("operacoes").innerHTML = "Ocorreu um erro: " + e;
  376 + }
  377 + // recosntroi a tabela
  378 + if(numero){
  379 + psortfim = psort.sort(function(a, b) {
  380 + return a.split("@$")[0]*1 - b.split("@$")[0]*1;
  381 + });
  382 + } else {
  383 + psortfim = psort.sort();
  384 + }
  385 +
  386 + ins = "<table id=" + "i3GEOtabelatabelai class=lista8 >";
  387 + ins += "<tr>" + trs[0].innerHTML + "</tr>";
  388 + npsortfim = psortfim.length;
  389 + for (p = 0; p < npsortfim; p++) {
  390 + e = psortfim[p].split("@$")[1] * 1;
  391 + if (trs[e] !== undefined) {
  392 + ins += "<tr>" + trs[e].innerHTML + "</tr>";
550 393 }
551   - },
552   - tabelaTexto : function() {
553   - },
554   - /*
555   - * Function: relatorioTabela
556   - *
557   - * Monta o relat&oacute;rio padr&atilde;o em uma nova janela
558   - */
559   - relatorioTabela : function() {
560   - try {
561   - $i("i3GEOtabelatiporelh").value = "";
562   - $i("i3GEOtabelaarearelh").value = $i("i3GEOtabelacalculaarea").checked;
563   - $i("i3GEOtabelastatrelh").value = $i("i3GEOtabelacalculaestat").checked;
564   - $i("i3GEOtabelaexcluirvalorh").value = $i("i3GEOtabelaexcestat").value;
565   - $i("i3GEOtabelatemarelh").value = i3GEOF.tabela._parameters.tema;
566   - $i("i3GEOtabelag_sidh").value = i3GEO.configura.sid;
567   - $i("i3GEOtabelaitemagruparelh").value = $i("i3GEOtabelaagrupaItem").value;
568   - var inputs = $i("i3GEOtabelaitensrelatorio").getElementsByTagName("input"), listai = [], listaordem = [], listanomes =
569   - [], nome, ordem, i, temp, n = inputs.length;
570   - for (i = 0; i < n; i++) {
571   - if (inputs[i].type === "checkbox" && inputs[i].checked == true) {
572   - listai.push(inputs[i].id + "|" + inputs[i].name);
573   - nome = $i(inputs[i].id + inputs[i].name).value;
574   - listanomes.push(nome);
575   - ordem = $i("ordem_" + inputs[i].id + inputs[i].name).value;
576   - if (ordem === "") {
577   - ordem = 0;
578   - }
579   - listaordem.push(ordem);
  394 + }
  395 + $i("i3GEOtabelaregistros").innerHTML = ins + "</table>";
  396 + } catch (e) {
  397 + if (typeof (console) !== 'undefined') {
  398 + console.error(e);
  399 + }
  400 + }
  401 +},
  402 +excluiLinha : function(celula) {
  403 + var p = celula.parentNode.parentNode;
  404 + do {
  405 + p.removeChild(p.childNodes[0]);
  406 + } while (p.childNodes.length > 0);
  407 + p.parentNode.removeChild(p);
  408 +},
  409 +zoomExt : function(ext, idjanela) {
  410 + var funcao = function() {
  411 + i3GEOF.tabela.pegaRegistros();
  412 + i3GEO.atualiza();
  413 + };
  414 + i3GEO.php.mudaext(funcao, "nenhum", ext);
  415 +},
  416 +registraLinha : function(linha, idjanela) {
  417 + i3GEOF.tabela._parameters.registros[linha.name] = linha.checked;
  418 +},
  419 +/*
  420 + * Function: listaMarcados
  421 + *
  422 + * Retorna um array com os &iacute;ndices dos registros que est&atilde;o marcados.
  423 + */
  424 +listaMarcados : function(idjanela) {
  425 + var lista = [], registros = i3GEOF.tabela._parameters.registros, i, n = registros.length;
  426 + for (i = 0; i < n; i++) {
  427 + if (registros[i] === true) {
  428 + lista.push(i);
  429 + }
  430 + }
  431 + return lista;
  432 +},
  433 +/*
  434 + * Function: ativaSelecao
  435 + *
  436 + * Seleciona no mapa os elementos que estiverem marcados na guia 2
  437 + *
  438 + * Veja:
  439 + *
  440 + * <INCLUISEL>
  441 + */
  442 +ativaSelecao : function() {
  443 + var lista = i3GEOF.tabela.listaMarcados(), p, cp, temp = function(retorno) {
  444 + if (retorno) {
  445 + i3GEO.Interface.atualizaTema(retorno, i3GEOF.tabela._parameters.tema);
  446 + }
  447 + };
  448 + p =
  449 + i3GEO.configura.locaplic + "/ferramentas/tabela/exec.php?g_sid="
  450 + + i3GEO.configura.sid
  451 + + "&funcao=incluisel&tema="
  452 + + i3GEOF.tabela._parameters.tema
  453 + + "&ids="
  454 + + lista.toString();
  455 + cp = new cpaint();
  456 + cp.set_response_type("JSON");
  457 + cp.call(p, "incluiSel", temp);
  458 +},
  459 +/*
  460 + * Function: limpaSelecao
  461 + *
  462 + * Limpa a sele&ccedil;&atilde;o do tema da tabela
  463 + */
  464 +limpaSelecao : function() {
  465 + i3GEO.tema.limpasel(i3GEOF.tabela._parameters.tema);
  466 + i3GEOF.tabela._parameters.registros = [];
  467 + var lista = $i("i3GEOtabelatabelai").getElementsByTagName("input"), n = lista.length, i;
  468 + for (i = 0; i < n; i++) {
  469 + lista[i].checked = false;
  470 + }
  471 +},
  472 +/*
  473 + * Function: criaNovoTema
  474 + *
  475 + * Cria um novo tema contendo a sele&ccedil;&atilde;o existente
  476 + */
  477 +criaNovoTema : function(idjanela) {
  478 + var camada = i3GEO.arvoreDeCamadas.pegaTema(i3GEOF.tabela._parameters.tema);
  479 + if(camada.nsel == 0){
  480 + i3GEO.janela.tempoMsg($trad("selUmReg",i3GEOF.tabela.dicionario));
  481 + return;
  482 + }
  483 + var temp = function(retorno) {
  484 + i3GEO.atualiza(retorno);
  485 + };
  486 + i3GEO.php.criatemaSel(temp, i3GEOF.tabela._parameters.tema);
  487 +},
  488 +/*
  489 + * Function: comboItens
  490 + *
  491 + * Cria um combo para selecionar um item do tema escolhido
  492 + */
  493 +comboItensEstat : function(idjanela) {
  494 + var tema = i3GEOF.tabela._parameters.tema;
  495 + i3GEO.util.comboItens("i3GEOtabelaComboItensGuia3", tema, function(retorno) {
  496 + if (retorno.tipo === "erro") {
  497 + $i("i3GEOtabelaitensGuia3").innerHTML =
  498 + i3GEO.janela.closeMsg('<div class="alert alert-danger" role="alert">' + $trad('erroTemaOrigem2',i3GEOF.tabela.dicionario) + '</div>');
  499 + } else {
  500 + $i("i3GEOtabelaitensGuia3").innerHTML = retorno.dados;
  501 + }
  502 + }, "i3GEOtabelaitensGuia3", "","sim","","form-control");
  503 +},
  504 +estatistica : function(idjanela) {
  505 + if ($i("i3GEOtabelaComboItensGuia3").value === "") {
  506 + i3GEO.janela.tempoMsg("Escolha um item!");
  507 + return;
  508 + }
  509 + try {
  510 + var monta = function(retorno) {
  511 + var ins = "", nome, valor, i, n;
  512 + if (retorno.data.indices !== undefined) {
  513 + if (retorno.data.indices) {
  514 + n = retorno.data.indices.length;
  515 + for (i = 0; i < n; i++) {
  516 + nome =retorno.data.variaveis[retorno.data.indices[i]];
  517 + valor = retorno.data.valores[retorno.data.indices[i]];
  518 + ins += '<div class="row-content"><h4 class="list-group-item-heading">'+nome+'</h4><p class="list-group-item-text">'+valor+'</p></div>';
  519 + ins += '<div class="list-group-separator">&nbsp;</div>';
580 520 }
581 521 }
582   - $i("i3GEOtabelaordemrel").value = listaordem;
583   - $i("i3GEOtabelanomesrelh").value = listanomes;
584   - $i("i3GEOtabelaitensrelh").value = listai;
585   - temp = $i("i3GEOtabelarelatorio").action;
586   - $i("i3GEOtabelarelatorio").action += "?ext=" + i3GEO.parametros.mapexten;
587   - $i("i3GEOtabelarelatorio").submit();
588   - $i("i3GEOtabelarelatorio").action = temp;
589   - } catch (e) {
590   - i3GEO.janela.tempoMsg(e);
  522 + } else {
  523 + ins = retorno.data;
591 524 }
592   - },
593   - /*
594   - * Function: relatorioTexto
595   - *
596   - * Gera o relat&oacute;rio no formato CSV
597   - */
598   - relatorioTexto : function(idjanela) {
599   - $i("i3GEOtabelaarearelh").value = $i("i3GEOtabelacalculaarea").checked;
600   - $i("i3GEOtabelastatrelh").value = $i("i3GEOtabelacalculaestat").checked;
601   - $i("i3GEOtabelaexcluirvalorh").value = $i("i3GEOtabelaexcestat").value;
602   - $i("i3GEOtabelatemarelh").value = i3GEOF.tabela._parameters.tema;
603   - $i("i3GEOtabelag_sidh").value = i3GEO.configura.sid;
604   - $i("i3GEOtabelaitemagruparelh").value = $i("i3GEOtabelaagrupaItem").value;
605   - $i("i3GEOtabelatiporelh").value = "csv";
606   - var inputs = $i("i3GEOtabelaitensrelatorio").getElementsByTagName("input"), listai = [], listanomes = [], nome, i, temp, n =
607   - inputs.length;
608   - for (i = 0; i < n; i++) {
609   - if (inputs[i].checked === true) {
610   - listai.push(inputs[i].id + "|" + inputs[i].name);
611   - nome = $i(inputs[i].id + inputs[i].name).value;
612   - listanomes.push(nome);
  525 + $i("i3GEOtabelaoperacoes").innerHTML = ins + "<br>";
  526 + }, exclui = "", cp = new cpaint(), p;
  527 + if ($i("i3GEOtabelafiltro1").value !== "") {
  528 + exclui = $i("i3GEOtabelafiltro1").value;
  529 + }
  530 + p =
  531 + i3GEO.configura.locaplic + "/ferramentas/tabela/exec.php?g_sid="
  532 + + i3GEO.configura.sid
  533 + + "&funcao=estatistica&item="
  534 + + $i("i3GEOtabelaComboItensGuia3").value
  535 + + "&tema="
  536 + + i3GEOF.tabela._parameters.tema
  537 + + "&exclui="
  538 + + exclui
  539 + + "&ext="
  540 + + i3GEO.parametros.mapexten;
  541 + cp.set_response_type("JSON");
  542 + cp.call(p, "estatDescritivas", monta);
  543 + } catch (e) {
  544 + $i("operacoes").innerHTML = "Ocorreu um erro: " + e;
  545 + }
  546 +},
  547 +tabelaTexto : function() {
  548 +},
  549 +/*
  550 + * Function: relatorioTabela
  551 + *
  552 + * Monta o relat&oacute;rio padr&atilde;o em uma nova janela
  553 + */
  554 +relatorioTabela : function() {
  555 + try {
  556 + $i("i3GEOtabelatiporelh").value = "";
  557 + $i("i3GEOtabelaarearelh").value = $i("i3GEOtabelacalculaarea").checked;
  558 + $i("i3GEOtabelastatrelh").value = $i("i3GEOtabelacalculaestat").checked;
  559 + $i("i3GEOtabelaexcluirvalorh").value = $i("i3GEOtabelaexcestat").value;
  560 + $i("i3GEOtabelatemarelh").value = i3GEOF.tabela._parameters.tema;
  561 + $i("i3GEOtabelag_sidh").value = i3GEO.configura.sid;
  562 + $i("i3GEOtabelaitemagruparelh").value = $i("i3GEOtabelaagrupaItem").value;
  563 + var inputs = $i("i3GEOtabelaitensrelatorio").getElementsByTagName("input"), listai = [], listaordem = [], listanomes =
  564 + [], nome, ordem, i, temp, n = inputs.length;
  565 + for (i = 0; i < n; i++) {
  566 + if (inputs[i].type === "checkbox" && inputs[i].checked == true) {
  567 + listai.push(inputs[i].id + "|" + inputs[i].name);
  568 + nome = $i(inputs[i].id + inputs[i].name).value;
  569 + listanomes.push(nome);
  570 + ordem = $i("ordem_" + inputs[i].id + inputs[i].name).value;
  571 + if (ordem === "") {
  572 + ordem = 0;
613 573 }
  574 + listaordem.push(ordem);
614 575 }
615   - $i("i3GEOtabelanomesrelh").value = listanomes;
616   - $i("i3GEOtabelaitensrelh").value = listai;
617   - temp = $i("i3GEOtabelarelatorio").action;
618   - $i("i3GEOtabelarelatorio").action += "?ext=" + i3GEO.parametros.mapexten;
619   - $i("i3GEOtabelarelatorio").submit();
620   - $i("i3GEOtabelarelatorio").action = temp;
621 576 }
  577 + $i("i3GEOtabelaordemrel").value = listaordem;
  578 + $i("i3GEOtabelanomesrelh").value = listanomes;
  579 + $i("i3GEOtabelaitensrelh").value = listai;
  580 + temp = $i("i3GEOtabelarelatorio").action;
  581 + $i("i3GEOtabelarelatorio").action += "?ext=" + i3GEO.parametros.mapexten;
  582 + $i("i3GEOtabelarelatorio").submit();
  583 + $i("i3GEOtabelarelatorio").action = temp;
  584 + } catch (e) {
  585 + i3GEO.janela.tempoMsg(e);
  586 + }
  587 +},
  588 +/*
  589 + * Function: relatorioTexto
  590 + *
  591 + * Gera o relat&oacute;rio no formato CSV
  592 + */
  593 +relatorioTexto : function(idjanela) {
  594 + $i("i3GEOtabelaarearelh").value = $i("i3GEOtabelacalculaarea").checked;
  595 + $i("i3GEOtabelastatrelh").value = $i("i3GEOtabelacalculaestat").checked;
  596 + $i("i3GEOtabelaexcluirvalorh").value = $i("i3GEOtabelaexcestat").value;
  597 + $i("i3GEOtabelatemarelh").value = i3GEOF.tabela._parameters.tema;
  598 + $i("i3GEOtabelag_sidh").value = i3GEO.configura.sid;
  599 + $i("i3GEOtabelaitemagruparelh").value = $i("i3GEOtabelaagrupaItem").value;
  600 + $i("i3GEOtabelatiporelh").value = "csv";
  601 + var inputs = $i("i3GEOtabelaitensrelatorio").getElementsByTagName("input"), listai = [], listanomes = [], nome, i, temp, n =
  602 + inputs.length;
  603 + for (i = 0; i < n; i++) {
  604 + if (inputs[i].checked === true) {
  605 + listai.push(inputs[i].id + "|" + inputs[i].name);
  606 + nome = $i(inputs[i].id + inputs[i].name).value;
  607 + listanomes.push(nome);
  608 + }
  609 + }
  610 + $i("i3GEOtabelanomesrelh").value = listanomes;
  611 + $i("i3GEOtabelaitensrelh").value = listai;
  612 + temp = $i("i3GEOtabelarelatorio").action;
  613 + $i("i3GEOtabelarelatorio").action += "?ext=" + i3GEO.parametros.mapexten;
  614 + $i("i3GEOtabelarelatorio").submit();
  615 + $i("i3GEOtabelarelatorio").action = temp;
  616 +}
622 617 };
623 618 \ No newline at end of file
... ...