public_municipio_lst.php
4.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
require_once 'include/clsBase.inc.php';
require_once 'include/clsListagem.inc.php';
require_once 'include/clsBanco.inc.php';
require_once 'include/public/geral.inc.php';
class clsIndexBase extends clsBase
{
public function Formular()
{
$this->SetTitulo("{$this->_instituicao} Município");
$this->processoAp = 755;
}
}
class indice extends clsListagem
{
public $__limite;
public $__offset;
public $idmun;
public $nome;
public $sigla_uf;
public $cod_ibge;
public $geom;
public $tipo;
public $idpes_rev;
public $idpes_cad;
public $data_rev;
public $data_cad;
public $origem_gravacao;
public $operacao;
public $idpais;
public function Gerar()
{
$this->__titulo = 'Município - Listagem';
foreach ($_GET as $var => $val) {
$this->$var = ($val === '') ? null : $val;
}
$this->addCabecalhos([
'Nome',
'Estado'
]);
$opcoes = ['' => 'Selecione'];
$objTemp = new clsPais();
$lista = $objTemp->lista(false, false, false, false, false, 'nome ASC');
if (is_array($lista) && count($lista)) {
foreach ($lista as $registro) {
$opcoes["{$registro['idpais']}"] = "{$registro['nome']}";
}
}
$this->campoLista('idpais', 'Pais', $opcoes, $this->idpais, '', false, '', '', false, false);
$opcoes = ['' => 'Selecione'];
if ($this->idpais) {
$objTemp = new clsUf();
$lista = $objTemp->lista(false, false, $this->idpais, false, false, 'nome ASC');
if (is_array($lista) && count($lista)) {
foreach ($lista as $registro) {
$opcoes["{$registro['sigla_uf']}"] = "{$registro['nome']}";
}
}
}
$this->campoLista('sigla_uf', 'Estado', $opcoes, $this->sigla_uf, '', false, '', '', false, false);
$this->campoTexto('nome', 'Nome', $this->nome, 30, 60, false);
$this->__limite = 20;
$this->__offset = ($_GET["pagina_{$this->nome}"]) ? $_GET["pagina_{$this->nome}"] * $this->__limite - $this->__limite : 0;
$obj_municipio = new clsPublicMunicipio();
$obj_municipio->setOrderby('nome ASC');
$obj_municipio->setLimite($this->__limite, $this->__offset);
$lista = $obj_municipio->lista(
$this->nome,
$this->sigla_uf
);
$total = $obj_municipio->_total;
if (is_array($lista) && count($lista)) {
foreach ($lista as $registro) {
$obj_sigla_uf = new clsUf($registro['sigla_uf']);
$det_sigla_uf = $obj_sigla_uf->detalhe();
$registro['sigla_uf'] = $det_sigla_uf['nome'];
$this->addLinhas([
"<a href=\"public_municipio_det.php?idmun={$registro['idmun']}\">{$registro['nome']}</a>",
"<a href=\"public_municipio_det.php?idmun={$registro['idmun']}\">{$registro['sigla_uf']}</a>"
]);
}
}
$this->addPaginador2('public_municipio_lst.php', $total, $_GET, $this->nome, $this->__limite);
$this->largura = '100%';
$obj_permissao = new clsPermissoes();
if ($obj_permissao->permissao_cadastra(755, $this->pessoa_logada, 7, null, true)) {
$this->acao = 'go("public_municipio_cad.php")';
$this->nome_acao = 'Novo';
}
$this->breadcrumb('Listagem de municípios', [
url('intranet/educar_enderecamento_index.php') => 'Endereçamento',
]);
}
}
$pagina = new clsIndexBase();
$miolo = new indice();
$pagina->addForm($miolo);
$pagina->MakeAll();
?>
<script>
document.getElementById('idpais').onchange = function () {
var campoPais = document.getElementById('idpais').value;
var campoUf = document.getElementById('sigla_uf');
campoUf.length = 1;
campoUf.disabled = true;
campoUf.options[0].text = 'Carregando estado...';
var xml_uf = new ajax(getUf);
xml_uf.envia("public_uf_xml.php?pais=" + campoPais);
}
function getUf (xml_uf) {
var campoUf = document.getElementById('sigla_uf');
var DOM_array = xml_uf.getElementsByTagName("estado");
if (DOM_array.length) {
campoUf.length = 1;
campoUf.options[0].text = 'Selecione um estado';
campoUf.disabled = false;
for (var i = 0; i < DOM_array.length; i++) {
campoUf.options[campoUf.options.length] = new Option(DOM_array[i].firstChild.data, DOM_array[i].getAttribute("sigla_uf"), false, false);
}
} else
campoUf.options[0].text = 'O pais não possui nenhum estado';
}
</script>