Commit 7a5c388b64341e397cd982e358e7a984eb0b87c4

Authored by Eriksen Costa
1 parent 7209fa66
Exists in master

Refactoring para coding standards

Showing 1 changed file with 575 additions and 415 deletions   Show diff stats
ieducar/intranet/atendidos_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 -$desvio_diretorio = "";  
28 -require_once ("include/clsBase.inc.php");  
29 -require_once ("include/clsBanco.inc.php");  
30 -require_once ("include/clsCadastro.inc.php");  
31 -  
32 -  
33 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 http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL
  26 + * @package Ied_Cadastro
  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/clsBanco.inc.php';
  33 +require_once 'include/clsCadastro.inc.php';
  34 +
  35 +/**
  36 + * clsIndex class.
  37 + *
  38 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  39 + * @category i-Educar
  40 + * @license @@license@@
  41 + * @package iEd_Cadastro
  42 + * @since Classe disponível desde a versão 1.0.0
  43 + * @version @@package_version@@
  44 + */
34 class clsIndex extends clsBase 45 class clsIndex extends clsBase
35 { 46 {
36 -  
37 - function Formular()  
38 - {  
39 - $this->SetTitulo( "{$this->_instituicao} Pessoas F&iacute;sicas - Cadastro!" );  
40 - $this->processoAp = "43";  
41 - } 47 + function Formular()
  48 + {
  49 + $this->SetTitulo($this->_instituicao . ' Pessoas Físicas - Cadastro');
  50 + $this->processoAp = 43;
  51 + }
42 } 52 }
43 53
  54 +/**
  55 + * indice class.
  56 + *
  57 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  58 + * @category i-Educar
  59 + * @license @@license@@
  60 + * @package iEd_Cadastro
  61 + * @since Classe disponível desde a versão 1.0.0
  62 + * @version @@package_version@@
  63 + */
