Commit da6357f0462070dde30b379de3b5a1b3a06a4909

Authored by Edmar Moretti
1 parent 87cc4ea3

Alteração nos padrões de programação

admin/admin.db
No preview for this file type
admin/html/estat_conexao.html
... ... @@ -43,6 +43,7 @@ body {
43 43 value="Adicionar um novo registro" style="left: -5px;" />
44 44 <p>
45 45 <br>
  46 + <div id="letras" ></div><br>
46 47 <div id="tabela" style="left: -5px;"></div>
47 48 </div>
48 49 </div>
... ... @@ -86,7 +87,7 @@ body {
86 87 };
87 88 cabecalhoMetaestat("cabecalhoPrincipal", "conexao");
88 89 document.getElementById("formulario").style.display = "block";
89   - initEditor();
  90 + i3GEOadmin.conexao.inicia();
90 91 /*
91 92 temp = function() {
92 93 document.getElementById("formulario").style.display = "block";
... ...
admin/html/estat_fonteinfo.html
... ... @@ -41,6 +41,7 @@ body {
41 41 value="Adicionar um novo registro" style="left: -5px;" />
42 42 <p>
43 43 <br>
  44 + <div id="letras" ></div><br>
44 45 <div id="tabela" style="left: -5px;"></div>
45 46 </div>
46 47 </div>
... ... @@ -85,7 +86,7 @@ body {
85 86 };
86 87 cabecalhoMetaestat("cabecalhoPrincipal", "fonteinfo");
87 88 document.getElementById("formulario").style.display = "block";
88   - initEditor();
  89 + i3GEOadmin.fonteinfo.inicia();
89 90 /*
90 91 temp = function() {
91 92 document.getElementById("formulario").style.display = "block";
... ...
admin/html/estat_tipo_periodo.html
... ... @@ -40,6 +40,7 @@ body {
40 40 value="Adicionar um novo registro" style="left: -5px;" />
41 41 <p>
42 42 <br>
  43 + <div id="letras" ></div><br>
43 44 <div id="tabela" style="left: -5px;"></div>
44 45 </div>
45 46 </div>
... ... @@ -83,7 +84,7 @@ body {
83 84 };
84 85 cabecalhoMetaestat("cabecalhoPrincipal", "periodo_tempo");
85 86 document.getElementById("formulario").style.display = "block";
86   - initEditor();
  87 + i3GEOadmin.periodo.inicia();
87 88 /*
88 89 temp = function() {
89 90 document.getElementById("formulario").style.display = "block";
... ...
admin/html/estat_unidade_medida.html
... ... @@ -41,6 +41,7 @@ body {
41 41 value="Adicionar um novo registro" style="left: -5px;" />
42 42 <p>
43 43 <br>
  44 + <div id="letras" ></div><br>
44 45 <div id="tabela" style="left: -5px;"></div>
45 46 </div>
46 47 </div>
... ... @@ -85,7 +86,7 @@ body {
85 86 };
86 87 cabecalhoMetaestat("cabecalhoPrincipal", "unidade_medida");
87 88 document.getElementById("formulario").style.display = "block";
88   - initEditor();
  89 + i3GEOadmin.umedida.inicia();
89 90 /*
90 91 temp = function() {
91 92 document.getElementById("formulario").style.display = "block";
... ...
admin/index.html
... ... @@ -179,10 +179,6 @@
179 179 <td><div class=aplicar></div></td>
180 180 <td>Cadastro de tabelas com regi&otilde;es geogr&aacute;ficas</td>
181 181 </tr>
182   - <tr onclick="abre('html/estat_links.html')">
183   - <td><div class=aplicar></div></td>
184   - <td>Cadastro de links</td>
185   - </tr>
186 182 <tr onclick="abre('html/estat_fonteinfo.html')">
187 183 <td><div class=aplicar></div></td>
188 184 <td>Cadastro de fontes de informa&ccedil;&atilde;o</td>
... ...
admin/js/estat_conexao.js
1   -function initEditor(){
2   - YAHOO.namespace("admin.container");
3   - core_ativaBotaoAdicionaLinha("../php/metaestat.php?funcao=alterarConexao","adicionaNovaLinha","pegaDados");
4   - pegaDados();
  1 +if(typeof(i3GEOadmin) === 'undefined'){
  2 + var i3GEOadmin = {};
5 3 }
6   -function pegaDados(){
7   - core_carregando("ativa");
8   - core_pegaDados("buscando dados...","../php/metaestat.php?funcao=listaConexao","montaTabela");
9   -}
10   -function montaTabela(dados){
11   - YAHOO.example.InlineCellEditing = new function() {
12   - // Custom formatter for "address" column to preserve line breaks
13   - var formatTexto = function(elCell, oRecord, oColumn, oData){
14   - if(oData === ""){
15   - oData = "<span style='color:gray' ></span>";
16   - }
17   - elCell.innerHTML = "<pre ><p style=cursor:pointer title='clique para editar'>" + oData + "</pre>";
18   - },
19   - formatExclui = function(elCell, oRecord, oColumn){
20   - elCell.innerHTML = "<div class=excluir title='exclui' style='text-align:center' ></div>";
21   - },
22   - formatMais = function(elCell, oRecord, oColumn){
23   - elCell.innerHTML = "<div class=editar style='text-align:center' ></div>";
24   - },
25   - formatSenha = function(elCell, oRecord, oColumn){
26   - elCell.innerHTML = "a senha deve ser editada<br>diretamente no banco de dados";
27   - },
28   - myColumnDefs = [
29   - {key:"excluir",label:"excluir",formatter:formatExclui},
30   - {key:"mais",label:"editar",formatter:formatMais},
31   - {label:"c&oacute;digo",key:"codigo_estat_conexao", formatter:formatTexto},
32   - {label:"Banco de dados",resizeable:true,key:"bancodedados", formatter:formatTexto},
33   - {label:"Host",resizeable:true,key:"host", formatter:formatTexto},
34   - {label:"Porta",key:"porta",formatter:formatTexto},
35   - {label:"Usu&aacute;rio",key:"usuario",formatter:formatTexto},
36   - {label:"Senha",key:"senha",formatter:formatSenha}
37   - ];
38   - myDataSource = new YAHOO.util.DataSource(dados);
39   - myDataTable = new YAHOO.widget.DataTable("tabela", myColumnDefs, myDataSource);
40   -
41   - myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
42   - myDataSource.responseSchema = {
43   - fields: ["codigo_estat_conexao","bancodedados","host","porta","usuario","senha"]
44   - };
45   - myDataTable.subscribe(
46   - 'cellClickEvent',
47   - function(ev){
48   - var record,$clicouId,$recordid,sUrl,callback,
49   - target = YAHOO.util.Event.getTarget(ev),
50   - column = this.getColumn(target);
51   - if(YAHOO.admin.container.panelCK){
52   - YAHOO.admin.container.panelCK.destroy();
53   - YAHOO.admin.container.panelCK = null;
  4 +i3GEOadmin.conexao = {
  5 + dados: "",
  6 + dataTable: null,
  7 + colunas: ["codigo_estat_conexao","bancodedados","host","porta","usuario","senha"],
  8 + formatTexto: function(elCell, oRecord, oColumn, oData){
  9 + if(oData === ""){
  10 + oData = "<span style='color:gray' ></span>";
  11 + }
  12 + elCell.innerHTML = "<pre ><p style=cursor:default >" + oData + "</pre>";
  13 + },
  14 + formatExclui: function(elCell, oRecord, oColumn){
  15 + elCell.innerHTML = "<div title='exclui' class=excluir style='text-align:center' ></div>";
  16 + },
  17 + formatMais: function(elCell, oRecord, oColumn){
  18 + elCell.innerHTML = "<div class=editar style='text-align:center' ></div>";
  19 + },
  20 + formatSenha: function(elCell, oRecord, oColumn){
  21 + elCell.innerHTML = "a senha deve ser editada<br>diretamente no banco de dados";
  22 + },
  23 + defColunas: function(){
  24 + return [
  25 + {key:"excluir",label:"excluir",formatter:i3GEOadmin.conexao.formatExclui},
  26 + {key:"mais",label:"editar",formatter:i3GEOadmin.conexao.formatMais},
  27 + {label:"c&oacute;digo",key:"codigo_estat_conexao", formatter:i3GEOadmin.conexao.formatTexto},
  28 + {label:"Banco de dados",resizeable:true,key:"bancodedados", formatter:i3GEOadmin.conexao.formatTexto},
  29 + {label:"Host",resizeable:true,key:"host", formatter:i3GEOadmin.conexao.formatTexto},
  30 + {label:"Porta",key:"porta",formatter:i3GEOadmin.conexao.formatTexto},
  31 + {label:"Usu&aacute;rio",key:"usuario",formatter:i3GEOadmin.conexao.formatTexto},
  32 + {label:"Senha",key:"senha",formatter:i3GEOadmin.conexao.formatSenha}
  33 + ];
  34 + },
  35 + /*
  36 + * Inicializa o menu
  37 + */
  38 + inicia: function(){
  39 + YAHOO.namespace("conexao");
  40 + YAHOO.namespace("admin.container");
  41 + core_ativaPainelAjuda("ajuda","botaoAjuda");
  42 + core_ativaBotaoAdicionaLinha("../php/metaestat.php?funcao=alterarConexao","adicionaNovaLinha","i3GEOadmin.conexao.obtem");
  43 + i3GEOadmin.conexao.obtem();
  44 + },
  45 + /*
  46 + * Obt&eacute;m a lista de menus
  47 + */
  48 + obtem: function(){
  49 + i3GEOadmin.conexao.dados = "";
  50 + core_carregando("ativa");
  51 + core_pegaDados("buscando endere&ccedil;os...","../php/metaestat.php?funcao=listaConexao","i3GEOadmin.conexao.tabela");
  52 + },
  53 + tabela: function(dados){
  54 + if(i3GEOadmin.conexao.dados == ""){
  55 + i3GEOadmin.conexao.dados = dados;
  56 + }
  57 + core_listaDeLetras("letras","i3GEOadmin.conexao.filtra");
  58 + YAHOO.example.InlineCellEditing = new function(){
  59 + // Custom formatter for "address" column to preserve line breaks
  60 + var myDataSource = new YAHOO.util.DataSource(dados);
  61 + myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
  62 + myDataSource.responseSchema = {
  63 + fields: i3GEOadmin.conexao.colunas
  64 + };
  65 + i3GEOadmin.conexao.dataTable = new YAHOO.widget.DataTable("tabela", i3GEOadmin.conexao.defColunas(), myDataSource);
  66 + i3GEOadmin.conexao.dataTable.subscribe('cellClickEvent',function(ev){
  67 + var sUrl, callback,$clicouId, $recordid,
  68 + target = YAHOO.util.Event.getTarget(ev),
  69 + column = this.getColumn(target),
  70 + registro = this.getRecord(target);
  71 + if(YAHOO.conexao.panelCK) {
  72 + YAHOO.conexao.panelCK.destroy();
  73 + YAHOO.conexao.panelCK = null;
54 74 }
55 75 if (column.key == 'excluir'){
56   - record = this.getRecord(target);
57   - excluiLinha(record.getData('codigo_estat_conexao'),target);
  76 + i3GEOadmin.conexao.exclui(registro.getData('codigo_estat_conexao'),target);
58 77 }
59 78 if (column.key == 'mais'){
60   - record = this.getRecord(target);
61 79 core_carregando("ativa");
62 80 core_carregando("buscando dados...");
63   - $clicouId = record.getData('codigo_estat_conexao');
64   - $recordid = record.getId();
65   - sUrl = "../php/metaestat.php?funcao=listaConexao&codigo_estat_conexao="+record.getData('codigo_estat_conexao');
  81 + $clicouId = registro.getData('codigo_estat_conexao');
  82 + $recordid = registro.getId();
  83 + sUrl = "../php/metaestat.php?funcao=listaConexao&codigo_estat_conexao="+$clicouId;
66 84 callback = {
67   - success:function(o){
68   - try{
69   - montaEditor(YAHOO.lang.JSON.parse(o.responseText),$clicouId,$recordid);
70   - }
71   - catch(e){core_handleFailure(e,o.responseText);}
72   - },
73   - failure:core_handleFailure,
74   - argument: { foo:"foo", bar:"bar" }
  85 + success:function(o){
  86 + try{
  87 + i3GEOadmin.conexao.editor(YAHOO.lang.JSON.parse(o.responseText),$clicouId,$recordid);
  88 + }
  89 + catch(e){core_handleFailure(e,o.responseText);}
  90 + },
  91 + failure:core_handleFailure,
  92 + argument: { foo:"foo", bar:"bar" }
75 93 };
76 94 core_makeRequest(sUrl,callback);
77 95 }
  96 + });
  97 + };
  98 + core_carregando("desativa");
  99 + },
  100 + editor: function(dados,id,recordid){
  101 + function on_editorCheckBoxChange(p_oEvent){
  102 + if(p_oEvent.newValue.get("value") == "OK"){
  103 + i3GEOadmin.conexao.salva(id,recordid);
78 104 }
79   - );
80   - };
81   - core_carregando("desativa");
82   -}
83   -function montaEditor(dados,id,recordid){
84   - function on_editorCheckBoxChange(p_oEvent){
85   - if(p_oEvent.newValue.get("value") == "OK"){
86   - gravaDados(id,recordid);
87   - }
88   - YAHOO.admin.container.panelEditor2.destroy();
89   - YAHOO.admin.container.panelEditor2 = null;
90   - };
91   - if(!$i("janela_editor2")){
92   - var ins,editorBotoes,
93   - novoel = document.createElement("div");
94   -
95   - novoel.id = "janela_editor2";
96   - ins = '<div class="hd">Editor</div>';
97   - ins += "<div class='bd' style='height:354px;overflow:auto'>";
98   - ins += "<div id='okcancel_checkbox2'></div><div id='editor_bd2'></div>";
99   - novoel.innerHTML = ins;
100   - document.body.appendChild(novoel);
101   - editorBotoes = new YAHOO.widget.ButtonGroup({id:"okcancel_checkbox_id2", name: "okcancel_checkbox_id2", container: "okcancel_checkbox2" });
102   - editorBotoes.addButtons([
103   - { label: "Salva", value: "OK", checked: false},
104   - { label: "Cancela", value: "CANCEL", checked: false }
105   - ]);
106   - editorBotoes.on("checkedButtonChange", on_editorCheckBoxChange);
107   - YAHOO.admin.container.panelEditor2 = new YAHOO.widget.Panel("janela_editor2", { fixedcenter:true,close:false,width:"400px", height:"380px",overflow:"auto", visible:false,constraintoviewport:true } );
108   - YAHOO.admin.container.panelEditor2.render();
109   - }
110   - YAHOO.admin.container.panelEditor2.show();
111   - $i("editor_bd2").innerHTML = montaDiv(dados);
112   - core_carregando("desativa");
113   -}
114   -function montaDiv(i){
115   - var param = {
116   - "linhas":[
117   - {titulo:"Banco de dados:",id:"Ebancodedados",size:"50",value:i.bancodedados,tipo:"text",div:""},
118   - {titulo:"Servidor:",id:"Ehost",size:"50",value:i.host,tipo:"text",div:""},
119   - {titulo:"Porta:",id:"Eporta",size:"50",value:i.porta,tipo:"text",div:""},
120   - {titulo:"Usu&aacute;rio:",id:"Eusuario",size:"50",value:i.usuario,tipo:"text",div:""}
121   - ]
122   - },
123   - ins = "";
124   -
125   - ins += core_geraLinhas(param);
126   - return(ins);
127   -}
  105 + YAHOO.conexao.panelEditor2.destroy();
  106 + YAHOO.conexao.panelEditor2 = null;
  107 + };
  108 + if(!$i("janela_editor2")){
  109 + var editorBotoes,ins,
  110 + novoel = document.createElement("div");
  111 + novoel.id = "janela_editor2";
  112 + ins = '<div class="hd">Editor</div>';
  113 + ins += "<div class='bd' style='height:354px;overflow:auto'>";
  114 + ins += "<div id='okcancel_checkbox2'></div><div id='editor_bd2'></div>";
  115 + novoel.innerHTML = ins;
128 116  
129   -function gravaDados(id,recordid){
130   - var campos = new Array("bancodedados","host","porta","usuario"),
131   - par = "",
132   - i = 0,
133   - sUrl,callback;
  117 + document.body.appendChild(novoel);
  118 + editorBotoes = new YAHOO.widget.ButtonGroup({id:"okcancel_checkbox_id2", name: "okcancel_checkbox_id2", container: "okcancel_checkbox2" });
  119 + editorBotoes.addButtons([
  120 + { label: "Salva", value: "OK", checked: false},
  121 + { label: "Cancela", value: "CANCEL", checked: false }
  122 + ]);
  123 + editorBotoes.on("checkedButtonChange", on_editorCheckBoxChange);
  124 + YAHOO.conexao.panelEditor2 = new YAHOO.widget.Panel("janela_editor2", { modal:true,fixedcenter:true,close:false,width:"400px", height:"360px",overflow:"auto", visible:false,constraintoviewport:true } );
  125 + YAHOO.conexao.panelEditor2.render();
  126 + }
  127 + YAHOO.conexao.panelEditor2.show();
  128 + $i("editor_bd2").innerHTML = i3GEOadmin.conexao.formulario(dados);
  129 + core_carregando("desativa");
  130 + },
  131 + formulario: function(i){
  132 + var param = {
  133 + "linhas":[
  134 + {titulo:"Banco de dados:",id:"Ebancodedados",size:"50",value:i.bancodedados,tipo:"text",div:""},
  135 + {titulo:"Servidor:",id:"Ehost",size:"50",value:i.host,tipo:"text",div:""},
  136 + {titulo:"Porta:",id:"Eporta",size:"50",value:i.porta,tipo:"text",div:""},
  137 + {titulo:"Usu&aacute;rio:",id:"Eusuario",size:"50",value:i.usuario,tipo:"text",div:""}
  138 + ]
  139 + },
  140 + ins = "";
134 141  
135   - for (i=0;i<campos.length;i++){
136   - par += "&"+campos[i]+"="+($i("E"+campos[i]).value);
137   - }
138   - par += "&codigo_estat_conexao="+id;
139   - core_carregando("ativa");
140   - core_carregando(" gravando o registro do id= "+id);
141   - sUrl = "../php/metaestat.php?funcao=alterarConexao"+par;
142   - callback = {
143   - success:function(o){
144   - try {
145   - if(YAHOO.lang.JSON.parse(o.responseText) == "erro") {
146   - core_carregando("<span style=color:red >N&atilde;o foi poss&iacute;vel excluir. Verifique se n&atilde;o existem registros vinculados</span>");
147   - setTimeout("core_carregando('desativa')",3000);
148   - }
149   - else{
150   - var rec = myDataTable.getRecordSet().getRecord(recordid);
151   - myDataTable.updateRow(rec,YAHOO.lang.JSON.parse(o.responseText));
152   - core_carregando("desativa");
153   - }
  142 + ins += core_geraLinhas(param);
  143 + return(ins);
  144 + },
  145 + filtra: function(letra){
  146 + var i,temp,
  147 + n = i3GEOadmin.conexao.dados.length,
  148 + novo = [];
  149 + if(letra == "Todos"){
  150 + novo = i3GEOadmin.conexao.dados;
  151 + }
  152 + else{
  153 + for(i=0;i<n;i++){
  154 + temp = i3GEOadmin.conexao.dados[i].bancodedados;
  155 + if(temp.charAt(0).toUpperCase() == letra.toUpperCase()){
  156 + novo.push(i3GEOadmin.conexao.dados[i]);
154 157 }
155   - catch(e){core_handleFailure(e,o.responseText);}
156   - },
157   - failure:core_handleFailure,
158   - argument: { foo:"foo", bar:"bar" }
159   - };
160   - core_makeRequest(sUrl,callback);
161   -}
162   -function excluiLinha(id,row){
163   - var mensagem = " excluindo o registro do id= "+id,
164   - sUrl = "../php/metaestat.php?funcao=excluirConexao&codigo_estat_conexao="+id;
165   - core_excluiLinha(sUrl,row,mensagem);
166   -}
167   -//YAHOO.util.Event.addListener(window, "load", initMenu);
168 158 \ No newline at end of file
  159 + }
  160 + }
  161 + i3GEOadmin.conexao.tabela(novo);
  162 + },
  163 + exclui: function(id,row){
  164 + var mensagem = " excluindo o registro do id= "+id,
  165 + sUrl = "../php/metaestat.php?funcao=excluirConexao&codigo_estat_conexao="+id;
  166 + core_excluiLinha(sUrl,row,mensagem,"",i3GEOadmin.conexao.dataTable);
  167 + },
  168 + salva: function(id,recordid){
  169 + var i,c,sUrl, callback,
  170 + campos = i3GEOadmin.conexao.colunas,
  171 + par = "",
  172 + n = campos.length;
  173 + for (i=0;i<n;i++){
  174 + c = $i("E"+campos[i].key);
  175 + if(c){
  176 + par += "&"+campos[i].key+"="+(c.value);
  177 + }
  178 + }
  179 + par += "&codigo_estat_conexao="+id;
  180 + core_carregando("ativa");
  181 + core_carregando(" gravando o registro do id= "+id);
  182 + sUrl = "../php/metaestat.php?funcao=alterarConexao"+par;
  183 + callback = {
  184 + success:function(o){
  185 + try {
  186 + if(YAHOO.lang.JSON.parse(o.responseText) == "erro") {
  187 + core_carregando("<span style=color:red >N&atilde;o foi poss&iacute;vel excluir. Verifique se n&atilde;o existem registros vinculados</span>");
  188 + setTimeout("core_carregando('desativa')",3000);
  189 + }
  190 + else{
  191 + var rec = i3GEOadmin.conexao.dataTable.getRecordSet().getRecord(recordid);
  192 + i3GEOadmin.conexao.dataTable.updateRow(rec,YAHOO.lang.JSON.parse(o.responseText));
  193 + core_carregando("desativa");
  194 + }
  195 + }
  196 + catch(e){core_handleFailure(e,o.responseText);}
  197 + },
  198 + failure:core_handleFailure,
  199 + argument: { foo:"foo", bar:"bar" }
  200 + };
  201 + core_makeRequest(sUrl,callback);
  202 + }
  203 +};
