Commit 13cd345bdd7180033c10da462f44b58bcb50a33e
1 parent
099dd342
Exists in
master
Refactoring para coding standards
Showing
1 changed file
with
291 additions
and
290 deletions
Show diff stats
ieducar/intranet/educar_servidor_nivel_cad.php
1 | <?php | 1 | <?php |
2 | -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
3 | - * * | ||
4 | - * @author Prefeitura Municipal de Itajaí * | ||
5 | - * @updated 29/03/2007 * | ||
6 | - * Pacote: i-PLB Software Público Livre e Brasileiro * | ||
7 | - * * | ||
8 | - * Copyright (C) 2006 PMI - Prefeitura Municipal de Itajaí * | ||
9 | - * ctima@itajai.sc.gov.br * | ||
10 | - * * | ||
11 | - * Este programa é software livre, você pode redistribuí-lo e/ou * | ||
12 | - * modificá-lo sob os termos da Licença Pública Geral GNU, conforme * | ||
13 | - * publicada pela Free Software Foundation, tanto a versão 2 da * | ||
14 | - * Licença como (a seu critério) qualquer versão mais nova. * | ||
15 | - * * | ||
16 | - * Este programa é distribuído na expectativa de ser útil, mas SEM * | ||
17 | - * QUALQUER GARANTIA. Sem mesmo a garantia implícita de COMERCIALI- * | ||
18 | - * ZAÇÃO ou de ADEQUAÇÃO A QUALQUER PROPÓSITO EM PARTICULAR. Con- * | ||
19 | - * sulte a Licença Pública Geral GNU para obter mais detalhes. * | ||
20 | - * * | ||
21 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU * | ||
22 | - * junto com este programa. Se não, escreva para a Free Software * | ||
23 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * | ||
24 | - * 02111-1307, USA. * | ||
25 | - * * | ||
26 | - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
27 | - | ||
28 | -require_once ("include/clsBase.inc.php"); | ||
29 | -require_once ("include/clsCadastro.inc.php"); | ||
30 | -require_once ("include/clsBanco.inc.php"); | ||
31 | -require_once( "include/pmieducar/geral.inc.php" ); | ||
32 | 2 | ||
3 | +/** | ||
4 | + * i-Educar - Sistema de gestão escolar | ||
5 | + * | ||
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | ||
7 | + * <ctima@itajai.sc.gov.br> | ||
8 | + * | ||
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | ||
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | ||
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | ||
12 | + * qualquer versão posterior. | ||
13 | + * | ||
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | ||
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | ||
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | ||
17 | + * do GNU para mais detalhes. | ||
18 | + * | ||
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | ||
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | ||
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | + * | ||
23 | + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br> | ||
24 | + * @category i-Educar | ||
25 | + * @license @@license@@ | ||
26 | + * @package iEd_Pmieducar | ||
27 | + * @since Arquivo disponível desde a versão 1.0.0 | ||
28 | + * @version $Id$ | ||
29 | + */ | ||
30 | + | ||
31 | +require_once 'include/clsBase.inc.php'; | ||
32 | +require_once 'include/clsCadastro.inc.php'; | ||
33 | +require_once 'include/clsBanco.inc.php'; | ||
34 | +require_once 'include/pmieducar/geral.inc.php'; | ||
35 | + | ||
36 | +/** | ||
37 | + * clsIndexBase class. | ||
38 | + * | ||
39 | + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br> | ||
40 | + * @category i-Educar | ||
41 | + * @license @@license@@ | ||
42 | + * @package iEd_Pmieducar | ||
43 | + * @since Classe disponível desde a versão 1.0.0 | ||
44 | + * @version @@package_version@@ | ||
45 | + */ | ||
33 | class clsIndexBase extends clsBase | 46 | class clsIndexBase extends clsBase |
34 | { | 47 | { |
35 | - function Formular() | ||
36 | - { | ||
37 | - $this->SetTitulo( "{$this->_instituicao} i-Educar - Servidor Nível" ); | ||
38 | - $this->processoAp = "0"; | ||
39 | - $this->renderBanner = false; | ||
40 | - $this->renderMenu = false; | ||
41 | - $this->renderMenuSuspenso = false; | ||
42 | - | ||
43 | - } | 48 | + function Formular() |
49 | + { | ||
50 | + $this->SetTitulo($this->_instituicao . ' i-Educar - Servidor Nível'); | ||
51 | + $this->processoAp = 0; | ||
52 | + $this->renderBanner = FALSE; | ||
53 | + $this->renderMenu = FALSE; | ||
54 | + $this->renderMenuSuspenso = FALSE; | ||
55 | + } | ||
44 | } | 56 | } |
45 | 57 | ||
58 | +/** | ||
59 | + * indice class. | ||
60 | + * | ||
61 | + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br> | ||
62 | + * @category i-Educar | ||
63 | + * @license @@license@@ | ||
64 | + * @package iEd_Pmieducar | ||
65 | + * @since Classe disponível desde a versão 1.0.0 | ||
66 | + * @version @@package_version@@ | ||
67 | + */ | ||
46 | class indice extends clsCadastro | 68 | class indice extends clsCadastro |
47 | { | 69 | { |
48 | - /** | ||
49 | - * Referencia pega da session para o idpes do usuario atual | ||
50 | - * | ||
51 | - * @var int | ||
52 | - */ | ||
53 | - var $pessoa_logada; | ||
54 | - | ||
55 | - var $cod_servidor; | ||
56 | - var $ref_cod_instituicao; | ||
57 | - var $data_cadastro; | ||
58 | - var $data_exclusao; | ||
59 | - var $ativo; | ||
60 | - var $ref_cod_nivel; | ||
61 | - var $ref_cod_subnivel; | ||
62 | - var $ref_cod_categoria; | ||
63 | - | ||
64 | - | ||
65 | - function Inicializar() | ||
66 | - { | ||
67 | - $retorno = "Novo"; | ||
68 | - @session_start(); | ||
69 | - $this->pessoa_logada = $_SESSION['id_pessoa']; | ||
70 | - @session_write_close(); | ||
71 | - | ||
72 | - $this->cod_servidor = $_GET["ref_cod_servidor"]; | ||
73 | - $this->ref_cod_instituicao = $_GET["ref_cod_instituicao"]; | ||
74 | - | ||
75 | - | ||
76 | - $obj_permissoes = new clsPermissoes(); | ||
77 | - | ||
78 | - $obj_permissoes->permissao_cadastra( 635, $this->pessoa_logada, 3, "educar_servidor_lst.php" ); | ||
79 | - | ||
80 | - if( is_numeric( $this->cod_servidor ) && is_numeric( $this->ref_cod_instituicao ) ) | ||
81 | - { | ||
82 | - | ||
83 | - $obj = new clsPmieducarServidor( $this->cod_servidor, null, null, null, null, null, null, $this->ref_cod_instituicao ); | ||
84 | - $registro = $obj->detalhe(); | ||
85 | - if( $registro ) | ||
86 | - { | ||
87 | - $this->ref_cod_subnivel = $registro['ref_cod_subnivel']; | ||
88 | - $obj_subnivel = new clsPmieducarSubnivel($this->ref_cod_subnivel); | ||
89 | - $det_subnivel = $obj_subnivel->detalhe(); | ||
90 | - if($det_subnivel) | ||
91 | - $this->ref_cod_nivel = $det_subnivel['ref_cod_nivel']; | ||
92 | - | ||
93 | - if($this->ref_cod_nivel) | ||
94 | - { | ||
95 | - $obj_nivel = new clsPmieducarNivel($this->ref_cod_nivel); | ||
96 | - $det_nivel = $obj_nivel->detalhe(); | ||
97 | - $this->ref_cod_categoria = $det_nivel['ref_cod_categoria_nivel']; | ||
98 | - } | ||
99 | - | ||
100 | - $retorno = "Editar"; | ||
101 | - } | ||
102 | - } | ||
103 | - else | ||
104 | - { | ||
105 | - echo "<script>window.parent.fechaExpansivel( '{$_GET['div']}');</script>"; | ||
106 | - die(); | ||
107 | - } | ||
108 | - | ||
109 | - return $retorno; | ||
110 | - } | ||
111 | - | ||
112 | - function Gerar() | ||
113 | - { | ||
114 | - | ||
115 | - $this->campoOculto("cod_servidor",$this->cod_servidor); | ||
116 | - $this->campoOculto("ref_cod_instituicao",$this->ref_cod_instituicao); | ||
117 | - | ||
118 | - $obj_categoria = new clsPmieducarCategoriaNivel(); | ||
119 | - $lst_categoria = $obj_categoria->lista(null,null,null,null,null,null,null,null,1); | ||
120 | - $opcoes = array('' => 'Selecione uma categoria'); | ||
121 | - if($lst_categoria) | ||
122 | - { | ||
123 | - foreach ($lst_categoria as $categoria) | ||
124 | - { | ||
125 | - $opcoes[$categoria['cod_categoria_nivel']] = $categoria['nm_categoria_nivel']; | ||
126 | - } | ||
127 | - } | ||
128 | - | ||
129 | - $this->campoLista("ref_cod_categoria","Categoria",$opcoes,$this->ref_cod_categoria); | ||
130 | - | ||
131 | - $opcoes = array('' => 'Selecione uma categoria'); | ||
132 | - if($this->ref_cod_categoria) | ||
133 | - { | ||
134 | - $obj_nivel = new clsPmieducarNivel(); | ||
135 | - $lst_nivel = $obj_nivel->buscaSequenciaNivel($this->ref_cod_categoria); | ||
136 | - if($lst_nivel) | ||
137 | - { | ||
138 | - foreach ($lst_nivel as $nivel) | ||
139 | - { | ||
140 | - $opcoes[$nivel['cod_nivel']] = $nivel['nm_nivel']; | ||
141 | - } | ||
142 | - } | ||
143 | - } | ||
144 | - $this->campoLista("ref_cod_nivel","Nível",$opcoes,$this->ref_cod_nivel,"",true); | ||
145 | - | ||
146 | - $opcoes = array('' => 'Selecione um nível'); | ||
147 | - | ||
148 | - if($this->ref_cod_nivel) | ||
149 | - { | ||
150 | - $obj_nivel = new clsPmieducarSubnivel(); | ||
151 | - $lst_nivel = $obj_nivel->buscaSequenciaSubniveis($this->ref_cod_nivel); | ||
152 | - if($lst_nivel) | ||
153 | - { | ||
154 | - foreach ($lst_nivel as $subnivel) | ||
155 | - { | ||
156 | - $opcoes[$subnivel['cod_subnivel']] = $subnivel['nm_subnivel']; | ||
157 | - } | ||
158 | - } | ||
159 | - } | ||
160 | - | ||
161 | - $this->campoLista("ref_cod_subnivel","Subnível",$opcoes,$this->ref_cod_subnivel,"",false,"","",false,true); | ||
162 | - | ||
163 | - } | ||
164 | - | ||
165 | - function Novo() | ||
166 | - { | ||
167 | - echo "<script>window.parent.fechaExpansivel( '{$_GET['div']}');</script>"; | ||
168 | - die(); | ||
169 | - } | ||
170 | - | ||
171 | - function Editar() | ||
172 | - { | ||
173 | - | ||
174 | - $obj_servidor = new clsPmieducarServidor($this->cod_servidor,null,null,null,null,null,null,$this->ref_cod_instituicao,$this->ref_cod_subnivel); | ||
175 | - $obj_servidor->edita(); | ||
176 | - | ||
177 | - echo "<script>parent.fechaExpansivel( '{$_GET['div']}');window.parent.location.reload(true);</script>"; | ||
178 | - die; | ||
179 | - | ||
180 | - | ||
181 | - return true; | ||
182 | - } | ||
183 | - | ||
184 | - function Excluir() | ||
185 | - { | ||
186 | - | ||
187 | - return false; | ||
188 | - } | 70 | + var $pessoa_logada; |
71 | + | ||
72 | + var $cod_servidor; | ||
73 | + var $ref_cod_instituicao; | ||
74 | + var $data_cadastro; | ||
75 | + var $data_exclusao; | ||
76 | + var $ativo; | ||
77 | + var $ref_cod_nivel; | ||
78 | + var $ref_cod_subnivel; | ||
79 | + var $ref_cod_categoria; | ||
80 | + | ||
81 | + function Inicializar() | ||
82 | + { | ||
83 | + $retorno = 'Novo'; | ||
84 | + | ||
85 | + @session_start(); | ||
86 | + $this->pessoa_logada = $_SESSION['id_pessoa']; | ||
87 | + @session_write_close(); | ||
88 | + | ||
89 | + $this->cod_servidor = $_GET['ref_cod_servidor']; | ||
90 | + $this->ref_cod_instituicao = $_GET['ref_cod_instituicao']; | ||
91 | + | ||
92 | + $obj_permissoes = new clsPermissoes(); | ||
93 | + | ||
94 | + $obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 3, 'educar_servidor_lst.php'); | ||
95 | + | ||
96 | + if (is_numeric($this->cod_servidor) && is_numeric($this->ref_cod_instituicao)) { | ||
97 | + $obj = new clsPmieducarServidor($this->cod_servidor, NULL, NULL, NULL, NULL, | ||
98 | + NULL, NULL, $this->ref_cod_instituicao); | ||
99 | + | ||
100 | + $registro = $obj->detalhe(); | ||
101 | + if ($registro) { | ||
102 | + $this->ref_cod_subnivel = $registro['ref_cod_subnivel']; | ||
103 | + $obj_subnivel = new clsPmieducarSubnivel($this->ref_cod_subnivel); | ||
104 | + $det_subnivel = $obj_subnivel->detalhe(); | ||
105 | + | ||
106 | + if ($det_subnivel) { | ||
107 | + $this->ref_cod_nivel = $det_subnivel['ref_cod_nivel']; | ||
108 | + } | ||
109 | + | ||
110 | + if ($this->ref_cod_nivel) { | ||
111 | + $obj_nivel = new clsPmieducarNivel($this->ref_cod_nivel); | ||
112 | + $det_nivel = $obj_nivel->detalhe(); | ||
113 | + $this->ref_cod_categoria = $det_nivel['ref_cod_categoria_nivel']; | ||
114 | + } | ||
115 | + | ||
116 | + $retorno = 'Editar'; | ||
117 | + } | ||
118 | + } | ||
119 | + else { | ||
120 | + echo sprintf('<script>window.parent.fechaExpansivel("%s");</script>', $_GET['div']); | ||
121 | + die(); | ||
122 | + } | ||
123 | + | ||
124 | + return $retorno; | ||
125 | + } | ||
126 | + | ||
127 | + function Gerar() | ||
128 | + { | ||
129 | + $this->campoOculto('cod_servidor',$this->cod_servidor); | ||
130 | + $this->campoOculto('ref_cod_instituicao',$this->ref_cod_instituicao); | ||
131 | + | ||
132 | + $obj_categoria = new clsPmieducarCategoriaNivel(); | ||
133 | + $lst_categoria = $obj_categoria->lista(NULL, NULL, NULL, NULL, NULL, NULL, | ||
134 | + NULL, NULL, 1); | ||
135 | + | ||
136 | + $opcoes = array('' => 'Selecione uma categoria'); | ||
137 | + | ||
138 | + if ($lst_categoria) { | ||
139 | + foreach ($lst_categoria as $categoria) { | ||
140 | + $opcoes[$categoria['cod_categoria_nivel']] = $categoria['nm_categoria_nivel']; | ||
141 | + } | ||
142 | + } | ||
143 | + | ||
144 | + $this->campoLista('ref_cod_categoria', 'Categoria', $opcoes, $this->ref_cod_categoria); | ||
145 | + | ||
146 | + $opcoes = array('' => 'Selecione uma categoria'); | ||
147 | + | ||
148 | + if ($this->ref_cod_categoria) { | ||
149 | + $obj_nivel = new clsPmieducarNivel(); | ||
150 | + $lst_nivel = $obj_nivel->buscaSequenciaNivel($this->ref_cod_categoria); | ||
151 | + | ||
152 | + if ($lst_nivel) { | ||
153 | + foreach ($lst_nivel as $nivel) { | ||
154 | + $opcoes[$nivel['cod_nivel']] = $nivel['nm_nivel']; | ||
155 | + } | ||
156 | + } | ||
157 | + } | ||
158 | + | ||
159 | + $this->campoLista('ref_cod_nivel', 'Nível', $opcoes, $this->ref_cod_nivel, '', TRUE); | ||
160 | + | ||
161 | + $opcoes = array('' => 'Selecione um nível'); | ||
162 | + | ||
163 | + if ($this->ref_cod_nivel) { | ||
164 | + $obj_nivel = new clsPmieducarSubnivel(); | ||
165 | + $lst_nivel = $obj_nivel->buscaSequenciaSubniveis($this->ref_cod_nivel); | ||
166 | + if ($lst_nivel) { | ||
167 | + foreach ($lst_nivel as $subnivel) { | ||
168 | + $opcoes[$subnivel['cod_subnivel']] = $subnivel['nm_subnivel']; | ||
169 | + } | ||
170 | + } | ||
171 | + } | ||
172 | + | ||
173 | + $this->campoLista('ref_cod_subnivel', 'Subnível', $opcoes, | ||
174 | + $this->ref_cod_subnivel, '', FALSE, '', '', FALSE, TRUE); | ||
175 | + } | ||
176 | + | ||
177 | + function Novo() | ||
178 | + { | ||
179 | + echo sprintf('<script>window.parent.fechaExpansivel("%s");</script>', $_GET['div']); | ||
180 | + die(); | ||
181 | + } | ||
182 | + | ||
183 | + function Editar() | ||
184 | + { | ||
185 | + $obj_servidor = new clsPmieducarServidor($this->cod_servidor, NULL, NULL, | ||
186 | + NULL, NULL, NULL, NULL, $this->ref_cod_instituicao, $this->ref_cod_subnivel | ||
187 | + ); | ||
188 | + | ||
189 | + $obj_servidor->edita(); | ||
190 | + | ||
191 | + echo sprintf('<script>parent.fechaExpansivel("%s");window.parent.location.reload(true);</script>', $_GET['div']); | ||
192 | + die; | ||
193 | + } | ||
194 | + | ||
195 | + function Excluir() | ||
196 | + { | ||
197 | + return FALSE; | ||
198 | + } | ||
189 | } | 199 | } |
190 | 200 | ||
191 | -// cria uma extensao da classe base | 201 | +// Instancia objeto de página |
192 | $pagina = new clsIndexBase(); | 202 | $pagina = new clsIndexBase(); |
193 | -// cria o conteudo | 203 | + |
204 | +// Instancia objeto de conteúdo | ||
194 | $miolo = new indice(); | 205 | $miolo = new indice(); |
195 | -// adiciona o conteudo na clsBase | ||
196 | -$pagina->addForm( $miolo ); | ||
197 | -// gera o html | 206 | + |
207 | +// Atribui o conteúdo à página | ||
208 | +$pagina->addForm($miolo); | ||
209 | + | ||
210 | +// Gera o código HTML | ||
198 | $pagina->MakeAll(); | 211 | $pagina->MakeAll(); |
199 | ?> | 212 | ?> |
200 | -<script> | ||
201 | - | ||
202 | - function trocaNiveis() | ||
203 | - { | ||
204 | - | ||
205 | - var campoCategoria = document.getElementById('ref_cod_categoria').value; | ||
206 | - var campoNivel = document.getElementById('ref_cod_nivel'); | ||
207 | - var campoSubNivel = document.getElementById('ref_cod_subnivel'); | ||
208 | - | ||
209 | - campoNivel.length = 1; | ||
210 | - campoSubNivel.length = 1; | ||
211 | - | ||
212 | - if( campoCategoria ) | ||
213 | - { | ||
214 | - campoNivel.disabled = true; | ||
215 | - campoNivel.options[0].text = 'Carregando Níveis'; | ||
216 | - var xml = new ajax(atualizaLstNiveis); | ||
217 | - xml.envia("educar_niveis_servidor_xml.php?cod_cat="+campoCategoria); | ||
218 | - } | ||
219 | - else | ||
220 | - { | ||
221 | - campoNivel.options[0].text = 'Selecione uma Categoria'; | ||
222 | - campoNivel.disabled = false; | ||
223 | - campoSubNivel.options[0].text = 'Selecione um Nível'; | ||
224 | - campoSubNivel.disabled = false; | ||
225 | - } | ||
226 | - } | ||
227 | - | ||
228 | - function atualizaLstNiveis(xml) | ||
229 | - { | ||
230 | - var campoNivel = document.getElementById('ref_cod_nivel'); | ||
231 | - | ||
232 | - campoNivel.length = 1; | ||
233 | - campoNivel.options[0].text = 'Selecione uma Categoria'; | ||
234 | - campoNivel.disabled = false; | ||
235 | - | ||
236 | - var niveis = xml.getElementsByTagName('nivel'); | ||
237 | - if(niveis.length) | ||
238 | - { | ||
239 | - for( var i = 0; i < niveis.length; i++ ) | ||
240 | - { | ||
241 | - campoNivel.options[campoNivel.options.length] = new Option( niveis[i].firstChild.data, niveis[i].getAttribute('cod_nivel'),false,false); | ||
242 | - } | ||
243 | - } | ||
244 | - else | ||
245 | - { | ||
246 | - campoNivel.options[0].text = 'Categoria não possui níveis'; | ||
247 | - } | ||
248 | - | ||
249 | - | ||
250 | - } | ||
251 | - | ||
252 | - function trocaSubniveis() | ||
253 | - { | ||
254 | - | ||
255 | - var campoNivel = document.getElementById('ref_cod_nivel').value; | ||
256 | - var campoSubNivel = document.getElementById('ref_cod_subnivel'); | ||
257 | - | ||
258 | - campoSubNivel.length = 1; | ||
259 | - | ||
260 | - if( campoNivel ) | ||
261 | - { | ||
262 | - campoSubNivel.disabled = true; | ||
263 | - campoSubNivel.options[0].text = 'Carregando Subníveis'; | ||
264 | - var xml = new ajax(atualizaLstSubiveis); | ||
265 | - xml.envia("educar_subniveis_servidor_xml.php?cod_nivel="+campoNivel); | ||
266 | - } | ||
267 | - else | ||
268 | - { | ||
269 | - campoSubNivel.options[0].text = 'Selecione uma Nível'; | ||
270 | - campoSubNivel.disabled = false; | ||
271 | - } | ||
272 | - } | ||
273 | - | ||
274 | - function atualizaLstSubiveis(xml) | ||
275 | - { | ||
276 | - var campoSubNivel = document.getElementById('ref_cod_subnivel'); | ||
277 | - | ||
278 | - campoSubNivel.length = 1; | ||
279 | - campoSubNivel.options[0].text = 'Selecione um Subnível'; | ||
280 | - campoSubNivel.disabled = false; | ||
281 | - | ||
282 | - var subniveis = xml.getElementsByTagName('subnivel'); | ||
283 | - if(subniveis.length) | ||
284 | - { | ||
285 | - for( var i = 0; i < subniveis.length; i++ ) | ||
286 | - { | ||
287 | - campoSubNivel.options[campoSubNivel.options.length] = new Option( subniveis[i].firstChild.data, subniveis[i].getAttribute('cod_subnivel'),false,false); | ||
288 | - } | ||
289 | - } | ||
290 | - else | ||
291 | - { | ||
292 | - campoNivel.options[0].text = 'Nível não possui subníveis'; | ||
293 | - } | ||
294 | - | ||
295 | - | ||
296 | - } | ||
297 | - | ||
298 | - document.getElementById('ref_cod_categoria').onchange = function(){ | ||
299 | - trocaNiveis(); | ||
300 | - } | ||
301 | - | ||
302 | - document.getElementById('ref_cod_nivel').onchange = function(){ | ||
303 | - trocaSubniveis(); | ||
304 | - } | 213 | +<script type="text/javascript"> |
214 | +function trocaNiveis() | ||
215 | +{ | ||
216 | + var campoCategoria = document.getElementById('ref_cod_categoria').value; | ||
217 | + var campoNivel = document.getElementById('ref_cod_nivel'); | ||
218 | + var campoSubNivel = document.getElementById('ref_cod_subnivel'); | ||
219 | + | ||
220 | + campoNivel.length = 1; | ||
221 | + campoSubNivel.length = 1; | ||
222 | + | ||
223 | + if (campoCategoria) { | ||
224 | + campoNivel.disabled = true; | ||
225 | + campoNivel.options[0].text = 'Carregando Níveis'; | ||
226 | + var xml = new ajax(atualizaLstNiveis); | ||
227 | + xml.envia('educar_niveis_servidor_xml.php?cod_cat=' + campoCategoria); | ||
228 | + } | ||
229 | + else { | ||
230 | + campoNivel.options[0].text = 'Selecione uma Categoria'; | ||
231 | + campoNivel.disabled = false; | ||
232 | + campoSubNivel.options[0].text = 'Selecione um Nível'; | ||
233 | + campoSubNivel.disabled = false; | ||
234 | + } | ||
235 | +} | ||
236 | + | ||
237 | +function atualizaLstNiveis(xml) | ||
238 | +{ | ||
239 | + var campoNivel = document.getElementById('ref_cod_nivel'); | ||
240 | + | ||
241 | + campoNivel.length = 1; | ||
242 | + campoNivel.options[0].text = 'Selecione uma Categoria'; | ||
243 | + campoNivel.disabled = false; | ||
244 | + | ||
245 | + var niveis = xml.getElementsByTagName('nivel'); | ||
246 | + | ||
247 | + if (niveis.length) { | ||
248 | + for (var i = 0; i < niveis.length; i++) { | ||
249 | + campoNivel.options[campoNivel.options.length] = new Option( niveis[i].firstChild.data, niveis[i].getAttribute('cod_nivel'),false,false); | ||
250 | + } | ||
251 | + } | ||
252 | + else { | ||
253 | + campoNivel.options[0].text = 'Categoria não possui níveis'; | ||
254 | + } | ||
255 | +} | ||
256 | + | ||
257 | +function trocaSubniveis() | ||
258 | +{ | ||
259 | + var campoNivel = document.getElementById('ref_cod_nivel').value; | ||
260 | + var campoSubNivel = document.getElementById('ref_cod_subnivel'); | ||
261 | + | ||
262 | + campoSubNivel.length = 1; | ||
263 | + | ||
264 | + if (campoNivel) { | ||
265 | + campoSubNivel.disabled = true; | ||
266 | + campoSubNivel.options[0].text = 'Carregando Subníveis'; | ||
267 | + var xml = new ajax(atualizaLstSubiveis); | ||
268 | + xml.envia("educar_subniveis_servidor_xml.php?cod_nivel="+campoNivel); | ||
269 | + } | ||
270 | + else { | ||
271 | + campoSubNivel.options[0].text = 'Selecione uma Nível'; | ||
272 | + campoSubNivel.disabled = false; | ||
273 | + } | ||
274 | +} | ||
275 | + | ||
276 | +function atualizaLstSubiveis(xml) | ||
277 | +{ | ||
278 | + var campoSubNivel = document.getElementById('ref_cod_subnivel'); | ||
279 | + | ||
280 | + campoSubNivel.length = 1; | ||
281 | + campoSubNivel.options[0].text = 'Selecione um Subnível'; | ||
282 | + campoSubNivel.disabled = false; | ||
283 | + | ||
284 | + var subniveis = xml.getElementsByTagName('subnivel'); | ||
285 | + | ||
286 | + if (subniveis.length) { | ||
287 | + for (var i = 0; i < subniveis.length; i++) { | ||
288 | + campoSubNivel.options[campoSubNivel.options.length] = new Option( | ||
289 | + subniveis[i].firstChild.data, subniveis[i].getAttribute('cod_subnivel'), | ||
290 | + false, false | ||
291 | + ); | ||
292 | + } | ||
293 | + } | ||
294 | + else { | ||
295 | + campoNivel.options[0].text = 'Nível não possui subníveis'; | ||
296 | + } | ||
297 | +} | ||
298 | + | ||
299 | +document.getElementById('ref_cod_categoria').onchange = function(){ | ||
300 | + trocaNiveis(); | ||
301 | +} | ||
302 | + | ||
303 | +document.getElementById('ref_cod_nivel').onchange = function(){ | ||
304 | + trocaSubniveis(); | ||
305 | +} | ||
305 | </script> | 306 | </script> |
306 | \ No newline at end of file | 307 | \ No newline at end of file |