Commit 7e2dfd43f72ad6d994ac064101395bdaa2a93207
1 parent
88918c3c
Exists in
master
#16 by Davi Silva, Eriksen: Corrigido erro 404 no carregamento de estados de um país via AJAX.
Showing
2 changed files
with
61 additions
and
85 deletions
Show diff stats
ieducar/intranet/educar_historico_escolar_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 | -require_once ("include/clsBase.inc.php"); | ||
28 | -require_once ("include/clsCadastro.inc.php"); | ||
29 | -require_once ("include/clsBanco.inc.php"); | ||
30 | -require_once( "include/pmieducar/geral.inc.php" ); | 2 | +/** |
3 | + * | ||
4 | + * @author Prefeitura Municipal de Itajaí | ||
5 | + * @version SVN: $Id$ | ||
6 | + * | ||
7 | + * Pacote: i-PLB Software Público Livre e Brasileiro | ||
8 | + * | ||
9 | + * Copyright (C) 2006 PMI - Prefeitura Municipal de Itajaí | ||
10 | + * ctima@itajai.sc.gov.br | ||
11 | + * | ||
12 | + * Este programa é software livre, você pode redistribuí-lo e/ou | ||
13 | + * modificá-lo sob os termos da Licença Pública Geral GNU, conforme | ||
14 | + * publicada pela Free Software Foundation, tanto a versão 2 da | ||
15 | + * Licença como (a seu critério) qualquer versão mais nova. | ||
16 | + * | ||
17 | + * Este programa é distribuído na expectativa de ser útil, mas SEM | ||
18 | + * QUALQUER GARANTIA. Sem mesmo a garantia implícita de COMERCIALI- | ||
19 | + * ZAÇÃO ou de ADEQUAÇÃO A QUALQUER PROPÓSITO EM PARTICULAR. Con- | ||
20 | + * sulte a Licença Pública Geral GNU para obter mais detalhes. | ||
21 | + * | ||
22 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU | ||
23 | + * junto com este programa. Se não, escreva para a Free Software | ||
24 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | ||
25 | + * 02111-1307, USA. | ||
26 | + * | ||
27 | + */ | ||
28 | + | ||
29 | +require_once 'include/clsBase.inc.php'; | ||
30 | +require_once 'include/clsCadastro.inc.php'; | ||
31 | +require_once 'include/clsBanco.inc.php'; | ||
32 | +require_once 'include/pmieducar/geral.inc.php'; | ||
31 | 33 | ||
32 | class clsIndexBase extends clsBase | 34 | class clsIndexBase extends clsBase |
33 | { | 35 | { |
@@ -142,11 +144,11 @@ class indice extends clsCadastro | @@ -142,11 +144,11 @@ class indice extends clsCadastro | ||
142 | //$obj_permissoes = new clsPermissoes(); | 144 | //$obj_permissoes = new clsPermissoes(); |
143 | //$this->ref_cod_instituicao = $obj_permissoes->getInstituicao( $this->pessoa_logada ); | 145 | //$this->ref_cod_instituicao = $obj_permissoes->getInstituicao( $this->pessoa_logada ); |
144 | //$this->campoOculto( 'ref_cod_instituicao', $this->ref_cod_instituicao ); | 146 | //$this->campoOculto( 'ref_cod_instituicao', $this->ref_cod_instituicao ); |
145 | - | 147 | + |
146 | $obj_nivel = new clsPmieducarUsuario($this->pessoa_logada); | 148 | $obj_nivel = new clsPmieducarUsuario($this->pessoa_logada); |
147 | $nivel_usuario = $obj_nivel->detalhe(); | 149 | $nivel_usuario = $obj_nivel->detalhe(); |
148 | - | ||
149 | - if ($nivel_usuario['ref_cod_tipo_usuario'] == 1) | 150 | + |
151 | + if ($nivel_usuario['ref_cod_tipo_usuario'] == 1) | ||
150 | { | 152 | { |
151 | $obj_instituicao = new clsPmieducarInstituicao(); | 153 | $obj_instituicao = new clsPmieducarInstituicao(); |
152 | $lista = $obj_instituicao->lista(null,null,null,null,null,null,null,null,null,null,null,null,null,1); | 154 | $lista = $obj_instituicao->lista(null,null,null,null,null,null,null,null,null,null,null,null,null,1); |
@@ -167,7 +169,7 @@ class indice extends clsCadastro | @@ -167,7 +169,7 @@ class indice extends clsCadastro | ||
167 | $this->campoOculto("ref_cod_instituicao", $inst['cod_instituicao']); | 169 | $this->campoOculto("ref_cod_instituicao", $inst['cod_instituicao']); |
168 | $this->campoTexto("instituicao", "Instiuição", $inst['nm_instituicao'], 30, 255, false, false, false, "", "", "", "", true); | 170 | $this->campoTexto("instituicao", "Instiuição", $inst['nm_instituicao'], 30, 255, false, false, false, "", "", "", "", true); |
169 | } | 171 | } |
170 | - | 172 | + |
171 | // text | 173 | // text |
172 | $this->campoTexto( "escola", "Escola", $this->escola, 30, 255, true ); | 174 | $this->campoTexto( "escola", "Escola", $this->escola, 30, 255, true ); |
173 | $this->campoTexto( "escola_cidade", "Cidade da Escola", $this->escola_cidade, 30, 255, true ); | 175 | $this->campoTexto( "escola_cidade", "Cidade da Escola", $this->escola_cidade, 30, 255, true ); |
@@ -456,7 +458,7 @@ document.getElementById('idpais').onchange = function() | @@ -456,7 +458,7 @@ document.getElementById('idpais').onchange = function() | ||
456 | campoEstado.options[0] = new Option( 'Carregando estados', '', false, false ); | 458 | campoEstado.options[0] = new Option( 'Carregando estados', '', false, false ); |
457 | 459 | ||
458 | var xml1 = new ajax(getEstado_XML); | 460 | var xml1 = new ajax(getEstado_XML); |
459 | - strURL = "xml_estado.php?pais="+campoPais; | 461 | + strURL = "public_uf_xml.php?pais="+campoPais; |
460 | xml1.envia(strURL); | 462 | xml1.envia(strURL); |
461 | } | 463 | } |
462 | 464 |
ieducar/intranet/public_uf_xml.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 | - header( 'Content-type: text/xml' ); | 2 | +/** |
3 | + * Retorna um XML formatado com UF e estado de um determinado país. | ||
4 | + * | ||
5 | + * @author Eriksen Costa <eriksen.paixao_bs@cobra.com.br> | ||
6 | + * @version SVN: $Id$ | ||
7 | + */ | ||
28 | 8 | ||
29 | - require_once( "include/clsBanco.inc.php" ); | ||
30 | - require_once( "include/funcoes.inc.php" ); | ||
31 | - echo "<?xml version=\"1.0\" encoding=\"ISO-8859-15\"?>\n<query xmlns=\"sugestoes\">\n"; | ||
32 | - if( is_numeric( $_GET["pais"] ) ) | ||
33 | - { | ||
34 | - $db = new clsBanco(); | ||
35 | - $db->Consulta( " | ||
36 | - SELECT | ||
37 | - sigla_uf | ||
38 | - , nome | ||
39 | - FROM | ||
40 | - public.uf | ||
41 | - WHERE | ||
42 | - idpais = {$_GET["pais"]} | ||
43 | - ORDER BY | ||
44 | - nome ASC | ||
45 | - " ); | 9 | +require_once 'include/pessoa/clsUf.inc.php'; |
46 | 10 | ||
47 | - while ( $db->ProximoRegistro() ) | ||
48 | - { | ||
49 | - list( $cod, $nome ) = $db->Tupla(); | ||
50 | - echo " <uf sigla_uf=\"{$cod}\">{$nome}</uf>\n"; | ||
51 | - } | ||
52 | - } | ||
53 | - echo "</query>"; | ||
54 | -?> | ||
55 | \ No newline at end of file | 11 | \ No newline at end of file |
12 | +// Id do país na tabela public.pais | ||
13 | +$id = isset($_GET['pais']) ? $_GET['pais'] : NULL; | ||
14 | + | ||
15 | +header('Content-type: text/xml; charset=iso-8859-1'); | ||
16 | +print '<?xml version="1.0" encoding="iso-8859-1"?>' . PHP_EOL; | ||
17 | +print '<query>' . PHP_EOL; | ||
18 | + | ||
19 | +if ($id == strval(intval($id))) { | ||
20 | + $uf = new clsUf(); | ||
21 | + $ufs = $uf->lista(NULL, NULL, $id, NULL, NULL, 'sigla_uf'); | ||
22 | + | ||
23 | + foreach ($ufs as $uf) { | ||
24 | + print sprintf(' <estado sigla_uf="%s">%s</estado>' . PHP_EOL, | ||
25 | + $uf['sigla_uf'], $uf['nome']); | ||
26 | + } | ||
27 | +} | ||
28 | + | ||
29 | +print '</query>'; | ||
56 | \ No newline at end of file | 30 | \ No newline at end of file |