Commit 4f3432d229c9f02aa7357aaba539832af86917a3
1 parent
11c7091d
Exists in
master
and in
7 other branches
--no commit message
Showing
6 changed files
with
481 additions
and
408 deletions
Show diff stats
admin/html/menus.html
@@ -122,7 +122,7 @@ body { | @@ -122,7 +122,7 @@ body { | ||
122 | cabecalhoGeral("cabecalhoPrincipal", "menus"); | 122 | cabecalhoGeral("cabecalhoPrincipal", "menus"); |
123 | temp = function() { | 123 | temp = function() { |
124 | document.getElementById("formulario").style.display = "block"; | 124 | document.getElementById("formulario").style.display = "block"; |
125 | - initEditorMenu(); | 125 | + i3GEOadmin.menus.inicia(); |
126 | }; | 126 | }; |
127 | i3GEO.login.verificaOperacao("admin/html/menus", | 127 | i3GEO.login.verificaOperacao("admin/html/menus", |
128 | i3GEO.configura.locaplic, temp, "sessao"); | 128 | i3GEO.configura.locaplic, temp, "sessao"); |
admin/js/arvore.js
@@ -65,13 +65,13 @@ function initMenu(){ | @@ -65,13 +65,13 @@ function initMenu(){ | ||
65 | if($i("editor_bd")){return;} | 65 | if($i("editor_bd")){return;} |
66 | core_montaEditor("","600px","500px","pegaMenus","Menu"); | 66 | core_montaEditor("","600px","500px","pegaMenus","Menu"); |
67 | $i("editor_bd").innerHTML = '<input type=button id=adicionaNovoMenu value="Adicionar um novo menu" style="left:-5px;" /><br><br><div id="letras_M" ></div><br><br><div id="tabela" style="left:-5px;"> </div>'; | 67 | $i("editor_bd").innerHTML = '<input type=button id=adicionaNovoMenu value="Adicionar um novo menu" style="left:-5px;" /><br><br><div id="letras_M" ></div><br><br><div id="tabela" style="left:-5px;"> </div>'; |
68 | - initEditorMenu(); | 68 | + i3GEOadmin.menus.inicia(); |
69 | }, | 69 | }, |
70 | editorDeGrupos = function(){ | 70 | editorDeGrupos = function(){ |
71 | if($i("editor_bd")){return;} | 71 | if($i("editor_bd")){return;} |
72 | core_montaEditor("","600px","500px","","Grupos"); | 72 | core_montaEditor("","600px","500px","","Grupos"); |
73 | $i("editor_bd").innerHTML = '<p class=paragrafo >Clique nas células da tabela para editar a característica de cada item. Finalize com "enter". Após editar, salve o item.</p><p class=paragrafo ><input type=button id=adicionaNovoGrupo value="Adicionar um novo grupo" style="left:-5px;" /></p><p><br><br><div id="letras_G" ></div><br><div id="tabela" style="left:-5px;"> </div>'; | 73 | $i("editor_bd").innerHTML = '<p class=paragrafo >Clique nas células da tabela para editar a característica de cada item. Finalize com "enter". Após editar, salve o item.</p><p class=paragrafo ><input type=button id=adicionaNovoGrupo value="Adicionar um novo grupo" style="left:-5px;" /></p><p><br><br><div id="letras_G" ></div><br><div id="tabela" style="left:-5px;"> </div>'; |
74 | - initEditorGrupos(); | 74 | + i3GEOadmin.grupos.inicia(); |
75 | }, | 75 | }, |
76 | editorDeSubGrupos = function() { | 76 | editorDeSubGrupos = function() { |
77 | if($i("editor_bd")){return;} | 77 | if($i("editor_bd")){return;} |
admin/js/core.js
@@ -1235,7 +1235,7 @@ row - objeto row de um datatable | @@ -1235,7 +1235,7 @@ row - objeto row de um datatable | ||
1235 | 1235 | ||
1236 | mensagem - | 1236 | mensagem - |
1237 | */ | 1237 | */ |
1238 | -function core_excluiLinha(sUrl,row,mensagem,cabecalho) | 1238 | +function core_excluiLinha(sUrl,row,mensagem,cabecalho,tabela) |
1239 | { | 1239 | { |
1240 | if(!cabecalho){ | 1240 | if(!cabecalho){ |
1241 | cabecalho = ""; | 1241 | cabecalho = ""; |
@@ -1260,7 +1260,12 @@ function core_excluiLinha(sUrl,row,mensagem,cabecalho) | @@ -1260,7 +1260,12 @@ function core_excluiLinha(sUrl,row,mensagem,cabecalho) | ||
1260 | } | 1260 | } |
1261 | else | 1261 | else |
1262 | { | 1262 | { |
1263 | - myDataTable.deleteRow(row); | 1263 | + if(tabela){ |
1264 | + tabela.deleteRow(row); | ||
1265 | + } | ||
1266 | + else{ | ||
1267 | + myDataTable.deleteRow(row); | ||
1268 | + } | ||
1264 | core_carregando("desativa"); | 1269 | core_carregando("desativa"); |
1265 | } | 1270 | } |
1266 | } | 1271 | } |
@@ -1271,8 +1276,7 @@ function core_excluiLinha(sUrl,row,mensagem,cabecalho) | @@ -1271,8 +1276,7 @@ function core_excluiLinha(sUrl,row,mensagem,cabecalho) | ||
1271 | }; | 1276 | }; |
1272 | core_makeRequest(sUrl,callback); | 1277 | core_makeRequest(sUrl,callback); |
1273 | }; | 1278 | }; |
1274 | - var handleNo = function() | ||
1275 | - { | 1279 | + var handleNo = function(){ |
1276 | this.hide(); | 1280 | this.hide(); |
1277 | }; | 1281 | }; |
1278 | var mensagem = "Exclui o registro?"; | 1282 | var mensagem = "Exclui o registro?"; |
admin/js/grupos.js
@@ -29,164 +29,237 @@ Arquivo: | @@ -29,164 +29,237 @@ Arquivo: | ||
29 | 29 | ||
30 | i3geo/admin/js/grupos.js | 30 | i3geo/admin/js/grupos.js |
31 | */ | 31 | */ |
32 | + | ||
32 | /* | 33 | /* |
33 | -Function: initEditorGrupos | 34 | +Title: menu.js |
34 | 35 | ||
35 | -Inicializa o editor | 36 | +Funções que controlam a interface do editor de menus |
36 | 37 | ||
37 | -<ALTERAGRUPOS> | ||
38 | -*/ | ||
39 | -function initEditorGrupos() | ||
40 | -{ | ||
41 | - core_ativaBotaoAdicionaLinha("../php/menutemas.php?funcao=alteraGrupos","adicionaNovoGrupo","pegaGrupos_G"); | ||
42 | - pegaGrupos_G(); | ||
43 | -} | ||
44 | -/* | ||
45 | -Function: pegaGrupos_G | 38 | +Licenca: |
39 | + | ||
40 | +GPL2 | ||
41 | + | ||
42 | +i3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet | ||
43 | + | ||
44 | +Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil | ||
45 | +Desenvolvedor: Edmar Moretti edmar.moretti@mma.gov.br | ||
46 | + | ||
47 | +Este programa é software livre; você pode redistribuí-lo | ||
48 | +e/ou modificá-lo sob os termos da Licença Pública Geral | ||
49 | +GNU conforme publicada pela Free Software Foundation; | ||
46 | 50 | ||
47 | -Obtém a lista de grupos | 51 | +Este programa é distribuído na expectativa de que seja útil, |
52 | +porém, SEM NENHUMA GARANTIA; nem mesmo a garantia implícita | ||
53 | +de COMERCIABILIDADE OU ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. | ||
54 | +Consulte a Licença Pública Geral do GNU para mais detalhes. | ||
55 | +Você deve ter recebido uma cópia da Licença Pública Geral do | ||
56 | +GNU junto com este programa; se não, escreva para a | ||
57 | +Free Software Foundation, Inc., no endereço | ||
58 | +59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
59 | + | ||
60 | +Arquivo: | ||
48 | 61 | ||
49 | -<PEGAGRUPOS> | 62 | +i3geo/admin/js/menus.js |
50 | */ | 63 | */ |
51 | -function pegaGrupos_G() | ||
52 | -{ | ||
53 | - dados_G = ""; | ||
54 | - core_carregando("ativa"); | ||
55 | - core_pegaDados("buscando grupos...","../php/menutemas.php?funcao=pegaGrupos","montaTabela_G"); | 64 | + |
65 | +if(typeof(i3GEOadmin) === 'undefined'){ | ||
66 | + var i3GEOadmin = {}; | ||
56 | } | 67 | } |
57 | -function filtraDadosLetras_G(letra){ | ||
58 | - var i,temp, | ||
59 | - n = dados_G.length, | ||
60 | - novo = []; | ||
61 | - if(letra == "Todos"){ | ||
62 | - novo = dados_G; | ||
63 | - } | ||
64 | - else{ | ||
65 | - for(i=0;i<n;i++){ | ||
66 | - temp = dados_G[i].nome_grupo; | ||
67 | - if(temp.charAt(0).toUpperCase() == letra.toUpperCase()){ | ||
68 | - novo.push(dados_G[i]); | ||
69 | - } | 68 | +i3GEOadmin.grupos = { |
69 | + dados: "", | ||
70 | + dataTable: null, | ||
71 | + colunas: ["it","es","en","desc_grupo","id_grupo","nome_grupo"], | ||
72 | + formatTexto: function(elCell, oRecord, oColumn, oData){ | ||
73 | + if(oData === ""){ | ||
74 | + oData = "<span style='color:gray' ></span>"; | ||
70 | } | 75 | } |
71 | - } | ||
72 | - montaTabela_G(novo); | ||
73 | -} | ||
74 | -function montaTabela_G(dados) | ||
75 | -{ | ||
76 | - if(dados_G == ""){ | ||
77 | - dados_G = dados; | ||
78 | - } | ||
79 | - core_listaDeLetras("letras_G","filtraDadosLetras_G"); | ||
80 | - YAHOO.example.InlineCellEditing = new function(){ | ||
81 | - // Custom formatter for "address" column to preserve line breaks | ||
82 | - var formatTexto = function(elCell, oRecord, oColumn, oData){ | ||
83 | - if(oData === ""){ | ||
84 | - oData = "<span style='color:gray' >Clique para editar, tecle enter e depois salve</span>"; | 76 | + elCell.innerHTML = "<pre ><p style=cursor:default >" + oData + "</pre>"; |
77 | + }, | ||
78 | + formatSalva: function(elCell, oRecord, oColumn){ | ||
79 | + elCell.innerHTML = "<div title='salva' class=salvar style='text-align:center' onclick='gravaLinha_G(\""+oRecord._sId+"\")'></div>"; | ||
80 | + }, | ||
81 | + formatExclui: function(elCell, oRecord, oColumn){ | ||
82 | + elCell.innerHTML = "<div title='exclui' class=excluir style='text-align:center' ></div>"; | ||
83 | + }, | ||
84 | + formatMais: function(elCell, oRecord, oColumn){ | ||
85 | + elCell.innerHTML = "<div class=editar style='text-align:center' ></div>"; | ||
86 | + }, | ||
87 | + defColunas: function(){ | ||
88 | + return [ | ||
89 | + {key:"excluir",label:"excluir",formatter:i3GEOadmin.grupos.formatExclui}, | ||
90 | + {key:"mais",label:"editar",formatter:i3GEOadmin.grupos.formatMais}, | ||
91 | + {label:"id",key:"id_grupo", formatter:i3GEOadmin.grupos.formatTexto}, | ||
92 | + {label:"nome",resizeable:true,key:"nome_grupo", formatter:i3GEOadmin.grupos.formatTexto}, | ||
93 | + {label:"descrição",resizeable:true,key:"desc_grupo", formatter:i3GEOadmin.grupos.formatTexto}, | ||
94 | + {label:"en",resizeable:true,key:"en", formatter:i3GEOadmin.grupos.formatTexto}, | ||
95 | + {label:"es",resizeable:true,key:"es", formatter:i3GEOadmin.grupos.formatTexto}, | ||
96 | + {label:"it",resizeable:true,key:"it", formatter:i3GEOadmin.grupos.formatTexto} | ||
97 | + ]; | ||
98 | + }, | ||
99 | + /* | ||
100 | + * Inicializa o menu | ||
101 | + */ | ||
102 | + inicia: function(){ | ||
103 | + YAHOO.namespace("grupos"); | ||
104 | + core_ativaBotaoAdicionaLinha("../php/menutemas.php?funcao=alteraGrupos","adicionaNovoGrupo","i3GEOadmin.grupos.obtem"); | ||
105 | + i3GEOadmin.grupos.obtem(); | ||
106 | + }, | ||
107 | + /* | ||
108 | + * Obtém a lista de menus | ||
109 | + */ | ||
110 | + obtem: function(){ | ||
111 | + i3GEOadmin.grupos.dados = ""; | ||
112 | + core_carregando("ativa"); | ||
113 | + core_pegaDados("buscando grupos...","../php/menutemas.php?funcao=pegaGrupos","i3GEOadmin.grupos.tabela"); | ||
114 | + }, | ||
115 | + tabela: function(dados){ | ||
116 | + if(i3GEOadmin.grupos.dados == ""){ | ||
117 | + i3GEOadmin.grupos.dados = dados; | ||
118 | + } | ||
119 | + core_listaDeLetras("letras_G","i3GEOadmin.grupos.filtra"); | ||
120 | + YAHOO.example.InlineCellEditing = new function(){ | ||
121 | + // Custom formatter for "address" column to preserve line breaks | ||
122 | + var myDataSource = new YAHOO.util.DataSource(dados); | ||
123 | + myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY; | ||
124 | + myDataSource.responseSchema = { | ||
125 | + fields: i3GEOadmin.grupos.colunas | ||
126 | + }; | ||
127 | + i3GEOadmin.grupos.dataTable = new YAHOO.widget.DataTable("tabela", i3GEOadmin.grupos.defColunas(), myDataSource); | ||
128 | + i3GEOadmin.grupos.dataTable.subscribe('cellClickEvent',function(ev){ | ||
129 | + var sUrl, callback,$clicouId, $recordid, | ||
130 | + target = YAHOO.util.Event.getTarget(ev), | ||
131 | + column = this.getColumn(target), | ||
132 | + registro = this.getRecord(target); | ||
133 | + if(YAHOO.grupos.panelCK) { | ||
134 | + YAHOO.grupos.panelCK.destroy(); | ||
135 | + YAHOO.grupos.panelCK = null; | ||
85 | } | 136 | } |
86 | - elCell.innerHTML = "<p style=width:250px;cursor:pointer title='clique para editar'>" + oData + "</p>"; | ||
87 | - }, | ||
88 | - formatTextoId = function(elCell, oRecord, oColumn, oData){ | ||
89 | - elCell.innerHTML = "<p style=width:20px >" + oData + "</p>"; | ||
90 | - }, | ||
91 | - formatSalva = function(elCell, oRecord, oColumn){ | ||
92 | - elCell.innerHTML = "<div title='salva' class=salvar style='text-align:center' onclick='gravaLinha_G(\""+oRecord._sId+"\")'></div>"; | ||
93 | - }, | ||
94 | - formatExclui = function(elCell, oRecord, oColumn){ | ||
95 | - elCell.innerHTML = "<div title='exclui' class=excluir style='text-align:center' ></div>"; | ||
96 | - }, | ||
97 | - myColumnDefs = [ | ||
98 | - {key:"excluir",label:"excluir",formatter:formatExclui}, | ||
99 | - {label:"salvar",formatter:formatSalva}, | ||
100 | - {label:"id",key:"id_grupo", formatter:formatTextoId}, | ||
101 | - {label:"nome",resizeable:true,key:"nome_grupo", formatter:formatTexto, editor:new YAHOO.widget.TextboxCellEditor({disableBtns:true})}, | ||
102 | - {label:"descrição",resizeable:true,key:"desc_grupo", formatter:formatTexto, editor:new YAHOO.widget.TextboxCellEditor({disableBtns:true})}, | ||
103 | - {label:"en",resizeable:true,key:"en", formatter:formatTexto, editor:new YAHOO.widget.TextboxCellEditor({disableBtns:true})}, | ||
104 | - {label:"es",resizeable:true,key:"es", formatter:formatTexto, editor:new YAHOO.widget.TextboxCellEditor({disableBtns:true})}, | ||
105 | - {label:"it",resizeable:true,key:"it", formatter:formatTexto, editor:new YAHOO.widget.TextboxCellEditor({disableBtns:true})} | ||
106 | - ]; | ||
107 | - myDataSource = new YAHOO.util.DataSource(dados); | ||
108 | - myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY; | ||
109 | - myDataSource.responseSchema = { | ||
110 | - fields: ["it","es","en","desc_grupo","id_grupo","nome_grupo"] | ||
111 | - }; | ||
112 | - myDataTable = new YAHOO.widget.DataTable("tabela", myColumnDefs, myDataSource); | ||
113 | - // Set up editing flow | ||
114 | - myDataTable.highlightEditableCell = function(oArgs) { | ||
115 | - var elCell = oArgs.target, | ||
116 | - column = myDataTable.getColumn(oArgs.target); | ||
117 | - //if(column.editor != "null") | ||
118 | - if(!YAHOO.lang.isNull(column.editor)){ | ||
119 | - YAHOO.util.Dom.addClass(elCell,'yui-dt-highlighted'); | ||
120 | - } | 137 | + if (column.key == 'excluir'){ |
138 | + i3GEOadmin.grupos.exclui(registro.getData('id_grupo'),target); | ||
139 | + } | ||
140 | + if (column.key == 'mais'){ | ||
141 | + core_carregando("ativa"); | ||
142 | + core_carregando("buscando dados..."); | ||
143 | + $clicouId = registro.getData('id_grupo'); | ||
144 | + $recordid = registro.getId(); | ||
145 | + sUrl = "../php/menutemas.php?funcao=pegaGrupos&id_grupo="+$clicouId; | ||
146 | + callback = { | ||
147 | + success:function(o){ | ||
148 | + try{ | ||
149 | + i3GEOadmin.grupos.editor(YAHOO.lang.JSON.parse(o.responseText),$clicouId,$recordid); | ||
150 | + } | ||
151 | + catch(e){core_handleFailure(e,o.responseText);} | ||
152 | + }, | ||
153 | + failure:core_handleFailure, | ||
154 | + argument: { foo:"foo", bar:"bar" } | ||
155 | + }; | ||
156 | + core_makeRequest(sUrl,callback); | ||
157 | + } | ||
158 | + }); | ||
121 | }; | 159 | }; |
122 | - myDataTable.unhighlightEditableCell = function(oArgs){ | ||
123 | - var elCell = oArgs.target; | ||
124 | - if(elCell.style.cursor="pointer"){ | ||
125 | - YAHOO.util.Dom.removeClass(elCell,'yui-dt-highlighted'); | 160 | + core_carregando("desativa"); |
161 | + }, | ||
162 | + editor: function(dados,id,recordid){ | ||
163 | + function on_editorCheckBoxChange(p_oEvent){ | ||
164 | + if(p_oEvent.newValue.get("value") == "OK"){ | ||
165 | + i3GEOadmin.grupos.salva(id,recordid); | ||
126 | } | 166 | } |
167 | + YAHOO.grupos.panelEditor2.destroy(); | ||
168 | + YAHOO.grupos.panelEditor2 = null; | ||
127 | }; | 169 | }; |
128 | - myDataTable.subscribe("cellMouseoverEvent", myDataTable.highlightEditableCell); | ||
129 | - myDataTable.subscribe("cellMouseoutEvent", myDataTable.unhighlightEditableCell); | ||
130 | - myDataTable.subscribe('cellClickEvent',function(ev){ | ||
131 | - var record,target = YAHOO.util.Event.getTarget(ev), | ||
132 | - column = this.getColumn(target); | ||
133 | - if(YAHOO.admin.container.panelCK){ | ||
134 | - YAHOO.admin.container.panelCK.destroy(); | ||
135 | - YAHOO.admin.container.panelCK = null; | ||
136 | - } | ||
137 | - if (column.key == 'excluir'){ | ||
138 | - record = this.getRecord(target); | ||
139 | - excluiLinha_G(record.getData('id_grupo'),target); | ||
140 | - } | ||
141 | - else | ||
142 | - {this.onEventShowCellEditor(ev);} | ||
143 | - }); | ||
144 | - // Hook into custom event to customize save-flow of "radio" editor | ||
145 | - myDataTable.subscribe("editorUpdateEvent", function(oArgs){ | ||
146 | - if(oArgs.editor.column.key === "active"){ | ||
147 | - this.saveCellEditor(); | ||
148 | - } | ||
149 | - }); | ||
150 | - myDataTable.subscribe("editorBlurEvent", function(oArgs){ | ||
151 | - this.cancelCellEditor(); | ||
152 | - }); | ||
153 | - myDataTable.subscribe("editorSaveEvent", function(oArgs){ | ||
154 | - if(oArgs.newData != oArgs.oldData){ | ||
155 | - var linha = myDataTable.getTrEl(oArgs.editor.getRecord()); | ||
156 | - if(linha){ | ||
157 | - linha.style.color = "blue"; | ||
158 | - linha.style.textDecoration = "blink"; | 170 | + if(!$i("janela_editor2")){ |
171 | + var editorBotoes,ins, | ||
172 | + novoel = document.createElement("div"); | ||
173 | + novoel.id = "janela_editor2"; | ||
174 | + ins = '<div class="hd">Editor</div>'; | ||
175 | + ins += "<div class='bd' style='height:354px;overflow:auto'>"; | ||
176 | + ins += "<div id='okcancel_checkbox2'></div><div id='editor_bd2'></div>"; | ||
177 | + ins += "<div id='letras_M'></div>"; | ||
178 | + novoel.innerHTML = ins; | ||
179 | + | ||
180 | + document.body.appendChild(novoel); | ||
181 | + editorBotoes = new YAHOO.widget.ButtonGroup({id:"okcancel_checkbox_id2", name: "okcancel_checkbox_id2", container: "okcancel_checkbox2" }); | ||
182 | + editorBotoes.addButtons([ | ||
183 | + { label: "Salva", value: "OK", checked: false}, | ||
184 | + { label: "Cancela", value: "CANCEL", checked: false } | ||
185 | + ]); | ||
186 | + editorBotoes.on("checkedButtonChange", on_editorCheckBoxChange); | ||
187 | + YAHOO.grupos.panelEditor2 = new YAHOO.widget.Panel("janela_editor2", { modal:true,fixedcenter:true,close:false,width:"400px", height:"480px",overflow:"auto", visible:false,constraintoviewport:true } ); | ||
188 | + YAHOO.grupos.panelEditor2.render(); | ||
189 | + } | ||
190 | + YAHOO.grupos.panelEditor2.show(); | ||
191 | + $i("editor_bd2").innerHTML = i3GEOadmin.grupos.formulario(dados[0]); | ||
192 | + core_carregando("desativa"); | ||
193 | + }, | ||
194 | + formulario: function(i){ | ||
195 | + var param = { | ||
196 | + "linhas":[ | ||
197 | + {titulo:"Nome padrão:",id:"Enome_grupo",size:"50",value:i.nome_grupo,tipo:"text",div:""}, | ||
198 | + {titulo:"Descricao (opcional):",id:"Edesc_grupo",size:"50",value:i.desc_grupo,tipo:"text",div:""}, | ||
199 | + {titulo:"Nome em inglês (opcional):",id:"Een",size:"50",value:i.en,tipo:"text",div:""}, | ||
200 | + {titulo:"Espanhol (opcional):",id:"Ees",size:"50",value:i.es,tipo:"text",div:""}, | ||
201 | + {titulo:"Italiano (opcional):",id:"Eit",size:"50",value:i.it,tipo:"text",div:""} | ||
202 | + ] | ||
203 | + }, | ||
204 | + ins = ""; | ||
205 | + ins += core_geraLinhas(param); | ||
206 | + return(ins); | ||
207 | + }, | ||
208 | + filtra: function(letra){ | ||
209 | + var i,temp, | ||
210 | + n = i3GEOadmin.grupos.dados.length, | ||
211 | + novo = []; | ||
212 | + if(letra == "Todos"){ | ||
213 | + novo = i3GEOadmin.grupos.dados; | ||
214 | + } | ||
215 | + else{ | ||
216 | + for(i=0;i<n;i++){ | ||
217 | + temp = i3GEOadmin.grupos.dados[i].nome_grupo; | ||
218 | + if(temp.charAt(0).toUpperCase() == letra.toUpperCase()){ | ||
219 | + novo.push(i3GEOadmin.grupos.dados[i]); | ||
159 | } | 220 | } |
160 | } | 221 | } |
161 | - }); | ||
162 | - }; | ||
163 | - core_carregando("desativa"); | ||
164 | -} | ||
165 | -/* | ||
166 | -Function: gravaLinha_G | ||
167 | - | ||
168 | -Aplica as alterações feitas em um registro | ||
169 | - | ||
170 | -<ALTERAGRUPOS> | ||
171 | -*/ | ||
172 | -function gravaLinha_G(row) | ||
173 | -{ | ||
174 | - var r = myDataTable.getRecordSet().getRecord(row); | ||
175 | - var id_grupo = r.getData("id_grupo"); | ||
176 | - var nome_grupo = r.getData("nome_grupo"); | ||
177 | - var desc_grupo = r.getData("desc_grupo"); | ||
178 | - var en = r.getData("en"); | ||
179 | - var es = r.getData("es"); | ||
180 | - var it = r.getData("it"); | ||
181 | - core_carregando("ativa"); | ||
182 | - var mensagem = " gravando registro do id= "+id_grupo; | ||
183 | - var sUrl = "../php/menutemas.php?funcao=alteraGrupos&nome="+nome_grupo+"&desc="+desc_grupo+"&id="+id_grupo+"&en="+en+"&es="+es+"&it="+it; | ||
184 | - core_gravaLinha(mensagem,row,sUrl,"pegaGrupos_G"); | ||
185 | -} | ||
186 | -function excluiLinha_G(id,row) | ||
187 | -{ | ||
188 | - var mensagem = " excluindo o registro do id= "+id; | ||
189 | - var sUrl = "../php/menutemas.php?funcao=excluirRegistro&id="+id+"&tabela=grupos"; | ||
190 | - core_excluiLinha(sUrl,row,mensagem); | ||
191 | -} | ||
192 | -//YAHOO.util.Event.addListener(window, "load", initMenu); | ||
193 | \ No newline at end of file | 222 | \ No newline at end of file |
223 | + } | ||
224 | + i3GEOadmin.grupos.tabela(novo); | ||
225 | + }, | ||
226 | + exclui: function(id,row){ | ||
227 | + var mensagem = " excluindo o registro do id= "+id, | ||
228 | + sUrl = "../php/menutemas.php?funcao=excluirRegistro&id="+id+"&tabela=grupos"; | ||
229 | + core_excluiLinha(sUrl,row,mensagem,"",i3GEOadmin.grupos.dataTable); | ||
230 | + }, | ||
231 | + salva: function(id,recordid){ | ||
232 | + var i,c,sUrl, callback, | ||
233 | + campos = i3GEOadmin.grupos.colunas, | ||
234 | + par = "", | ||
235 | + n = campos.length; | ||
236 | + for (i=0;i<n;i++){ | ||
237 | + c = $i("E"+campos[i].key); | ||
238 | + if(c){ | ||
239 | + par += "&"+campos[i].key+"="+(c.value); | ||
240 | + } | ||
241 | + } | ||
242 | + par += "&id_grupo="+id; | ||
243 | + core_carregando("ativa"); | ||
244 | + core_carregando(" gravando o registro do id= "+id); | ||
245 | + sUrl = "../php/menutemas.php?funcao=alteraGrupos"+par; | ||
246 | + callback = { | ||
247 | + success:function(o){ | ||
248 | + try { | ||
249 | + if(YAHOO.lang.JSON.parse(o.responseText) == "erro") { | ||
250 | + core_carregando("<span style=color:red >Não foi possível excluir. Verifique se não existem registros vinculados</span>"); | ||
251 | + setTimeout("core_carregando('desativa')",3000); | ||
252 | + } | ||
253 | + else{ | ||
254 | + var rec = i3GEOadmin.grupos.dataTable.getRecordSet().getRecord(recordid); | ||
255 | + i3GEOadmin.grupos.dataTable.updateRow(rec,YAHOO.lang.JSON.parse(o.responseText)[0]); | ||
256 | + core_carregando("desativa"); | ||
257 | + } | ||
258 | + } | ||
259 | + catch(e){core_handleFailure(e,o.responseText);} | ||
260 | + }, | ||
261 | + failure:core_handleFailure, | ||
262 | + argument: { foo:"foo", bar:"bar" } | ||
263 | + }; | ||
264 | + core_makeRequest(sUrl,callback); | ||
265 | + } | ||
266 | +}; | ||
194 | \ No newline at end of file | 267 | \ No newline at end of file |
admin/js/menu.js
@@ -36,251 +36,229 @@ Inicializa o editor | @@ -36,251 +36,229 @@ Inicializa o editor | ||
36 | 36 | ||
37 | <ALTERAMENUS> | 37 | <ALTERAMENUS> |
38 | */ | 38 | */ |
39 | -function initEditorMenu() | ||
40 | -{ | ||
41 | - YAHOO.namespace("admin.container"); | ||
42 | - core_ativaBotaoAdicionaLinha("../php/menutemas.php?funcao=alteraMenus&publicado_menu=&perfil=&nome=&desc=&id=&aberto=","adicionaNovoMenu","pegaMenus_M"); | ||
43 | - pegaMenus_M(); | 39 | +if(typeof(i3GEOadmin) === 'undefined'){ |
40 | + var i3GEOadmin = {}; | ||
44 | } | 41 | } |
45 | -/* | ||
46 | -Function: pegaMenus_M | ||
47 | - | ||
48 | -Obtém a lista de menus | ||
49 | - | ||
50 | -<PEGAMENUS> | ||
51 | -*/ | ||
52 | -function pegaMenus_M() | ||
53 | -{ | ||
54 | - dados_M = ""; | ||
55 | - core_carregando("ativa"); | ||
56 | - core_pegaDados("buscando menus...","../php/menutemas.php?funcao=pegaMenus","montaTabela_M"); | ||
57 | -} | ||
58 | -function filtraDadosLetras_M(letra){ | ||
59 | - var i,temp, | ||
60 | - n = dados_M.length, | ||
61 | - novo = []; | ||
62 | - if(letra == "Todos"){ | ||
63 | - novo = dados_M; | ||
64 | - } | ||
65 | - else{ | ||
66 | - for(i=0;i<n;i++){ | ||
67 | - temp = dados_M[i].nome_menu; | ||
68 | - if(temp.charAt(0).toUpperCase() == letra.toUpperCase()){ | ||
69 | - novo.push(dados_M[i]); | ||
70 | - } | 42 | +i3GEOadmin.menus = { |
43 | + dados: "", | ||
44 | + dataTable: null, | ||
45 | + colunas: ["it","es","en","publicado_menu","perfil_menu","aberto","desc_menu","id_menu","nome_menu"], | ||
46 | + formatTexto: function(elCell, oRecord, oColumn, oData){ | ||
47 | + if(oData === ""){ | ||
48 | + oData = "<span style='color:gray' ></span>"; | ||
71 | } | 49 | } |
72 | - } | ||
73 | - montaTabela_M(novo); | ||
74 | -} | ||
75 | -function montaTabela_M(dados) | ||
76 | -{ | ||
77 | - if(dados_M == ""){ | ||
78 | - dados_M = dados; | ||
79 | - } | ||
80 | - core_listaDeLetras("letras_M","filtraDadosLetras_M"); | ||
81 | - YAHOO.example.InlineCellEditing = new function() | ||
82 | - { | ||
83 | - // Custom formatter for "address" column to preserve line breaks | ||
84 | - var formatTexto = function(elCell, oRecord, oColumn, oData) | ||
85 | - { | ||
86 | - if(oData === ""){ | ||
87 | - oData = "<span style='color:gray' ></span>"; | ||
88 | - } | ||
89 | - elCell.innerHTML = "<pre ><p style=cursor:pointer title='clique para editar'>" + oData + "</pre>"; | ||
90 | - }; | ||
91 | - var formatExclui = function(elCell, oRecord, oColumn) | ||
92 | - { | ||
93 | - elCell.innerHTML = "<div class=excluir title='exclui' style='text-align:center' ></div>";//onclick='excluiLinha_M(\""+oRecord.getData("id_menu")+"\",\""+oRecord.getId()+"\")'></div>"; | ||
94 | - }; | ||
95 | - var formatMais = function(elCell, oRecord, oColumn) | ||
96 | - { | ||
97 | - elCell.innerHTML = "<div class=editar style='text-align:center' ></div>"; | ||
98 | - }; | ||
99 | - var myColumnDefs = [ | ||
100 | - {key:"excluir",label:"excluir",formatter:formatExclui}, | ||
101 | - {key:"mais",label:"editar",formatter:formatMais}, | ||
102 | - {label:"id",key:"id_menu", formatter:formatTexto}, | ||
103 | - {label:"nome padrão do menu",resizeable:true,key:"nome_menu", formatter:formatTexto,editor:new YAHOO.widget.TextboxCellEditor({disableBtns:true})}, | ||
104 | - {label:"nome em inglês (opcional)",resizeable:true,key:"en", formatter:formatTexto,editor:new YAHOO.widget.TextboxCellEditor({disableBtns:true})}, | ||
105 | - {label:"nome em espanhol (opcional)",resizeable:true,key:"es", formatter:formatTexto,editor:new YAHOO.widget.TextboxCellEditor({disableBtns:true})}, | ||
106 | - {label:"nome em italiano (opcional)",resizeable:true,key:"it", formatter:formatTexto,editor:new YAHOO.widget.TextboxCellEditor({disableBtns:true})}, | ||
107 | - {label:"publicado para todos verem?",key:"publicado_menu",editor:"radio" ,editorOptions:{radioOptions:["SIM","NAO"],disableBtns:false,LABEL_SAVE:"OK"}}, | ||
108 | - {label:"perfis",resizeable:true,key:"perfil_menu", formatter:formatTexto,editor:"textbox",editorOptions:{LABEL_SAVE:"OK"}}, | ||
109 | - {label:"inicia aberto?",key:"aberto", editor:"radio" ,editorOptions:{radioOptions:["SIM","NAO"],disableBtns:false,LABEL_SAVE:"OK"}}, | ||
110 | - {label:"descrição",resizeable:true,key:"desc_menu", formatter:formatTexto,editor:new YAHOO.widget.TextboxCellEditor({disableBtns:true})} | 50 | + elCell.innerHTML = "<pre ><p style=cursor:default >" + oData + "</pre>"; |
51 | + }, | ||
52 | + formatExclui: function(elCell, oRecord, oColumn){ | ||
53 | + elCell.innerHTML = "<div class=excluir title='exclui' style='text-align:center' ></div>"; | ||
54 | + }, | ||
55 | + formatMais: function(elCell, oRecord, oColumn){ | ||
56 | + elCell.innerHTML = "<div class=editar style='text-align:center' ></div>"; | ||
57 | + }, | ||
58 | + defColunas: function(){ | ||
59 | + return [ | ||
60 | + {key:"excluir",label:"excluir",formatter:i3GEOadmin.menus.formatExclui}, | ||
61 | + {key:"mais",label:"editar",formatter:i3GEOadmin.menus.formatMais}, | ||
62 | + {label:"id",key:"id_menu", formatter:i3GEOadmin.menus.formatTexto}, | ||
63 | + {label:"nome padrão do menu",resizeable:true,key:"nome_menu", formatter:i3GEOadmin.menus.formatTexto}, | ||
64 | + {label:"nome em inglês (opcional)",resizeable:true,key:"en", formatter:i3GEOadmin.menus.formatTexto}, | ||
65 | + {label:"nome em espanhol (opcional)",resizeable:true,key:"es", formatter:i3GEOadmin.menus.formatTexto}, | ||
66 | + {label:"nome em italiano (opcional)",resizeable:true,key:"it", formatter:i3GEOadmin.menus.formatTexto}, | ||
67 | + {label:"publicado para todos verem?",key:"publicado_menu", formatter:i3GEOadmin.menus.formatTexto}, | ||
68 | + {label:"perfis",resizeable:true,key:"perfil_menu", formatter:i3GEOadmin.menus.formatTexto}, | ||
69 | + {label:"inicia aberto?",key:"aberto", formatter:i3GEOadmin.menus.formatTexto}, | ||
70 | + {label:"descrição",resizeable:true,key:"desc_menu", formatter:i3GEOadmin.menus.formatTexto} | ||
111 | ]; | 71 | ]; |
112 | - //YAHOO.widget.CellEditor.LABEL_SAVE = "Aplicar"; | ||
113 | - myDataSource = new YAHOO.util.DataSource(dados); | ||
114 | - myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY; | ||
115 | - myDataSource.responseSchema = | ||
116 | - { | ||
117 | - fields: ["it","es","en","publicado_menu","perfil_menu","aberto","desc_menu","id_menu","nome_menu"] | 72 | + }, |
73 | + /* | ||
74 | + * Inicializa o menu | ||
75 | + */ | ||
76 | + inicia: function(){ | ||
77 | + YAHOO.namespace("menus"); | ||
78 | + core_ativaBotaoAdicionaLinha("../php/menutemas.php?funcao=alteraMenus&publicado_menu=&perfil=&nome=&desc=&id=&aberto=","adicionaNovoMenu","i3GEOadmin.menus.obtem"); | ||
79 | + i3GEOadmin.menus.obtem(); | ||
80 | + }, | ||
81 | + /* | ||
82 | + * Obtém a lista de menus | ||
83 | + */ | ||
84 | + obtem: function(){ | ||
85 | + i3GEOadmin.menus.dados = ""; | ||
86 | + core_carregando("ativa"); | ||
87 | + core_pegaDados("buscando menus...","../php/menutemas.php?funcao=pegaMenus","i3GEOadmin.menus.tabela"); | ||
88 | + }, | ||
89 | + tabela: function(dados){ | ||
90 | + if(i3GEOadmin.menus.dados == ""){ | ||
91 | + i3GEOadmin.menus.dados = dados; | ||
92 | + } | ||
93 | + core_listaDeLetras("letras_M","i3GEOadmin.menus.filtra"); | ||
94 | + YAHOO.example.InlineCellEditing = new function(){ | ||
95 | + // Custom formatter for "address" column to preserve line breaks | ||
96 | + var myDataSource = new YAHOO.util.DataSource(dados); | ||
97 | + myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY; | ||
98 | + myDataSource.responseSchema = { | ||
99 | + fields: i3GEOadmin.menus.colunas | ||
100 | + }; | ||
101 | + i3GEOadmin.menus.dataTable = new YAHOO.widget.DataTable("tabela", i3GEOadmin.menus.defColunas(), myDataSource); | ||
102 | + i3GEOadmin.menus.dataTable.subscribe('cellClickEvent',function(ev){ | ||
103 | + var sUrl, callback,$clicouId, $recordid, | ||
104 | + target = YAHOO.util.Event.getTarget(ev), | ||
105 | + column = this.getColumn(target), | ||
106 | + registro = this.getRecord(target); | ||
107 | + if(YAHOO.menus.panelCK) { | ||
108 | + YAHOO.menus.panelCK.destroy(); | ||
109 | + YAHOO.menus.panelCK = null; | ||
110 | + } | ||
111 | + if (column.key == 'excluir'){ | ||
112 | + i3GEOadmin.menus.exclui(registro.getData('id_menu'),target); | ||
113 | + } | ||
114 | + if (column.key == 'mais'){ | ||
115 | + core_carregando("ativa"); | ||
116 | + core_carregando("buscando dados..."); | ||
117 | + $clicouId = registro.getData('id_menu'); | ||
118 | + $recordid = registro.getId(); | ||
119 | + sUrl = "../php/menutemas.php?funcao=pegamenus&id_menu="+$clicouId; | ||
120 | + callback = { | ||
121 | + success:function(o){ | ||
122 | + try{ | ||
123 | + i3GEOadmin.menus.editor(YAHOO.lang.JSON.parse(o.responseText),$clicouId,$recordid); | ||
124 | + } | ||
125 | + catch(e){core_handleFailure(e,o.responseText);} | ||
126 | + }, | ||
127 | + failure:core_handleFailure, | ||
128 | + argument: { foo:"foo", bar:"bar" } | ||
129 | + }; | ||
130 | + core_makeRequest(sUrl,callback); | ||
131 | + } | ||
132 | + }); | ||
118 | }; | 133 | }; |
119 | - myDataTable = new YAHOO.widget.DataTable("tabela", myColumnDefs, myDataSource); | ||
120 | - myDataTable.subscribe('cellClickEvent',function(ev) | ||
121 | - { | ||
122 | - var target = YAHOO.util.Event.getTarget(ev); | ||
123 | - var column = this.getColumn(target); | ||
124 | - if(YAHOO.admin.container.panelCK) | ||
125 | - { | ||
126 | - YAHOO.admin.container.panelCK.destroy(); | ||
127 | - YAHOO.admin.container.panelCK = null; | 134 | + core_carregando("desativa"); |
135 | + }, | ||
136 | + editor: function(dados,id,recordid){ | ||
137 | + function on_editorCheckBoxChange(p_oEvent){ | ||
138 | + if(p_oEvent.newValue.get("value") == "OK"){ | ||
139 | + i3GEOadmin.menus.salva(id,recordid); | ||
128 | } | 140 | } |
129 | - if (column.key == 'excluir') | ||
130 | - { | ||
131 | - var record = this.getRecord(target); | ||
132 | - excluiLinha_M(record.getData('id_menu'),target); | 141 | + YAHOO.menus.panelEditor2.destroy(); |
142 | + YAHOO.menus.panelEditor2 = null; | ||
143 | + }; | ||
144 | + if(!$i("janela_editor2")){ | ||
145 | + var editorBotoes,ins, | ||
146 | + novoel = document.createElement("div"); | ||
147 | + novoel.id = "janela_editor2"; | ||
148 | + ins = '<div class="hd">Editor</div>'; | ||
149 | + ins += "<div class='bd' style='height:354px;overflow:auto'>"; | ||
150 | + ins += "<div id='okcancel_checkbox2'></div><div id='editor_bd2'></div>"; | ||
151 | + ins += "<div id='letras_M'></div>"; | ||
152 | + novoel.innerHTML = ins; | ||
153 | + | ||
154 | + document.body.appendChild(novoel); | ||
155 | + editorBotoes = new YAHOO.widget.ButtonGroup({id:"okcancel_checkbox_id2", name: "okcancel_checkbox_id2", container: "okcancel_checkbox2" }); | ||
156 | + editorBotoes.addButtons([ | ||
157 | + { label: "Salva", value: "OK", checked: false}, | ||
158 | + { label: "Cancela", value: "CANCEL", checked: false } | ||
159 | + ]); | ||
160 | + editorBotoes.on("checkedButtonChange", on_editorCheckBoxChange); | ||
161 | + YAHOO.menus.panelEditor2 = new YAHOO.widget.Panel("janela_editor2", { modal:true,fixedcenter:true,close:false,width:"400px", height:"480px",overflow:"auto", visible:false,constraintoviewport:true } ); | ||
162 | + YAHOO.menus.panelEditor2.render(); | ||
163 | + } | ||
164 | + YAHOO.menus.panelEditor2.show(); | ||
165 | + $i("editor_bd2").innerHTML = i3GEOadmin.menus.formulario(dados[0]); | ||
166 | + core_carregando("desativa"); | ||
167 | + }, | ||
168 | + formulario: function(i){ | ||
169 | + var param = { | ||
170 | + "linhas":[ | ||
171 | + {titulo:"Nome padrão:",id:"Enome_menu",size:"50",value:i.nome_menu,tipo:"text",div:""}, | ||
172 | + {titulo:"Descricao (opcional):",id:"Edesc_menu",size:"50",value:i.desc_menu,tipo:"text",div:""}, | ||
173 | + {titulo:"Nome em inglês (opcional):",id:"Een",size:"50",value:i.en,tipo:"text",div:""}, | ||
174 | + {titulo:"Espanhol (opcional):",id:"Ees",size:"50",value:i.es,tipo:"text",div:""}, | ||
175 | + {titulo:"Italiano (opcional):",id:"Eit",size:"50",value:i.it,tipo:"text",div:""}, | ||
176 | + {titulo:"Perfis (opcional):",id:"Eperfil_menu",size:"50",value:i.perfil_menu,tipo:"text",div:""} | ||
177 | + ] | ||
178 | + }, | ||
179 | + ins = ""; | ||
180 | + ins += core_geraLinhas(param); | ||
181 | + ins += "<p>Publicado para todos verem?<br>"; | ||
182 | + ins += "<select id='Epublicado_menu' />"; | ||
183 | + ins += "<option value='' "; | ||
184 | + if (i.publicado_menu == ""){ins += "selected";} | ||
185 | + ins += ">---</option>"; | ||
186 | + ins += "<option value='SIM' "; | ||
187 | + if ((i.publicado_menu).toLowerCase() == "sim"){ins += "selected";} | ||
188 | + ins += " >sim</option>"; | ||
189 | + ins += "<option value='NAO' "; | ||
190 | + if ((i.publicado_menu).toLowerCase() == "nao"){ins += "selected";} | ||
191 | + ins += " >não</option>"; | ||
192 | + ins += "</select></p>"; | ||
193 | + ins += "<p>Inicia aberto na árvore?<br>"; | ||
194 | + ins += "<select id='Eaberto' />"; | ||
195 | + ins += "<option value='' "; | ||
196 | + if (i.aberto == ""){ins += "selected";} | ||
197 | + ins += ">---</option>"; | ||
198 | + ins += "<option value='SIM' "; | ||
199 | + if ((i.aberto).toLowerCase() == "sim"){ins += "selected";} | ||
200 | + ins += " >sim</option>"; | ||
201 | + ins += "<option value='NAO' "; | ||
202 | + if ((i.aberto).toLowerCase() == "nao"){ins += "selected";} | ||
203 | + ins += " >não</option>"; | ||
204 | + ins += "</select></p>"; | ||
205 | + return(ins); | ||
206 | + }, | ||
207 | + filtra: function(letra){ | ||
208 | + var i,temp, | ||
209 | + n = i3GEOadmin.menus.dados.length, | ||
210 | + novo = []; | ||
211 | + if(letra == "Todos"){ | ||
212 | + novo = i3GEOadmin.menus.dados; | ||
213 | + } | ||
214 | + else{ | ||
215 | + for(i=0;i<n;i++){ | ||
216 | + temp = i3GEOadmin.menus.dados[i].nome_menu; | ||
217 | + if(temp.charAt(0).toUpperCase() == letra.toUpperCase()){ | ||
218 | + novo.push(i3GEOadmin.menus.dados[i]); | ||
219 | + } | ||
133 | } | 220 | } |
134 | - if (column.key == 'mais') | ||
135 | - { | ||
136 | - var record = this.getRecord(target); | ||
137 | - core_carregando("ativa"); | ||
138 | - core_carregando("buscando dados..."); | ||
139 | - $clicouId = record.getData('id_menu'); | ||
140 | - $recordid = record.getId(); | ||
141 | - var sUrl = "../php/menutemas.php?funcao=pegamenus&id_menu="+record.getData('id_menu'); | ||
142 | - var callback = | ||
143 | - { | ||
144 | - success:function(o) | ||
145 | - { | ||
146 | - try | ||
147 | - { | ||
148 | - montaEditor_M(YAHOO.lang.JSON.parse(o.responseText),$clicouId,$recordid); | ||
149 | - } | ||
150 | - catch(e){core_handleFailure(e,o.responseText);} | ||
151 | - }, | ||
152 | - failure:core_handleFailure, | ||
153 | - argument: { foo:"foo", bar:"bar" } | ||
154 | - }; | ||
155 | - core_makeRequest(sUrl,callback); | 221 | + } |
222 | + i3GEOadmin.menus.tabela(novo); | ||
223 | + }, | ||
224 | + exclui: function(id,row){ | ||
225 | + var mensagem = " excluindo o registro do id= "+id, | ||
226 | + sUrl = "../php/menutemas.php?funcao=excluirRegistro&id="+id+"&tabela=menus"; | ||
227 | + core_excluiLinha(sUrl,row,mensagem,"",i3GEOadmin.menus.dataTable); | ||
228 | + }, | ||
229 | + salva: function(id,recordid){ | ||
230 | + var i,c,sUrl, callback, | ||
231 | + campos = i3GEOadmin.menus.colunas, | ||
232 | + par = "", | ||
233 | + n = campos.length; | ||
234 | + for (i=0;i<n;i++){ | ||
235 | + c = $i("E"+campos[i].key); | ||
236 | + if(c){ | ||
237 | + par += "&"+campos[i].key+"="+(c.value); | ||
156 | } | 238 | } |
157 | - }); | ||
158 | - }; | ||
159 | - core_carregando("desativa"); | ||
160 | -} | ||
161 | -function montaEditor_M(dados,id,recordid) | ||
162 | -{ | ||
163 | - function on_editorCheckBoxChange(p_oEvent) | ||
164 | - { | ||
165 | - if(p_oEvent.newValue.get("value") == "OK") | ||
166 | - { | ||
167 | - gravaDados_M(id,recordid); | ||
168 | } | 239 | } |
169 | - YAHOO.admin.container.panelEditor2.destroy(); | ||
170 | - YAHOO.admin.container.panelEditor2 = null; | ||
171 | - }; | ||
172 | - if(!$i("janela_editor2")) | ||
173 | - { | ||
174 | - var novoel = document.createElement("div"); | ||
175 | - novoel.id = "janela_editor2"; | ||
176 | - var ins = '<div class="hd">Editor</div>'; | ||
177 | - ins += "<div class='bd' style='height:354px;overflow:auto'>"; | ||
178 | - ins += "<div id='okcancel_checkbox2'></div><div id='editor_bd2'></div>"; | ||
179 | - ins += "<div id='letras_M'></div>"; | ||
180 | - novoel.innerHTML = ins; | ||
181 | - | ||
182 | - document.body.appendChild(novoel); | ||
183 | - var editorBotoes = new YAHOO.widget.ButtonGroup({id:"okcancel_checkbox_id2", name: "okcancel_checkbox_id2", container: "okcancel_checkbox2" }); | ||
184 | - editorBotoes.addButtons([ | ||
185 | - { label: "Salva", value: "OK", checked: false}, | ||
186 | - { label: "Cancela", value: "CANCEL", checked: false } | ||
187 | - ]); | ||
188 | - editorBotoes.on("checkedButtonChange", on_editorCheckBoxChange); | ||
189 | - YAHOO.admin.container.panelEditor2 = new YAHOO.widget.Panel("janela_editor2", { fixedcenter:true,close:false,width:"400px", height:"480px",overflow:"auto", visible:false,constraintoviewport:true } ); | ||
190 | - YAHOO.admin.container.panelEditor2.render(); | ||
191 | - } | ||
192 | - YAHOO.admin.container.panelEditor2.show(); | ||
193 | - $i("editor_bd2").innerHTML = montaDiv_M(dados[0]); | ||
194 | - core_carregando("desativa"); | ||
195 | -} | ||
196 | -function montaDiv_M(i) | ||
197 | -{ | ||
198 | - var param = { | ||
199 | - "linhas":[ | ||
200 | - {titulo:"Nome padrão:",id:"Enome_menu",size:"50",value:i.nome_menu,tipo:"text",div:""}, | ||
201 | - {titulo:"Descricao (opcional):",id:"Edesc_menu",size:"50",value:i.desc_menu,tipo:"text",div:""}, | ||
202 | - {titulo:"Nome em inglês (opcional):",id:"Een",size:"50",value:i.en,tipo:"text",div:""}, | ||
203 | - {titulo:"Espanhol (opcional):",id:"Ees",size:"50",value:i.es,tipo:"text",div:""}, | ||
204 | - {titulo:"Italiano (opcional):",id:"Eit",size:"50",value:i.it,tipo:"text",div:""}, | ||
205 | - {titulo:"Perfis (opcional):",id:"Eperfil_menu",size:"50",value:i.perfil_menu,tipo:"text",div:""} | ||
206 | - ] | ||
207 | - }; | ||
208 | - var ins = ""; | ||
209 | - ins += core_geraLinhas(param); | ||
210 | - ins += "<p>Publicado para todos verem?<br>"; | ||
211 | - ins += "<select id='Epublicado_menu' />"; | ||
212 | - ins += "<option value='' "; | ||
213 | - if (i.publicado_menu == ""){ins += "selected";} | ||
214 | - ins += ">---</option>"; | ||
215 | - ins += "<option value='SIM' "; | ||
216 | - if ((i.publicado_menu).toLowerCase() == "sim"){ins += "selected";} | ||
217 | - ins += " >sim</option>"; | ||
218 | - ins += "<option value='NAO' "; | ||
219 | - if ((i.publicado_menu).toLowerCase() == "nao"){ins += "selected";} | ||
220 | - ins += " >não</option>"; | ||
221 | - ins += "</select></p>"; | ||
222 | - ins += "<p>Inicia aberto na árvore?<br>"; | ||
223 | - ins += "<select id='Eaberto' />"; | ||
224 | - ins += "<option value='' "; | ||
225 | - if (i.aberto == ""){ins += "selected";} | ||
226 | - ins += ">---</option>"; | ||
227 | - ins += "<option value='SIM' "; | ||
228 | - if ((i.aberto).toLowerCase() == "sim"){ins += "selected";} | ||
229 | - ins += " >sim</option>"; | ||
230 | - ins += "<option value='NAO' "; | ||
231 | - if ((i.aberto).toLowerCase() == "nao"){ins += "selected";} | ||
232 | - ins += " >não</option>"; | ||
233 | - ins += "</select></p>"; | ||
234 | - return(ins); | ||
235 | -} | ||
236 | -/* | ||
237 | -Function: gravaDados_M | ||
238 | - | ||
239 | -Salva as alterações feitas | ||
240 | - | ||
241 | -<ALTERAMENUS> | ||
242 | -*/ | ||
243 | -function gravaDados_M(id,recordid) | ||
244 | -{ | ||
245 | - var campos = new Array("publicado_menu","perfil_menu","nome_menu","desc_menu","aberto","en","es","it"); | ||
246 | - var par = ""; | ||
247 | - for (var i=0;i<campos.length;i++) | ||
248 | - { | ||
249 | - par += "&"+campos[i]+"="+($i("E"+campos[i]).value); | 240 | + par += "&id_menu="+id; |
241 | + core_carregando("ativa"); | ||
242 | + core_carregando(" gravando o registro do id= "+id); | ||
243 | + sUrl = "../php/menutemas.php?funcao=alteraMenus"+par; | ||
244 | + callback = { | ||
245 | + success:function(o){ | ||
246 | + try { | ||
247 | + if(YAHOO.lang.JSON.parse(o.responseText) == "erro") { | ||
248 | + core_carregando("<span style=color:red >Não foi possível excluir. Verifique se não existem registros vinculados</span>"); | ||
249 | + setTimeout("core_carregando('desativa')",3000); | ||
250 | + } | ||
251 | + else{ | ||
252 | + var rec = i3GEOadmin.menus.dataTable.getRecordSet().getRecord(recordid); | ||
253 | + i3GEOadmin.menus.dataTable.updateRow(rec,YAHOO.lang.JSON.parse(o.responseText)[0]); | ||
254 | + core_carregando("desativa"); | ||
255 | + } | ||
256 | + } | ||
257 | + catch(e){core_handleFailure(e,o.responseText);} | ||
258 | + }, | ||
259 | + failure:core_handleFailure, | ||
260 | + argument: { foo:"foo", bar:"bar" } | ||
261 | + }; | ||
262 | + core_makeRequest(sUrl,callback); | ||
250 | } | 263 | } |
251 | - par += "&id_menu="+id; | ||
252 | - core_carregando("ativa"); | ||
253 | - core_carregando(" gravando o registro do id= "+id); | ||
254 | - var sUrl = "../php/menutemas.php?funcao=alteraMenus"+par; | ||
255 | - var callback = | ||
256 | - { | ||
257 | - success:function(o) | ||
258 | - { | ||
259 | - try | ||
260 | - { | ||
261 | - if(YAHOO.lang.JSON.parse(o.responseText) == "erro") | ||
262 | - { | ||
263 | - core_carregando("<span style=color:red >Não foi possível excluir. Verifique se não existem registros vinculados</span>"); | ||
264 | - setTimeout("core_carregando('desativa')",3000); | ||
265 | - } | ||
266 | - else | ||
267 | - { | ||
268 | - var rec = myDataTable.getRecordSet().getRecord(recordid); | ||
269 | - myDataTable.updateRow(rec,YAHOO.lang.JSON.parse(o.responseText)[0]); | ||
270 | - core_carregando("desativa"); | ||
271 | - } | ||
272 | - } | ||
273 | - catch(e){core_handleFailure(e,o.responseText);} | ||
274 | - }, | ||
275 | - failure:core_handleFailure, | ||
276 | - argument: { foo:"foo", bar:"bar" } | ||
277 | - }; | ||
278 | - core_makeRequest(sUrl,callback); | ||
279 | -} | ||
280 | -function excluiLinha_M(id,row) | ||
281 | -{ | ||
282 | - var mensagem = " excluindo o registro do id= "+id; | ||
283 | - var sUrl = "../php/menutemas.php?funcao=excluirRegistro&id="+id+"&tabela=menus"; | ||
284 | - core_excluiLinha(sUrl,row,mensagem); | ||
285 | -} | ||
286 | -//YAHOO.util.Event.addListener(window, "load", initMenu); | ||
287 | \ No newline at end of file | 264 | \ No newline at end of file |
265 | +}; | ||
288 | \ No newline at end of file | 266 | \ No newline at end of file |
admin/php/menutemas.php
@@ -80,8 +80,8 @@ switch (strtoupper($funcao)) | @@ -80,8 +80,8 @@ switch (strtoupper($funcao)) | ||
80 | { | 80 | { |
81 | $dados = pegaDados("SELECT * from ".$esquemaadmin."i3geoadmin_menus where id_menu = $id_menu order by nome_menu"); | 81 | $dados = pegaDados("SELECT * from ".$esquemaadmin."i3geoadmin_menus where id_menu = $id_menu order by nome_menu"); |
82 | } | 82 | } |
83 | - else | ||
84 | - {$dados = pegaDados("SELECT * from ".$esquemaadmin."i3geoadmin_menus order by nome_menu"); | 83 | + else{ |
84 | + $dados = pegaDados("SELECT * from ".$esquemaadmin."i3geoadmin_menus order by nome_menu"); | ||
85 | } | 85 | } |
86 | retornaJSON($dados); | 86 | retornaJSON($dados); |
87 | exit; | 87 | exit; |
@@ -237,12 +237,13 @@ switch (strtoupper($funcao)) | @@ -237,12 +237,13 @@ switch (strtoupper($funcao)) | ||
237 | {JSON} | 237 | {JSON} |
238 | */ | 238 | */ |
239 | case "PEGAGRUPOS": | 239 | case "PEGAGRUPOS": |
240 | - $nome = "nome_grupo"; | ||
241 | - if($idioma != "pt") | 240 | + if(isset($id_grupo) && $id_grupo != "") |
242 | { | 241 | { |
243 | - $nome = $idioma; | 242 | + $dados = pegaDados("SELECT * from ".$esquemaadmin."i3geoadmin_grupos WHERE id_grupo = $id_grupo order by nome_grupo"); |
243 | + } | ||
244 | + else{ | ||
245 | + $dados = pegaDados("SELECT * from ".$esquemaadmin."i3geoadmin_grupos order by nome_grupo"); | ||
244 | } | 246 | } |
245 | - $dados = pegaDados("SELECT * from ".$esquemaadmin."i3geoadmin_grupos order by $nome"); | ||
246 | retornaJSON($dados); | 247 | retornaJSON($dados); |
247 | exit; | 248 | exit; |
248 | break; | 249 | break; |
@@ -257,8 +258,7 @@ switch (strtoupper($funcao)) | @@ -257,8 +258,7 @@ switch (strtoupper($funcao)) | ||
257 | */ | 258 | */ |
258 | case "PEGAGRUPOS2": | 259 | case "PEGAGRUPOS2": |
259 | $nome = "nome_grupo"; | 260 | $nome = "nome_grupo"; |
260 | - if($idioma != "pt") | ||
261 | - { | 261 | + if($idioma != "pt"){ |
262 | $nome = $idioma; | 262 | $nome = $idioma; |
263 | } | 263 | } |
264 | $dados = pegaDados("SELECT desc_grupo,id_grupo,$nome as 'nome_grupo' from ".$esquemaadmin."i3geoadmin_grupos order by $nome"); | 264 | $dados = pegaDados("SELECT desc_grupo,id_grupo,$nome as 'nome_grupo' from ".$esquemaadmin."i3geoadmin_grupos order by $nome"); |
@@ -289,7 +289,13 @@ switch (strtoupper($funcao)) | @@ -289,7 +289,13 @@ switch (strtoupper($funcao)) | ||
289 | {JSON} | 289 | {JSON} |
290 | */ | 290 | */ |
291 | case "ALTERAGRUPOS": | 291 | case "ALTERAGRUPOS": |
292 | - retornaJSON(alteraGrupos()); | 292 | + alteraGrupos(); |
293 | + if(isset($id_grupo) && $id_grupo != "") { | ||
294 | + retornaJSON(pegaDados("SELECT * from ".$esquemaadmin."i3geoadmin_grupos WHERE id_grupo = $id_grupo")); | ||
295 | + } | ||
296 | + else{ | ||
297 | + retornaJSON("ok"); | ||
298 | + } | ||
293 | exit; | 299 | exit; |
294 | break; | 300 | break; |
295 | /* | 301 | /* |
@@ -811,6 +817,9 @@ function alteraMenus() | @@ -811,6 +817,9 @@ function alteraMenus() | ||
811 | { | 817 | { |
812 | $nome_menu = utf8_encode($nome_menu); | 818 | $nome_menu = utf8_encode($nome_menu); |
813 | $desc_menu = utf8_encode($desc_menu); | 819 | $desc_menu = utf8_encode($desc_menu); |
820 | + $en = utf8_encode($en); | ||
821 | + $es = utf8_encode($es); | ||
822 | + $it = utf8_encode($it); | ||
814 | } | 823 | } |
815 | if($id_menu != "") | 824 | if($id_menu != "") |
816 | { | 825 | { |
@@ -985,18 +994,21 @@ function alteraTags() | @@ -985,18 +994,21 @@ function alteraTags() | ||
985 | */ | 994 | */ |
986 | function alteraGrupos() | 995 | function alteraGrupos() |
987 | { | 996 | { |
988 | - global $nome,$desc,$id,$en,$es,$it,$esquemaadmin; | 997 | + global $nome_grupo,$desc_grupo,$id_grupo,$en,$es,$it,$esquemaadmin; |
989 | try | 998 | try |
990 | { | 999 | { |
991 | - include("conexao.php"); | 1000 | + require_once("conexao.php"); |
992 | if($convUTF) | 1001 | if($convUTF) |
993 | { | 1002 | { |
994 | - $nome = utf8_encode($nome); | ||
995 | - $desc = utf8_encode($desc); | 1003 | + $nome_grupo = utf8_encode($nome_grupo); |
1004 | + $desc_grupo = utf8_encode($desc_grupo); | ||
1005 | + $en = utf8_encode($en); | ||
1006 | + $es = utf8_encode($es); | ||
1007 | + $it = utf8_encode($it); | ||
996 | } | 1008 | } |
997 | - if($id != "") | 1009 | + if($id_grupo != "") |
998 | { | 1010 | { |
999 | - $dbhw->query("UPDATE ".$esquemaadmin."i3geoadmin_grupos SET en = '$en', es = '$es', it = '$it', nome_grupo = '$nome', desc_grupo = '$desc' WHERE id_grupo = $id"); | 1011 | + $dbhw->query("UPDATE ".$esquemaadmin."i3geoadmin_grupos SET en = '$en', es = '$es', it = '$it', nome_grupo = '$nome_grupo', desc_grupo = '$desc_grupo' WHERE id_grupo = $id_grupo"); |
1000 | } | 1012 | } |
1001 | else | 1013 | else |
1002 | { | 1014 | { |
@@ -1024,6 +1036,9 @@ function alteraSubGrupos() | @@ -1024,6 +1036,9 @@ function alteraSubGrupos() | ||
1024 | { | 1036 | { |
1025 | $nome = utf8_encode($nome); | 1037 | $nome = utf8_encode($nome); |
1026 | $desc = utf8_encode($desc); | 1038 | $desc = utf8_encode($desc); |
1039 | + $en = utf8_encode($en); | ||
1040 | + $es = utf8_encode($es); | ||
1041 | + $it = utf8_encode($it); | ||
1027 | } | 1042 | } |
1028 | $retorna = ""; | 1043 | $retorna = ""; |
1029 | if($id != "") | 1044 | if($id != "") |
@@ -1085,6 +1100,9 @@ function alteraTemas() | @@ -1085,6 +1100,9 @@ function alteraTemas() | ||
1085 | $nome = utf8_encode($nome); | 1100 | $nome = utf8_encode($nome); |
1086 | $desc = utf8_encode($desc); | 1101 | $desc = utf8_encode($desc); |
1087 | $tags = utf8_encode($tags); | 1102 | $tags = utf8_encode($tags); |
1103 | + $en = utf8_encode($en); | ||
1104 | + $es = utf8_encode($es); | ||
1105 | + $it = utf8_encode($it); | ||
1088 | } | 1106 | } |
1089 | if($id != "") | 1107 | if($id != "") |
1090 | { | 1108 | { |