Commit 605e8b4ae030702f5a407856a386194deac82b67

Authored by Edmar Moretti
1 parent 35d519bc

Atuzaliação da ferramenta tabela

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