169 204 \ No newline at end of file
... ...
admin/js/estat_fonteinfo.js
1   -function initEditor(){
2   - YAHOO.namespace("admin.container");
3   - core_ativaBotaoAdicionaLinha("../php/metaestat.php?funcao=alterarFonteinfo","adicionaNovaLinha","pegaDados");
4   - pegaDados();
  1 +if(typeof(i3GEOadmin) === 'undefined'){
  2 + var i3GEOadmin = {};
5 3 }
6   -function pegaDados(){
7   - core_carregando("ativa");
8   - core_pegaDados("buscando dados...","../php/metaestat.php?funcao=listaFonteinfo","montaTabela");
9   -}
10   -function montaTabela(dados){
11   - YAHOO.example.InlineCellEditing = new function() {
12   - // Custom formatter for "address" column to preserve line breaks
13   - var formatTexto = function(elCell, oRecord, oColumn, oData){
14   - if(oData === ""){
15   - oData = "<span style='color:gray' ></span>";
16   - }
17   - elCell.innerHTML = "<pre ><p>" + oData + "</pre>";
18   - },
19   - formatExclui = function(elCell, oRecord, oColumn){
20   - elCell.innerHTML = "<div class=excluir title='exclui' style='text-align:center' ></div>";
21   - },
22   - formatMais = function(elCell, oRecord, oColumn){
23   - elCell.innerHTML = "<div class=editar style='text-align:center' ></div>";
24   - },
25   - myColumnDefs = [
26   - {key:"excluir",label:"excluir",formatter:formatExclui},
27   - {key:"mais",label:"editar",formatter:formatMais},
28   - {label:"Id",resizeable:true,key:"id_fonteinfo", formatter:formatTexto,editor:new YAHOO.widget.TextboxCellEditor({disableBtns:true})},
29   - {label:"T&iacute;tulo",resizeable:true,key:"titulo", formatter:formatTexto,editor:new YAHOO.widget.TextboxCellEditor({disableBtns:true})},
30   - {label:"Link",resizeable:true,key:"link", formatter:formatTexto,editor:new YAHOO.widget.TextboxCellEditor({disableBtns:true})}
31   - ];
32   - myDataSource = new YAHOO.util.DataSource(dados);
33   - myDataTable = new YAHOO.widget.DataTable("tabela", myColumnDefs, myDataSource);
34   -
35   - myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
36   - myDataSource.responseSchema = {
37   - fields: ["id_fonteinfo","titulo","link"]
38   - };
39   - myDataTable.subscribe(
40   - 'cellClickEvent',
41   - function(ev){
42   - var record,$clicouId,$recordid,sUrl,callback,
43   - target = YAHOO.util.Event.getTarget(ev),
44   - column = this.getColumn(target);
45   - if(YAHOO.admin.container.panelCK){
46   - YAHOO.admin.container.panelCK.destroy();
47   - YAHOO.admin.container.panelCK = null;
  4 +i3GEOadmin.fonteinfo = {
  5 + dados: "",
  6 + dataTable: null,
  7 + colunas: ["id_fonteinfo","titulo","link"],
  8 + formatTexto: function(elCell, oRecord, oColumn, oData){
  9 + if(oData === ""){
  10 + oData = "<span style='color:gray' ></span>";
  11 + }
  12 + elCell.innerHTML = "<pre ><p style=cursor:default >" + oData + "</pre>";
  13 + },
  14 + formatExclui: function(elCell, oRecord, oColumn){
  15 + elCell.innerHTML = "<div title='exclui' class=excluir style='text-align:center' ></div>";
  16 + },
  17 + formatMais: function(elCell, oRecord, oColumn){
  18 + elCell.innerHTML = "<div class=editar style='text-align:center' ></div>";
  19 + },
  20 + defColunas: function(){
  21 + return [
  22 + {key:"excluir",label:"excluir",formatter:i3GEOadmin.fonteinfo.formatExclui},
  23 + {key:"mais",label:"editar",formatter:i3GEOadmin.fonteinfo.formatMais},
  24 + {label:"Id",resizeable:true,key:"id_fonteinfo", formatter:i3GEOadmin.fonteinfo.formatTexto},
  25 + {label:"T&iacute;tulo",resizeable:true,key:"titulo", formatter:i3GEOadmin.fonteinfo.formatTexto},
  26 + {label:"Link",resizeable:true,key:"link", formatter:i3GEOadmin.fonteinfo.formatTexto}
  27 + ];
  28 + },
  29 + /*
  30 + * Inicializa o menu
  31 + */
  32 + inicia: function(){
  33 + YAHOO.namespace("fonteinfo");
  34 + YAHOO.namespace("admin.container");
  35 + core_ativaPainelAjuda("ajuda","botaoAjuda");
  36 + core_ativaBotaoAdicionaLinha("../php/metaestat.php?funcao=alterarFonteinfo","adicionaNovaLinha","i3GEOadmin.fonteinfo.obtem");
  37 + i3GEOadmin.fonteinfo.obtem();
  38 + },
  39 + /*
  40 + * Obt&eacute;m a lista de menus
  41 + */
  42 + obtem: function(){
  43 + i3GEOadmin.fonteinfo.dados = "";
  44 + core_carregando("ativa");
  45 + core_pegaDados("buscando endere&ccedil;os...","../php/metaestat.php?funcao=listaFonteinfo","i3GEOadmin.fonteinfo.tabela");
  46 + },
  47 + tabela: function(dados){
  48 + if(i3GEOadmin.fonteinfo.dados == ""){
  49 + i3GEOadmin.fonteinfo.dados = dados;
  50 + }
  51 + core_listaDeLetras("letras","i3GEOadmin.fonteinfo.filtra");
  52 + YAHOO.example.InlineCellEditing = new function(){
  53 + // Custom formatter for "address" column to preserve line breaks
  54 + var myDataSource = new YAHOO.util.DataSource(dados);
  55 + myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
  56 + myDataSource.responseSchema = {
  57 + fields: i3GEOadmin.fonteinfo.colunas
  58 + };
  59 + i3GEOadmin.fonteinfo.dataTable = new YAHOO.widget.DataTable("tabela", i3GEOadmin.fonteinfo.defColunas(), myDataSource);
  60 + i3GEOadmin.fonteinfo.dataTable.subscribe('cellClickEvent',function(ev){
  61 + var sUrl, callback,$clicouId, $recordid,
  62 + target = YAHOO.util.Event.getTarget(ev),
  63 + column = this.getColumn(target),
  64 + registro = this.getRecord(target);
  65 + if(YAHOO.fonteinfo.panelCK) {
  66 + YAHOO.fonteinfo.panelCK.destroy();
  67 + YAHOO.fonteinfo.panelCK = null;
48 68 }
49 69 if (column.key == 'excluir'){
50   - record = this.getRecord(target);
51   - excluiLinha(record.getData('id_fonteinfo'),target);
  70 + i3GEOadmin.fonteinfo.exclui(registro.getData('id_fonteinfo'),target);
52 71 }
53 72 if (column.key == 'mais'){
54   - record = this.getRecord(target);
55 73 core_carregando("ativa");
56 74 core_carregando("buscando dados...");
57   - $clicouId = record.getData('id_fonteinfo');
58   - $recordid = record.getId();
59   - sUrl = "../php/metaestat.php?funcao=listaFonteinfo&id_fonteinfo="+record.getData('id_fonteinfo');
  75 + $clicouId = registro.getData('id_fonteinfo');
  76 + $recordid = registro.getId();
  77 + sUrl = "../php/metaestat.php?funcao=listaFonteinfo&id_fonteinfo="+$clicouId;
60 78 callback = {
61   - success:function(o){
62   - try{
63   - montaEditor(YAHOO.lang.JSON.parse(o.responseText),$clicouId,$recordid);
64   - }
65   - catch(e){core_handleFailure(e,o.responseText);}
66   - },
67   - failure:core_handleFailure,
68   - argument: { foo:"foo", bar:"bar" }
  79 + success:function(o){
  80 + try{
  81 + i3GEOadmin.fonteinfo.editor(YAHOO.lang.JSON.parse(o.responseText),$clicouId,$recordid);
  82 + }
  83 + catch(e){core_handleFailure(e,o.responseText);}
  84 + },
  85 + failure:core_handleFailure,
  86 + argument: { foo:"foo", bar:"bar" }
69 87 };
70 88 core_makeRequest(sUrl,callback);
71 89 }
  90 + });
  91 + };
  92 + core_carregando("desativa");
  93 + },
  94 + editor: function(dados,id,recordid){
  95 + function on_editorCheckBoxChange(p_oEvent){
  96 + if(p_oEvent.newValue.get("value") == "OK"){
  97 + i3GEOadmin.fonteinfo.salva(id,recordid);
72 98 }
73   - );
74   - };
75   - core_carregando("desativa");
76   -}
77   -function montaEditor(dados,id,recordid){
78   - function on_editorCheckBoxChange(p_oEvent){
79   - if(p_oEvent.newValue.get("value") == "OK"){
80   - gravaDados(id,recordid);
81   - }
82   - YAHOO.admin.container.panelEditor2.destroy();
83   - YAHOO.admin.container.panelEditor2 = null;
84   - };
85   - if(!$i("janela_editor2")){
86   - var ins,editorBotoes,
87   - novoel = document.createElement("div");
88   -
89   - novoel.id = "janela_editor2";
90   - ins = '<div class="hd">Editor</div>';
91   - ins += "<div class='bd' style='height:354px;overflow:auto'>";
92   - ins += "<div id='okcancel_checkbox2'></div><div id='editor_bd2'></div>";
93   - novoel.innerHTML = ins;
94   - document.body.appendChild(novoel);
95   - editorBotoes = new YAHOO.widget.ButtonGroup({id:"okcancel_checkbox_id2", name: "okcancel_checkbox_id2", container: "okcancel_checkbox2" });
96   - editorBotoes.addButtons([
97   - { label: "Salva", value: "OK", checked: false},
98   - { label: "Cancela", value: "CANCEL", checked: false }
99   - ]);
100   - editorBotoes.on("checkedButtonChange", on_editorCheckBoxChange);
101   - YAHOO.admin.container.panelEditor2 = new YAHOO.widget.Panel("janela_editor2", { fixedcenter:true,close:false,width:"400px", height:"380px",overflow:"auto", visible:false,constraintoviewport:true } );
102   - YAHOO.admin.container.panelEditor2.render();
103   - }
104   - YAHOO.admin.container.panelEditor2.show();
105   - $i("editor_bd2").innerHTML = montaDiv(dados);
106   - core_carregando("desativa");
107   -}
108   -function montaDiv(i){
109   - var param = {
110   - "linhas":[{
111   - titulo:"T&iacute;tulo:",id:"Etitulo",size:"50",value:i.titulo,tipo:"text",div:""
112   - },{
113   - titulo:"Link:",id:"Elink",size:"50",value:i.link,tipo:"text",div:""
114   - }]
115   - },
116   - ins = "";
  99 + YAHOO.fonteinfo.panelEditor2.destroy();
  100 + YAHOO.fonteinfo.panelEditor2 = null;
  101 + };
  102 + if(!$i("janela_editor2")){
  103 + var editorBotoes,ins,
  104 + novoel = document.createElement("div");
  105 + novoel.id = "janela_editor2";
  106 + ins = '<div class="hd">Editor</div>';
  107 + ins += "<div class='bd' style='height:354px;overflow:auto'>";
  108 + ins += "<div id='okcancel_checkbox2'></div><div id='editor_bd2'></div>";
  109 + novoel.innerHTML = ins;
117 110  
118   - ins += core_geraLinhas(param);
119   - return(ins);
120   -}
121   -function gravaDados(id,recordid){
122   - var campos = new Array("titulo","link"),
123   - par = "",
124   - i = 0,
125   - sUrl,callback;
  111 + document.body.appendChild(novoel);
  112 + editorBotoes = new YAHOO.widget.ButtonGroup({id:"okcancel_checkbox_id2", name: "okcancel_checkbox_id2", container: "okcancel_checkbox2" });
  113 + editorBotoes.addButtons([
  114 + { label: "Salva", value: "OK", checked: false},
  115 + { label: "Cancela", value: "CANCEL", checked: false }
  116 + ]);
  117 + editorBotoes.on("checkedButtonChange", on_editorCheckBoxChange);
  118 + YAHOO.fonteinfo.panelEditor2 = new YAHOO.widget.Panel("janela_editor2", { modal:true,fixedcenter:true,close:false,width:"400px", height:"360px",overflow:"auto", visible:false,constraintoviewport:true } );
  119 + YAHOO.fonteinfo.panelEditor2.render();
  120 + }
  121 + YAHOO.fonteinfo.panelEditor2.show();
  122 + $i("editor_bd2").innerHTML = i3GEOadmin.fonteinfo.formulario(dados);
  123 + core_carregando("desativa");
  124 + },
  125 + formulario: function(i){
  126 + var param = {
  127 + "linhas":[{
  128 + titulo:"T&iacute;tulo:",id:"Etitulo",size:"50",value:i.titulo,tipo:"text",div:""
  129 + },{
  130 + titulo:"Link:",id:"Elink",size:"50",value:i.link,tipo:"text",div:""
  131 + }]
  132 + },
  133 + ins = "";
126 134  
127   - for (i=0;i<campos.length;i++){
128   - par += "&"+campos[i]+"="+($i("E"+campos[i]).value);
129   - }
130   - par += "&id_fonteinfo="+id;
131   - core_carregando("ativa");
132   - core_carregando(" gravando o registro do id= "+id);
133   - sUrl = "../php/metaestat.php?funcao=alterarFonteinfo"+par;
134   - callback = {
135   - success:function(o){
136   - try {
137   - if(YAHOO.lang.JSON.parse(o.responseText) == "erro") {
138   - core_carregando("<span style=color:red >N&atilde;o foi poss&iacute;vel excluir. Verifique se n&atilde;o existem registros vinculados</span>");
139   - setTimeout("core_carregando('desativa')",3000);
140   - }
141   - else{
142   - var rec = myDataTable.getRecordSet().getRecord(recordid);
143   - myDataTable.updateRow(rec,YAHOO.lang.JSON.parse(o.responseText));
144   - core_carregando("desativa");
145   - }
  135 + ins += core_geraLinhas(param);
  136 + return(ins);
  137 + },
  138 + filtra: function(letra){
  139 + var i,temp,
  140 + n = i3GEOadmin.fonteinfo.dados.length,
  141 + novo = [];
  142 + if(letra == "Todos"){
  143 + novo = i3GEOadmin.fonteinfo.dados;
  144 + }
  145 + else{
  146 + for(i=0;i<n;i++){
  147 + temp = i3GEOadmin.fonteinfo.dados[i].titulo;
  148 + if(temp.charAt(0).toUpperCase() == letra.toUpperCase()){
  149 + novo.push(i3GEOadmin.fonteinfo.dados[i]);
146 150 }
147   - catch(e){core_handleFailure(e,o.responseText);}
148   - },
149   - failure:core_handleFailure,
150   - argument: { foo:"foo", bar:"bar" }
151   - };
152   - core_makeRequest(sUrl,callback);
153   -}
154   -function excluiLinha(id,row){
155   - var mensagem = " excluindo o registro do id= "+id,
156   - sUrl = "../php/metaestat.php?funcao=excluirFonteinfo&id_fonteinfo="+id;
157   - core_excluiLinha(sUrl,row,mensagem);
158   -}
159   -//YAHOO.util.Event.addListener(window, "load", initMenu);
160 151 \ No newline at end of file
  152 + }
  153 + }
  154 + i3GEOadmin.fonteinfo.tabela(novo);
  155 + },
  156 + exclui: function(id,row){
  157 + var mensagem = " excluindo o registro do id= "+id,
  158 + sUrl = "../php/metaestat.php?funcao=excluirFonteinfo&id_fonteinfo="+id;
  159 + core_excluiLinha(sUrl,row,mensagem,"",i3GEOadmin.fonteinfo.dataTable);
  160 + },
  161 + salva: function(id,recordid){
  162 + var i,c,sUrl, callback,
  163 + campos = i3GEOadmin.fonteinfo.colunas,
  164 + par = "",
  165 + n = campos.length;
  166 + for (i=0;i<n;i++){
  167 + c = $i("E"+campos[i].key);
  168 + if(c){
  169 + par += "&"+campos[i].key+"="+(c.value);
  170 + }
  171 + }
  172 + par += "&id_fonteinfo="+id;
  173 + core_carregando("ativa");
  174 + core_carregando(" gravando o registro do id= "+id);
  175 + sUrl = "../php/metaestat.php?funcao=alterarFonteinfo"+par;
  176 + callback = {
  177 + success:function(o){
  178 + try {
  179 + if(YAHOO.lang.JSON.parse(o.responseText) == "erro") {
  180 + core_carregando("<span style=color:red >N&atilde;o foi poss&iacute;vel excluir. Verifique se n&atilde;o existem registros vinculados</span>");
  181 + setTimeout("core_carregando('desativa')",3000);
  182 + }
  183 + else{
  184 + var rec = i3GEOadmin.fonteinfo.dataTable.getRecordSet().getRecord(recordid);
  185 + i3GEOadmin.fonteinfo.dataTable.updateRow(rec,YAHOO.lang.JSON.parse(o.responseText));
  186 + core_carregando("desativa");
  187 + }
  188 + }
  189 + catch(e){core_handleFailure(e,o.responseText);}
  190 + },
  191 + failure:core_handleFailure,
  192 + argument: { foo:"foo", bar:"bar" }
  193 + };
  194 + core_makeRequest(sUrl,callback);
  195 + }
  196 +};
161 197 \ No newline at end of file
... ...
admin/js/estat_tipo_periodo.js
1   -function initEditor(){
2   - YAHOO.namespace("admin.container");
3   - core_ativaBotaoAdicionaLinha("../php/metaestat.php?funcao=alterarTipoPeriodo","adicionaNovaLinha","pegaDados");
4   - pegaDados();
  1 +if(typeof(i3GEOadmin) === 'undefined'){
  2 + var i3GEOadmin = {};
5 3 }
6   -function pegaDados(){
7   - core_carregando("ativa");
8   - core_pegaDados("buscando dados...","../php/metaestat.php?funcao=listaTipoPeriodo","montaTabela");
9   -}
10   -function montaTabela(dados){
11   - YAHOO.example.InlineCellEditing = new function() {
12   - // Custom formatter for "address" column to preserve line breaks
13   - var formatTexto = function(elCell, oRecord, oColumn, oData){
14   - if(oData === ""){
15   - oData = "<span style='color:gray' ></span>";
16   - }
17   - elCell.innerHTML = "<pre ><p>" + oData + "</pre>";
18   - },
19   - formatExclui = function(elCell, oRecord, oColumn){
20   - elCell.innerHTML = "<div class=excluir title='exclui' style='text-align:center' ></div>";
21   - },
22   - formatMais = function(elCell, oRecord, oColumn){
23   - elCell.innerHTML = "<div class=editar style='text-align:center' ></div>";
24   - },
25   - myColumnDefs = [
26   - {key:"excluir",label:"excluir",formatter:formatExclui},
27   - {key:"mais",label:"editar",formatter:formatMais},
28   - {label:"c&oacute;digo",key:"codigo_tipo_periodo", formatter:formatTexto},
29   - {label:"Nome",resizeable:true,key:"nome", formatter:formatTexto,editor:new YAHOO.widget.TextboxCellEditor({disableBtns:true})},
30   - {label:"Descricao",resizeable:true,key:"descricao", formatter:formatTexto,editor:new YAHOO.widget.TextboxCellEditor({disableBtns:true})}
31   - ];
32   - myDataSource = new YAHOO.util.DataSource(dados);
33   - myDataTable = new YAHOO.widget.DataTable("tabela", myColumnDefs, myDataSource);
34   -
35   - myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
36   - myDataSource.responseSchema = {
37   - fields: ["codigo_tipo_periodo","nome","descricao"]
38   - };
39   - myDataTable.subscribe(
40   - 'cellClickEvent',
41   - function(ev){
42   - var record,$clicouId,$recordid,sUrl,callback,
43   - target = YAHOO.util.Event.getTarget(ev),
44   - column = this.getColumn(target);
45   - if(YAHOO.admin.container.panelCK){
46   - YAHOO.admin.container.panelCK.destroy();
47   - YAHOO.admin.container.panelCK = null;
  4 +i3GEOadmin.periodo = {
  5 + dados: "",
  6 + dataTable: null,
  7 + colunas: ["codigo_tipo_periodo","nome","descricao"],
  8 + formatTexto: function(elCell, oRecord, oColumn, oData){
  9 + if(oData === ""){
  10 + oData = "<span style='color:gray' ></span>";
  11 + }
  12 + elCell.innerHTML = "<pre ><p style=cursor:default >" + oData + "</pre>";
  13 + },
  14 + formatExclui: function(elCell, oRecord, oColumn){
  15 + elCell.innerHTML = "<div title='exclui' class=excluir style='text-align:center' ></div>";
  16 + },
  17 + formatMais: function(elCell, oRecord, oColumn){
  18 + elCell.innerHTML = "<div class=editar style='text-align:center' ></div>";
  19 + },
  20 + defColunas: function(){
  21 + return [
  22 + {key:"excluir",label:"excluir",formatter:i3GEOadmin.periodo.formatExclui},
  23 + {key:"mais",label:"editar",formatter:i3GEOadmin.periodo.formatMais},
  24 + {label:"c&oacute;digo",key:"codigo_tipo_periodo", formatter:i3GEOadmin.periodo.formatTexto},
  25 + {label:"Nome",resizeable:true,key:"nome", formatter:i3GEOadmin.periodo.formatTexto},
  26 + {label:"Descricao",resizeable:true,key:"descricao", formatter:i3GEOadmin.periodo.formatTexto}
  27 + ];
  28 + },
  29 + /*
  30 + * Inicializa o menu
  31 + */
  32 + inicia: function(){
  33 + YAHOO.namespace("periodo");
  34 + YAHOO.namespace("admin.container");
  35 + core_ativaPainelAjuda("ajuda","botaoAjuda");
  36 + core_ativaBotaoAdicionaLinha("../php/metaestat.php?funcao=alterarTipoPeriodo","adicionaNovaLinha","i3GEOadmin.periodo.obtem");
  37 + i3GEOadmin.periodo.obtem();
  38 + },
  39 + /*
  40 + * Obt&eacute;m a lista de menus
  41 + */
  42 + obtem: function(){
  43 + i3GEOadmin.periodo.dados = "";
  44 + core_carregando("ativa");
  45 + core_pegaDados("buscando endere&ccedil;os...","../php/metaestat.php?funcao=listaTipoPeriodo","i3GEOadmin.periodo.tabela");
  46 + },
  47 + tabela: function(dados){
  48 + if(i3GEOadmin.periodo.dados == ""){
  49 + i3GEOadmin.periodo.dados = dados;
  50 + }
  51 + core_listaDeLetras("letras","i3GEOadmin.periodo.filtra");
  52 + YAHOO.example.InlineCellEditing = new function(){
  53 + // Custom formatter for "address" column to preserve line breaks
  54 + var myDataSource = new YAHOO.util.DataSource(dados);
  55 + myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
  56 + myDataSource.responseSchema = {
  57 + fields: i3GEOadmin.periodo.colunas
  58 + };
  59 + i3GEOadmin.periodo.dataTable = new YAHOO.widget.DataTable("tabela", i3GEOadmin.periodo.defColunas(), myDataSource);
  60 + i3GEOadmin.periodo.dataTable.subscribe('cellClickEvent',function(ev){
  61 + var sUrl, callback,$clicouId, $recordid,
  62 + target = YAHOO.util.Event.getTarget(ev),
  63 + column = this.getColumn(target),
  64 + registro = this.getRecord(target);
  65 + if(YAHOO.periodo.panelCK) {
  66 + YAHOO.periodo.panelCK.destroy();
  67 + YAHOO.periodo.panelCK = null;
48 68 }
49 69 if (column.key == 'excluir'){
50   - record = this.getRecord(target);
51   - excluiLinha(record.getData('codigo_tipo_periodo'),target);
  70 + i3GEOadmin.periodo.exclui(registro.getData('codigo_tipo_periodo'),target);
52 71 }
53 72 if (column.key == 'mais'){
54   - record = this.getRecord(target);
55 73 core_carregando("ativa");
56 74 core_carregando("buscando dados...");
57   - $clicouId = record.getData('codigo_tipo_periodo');
58   - $recordid = record.getId();
59   - sUrl = "../php/metaestat.php?funcao=listaTipoPeriodo&codigo_tipo_periodo="+record.getData('codigo_tipo_periodo');
  75 + $clicouId = registro.getData('codigo_tipo_periodo');
  76 + $recordid = registro.getId();
  77 + sUrl = "../php/metaestat.php?funcao=listaTipoPeriodo&codigo_tipo_periodo="+$clicouId;
60 78 callback = {
61   - success:function(o){
62   - try{
63   - montaEditor(YAHOO.lang.JSON.parse(o.responseText),$clicouId,$recordid);
64   - }
65   - catch(e){core_handleFailure(e,o.responseText);}
66   - },
67   - failure:core_handleFailure,
68   - argument: { foo:"foo", bar:"bar" }
  79 + success:function(o){
  80 + try{
  81 + i3GEOadmin.periodo.editor(YAHOO.lang.JSON.parse(o.responseText),$clicouId,$recordid);
  82 + }
  83 + catch(e){core_handleFailure(e,o.responseText);}
  84 + },
  85 + failure:core_handleFailure,
  86 + argument: { foo:"foo", bar:"bar" }
69 87 };
70 88 core_makeRequest(sUrl,callback);
71 89 }
  90 + });
  91 + };
  92 + core_carregando("desativa");
  93 + },
  94 + editor: function(dados,id,recordid){
  95 + function on_editorCheckBoxChange(p_oEvent){
  96 + if(p_oEvent.newValue.get("value") == "OK"){
  97 + i3GEOadmin.periodo.salva(id,recordid);
72 98 }
73   - );
74   - };
75   - core_carregando("desativa");
76   -}
77   -function montaEditor(dados,id,recordid){
78   - function on_editorCheckBoxChange(p_oEvent){
79   - if(p_oEvent.newValue.get("value") == "OK"){
80   - gravaDados(id,recordid);
81   - }
82   - YAHOO.admin.container.panelEditor2.destroy();
83   - YAHOO.admin.container.panelEditor2 = null;
84   - };
85   - if(!$i("janela_editor2")){
86   - var ins,editorBotoes,
87   - novoel = document.createElement("div");
88   -
89   - novoel.id = "janela_editor2";
90   - ins = '<div class="hd">Editor</div>';
91   - ins += "<div class='bd' style='height:354px;overflow:auto'>";
92   - ins += "<div id='okcancel_checkbox2'></div><div id='editor_bd2'></div>";
93   - novoel.innerHTML = ins;
94   - document.body.appendChild(novoel);
95   - editorBotoes = new YAHOO.widget.ButtonGroup({id:"okcancel_checkbox_id2", name: "okcancel_checkbox_id2", container: "okcancel_checkbox2" });
96   - editorBotoes.addButtons([
97   - { label: "Salva", value: "OK", checked: false},
98   - { label: "Cancela", value: "CANCEL", checked: false }
99   - ]);
100   - editorBotoes.on("checkedButtonChange", on_editorCheckBoxChange);
101   - YAHOO.admin.container.panelEditor2 = new YAHOO.widget.Panel("janela_editor2", { fixedcenter:true,close:false,width:"400px", height:"380px",overflow:"auto", visible:false,constraintoviewport:true } );
102   - YAHOO.admin.container.panelEditor2.render();
103   - }
104   - YAHOO.admin.container.panelEditor2.show();
105   - $i("editor_bd2").innerHTML = montaDiv(dados);
106   - core_carregando("desativa");
107   -}
108   -function montaDiv(i){
109   - var param = {
110   - "linhas":[{
111   - titulo:"Nome:",id:"Enome",size:"50",value:i.nome,tipo:"text",div:""
112   - },{
113   - titulo:"Descricao:",id:"Edescricao",size:"50",value:i.descricao,tipo:"text",div:""
114   - }]
115   - },
116   - ins = "";
117   -
118   - ins += core_geraLinhas(param);
119   - return(ins);
120   -}
  99 + YAHOO.periodo.panelEditor2.destroy();
  100 + YAHOO.periodo.panelEditor2 = null;
  101 + };
  102 + if(!$i("janela_editor2")){
  103 + var editorBotoes,ins,
  104 + novoel = document.createElement("div");
  105 + novoel.id = "janela_editor2";
  106 + ins = '<div class="hd">Editor</div>';
  107 + ins += "<div class='bd' style='height:354px;overflow:auto'>";
  108 + ins += "<div id='okcancel_checkbox2'></div><div id='editor_bd2'></div>";
  109 + novoel.innerHTML = ins;
121 110  
122   -function gravaDados(id,recordid){
123   - var campos = new Array("nome","descricao"),
124   - par = "",
125   - i = 0,
126   - sUrl,callback;
  111 + document.body.appendChild(novoel);
  112 + editorBotoes = new YAHOO.widget.ButtonGroup({id:"okcancel_checkbox_id2", name: "okcancel_checkbox_id2", container: "okcancel_checkbox2" });
  113 + editorBotoes.addButtons([
  114 + { label: "Salva", value: "OK", checked: false},
  115 + { label: "Cancela", value: "CANCEL", checked: false }
  116 + ]);
  117 + editorBotoes.on("checkedButtonChange", on_editorCheckBoxChange);
  118 + YAHOO.periodo.panelEditor2 = new YAHOO.widget.Panel("janela_editor2", { modal:true,fixedcenter:true,close:false,width:"400px", height:"360px",overflow:"auto", visible:false,constraintoviewport:true } );
  119 + YAHOO.periodo.panelEditor2.render();
  120 + }
  121 + YAHOO.periodo.panelEditor2.show();
  122 + $i("editor_bd2").innerHTML = i3GEOadmin.periodo.formulario(dados);
  123 + core_carregando("desativa");
  124 + },
  125 + formulario: function(i){
  126 + var param = {
  127 + "linhas":[{
  128 + titulo:"Nome:",id:"Enome",size:"50",value:i.nome,tipo:"text",div:""
  129 + },{
  130 + titulo:"Descricao:",id:"Edescricao",size:"50",value:i.descricao,tipo:"text",div:""
  131 + }]
  132 + },
  133 + ins = "";
127 134  
128   - for (i=0;i<campos.length;i++){
129   - par += "&"+campos[i]+"="+($i("E"+campos[i]).value);
130   - }
131   - par += "&codigo_tipo_periodo="+id;
132   - core_carregando("ativa");
133   - core_carregando(" gravando o registro do id= "+id);
134   - sUrl = "../php/metaestat.php?funcao=alterarTipoPeriodo"+par;
135   - callback = {
136   - success:function(o){
137   - try {
138   - if(YAHOO.lang.JSON.parse(o.responseText) == "erro") {
139   - core_carregando("<span style=color:red >N&atilde;o foi poss&iacute;vel excluir. Verifique se n&atilde;o existem registros vinculados</span>");
140   - setTimeout("core_carregando('desativa')",3000);
141   - }
142   - else{
143   - var rec = myDataTable.getRecordSet().getRecord(recordid);
144   - myDataTable.updateRow(rec,YAHOO.lang.JSON.parse(o.responseText));
145   - core_carregando("desativa");
146   - }
  135 + ins += core_geraLinhas(param);
  136 + return(ins);
  137 + },
  138 + filtra: function(letra){
  139 + var i,temp,
  140 + n = i3GEOadmin.periodo.dados.length,
  141 + novo = [];
  142 + if(letra == "Todos"){
  143 + novo = i3GEOadmin.periodo.dados;
  144 + }
  145 + else{
  146 + for(i=0;i<n;i++){
  147 + temp = i3GEOadmin.periodo.dados[i].nome;
  148 + if(temp.charAt(0).toUpperCase() == letra.toUpperCase()){
  149 + novo.push(i3GEOadmin.periodo.dados[i]);
147 150 }
148   - catch(e){core_handleFailure(e,o.responseText);}
149   - },
150   - failure:core_handleFailure,
151   - argument: { foo:"foo", bar:"bar" }
152   - };
153   - core_makeRequest(sUrl,callback);
154   -}
155   -function excluiLinha(id,row){
156   - var mensagem = " excluindo o registro do id= "+id,
157   - sUrl = "../php/metaestat.php?funcao=excluirTipoPeriodo&codigo_tipo_periodo="+id;
158   - core_excluiLinha(sUrl,row,mensagem);
159   -}
160   -//YAHOO.util.Event.addListener(window, "load", initMenu);
161 151 \ No newline at end of file
  152 + }
  153 + }
  154 + i3GEOadmin.periodo.tabela(novo);
  155 + },
  156 + exclui: function(id,row){
  157 + var mensagem = " excluindo o registro do id= "+id,
  158 + sUrl = "../php/metaestat.php?funcao=excluirTipoPeriodo&codigo_tipo_periodo="+id;
  159 + core_excluiLinha(sUrl,row,mensagem,"",i3GEOadmin.periodo.dataTable);
  160 + },
  161 + salva: function(id,recordid){
  162 + var i,c,sUrl, callback,
  163 + campos = i3GEOadmin.periodo.colunas,
  164 + par = "",
  165 + n = campos.length;
  166 + for (i=0;i<n;i++){
  167 + c = $i("E"+campos[i].key);
  168 + if(c){
  169 + par += "&"+campos[i].key+"="+(c.value);
  170 + }
  171 + }
  172 + par += "&codigo_tipo_periodo="+id;
  173 + core_carregando("ativa");
  174 + core_carregando(" gravando o registro do id= "+id);
  175 + sUrl = "../php/metaestat.php?funcao=alterarTipoPeriodo"+par;
  176 + callback = {
  177 + success:function(o){
  178 + try {
  179 + if(YAHOO.lang.JSON.parse(o.responseText) == "erro") {
  180 + core_carregando("<span style=color:red >N&atilde;o foi poss&iacute;vel excluir. Verifique se n&atilde;o existem registros vinculados</span>");
  181 + setTimeout("core_carregando('desativa')",3000);
  182 + }
  183 + else{
  184 + var rec = i3GEOadmin.periodo.dataTable.getRecordSet().getRecord(recordid);
  185 + i3GEOadmin.periodo.dataTable.updateRow(rec,YAHOO.lang.JSON.parse(o.responseText));
  186 + core_carregando("desativa");
  187 + }
  188 + }
  189 + catch(e){core_handleFailure(e,o.responseText);}
  190 + },
  191 + failure:core_handleFailure,
  192 + argument: { foo:"foo", bar:"bar" }
  193 + };
  194 + core_makeRequest(sUrl,callback);
  195 + }
  196 +};
162 197 \ No newline at end of file
... ...
admin/js/estat_unidade_medida.js
1   -function initEditor(){
2   - YAHOO.namespace("admin.container");
3   - core_ativaBotaoAdicionaLinha("../php/metaestat.php?funcao=alterarUnidadeMedida","adicionaNovaLinha","pegaDados");
4   - pegaDados();
  1 +if(typeof(i3GEOadmin) === 'undefined'){
  2 + var i3GEOadmin = {};
5 3 }
6   -function pegaDados(){
7   - core_carregando("ativa");
8   - core_pegaDados("buscando dados...","../php/metaestat.php?funcao=listaUnidadeMedida","montaTabela");
9   -}
10   -function montaTabela(dados){
11   - YAHOO.example.InlineCellEditing = new function() {
12   - // Custom formatter for "address" column to preserve line breaks
13   - var formatTexto = function(elCell, oRecord, oColumn, oData){
14   - if(oData === ""){
15   - oData = "<span style='color:gray' ></span>";
16   - }
17   - elCell.innerHTML = "<pre ><p>" + oData + "</pre>";
18   - },
19   - formatExclui = function(elCell, oRecord, oColumn){
20   - elCell.innerHTML = "<div class=excluir title='exclui' style='text-align:center' ></div>";
21   - },
22   - formatMais = function(elCell, oRecord, oColumn){
23   - elCell.innerHTML = "<div class=editar style='text-align:center' ></div>";
24   - },
25   - myColumnDefs = [
26   - {key:"excluir",label:"excluir",formatter:formatExclui},
27   - {key:"mais",label:"editar",formatter:formatMais},
28   - {label:"c&oacute;digo",key:"codigo_unidade_medida", formatter:formatTexto},
29   - {label:"Nome",resizeable:true,key:"nome", formatter:formatTexto,editor:new YAHOO.widget.TextboxCellEditor({disableBtns:true})},
30   - {label:"Sigla",resizeable:true,key:"sigla", formatter:formatTexto,editor:new YAHOO.widget.TextboxCellEditor({disableBtns:true})},
31   - {label:"Permite soma?",key:"permitesoma",editor:"radio" ,editorOptions:{radioOptions:["SIM","NAO"],disableBtns:false,LABEL_SAVE:"OK"}},
32   - {label:"Permite m&eacute;dia?",key:"permitemedia",editor:"radio" ,editorOptions:{radioOptions:["SIM","NAO"],disableBtns:false,LABEL_SAVE:"OK"}}
33   - ];
34   - myDataSource = new YAHOO.util.DataSource(dados);
35   - myDataTable = new YAHOO.widget.DataTable("tabela", myColumnDefs, myDataSource);
36   -
37   - myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
38   - myDataSource.responseSchema = {
39   - fields: ["codigo_unidade_medida","nome","sigla","permitesoma","permitemedia"]
40   - };
41   - myDataTable.subscribe(
42   - 'cellClickEvent',
43   - function(ev){
44   - var record,$clicouId,$recordid,sUrl,callback,
45   - target = YAHOO.util.Event.getTarget(ev),
46   - column = this.getColumn(target);
47   - if(YAHOO.admin.container.panelCK){
48   - YAHOO.admin.container.panelCK.destroy();
49   - YAHOO.admin.container.panelCK = null;
  4 +i3GEOadmin.umedida = {
  5 + dados: "",
  6 + dataTable: null,
  7 + colunas: ["codigo_unidade_medida","nome","sigla","permitesoma","permitemedia"],
  8 + formatTexto: function(elCell, oRecord, oColumn, oData){
  9 + if(oData === ""){
  10 + oData = "<span style='color:gray' ></span>";
  11 + }
  12 + elCell.innerHTML = "<pre ><p style=cursor:default >" + oData + "</pre>";
  13 + },
  14 + formatExclui: function(elCell, oRecord, oColumn){
  15 + elCell.innerHTML = "<div title='exclui' class=excluir style='text-align:center' ></div>";
  16 + },
  17 + formatMais: function(elCell, oRecord, oColumn){
  18 + elCell.innerHTML = "<div class=editar style='text-align:center' ></div>";
  19 + },
  20 + defColunas: function(){
  21 + return [
  22 + {key:"excluir",label:"excluir",formatter:i3GEOadmin.umedida.formatExclui},
  23 + {key:"mais",label:"editar",formatter:i3GEOadmin.umedida.formatMais},
  24 + {label:"c&oacute;digo",key:"codigo_unidade_medida", formatter:i3GEOadmin.umedida.formatTexto},
  25 + {label:"Nome",resizeable:true,key:"nome", formatter:i3GEOadmin.umedida.formatTexto},
  26 + {label:"Sigla",resizeable:true,key:"sigla", formatter:i3GEOadmin.umedida.formatTexto},
  27 + {label:"Permite soma?",key:"permitesoma", formatter:i3GEOadmin.umedida.formatTexto},
  28 + {label:"Permite m&eacute;dia?",key:"permitemedia", formatter:i3GEOadmin.umedida.formatTexto}
  29 + ];
  30 + },
  31 + /*
  32 + * Inicializa o menu
  33 + */
  34 + inicia: function(){
  35 + YAHOO.namespace("umedida");
  36 + YAHOO.namespace("admin.container");
  37 + core_ativaPainelAjuda("ajuda","botaoAjuda");
  38 + core_ativaBotaoAdicionaLinha("../php/metaestat.php?funcao=alterarUnidadeMedida","adicionaNovaLinha","i3GEOadmin.umedida.obtem");
  39 + i3GEOadmin.umedida.obtem();
  40 + },
  41 + /*
  42 + * Obt&eacute;m a lista de menus
  43 + */
  44 + obtem: function(){
  45 + i3GEOadmin.umedida.dados = "";
  46 + core_carregando("ativa");
  47 + core_pegaDados("buscando endere&ccedil;os...","../php/metaestat.php?funcao=listaUnidadeMedida","i3GEOadmin.umedida.tabela");
  48 + },
  49 + tabela: function(dados){
  50 + if(i3GEOadmin.umedida.dados == ""){
  51 + i3GEOadmin.umedida.dados = dados;
  52 + }
  53 + core_listaDeLetras("letras","i3GEOadmin.umedida.filtra");
  54 + YAHOO.example.InlineCellEditing = new function(){
  55 + // Custom formatter for "address" column to preserve line breaks
  56 + var myDataSource = new YAHOO.util.DataSource(dados);
  57 + myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
  58 + myDataSource.responseSchema = {
  59 + fields: i3GEOadmin.umedida.colunas
  60 + };
  61 + i3GEOadmin.umedida.dataTable = new YAHOO.widget.DataTable("tabela", i3GEOadmin.umedida.defColunas(), myDataSource);
  62 + i3GEOadmin.umedida.dataTable.subscribe('cellClickEvent',function(ev){
  63 + var sUrl, callback,$clicouId, $recordid,
  64 + target = YAHOO.util.Event.getTarget(ev),
  65 + column = this.getColumn(target),
  66 + registro = this.getRecord(target);
  67 + if(YAHOO.umedida.panelCK) {
  68 + YAHOO.umedida.panelCK.destroy();
  69 + YAHOO.umedida.panelCK = null;
50 70 }
51 71 if (column.key == 'excluir'){
52   - record = this.getRecord(target);
53   - excluiLinha(record.getData('codigo_unidade_medida'),target);
  72 + i3GEOadmin.umedida.exclui(registro.getData('codigo_unidade_medida'),target);
54 73 }
55 74 if (column.key == 'mais'){
56   - record = this.getRecord(target);
57 75 core_carregando("ativa");
58 76 core_carregando("buscando dados...");
59   - $clicouId = record.getData('codigo_unidade_medida');
60   - $recordid = record.getId();
61   - sUrl = "../php/metaestat.php?funcao=listaUnidadeMedida&codigo_unidade_medida="+record.getData('codigo_unidade_medida');
  77 + $clicouId = registro.getData('codigo_unidade_medida');
  78 + $recordid = registro.getId();
  79 + sUrl = "../php/metaestat.php?funcao=listaUnidadeMedida&codigo_unidade_medida="+$clicouId;
62 80 callback = {
63   - success:function(o){
64   - try{
65   - montaEditor(YAHOO.lang.JSON.parse(o.responseText),$clicouId,$recordid);
66   - }
67   - catch(e){core_handleFailure(e,o.responseText);}
68   - },
69   - failure:core_handleFailure,
70   - argument: { foo:"foo", bar:"bar" }
  81 + success:function(o){
  82 + try{
  83 + i3GEOadmin.umedida.editor(YAHOO.lang.JSON.parse(o.responseText),$clicouId,$recordid);
  84 + }
  85 + catch(e){core_handleFailure(e,o.responseText);}
  86 + },
  87 + failure:core_handleFailure,
  88 + argument: { foo:"foo", bar:"bar" }
71 89 };
72 90 core_makeRequest(sUrl,callback);
73 91 }
  92 + });
  93 + };
  94 + core_carregando("desativa");
  95 + },
  96 + editor: function(dados,id,recordid){
  97 + function on_editorCheckBoxChange(p_oEvent){
  98 + if(p_oEvent.newValue.get("value") == "OK"){
  99 + i3GEOadmin.umedida.salva(id,recordid);
74 100 }
75   - );
76   - };
77   - core_carregando("desativa");
78   -}
79   -function montaEditor(dados,id,recordid){
80   - function on_editorCheckBoxChange(p_oEvent){
81   - if(p_oEvent.newValue.get("value") == "OK"){
82   - gravaDados(id,recordid);
83   - }
84   - YAHOO.admin.container.panelEditor2.destroy();
85   - YAHOO.admin.container.panelEditor2 = null;
86   - };
87   - if(!$i("janela_editor2")){
88   - var ins,editorBotoes,
89   - novoel = document.createElement("div");
90   -
91   - novoel.id = "janela_editor2";
92   - ins = '<div class="hd">Editor</div>';
93   - ins += "<div class='bd' style='height:354px;overflow:auto'>";
94   - ins += "<div id='okcancel_checkbox2'></div><div id='editor_bd2'></div>";
95   - novoel.innerHTML = ins;
96   - document.body.appendChild(novoel);
97   - editorBotoes = new YAHOO.widget.ButtonGroup({id:"okcancel_checkbox_id2", name: "okcancel_checkbox_id2", container: "okcancel_checkbox2" });
98   - editorBotoes.addButtons([
99   - { label: "Salva", value: "OK", checked: false},
100   - { label: "Cancela", value: "CANCEL", checked: false }
101   - ]);
102   - editorBotoes.on("checkedButtonChange", on_editorCheckBoxChange);
103   - YAHOO.admin.container.panelEditor2 = new YAHOO.widget.Panel("janela_editor2", { fixedcenter:true,close:false,width:"400px", height:"380px",overflow:"auto", visible:false,constraintoviewport:true } );
104   - YAHOO.admin.container.panelEditor2.render();
105   - }
106   - YAHOO.admin.container.panelEditor2.show();
107   - $i("editor_bd2").innerHTML = montaDiv(dados);
108   - core_carregando("desativa");
109   -}
110   -function montaDiv(i){
111   - var param = {
112   - "linhas":[{
113   - titulo:"Nome:",id:"Enome",size:"50",value:i.nome,tipo:"text",div:""
114   - },{
115   - titulo:"Sigla:",id:"Esigla",size:"50",value:i.sigla,tipo:"text",div:""
116   - }]
117   - },
118   - ins = "";
119   -
120   - ins += core_geraLinhas(param);
121   - ins += "<p>Possibilita somar os valores?<br>";
122   - ins += "<select id='Epermitesoma' />";
123   - ins += "<option value='' ";
124   - if (i.permitesoma == ""){ins += "selected";}
125   - ins += ">---</option>";
126   - ins += "<option value='1' ";
127   - if (i.permitesoma == 1){ins += "selected";}
128   - ins += " >sim</option>";
129   - ins += "<option value='0' ";
130   - if (i.permitesoma == 0 ){ins += "selected";}
131   - ins += " >n&atilde;o</option>";
132   - ins += "</select></p>";
  101 + YAHOO.umedida.panelEditor2.destroy();
  102 + YAHOO.umedida.panelEditor2 = null;
  103 + };
  104 + if(!$i("janela_editor2")){
  105 + var editorBotoes,ins,
  106 + novoel = document.createElement("div");
  107 + novoel.id = "janela_editor2";
  108 + ins = '<div class="hd">Editor</div>';
  109 + ins += "<div class='bd' style='height:354px;overflow:auto'>";
  110 + ins += "<div id='okcancel_checkbox2'></div><div id='editor_bd2'></div>";
  111 + novoel.innerHTML = ins;
133 112  
134   - ins += "<p>Possibilita calcular m&eacute;dia?<br>";
135   - ins += "<select id='Epermitemedia' />";
136   - ins += "<option value='' ";
137   - if (i.permitemedia == ""){ins += "selected";}
138   - ins += ">---</option>";
139   - ins += "<option value='1' ";
140   - if (i.permitemedia == 1){ins += "selected";}
141   - ins += " >sim</option>";
142   - ins += "<option value='0' ";
143   - if (i.permitemedia == 0 ){ins += "selected";}
144   - ins += " >n&atilde;o</option>";
145   - ins += "</select></p>";
146   - return(ins);
147   -}
  113 + document.body.appendChild(novoel);
  114 + editorBotoes = new YAHOO.widget.ButtonGroup({id:"okcancel_checkbox_id2", name: "okcancel_checkbox_id2", container: "okcancel_checkbox2" });
  115 + editorBotoes.addButtons([
  116 + { label: "Salva", value: "OK", checked: false},
  117 + { label: "Cancela", value: "CANCEL", checked: false }
  118 + ]);
  119 + editorBotoes.on("checkedButtonChange", on_editorCheckBoxChange);
  120 + YAHOO.umedida.panelEditor2 = new YAHOO.widget.Panel("janela_editor2", { modal:true,fixedcenter:true,close:false,width:"400px", height:"360px",overflow:"auto", visible:false,constraintoviewport:true } );
  121 + YAHOO.umedida.panelEditor2.render();
  122 + }
  123 + YAHOO.umedida.panelEditor2.show();
  124 + $i("editor_bd2").innerHTML = i3GEOadmin.umedida.formulario(dados);
  125 + core_carregando("desativa");
  126 + },
  127 + formulario: function(i){
  128 + var param = {
  129 + "linhas":[{
  130 + titulo:"Nome:",id:"Enome",size:"50",value:i.nome,tipo:"text",div:""
  131 + },{
  132 + titulo:"Sigla:",id:"Esigla",size:"50",value:i.sigla,tipo:"text",div:""
  133 + }]
  134 + },
  135 + ins = "";
148 136  
149   -function gravaDados(id,recordid){
150   - var campos = new Array("nome","sigla","permitesoma","permitemedia"),
151   - par = "",
152   - i = 0,
153   - sUrl,callback;
  137 + ins += core_geraLinhas(param);
  138 + ins += "<p>Possibilita somar os valores?<br>";
  139 + ins += "<select id='Epermitesoma' />";
  140 + ins += "<option value='' ";
  141 + if (i.permitesoma == ""){ins += "selected";}
  142 + ins += ">---</option>";
  143 + ins += "<option value='1' ";
  144 + if (i.permitesoma == 1){ins += "selected";}
  145 + ins += " >sim</option>";
  146 + ins += "<option value='0' ";
  147 + if (i.permitesoma == 0 ){ins += "selected";}
  148 + ins += " >n&atilde;o</option>";
  149 + ins += "</select></p>";
154 150  
155   - for (i=0;i<campos.length;i++){
156   - par += "&"+campos[i]+"="+($i("E"+campos[i]).value);
157   - }
158   - par += "&codigo_unidade_medida="+id;
159   - core_carregando("ativa");
160   - core_carregando(" gravando o registro do id= "+id);
161   - sUrl = "../php/metaestat.php?funcao=alterarUnidadeMedida"+par;
162   - callback = {
163   - success:function(o){
164   - try {
165   - if(YAHOO.lang.JSON.parse(o.responseText) == "erro") {
166   - core_carregando("<span style=color:red >N&atilde;o foi poss&iacute;vel excluir. Verifique se n&atilde;o existem registros vinculados</span>");
167   - setTimeout("core_carregando('desativa')",3000);
168   - }
169   - else{
170   - var rec = myDataTable.getRecordSet().getRecord(recordid);
171   - myDataTable.updateRow(rec,YAHOO.lang.JSON.parse(o.responseText));
172   - core_carregando("desativa");
173   - }
  151 + ins += "<p>Possibilita calcular m&eacute;dia?<br>";
  152 + ins += "<select id='Epermitemedia' />";
  153 + ins += "<option value='' ";
  154 + if (i.permitemedia == ""){ins += "selected";}
  155 + ins += ">---</option>";
  156 + ins += "<option value='1' ";
  157 + if (i.permitemedia == 1){ins += "selected";}
  158 + ins += " >sim</option>";
  159 + ins += "<option value='0' ";
  160 + if (i.permitemedia == 0 ){ins += "selected";}
  161 + ins += " >n&atilde;o</option>";
  162 + ins += "</select></p>";
  163 + return(ins);
  164 + },
  165 + filtra: function(letra){
  166 + var i,temp,
  167 + n = i3GEOadmin.umedida.dados.length,
  168 + novo = [];
  169 + if(letra == "Todos"){
  170 + novo = i3GEOadmin.umedida.dados;
  171 + }
  172 + else{
  173 + for(i=0;i<n;i++){
  174 + temp = i3GEOadmin.umedida.dados[i].nome;
  175 + if(temp.charAt(0).toUpperCase() == letra.toUpperCase()){
  176 + novo.push(i3GEOadmin.umedida.dados[i]);
174 177 }
175   - catch(e){core_handleFailure(e,o.responseText);}
176   - },
177   - failure:core_handleFailure,
178   - argument: { foo:"foo", bar:"bar" }
179   - };
180   - core_makeRequest(sUrl,callback);
181   -}
182   -function excluiLinha(id,row){
183   - var mensagem = " excluindo o registro do id= "+id,
184   - sUrl = "../php/metaestat.php?funcao=excluirUnidadeMedida&codigo_unidade_medida="+id;
185   - core_excluiLinha(sUrl,row,mensagem);
186   -}
187   -//YAHOO.util.Event.addListener(window, "load", initMenu);
188 178 \ No newline at end of file
  179 + }
  180 + }
  181 + i3GEOadmin.umedida.tabela(novo);
  182 + },
  183 + exclui: function(id,row){
  184 + var mensagem = " excluindo o registro do id= "+id,
  185 + sUrl = "../php/metaestat.php?funcao=excluirUnidadeMedida&codigo_unidade_medida="+id;
  186 + core_excluiLinha(sUrl,row,mensagem,"",i3GEOadmin.umedida.dataTable);
  187 + },
  188 + salva: function(id,recordid){
  189 + var i,c,sUrl, callback,
  190 + campos = i3GEOadmin.umedida.colunas,
  191 + par = "",
  192 + n = campos.length;
  193 + for (i=0;i<n;i++){
  194 + c = $i("E"+campos[i].key);
  195 + if(c){
  196 + par += "&"+campos[i].key+"="+(c.value);
  197 + }
  198 + }
  199 + par += "&codigo_unidade_medida="+id;
  200 + core_carregando("ativa");
  201 + core_carregando(" gravando o registro do id= "+id);
  202 + sUrl = "../php/metaestat.php?funcao=alterarUnidadeMedida"+par;
  203 + callback = {
  204 + success:function(o){
  205 + try {
  206 + if(YAHOO.lang.JSON.parse(o.responseText) == "erro") {
  207 + core_carregando("<span style=color:red >N&atilde;o foi poss&iacute;vel excluir. Verifique se n&atilde;o existem registros vinculados</span>");
  208 + setTimeout("core_carregando('desativa')",3000);
  209 + }
  210 + else{
  211 + var rec = i3GEOadmin.umedida.dataTable.getRecordSet().getRecord(recordid);
  212 + i3GEOadmin.umedida.dataTable.updateRow(rec,YAHOO.lang.JSON.parse(o.responseText));
  213 + core_carregando("desativa");
  214 + }
  215 + }
  216 + catch(e){core_handleFailure(e,o.responseText);}
  217 + },
  218 + failure:core_handleFailure,
  219 + argument: { foo:"foo", bar:"bar" }
  220 + };
  221 + core_makeRequest(sUrl,callback);
  222 + }
  223 +};
... ...