Commit c1eb42beae5178dc0c9093da97074e4436ea0904
1 parent
d09dab0c
Exists in
master
Refactoring para coding standards
Showing
1 changed file
with
491 additions
and
436 deletions
Show diff stats
ieducar/intranet/include/pessoa/clsPessoaFj.inc.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/clsBanco.inc.php"); | ||
28 | 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_Cadastro | ||
27 | + * @since Arquivo disponível desde a versão 1.0.0 | ||
28 | + * @version $Id$ | ||
29 | + */ | ||
30 | + | ||
31 | +require_once 'include/clsBanco.inc.php'; | ||
32 | + | ||
33 | +/** | ||
34 | + * clsPessoaFj class. | ||
35 | + * | ||
36 | + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br> | ||
37 | + * @category i-Educar | ||
38 | + * @license @@license@@ | ||
39 | + * @package iEd_Cadastro | ||
40 | + * @since Classe disponível desde a versão 1.0.0 | ||
41 | + * @version @@package_version@@ | ||
42 | + */ | ||
29 | class clsPessoaFj | 43 | class clsPessoaFj |
30 | { | 44 | { |
31 | - // Vari�veis da Pessoa | ||
32 | - var $idpes; | ||
33 | - var $nome; | ||
34 | - var $idpes_cad; | ||
35 | - var $data_cad; | ||
36 | - var $url; | ||
37 | - var $tipo; | ||
38 | - var $idpes_rev; | ||
39 | - var $data_rev; | ||
40 | - var $situacao; | ||
41 | - var $origem_gravacao; | ||
42 | - var $email; | ||
43 | - var $data_nasc; | ||
44 | - // Vari�veis de Endereco | ||
45 | - var $bairro; | ||
46 | - var $idbai; | ||
47 | - var $logradouro; | ||
48 | - var $idlog; | ||
49 | - var $idtlog; | ||
50 | - var $cidade; | ||
51 | - var $idmun; | ||
52 | - var $sigla_uf; | ||
53 | - var $pais; | ||
54 | - var $complemento; | ||
55 | - var $reside_desde; | ||
56 | - var $letra; | ||
57 | - var $numero; | ||
58 | - var $cep; | ||
59 | - var $bloco; | ||
60 | - var $apartamento; | ||
61 | - var $andar; | ||
62 | - // Vari�veis de Telefone | ||
63 | - var $ddd_1; | ||
64 | - var $fone_1; | ||
65 | - var $ddd_2; | ||
66 | - var $fone_2; | ||
67 | - var $ddd_fax; | ||
68 | - var $fone_fax; | ||
69 | - var $ddd_mov; | ||
70 | - var $fone_mov; | ||
71 | - //Variaveis de documentacao | ||
72 | - var $rg; | ||
73 | - var $cpf; | ||
74 | - | ||
75 | - var $_total; | ||
76 | - | ||
77 | - var $banco = 'gestao_homolog'; | ||
78 | - var $schema_cadastro = "cadastro"; | ||
79 | - var $tabela_pessoa = "pessoa"; | ||
80 | - | ||
81 | - | ||
82 | - function clsPessoaFj($int_idpes = false ) | ||
83 | - { | ||
84 | - $this->idpes = $int_idpes; | ||
85 | - } | ||
86 | - | ||
87 | - | ||
88 | - function lista($str_nome = false, $inicio_limite = false, $qtd_registros = false, $str_orderBy = false, $arrayint_idisin=false, $arrayint_idnotin = false, $str_tipo_pessoa = false ) | ||
89 | - { | ||
90 | - $objPessoa = new clsPessoa_(); | ||
91 | - $listaPessoa = $objPessoa->lista($str_nome,$inicio_limite,$qtd_registros,$str_orderBy,$arrayint_idisin,$arrayint_idnotin,$str_tipo_pessoa); | ||
92 | - if(count($listaPessoa) > 0) | ||
93 | - { | ||
94 | - return $listaPessoa; | ||
95 | - } | ||
96 | - return false; | ||
97 | - } | ||
98 | - | ||
99 | - /*function lista_rapida($idpes = null, $nome = null, $id_federal = null, $inicio_limite = null, $limite = null, $str_tipo_pessoa = null, $str_order_by = null, $int_ref_cod_sistema = null) | ||
100 | - { | ||
101 | - $db = new clsBanco(); | ||
102 | - | ||
103 | - $filtros = ""; | ||
104 | - $filtroTipo = ""; | ||
105 | - $whereAnd = " WHERE "; | ||
106 | - $outros_filtros = false; | ||
107 | - $filtro_cnpj = false; | ||
108 | - | ||
109 | - if( is_string( $nome ) && $nome != "") | ||
110 | - { | ||
111 | - $filtros .= "{$whereAnd} (nome ILIKE '%{$nome}%')"; | ||
112 | - $whereAnd = " AND "; | ||
113 | - $outros_filtros =true; | ||
114 | - } | ||
115 | - | ||
116 | - if( is_numeric( $id_federal ) ) | ||
117 | - { | ||
118 | - $filtros .= "{$whereAnd} id_federal LIKE '%{$id_federal}'"; | ||
119 | - $whereAnd = " AND "; | ||
120 | - $filtro_cnpj =true; | ||
121 | - } | ||
122 | - | ||
123 | - | ||
124 | - if( is_numeric( $idpes ) ) | ||
125 | - { | ||
126 | - $filtros .= "{$whereAnd} idpes = '{$idpes}'"; | ||
127 | - $whereAnd = " AND "; | ||
128 | - $outros_filtros =true; | ||
129 | - } | ||
130 | - | ||
131 | - if( is_numeric( $int_ref_cod_sistema ) ) | ||
132 | - { | ||
133 | - $filtro_sistema = true; | ||
134 | - $filtros .= "{$whereAnd} (ref_cod_sistema = '{$int_ref_cod_sistema}' OR id_federal is not null)"; | ||
135 | - $whereAnd = " AND "; | ||
136 | - } | ||
137 | - | ||
138 | - if ( is_string( $str_tipo_pessoa ) ) { | ||
139 | - $filtroTipo .= " AND tipo = '{$str_tipo_pessoa}' "; | ||
140 | - $outros_filtros =true; | ||
141 | - } | ||
142 | - | ||
143 | - if ( is_string( $str_order_by ) ) { | ||
144 | - $order = "ORDER BY $str_order_by"; | ||
145 | - } | ||
146 | - | ||
147 | - $limit = ""; | ||
148 | - if(is_numeric($inicio_limite) && is_numeric($limite)) | ||
149 | - { | ||
150 | - $limit = "LIMIT $limite OFFSET $inicio_limite"; | ||
151 | - } | ||
152 | - | ||
153 | - if($filtro_sistema && $outros_filtros == false || $filtro_cnpj ) | ||
154 | - { | ||
155 | - $this->_total = $db->CampoUnico("SELECT COUNT(0) FROM cadastro.v_pessoafj_count $filtros"); | ||
156 | - }else | ||
157 | - { | ||
158 | - $this->_total = $db->CampoUnico("SELECT COUNT(0) FROM cadastro.v_pessoa_fj $filtros"); | ||
159 | - } | ||
160 | - | ||
161 | - $db->Consulta("SELECT idpes, nome, ref_cod_sistema, fantasia, tipo , id_federal as cpf, id_federal as cnpj, id_federal FROM cadastro.v_pessoa_fj $filtros $order $limit "); | ||
162 | - while ( $db->ProximoRegistro() ) | ||
163 | - { | ||
164 | - $tupla = $db->Tupla(); | ||
165 | - $tupla["_total"] = $this->_total; | ||
166 | - $resultado[] = $tupla; | ||
167 | - } | ||
168 | - | ||
169 | - if( count( $resultado ) ) | ||
170 | - { | ||
171 | - return $resultado; | ||
172 | - } | ||
173 | - return false; | ||
174 | - }*/ | ||
175 | - | ||
176 | - function lista_rapida($idpes = null, $nome = null, $id_federal = null, $inicio_limite = null, $limite = null, $str_tipo_pessoa = null, $str_order_by = null, $int_ref_cod_sistema = null) | ||
177 | - { | ||
178 | - $db = new clsBanco(); | ||
179 | - | ||
180 | - $filtros = ""; | ||
181 | - $filtroTipo = ""; | ||
182 | - $whereAnd = " WHERE "; | ||
183 | - $outros_filtros = false; | ||
184 | - $filtro_cnpj = false; | ||
185 | - | ||
186 | - if( is_string( $nome ) && $nome != "") | ||
187 | - { | ||
188 | - $filtros .= "{$whereAnd} (nome ILIKE '%{$nome}%')"; | ||
189 | - $whereAnd = " AND "; | ||
190 | - $outros_filtros =true; | ||
191 | - } | ||
192 | - | ||
193 | - if( is_numeric( $idpes ) ) | ||
194 | - { | ||
195 | - $filtros .= "{$whereAnd} idpes = '{$idpes}'"; | ||
196 | - $whereAnd = " AND "; | ||
197 | - $outros_filtros =true; | ||
198 | - } | ||
199 | - | ||
200 | - if( is_numeric( $int_ref_cod_sistema ) ) | ||
201 | - { | ||
202 | - $filtro_sistema = true; | ||
203 | - $filtros .= "{$whereAnd} (ref_cod_sistema = '{$int_ref_cod_sistema}' OR id_federal is not null)"; | ||
204 | - $whereAnd = " AND "; | ||
205 | - } | ||
206 | - | ||
207 | - if( is_numeric( $id_federal ) ) | ||
208 | - { | ||
209 | - $db2 = new clsBanco(); | ||
210 | - $db2->Consulta("SELECT idpes FROM cadastro.fisica WHERE cpf LIKE '%{$id_federal}%'"); | ||
211 | - | ||
212 | - $array_idpes = null; | ||
213 | - while ($db2->ProximoRegistro()) | ||
214 | - { | ||
215 | - list($id_pes) = $db2->Tupla(); | ||
216 | - $array_idpes[] = $id_pes; | ||
217 | - } | ||
218 | - | ||
219 | - $db2->Consulta("SELECT idpes FROM cadastro.juridica WHERE cnpj LIKE '%{$id_federal}%'"); | ||
220 | - while ($db2->ProximoRegistro()) | ||
221 | - { | ||
222 | - list($id_pes) = $db2->Tupla(); | ||
223 | - $array_idpes[] = $id_pes; | ||
224 | - } | ||
225 | - | ||
226 | - if(is_array($array_idpes)) | ||
227 | - { | ||
228 | - $array_idpes = implode(", ", $array_idpes); | ||
229 | - $filtros .= "{$whereAnd} idpes IN ($array_idpes)"; | ||
230 | - $whereAnd = " AND "; | ||
231 | - $filtro_idfederal = true; | ||
232 | - } | ||
233 | - else | ||
234 | - { | ||
235 | - return false; | ||
236 | - } | ||
237 | - } | ||
238 | - | ||
239 | - if ( is_string( $str_tipo_pessoa ) ) { | ||
240 | - $filtroTipo .= " AND tipo = '{$str_tipo_pessoa}' "; | ||
241 | - $outros_filtros =true; | ||
242 | - } | ||
243 | - | ||
244 | - if ( is_string( $str_order_by ) ) { | ||
245 | - $order = "ORDER BY $str_order_by"; | ||
246 | - } | ||
247 | - | ||
248 | - $limit = ""; | ||
249 | - if(is_numeric($inicio_limite) && is_numeric($limite)) | ||
250 | - { | ||
251 | - $limit = "LIMIT $limite OFFSET $inicio_limite"; | ||
252 | - } | ||
253 | - | ||
254 | - if($filtro_idfederal) | ||
255 | - { | ||
256 | - $this->_total = $db->CampoUnico("SELECT COUNT(0) FROM cadastro.v_pessoa_fj $filtros"); | ||
257 | - } | ||
258 | - else | ||
259 | - { | ||
260 | - if($filtro_sistema && $outros_filtros == false || $filtro_cnpj ) | ||
261 | - { | ||
262 | - $this->_total = $db->CampoUnico("SELECT COUNT(0) FROM cadastro.v_pessoafj_count $filtros"); | ||
263 | - }else | ||
264 | - { | ||
265 | - $this->_total = $db->CampoUnico("SELECT COUNT(0) FROM cadastro.v_pessoa_fj $filtros"); | ||
266 | - } | ||
267 | - } | ||
268 | - | ||
269 | - echo "<!-- SELECT idpes, nome, ref_cod_sistema, fantasia, tipo , id_federal as cpf, id_federal as cnpj, id_federal FROM cadastro.v_pessoa_fj $filtros $order $limit -->"; | ||
270 | - | ||
271 | - $db->Consulta("SELECT idpes, nome, ref_cod_sistema, fantasia, tipo , id_federal as cpf, id_federal as cnpj, id_federal FROM cadastro.v_pessoa_fj $filtros $order $limit "); | ||
272 | - while ( $db->ProximoRegistro() ) | ||
273 | - { | ||
274 | - $tupla = $db->Tupla(); | ||
275 | - $tupla["_total"] = $this->_total; | ||
276 | - $resultado[] = $tupla; | ||
277 | - } | ||
278 | - | ||
279 | - if( count( $resultado ) ) | ||
280 | - { | ||
281 | - return $resultado; | ||
282 | - } | ||
283 | - return false; | ||
284 | - } | ||
285 | - | ||
286 | - function detalhe() | ||
287 | - { | ||
288 | - if($this->idpes) | ||
289 | - { | ||
290 | - $objPessoa = new clsPessoa_($this->idpes); | ||
291 | - $detalhePessoa = $objPessoa->detalhe(); | ||
292 | - | ||
293 | - $objEndereco = new clsEndereco($this->idpes); | ||
294 | - $detalheEndereco = $objEndereco->detalhe(); | ||
295 | - | ||
296 | - | ||
297 | - if($detalheEndereco) | ||
298 | - { | ||
299 | - $this->bairro = $detalheEndereco['bairro']; | ||
300 | - $this->logradouro = $detalheEndereco['logradouro']; | ||
301 | - $this->sigla_uf = $detalheEndereco['sigla_uf']; | ||
302 | - $this->cidade = $detalheEndereco['cidade']; | ||
303 | - $this->reside_desde = $detalheEndereco['reside_desde']; | ||
304 | - $this->idtlog = $detalheEndereco['idtlog']; | ||
305 | - $this->complemento = $detalheEndereco['complemento']; | ||
306 | - $this->numero = $detalheEndereco['numero']; | ||
307 | - $this->letra = $detalheEndereco['letra']; | ||
308 | - $this->idlog = $detalheEndereco['idlog']; | ||
309 | - $this->idbai = $detalheEndereco['idbai']; | ||
310 | - $this->cep = $detalheEndereco['cep']; | ||
311 | - $this->apartamento = $detalheEndereco['apartamento']; | ||
312 | - $this->bloco = $detalheEndereco['bloco']; | ||
313 | - $this->andar = $detalheEndereco['andar']; | ||
314 | - | ||
315 | - $detalhePessoa['bairro'] = $this->bairro; | ||
316 | - $detalhePessoa['logradouro'] = $this->logradouro; | ||
317 | - $detalhePessoa['sigla_uf'] = $this->sigla_uf; | ||
318 | - $detalhePessoa['cidade'] = $this->cidade; | ||
319 | - $detalhePessoa['reside_desde'] = $this->reside_desde; | ||
320 | - $detalhePessoa['idtlog'] = $this->idtlog; | ||
321 | - $detalhePessoa['complemento'] = $this->complemento; | ||
322 | - $detalhePessoa['numero'] = $this->numero; | ||
323 | - $detalhePessoa['letra'] = $this->letra; | ||
324 | - $detalhePessoa['idbai'] = $this->idbai; | ||
325 | - $detalhePessoa['cep'] = $this->cep; | ||
326 | - $detalhePessoa['idlog'] = $this->idlog; | ||
327 | - | ||
328 | - } | ||
329 | - | ||
330 | - $obj_fisica = new clsFisica($this->idpes); | ||
331 | - $detalhe_fisica = $obj_fisica->detalhe(); | ||
332 | - if( $detalhe_fisica ) | ||
333 | - { | ||
334 | - $detalhePessoa['cpf'] = $detalhe_fisica['cpf']; | ||
335 | - $this->cpf = $detalhe_fisica['cpf']; | ||
336 | - $this->data_nasc = $detalhe_fisica['data_nasc']; | ||
337 | - if($this->data_nasc) | ||
338 | - { | ||
339 | - $detalhePessoa['data_nasc'] = $this->data_nasc; | ||
340 | - } | ||
341 | - } | ||
342 | - $objFone = new clsPessoaTelefone(); | ||
343 | - $listaFone = $objFone->lista($this->idpes); | ||
344 | - if($listaFone) | ||
345 | - { | ||
346 | - foreach ($listaFone as $fone) { | ||
347 | - if($fone['tipo'] == 1) | ||
348 | - { | ||
349 | - $detalhePessoa['ddd_1'] = $fone['ddd']; | ||
350 | - $detalhePessoa[] = &$detalhePessoa['ddd_1']; | ||
351 | - $detalhePessoa['fone_1'] = $fone['fone']; | ||
352 | - $detalhePessoa[] = &$detalhePessoa['fone_1']; | ||
353 | - $this->ddd_1 = $fone['ddd']; | ||
354 | - $this->fone_1 = $fone['fone']; | ||
355 | - } | ||
356 | - if($fone['tipo'] == 2) | ||
357 | - { | ||
358 | - $detalhePessoa['ddd_2'] = $fone['ddd']; | ||
359 | - $detalhePessoa[] = &$detalhePessoa['ddd_2']; | ||
360 | - $detalhePessoa['fone_2'] = $fone['fone']; | ||
361 | - $detalhePessoa[] = &$detalhePessoa['fone_2']; | ||
362 | - $this->ddd_2 = $fone['ddd']; | ||
363 | - $this->fone_2 = $fone['fone']; | ||
364 | - } | ||
365 | - if($fone['tipo'] == 3) | ||
366 | - { | ||
367 | - $detalhePessoa['ddd_mov'] = $fone['ddd']; | ||
368 | - $detalhePessoa[''] = &$detalhePessoa['ddd_mov']; | ||
369 | - $detalhePessoa['fone_mov'] = $fone['fone']; | ||
370 | - $detalhePessoa[] = &$detalhePessoa['fone_mov']; | ||
371 | - $this->ddd_mov = $fone['ddd']; | ||
372 | - $this->fone_mov = $fone['fone']; | ||
373 | - } | ||
374 | - if($fone['tipo'] == 4) | ||
375 | - { | ||
376 | - $detalhePessoa['ddd_fax'] = $fone['ddd']; | ||
377 | - $detalhePessoa[] = &$detalhePessoa['ddd_fax']; | ||
378 | - $detalhePessoa['fone_fax'] = $fone['fone']; | ||
379 | - $detalhePessoa[] = &$detalhePessoa['fone_fax']; | ||
380 | - $this->ddd_fax = $fone['ddd']; | ||
381 | - $this->fone_fax = $fone['fone']; | ||
382 | - } | ||
383 | - } | ||
384 | - } | ||
385 | - | ||
386 | - $obj_documento = new clsDocumento($this->idpes); | ||
387 | - $documentos = $obj_documento->detalhe(); | ||
388 | - | ||
389 | - | ||
390 | - if(is_array($documentos)) | ||
391 | - { | ||
392 | - if($documentos['rg']) | ||
393 | - { | ||
394 | - $detalhePessoa['rg'] = $documentos['rg']; | ||
395 | - $detalhePessoa[] = &$detalhePessoa['rg']; | ||
396 | - $this->rg = $documentos['rg']; | ||
397 | - | ||
398 | - } | ||
399 | - } | ||
400 | - $this->idpes = $detalhePessoa['idpes']; | ||
401 | - $this->nome = $detalhePessoa['nome']; | ||
402 | - $this->idpes_cad = $detalhePessoa['idpes_cad']; | ||
403 | - $this->data_cad = $detalhePessoa['data_cad']; | ||
404 | - $this->url = $detalhePessoa['url']; | ||
405 | - $this->tipo = $detalhePessoa['tipo']; | ||
406 | - $this->idpes_rev = $detalhePessoa['idpes_rev']; | ||
407 | - $this->data_rev = $detalhePessoa['data_rev']; | ||
408 | - $this->situacao = $detalhePessoa['situacao']; | ||
409 | - $this->origem_gravacao = $detalhePessoa['origem_gravacao']; | ||
410 | - $this->email = $detalhePessoa['email']; | ||
411 | - return $detalhePessoa; | ||
412 | - | ||
413 | - } | ||
414 | - return false; | ||
415 | - } | ||
416 | - | ||
417 | - function queryRapida($int_idpes) | ||
418 | - { | ||
419 | - $this->idpes = $int_idpes; | ||
420 | - $this->detalhe(); | ||
421 | - $resultado = array(); | ||
422 | - $pos = 0; | ||
423 | - for ($i = 1; $i< func_num_args(); $i++ ) { | ||
424 | - $campo = func_get_arg($i); | ||
425 | - $resultado[$pos] = ($this->$campo) ? $this->$campo : ""; | ||
426 | - $resultado[$campo] = &$resultado[$pos]; | ||
427 | - $pos++; | ||
428 | - | ||
429 | - } | ||
430 | - if(count($resultado) > 0) | ||
431 | - { | ||
432 | - | ||
433 | - return $resultado; | ||
434 | - } | ||
435 | - return false; | ||
436 | - } | ||
437 | - | ||
438 | - | ||
439 | -} | ||
440 | -?> | 45 | + /** |
46 | + * Atributos de clsPessoa(Fisica|Juridica). | ||
47 | + */ | ||
48 | + var $idpes; | ||
49 | + var $nome; | ||
50 | + var $idpes_cad; | ||
51 | + var $data_cad; | ||
52 | + var $url; | ||
53 | + var $tipo; | ||
54 | + var $idpes_rev; | ||
55 | + var $data_rev; | ||
56 | + var $situacao; | ||
57 | + var $origem_gravacao; | ||
58 | + var $email; | ||
59 | + var $data_nasc; | ||
60 | + | ||
61 | + /** | ||
62 | + * Atributos de endereço. | ||
63 | + */ | ||
64 | + var $bairro; | ||
65 | + var $idbai; | ||
66 | + var $logradouro; | ||
67 | + var $idlog; | ||
68 | + var $idtlog; | ||
69 | + var $cidade; | ||
70 | + var $idmun; | ||
71 | + var $sigla_uf; | ||
72 | + var $pais; | ||
73 | + var $complemento; | ||
74 | + var $reside_desde; | ||
75 | + var $letra; | ||
76 | + var $numero; | ||
77 | + var $cep; | ||
78 | + var $bloco; | ||
79 | + var $apartamento; | ||
80 | + var $andar; | ||
81 | + | ||
82 | + /** | ||
83 | + * Atributos de endereço. | ||
84 | + */ | ||
85 | + var $ddd_1; | ||
86 | + var $fone_1; | ||
87 | + var $ddd_2; | ||
88 | + var $fone_2; | ||
89 | + var $ddd_fax; | ||
90 | + var $fone_fax; | ||
91 | + var $ddd_mov; | ||
92 | + var $fone_mov; | ||
93 | + | ||
94 | + /** | ||
95 | + * Atributos de documentos. | ||
96 | + */ | ||
97 | + var $rg; | ||
98 | + var $cpf; | ||
99 | + | ||
100 | + var $_total; | ||
101 | + | ||
102 | + var $banco = 'gestao_homolog'; | ||
103 | + var $schema_cadastro = 'cadastro'; | ||
104 | + var $tabela_pessoa = 'pessoa'; | ||
105 | + | ||
106 | + /** | ||
107 | + * Construtor. | ||
108 | + */ | ||
109 | + function clsPessoaFj($int_idpes = FALSE) | ||
110 | + { | ||
111 | + $this->idpes = $int_idpes; | ||
112 | + } | ||
113 | + | ||
114 | + function lista($str_nome = FALSE, $inicio_limite = FALSE, $qtd_registros = FALSE, | ||
115 | + $str_orderBy = FALSE, $arrayint_idisin = FALSE, $arrayint_idnotin = FALSE, | ||
116 | + $str_tipo_pessoa = FALSE) | ||
117 | + { | ||
118 | + $objPessoa = new clsPessoa_(); | ||
119 | + | ||
120 | + $listaPessoa = $objPessoa->lista($str_nome, $inicio_limite, $qtd_registros, | ||
121 | + $str_orderBy, $arrayint_idisin, $arrayint_idnotin, $str_tipo_pessoa); | ||
122 | + | ||
123 | + if (count($listaPessoa) > 0) { | ||
124 | + return $listaPessoa; | ||
125 | + } | ||
126 | + | ||
127 | + return FALSE; | ||
128 | + } | ||
129 | + | ||
130 | + /*function lista_rapida($idpes = null, $nome = null, $id_federal = null, $inicio_limite = null, $limite = null, $str_tipo_pessoa = null, $str_order_by = null, $int_ref_cod_sistema = null) | ||
131 | + { | ||
132 | + $db = new clsBanco(); | ||
133 | + | ||
134 | + $filtros = ""; | ||
135 | + $filtroTipo = ""; | ||
136 | + $whereAnd = " WHERE "; | ||
137 | + $outros_filtros = false; | ||
138 | + $filtro_cnpj = false; | ||
139 | + | ||
140 | + if( is_string( $nome ) && $nome != "") | ||
141 | + { | ||
142 | + $filtros .= "{$whereAnd} (nome ILIKE '%{$nome}%')"; | ||
143 | + $whereAnd = " AND "; | ||
144 | + $outros_filtros =true; | ||
145 | + } | ||
146 | + | ||
147 | + if( is_numeric( $id_federal ) ) | ||
148 | + { | ||
149 | + $filtros .= "{$whereAnd} id_federal LIKE '%{$id_federal}'"; | ||
150 | + $whereAnd = " AND "; | ||
151 | + $filtro_cnpj =true; | ||
152 | + } | ||
153 | + | ||
154 | + | ||
155 | + if( is_numeric( $idpes ) ) | ||
156 | + { | ||
157 | + $filtros .= "{$whereAnd} idpes = '{$idpes}'"; | ||
158 | + $whereAnd = " AND "; | ||
159 | + $outros_filtros =true; | ||
160 | + } | ||
161 | + | ||
162 | + if( is_numeric( $int_ref_cod_sistema ) ) | ||
163 | + { | ||
164 | + $filtro_sistema = true; | ||
165 | + $filtros .= "{$whereAnd} (ref_cod_sistema = '{$int_ref_cod_sistema}' OR id_federal is not null)"; | ||
166 | + $whereAnd = " AND "; | ||
167 | + } | ||
168 | + | ||
169 | + if ( is_string( $str_tipo_pessoa ) ) { | ||
170 | + $filtroTipo .= " AND tipo = '{$str_tipo_pessoa}' "; | ||
171 | + $outros_filtros =true; | ||
172 | + } | ||
173 | + | ||
174 | + if ( is_string( $str_order_by ) ) { | ||
175 | + $order = "ORDER BY $str_order_by"; | ||
176 | + } | ||
177 | + | ||
178 | + $limit = ""; | ||
179 | + if(is_numeric($inicio_limite) && is_numeric($limite)) | ||
180 | + { | ||
181 | + $limit = "LIMIT $limite OFFSET $inicio_limite"; | ||
182 | + } | ||
183 | + | ||
184 | + if($filtro_sistema && $outros_filtros == false || $filtro_cnpj ) | ||
185 | + { | ||
186 | + $this->_total = $db->CampoUnico("SELECT COUNT(0) FROM cadastro.v_pessoafj_count $filtros"); | ||
187 | + }else | ||
188 | + { | ||
189 | + $this->_total = $db->CampoUnico("SELECT COUNT(0) FROM cadastro.v_pessoa_fj $filtros"); | ||
190 | + } | ||
191 | + | ||
192 | + $db->Consulta("SELECT idpes, nome, ref_cod_sistema, fantasia, tipo , id_federal as cpf, id_federal as cnpj, id_federal FROM cadastro.v_pessoa_fj $filtros $order $limit "); | ||
193 | + while ( $db->ProximoRegistro() ) | ||
194 | + { | ||
195 | + $tupla = $db->Tupla(); | ||
196 | + $tupla["_total"] = $this->_total; | ||
197 | + $resultado[] = $tupla; | ||
198 | + } | ||
199 | + | ||
200 | + if( count( $resultado ) ) | ||
201 | + { | ||
202 | + return $resultado; | ||
203 | + } | ||
204 | + return false; | ||
205 | + }*/ | ||
206 | + | ||
207 | + function lista_rapida($idpes = NULL, $nome = NULL, $id_federal = NULL, | ||
208 | + $inicio_limite = NULL, $limite = NULL, $str_tipo_pessoa = NULL, | ||
209 | + $str_order_by = NULL, $int_ref_cod_sistema = NULL) | ||
210 | + { | ||
211 | + $db = new clsBanco(); | ||
212 | + | ||
213 | + $filtros = ''; | ||
214 | + $filtroTipo = ''; | ||
215 | + $whereAnd = ' WHERE '; | ||
216 | + $outros_filtros = FALSE; | ||
217 | + $filtro_cnpj = FALSE; | ||
218 | + | ||
219 | + if (is_string($nome) && $nome != '') { | ||
220 | + $filtros .= "{$whereAnd} (nome ILIKE '%{$nome}%')"; | ||
221 | + $whereAnd = ' AND '; | ||
222 | + $outros_filtros = TRUE; | ||
223 | + } | ||
224 | + | ||
225 | + if (is_numeric($idpes)) { | ||
226 | + $filtros .= "{$whereAnd} idpes = '{$idpes}'"; | ||
227 | + $whereAnd = ' AND '; | ||
228 | + $outros_filtros = TRUE; | ||
229 | + } | ||
230 | + | ||
231 | + if (is_numeric($int_ref_cod_sistema)) { | ||
232 | + $filtro_sistema = TRUE; | ||
233 | + $filtros .= "{$whereAnd} (ref_cod_sistema = '{$int_ref_cod_sistema}' OR id_federal is not null)"; | ||
234 | + $whereAnd = ' AND '; | ||
235 | + } | ||
236 | + | ||
237 | + if (is_numeric($id_federal)) { | ||
238 | + $db2 = new clsBanco(); | ||
239 | + | ||
240 | + $sql = sprintf( | ||
241 | + 'SELECT idpes FROM cadastro.fisica WHERE cpf LIKE \'%%%s%%\'', $id_federal | ||
242 | + ); | ||
243 | + | ||
244 | + $db2->Consulta(); | ||
245 | + | ||
246 | + $array_idpes = NULL; | ||
247 | + | ||
248 | + while ($db2->ProximoRegistro()) { | ||
249 | + list($id_pes) = $db2->Tupla(); | ||
250 | + $array_idpes[] = $id_pes; | ||
251 | + } | ||
252 | + | ||
253 | + $sql = sprintf( | ||
254 | + 'SELECT idpes FROM cadastro.juridica WHERE cnpj LIKE \'%%%s%%\'', $id_federal | ||
255 | + ); | ||
256 | + | ||
257 | + $db2->Consulta($sql); | ||
258 | + | ||
259 | + while ($db2->ProximoRegistro()) { | ||
260 | + list($id_pes) = $db2->Tupla(); | ||
261 | + $array_idpes[] = $id_pes; | ||
262 | + } | ||
263 | + | ||
264 | + if (is_array($array_idpes)) { | ||
265 | + $array_idpes = implode(', ', $array_idpes); | ||
266 | + $filtros .= "{$whereAnd} idpes IN ($array_idpes)"; | ||
267 | + $whereAnd = ' AND '; | ||
268 | + $filtro_idfederal = TRUE; | ||
269 | + } | ||
270 | + else { | ||
271 | + return FALSE; | ||
272 | + } | ||
273 | + } | ||
274 | + | ||
275 | + if (is_string($str_tipo_pessoa)) { | ||
276 | + $filtroTipo .= " AND tipo = '{$str_tipo_pessoa}' "; | ||
277 | + $outros_filtros = TRUE; | ||
278 | + } | ||
279 | + | ||
280 | + if (is_string($str_order_by)) { | ||
281 | + $order = "ORDER BY $str_order_by"; | ||
282 | + } | ||
283 | + | ||
284 | + $limit = ''; | ||
285 | + | ||
286 | + if (is_numeric($inicio_limite) && is_numeric($limite)) { | ||
287 | + $limit = "LIMIT $limite OFFSET $inicio_limite"; | ||
288 | + } | ||
289 | + | ||
290 | + if ($filtro_idfederal) { | ||
291 | + $this->_total = $db->CampoUnico( | ||
292 | + sprintf('SELECT COUNT(0) FROM cadastro.v_pessoa_fj %s', $filtros) | ||
293 | + ); | ||
294 | + } | ||
295 | + else { | ||
296 | + if ($filtro_sistema && $outros_filtros == FALSE || $filtro_cnpj) { | ||
297 | + $this->_total = $db->CampoUnico( | ||
298 | + sprintf('SELECT COUNT(0) FROM cadastro.v_pessoafj_count %s', $filtros) | ||
299 | + ); | ||
300 | + } | ||
301 | + else { | ||
302 | + $this->_total = $db->CampoUnico( | ||
303 | + sprintf('SELECT COUNT(0) FROM cadastro.v_pessoa_fj %s', $filtros) | ||
304 | + ); | ||
305 | + } | ||
306 | + } | ||
307 | + | ||
308 | + $sql = sprintf(' | ||
309 | + SELECT | ||
310 | + idpes, | ||
311 | + nome, | ||
312 | + ref_cod_sistema, | ||
313 | + fantasia, | ||
314 | + tipo, | ||
315 | + id_federal AS cpf, | ||
316 | + id_federal AS cnpj, | ||
317 | + id_federal | ||
318 | + FROM | ||
319 | + cadastro.v_pessoa_fj | ||
320 | + %s | ||
321 | + %s | ||
322 | + %s', | ||
323 | + $filtros, $order, $limit | ||
324 | + ); | ||
325 | + | ||
326 | + $db->Consulta($sql); | ||
327 | + | ||
328 | + while ($db->ProximoRegistro()) { | ||
329 | + $tupla = $db->Tupla(); | ||
330 | + $tupla['_total'] = $this->_total; | ||
331 | + $resultado[] = $tupla; | ||
332 | + } | ||
333 | + | ||
334 | + if (count($resultado)) { | ||
335 | + return $resultado; | ||
336 | + } | ||
337 | + | ||
338 | + return FALSE; | ||
339 | + } | ||
340 | + | ||
341 | + function detalhe() | ||
342 | + { | ||
343 | + if ($this->idpes) { | ||
344 | + $objPessoa = new clsPessoa_($this->idpes); | ||
345 | + $detalhePessoa = $objPessoa->detalhe(); | ||
346 | + | ||
347 | + $objEndereco = new clsEndereco($this->idpes); | ||
348 | + $detalheEndereco = $objEndereco->detalhe(); | ||
349 | + | ||
350 | + if ($detalheEndereco) { | ||
351 | + $this->bairro = $detalheEndereco['bairro']; | ||
352 | + $this->logradouro = $detalheEndereco['logradouro']; | ||
353 | + $this->sigla_uf = $detalheEndereco['sigla_uf']; | ||
354 | + $this->cidade = $detalheEndereco['cidade']; | ||
355 | + $this->reside_desde = $detalheEndereco['reside_desde']; | ||
356 | + $this->idtlog = $detalheEndereco['idtlog']; | ||
357 | + $this->complemento = $detalheEndereco['complemento']; | ||
358 | + $this->numero = $detalheEndereco['numero']; | ||
359 | + $this->letra = $detalheEndereco['letra']; | ||
360 | + $this->idlog = $detalheEndereco['idlog']; | ||
361 | + $this->idbai = $detalheEndereco['idbai']; | ||
362 | + $this->cep = $detalheEndereco['cep']; | ||
363 | + $this->apartamento = $detalheEndereco['apartamento']; | ||
364 | + $this->bloco = $detalheEndereco['bloco']; | ||
365 | + $this->andar = $detalheEndereco['andar']; | ||
366 | + | ||
367 | + $detalhePessoa['bairro'] = $this->bairro; | ||
368 | + $detalhePessoa['logradouro'] = $this->logradouro; | ||
369 | + $detalhePessoa['sigla_uf'] = $this->sigla_uf; | ||
370 | + $detalhePessoa['cidade'] = $this->cidade; | ||
371 | + $detalhePessoa['reside_desde'] = $this->reside_desde; | ||
372 | + $detalhePessoa['idtlog'] = $this->idtlog; | ||
373 | + $detalhePessoa['complemento'] = $this->complemento; | ||
374 | + $detalhePessoa['numero'] = $this->numero; | ||
375 | + $detalhePessoa['letra'] = $this->letra; | ||
376 | + $detalhePessoa['idbai'] = $this->idbai; | ||
377 | + $detalhePessoa['cep'] = $this->cep; | ||
378 | + $detalhePessoa['idlog'] = $this->idlog; | ||
379 | + } | ||
380 | + | ||
381 | + $obj_fisica = new clsFisica($this->idpes); | ||
382 | + $detalhe_fisica = $obj_fisica->detalhe(); | ||
383 | + | ||
384 | + if ($detalhe_fisica) { | ||
385 | + $detalhePessoa['cpf'] = $detalhe_fisica['cpf']; | ||
386 | + | ||
387 | + $this->cpf = $detalhe_fisica['cpf']; | ||
388 | + $this->data_nasc = $detalhe_fisica['data_nasc']; | ||
389 | + | ||
390 | + if ($this->data_nasc) { | ||
391 | + $detalhePessoa['data_nasc'] = $this->data_nasc; | ||
392 | + } | ||
393 | + } | ||
394 | + | ||
395 | + $objFone = new clsPessoaTelefone(); | ||
396 | + $listaFone = $objFone->lista($this->idpes); | ||
397 | + | ||
398 | + if ($listaFone) { | ||
399 | + foreach ($listaFone as $fone) { | ||
400 | + if($fone['tipo'] == 1) { | ||
401 | + $detalhePessoa['ddd_1'] = $fone['ddd']; | ||
402 | + $detalhePessoa[] = & $detalhePessoa['ddd_1']; | ||
403 | + $detalhePessoa['fone_1'] = $fone['fone']; | ||
404 | + $detalhePessoa[] = & $detalhePessoa['fone_1']; | ||
405 | + | ||
406 | + $this->ddd_1 = $fone['ddd']; | ||
407 | + $this->fone_1 = $fone['fone']; | ||
408 | + } | ||
409 | + | ||
410 | + if ($fone['tipo'] == 2) { | ||
411 | + $detalhePessoa['ddd_2'] = $fone['ddd']; | ||
412 | + $detalhePessoa[] = & $detalhePessoa['ddd_2']; | ||
413 | + $detalhePessoa['fone_2'] = $fone['fone']; | ||
414 | + $detalhePessoa[] = & $detalhePessoa['fone_2']; | ||
415 | + | ||
416 | + $this->ddd_2 = $fone['ddd']; | ||
417 | + $this->fone_2 = $fone['fone']; | ||
418 | + } | ||
419 | + | ||
420 | + if ($fone['tipo'] == 3) { | ||
421 | + $detalhePessoa['ddd_mov'] = $fone['ddd']; | ||
422 | + $detalhePessoa[] = & $detalhePessoa['ddd_mov']; | ||
423 | + $detalhePessoa['fone_mov'] = $fone['fone']; | ||
424 | + $detalhePessoa[] = & $detalhePessoa['fone_mov']; | ||
425 | + | ||
426 | + $this->ddd_mov = $fone['ddd']; | ||
427 | + $this->fone_mov = $fone['fone']; | ||
428 | + } | ||
429 | + | ||
430 | + if ($fone['tipo'] == 4) { | ||
431 | + $detalhePessoa['ddd_fax'] = $fone['ddd']; | ||
432 | + $detalhePessoa[] = & $detalhePessoa['ddd_fax']; | ||
433 | + $detalhePessoa['fone_fax'] = $fone['fone']; | ||
434 | + $detalhePessoa[] = & $detalhePessoa['fone_fax']; | ||
435 | + | ||
436 | + $this->ddd_fax = $fone['ddd']; | ||
437 | + $this->fone_fax = $fone['fone']; | ||
438 | + } | ||
439 | + } | ||
440 | + } | ||
441 | + | ||
442 | + $obj_documento = new clsDocumento($this->idpes); | ||
443 | + $documentos = $obj_documento->detalhe(); | ||
444 | + | ||
445 | + if (is_array($documentos)) { | ||
446 | + if ($documentos['rg']) { | ||
447 | + $detalhePessoa['rg'] = $documentos['rg']; | ||
448 | + $detalhePessoa[] = & $detalhePessoa['rg']; | ||
449 | + | ||
450 | + $this->rg = $documentos['rg']; | ||
451 | + } | ||
452 | + } | ||
453 | + | ||
454 | + $this->idpes = $detalhePessoa['idpes']; | ||
455 | + $this->nome = $detalhePessoa['nome']; | ||
456 | + $this->idpes_cad = $detalhePessoa['idpes_cad']; | ||
457 | + $this->data_cad = $detalhePessoa['data_cad']; | ||
458 | + $this->url = $detalhePessoa['url']; | ||
459 | + $this->tipo = $detalhePessoa['tipo']; | ||
460 | + $this->idpes_rev = $detalhePessoa['idpes_rev']; | ||
461 | + $this->data_rev = $detalhePessoa['data_rev']; | ||
462 | + $this->situacao = $detalhePessoa['situacao']; | ||
463 | + $this->origem_gravacao = $detalhePessoa['origem_gravacao']; | ||
464 | + $this->email = $detalhePessoa['email']; | ||
465 | + | ||
466 | + return $detalhePessoa; | ||
467 | + } | ||
468 | + | ||
469 | + return FALSE; | ||
470 | + } | ||
471 | + | ||
472 | + function queryRapida($int_idpes) | ||
473 | + { | ||
474 | + $this->idpes = $int_idpes; | ||
475 | + | ||
476 | + $this->detalhe(); | ||
477 | + | ||
478 | + $resultado = array(); | ||
479 | + $pos = 0; | ||
480 | + | ||
481 | + for ($i = 1; $i< func_num_args(); $i++) { | ||
482 | + $campo = func_get_arg($i); | ||
483 | + $resultado[$pos] = ($this->$campo) ? $this->$campo : ''; | ||
484 | + $resultado[$campo] = & $resultado[$pos]; | ||
485 | + | ||
486 | + $pos++; | ||
487 | + } | ||
488 | + | ||
489 | + if (count($resultado) > 0) { | ||
490 | + return $resultado; | ||
491 | + } | ||
492 | + | ||
493 | + return FALSE; | ||
494 | + } | ||
495 | +} | ||
441 | \ No newline at end of file | 496 | \ No newline at end of file |