44 class indice extends clsCadastro 64 class indice extends clsCadastro
45 { 65 {
46 - var $cod_pessoa_fj, $nm_pessoa, $id_federal, $data_nasc, $endereco, $cep, $idlog, $idbai, $sigla_uf, $ddd_telefone_1, $telefone_1, $ddd_telefone_2, $telefone_2, $ddd_telefone_mov, $telefone_mov, $ddd_telefone_fax, $telefone_fax, $email, $http, $tipo_pessoa, $sexo;  
47 - var $busca_pessoa;  
48 - var $complemento;  
49 - var $apartamento;  
50 - var $bloco;  
51 - var $andar;  
52 - var $numero;  
53 - var $retorno;  
54 -  
55 - var $caminho_det, $caminho_lst;  
56 -  
57 - var $alterado;  
58 -  
59 - function Inicializar()  
60 - {  
61 - if( $_REQUEST['busca_pessoa'])  
62 - {  
63 -  
64 - $this->retorno = "Novo";  
65 - $cpf = idFederal2int( $_REQUEST['busca_pessoa'] );  
66 - $this->busca_pessoa = $cpf;  
67 - $this->id_federal = $cpf;  
68 - $objPessoa = new clsPessoaFisica( false, $cpf );  
69 - $detalhePessoa = $objPessoa->detalhe();  
70 -  
71 - $this->cod_pessoa_fj = $detalhePessoa["idpes"];  
72 - }elseif( $_REQUEST['cod_pessoa_fj'] != "")  
73 - {  
74 - $this->busca_pessoa = true;  
75 - if($_REQUEST['cod_pessoa_fj'] != 0)  
76 - {  
77 - $this->cod_pessoa_fj = $_REQUEST['cod_pessoa_fj'];  
78 - }  
79 - else  
80 - {  
81 - $this->retorno = "Novo";  
82 - }  
83 - }  
84 -  
85 - if( $this->cod_pessoa_fj )  
86 - {  
87 - $this->cod_pessoa_fj = (@$_GET['cod_pessoa']) ? @$_GET['cod_pessoa'] : $this->cod_pessoa_fj;  
88 - $db = new clsBanco();  
89 - $objPessoa = new clsPessoaFisica();  
90 - list( $this->nm_pessoa,$this->id_federal, $this->data_nasc, $this->ddd_telefone_1, $this->telefone_1, $this->ddd_telefone_2, $this->telefone_2, $this->ddd_telefone_mov, $this->telefone_mov, $this->ddd_telefone_fax, $this->telefone_fax, $this->email, $this->http, $this->tipo_pessoa, $this->sexo, $this->cidade, $this->bairro, $this->logradouro, $this->cep, $this->idlog, $this->idbai, $this->idtlog, $this->sigla_uf, $this->complemento, $this->numero, $this->bloco, $this->apartamento, $this->andar) = $objPessoa->queryRapida( $this->cod_pessoa_fj, "nome", "cpf", "data_nasc", "ddd_1", "fone_1", "ddd_2", "fone_2", "ddd_mov", "fone_mov", "ddd_fax", "fone_fax", "email", "url", "tipo", "sexo", "cidade", "bairro", "logradouro", "cep", "idlog", "idbai", "idtlog", "sigla_uf", "complemento", "numero", "bloco", "apartamento", "andar");  
91 - $this->cep = int2Cep($this->cep);  
92 - $this->retorno = "Editar";  
93 - }  
94 - $this->nome_url_cancelar = "Cancelar";  
95 -  
96 - return $this->retorno;  
97 - }  
98 -  
99 - function Gerar()  
100 - {  
101 - $this->addBanner( "imagens/nvp_top_intranet.jpg", "imagens/nvp_vert_intranet.jpg", "Intranet",false );  
102 -  
103 - if( !$this->busca_pessoa )  
104 - {  
105 - $this->campoOculto("cod_pessoa_fj","");  
106 - $parametros = new clsParametrosPesquisas();  
107 - $parametros->setSubmit( 1 );  
108 - $parametros->adicionaCampoTexto( "busca_pessoa", "id_federal" );  
109 - $parametros->adicionaCampoTexto( "cod_pessoa_fj", "idpes" );  
110 - $parametros->setPessoa( 'F' );  
111 - $parametros->setPessoaCampo( "cod_pessoa_fj" );  
112 - $parametros->setPessoaNovo( 'S' );  
113 - $parametros->setPessoaTela( "window" );  
114 - $this->campoCpf("busca_pessoa", "CPF", $this->ref_cod_pessoa_fj, true, "<img id='lupa' src=\"imagens/lupa.png\" border=\"0\" onclick=\"showExpansivel( 500,500, '<iframe name=\'miolo\' id=\'miolo\' frameborder=\'0\' height=\'100%\' width=\'500\' marginheight=\'0\' marginwidth=\'0\' src=\'pesquisa_pessoa_lst.php?campos=".$parametros->serializaCampos()."\'></iframe>' );\">", false, true );  
115 -  
116 - }  
117 - else  
118 - {  
119 - $this->campoOculto("busca_pessoa",$this->busca_pessoa);  
120 - $this->url_cancelar = ( $this->retorno == "Editar" ) ? "atendidos_det.php?cod_pessoa={$this->cod_pessoa_fj}" : "atendidos_lst.php";  
121 - $this->campoOculto( "cod_pessoa_fj", $this->cod_pessoa_fj );  
122 - $this->campoTexto( "nm_pessoa", "Nome", $this->nm_pessoa, "50", "255", true );  
123 - if($this->id_federal)  
124 - {  
125 - $this->campoRotulo( "id_federal", "CPF", int2CPF( $this->id_federal ));  
126 - }else  
127 - {  
128 - $this->campoCpf( "id_federal", "CPF","", false);  
129 - }  
130 -  
131 - if( $this->data_nasc )  
132 - {  
133 - $this->data_nasc = dataFromPgToBr($this->data_nasc);  
134 - }  
135 - $this->campoData( "data_nasc", "Data de Nascimento", $this->data_nasc );  
136 -  
137 - $lista_sexos = array();  
138 - $lista_sexos[""] = "Escolha uma op&ccedil;&atilde;o...";  
139 - $lista_sexos["M"] = "Masculino";  
140 - $lista_sexos["F"] = "Feminino";  
141 - $this->campoLista( "sexo", "Sexo", $lista_sexos, $this->sexo);  
142 -  
143 - // Detalhes do Endere�o  
144 - $objTipoLog = new clsTipoLogradouro();  
145 - $listaTipoLog = $objTipoLog->lista();  
146 - $listaTLog = array("0"=>"Selecione");  
147 - if($listaTipoLog)  
148 - {  
149 - foreach ($listaTipoLog as $tipoLog) {  
150 - $listaTLog[$tipoLog['idtlog']] = $tipoLog['descricao'];  
151 - }  
152 - }  
153 -  
154 - $objUf = new clsUf();  
155 - $listauf = $objUf->lista();  
156 - $listaEstado = array("0"=>"Selecione");  
157 - if($listauf)  
158 - {  
159 - foreach ($listauf as $uf) {  
160 - $listaEstado[$uf['sigla_uf']] = $uf['sigla_uf'];  
161 - }  
162 - }  
163 -  
164 - $this->campoOculto( "idbai", $this->idbai );  
165 - $this->campoOculto( "idlog", $this->idlog );  
166 - $this->campoOculto( "cep", $this->cep );  
167 - $this->campoOculto( "ref_sigla_uf", $this->sigla_uf);  
168 - $this->campoOculto( "ref_idtlog", $this->idtlog);  
169 - $this->campoOculto( "id_cidade", $this->cidade);  
170 -  
171 - if($this->idlog && $this->idbai && $this->cep && $this->cod_pessoa_fj)  
172 - {  
173 - $this->campoCep("cep_", "CEP", $this->cep, true, "-", "&nbsp;<img id='lupa' src=\"imagens/lupa.png\" border=\"0\" onclick=\"showExpansivel( 500,500, '<iframe name=\'miolo\' id=\'miolo\' frameborder=\'0\' height=\'100%\' width=\'500\' marginheight=\'0\' marginwidth=\'0\' src=\'educar_pesquisa_cep_log_bairro.php?campo1=bairro&campo2=idbai&campo3=cep&campo4=logradouro&campo5=idlog&campo6=ref_sigla_uf&campo7=cidade&campo8=ref_idtlog&campo9=isEnderecoExterno&campo10=cep_&campo11=sigla_uf&campo12=idtlog&campo13=id_cidade\'></iframe>');\">", true);  
174 - $this->campoLista("idtlog","Tipo Logradouro",$listaTLog,$this->idtlog,false,false,false,false,true);  
175 - $this->campoTextoInv( "logradouro", "Logradouro", $this->logradouro, "50", "255", false );  
176 - $this->campoTextoInv( "cidade", "Cidade", $this->cidade, "50", "255", false );  
177 - $this->campoTextoInv( "bairro", "Bairro", $this->bairro, "50", "255", false );  
178 - $this->campoTexto( "complemento", "Complemento", $this->complemento, "50", "255", false );  
179 - $this->campoTexto( "numero", "N&uacute;mero", $this->numero, "10", "10" );  
180 - $this->campoTexto( "letra", "Letra", $this->letra, "1", "1", false );  
181 - $this->campoTexto( "apartamento", "N&uacute;mero Apartametno", $this->apartamento, "6", "6", false );  
182 - $this->campoTexto( "bloco", "Bloco", $this->bloco, "20", "20", false );  
183 - $this->campoTexto( "andar", "Andar", $this->andar, "2", "2", false );  
184 - $this->campoLista("sigla_uf","Estado",$listaEstado,$this->sigla_uf,false,false,false,false,true);  
185 - }  
186 - elseif($this->cod_pessoa_fj && $this->cep)  
187 - {  
188 - $this->campoCep("cep_", "CEP", $this->cep, true, "-", "&nbsp;<img id='lupa' src=\"imagens/lupa.png\" border=\"0\" onclick=\"showExpansivel( 500,500, '<iframe name=\'miolo\' id=\'miolo\' frameborder=\'0\' height=\'100%\' width=\'500\' marginheight=\'0\' marginwidth=\'0\' src=\'educar_pesquisa_cep_log_bairro.php?campo1=bairro&campo2=idbai&campo3=cep&campo4=logradouro&campo5=idlog&campo6=ref_sigla_uf&campo7=cidade&campo8=ref_idtlog&campo9=isEnderecoExterno&campo10=cep_&campo11=sigla_uf&campo12=idtlog&campo13=id_cidade\'></iframe>');\">", $disabled);  
189 - $this->campoLista("idtlog","Tipo Logradouro",$listaTLog,$this->idtlog);  
190 - $this->campoTexto( "logradouro", "Logradouro", $this->logradouro, "50", "255", false );  
191 - $this->campoTexto( "cidade", "Cidade", $this->cidade, "50", "255", false );  
192 - $this->campoTexto( "bairro", "Bairro", $this->bairro, "50", "255", false );  
193 - $this->campoTexto( "complemento", "Complemento", $this->complemento, "50", "255", false );  
194 - $this->campoTexto( "numero", "N&uacute;mero", $this->numero, "10", "10" );  
195 - $this->campoTexto( "letra", "Letra", $this->letra, "1", "1", false );  
196 - $this->campoTexto( "apartamento", "N&uacute;mero Apartametno", $this->apartamento, "6", "6", false );  
197 - $this->campoTexto( "bloco", "Bloco", $this->bloco, "20", "20", false );  
198 - $this->campoTexto( "andar", "Andar", $this->andar, "2", "2", false );  
199 - $this->campoLista("sigla_uf","Estado",$listaEstado,$this->sigla_uf);  
200 - }  
201 - else  
202 - {  
203 - $this->campoCep("cep_", "CEP", $this->cep, true, "-", "&nbsp;<img id='lupa' src=\"imagens/lupa.png\" border=\"0\" onclick=\"showExpansivel( 500,500, '<iframe name=\'miolo\' id=\'miolo\' frameborder=\'0\' height=\'100%\' width=\'500\' marginheight=\'0\' marginwidth=\'0\' src=\'educar_pesquisa_cep_log_bairro.php?campo1=bairro&campo2=idbai&campo3=cep&campo4=logradouro&campo5=idlog&campo6=ref_sigla_uf&campo7=cidade&campo8=ref_idtlog&campo9=isEnderecoExterno&campo10=cep_&campo11=sigla_uf&campo12=idtlog&campo13=id_cidade\'></iframe>');\">", false/*$disabled*/);  
204 -  
205 - $this->campoLista("idtlog","Tipo Logradouro",$listaTLog,$this->idtlog,false,false,false,false,false);  
206 - $this->campoTexto( "logradouro", "Logradouro", $this->logradouro, "50", "255" );  
207 - $this->campoTexto( "cidade", "Cidade", $this->cidade, "50", "255");  
208 - $this->campoTexto( "bairro", "Bairro", $this->bairro, "50", "255" );  
209 - $this->campoTexto( "complemento", "Complemento", $this->complemento, "50", "255", false );  
210 - $this->campoTexto( "numero", "N&uacute;mero", $this->numero, "10", "10" );  
211 - $this->campoTexto( "letra", "Letra", $this->letra, "1", "1", false );  
212 - $this->campoTexto( "apartamento", "N&uacute;mero Apartametno", $this->apartamento, "6", "6", false );  
213 - $this->campoTexto( "bloco", "Bloco", $this->bloco, "20", "20", false );  
214 - $this->campoTexto( "andar", "Andar", $this->andar, "2", "2", false );  
215 - $this->campoLista("sigla_uf","Estado",$listaEstado,$this->sigla_uf,false,false,false,false,false);  
216 - }  
217 -  
218 - $this->campoTexto( "ddd_telefone_1", "DDD Telefone 1", $this->ddd_telefone_1, "3", "2", false );  
219 - $this->campoTexto( "telefone_1", "Telefone 1", $this->telefone_1, "10", "15", false );  
220 - $this->campoTexto( "ddd_telefone_2", "DDD Telefone 2", $this->ddd_telefone_2, "3", "2", false );  
221 - $this->campoTexto( "telefone_2", "Telefone 2", $this->telefone_2, "10", "15", false );  
222 - $this->campoTexto( "ddd_telefone_mov", "DDD Celular", $this->ddd_telefone_mov, "3", "2", false );  
223 - $this->campoTexto( "telefone_mov", "Celular", $this->telefone_mov, "10", "15", false );  
224 - $this->campoTexto( "ddd_telefone_fax", "DDD Fax", $this->ddd_telefone_fax, "3", "2", false );  
225 - $this->campoTexto( "telefone_fax", "Fax", $this->telefone_fax, "10", "15", false );  
226 -  
227 - $this->campoTexto( "http", "Site", $this->http, "50", "255", false );  
228 - $this->campoTexto( "email", "E-mail", $this->email, "50", "255", false );  
229 -  
230 - /***********************  
231 - Documentos  
232 - ***********************/  
233 - if($this->cod_pessoa_fj)  
234 - {  
235 - $this->campoRotulo("documentos","<b><i>Documentos</i></b>","<a href='#' onclick=\" openPage('adicionar_documentos_cad.php?id_pessoa={$this->cod_pessoa_fj}','400','400','yes', '10','10'); \"><img src='imagens/nvp_bot_ad_doc.png' border='0'></a>");  
236 -  
237 - $this->campoCheck("alterado", "Alterado", $this->alterado);  
238 - }  
239 - }  
240 - }  
241 -  
242 - function Novo()  
243 - {  
244 - @session_start();  
245 - $pessoaFj = $_SESSION['id_pessoa'];  
246 - session_write_close();  
247 - $db = new clsBanco();  
248 - $db2 = new clsBanco();  
249 -  
250 - $ref_cod_sistema = false;  
251 -  
252 - if($this->id_federal)  
253 - {  
254 - $this->id_federal = idFederal2int( $this->id_federal );  
255 - $objCPF = new clsFisica( false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false,false, false, $this->id_federal );  
256 - $detalhe_fisica = $objCPF->detalhe();  
257 - if( $detalhe_fisica['cpf'] )  
258 - {  
259 - $this->erros['id_federal'] = "CPF j&aacute; cadastrado.";  
260 - return false;  
261 - }  
262 - }  
263 -  
264 - $objPessoa = new clsPessoa_( false, $this->nm_pessoa, $pessoaFj, $this->http, "F", false, false, $this->email);  
265 - $idpes = $objPessoa->cadastra();  
266 -  
267 - $this->data_nasc = dataToBanco($this->data_nasc);  
268 -  
269 - if($this->id_federal)  
270 - {  
271 - $objFisica = new clsFisica( $idpes, $this->data_nasc, $this->sexo,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,$ref_cod_sistema, $this->id_federal );  
272 - }else  
273 - {  
274 - $objFisica = new clsFisica( $idpes, $this->data_nasc, $this->sexo,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,$ref_cod_sistema);  
275 - }  
276 - $objFisica->cadastra();  
277 -  
278 - $objTelefone = new clsPessoaTelefone( $idpes, 1, $this->telefone_1, $this->ddd_telefone_1 );  
279 - $objTelefone->cadastra();  
280 - $objTelefone = new clsPessoaTelefone( $idpes, 2, $this->telefone_2, $this->ddd_telefone_2 );  
281 - $objTelefone->cadastra();  
282 - $objTelefone = new clsPessoaTelefone( $idpes, 3, $this->telefone_mov, $this->ddd_telefone_mov );  
283 - $objTelefone->cadastra();  
284 - $objTelefone = new clsPessoaTelefone( $idpes, 4, $this->telefone_fax, $this->ddd_telefone_fax );  
285 - $objTelefone->cadastra();  
286 -  
287 - if($this->cep && $this->idbai && $this->idlog)  
288 - {  
289 - $this->cep = idFederal2Int($this->cep);  
290 - $objEndereco = new clsPessoaEndereco( $idpes );  
291 - $objEndereco2 = new clsPessoaEndereco($idpes, $this->cep,$this->idlog,$this->idbai,$this->numero,$this->complemento,false,$this->letra,$this->bloco,$this->apartamento,$this->andar);  
292 - if( $objEndereco->detalhe() )  
293 - {  
294 - $objEndereco2->edita();  
295 - }  
296 - else  
297 - {  
298 - $objEndereco2->cadastra();  
299 - }  
300 - }  
301 - elseif($this->cep_)  
302 - {  
303 - $this->cep_ = idFederal2int($this->cep_);  
304 - $objEnderecoExterno = new clsEnderecoExterno( $idpes );  
305 - $objEnderecoExterno2 = new clsEnderecoExterno( $idpes, "1",$this->idtlog,$this->logradouro,$this->numero,$this->letra,$this->complemento,$this->bairro,$this->cep_,$this->cidade,$this->sigla_uf,false,$this->bloco,$this->apartamento,$this->andar);  
306 - if( $objEnderecoExterno->detalhe() )  
307 - {  
308 - $objEnderecoExterno2->edita();  
309 - }  
310 - else  
311 - {  
312 - $objEnderecoExterno2->cadastra();  
313 - }  
314 - }  
315 - echo "<script>document.location='atendidos_lst.php';</script>";  
316 -  
317 - return true;  
318 - }  
319 -  
320 - function Editar()  
321 - {  
322 - @session_start();  
323 - $pessoaFj = $_SESSION['id_pessoa'];  
324 - session_write_close();  
325 -  
326 -  
327 - if($this->id_federal)  
328 - {  
329 - $ref_cod_sistema = "null";  
330 - $this->id_federal = idFederal2int( $this->id_federal );  
331 - $objFisicaCpf = new clsFisica($this->cod_pessoa_fj);  
332 - $detalhe_fisica = $objFisicaCpf->detalhe();  
333 -  
334 - if(!$detalhe_fisica['cpf'])  
335 - {  
336 -  
337 - $objCPF = new clsFisica( false, false, false,false, false, false, false,false, false, false, false,false, false, false, false,false, false, false, false,false, false, false, false,false, false, $this->id_federal );  
338 - if( $objCPF->detalhe() )  
339 - {  
340 - $this->erros['id_federal'] = "CPF j&aacute; cadastrado.";  
341 - return false;  
342 - }  
343 - }  
344 - }  
345 -  
346 -  
347 - $objPessoa = new clsPessoa_( $this->cod_pessoa_fj, $this->nm_pessoa, false, $this->p_http, false, $pessoaFj, date( "Y-m-d H:i:s", time() ), $this->email );  
348 - $objPessoa->edita();  
349 -  
350 - $this->data_nasc = dataToBanco($this->data_nasc);  
351 -  
352 - if($this->id_federal)  
353 - {  
354 - $this->id_federal = idFederal2Int($this->id_federal);  
355 - $objFisica = new clsFisica( $this->cod_pessoa_fj, $this->data_nasc, $this->sexo,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,$ref_cod_sistema, $this->id_federal );  
356 - }else  
357 - {  
358 - $objFisica = new clsFisica( $this->cod_pessoa_fj, $this->data_nasc, $this->sexo,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,$ref_cod_sistema);  
359 - }  
360 - $objFisica->edita();  
361 -  
362 - if($this->alterado)  
363 - {  
364 - $db = new clsBanco();  
365 - $db->Consulta("UPDATE cadastro.fisica SET alterado = 'TRUE' WHERE idpes = '$this->cod_pessoa_fj'");  
366 - }  
367 -  
368 -  
369 - $objTelefone = new clsPessoaTelefone( $this->cod_pessoa_fj, 1, $this->telefone_1, $this->ddd_telefone_1 );  
370 - $objTelefone->cadastra();  
371 - $objTelefone = new clsPessoaTelefone( $this->cod_pessoa_fj, 2, $this->telefone_2, $this->ddd_telefone_2 );  
372 - $objTelefone->cadastra();  
373 - $objTelefone = new clsPessoaTelefone( $this->cod_pessoa_fj, 3, $this->telefone_mov, $this->ddd_telefone_mov );  
374 - $objTelefone->cadastra();  
375 - $objTelefone = new clsPessoaTelefone( $this->cod_pessoa_fj, 4, $this->telefone_fax, $this->ddd_telefone_fax );  
376 - $objTelefone->cadastra();  
377 -  
378 -  
379 -  
380 - $objEndereco = new clsPessoaEndereco( $this->cod_pessoa_fj );  
381 - $this->cep = idFederal2Int($this->cep);  
382 - $objEndereco2 = new clsPessoaEndereco($this->cod_pessoa_fj,$this->cep,$this->idlog,$this->idbai,$this->numero,$this->complemento,false,$this->letra, $this->bloco, $this->apartamento,$this->andar);  
383 -  
384 - if( $objEndereco->detalhe() && $this->cep && $this->idlog && $this->idbai)  
385 - {  
386 - $objEndereco2->edita();  
387 - }  
388 - elseif($this->cep && $this->idlog && $this->idbai)  
389 - {  
390 - $objEndereco2->cadastra();  
391 - }  
392 - elseif($objEndereco->detalhe())  
393 - {  
394 - $objEndereco2->exclui();  
395 - }  
396 - else  
397 - {  
398 - $this->cep_ = idFederal2int($this->cep_);  
399 - $objEnderecoExterno = new clsEnderecoExterno($this->cod_pessoa_fj );  
400 -  
401 - $objEnderecoExterno2 = new clsEnderecoExterno($this->cod_pessoa_fj,"1",$this->idtlog,$this->logradouro,$this->numero,$this->letra,$this->complemento,$this->bairro,$this->cep_,$this->cidade,$this->sigla_uf,false,$this->bloco,$this->apartamento,$this->andar);  
402 - if( $objEnderecoExterno->detalhe() )  
403 - {  
404 - $objEnderecoExterno2->edita();  
405 - }  
406 - else  
407 - {  
408 - $objEnderecoExterno2->cadastra();  
409 - }  
410 - }  
411 - echo "<script>document.location='atendidos_lst.php';</script>";  
412 -  
413 - return true;  
414 - }  
415 -  
416 - function Excluir()  
417 - {  
418 - echo "<script>document.location='atendidos_lst.php';</script>";  
419 - return true;  
420 - } 66 + var $cod_pessoa_fj;
  67 + var $nm_pessoa;
  68 + var $id_federal;
  69 + var $data_nasc;
  70 + var $endereco;
  71 + var $cep;
  72 + var $idlog;
  73 + var $idbai;
  74 + var $sigla_uf;
  75 + var $ddd_telefone_1;
  76 + var $telefone_1;
  77 + var $ddd_telefone_2;
  78 + var $telefone_2;
  79 + var $ddd_telefone_mov;
  80 + var $telefone_mov;
  81 + var $ddd_telefone_fax;
  82 + var $telefone_fax;
  83 + var $email;
  84 + var $http;
  85 + var $tipo_pessoa;
  86 + var $sexo;
  87 + var $busca_pessoa;
  88 + var $complemento;
  89 + var $apartamento;
  90 + var $bloco;
  91 + var $andar;
  92 + var $numero;
  93 + var $retorno;
  94 +
  95 + var $caminho_det;
  96 + var $caminho_lst;
  97 +
  98 + var $alterado;
  99 +
  100 + function Inicializar()
  101 + {
  102 + if ($_REQUEST['busca_pessoa']) {
  103 + $this->retorno = 'Novo';
  104 +
  105 + $cpf = idFederal2int($_REQUEST['busca_pessoa']);
  106 +
  107 + $this->busca_pessoa = $cpf;
  108 + $this->id_federal = $cpf;
  109 +
  110 + $objPessoa = new clsPessoaFisica(FALSE, $cpf);
  111 + $detalhePessoa = $objPessoa->detalhe();
  112 +
  113 + $this->cod_pessoa_fj = $detalhePessoa["idpes"];
  114 + }
  115 + elseif ($_REQUEST['cod_pessoa_fj'] != '') {
  116 + $this->busca_pessoa = TRUE;
  117 +
  118 + if ($_REQUEST['cod_pessoa_fj'] != 0) {
  119 + $this->cod_pessoa_fj = $_REQUEST['cod_pessoa_fj'];
  120 + }
  121 + else {
  122 + $this->retorno = 'Novo';
  123 + }
  124 + }
  125 +
  126 + if ($this->cod_pessoa_fj) {
  127 + $this->cod_pessoa_fj = @$_GET['cod_pessoa'] ?
  128 + @$_GET['cod_pessoa'] : $this->cod_pessoa_fj;
  129 +
  130 + $db = new clsBanco();
  131 + $objPessoa = new clsPessoaFisica();
  132 +
  133 + list($this->nm_pessoa, $this->id_federal, $this->data_nasc,
  134 + $this->ddd_telefone_1, $this->telefone_1, $this->ddd_telefone_2,
  135 + $this->telefone_2, $this->ddd_telefone_mov, $this->telefone_mov,
  136 + $this->ddd_telefone_fax, $this->telefone_fax, $this->email,
  137 + $this->http, $this->tipo_pessoa, $this->sexo, $this->cidade,
  138 + $this->bairro, $this->logradouro, $this->cep, $this->idlog, $this->idbai,
  139 + $this->idtlog, $this->sigla_uf, $this->complemento, $this->numero,
  140 + $this->bloco, $this->apartamento, $this->andar
  141 + ) =
  142 + $objPessoa->queryRapida(
  143 + $this->cod_pessoa_fj, 'nome', 'cpf', 'data_nasc', 'ddd_1', 'fone_1',
  144 + 'ddd_2', 'fone_2', 'ddd_mov', 'fone_mov', 'ddd_fax', 'fone_fax', 'email',
  145 + 'url', 'tipo', 'sexo', 'cidade', 'bairro', 'logradouro', 'cep', 'idlog',
  146 + 'idbai', 'idtlog', 'sigla_uf', 'complemento', 'numero', 'bloco', 'apartamento',
  147 + 'andar'
  148 + );
  149 +
  150 + $this->cep = int2Cep($this->cep);
  151 + $this->retorno = 'Editar';
  152 + }
  153 +
  154 + $this->nome_url_cancelar = 'Cancelar';
  155 +
  156 + return $this->retorno;
  157 + }
  158 +
  159 + function Gerar()
  160 + {
  161 + $this->addBanner('imagens/nvp_top_intranet.jpg',
  162 + 'imagens/nvp_vert_intranet.jpg', 'Intranet', FALSE);
  163 +
  164 + if (! $this->busca_pessoa) {
  165 + $this->campoOculto('cod_pessoa_fj', '');
  166 +
  167 + $parametros = new clsParametrosPesquisas();
  168 + $parametros->setSubmit(1);
  169 + $parametros->adicionaCampoTexto('busca_pessoa', 'id_federal');
  170 + $parametros->adicionaCampoTexto('cod_pessoa_fj', 'idpes');
  171 + $parametros->setPessoa('F');
  172 + $parametros->setPessoaCampo('cod_pessoa_fj');
  173 + $parametros->setPessoaNovo('S');
  174 + $parametros->setPessoaTela('window');
  175 +
  176 + $html = sprintf(
  177 + '<img id="lupa" src="imagens/lupa.png" border="0" ' .
  178 + "onclick=\"showExpansivel(500, 500, '<iframe name=\'miolo\' id=\'miolo\' frameborder=\'0\' height=\'100%%\' width=\'500\' marginheight=\'0\' marginwidth=\'0\' src=\'pesquisa_pessoa_lst.php?campos=%s\'></iframe>');\"".
  179 + '>',
  180 + $parametros->serializaCampos()
  181 + );
  182 +
  183 + $this->campoCpf('busca_pessoa', 'CPF', $this->ref_cod_pessoa_fj, TRUE,
  184 + $html, FALSE, TRUE);
  185 + }
  186 + else {
  187 + $this->campoOculto('busca_pessoa', $this->busca_pessoa);
  188 +
  189 + $this->url_cancelar = $this->retorno == 'Editar' ?
  190 + 'atendidos_det.php?cod_pessoa=' . $this->cod_pessoa_fj : 'atendidos_lst.php';
  191 +
  192 + $this->campoOculto('cod_pessoa_fj', $this->cod_pessoa_fj);
  193 + $this->campoTexto('nm_pessoa', 'Nome', $this->nm_pessoa, '50', '255', TRUE);
  194 +
  195 + if ($this->id_federal) {
  196 + $this->campoRotulo('id_federal', 'CPF', int2CPF($this->id_federal));
  197 + }
  198 + else {
  199 + $this->campoCpf('id_federal', 'CPF', '', FALSE);
  200 + }
  201 +
  202 + if ($this->data_nasc) {
  203 + $this->data_nasc = dataFromPgToBr($this->data_nasc);
  204 + }
  205 +
  206 + $this->campoData('data_nasc', 'Data de Nascimento', $this->data_nasc);
  207 +
  208 + $lista_sexos = array();
  209 + $lista_sexos[''] = 'Escolha uma opção...';
  210 + $lista_sexos['M'] = 'Masculino';
  211 + $lista_sexos['F'] = 'Feminino';
  212 + $this->campoLista('sexo', 'Sexo', $lista_sexos, $this->sexo);
  213 +
  214 + // Detalhes do Endereço
  215 + $objTipoLog = new clsTipoLogradouro();
  216 + $listaTipoLog = $objTipoLog->lista();
  217 + $listaTLog = array('0' => 'Selecione');
  218 +
  219 + if ($listaTipoLog) {
  220 + foreach ($listaTipoLog as $tipoLog) {
  221 + $listaTLog[$tipoLog['idtlog']] = $tipoLog['descricao'];
  222 + }
  223 + }
  224 +
  225 + $objUf = new clsUf();
  226 + $listauf = $objUf->lista();
  227 + $listaEstado = array('0' => 'Selecione');
  228 +
  229 + if ($listauf) {
  230 + foreach ($listauf as $uf) {
  231 + $listaEstado[$uf['sigla_uf']] = $uf['sigla_uf'];
  232 + }
  233 + }
  234 +
  235 + $this->campoOculto('idbai', $this->idbai);
  236 + $this->campoOculto('idlog', $this->idlog);
  237 + $this->campoOculto('cep', $this->cep);
  238 + $this->campoOculto('ref_sigla_uf', $this->sigla_uf);
  239 + $this->campoOculto('ref_idtlog', $this->idtlog);
  240 + $this->campoOculto('id_cidade', $this->cidade);
  241 +
  242 + if ($this->idlog && $this->idbai && $this->cep && $this->cod_pessoa_fj) {
  243 + $this->campoCep('cep_', 'CEP', $this->cep, true, '-',
  244 + "&nbsp;<img id='lupa' src=\"imagens/lupa.png\" border=\"0\" onclick=\"showExpansivel( 500,500, '<iframe name=\'miolo\' id=\'miolo\' frameborder=\'0\' height=\'100%\' width=\'500\' marginheight=\'0\' marginwidth=\'0\' src=\'educar_pesquisa_cep_log_bairro.php?campo1=bairro&campo2=idbai&campo3=cep&campo4=logradouro&campo5=idlog&campo6=ref_sigla_uf&campo7=cidade&campo8=ref_idtlog&campo9=isEnderecoExterno&campo10=cep_&campo11=sigla_uf&campo12=idtlog&campo13=id_cidade\'></iframe>');\">",
  245 + TRUE);
  246 +
  247 + $this->campoLista('idtlog', 'Tipo Logradouro', $listaTLog, $this->idtlog,
  248 + FALSE, FALSE, FALSE, FALSE, TRUE);
  249 +
  250 + $this->campoTextoInv('logradouro', 'Logradouro', $this->logradouro,
  251 + '50', '255', FALSE);
  252 +
  253 + $this->campoTextoInv('cidade', 'Cidade', $this->cidade, '50', '255',
  254 + FALSE);
  255 +
  256 + $this->campoTextoInv('bairro', 'Bairro', $this->bairro, '50', '255', FALSE);
  257 +
  258 + $this->campoTexto('complemento', 'Complemento', $this->complemento, '50', '255',
  259 + FALSE);
  260 +
  261 + $this->campoTexto('numero', 'Número', $this->numero, '10', '10');
  262 +
  263 + $this->campoTexto('letra', 'Letra', $this->letra, '1', '1', FALSE);
  264 +
  265 + $this->campoTexto('apartamento', 'Número Apartamento', $this->apartamento, '6', '6',
  266 + FALSE);
  267 +
  268 + $this->campoTexto('bloco', 'Bloco', $this->bloco, '20', '20', FALSE);
  269 + $this->campoTexto('andar', 'Andar', $this->andar, '2', '2', FALSE);
  270 +
  271 + $this->campoLista('sigla_uf', 'Estado', $listaEstado, $this->sigla_uf,
  272 + FALSE, FALSE, FALSE, FALSE, TRUE);
  273 + }
  274 + elseif($this->cod_pessoa_fj && $this->cep) {
  275 + $this->campoCep('cep_', 'CEP', $this->cep, true, '-',
  276 + "&nbsp;<img id='lupa' src=\"imagens/lupa.png\" border=\"0\" onclick=\"showExpansivel( 500,500, '<iframe name=\'miolo\' id=\'miolo\' frameborder=\'0\' height=\'100%\' width=\'500\' marginheight=\'0\' marginwidth=\'0\' src=\'educar_pesquisa_cep_log_bairro.php?campo1=bairro&campo2=idbai&campo3=cep&campo4=logradouro&campo5=idlog&campo6=ref_sigla_uf&campo7=cidade&campo8=ref_idtlog&campo9=isEnderecoExterno&campo10=cep_&campo11=sigla_uf&campo12=idtlog&campo13=id_cidade\'></iframe>');\">",
  277 + $disabled);
  278 +
  279 + $this->campoLista('idtlog', 'Tipo Logradouro', $listaTLog, $this->idtlog);
  280 +
  281 + $this->campoTexto('logradouro', 'Logradouro', $this->logradouro, '50',
  282 + '255', FALSE);
  283 +
  284 + $this->campoTexto('cidade', 'Cidade', $this->cidade, '50', '255', FALSE);
  285 +
  286 + $this->campoTexto('bairro', 'Bairro', $this->bairro, '50', '255', FALSE);
  287 +
  288 + $this->campoTexto('complemento', 'Complemento', $this->complemento, '50',
  289 + '255', FALSE);
  290 +
  291 + $this->campoTexto('numero', 'Número', $this->numero, '10', '10');
  292 +
  293 + $this->campoTexto('letra', 'Letra', $this->letra, '1', '1', FALSE);
  294 +
  295 + $this->campoTexto('apartamento', 'Número Apartamento', $this->apartamento,
  296 + '6', '6', FALSE);
  297 +
  298 + $this->campoTexto('bloco', 'Bloco', $this->bloco, '20', '20', FALSE);
  299 +
  300 + $this->campoTexto('andar', 'Andar', $this->andar, '2', '2', FALSE);
  301 +
  302 + $this->campoLista('sigla_uf', 'Estado', $listaEstado, $this->sigla_uf);
  303 + }
  304 + else {
  305 + $this->campoCep('cep_', 'CEP', $this->cep, TRUE, '-',
  306 + "&nbsp;<img id='lupa' src=\"imagens/lupa.png\" border=\"0\" onclick=\"showExpansivel( 500,500, '<iframe name=\'miolo\' id=\'miolo\' frameborder=\'0\' height=\'100%\' width=\'500\' marginheight=\'0\' marginwidth=\'0\' src=\'educar_pesquisa_cep_log_bairro.php?campo1=bairro&campo2=idbai&campo3=cep&campo4=logradouro&campo5=idlog&campo6=ref_sigla_uf&campo7=cidade&campo8=ref_idtlog&campo9=isEnderecoExterno&campo10=cep_&campo11=sigla_uf&campo12=idtlog&campo13=id_cidade\'></iframe>');\">", false/*$disabled*/);
  307 +
  308 + $this->campoLista('idtlog', 'Tipo Logradouro', $listaTLog, $this->idtlog,
  309 + FALSE, FALSE, FALSE, FALSE, FALSE);
  310 +
  311 + $this->campoTexto('logradouro', 'Logradouro', $this->logradouro,
  312 + '50', '255');
  313 +
  314 + $this->campoTexto('cidade', 'Cidade', $this->cidade, '50', '255');
  315 +
  316 + $this->campoTexto('bairro', 'Bairro', $this->bairro, '50', '255');
  317 +
  318 + $this->campoTexto('complemento', 'Complemento', $this->complemento,
  319 + '50', '255', FALSE);
  320 +
  321 + $this->campoTexto('numero', 'Número', $this->numero, '10', '10');
  322 +
  323 + $this->campoTexto('letra', 'Letra', $this->letra, '1', '1', FALSE);
  324 +
  325 + $this->campoTexto('apartamento', 'Número Apartamento', $this->apartamento,
  326 + '6', '6', FALSE);
  327 +
  328 + $this->campoTexto('bloco', 'Bloco', $this->bloco, '20', '20', FALSE);
  329 +
  330 + $this->campoTexto('andar', 'Andar', $this->andar, '2', '2', FALSE);
  331 +
  332 + $this->campoLista('sigla_uf', 'Estado', $listaEstado, $this->sigla_uf,
  333 + FALSE, FALSE, FALSE, FALSE, FALSE);
  334 + }
  335 +
  336 + $this->campoTexto('ddd_telefone_1', 'DDD Telefone 1', $this->ddd_telefone_1,
  337 + '3', '2', FALSE);
  338 +
  339 + $this->campoTexto('telefone_1', 'Telefone 1', $this->telefone_1, '10',
  340 + '15', FALSE);
  341 +
  342 + $this->campoTexto('ddd_telefone_2', 'DDD Telefone 2', $this->ddd_telefone_2,
  343 + '3', '2', FALSE);
  344 +
  345 + $this->campoTexto('telefone_2', 'Telefone 2', $this->telefone_2, '10',
  346 + '15', FALSE);
  347 +
  348 + $this->campoTexto('ddd_telefone_mov', 'DDD Celular',
  349 + $this->ddd_telefone_mov, '3', '2', FALSE);
  350 +
  351 + $this->campoTexto('telefone_mov', 'Celular', $this->telefone_mov, '10',
  352 + '15', FALSE);
  353 +
  354 + $this->campoTexto('ddd_telefone_fax', 'DDD Fax', $this->ddd_telefone_fax,
  355 + '3', '2', FALSE);
  356 +
  357 + $this->campoTexto('telefone_fax', 'Fax', $this->telefone_fax, '10', '15',
  358 + FALSE);
  359 +
  360 + $this->campoTexto('http', 'Site', $this->http, '50', '255', FALSE);
  361 +
  362 + $this->campoTexto('email', 'E-mail', $this->email, '50', '255', FALSE);
  363 +
  364 + if ($this->cod_pessoa_fj) {
  365 + $this->campoRotulo('documentos', '<b><i>Documentos</i></b>',
  366 + "<a href='#' onclick=\"openPage('adicionar_documentos_cad.php?id_pessoa={$this->cod_pessoa_fj}', '400', '400', 'yes', '10', '10'); \"><img src='imagens/nvp_bot_ad_doc.png' border='0'></a>");
  367 +
  368 + $this->campoCheck('alterado', 'Alterado', $this->alterado);
  369 + }
  370 + }
  371 + }
  372 +
  373 + function Novo()
  374 + {
  375 + @session_start();
  376 + $pessoaFj = $_SESSION['id_pessoa'];
  377 + session_write_close();
  378 +
  379 + $db = new clsBanco();
  380 + $db2 = new clsBanco();
  381 +
  382 + $ref_cod_sistema = FALSE;
  383 +
  384 + if ($this->id_federal) {
  385 + $this->id_federal = idFederal2int($this->id_federal);
  386 +
  387 + $objCPF = new clsFisica(FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
  388 + FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
  389 + FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, $this->id_federal);
  390 +
  391 + $detalhe_fisica = $objCPF->detalhe();
  392 + if ($detalhe_fisica['cpf']) {
  393 + $this->erros['id_federal'] = 'CPF já cadastrado.';
  394 + return FALSE;
  395 + }
  396 + }
  397 +
  398 + $objPessoa = new clsPessoa_(FALSE, $this->nm_pessoa, $pessoaFj, $this->http,
  399 + 'F', FALSE, FALSE, $this->email);
  400 +
  401 + $idpes = $objPessoa->cadastra();
  402 +
  403 + $this->data_nasc = dataToBanco($this->data_nasc);
  404 +
  405 + if ($this->id_federal) {
  406 + $objFisica = new clsFisica($idpes, $this->data_nasc, $this->sexo, FALSE,
  407 + FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
  408 + FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
  409 + $ref_cod_sistema, $this->id_federal);
  410 + }
  411 + else {
  412 + $objFisica = new clsFisica($idpes, $this->data_nasc, $this->sexo, FALSE,
  413 + FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
  414 + FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
  415 + $ref_cod_sistema);
  416 + }
  417 +
  418 + $objFisica->cadastra();
421 419
  420 + $objTelefone = new clsPessoaTelefone($idpes, 1, $this->telefone_1, $this->ddd_telefone_1);
  421 + $objTelefone->cadastra();
  422 +
  423 + $objTelefone = new clsPessoaTelefone($idpes, 2, $this->telefone_2, $this->ddd_telefone_2);
  424 + $objTelefone->cadastra();
  425 +
  426 + $objTelefone = new clsPessoaTelefone($idpes, 3, $this->telefone_mov, $this->ddd_telefone_mov);
  427 + $objTelefone->cadastra();
  428 +
  429 + $objTelefone = new clsPessoaTelefone($idpes, 4, $this->telefone_fax, $this->ddd_telefone_fax);
  430 + $objTelefone->cadastra();
  431 +
  432 + if ($this->cep && $this->idbai && $this->idlog) {
  433 + $this->cep = idFederal2Int($this->cep);
  434 + $objEndereco = new clsPessoaEndereco($idpes);
  435 + $objEndereco2 = new clsPessoaEndereco($idpes, $this->cep, $this->idlog,
  436 + $this->idbai, $this->numero, $this->complemento, FALSE, $this->letra,
  437 + $this->bloco, $this->apartamento, $this->andar);
  438 +
  439 + if ($objEndereco->detalhe()) {
  440 + $objEndereco2->edita();
  441 + }
  442 + else {
  443 + $objEndereco2->cadastra();
  444 + }
  445 + }
  446 + elseif($this->cep_) {
  447 + $this->cep_ = idFederal2int($this->cep_);
  448 +
  449 + $objEnderecoExterno = new clsEnderecoExterno($idpes);
  450 + $objEnderecoExterno2 = new clsEnderecoExterno($idpes, '1', $this->idtlog,
  451 + $this->logradouro, $this->numero, $this->letra, $this->complemento,
  452 + $this->bairro, $this->cep_, $this->cidade, $this->sigla_uf, FALSE,
  453 + $this->bloco, $this->apartamento, $this->andar);
  454 +
  455 + if ($objEnderecoExterno->detalhe()) {
  456 + $objEnderecoExterno2->edita();
  457 + }
  458 + else {
  459 + $objEnderecoExterno2->cadastra();
  460 + }
  461 + }
  462 +
  463 + echo '<script>document.location="atendidos_lst.php";</script>';
  464 + return TRUE;
  465 + }
  466 +
  467 + function Editar()
  468 + {
  469 + @session_start();
  470 + $pessoaFj = $_SESSION['id_pessoa'];
  471 + session_write_close();
  472 +
  473 + if ($this->id_federal) {
  474 + $ref_cod_sistema = 'null';
  475 + $this->id_federal = idFederal2int($this->id_federal);
  476 +
  477 + $objFisicaCpf = new clsFisica($this->cod_pessoa_fj);
  478 + $detalhe_fisica = $objFisicaCpf->detalhe();
  479 +
  480 + if (! $detalhe_fisica['cpf']) {
  481 + $objCPF = new clsFisica(FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
  482 + FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
  483 + FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, $this->id_federal);
  484 +
  485 + if ($objCPF->detalhe()) {
  486 + $this->erros['id_federal'] = 'CPF já cadastrado.';
  487 + return FALSE;
  488 + }
  489 + }
  490 + }
  491 +
  492 + $objPessoa = new clsPessoa_($this->cod_pessoa_fj, $this->nm_pessoa, FALSE,
  493 + $this->p_http, FALSE, $pessoaFj, date('Y-m-d H:i:s', time()), $this->email);
  494 +
  495 + $objPessoa->edita();
  496 +
  497 + $this->data_nasc = dataToBanco($this->data_nasc);
  498 +
  499 + if ($this->id_federal) {
  500 + $this->id_federal = idFederal2Int($this->id_federal);
  501 + $objFisica = new clsFisica($this->cod_pessoa_fj, $this->data_nasc,
  502 + $this->sexo, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
  503 + FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
  504 + FALSE, FALSE, FALSE, $ref_cod_sistema, $this->id_federal);
  505 + }
  506 + else {
  507 + $objFisica = new clsFisica($this->cod_pessoa_fj, $this->data_nasc,
  508 + $this->sexo, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
  509 + FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
  510 + FALSE, FALSE, FALSE, $ref_cod_sistema);
  511 + }
  512 +
  513 + $objFisica->edita();
  514 +
  515 + if ($this->alterado) {
  516 + $db = new clsBanco();
  517 + $db->Consulta("UPDATE cadastro.fisica SET alterado = 'TRUE' WHERE idpes = '$this->cod_pessoa_fj'");
  518 + }
  519 +
  520 + $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 1,
  521 + $this->telefone_1, $this->ddd_telefone_1);
  522 + $objTelefone->cadastra();
  523 +
  524 + $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 2,
  525 + $this->telefone_2, $this->ddd_telefone_2);
  526 + $objTelefone->cadastra();
  527 +
  528 + $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 3,
  529 + $this->telefone_mov, $this->ddd_telefone_mov);
  530 + $objTelefone->cadastra();
  531 +
  532 + $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 4,
  533 + $this->telefone_fax, $this->ddd_telefone_fax);
  534 + $objTelefone->cadastra();
  535 +
  536 + $objEndereco = new clsPessoaEndereco($this->cod_pessoa_fj);
  537 +
  538 + $this->cep = idFederal2Int($this->cep);
  539 +
  540 + $objEndereco2 = new clsPessoaEndereco($this->cod_pessoa_fj, $this->cep,
  541 + $this->idlog, $this->idbai, $this->numero, $this->complemento, FALSE,
  542 + $this->letra, $this->bloco, $this->apartamento,$this->andar);
  543 +
  544 + if ($objEndereco->detalhe() && $this->cep && $this->idlog && $this->idbai) {
  545 + $objEndereco2->edita();
  546 + }
  547 + elseif ($this->cep && $this->idlog && $this->idbai) {
  548 + $objEndereco2->cadastra();
  549 + }
  550 + elseif ($objEndereco->detalhe()) {
  551 + $objEndereco2->exclui();
  552 + }
  553 + else {
  554 + $this->cep_ = idFederal2int($this->cep_);
  555 + $objEnderecoExterno = new clsEnderecoExterno($this->cod_pessoa_fj);
  556 +
  557 + $objEnderecoExterno2 = new clsEnderecoExterno($this->cod_pessoa_fj, '1',
  558 + $this->idtlog, $this->logradouro, $this->numero, $this->letra,
  559 + $this->complemento, $this->bairro, $this->cep_, $this->cidade,
  560 + $this->sigla_uf, FALSE, $this->bloco, $this->apartamento, $this->andar);
  561 +
  562 + if ($objEnderecoExterno->detalhe()) {
  563 + $objEnderecoExterno2->edita();
  564 + }
  565 + else {
  566 + $objEnderecoExterno2->cadastra();
  567 + }
  568 + }
  569 +
  570 + echo '<script>document.location="atendidos_lst.php";</script>';
  571 + return TRUE;
  572 + }
  573 +
  574 + function Excluir()
  575 + {
  576 + echo '<script>document.location="atendidos_lst.php";</script>';
  577 + return TRUE;
  578 + }
422 } 579 }
423 580
  581 +// Instancia objeto de página
424 $pagina = new clsIndex(); 582 $pagina = new clsIndex();
425 583
  584 +// Instancia objeto de conteúdo
426 $miolo = new indice(); 585 $miolo = new indice();
427 -$pagina->addForm( $miolo );  
428 586
429 -$pagina->MakeAll(); 587 +// Atribui o conteúdo à página
  588 +$pagina->addForm($miolo);
430 589
431 -?> 590 +// Gera o código HTML
  591 +$pagina->MakeAll();
432 \ No newline at end of file 592 \ No newline at end of file