Commit 37c3e4e982c330cda7d43dae2328e330162b804a
1 parent
20a554c2
Exists in
master
and in
7 other branches
Inclusão de filtro para listar apenas as colunas de um determinado tipo nos formulários do METAESTAT
Showing
3 changed files
with
35 additions
and
26 deletions
Show diff stats
admin/js/estat_tipo_regiao.js
| ... | ... | @@ -58,25 +58,25 @@ function montaTabela(dados){ |
| 58 | 58 | elCell.innerHTML = "<div class=download style='text-align:center' title='shape file' ></div>"; |
| 59 | 59 | }, |
| 60 | 60 | myColumnDefs = [ |
| 61 | - {key:"excluir",label:"excluir",formatter:formatExclui}, | |
| 62 | - {key:"shapefile",label:"download",formatter:formatShp}, | |
| 63 | - {key:"rel",label:"agregações",formatter:formatRel}, | |
| 64 | - {key:"mais",label:"propriedades",formatter:formatMais}, | |
| 65 | - {label:"código",key:"codigo_tipo_regiao", formatter:formatTexto}, | |
| 66 | - {label:"Nome",resizeable:true,key:"nome_tipo_regiao", formatter:formatTexto}, | |
| 67 | - {label:"Descrição",resizeable:true,key:"descricao_tipo_regiao", formatter:formatTexto}, | |
| 68 | - {label:"Conexão",key:"codigo_estat_conexao",formatter:formatTexto}, | |
| 69 | - {label:"Esquema",key:"esquemadb",formatter:formatTexto}, | |
| 70 | - {label:"Tabela",key:"tabela",formatter:formatTexto}, | |
| 71 | - {label:"Geometria",key:"colunageo",formatter:formatTexto}, | |
| 72 | - {label:"Centróide",key:"colunacentroide",formatter:formatTexto}, | |
| 73 | - {label:"Data",key:"data",formatter:formatTexto}, | |
| 74 | - {label:"Região",key:"identificador",formatter:formatTexto}, | |
| 75 | - {label:"Nomes",resizeable:false,key:"colunanomeregiao",formatter:formatTexto}, | |
| 76 | - {label:"Colunas visíveis (separa com vírgula)",resizeable:false,key:"colunasvisiveis",formatter:formatTexto}, | |
| 77 | - {label:"Apelidos",resizeable:false,key:"apelidos",formatter:formatTexto}, | |
| 78 | - {label:"SRID",key:"srid",formatter:formatTexto} | |
| 79 | - ]; | |
| 61 | + {key:"excluir",label:"excluir",formatter:formatExclui}, | |
| 62 | + {key:"shapefile",label:"download",formatter:formatShp}, | |
| 63 | + {key:"rel",label:"agregações",formatter:formatRel}, | |
| 64 | + {key:"mais",label:"propriedades",formatter:formatMais}, | |
| 65 | + {label:"código",key:"codigo_tipo_regiao", formatter:formatTexto}, | |
| 66 | + {label:"Nome",resizeable:true,key:"nome_tipo_regiao", formatter:formatTexto}, | |
| 67 | + {label:"Descrição",resizeable:true,key:"descricao_tipo_regiao", formatter:formatTexto}, | |
| 68 | + {label:"Conexão",key:"codigo_estat_conexao",formatter:formatTexto}, | |
| 69 | + {label:"Esquema",key:"esquemadb",formatter:formatTexto}, | |
| 70 | + {label:"Tabela",key:"tabela",formatter:formatTexto}, | |
| 71 | + {label:"Geometria",key:"colunageo",formatter:formatTexto}, | |
| 72 | + {label:"Centróide",key:"colunacentroide",formatter:formatTexto}, | |
| 73 | + {label:"Data",key:"data",formatter:formatTexto}, | |
| 74 | + {label:"Região",key:"identificador",formatter:formatTexto}, | |
| 75 | + {label:"Nomes",resizeable:false,key:"colunanomeregiao",formatter:formatTexto}, | |
| 76 | + {label:"Colunas visíveis (separa com vírgula)",resizeable:false,key:"colunasvisiveis",formatter:formatTexto}, | |
| 77 | + {label:"Apelidos",resizeable:false,key:"apelidos",formatter:formatTexto}, | |
| 78 | + {label:"SRID",key:"srid",formatter:formatTexto} | |
| 79 | + ]; | |
| 80 | 80 | myDataSource = new YAHOO.util.DataSource(dados); |
| 81 | 81 | myDataTable = new YAHOO.widget.ScrollingDataTable("tabela", myColumnDefs, myDataSource,{width:"100%"}); |
| 82 | 82 | |
| ... | ... | @@ -280,8 +280,8 @@ function montaDiv(i){ |
| 280 | 280 | {titulo:"Código da conexão com o banco:",id:"",size:"50",value:i.codigo_estat_conexao,tipo:"text",div:"<div id=Ccodigo_estat_conexao ></div>"}, |
| 281 | 281 | {titulo:"Esquema no banco de dados: <img onclick='selEsquema(\"Eesquemadb\",\"Ecodigo_estat_conexao\")' src='"+limg+"' style='cursor:pointer;position :relative;top:2px'/>",id:"Eesquemadb",size:"50",value:i.esquemadb,tipo:"text",div:""}, |
| 282 | 282 | {titulo:"Tabela: <img onclick='selTabela(\"Etabela\",\"Ecodigo_estat_conexao\",\"Eesquemadb\")' src='"+limg+"' style='cursor:pointer;position :relative;top:2px'/>",id:"Etabela",size:"50",value:i.tabela,tipo:"text",div:""}, |
| 283 | - {titulo:"Coluna com a geometria principal (normalmente poligonal): <img onclick='selColuna(\"Ecolunageo\",\"Ecodigo_estat_conexao\",\"Eesquemadb\",\"Etabela\")' src='"+limg+"' style='cursor:pointer;position :relative;top:2px'/>",id:"Ecolunageo",size:"50",value:i.colunageo,tipo:"text",div:""}, | |
| 284 | - {titulo:"Coluna com pontos (pode ser a mesmo que a anterior):<img onclick='selColuna(\"Ecolunacentroide\",\"Ecodigo_estat_conexao\",\"Eesquemadb\",\"Etabela\")' src='"+limg+"' style='cursor:pointer;position :relative;top:2px'/>",id:"Ecolunacentroide",size:"50",value:i.colunacentroide,tipo:"text",div:""}, | |
| 283 | + {titulo:"Coluna com a geometria principal (normalmente poligonal): <img onclick='selColuna(\"Ecolunageo\",\"Ecodigo_estat_conexao\",\"Eesquemadb\",\"Etabela\",\"geometry\")' src='"+limg+"' style='cursor:pointer;position :relative;top:2px'/>",id:"Ecolunageo",size:"50",value:i.colunageo,tipo:"text",div:""}, | |
| 284 | + {titulo:"Coluna com pontos (pode ser a mesmo que a anterior):<img onclick='selColuna(\"Ecolunacentroide\",\"Ecodigo_estat_conexao\",\"Eesquemadb\",\"Etabela\",\"geometry\")' src='"+limg+"' style='cursor:pointer;position :relative;top:2px'/>",id:"Ecolunacentroide",size:"50",value:i.colunacentroide,tipo:"text",div:""}, | |
| 285 | 285 | {titulo:"Data a qual se referem os dados:",id:"Edata",size:"50",value:i.data,tipo:"text",div:""}, |
| 286 | 286 | {titulo:"Coluna com o código de cada registro:<img onclick='selColuna(\"Eidentificador\",\"Ecodigo_estat_conexao\",\"Eesquemadb\",\"Etabela\")' src='"+limg+"' style='cursor:pointer;position :relative;top:2px'/>",id:"Eidentificador",size:"50",value:i.identificador,tipo:"text",div:""}, |
| 287 | 287 | {titulo:"Coluna com o nome do limite geográfico:<img onclick='selColuna(\"Ecolunanomeregiao\",\"Ecodigo_estat_conexao\",\"Eesquemadb\",\"Etabela\")' src='"+limg+"' style='cursor:pointer;position :relative;top:2px'/>",id:"Ecolunanomeregiao",size:"50",value:i.colunanomeregiao,tipo:"text",div:""}, |
| ... | ... | @@ -445,7 +445,10 @@ function selTabela(idEleValue,idEleCodigoConexao,idEleNomeEsquema){ |
| 445 | 445 | } |
| 446 | 446 | core_makeRequest(i3GEO.configura.locaplic+"/admin/php/metaestat.php?funcao=tabelasEsquema&formato=json&codigo_estat_conexao="+eleCodigoConexao.value+"&nome_esquema="+eleNomeEsquema.value,callback); |
| 447 | 447 | } |
| 448 | -function selColuna(idEleValue,idEleCodigoConexao,idEleNomeEsquema,idEleNomeTabela){ | |
| 448 | +function selColuna(idEleValue,idEleCodigoConexao,idEleNomeEsquema,idEleNomeTabela,tipo){ | |
| 449 | + if(!tipo){ | |
| 450 | + tipo = ""; | |
| 451 | + } | |
| 449 | 452 | var eleValue = $i(idEleValue), |
| 450 | 453 | eleCodigoConexao = $i(idEleCodigoConexao), |
| 451 | 454 | eleNomeEsquema = $i(idEleNomeEsquema), |
| ... | ... | @@ -473,7 +476,7 @@ function selColuna(idEleValue,idEleCodigoConexao,idEleNomeEsquema,idEleNomeTabel |
| 473 | 476 | if(!eleValue || !eleCodigoConexao || !eleNomeEsquema || !eleNomeTabela){ |
| 474 | 477 | return; |
| 475 | 478 | } |
| 476 | - core_makeRequest(i3GEO.configura.locaplic+"/admin/php/metaestat.php?funcao=colunasTabela&formato=json&codigo_estat_conexao="+eleCodigoConexao.value+"&nome_esquema="+eleNomeEsquema.value+"&nome_tabela="+eleNomeTabela.value,callback); | |
| 479 | + core_makeRequest(i3GEO.configura.locaplic+"/admin/php/metaestat.php?funcao=colunasTabela&tipo="+tipo+"&formato=json&codigo_estat_conexao="+eleCodigoConexao.value+"&nome_esquema="+eleNomeEsquema.value+"&nome_tabela="+eleNomeTabela.value,callback); | |
| 477 | 480 | } |
| 478 | 481 | |
| 479 | 482 | //YAHOO.util.Event.addListener(window, "load", initMenu); |
| 480 | 483 | \ No newline at end of file | ... | ... |
admin/php/classe_metaestat.php
| ... | ... | @@ -1704,9 +1704,12 @@ class Metaestat{ |
| 1704 | 1704 | function copiaTabelaDB($codigo_estat_conexao,$nome_esquema,$nome_tabela,$novonome_tabela){ |
| 1705 | 1705 | return $this->execSQLDB($codigo_estat_conexao,"CREATE TABLE ".$nome_esquema.".".$novonome_tabela." AS select * from ".$nome_esquema.".".$nome_tabela ); |
| 1706 | 1706 | } |
| 1707 | - function colunasTabela($codigo_estat_conexao,$nome_esquema,$nome_tabela){ | |
| 1707 | + function colunasTabela($codigo_estat_conexao,$nome_esquema,$nome_tabela,$tipo=""){ | |
| 1708 | 1708 | $colunas = array(); |
| 1709 | - $res = $this->execSQLDB($codigo_estat_conexao,"SELECT column_name as coluna FROM information_schema.columns where table_schema = '$nome_esquema' and table_name = '$nome_tabela'"); | |
| 1709 | + $res = $this->execSQLDB($codigo_estat_conexao,"SELECT column_name as coluna,udt_name FROM information_schema.columns where table_schema = '$nome_esquema' and table_name = '$nome_tabela'"); | |
| 1710 | + if($tipo != ""){ | |
| 1711 | + $res = $this->execSQLDB($codigo_estat_conexao,"SELECT column_name as coluna,udt_name FROM information_schema.columns where table_schema = '$nome_esquema' and udt_name = '$tipo' and table_name = '$nome_tabela'"); | |
| 1712 | + } | |
| 1710 | 1713 | foreach($res as $c){ |
| 1711 | 1714 | $colunas[] = $c["coluna"]; |
| 1712 | 1715 | } | ... | ... |
admin/php/metaestat.php
| ... | ... | @@ -1334,8 +1334,11 @@ switch (strtoupper($funcao)) |
| 1334 | 1334 | */ |
| 1335 | 1335 | case "COLUNASTABELA": |
| 1336 | 1336 | $m = new Metaestat(); |
| 1337 | + if(empty($tipo)){ | |
| 1338 | + $tipo = ""; | |
| 1339 | + } | |
| 1337 | 1340 | if($formato == "json"){ |
| 1338 | - retornaJSON($m->colunasTabela($codigo_estat_conexao,$nome_esquema,$nome_tabela)); | |
| 1341 | + retornaJSON($m->colunasTabela($codigo_estat_conexao,$nome_esquema,$nome_tabela,$tipo)); | |
| 1339 | 1342 | } |
| 1340 | 1343 | exit; |
| 1341 | 1344 | break; | ... | ... |