protected function getPrimeiroEnderecoCep()
 {
     $cep = idFederal2int($this->getRequest()->cep);
     // consulta dados
     $select = "\n      SELECT\n        c.idlog, c.cep, c.idbai, b.nome as nome_bairro, l.nome as nome_logradouro, u.sigla_uf, m.nome, t.idtlog, t.descricao as tipo_logradouro, m.idmun, b.zona_localizacao \n   \n      FROM\n        urbano.cep_logradouro_bairro c, public.bairro b, public.logradouro l,\n        public.municipio m, public.uf u, urbano.tipo_logradouro t\n      WHERE\n        c.idlog = l.idlog AND\n        c.idbai = b.idbai AND\n        l.idmun = b.idmun AND\n        l.idmun = m.idmun AND\n        l.idtlog = t.idtlog AND\n        m.sigla_uf = u.sigla_uf AND \n        c.cep = {$cep} LIMIT 1";
     $result = Portabilis_Utils_Database::fetchPreparedQuery($select, array('return_only' => 'first-line'));
     $return;
     if (is_array($result)) {
         $return = array();
         foreach ($result as $name => $value) {
             $return[$name] = Portabilis_String_Utils::toUtf8($value);
         }
     }
     return $return;
 }
 protected function _createOrUpdateEnderecoExterno($pessoaId)
 {
     $endereco = new clsEnderecoExterno($pessoaId, '1', $this->idtlog, addslashes($this->logradouro), $this->numero, addslashes($this->letra), addslashes($this->complemento), addslashes($this->bairro), idFederal2int($this->cep_), addslashes($this->cidade), $this->sigla_uf, FALSE, addslashes($this->bloco), $this->apartamento, $this->andar, FALSE, FALSE, $this->zona_localizacao);
     // forçado exclusão, assim ao cadastrar endereco_externo novamente,
     // será excluido endereco_pessoa (por meio da trigger fcn_aft_ins_endereco_externo).
     $endereco->exclui();
     $endereco->cadastra();
 }
 function Novo()
 {
     @session_start();
     $this->pessoa_logada = $_SESSION['id_pessoa'];
     @session_write_close();
     $obj_permissoes = new clsPermissoes();
     $obj_permissoes->permissao_cadastra(595, $this->pessoa_logada, 11, "educar_acervo_editora_lst.php");
     $this->cep = idFederal2int($this->cep);
     $obj = new clsPmieducarAcervoEditora(null, $this->pessoa_logada, null, $this->ref_idtlog, $this->ref_sigla_uf, $this->nm_editora, $this->cep, $this->cidade, $this->bairro, $this->logradouro, $this->numero, $this->telefone, $this->ddd_telefone, null, null, 1, $this->ref_cod_biblioteca);
     $cadastrou = $obj->cadastra();
     if ($cadastrou) {
         $this->mensagem .= "Cadastro efetuado com sucesso.<br>";
         //header( "Location: educar_acervo_editora_lst.php" );
         echo "<script>\n\t\t\t\t\tparent.document.getElementById('editora').value = '{$cadastrou}';\n\t\t\t\t\tparent.document.getElementById('tipoacao').value = '';\n\t\t\t\t\tparent.document.getElementById('ref_cod_acervo_editora').disabled = false;\n\t\t\t\t\tparent.document.getElementById('formcadastro').submit();\n\t\t\t     </script>";
         die;
         return true;
     }
     $this->mensagem = "Cadastro n&atilde;o realizado.<br>";
     echo "<!--\nErro ao cadastrar clsPmieducarAcervoEditora\nvalores obrigat&oacute;rios\nis_numeric( {$this->pessoa_logada} ) && is_string( {$this->ref_idtlog} ) && is_string( {$this->ref_sigla_uf} ) && is_string( {$this->nm_editora} ) && is_numeric( {$this->cep} ) && is_string( {$this->cidade} ) && is_string( {$this->bairro} ) && is_string( {$this->logradouro} ) && is_numeric( {$this->numero} )\n-->";
     return false;
 }
 function Gerar()
 {
     @session_start();
     $this->pessoa_logada = $_SESSION['id_pessoa'];
     session_write_close();
     $this->titulo = "Aluno - Listagem";
     foreach ($_GET as $var => $val) {
         // passa todos os valores obtidos no GET para atributos do objeto
         $this->{$var} = $val === "" ? null : $val;
     }
     $this->addBanner("imagens/nvp_top_intranet.jpg", "imagens/nvp_vert_intranet.jpg", "Intranet");
     $this->campoNumero("cod_aluno", "C&oacute;digo Aluno", $this->cod_aluno, 20, 255, false);
     $this->campoTexto("nome_aluno", "Nome do aluno", $this->nome_aluno, 50, 255, false);
     //		if ($this->pessoa_logada == 184580) {
     $this->campoData("data_nascimento", "Data de Nascimento", $this->data_nascimento);
     $this->campoTexto("nome_pai", "Nome do Pai", $this->nome_pai, 50, 255);
     $this->campoTexto("nome_mae", "Nome da Mãe", $this->nome_mae, 50, 255);
     $this->campoTexto("nome_responsavel", "Nome do Responsável", $this->nome_responsavel, 50, 255);
     //		}
     $obj_permissoes = new clsPermissoes();
     $cod_escola = $obj_permissoes->getEscola($this->pessoa_logada);
     if ($cod_escola) {
         $this->campoCheck("meus_alunos", "Meus Alunos", $_GET['meus_alunos']);
         $ref_cod_escola = false;
         if ($_GET['meus_alunos']) {
             $ref_cod_escola = $cod_escola;
         }
     }
     $array_matriculado = array('S' => "Sim", 'N' => 'N&atilde;o');
     $nivel_usuario = $obj_permissoes->nivel_acesso($this->pessoa_logada);
     $this->addCabecalhos(array("C&oacute;digo Aluno", "Nome do Aluno", "Nome do Respons&aacute;vel", "CPF Respons&aacute;vel"));
     // Paginador
     $this->limite = 20;
     $this->offset = $_GET["pagina_{$this->nome}"] ? $_GET["pagina_{$this->nome}"] * $this->limite - $this->limite : 0;
     $obj_aluno = new clsPmieducarAluno();
     //		$obj_aluno->setOrderby( "cod_aluno DESC" );
     $obj_aluno->setLimite($this->limite, $this->offset);
     /*$lista = $obj_aluno->lista(
     			$this->cod_aluno,
     			null,
     			null,
     			null,
     			null,
     			null,
     			null,
     			null,
     			null,
     			null,
     			1,
     			null,
     			$this->nome_aluno,
     			$this->nome_responsavel,
     			idFederal2int($this->cpf_responsavel),
     			null,
     			$this->nome_pai,
     			$this->nome_mae,
     			$ref_cod_escola
     		);*/
     //		if ($this->pessoa_logada == 184580) {
     $lista = $obj_aluno->lista2($this->cod_aluno, null, null, null, null, null, null, null, null, null, 1, null, $this->nome_aluno, null, idFederal2int($this->cpf_responsavel), null, null, null, $ref_cod_escola, null, $this->data_nascimento, $this->nome_pai, $this->nome_mae, $this->nome_responsavel);
     /*} else {
     			$lista = $obj_aluno->lista(
     					$this->cod_aluno,
     					null,
     					null,
     					null,
     					null,
     					null,
     					null,
     					null,
     					null,
     					null,
     					1,
     					null,
     					$this->nome_aluno,
     					null,
     					idFederal2int($this->cpf_responsavel),
     					null,
     					null,
     					null,
     					$ref_cod_escola
     				);
     		}*/
     $total = $obj_aluno->_total;
     // monta a lista
     if (is_array($lista) && count($lista)) {
         foreach ($lista as $registro) {
             $registro["nome_responsavel"] = null;
             $det_fisica_aluno = null;
             if ($registro['tipo_responsavel'] == 'p' || !$registro["nome_responsavel"] && $registro['tipo_responsavel'] == null) {
                 $obj_fisica = new clsFisica($registro["ref_idpes"]);
                 $det_fisica_aluno = $obj_fisica->detalhe();
                 if ($det_fisica_aluno["idpes_pai"]) {
                     $obj_ref_idpes = new clsPessoa_($det_fisica_aluno["idpes_pai"]);
                     $det_ref_idpes = $obj_ref_idpes->detalhe();
                     $obj_fisica = new clsFisica($det_fisica_aluno["idpes_pai"]);
                     $det_fisica = $obj_fisica->detalhe();
                     $registro["nome_responsavel"] = $det_ref_idpes['nome'];
                     if ($det_fisica["cpf"]) {
                         $registro["cpf_responsavel"] = int2CPF($det_fisica["cpf"]);
                     }
                 }
             }
             if ($registro['tipo_responsavel'] == 'm' || $registro["nome_responsavel"] == null && $registro['tipo_responsavel'] == null) {
                 if (!$det_fisica_aluno) {
                     $obj_fisica = new clsFisica($registro["ref_idpes"]);
                     $det_fisica_aluno = $obj_fisica->detalhe();
                 }
                 if ($det_fisica_aluno["idpes_mae"]) {
                     $obj_ref_idpes = new clsPessoa_($det_fisica_aluno["idpes_mae"]);
                     $det_ref_idpes = $obj_ref_idpes->detalhe();
                     $obj_fisica = new clsFisica($det_fisica_aluno["idpes_mae"]);
                     $det_fisica = $obj_fisica->detalhe();
                     $registro["nome_responsavel"] = $det_ref_idpes["nome"];
                     if ($det_fisica["cpf"]) {
                         $registro["cpf_responsavel"] = int2CPF($det_fisica["cpf"]);
                     }
                 }
             }
             if ($registro['tipo_responsavel'] == 'r' || $registro["nome_responsavel"] == null && $registro['tipo_responsavel'] == null) {
                 if (!$det_fisica_aluno) {
                     $obj_fisica = new clsFisica($registro["ref_idpes"]);
                     $det_fisica_aluno = $obj_fisica->detalhe();
                 }
                 if ($det_fisica_aluno["idpes_responsavel"]) {
                     $obj_ref_idpes = new clsPessoa_($det_fisica_aluno["idpes_responsavel"]);
                     $obj_fisica = new clsFisica($det_fisica_aluno["idpes_responsavel"]);
                     $det_ref_idpes = $obj_ref_idpes->detalhe();
                     $det_fisica = $obj_fisica->detalhe();
                     $registro["nome_responsavel"] = $det_ref_idpes["nome"];
                     if ($det_fisica["cpf"]) {
                         $registro["cpf_responsavel"] = int2CPF($det_fisica["cpf"]);
                     }
                 }
             }
             if (!$registro["nome_responsavel"]) {
                 if ($registro['tipo_responsavel'] != null) {
                     if ($registro['tipo_responsavel'] == 'p') {
                         $registro["nome_responsavel"] = $registro["nm_pai"];
                     } else {
                         $registro["nome_responsavel"] = $registro["nm_mae"];
                     }
                 } else {
                     if ($registro["nm_pai"]) {
                         $registro["nome_responsavel"] = $registro["nm_pai"];
                     } else {
                         $registro["nome_responsavel"] = $registro["nm_mae"];
                     }
                 }
             }
             $this->addLinhas(array("<a href=\"educar_aluno_det.php?cod_aluno={$registro["cod_aluno"]}\">{$registro["cod_aluno"]}</a>", "<a href=\"educar_aluno_det.php?cod_aluno={$registro["cod_aluno"]}\">{$registro["nome_aluno"]}</a>", "<a href=\"educar_aluno_det.php?cod_aluno={$registro["cod_aluno"]}\">{$registro["nome_responsavel"]}</a>", "<a href=\"educar_aluno_det.php?cod_aluno={$registro["cod_aluno"]}\">{$registro["cpf_responsavel"]}</a>"));
         }
     }
     $this->addPaginador2("educar_aluno_lst.php", $total, $_GET, $this->nome, $this->limite);
     //** Verificacao de permissao para cadastro
     if ($obj_permissoes->permissao_cadastra(578, $this->pessoa_logada, 7)) {
         $this->acao = "go(\"educar_aluno_cad.php\")";
         $this->nome_acao = "Novo";
         $this->array_botao = array("Ficha do Aluno (em branco)");
         $this->array_botao_script = array("showExpansivelImprimir(400, 200,  \"educar_relatorio_aluno_dados.php\",\"\", \"Relatório i-Educar\" )");
     }
     //**
     $this->largura = "100%";
 }
 function Editar()
 {
     session_start();
     $this->pessoa_logada = $_SESSION['id_pessoa'];
     session_write_close();
     if ($this->idbai[0] != '' && $this->cep[0] != '') {
         foreach ($this->cep as $id => $cep) {
             $cep = idFederal2int($cep);
             $obj = new clsUrbanoCepLogradouro($cep, $this->idlog, NULL, NULL, NULL, NULL, 'U', $this->pessoa_logada, NULL, 'I', NULL, 9);
             if (!$obj->existe()) {
                 if (!$obj->cadastra()) {
                     $this->mensagem = 'Cadastro n&atilde;o realizado.<br>';
                     echo "<!--\nErro ao editar clsUrbanoCepLogradouro\nvalores obrigatorios\nif( is_numeric( {$cep} ) && is_numeric( {$this->idlog} ) && is_numeric( {$this->pessoa_logada} ) )\n-->";
                     return FALSE;
                 }
             }
             $obj_cep_log_bairro = new clsUrbanoCepLogradouroBairro($this->idlog, $cep, $this->idbai[$id], NULL, NULL, 'U', $this->pessoa_logada, NULL, 'I', NULL, 9);
             if (!$obj_cep_log_bairro->existe()) {
                 if (!$obj_cep_log_bairro->cadastra()) {
                     $this->mensagem = 'Cadastro n&atilde;o realizado.<br>';
                     echo "<!--\nErro ao editar clsUrbanoCepLogradouroBairro\nvalores obrigatorios\nif( is_numeric( {$cep} ) && is_numeric( {$this->idlog} ) && is_numeric( {$this->idbai[$id]} ) && is_numeric( {$this->pessoa_logada} ) )\n-->";
                     return FALSE;
                 }
             }
         }
         $this->mensagem .= 'Edi&ccedil;&atilde;o efetuada com sucesso.<br>';
         header('Location: urbano_cep_logradouro_lst.php');
         die;
     } else {
         $this->mensagem = 'É necessario adicionar pelo menos um CEP e bairro.<br>';
         return FALSE;
     }
 }
 function Gerar()
 {
     @session_start();
     $this->pessoa_logada = $_SESSION['id_pessoa'];
     session_write_close();
     // Verificação de permissão para cadastro.
     $this->obj_permissao = new clsPermissoes();
     $this->nivel_usuario = $this->obj_permissao->nivel_acesso($this->pessoa_logada);
     $this->titulo = 'Aluno - Detalhe';
     $this->cod_aluno = $_GET['cod_aluno'];
     $tmp_obj = new clsPmieducarAluno($this->cod_aluno);
     $registro = $tmp_obj->detalhe();
     if (!$registro) {
         header('Location: educar_aluno_lst.php');
         die;
     } else {
         foreach ($registro as $key => $value) {
             $this->{$key} = $value;
         }
     }
     if ($this->ref_idpes) {
         $obj_pessoa_fj = new clsPessoaFj($this->ref_idpes);
         $det_pessoa_fj = $obj_pessoa_fj->detalhe();
         $obj_fisica = new clsFisica($this->ref_idpes);
         $det_fisica = $obj_fisica->detalhe();
         $obj_fisica_raca = new clsCadastroFisicaRaca();
         $lst_fisica_raca = $obj_fisica_raca->lista($this->ref_idpes);
         if ($lst_fisica_raca) {
             $det_fisica_raca = array_shift($lst_fisica_raca);
             $obj_raca = new clsCadastroRaca($det_fisica_raca['ref_cod_raca']);
             $det_raca = $obj_raca->detalhe();
         }
         $objFoto = new clsCadastroFisicaFoto($this->ref_idpes);
         $detalheFoto = $objFoto->detalhe();
         if ($detalheFoto) {
             $caminhoFoto = $detalheFoto['caminho'];
         }
         $registro['nome_aluno'] = strtoupper($det_pessoa_fj['nome']);
         $registro['cpf'] = int2IdFederal($det_fisica['cpf']);
         $registro['data_nasc'] = dataToBrasil($det_fisica['data_nasc']);
         $registro['sexo'] = $det_fisica['sexo'] == 'F' ? 'Feminino' : 'Masculino';
         $obj_estado_civil = new clsEstadoCivil();
         $obj_estado_civil_lista = $obj_estado_civil->lista();
         $lista_estado_civil = array();
         if ($obj_estado_civil_lista) {
             foreach ($obj_estado_civil_lista as $estado_civil) {
                 $lista_estado_civil[$estado_civil['ideciv']] = $estado_civil['descricao'];
             }
         }
         $registro['ideciv'] = $lista_estado_civil[$det_fisica['ideciv']->ideciv];
         $registro['email'] = $det_pessoa_fj['email'];
         $registro['url'] = $det_pessoa_fj['url'];
         $registro['nacionalidade'] = $det_fisica['nacionalidade'];
         $registro['naturalidade'] = $det_fisica['idmun_nascimento']->detalhe();
         $registro['naturalidade'] = $registro['naturalidade']['nome'];
         $registro['pais_origem'] = $det_fisica['idpais_estrangeiro']->detalhe();
         $registro['pais_origem'] = $registro['pais_origem']['nome'];
         $registro['ref_idpes_responsavel'] = $det_fisica['idpes_responsavel'];
         $this->idpes_pai = $det_fisica['idpes_pai'];
         $this->idpes_mae = $det_fisica['idpes_mae'];
         $this->sus = $det_fisica['sus'];
         $this->nm_pai = $registro['nm_pai'];
         $this->nm_mae = $registro['nm_mae'];
         if ($this->idpes_pai) {
             $obj_pessoa_pai = new clsPessoaFj($this->idpes_pai);
             $det_pessoa_pai = $obj_pessoa_pai->detalhe();
             if ($det_pessoa_pai) {
                 $registro['nm_pai'] = $det_pessoa_pai['nome'];
                 // CPF
                 $obj_cpf = new clsFisica($this->idpes_pai);
                 $det_cpf = $obj_cpf->detalhe();
                 if ($det_cpf['cpf']) {
                     $this->cpf_pai = int2CPF($det_cpf['cpf']);
                 }
             }
         }
         if ($this->idpes_mae) {
             $obj_pessoa_mae = new clsPessoaFj($this->idpes_mae);
             $det_pessoa_mae = $obj_pessoa_mae->detalhe();
             if ($det_pessoa_mae) {
                 $registro['nm_mae'] = $det_pessoa_mae['nome'];
                 // CPF
                 $obj_cpf = new clsFisica($this->idpes_mae);
                 $det_cpf = $obj_cpf->detalhe();
                 if ($det_cpf['cpf']) {
                     $this->cpf_mae = int2CPF($det_cpf['cpf']);
                 }
             }
         }
         $registro['ddd_fone_1'] = $det_pessoa_fj['ddd_1'];
         $registro['fone_1'] = $det_pessoa_fj['fone_1'];
         $registro['ddd_fone_2'] = $det_pessoa_fj['ddd_2'];
         $registro['fone_2'] = $det_pessoa_fj['fone_2'];
         $registro['ddd_fax'] = $det_pessoa_fj['ddd_fax'];
         $registro['fone_fax'] = $det_pessoa_fj['fone_fax'];
         $registro['ddd_mov'] = $det_pessoa_fj['ddd_mov'];
         $registro['fone_mov'] = $det_pessoa_fj['fone_mov'];
         $obj_deficiencia_pessoa = new clsCadastroFisicaDeficiencia();
         $obj_deficiencia_pessoa_lista = $obj_deficiencia_pessoa->lista($this->ref_idpes);
         if ($obj_deficiencia_pessoa_lista) {
             $deficiencia_pessoa = array();
             foreach ($obj_deficiencia_pessoa_lista as $deficiencia) {
                 $obj_def = new clsCadastroDeficiencia($deficiencia['ref_cod_deficiencia']);
                 $det_def = $obj_def->detalhe();
                 $deficiencia_pessoa[$deficiencia['ref_cod_deficiencia']] = $det_def['nm_deficiencia'];
             }
         }
         $ObjDocumento = new clsDocumento($this->ref_idpes);
         $detalheDocumento = $ObjDocumento->detalhe();
         $registro['rg'] = $detalheDocumento['rg'];
         if ($detalheDocumento['data_exp_rg']) {
             $registro['data_exp_rg'] = date('d/m/Y', strtotime(substr($detalheDocumento['data_exp_rg'], 0, 19)));
         }
         $registro['sigla_uf_exp_rg'] = $detalheDocumento['sigla_uf_exp_rg'];
         $registro['tipo_cert_civil'] = $detalheDocumento['tipo_cert_civil'];
         $registro['num_termo'] = $detalheDocumento['num_termo'];
         $registro['num_livro'] = $detalheDocumento['num_livro'];
         $registro['num_folha'] = $detalheDocumento['num_folha'];
         if ($detalheDocumento['data_emissao_cert_civil']) {
             $registro['data_emissao_cert_civil'] = date('d/m/Y', strtotime(substr($detalheDocumento['data_emissao_cert_civil'], 0, 19)));
         }
         $registro['sigla_uf_cert_civil'] = $detalheDocumento['sigla_uf_cert_civil'];
         $registro['cartorio_cert_civil'] = $detalheDocumento['cartorio_cert_civil'];
         $registro['num_cart_trabalho'] = $detalheDocumento['num_cart_trabalho'];
         $registro['serie_cart_trabalho'] = $detalheDocumento['serie_cart_trabalho'];
         if ($detalheDocumento['data_emissao_cart_trabalho']) {
             $registro['data_emissao_cart_trabalho'] = date('d/m/Y', strtotime(substr($detalheDocumento['data_emissao_cart_trabalho'], 0, 19)));
         }
         $registro['sigla_uf_cart_trabalho'] = $detalheDocumento['sigla_uf_cart_trabalho'];
         $registro['num_tit_eleitor'] = $detalheDocumento['num_titulo_eleitor'];
         $registro['zona_tit_eleitor'] = $detalheDocumento['zona_titulo_eleitor'];
         $registro['secao_tit_eleitor'] = $detalheDocumento['secao_titulo_eleitor'];
         $registro['idorg_exp_rg'] = $detalheDocumento['ref_idorg_rg'];
         $obj_endereco = new clsPessoaEndereco($this->ref_idpes);
         if ($obj_endereco_det = $obj_endereco->detalhe()) {
             $registro['id_cep'] = $obj_endereco_det['cep']->cep;
             $registro['id_bairro'] = $obj_endereco_det['idbai']->idbai;
             $registro['id_logradouro'] = $obj_endereco_det['idlog']->idlog;
             $registro['numero'] = $obj_endereco_det['numero'];
             $registro['letra'] = $obj_endereco_det['letra'];
             $registro['complemento'] = $obj_endereco_det['complemento'];
             $registro['andar'] = $obj_endereco_det['andar'];
             $registro['apartamento'] = $obj_endereco_det['apartamento'];
             $registro['bloco'] = $obj_endereco_det['bloco'];
             $registro['nm_logradouro'] = $obj_endereco_det['logradouro'];
             $registro['cep_'] = int2CEP($registro['id_cep']);
             $obj_bairro = new clsBairro($registro['id_bairro']);
             $obj_bairro_det = $obj_bairro->detalhe();
             if ($obj_bairro_det) {
                 $registro['nm_bairro'] = $obj_bairro_det['nome'];
             }
             $obj_log = new clsLogradouro($registro['id_logradouro']);
             $obj_log_det = $obj_log->detalhe();
             if ($obj_log_det) {
                 $registro['nm_logradouro'] = $obj_log_det['nome'];
                 $registro['idtlog'] = $obj_log_det['idtlog']->detalhe();
                 $registro['idtlog'] = $registro['idtlog']['descricao'];
                 $obj_mun = new clsMunicipio($obj_log_det['idmun']);
                 $det_mun = $obj_mun->detalhe();
                 if ($det_mun) {
                     $registro['cidade'] = ucfirst(strtolower($det_mun['nome']));
                 }
             }
             $obj_bairro = new clsBairro($registro["id_bairro"]);
             $obj_bairro_det = $obj_bairro->detalhe();
             if ($obj_bairro_det) {
                 $registro['nm_bairro'] = $obj_bairro_det['nome'];
             }
         } else {
             $obj_endereco = new clsEnderecoExterno($this->ref_idpes);
             if ($obj_endereco_det = $obj_endereco->detalhe()) {
                 $registro['id_cep'] = $obj_endereco_det['cep'];
                 $registro['cidade'] = $obj_endereco_det['cidade'];
                 $registro['nm_bairro'] = $obj_endereco_det['bairro'];
                 $registro['nm_logradouro'] = $obj_endereco_det['logradouro'];
                 $registro['numero'] = $obj_endereco_det['numero'];
                 $registro['letra'] = $obj_endereco_det['letra'];
                 $registro['complemento'] = $obj_endereco_det['complemento'];
                 $registro['andar'] = $obj_endereco_det['andar'];
                 $registro['apartamento'] = $obj_endereco_det['apartamento'];
                 $registro['bloco'] = $obj_endereco_det['bloco'];
                 $registro['idtlog'] = $obj_endereco_det['idtlog']->detalhe();
                 $registro['idtlog'] = $registro['idtlog']['descricao'];
                 $det_uf = $obj_endereco_det['sigla_uf']->detalhe();
                 $registro['ref_sigla_uf'] = $det_uf['nome'];
                 $registro['cep_'] = int2CEP($registro['id_cep']);
             }
         }
     }
     // Adiciona a informação de zona de localização junto ao bairro do
     // endereço.
     $zona = App_Model_ZonaLocalizacao::getInstance();
     $registro['nm_bairro'] = sprintf('%s (Zona %s)', $registro['nm_bairro'], $zona->getValue($obj_endereco_det['zona_localizacao']));
     if ($registro['cod_aluno']) {
         $this->addDetalhe(array('Código Aluno', $registro['cod_aluno']));
     }
     // código inep
     $alunoMapper = new Educacenso_Model_AlunoDataMapper();
     $alunoInep = NULL;
     try {
         $alunoInep = $alunoMapper->find(array('aluno' => $this->cod_aluno));
         $this->addDetalhe(array('Código inep', $alunoInep->alunoInep));
     } catch (Exception $e) {
     }
     // código estado
     $this->addDetalhe(array('Código estado', $registro['aluno_estado_id']));
     if ($registro['caminho_foto']) {
         $this->addDetalhe(array('Foto', sprintf('<img src="arquivos/educar/aluno/small/%s" border="0">', $registro['caminho_foto'])));
     }
     if ($registro['nome_aluno']) {
         if ($caminhoFoto != null and $caminhoFoto != '') {
             $this->addDetalhe(array('Nome Aluno', $registro['nome_aluno'] . '<p><img height="117" src="' . $caminhoFoto . '"/></p>'));
         } else {
             $this->addDetalhe(array('Nome Aluno', $registro['nome_aluno']));
         }
     }
     if (idFederal2int($registro['cpf'])) {
         $this->addDetalhe(array('CPF', $registro['cpf']));
     }
     if ($registro['data_nasc']) {
         $this->addDetalhe(array('Data de Nascimento', $registro['data_nasc']));
     }
     /**
      * Analfabeto.
      */
     $this->addDetalhe(array('Analfabeto', $registro['analfabeto'] == 0 ? 'Não' : 'Sim'));
     if ($registro['sexo']) {
         $this->addDetalhe(array('Sexo', $registro['sexo']));
     }
     if ($registro['ideciv']) {
         $this->addDetalhe(array('Estado Civil', $registro['ideciv']));
     }
     if ($registro['id_cep']) {
         $this->addDetalhe(array('CEP', $registro['cep_']));
     }
     if ($registro['ref_sigla_uf']) {
         $this->addDetalhe(array('UF', $registro['ref_sigla_uf']));
     }
     if ($registro['cidade']) {
         $this->addDetalhe(array('Cidade', $registro['cidade']));
     }
     if ($registro['nm_bairro']) {
         $this->addDetalhe(array('Bairro', $registro['nm_bairro']));
     }
     if ($registro['nm_logradouro']) {
         $logradouro = '';
         if ($registro['idtlog']) {
             $logradouro .= $registro['idtlog'] . ' ';
         }
         $logradouro .= $registro['nm_logradouro'];
         $this->addDetalhe(array('Logradouro', $logradouro));
     }
     if ($registro['numero']) {
         $this->addDetalhe(array('Número', $registro['numero']));
     }
     if ($registro['letra']) {
         $this->addDetalhe(array('Letra', $registro['letra']));
     }
     if ($registro['complemento']) {
         $this->addDetalhe(array('Complemento', $registro['complemento']));
     }
     if ($registro['bloco']) {
         $this->addDetalhe(array('Bloco', $registro['bloco']));
     }
     if ($registro['andar']) {
         $this->addDetalhe(array('Andar', $registro['andar']));
     }
     if ($registro['apartamento']) {
         $this->addDetalhe(array('Apartamento', $registro['apartamento']));
     }
     if ($registro['naturalidade']) {
         $this->addDetalhe(array('Naturalidade', $registro['naturalidade']));
     }
     if ($registro['nacionalidade']) {
         $lista_nacionalidade = array('NULL' => 'Selecione', 1 => 'Brasileiro', 2 => 'Naturalizado Brasileiro', 3 => 'Estrangeiro');
         $registro['nacionalidade'] = $lista_nacionalidade[$registro['nacionalidade']];
         $this->addDetalhe(array('Nacionalidade', $registro['nacionalidade']));
     }
     if ($registro['pais_origem']) {
         $this->addDetalhe(array('País de Origem', $registro['pais_origem']));
     }
     $responsavel = $tmp_obj->getResponsavelAluno();
     if ($responsavel) {
         $this->addDetalhe(array('Responsável Aluno', $responsavel['nome_responsavel']));
     }
     if ($registro['ref_idpes_responsavel']) {
         $obj_pessoa_resp = new clsPessoaFj($registro['ref_idpes_responsavel']);
         $det_pessoa_resp = $obj_pessoa_resp->detalhe();
         if ($det_pessoa_resp) {
             $registro['ref_idpes_responsavel'] = $det_pessoa_resp['nome'];
         }
         $this->addDetalhe(array('Responsável', $registro['ref_idpes_responsavel']));
     }
     if ($registro['nm_pai']) {
         $this->addDetalhe(array('Pai', $registro['nm_pai']));
     }
     if ($registro["nm_mae"]) {
         $this->addDetalhe(array('Mãe', $registro['nm_mae']));
     }
     if ($registro['fone_1']) {
         if ($registro['ddd_fone_1']) {
             $registro['ddd_fone_1'] = sprintf('(%s)&nbsp;', $registro['ddd_fone_1']);
         }
         $this->addDetalhe(array('Telefone 1', $registro['ddd_fone_1'] . $registro['fone_1']));
     }
     if ($registro['fone_2']) {
         if ($registro['ddd_fone_2']) {
             $registro['ddd_fone_2'] = sprintf('(%s)&nbsp;', $registro['ddd_fone_2']);
         }
         $this->addDetalhe(array('Telefone 2', $registro['ddd_fone_2'] . $registro['fone_2']));
     }
     if ($registro['fone_mov']) {
         if ($registro['ddd_mov']) {
             $registro['ddd_mov'] = sprintf('(%s)&nbsp;', $registro['ddd_mov']);
         }
         $this->addDetalhe(array('Celular', $registro['ddd_mov'] . $registro['fone_mov']));
     }
     if ($registro['fone_fax']) {
         if ($registro['ddd_fax']) {
             $registro['ddd_fax'] = sprintf('(%s)&nbsp;', $registro['ddd_fax']);
         }
         $this->addDetalhe(array('Fax', $registro['ddd_fax'] . $registro['fone_fax']));
     }
     if ($registro['email']) {
         $this->addDetalhe(array('E-mail', $registro['email']));
     }
     if ($registro['url']) {
         $this->addDetalhe(array('Página Pessoal', $registro['url']));
     }
     if ($registro['ref_cod_aluno_beneficio']) {
         $obj_beneficio = new clsPmieducarAlunoBeneficio($registro['ref_cod_aluno_beneficio']);
         $obj_beneficio_det = $obj_beneficio->detalhe();
         $this->addDetalhe(array('Benefício', $obj_beneficio_det['nm_beneficio']));
     }
     if ($registro['ref_cod_religiao']) {
         $obj_religiao = new clsPmieducarReligiao($registro['ref_cod_religiao']);
         $obj_religiao_det = $obj_religiao->detalhe();
         $this->addDetalhe(array('Religião', $obj_religiao_det['nm_religiao']));
     }
     if ($det_raca['nm_raca']) {
         $this->addDetalhe(array('Raça', $det_raca['nm_raca']));
     }
     if ($deficiencia_pessoa) {
         $tabela = '<table border="0" width="300" cellpadding="3"><tr bgcolor="#A1B3BD" align="center"><td>Deficiências</td></tr>';
         $cor = '#D1DADF';
         foreach ($deficiencia_pessoa as $indice => $valor) {
             $cor = $cor == '#D1DADF' ? '#E4E9ED' : '#D1DADF';
             $tabela .= sprintf('<tr bgcolor="%s" align="center"><td>%s</td></tr>', $cor, $valor);
         }
         $tabela .= '</table>';
         $this->addDetalhe(array('Deficiências', $tabela));
     }
     if ($registro['rg']) {
         $this->addDetalhe(array('RG', $registro['rg']));
     }
     if ($registro['data_exp_rg']) {
         $this->addDetalhe(array('Data de Expedição RG', $registro['data_exp_rg']));
     }
     if ($registro['idorg_exp_rg']) {
         $this->addDetalhe(array('Órgão Expedição RG', $registro['idorg_exp_rg']));
     }
     if ($registro['sigla_uf_exp_rg']) {
         $this->addDetalhe(array('Estado Expedidor', $registro['sigla_uf_exp_rg']));
     }
     /**
      * @todo CoreExt_Enum?
      */
     if ($registro['tipo_cert_civil']) {
         $lista_tipo_cert_civil = array();
         $lista_tipo_cert_civil["0"] = 'Selecione';
         $lista_tipo_cert_civil[91] = 'Nascimento';
         $lista_tipo_cert_civil[92] = 'Casamento';
         $this->addDetalhe(array('Tipo Certificado Civil', $registro['tipo_cert_civil']));
     }
     if ($registro['num_termo']) {
         $this->addDetalhe(array('Termo', $registro['num_termo']));
     }
     if ($registro['num_livro']) {
         $this->addDetalhe(array('Livro', $registro['num_livro']));
     }
     if ($registro['num_folha']) {
         $this->addDetalhe(array('Folha', $registro['num_folha']));
     }
     if ($registro['data_emissao_cert_civil']) {
         $this->addDetalhe(array('Emissão Certidão Civil', $registro['data_emissao_cert_civil']));
     }
     if ($registro['sigla_uf_cert_civil']) {
         $this->addDetalhe(array('Sigla Certidão Civil', $registro['sigla_uf_cert_civil']));
     }
     if ($registro['cartorio_cert_civil']) {
         $this->addDetalhe(array('Cartório', $registro['cartorio_cert_civil']));
     }
     if ($registro['num_tit_eleitor']) {
         $this->addDetalhe(array('Título de Eleitor', $registro['num_tit_eleitor']));
     }
     if ($registro['zona_tit_eleitor']) {
         $this->addDetalhe(array('Zona', $registro['zona_tit_eleitor']));
     }
     if ($registro['secao_tit_eleitor']) {
         $this->addDetalhe(array('Seção', $registro['secao_tit_eleitor']));
     }
     // Transporte escolar.
     $transporteMapper = new Transporte_Model_AlunoDataMapper();
     $transporteAluno = NULL;
     try {
         $transporteAluno = $transporteMapper->find(array('aluno' => $this->cod_aluno));
     } catch (Exception $e) {
     }
     $this->addDetalhe(array('Transporte escolar', isset($transporteAluno) && $transporteAluno->responsavel != 'Não utiliza' ? 'Sim' : 'Não'));
     if ($transporteAluno && $transporteAluno->responsavel != 'Não utiliza') {
         $this->addDetalhe(array('Responsável transporte', $transporteAluno->responsavel));
     }
     if ($this->obj_permissao->permissao_cadastra(578, $this->pessoa_logada, 7)) {
         $this->url_novo = '/module/Cadastro/aluno';
         $this->url_editar = '/module/Cadastro/aluno?id=' . $registro['cod_aluno'];
         $this->array_botao = array('Nova matrícula', 'Atualizar Histórico');
         $this->array_botao_url_script = array(sprintf('go("educar_matricula_cad.php?ref_cod_aluno=%d");', $registro['cod_aluno']), sprintf('go("educar_historico_escolar_lst.php?ref_cod_aluno=%d");', $registro['cod_aluno']));
     }
     $objFichaMedica = new clsModulesFichaMedicaAluno($this->cod_aluno);
     $reg = $objFichaMedica->detalhe();
     if ($reg) {
         $this->addDetalhe(array('<span id="fmedica"></span>Altura/metro', $reg['altura']));
         if (trim($reg['peso']) != '') {
             $this->addDetalhe(array('Peso/kg', $reg['peso']));
         }
         if (trim($reg['grupo_sanguineo']) != '') {
             $this->addDetalhe(array('Grupo sanguíneo', $reg['grupo_sanguineo']));
         }
         if (trim($reg['fator_rh']) != '') {
             $this->addDetalhe(array('Fator RH', $reg['fator_rh']));
         }
         if (trim($this->sus) != '') {
             $this->addDetalhe(array('Número do cartão do SUS', $this->sus));
         }
         $this->addDetalhe(array('Possui alergia a algum medicamento', $reg['alergia_medicamento'] == 'S' ? 'Sim' : 'Não'));
         if (trim($reg['desc_alergia_medicamento']) != '') {
             $this->addDetalhe(array('Quais', $reg['desc_alergia_medicamento']));
         }
         $this->addDetalhe(array('Possui alergia a algum alimento', $reg['alergia_alimento'] == 'S' ? 'Sim' : 'Não'));
         if (trim($reg['desc_alergia_alimento']) != '') {
             $this->addDetalhe(array('Quais', $reg['desc_alergia_alimento']));
         }
         $this->addDetalhe(array('Possui alguma doenca congênita', $reg['doenca_congenita'] == 'S' ? 'Sim' : 'Não'));
         if (trim($reg['desc_doenca_congenita']) != '') {
             $this->addDetalhe(array('Quais', $reg['desc_doenca_congenita']));
         }
         $this->addDetalhe(array('É fumante', $reg['fumante'] == 'S' ? 'Sim' : 'Não'));
         $this->addDetalhe(array('Já contraiu caxumba', $reg['doenca_caxumba'] == 'S' ? 'Sim' : 'Não'));
         $this->addDetalhe(array('Já contraiu sarampo', $reg['doenca_sarampo'] == 'S' ? 'Sim' : 'Não'));
         $this->addDetalhe(array('Já contraiu rubeola', $reg['doenca_rubeola'] == 'S' ? 'Sim' : 'Não'));
         $this->addDetalhe(array('Já contraiu catapora', $reg['doenca_catapora'] == 'S' ? 'Sim' : 'Não'));
         $this->addDetalhe(array('Já contraiu escarlatina', $reg['doenca_escarlatina'] == 'S' ? 'Sim' : 'Não'));
         $this->addDetalhe(array('Já contraiu coqueluche', $reg['doenca_coqueluche'] == 'S' ? 'Sim' : 'Não'));
         if (trim($reg['doenca_outras']) != '') {
             $this->addDetalhe(array('Outras doenças que o aluno já contraiu', $reg['doenca_outras']));
         }
         $this->addDetalhe(array('Epilético', $reg['epiletico'] == 'S' ? 'Sim' : 'Não'));
         $this->addDetalhe(array('Está em tratamento', $reg['epiletico_tratamento'] == 'S' ? 'Sim' : 'Não'));
         $this->addDetalhe(array('Hemofílico', $reg['hemofilico'] == 'S' ? 'Sim' : 'Não'));
         $this->addDetalhe(array('Hipertenso', $reg['hipertenso'] == 'S' ? 'Sim' : 'Não'));
         $this->addDetalhe(array('Asmático', $reg['asmatico'] == 'S' ? 'Sim' : 'Não'));
         $this->addDetalhe(array('Diabético', $reg['diabetico'] == 'S' ? 'Sim' : 'Não'));
         $this->addDetalhe(array('Depende de insulina', $reg['insulina'] == 'S' ? 'Sim' : 'Não'));
         $this->addDetalhe(array('Faz tratamento médico', $reg['tratamento_medico'] == 'S' ? 'Sim' : 'Não'));
         if (trim($reg['desc_tratamento_medico']) != '') {
             $this->addDetalhe(array('Qual', $reg['desc_tratamento_medico']));
         }
         $this->addDetalhe(array('Ingere medicação específica', $reg['medicacao_especifica'] == 'S' ? 'Sim' : 'Não'));
         if (trim($reg['desc_medicacao_especifica']) != '') {
             $this->addDetalhe(array('Qual', $reg['desc_medicacao_especifica']));
         }
         $this->addDetalhe(array('Acompanhamento médico ou psicológico', $reg['acomp_medico_psicologico'] == 'S' ? 'Sim' : 'Não'));
         if (trim($reg['desc_acomp_medico_psicologico']) != '') {
             $this->addDetalhe(array('Motivo', $reg['desc_acomp_medico_psicologico']));
         }
         $this->addDetalhe(array('Restrição para atividades físicas', $reg['restricao_atividade_fisica'] == 'S' ? 'Sim' : 'Não'));
         if (trim($reg['desc_restricao_atividade_fisica']) != '') {
             $this->addDetalhe(array('Qual', $reg['desc_restricao_atividade_fisica']));
         }
         $this->addDetalhe(array('Teve alguma fratura ou trauma', $reg['fratura_trauma'] == 'S' ? 'Sim' : 'Não'));
         if (trim($reg['desc_fratura_trauma']) != '') {
             $this->addDetalhe(array('Qual', $reg['desc_fratura_trauma']));
         }
         $this->addDetalhe(array('Tem plano de saúde', $reg['plano_saude'] == 'S' ? 'Sim' : 'Não'));
         if (trim($reg['desc_plano_saude']) != '') {
             $this->addDetalhe(array('Qual', $reg['desc_plano_saude']));
         }
         $this->addDetalhe(array('<span id="tr_tit_dados_hospital">Em caso de emergência, levar para hospital ou clínica</span>'));
         $this->addDetalhe(array('Nome', $reg['hospital_clinica']));
         $this->addDetalhe(array('Endereço', $reg['hospital_clinica_endereco']));
         $this->addDetalhe(array('Telefone', $reg['hospital_clinica_telefone']));
         $this->addDetalhe(array('<span id="tr_tit_dados_responsavel">Em caso de emergência, se não for possível contatar os responsáveis, comunicar</span>'));
         $this->addDetalhe(array('Nome', $reg['responsavel']));
         $this->addDetalhe(array('Parentesco', $reg['responsavel_parentesco']));
         $this->addDetalhe(array('Telefone', $reg['responsavel_parentesco_telefone']));
         $this->addDetalhe(array('Celular', $reg['responsavel_parentesco_celular']));
     }
     $objUniforme = new clsModulesUniformeAluno($this->cod_aluno);
     $reg = $objUniforme->detalhe();
     if ($reg) {
         $this->addDetalhe(array('<span id="funiforme"></span>Recebeu uniforme escolar', $reg['recebeu_uniforme'] == 'S' ? 'Sim' : 'Não'));
         $this->addDetalhe(array('<span class="tit_uniforme">Camiseta</span>'));
         $this->addDetalhe(array('Quantidade', $reg['quantidade_camiseta']));
         $this->addDetalhe(array('Tamanho', $reg['tamanho_camiseta']));
         $this->addDetalhe(array('<span class="tit_uniforme">Blusa/Jaqueta</span>'));
         $this->addDetalhe(array('Quantidade', $reg['quantidade_blusa_jaqueta']));
         $this->addDetalhe(array('Tamanho', $reg['tamanho_blusa_jaqueta']));
         $this->addDetalhe(array('<span class="tit_uniforme">Bermuda</span>'));
         $this->addDetalhe(array('Quantidade', $reg['quantidade_bermuda']));
         $this->addDetalhe(array('Tamanho', $reg['tamanho_bermuda']));
         $this->addDetalhe(array('<span class="tit_uniforme">Calça</span>'));
         $this->addDetalhe(array('Quantidade', $reg['quantidade_calca']));
         $this->addDetalhe(array('Tamanho', $reg['tamanho_calca']));
         $this->addDetalhe(array('<span class="tit_uniforme">Saia</span>'));
         $this->addDetalhe(array('Quantidade', $reg['quantidade_saia']));
         $this->addDetalhe(array('Tamanho', $reg['tamanho_saia']));
         $this->addDetalhe(array('<span class="tit_uniforme">Calçado</span>'));
         $this->addDetalhe(array('Quantidade', $reg['quantidade_calcado']));
         $this->addDetalhe(array('Tamanho', $reg['tamanho_calcado']));
         $this->addDetalhe(array('<span class="tit_uniforme">Meia</span>'));
         $this->addDetalhe(array('Quantidade', $reg['quantidade_meia']));
         $this->addDetalhe(array('Tamanho', $reg['tamanho_meia']));
     }
     $objMoradia = new clsModulesMoradiaAluno($this->cod_aluno);
     $reg = $objMoradia->detalhe();
     if ($reg) {
         $moradia = '';
         switch ($reg['moradia']) {
             case 'A':
                 $moradia = 'Apartamento';
                 break;
             case 'C':
                 $moradia = 'Casa';
                 switch ($reg['material']) {
                     case 'A':
                         $moradia .= ' de alvenaria';
                         break;
                     case 'M':
                         $moradia .= ' de madeira';
                         break;
                     case 'I':
                         $moradia .= ' mista';
                         break;
                 }
                 break;
             case 'O':
                 $moradia = 'Outra: ' . $reg['casa_outra'];
                 break;
             default:
                 $moradia = 'Não informado';
         }
         $this->addDetalhe(array('<span id="fmoradia"></span>Moradia', $moradia));
         $situacao;
         switch ($reg['moradia_situacao']) {
             case 1:
                 $situacao = 'Alugado';
                 break;
             case 2:
                 $situacao = 'Próprio';
                 break;
             case 3:
                 $situacao = 'Cedido';
                 break;
             case 4:
                 $situacao = 'Financiado';
                 break;
             case 5:
                 $situacao = 'Outra';
                 break;
         }
         $this->addDetalhe(array('Situação', $situacao));
         $this->addDetalhe(array('Quantidade de quartos', $reg['quartos']));
         $this->addDetalhe(array('Quantidade de salas', $reg['sala']));
         $this->addDetalhe(array('Quantidade de copas', $reg['copa']));
         $this->addDetalhe(array('Quantidade de banheiros', $reg['banheiro']));
         $this->addDetalhe(array('Quantidade de garagens', $reg['garagem']));
         $this->addDetalhe(array('Possui empregada doméstica', $reg['empregada_domestica']));
         $this->addDetalhe(array('Possui automóvel', $reg['automovel']));
         $this->addDetalhe(array('Possui motocicleta', $reg['motocicleta']));
         $this->addDetalhe(array('Possui computador', $reg['computador']));
         $this->addDetalhe(array('Possui geladeira', $reg['geladeira']));
         $this->addDetalhe(array('Possui fogão', $reg['fogao']));
         $this->addDetalhe(array('Possui máquina de lavar', $reg['maquina_lavar']));
         $this->addDetalhe(array('Possui microondas', $reg['microondas']));
         $this->addDetalhe(array('Possui vídeo/dvd', $reg['video_dvd']));
         $this->addDetalhe(array('Possui televisão', $reg['televisao']));
         $this->addDetalhe(array('Possui celular', $reg['celular']));
         $this->addDetalhe(array('Possui telefone', $reg['telefone']));
         $this->addDetalhe(array('Quantidade de pessoas', $reg['quant_pessoas']));
         $this->addDetalhe(array('Renda familiar', 'R$ ' . $reg['renda']));
         $this->addDetalhe(array('Possui água encanada', $reg['agua_encanada']));
         $this->addDetalhe(array('Possui poço', $reg['poco']));
         $this->addDetalhe(array('Possui energia elétrica', $reg['energia']));
         $this->addDetalhe(array('Possui tratamento de esgoto', $reg['esgoto']));
         $this->addDetalhe(array('Possui fossa', $reg['fossa']));
         $this->addDetalhe(array('Possui coleta de lixo', $reg['lixo']));
     }
     $this->url_cancelar = 'educar_aluno_lst.php';
     $this->largura = '100%';
     $localizacao = new LocalizacaoSistema();
     $localizacao->entradaCaminhos(array($_SERVER['SERVER_NAME'] . "/intranet" => "In&iacute;cio", "educar_index.php" => "i-Educar - Escola", "" => "Detalhe do aluno"));
     $this->enviaLocalizacao($localizacao->montar());
     $this->addDetalhe("<input type='hidden' id='escola_id' name='aluno_id' value='{$registro['ref_cod_escola']}' />");
     $this->addDetalhe("<input type='hidden' id='aluno_id' name='aluno_id' value='{$registro['cod_aluno']}' />");
     // js
     Portabilis_View_Helper_Application::loadJQueryLib($this);
     $scripts = array('/modules/Portabilis/Assets/Javascripts/Utils.js', '/modules/Portabilis/Assets/Javascripts/ClientApi.js', '/modules/Cadastro/Assets/Javascripts/AlunoShow.js');
     Portabilis_View_Helper_Application::loadJavascript($this, $scripts);
     $styles = array('/modules/Cadastro/Assets/Stylesheets/Aluno.css');
     Portabilis_View_Helper_Application::loadStylesheet($this, $styles);
 }
Beispiel #7
0
 /**
  * Exibe uma lista baseada nos parametros de filtragem passados
  *
  * @return Array
  */
 function lista($int_idpes = false, $data_data_nasc = false, $str_sexo = false, $int_idpes_mae = false, $int_idpes_pai = false, $int_idpes_responsavel = false, $int_idesco = false, $int_ideciv = false, $int_idpes_con = false, $data_data_uniao = false, $data_data_obito = false, $int_nacionalidade = false, $int_idpais_estrangeiro = false, $data_data_chagada_brasil = false, $int_idmun_nascimento = false, $str_ultima_empresa = false, $int_idocup = false, $str_nome_mae = false, $str_nome_pai = false, $str_nome_conjuge = false, $str_nome_responsavel = false, $str_justificativa_provisorio = false, $str_ordenacao = false, $int_limite_ini = 0, $int_limite_qtd = 20, $arrayint_idisin = false, $arrayint_idnotin = false, $str_data_nasc_ini = false, $str_data_nasc_fim = false, $int_mes_aniversario = false, $int_ref_cod_sistema = false, $int_cpf = false)
 {
     // verificacoes de filtros a serem usados
     $whereAnd = "WHERE ";
     if (is_numeric($int_idpes)) {
         $where .= "{$whereAnd}idpes = '{$int_idpes}'";
         $whereAnd = " AND ";
     } elseif (is_string($int_idpes)) {
         $where .= "{$whereAnd}idpes IN ({$int_idpes})";
         $whereAnd = " AND ";
     }
     if (is_string($data_data_nasc)) {
         $where .= "{$whereAnd}data_nasc = '{$data_data_nasc}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_mes_aniversario)) {
         $where .= "{$whereAnd} EXTRACT (MONTH FROM data_nasc) = '{$int_mes_aniversario}'";
         $whereAnd = " AND ";
     }
     if (is_string($str_sexo)) {
         $where .= "{$whereAnd}sexo = '{$str_sexo}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_idpes_mae)) {
         $where .= "{$whereAnd}idpes_mae =  '{$int_idpes_mae}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_idpes_pai)) {
         $where .= "{$whereAnd}idpes_pai =  '{$int_idpes_pai}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_idpes_responsavel)) {
         $where .= "{$whereAnd}idpes_responsavel =  '{$int_idpes_responsavel}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_idesco)) {
         $where .= "{$whereAnd}idesco =  '{$int_idesco}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_ideciv)) {
         $where .= "{$whereAnd}ideciv =  '{$int_ideciv}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_idpes_con)) {
         $where .= "{$whereAnd}idpes_con =  '{$int_idpes_con}'";
         $whereAnd = " AND ";
     }
     if (is_string($data_data_uniao)) {
         $where .= "{$whereAnd}data_uniao =  '{$data_data}-uniao'";
         $whereAnd = " AND ";
     }
     if (is_string($data_data_obito)) {
         $where .= "{$whereAnd}data_obito =  '{$data_data_obito}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_nacionalidade)) {
         $where .= "{$whereAnd}nacionalidade =  '{$int_nacionalidade}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_idpais_estrangeiro)) {
         $where .= "{$whereAnd}idpais_strangeiro =  '{$int_idpais_strangeiro}'";
         $whereAnd = " AND ";
     }
     if (is_string($data_data_chegada_brasil)) {
         $where .= "{$whereAnd}data_chegada_brasil =  '{$data_data_chegada_brasil}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_idmun_nascimento)) {
         $where .= "{$whereAnd}idmun_nascimento =  '{$int_idmun_nascimento}'";
         $whereAnd = " AND ";
     }
     if (is_string($str_ultima_empresa)) {
         $where .= "{$whereAnd}ultima_empresa =  '{$str_ultima_empresa}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_idocup)) {
         $where .= "{$whereAnd}idocup = '{$int_idocup}'";
         $whereAnd = " AND ";
     }
     if (is_string($str_nome_mae)) {
         $where .= "{$whereAnd}nome_mae = '{$str_nome_mae}'";
         $whereAnd = " AND ";
     }
     if (is_string($str_nome_pai)) {
         $where .= "{$whereAnd}nome_pai = '{$str_nome_pai}'";
         $whereAnd = " AND ";
     }
     if (is_string($str_nome_conjuge)) {
         $where .= "{$whereAnd}nome_conjuge = '{$str_nome_conjuge}'";
         $whereAnd = " AND ";
     }
     if (is_string($str_nome_responsavel)) {
         $where .= "{$whereAnd}nome_responsavel = '{$str_nome_responsavel}'";
         $whereAnd = " AND ";
     }
     if (is_string($int_ref_cod_sistema)) {
         $where .= "{$whereAnd}ref_cod_sistema = '{$int_ref_cod_sistema}'";
         $whereAnd = " AND ";
     }
     if (is_string($str_justificativa_provisorio)) {
         $where .= "{$whereAnd}justificativa_provisorio = '{$str_justificativa_provisorio}'";
     }
     $int_cpf = idFederal2int($int_cpf);
     if (is_numeric($int_cpf)) {
         $where .= "{$whereAnd}cpf like '%{$int_cpf}%'";
     }
     if (is_array($arrayint_idisin)) {
         $ok = true;
         foreach ($arrayint_idisin as $val) {
             if (!is_numeric($val)) {
                 $ok = false;
             }
         }
         if ($ok) {
             $where .= "{$whereAnd}idpes IN ( " . implode(",", $arrayint_idisin) . " )";
             $whereAnd = " AND ";
         }
     }
     if (is_array($arrayint_idnotin)) {
         $ok = true;
         foreach ($arrayint_idnotin as $val) {
             if (!is_numeric($val)) {
                 $ok = false;
             }
         }
         if ($ok) {
             $where .= "{$whereAnd}idpes NOT IN ( " . implode(",", $arrayint_idnotin) . " )";
             $whereAnd = " AND ";
         }
     }
     if (is_string($str_data_nasc_ini)) {
         $dia = substr($str_data_nasc_ini, 8, 2);
         $mes = substr($str_data_nasc_ini, 5, 2);
         $ano = substr($str_data_nasc_ini, 0, 4);
         $operador = $str_data_nasc_fim ? ">=" : "=";
         if ($dia != "" && $dia != "00") {
             $where .= "{$whereAnd}EXTRACT(DAY FROM data_nasc) {$operador} '{$dia}'";
             $whereAnd = " AND ";
         }
         if ($mes != "" && $mes != "00") {
             $where .= "{$whereAnd}EXTRACT(MONTH FROM data_nasc) {$operador} '{$mes}'";
             $whereAnd = " AND ";
         }
         if ($ano != "" && $ano != "0000") {
             $where .= "{$whereAnd}EXTRACT(YEAR FROM data_nasc) {$operador} '{$ano}'";
             $whereAnd = " AND ";
         }
     }
     if (is_string($str_data_nasc_fim)) {
         $dia = substr($str_data_nasc_fim, 8, 2);
         $mes = substr($str_data_nasc_fim, 5, 2);
         $ano = substr($str_data_nasc_fim, 0, 4);
         if ($dia != "" && $dia != "00") {
             $where .= "{$whereAnd}EXTRACT(DAY FROM data_nasc) <= '{$dia}'";
             $whereAnd = " AND ";
         }
         if ($mes != "" && $mes != "00") {
             $where .= "{$whereAnd}EXTRACT(MONTH FROM data_nasc) <= '{$mes}'";
             $whereAnd = " AND ";
         }
         if ($ano != "" && $ano != "0000") {
             $where .= "{$whereAnd}EXTRACT(YEAR FROM data_nasc) <= '{$ano}'";
             $whereAnd = " AND ";
         }
     }
     $orderBy = "";
     if (is_string($str_ordenacao)) {
         $orderBy = "ORDER BY {$str_ordenacao}";
     }
     $limit = "";
     if (is_numeric($int_limite_ini) && is_numeric($int_limite_qtd)) {
         $limit = " LIMIT {$int_limite_ini},{$int_limite_qtd}";
     }
     $db = new clsBanco();
     $db->Consulta("SELECT COUNT(0) AS total FROM {$this->schema}.{$this->tabela} {$where}");
     $db->ProximoRegistro();
     $total = $db->Campo("total");
     $db->Consulta("SELECT idpes, data_nasc, sexo, idpes_mae, idpes_pai, idpes_responsavel, idesco, ideciv, idpes_con, data_uniao, data_obito, nacionalidade, idpais_estrangeiro, data_chegada_brasil, idmun_nascimento, ultima_empresa, idocup, nome_mae, nome_pai, nome_conjuge, nome_responsavel, justificativa_provisorio, ref_cod_religiao FROM {$this->schema}.{$this->tabela} {$where} {$orderBy} {$limit}");
     $resultado = array();
     while ($db->ProximoRegistro()) {
         $tupla = $db->Tupla();
         $tupla["idesco"] = $tupla["idesco"];
         $tupla["ideciv"] = new clsEstadoCivil($tupla["ideciv"]);
         $tupla["idpais_estrangeiro"] = new clsPais($tupla["idpais_estrangeiro"]);
         $tupla["idmun_nascimento"] = new clsMunicipio($tupla["idmun_nascimento"]);
         $tupla["idocup"] = new clsOcupacao($tupla["idocup"]);
         $tupla["total"] = $total;
         $resultado[] = $tupla;
     }
     if (count($resultado)) {
         return $resultado;
     }
     return false;
 }
 function Editar()
 {
     @session_start();
     $this->pessoa_logada = $_SESSION['id_pessoa'];
     @session_write_close();
     $obj_permissoes = new clsPermissoes();
     $obj_permissoes->permissao_cadastra(595, $this->pessoa_logada, 11, "educar_acervo_editora_lst.php");
     $this->cep = idFederal2int($this->cep);
     $obj = new clsPmieducarAcervoEditora($this->cod_acervo_editora, null, $this->pessoa_logada, $this->ref_idtlog, $this->ref_sigla_uf, $this->nm_editora, $this->cep, $this->cidade, $this->bairro, $this->logradouro, $this->numero, $this->telefone, $this->ddd_telefone, null, null, 1, $this->ref_cod_biblioteca);
     $editou = $obj->edita();
     if ($editou) {
         $this->mensagem .= "Edi&ccedil;&atilde;o efetuada com sucesso.<br>";
         header("Location: educar_acervo_editora_lst.php");
         die;
         return true;
     }
     $this->mensagem = "Edi&ccedil;&atilde;o n&atilde;o realizada.<br>";
     echo "<!--\nErro ao editar clsPmieducarAcervoEditora\nvalores obrigat&oacute;rios\nif( is_numeric( {$this->cod_acervo_editora} ) && is_numeric( {$this->pessoa_logada} ) )\n-->";
     return false;
 }
 function Gerar()
 {
     @session_start();
     $this->pessoa_logada = $_SESSION['id_pessoa'];
     session_write_close();
     $this->titulo = "Aluno - Listagem";
     // passa todos os valores obtidos no GET para atributos do objeto
     foreach ($_GET as $var => $val) {
         $this->{$var} = $val === "" ? null : $val;
     }
     $this->addCabecalhos(array("Nome", "CPF", "Nome Respons&aacute;vel", "CPF Respons&aacute;vel"));
     $this->campoOculto("campo1", $this->campo1);
     $this->campoOculto("campo3", $this->campo3);
     $this->campoOculto("campo4", $this->campo4);
     $this->campoTexto("nome_aluno", "Nome do Aluno", $this->nome_aluno, 20, 255, false);
     $this->campoCpf("cpf_aluno", "CPF do Aluno", $this->cpf_aluno, false);
     $this->campoTexto("nome_responsavel", "Nome do Respons&aacute;vel", $this->nome_responsavel, 20, false);
     $this->campoCpf("cpf_responsavel", "CPF do Respons&aacute;vel", $this->cpf_responsavel, false);
     // Paginador
     $this->limite = 10;
     $this->offset = $_GET["pagina_{$this->nome}"] ? $_GET["pagina_{$this->nome}"] * $this->limite - $this->limite : 0;
     $obj_aluno = new clsPmieducarAlunoCMF();
     $obj_aluno->setLimite($this->limite, $this->offset);
     $lista_aluno = $obj_aluno->lista($this->nome_aluno, idFederal2int($this->cpf_aluno), $this->nome_responsavel, idFederal2int($this->cpf_responsavel));
     $total = $obj_aluno->_total;
     if ($lista_aluno) {
         foreach ($lista_aluno as $registro) {
             if ($registro["cpf_aluno"]) {
                 $registro["cpf_aluno_"] = int2CPF($registro["cpf_aluno"]);
             }
             if ($registro["cpf_responsavel"]) {
                 $registro["cpf_responsavel_"] = int2CPF($registro["cpf_responsavel"]);
             }
             //						$script = " onclick=\"addVal1('{$_GET['campo3']}','{$registro['cpf_aluno']}'); addVal1('{$_GET['campo1']}','{$registro['cod_aluno']}');  addVal1('{$_SESSION['campo4']}','{$registro['cpf_aluno_']}'); fecha();\"";
             $script = " onclick=\"addVal1('{$this->campo3}','{$registro['cpf_aluno']}'); addVal1('{$this->campo1}','{$registro['cod_aluno']}');  addVal1('{$this->campo4}','{$registro['cpf_aluno_']}'); fecha();\"";
             $obj_det = "";
             $obj_cpf_det = "";
             if ($registro["idpes_responsavel"]) {
                 $obj_resp = new clsPessoa_($registro["idpes_responsavel"]);
                 $obj_det = $obj_resp->detalhe();
                 $obj_cpf = new clsFisica($registro["idpes_responsavel"]);
                 $obj_cpf_det = $obj_cpf->detalhe();
                 if ($obj_cpf_det["cpf"]) {
                     $obj_cpf_det["cpf"] = int2IdFederal($obj_cpf_det["cpf"]);
                 }
             }
             $this->addLinhas(array("<a href=\"javascript:void( 0 );\" {$script}>{$registro["nome_aluno"]}</a>", "<a href=\"javascript:void( 0 );\" {$script}>{$registro["cpf_aluno_"]}</a>", "<a href=\"javascript:void( 0 );\" {$script}>{$obj_det["nome"]}</a>", "<a href=\"javascript:void( 0 );\" {$script}>{$obj_cpf_det["cpf"]}</a>"));
         }
     }
     $this->addPaginador2("educar_pesquisa_aluno_lst2.php", $total, $_GET, $this->nome, $this->limite);
     //verifica se foi realizado pesquisa
     if (isset($_GET["nome_aluno"]) || isset($_GET["nome_responsavel"]) || isset($_GET["cpf_aluno"]) || isset($_GET["cpf_responsavel"])) {
         $ok = true;
     }
     //** Verificacao de permissao para cadastro
     $obj_permissao = new clsPermissoes();
     if ($obj_permissao->permissao_cadastra(578, $this->pessoa_logada, 7) && $ok) {
         $this->acao = "window.parent.document.getElementById(\"cpf_\").disabled = true;\n\t\t\t\t\t\t   window.parent.document.getElementById(\"cpf_\").value = \"\";\n\t\t\t\t\t\t   window.parent.document.getElementById(\"cpf_2\").disabled = true; \n\t\t\t\t\t\t   window.parent.document.getElementById(\"cpf_2\").value = \"\"; \n\t\t\t\t\t\t   window.parent.document.getElementById(\"ref_idpes\").value = \"\"; \n\t\t\t\t\t\t   window.parent.document.getElementById(\"cpf\").value = \"\";\n\t\t\t\t\t\t   window.parent.document.getElementById(\"cpf\").disabled = true;\n\t\t\t\t\t\t   window.parent.document.getElementById(\"cpf\").value = \"\";\n\t\t\t\t\t\t   window.parent.document.getElementById(\"bloqueado\").value = \"0\";\n\t\t\t\t\t\t   window.parent.passaPagina();\n\t\t\t\t\t\t   fecha1();";
         $this->nome_acao = "Novo";
     }
     //**
     $this->largura = "100%";
 }
Beispiel #10
0
 function Gerar()
 {
     @session_start();
     $id_pessoa = $_SESSION['id_pessoa'];
     $this->nome = "form1";
     if ($_GET["campos"]) {
         $campos = str_replace("\\", null, $_GET["campos"]);
         $campos = unserialize($campos);
         $_SESSION['campos'] = $campos;
         unset($_GET["campos"]);
     } else {
         $campos = $_SESSION['campos'];
     }
     @session_write_close();
     $submit = false;
     $this->addCabecalhos(array("CEP", "Logradouro", "Bairro", "Cidade"));
     // Filtros de Busca
     $this->campoCep("cep", "CEP", "");
     $this->campoTexto("logradouro", "Logradouro", "", 30, 255);
     $this->campoTexto("cidade", "Cidade", "", 30, 255);
     if ($_GET["busca"] == "S") {
         $cep = @$_GET["cep"];
         $logradouro = @$_GET["logradouro"];
         $cidade = @$_GET["cidade"];
         $cep = idFederal2int($cep);
     }
     // Paginador
     $limite = 10;
     $iniciolimit = $_GET["pagina_{$this->nome}"] ? $_GET["pagina_{$this->nome}"] * $limite - $limite : 0;
     ################### BUSCA CIDADE E LOGRADOURO ##########
     if ($cidade && $logradouro) {
         $obj_mun = new clsMunicipio();
         $lista = $obj_mun->lista($cidade);
         $obj_logradouro = new clsLogradouro();
         $lista_logradouros = $obj_logradouro->lista(false, $logradouro, $lista[0]['idmun'], false, false);
         if ($lista_logradouros) {
             foreach ($lista_logradouros as $logradouro) {
                 $objCepLogBairro = new clsCepLogradouroBairro();
                 $listaCepLogBairro = $objCepLogBairro->lista($logradouro['idlog'], false, "", "idlog", $iniciolimit, $limite);
                 if ($listaCepLogBairro) {
                     foreach ($listaCepLogBairro as $id => $juncao) {
                         $det_cepLog = $juncao['idlog']->detalhe();
                         $det_log = $det_cepLog['idlog']->detalhe();
                         $det_TLog = $det_log['idtlog']->detalhe();
                         $det_bai = $juncao['idbai']->detalhe();
                         $det_mun = $det_bai['idmun']->detalhe();
                         $det_uf = $det_mun['sigla_uf']->detalhe();
                         $cep_formatado = int2CEP($det_cepLog['cep']);
                         //$funcao 	   = "set_campo_pesquisa( 'cidade', '".$det_mun["nome"]."', 'bairro', '".$det_bai["nome"]."', 'idbai', '".$det_bai["idbai"]."', 'logradouro', '".$det_log["nome"]."', 'idlog', '".$det_log["idlog"]."', 'cep', '".$det_cepLog['cep']."', 'cep_', '".$cep_formatado."', 'sigla_uf', '".$det_mun["sigla_uf"]."', 'idtlog', '".$det_TLog["idtlog"]."' )";
                         $funcao = "enviar( '{$det_cepLog["cep"]}', '{$det_bai["idbai"]}', '{$det_log["idlog"]}', '{$det_mun["nome"]}', '{$det_bai["nome"]}', '{$det_log["nome"]}', '{$det_uf["sigla_uf"]}', '{$det_TLog["idtlog"]}' )";
                         $this->addLinhas(array("<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$cep_formatado}</a>", "<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$det_log["nome"]}</a>", "<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$det_bai["nome"]}</a>", "<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$det_mun["nome"]}</a>"));
                         $total = $juncao['total'];
                     }
                 }
             }
         }
     }
     ######################################################################
     if ($cep || !$cep && !$logradouro && !$cidade) {
         $obj_cepLogBai = new clsCepLogradouroBairro();
         $lst_cepLogBai = $obj_cepLogBai->lista(false, $cep, false, "idlog", $iniciolimit, $limite);
         if ($lst_cepLogBai) {
             foreach ($lst_cepLogBai as $juncao) {
                 $det_bai = $juncao['idbai']->detalhe();
                 $det_mun = $det_bai['idmun']->detalhe();
                 $det_uf = $det_mun['sigla_uf']->detalhe();
                 $det_cepLog = $juncao['idlog']->detalhe();
                 $det_log = $det_cepLog['idlog']->detalhe();
                 $det_TLog = $det_log['idtlog']->detalhe();
                 $cep_formatado = int2CEP($det_cepLog["cep"]);
                 //$funcao 	   = "set_campo_pesquisa( 'cidade', '".$det_mun["nome"]."', 'bairro', '".$det_bai["nome"]."', 'idbai', '".$det_bai["idbai"]."', 'logradouro', '".$det_log["nome"]."', 'idlog', '".$det_log["idlog"]."', 'cep', '".$det_cepLog["cep"]."', 'cep_', '".$cep_formatado."', 'sigla_uf', '".$det_uf["sigla_uf"]."', 'idtlog', '".$det_TLog["idtlog"]."' )";
                 $funcao = "enviar( '{$det_cepLog["cep"]}', '{$det_bai["idbai"]}', '{$det_log["idlog"]}', '{$det_mun["nome"]}', '{$det_bai["nome"]}', '{$det_log["nome"]}', '{$det_uf["sigla_uf"]}', '{$det_TLog["idtlog"]}' )";
                 $this->addLinhas(array("<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$cep_formatado}</a>", "<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$det_log["nome"]}</a>", "<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$det_bai["nome"]}</a>", "<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$det_mun["nome"]}</a>"));
                 $total = $juncao['total'];
             }
         } else {
             $this->addLinhas(array("Não existe nenhum resultado a ser apresentado."));
         }
     } elseif ($logradouro) {
         $obj_logradouro = new clsLogradouro();
         $lista_logradouros = $obj_logradouro->lista(false, $logradouro, false, false, false);
         if ($lista_logradouros) {
             foreach ($lista_logradouros as $logradouro) {
                 $objCepLogBairro = new clsCepLogradouroBairro();
                 $listaCepLogBairro = $objCepLogBairro->lista($logradouro['idlog'], false, "", "idlog", $iniciolimit, $limite);
                 if ($listaCepLogBairro) {
                     foreach ($listaCepLogBairro as $id => $juncao) {
                         $det_cepLog = $juncao['idlog']->detalhe();
                         $det_log = $det_cepLog['idlog']->detalhe();
                         $det_TLog = $det_log['idtlog']->detalhe();
                         $det_bai = $juncao['idbai']->detalhe();
                         $det_mun = $det_bai['idmun']->detalhe();
                         $det_uf = $det_mun['sigla_uf']->detalhe();
                         $cep_formatado = int2CEP($det_cepLog['cep']);
                         //$funcao 	   = "set_campo_pesquisa( 'cidade', '".$det_mun["nome"]."', 'bairro', '".$det_bai["nome"]."', 'idbai', '".$det_bai["idbai"]."', 'logradouro', '".$det_log["nome"]."', 'idlog', '".$det_log["idlog"]."', 'cep', '".$det_cepLog['cep']."', 'cep_', '".$cep_formatado."', 'sigla_uf', '".$det_mun["sigla_uf"]."', 'idtlog', '".$det_TLog["idtlog"]."' )";
                         $funcao = "enviar( '{$det_cepLog["cep"]}', '{$det_bai["idbai"]}', '{$det_log["idlog"]}', '{$det_mun["nome"]}', '{$det_bai["nome"]}', '{$det_log["nome"]}', '{$det_uf["sigla_uf"]}', '{$det_TLog["idtlog"]}' )";
                         $this->addLinhas(array("<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$cep_formatado}</a>", "<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$det_log["nome"]}</a>", "<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$det_bai["nome"]}</a>", "<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$det_mun["nome"]}</a>"));
                         $total = $juncao['total'];
                     }
                 }
             }
         }
     } elseif ($cidade) {
         $cidade = strtoupper(limpa_acentos($cidade));
         $resultado = "";
         $obj_mun = new clsMunicipio();
         $lista = $obj_mun->lista($cidade);
         if ($lista) {
             foreach ($lista as $cidade) {
                 $det_uf = $cidade['sigla_uf']->detalhe();
                 $objBairro = new clsBairro();
                 $listaBairro = $objBairro->lista($cidade['idmun'], false);
                 if ($listaBairro) {
                     foreach ($listaBairro as $bairro) {
                         $objCepLogBairro = new clsCepLogradouroBairro();
                         $listaCepLogBairro = $objCepLogBairro->lista(false, false, $bairro['idbai'], "idlog", $iniciolimit, $limite);
                         if ($listaCepLogBairro) {
                             foreach ($listaCepLogBairro as $id => $juncao) {
                                 $det_cepLog = $juncao['idlog']->detalhe();
                                 $det_log = $det_cepLog['idlog']->detalhe();
                                 $det_TLog = $det_log['idtlog']->detalhe();
                                 $cep_formatado = int2CEP($det_cepLog['cep']);
                                 if ($logradouro) {
                                     if (substr_count(strtolower($det_log["nome"]), strtolower($logradouro)) > 0) {
                                         //$funcao 	   = "set_campo_pesquisa( 'cidade', '".$cidade["nome"]."', 'bairro', '".$bairro["nome"]."', 'idbai', '".$bairro["idbai"]."', 'logradouro', '".$det_log["nome"]."', 'idlog', '".$det_log["idlog"]."', 'cep', '".$det_cepLog['cep']."', 'cep_', '".$cep_formatado."', 'sigla_uf', '".$cidade["sigla_uf"]."', 'idtlog', '".$det_TLog["idtlog"]."' )";
                                         $funcao = "enviar( '{$det_cepLog["cep"]}', '{$bairro["idbai"]}', '{$det_log["idlog"]}', '{$cidade["nome"]}', '{$bairro["nome"]}', '{$det_log["nome"]}', '{$det_uf["sigla_uf"]}', '{$det_TLog["idtlog"]}' )";
                                         $this->addLinhas(array("<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$cep_formatado}</a>", "<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$det_log["nome"]}</a>", "<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$bairro["nome"]}</a>", "<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$cidade["nome"]}</a>"));
                                         $total = $juncao['total'];
                                     }
                                 } else {
                                     //$funcao 	   = "set_campo_pesquisa( 'cidade', '".$cidade["nome"]."', 'bairro', '".$bairro["nome"]."', 'idbai', '".$bairro["idbai"]."', 'logradouro', '".$det_log["nome"]."', 'idlog', '".$det_log["idlog"]."', 'cep', '".$det_cepLog['cep']."', 'cep_', '".$cep_formatado."', 'sigla_uf', '".$cidade["sigla_uf"]."', 'idtlog', '".$det_TLog["idtlog"]."' )";
                                     $funcao = "enviar( '{$det_cepLog["cep"]}', '{$bairro["idbai"]}', '{$det_log["idlog"]}', '{$cidade["nome"]}', '{$bairro["nome"]}', '{$det_log["nome"]}', '{$det_uf["sigla_uf"]}', '{$det_TLog["idtlog"]}' )";
                                     $this->addLinhas(array("<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$cep_formatado}</a>", "<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$det_log["nome"]}</a>", "<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$bairro["nome"]}</a>", "<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$cidade["nome"]}</a>"));
                                     $total = $juncao['total'];
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     // Paginador
     $this->addPaginador2("pesquisa_cep_lst.php", $total, $_GET, $this->nome, $limite);
     $funcao_js = "pesquisa_libera_campos( 'cep_', 'sigla_uf', 'cidade', 'bairro', 'idtlog', 'logradouro', 'idbai', 'idlog' )";
     $this->rodape = "\n\t\t\t\t\t\t<table border='0' cellspacing='0' cellpadding='0' width=\"100%\" align=\"center\">\n\t\t\t\t\t\t<tr width='100%'>\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t<div align='center'>[ <a href='javascript:void(0);' onclick=\"{$funcao_js}\">Cadastrar Novo Endere&ccedil;o</a> ]</div>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>";
     // Define Largura da Página
     $this->largura = "100%";
 }
Beispiel #11
0
 function Gerar()
 {
     @session_start();
     $this->pessoa_logada = $_SESSION['id_pessoa'];
     session_write_close();
     $this->titulo = 'Aluno - Detalhe';
     $this->addBanner('imagens/nvp_top_intranet.jpg', 'imagens/nvp_vert_intranet.jpg', 'Intranet');
     $this->cod_aluno = $_GET['cod_aluno'];
     $tmp_obj = new clsPmieducarAluno($this->cod_aluno);
     $registro = $tmp_obj->detalhe();
     if (!$registro) {
         header('Location: educar_aluno_lst.php');
         die;
     } else {
         foreach ($registro as $key => $value) {
             $this->{$key} = $value;
         }
     }
     if ($this->ref_idpes) {
         $obj_pessoa_fj = new clsPessoaFj($this->ref_idpes);
         $det_pessoa_fj = $obj_pessoa_fj->detalhe();
         $obj_fisica = new clsFisica($this->ref_idpes);
         $det_fisica = $obj_fisica->detalhe();
         $obj_fisica_raca = new clsCadastroFisicaRaca();
         $lst_fisica_raca = $obj_fisica_raca->lista($this->ref_idpes);
         if ($lst_fisica_raca) {
             $det_fisica_raca = array_shift($lst_fisica_raca);
             $obj_raca = new clsCadastroRaca($det_fisica_raca['ref_cod_raca']);
             $det_raca = $obj_raca->detalhe();
         }
         $registro['nome_aluno'] = $det_pessoa_fj['nome'];
         $registro['cpf'] = int2IdFederal($det_fisica['cpf']);
         $registro['data_nasc'] = dataToBrasil($det_fisica['data_nasc']);
         $registro['sexo'] = $det_fisica['sexo'] == 'F' ? 'Feminino' : 'Masculino';
         $obj_estado_civil = new clsEstadoCivil();
         $obj_estado_civil_lista = $obj_estado_civil->lista();
         $lista_estado_civil = array();
         if ($obj_estado_civil_lista) {
             foreach ($obj_estado_civil_lista as $estado_civil) {
                 $lista_estado_civil[$estado_civil['ideciv']] = $estado_civil['descricao'];
             }
         }
         $registro['ideciv'] = $lista_estado_civil[$det_fisica['ideciv']->ideciv];
         $registro['email'] = $det_pessoa_fj['email'];
         $registro['url'] = $det_pessoa_fj['url'];
         $registro['nacionalidade'] = $det_fisica['nacionalidade'];
         $registro['naturalidade'] = $det_fisica['idmun_nascimento']->detalhe();
         $registro['naturalidade'] = $registro['naturalidade']['nome'];
         $registro['pais_origem'] = $det_fisica['idpais_estrangeiro']->detalhe();
         $registro['pais_origem'] = $registro['pais_origem']['nome'];
         $registro['ref_idpes_responsavel'] = $det_fisica['idpes_responsavel'];
         $this->idpes_pai = $det_fisica['idpes_pai'];
         $this->idpes_mae = $det_fisica['idpes_mae'];
         $this->nm_pai = $detalhe_aluno['nm_pai'];
         $this->nm_mae = $detalhe_aluno['nm_mae'];
         if ($this->idpes_pai) {
             $obj_pessoa_pai = new clsPessoaFj($this->idpes_pai);
             $det_pessoa_pai = $obj_pessoa_pai->detalhe();
             if ($det_pessoa_pai) {
                 $registro['nm_pai'] = $det_pessoa_pai['nome'];
                 // CPF
                 $obj_cpf = new clsFisica($this->idpes_pai);
                 $det_cpf = $obj_cpf->detalhe();
                 if ($det_cpf['cpf']) {
                     $this->cpf_pai = int2CPF($det_cpf['cpf']);
                 }
             }
         }
         if ($this->idpes_mae) {
             $obj_pessoa_mae = new clsPessoaFj($this->idpes_mae);
             $det_pessoa_mae = $obj_pessoa_mae->detalhe();
             if ($det_pessoa_mae) {
                 $registro['nm_mae'] = $det_pessoa_mae['nome'];
                 // CPF
                 $obj_cpf = new clsFisica($this->idpes_mae);
                 $det_cpf = $obj_cpf->detalhe();
                 if ($det_cpf['cpf']) {
                     $this->cpf_mae = int2CPF($det_cpf['cpf']);
                 }
             }
         }
         $registro['ddd_fone_1'] = $det_pessoa_fj['ddd_1'];
         $registro['fone_1'] = $det_pessoa_fj['fone_1'];
         $registro['ddd_fone_2'] = $det_pessoa_fj['ddd_2'];
         $registro['fone_2'] = $det_pessoa_fj['fone_2'];
         $registro['ddd_fax'] = $det_pessoa_fj['ddd_fax'];
         $registro['fone_fax'] = $det_pessoa_fj['fone_fax'];
         $registro['ddd_mov'] = $det_pessoa_fj['ddd_mov'];
         $registro['fone_mov'] = $det_pessoa_fj['fone_mov'];
         $obj_deficiencia_pessoa = new clsCadastroFisicaDeficiencia();
         $obj_deficiencia_pessoa_lista = $obj_deficiencia_pessoa->lista($this->ref_idpes);
         if ($obj_deficiencia_pessoa_lista) {
             $deficiencia_pessoa = array();
             foreach ($obj_deficiencia_pessoa_lista as $deficiencia) {
                 $obj_def = new clsCadastroDeficiencia($deficiencia['ref_cod_deficiencia']);
                 $det_def = $obj_def->detalhe();
                 $deficiencia_pessoa[$deficiencia['ref_cod_deficiencia']] = $det_def['nm_deficiencia'];
             }
         }
         $ObjDocumento = new clsDocumento($this->ref_idpes);
         $detalheDocumento = $ObjDocumento->detalhe();
         $registro['rg'] = $detalheDocumento['rg'];
         if ($detalheDocumento['data_exp_rg']) {
             $registro['data_exp_rg'] = date('d/m/Y', strtotime(substr($detalheDocumento['data_exp_rg'], 0, 19)));
         }
         $registro['sigla_uf_exp_rg'] = $detalheDocumento['sigla_uf_exp_rg'];
         $registro['tipo_cert_civil'] = $detalheDocumento['tipo_cert_civil'];
         $registro['num_termo'] = $detalheDocumento['num_termo'];
         $registro['num_livro'] = $detalheDocumento['num_livro'];
         $registro['num_folha'] = $detalheDocumento['num_folha'];
         if ($detalheDocumento['data_emissao_cert_civil']) {
             $registro['data_emissao_cert_civil'] = date('d/m/Y', strtotime(substr($detalheDocumento['data_emissao_cert_civil'], 0, 19)));
         }
         $registro['sigla_uf_cert_civil'] = $detalheDocumento['sigla_uf_cert_civil'];
         $registro['cartorio_cert_civil'] = $detalheDocumento['cartorio_cert_civil'];
         $registro['num_cart_trabalho'] = $detalheDocumento['num_cart_trabalho'];
         $registro['serie_cart_trabalho'] = $detalheDocumento['serie_cart_trabalho'];
         if ($detalheDocumento['data_emissao_cart_trabalho']) {
             $registro['data_emissao_cart_trabalho'] = date('d/m/Y', strtotime(substr($detalheDocumento['data_emissao_cart_trabalho'], 0, 19)));
         }
         $registro['sigla_uf_cart_trabalho'] = $detalheDocumento['sigla_uf_cart_trabalho'];
         $registro['num_tit_eleitor'] = $detalheDocumento['num_titulo_eleitor'];
         $registro['zona_tit_eleitor'] = $detalheDocumento['zona_titulo_eleitor'];
         $registro['secao_tit_eleitor'] = $detalheDocumento['secao_titulo_eleitor'];
         $registro['idorg_exp_rg'] = $detalheDocumento['ref_idorg_rg'];
         $obj_endereco = new clsPessoaEndereco($this->ref_idpes);
         if ($obj_endereco_det = $obj_endereco->detalhe()) {
             $registro['id_cep'] = $obj_endereco_det['cep']->cep;
             $registro['id_bairro'] = $obj_endereco_det['idbai']->idbai;
             $registro['id_logradouro'] = $obj_endereco_det['idlog']->idlog;
             $registro['numero'] = $obj_endereco_det['numero'];
             $registro['letra'] = $obj_endereco_det['letra'];
             $registro['complemento'] = $obj_endereco_det['complemento'];
             $registro['andar'] = $obj_endereco_det['andar'];
             $registro['apartamento'] = $obj_endereco_det['apartamento'];
             $registro['bloco'] = $obj_endereco_det['bloco'];
             $registro['nm_logradouro'] = $obj_endereco_det['logradouro'];
             $registro['cep_'] = int2CEP($registro['id_cep']);
             $obj_bairro = new clsBairro($registro['id_bairro']);
             $obj_bairro_det = $obj_bairro->detalhe();
             if ($obj_bairro_det) {
                 $registro['nm_bairro'] = $obj_bairro_det['nome'];
             }
             $obj_log = new clsLogradouro($registro['id_logradouro']);
             $obj_log_det = $obj_log->detalhe();
             if ($obj_log_det) {
                 $registro['nm_logradouro'] = $obj_log_det['nome'];
                 $registro['idtlog'] = $obj_log_det['idtlog']->detalhe();
                 $registro['idtlog'] = $registro['idtlog']['descricao'];
                 $obj_mun = new clsMunicipio($obj_log_det['idmun']);
                 $det_mun = $obj_mun->detalhe();
                 if ($det_mun) {
                     $registro['cidade'] = ucfirst(strtolower($det_mun['nome']));
                 }
             }
             $obj_bairro = new clsBairro($registro["id_bairro"]);
             $obj_bairro_det = $obj_bairro->detalhe();
             if ($obj_bairro_det) {
                 $registro['nm_bairro'] = $obj_bairro_det['nome'];
             }
         } else {
             $obj_endereco = new clsEnderecoExterno($this->ref_idpes);
             if ($obj_endereco_det = $obj_endereco->detalhe()) {
                 $registro['id_cep'] = $obj_endereco_det['cep'];
                 $registro['cidade'] = $obj_endereco_det['cidade'];
                 $registro['nm_bairro'] = $obj_endereco_det['bairro'];
                 $registro['nm_logradouro'] = $obj_endereco_det['logradouro'];
                 $registro['numero'] = $obj_endereco_det['numero'];
                 $registro['letra'] = $obj_endereco_det['letra'];
                 $registro['complemento'] = $obj_endereco_det['complemento'];
                 $registro['andar'] = $obj_endereco_det['andar'];
                 $registro['apartamento'] = $obj_endereco_det['apartamento'];
                 $registro['bloco'] = $obj_endereco_det['bloco'];
                 $registro['idtlog'] = $obj_endereco_det['idtlog']->detalhe();
                 $registro['idtlog'] = $registro['idtlog']['descricao'];
                 $det_uf = $obj_endereco_det['sigla_uf']->detalhe();
                 $registro['ref_sigla_uf'] = $det_uf['nome'];
                 $registro['cep_'] = int2CEP($registro['id_cep']);
             }
         }
     }
     // Adiciona a informação de zona de localização junto ao bairro do
     // endereço.
     $zona = App_Model_ZonaLocalizacao::getInstance();
     $registro['nm_bairro'] = sprintf('%s (Zona %s)', $registro['nm_bairro'], $zona->getValue($obj_endereco_det['zona_localizacao']));
     if ($registro['cod_aluno']) {
         $this->addDetalhe(array('Código Aluno', $registro['cod_aluno']));
     }
     if ($registro['nome_aluno']) {
         $this->addDetalhe(array('Nome Aluno', $registro['nome_aluno']));
     }
     if (idFederal2int($registro['cpf'])) {
         $this->addDetalhe(array('CPF', $registro['cpf']));
     }
     if ($registro['data_nasc']) {
         $this->addDetalhe(array('Data de Nascimento', $registro['data_nasc']));
     }
     /**
      * Analfabeto.
      */
     $this->addDetalhe(array('Analfabeto', $registro['analfabeto'] == 0 ? 'Não' : 'Sim'));
     if ($registro['sexo']) {
         $this->addDetalhe(array('Sexo', $registro['sexo']));
     }
     if ($registro['ideciv']) {
         $this->addDetalhe(array('Estado Civil', $registro['ideciv']));
     }
     if ($registro['id_cep']) {
         $this->addDetalhe(array('CEP', $registro['cep_']));
     }
     if ($registro['ref_sigla_uf']) {
         $this->addDetalhe(array('UF', $registro['ref_sigla_uf']));
     }
     if ($registro['cidade']) {
         $this->addDetalhe(array('Cidade', $registro['cidade']));
     }
     if ($registro['nm_bairro']) {
         $this->addDetalhe(array('Bairro', $registro['nm_bairro']));
     }
     if ($registro['nm_logradouro']) {
         $logradouro = '';
         if ($registro['idtlog']) {
             $logradouro .= $registro['idtlog'] . ' ';
         }
         $logradouro .= $registro['nm_logradouro'];
         $this->addDetalhe(array('Logradouro', $logradouro));
     }
     if ($registro['numero']) {
         $this->addDetalhe(array('Número', $registro['numero']));
     }
     if ($registro['letra']) {
         $this->addDetalhe(array('Letra', $registro['letra']));
     }
     if ($registro['complemento']) {
         $this->addDetalhe(array('Complemento', $registro['complemento']));
     }
     if ($registro['bloco']) {
         $this->addDetalhe(array('Bloco', $registro['bloco']));
     }
     if ($registro['andar']) {
         $this->addDetalhe(array('Andar', $registro['andar']));
     }
     if ($registro['apartamento']) {
         $this->addDetalhe(array('Apartamento', $registro['apartamento']));
     }
     if ($registro['naturalidade']) {
         $this->addDetalhe(array('Naturalidade', $registro['naturalidade']));
     }
     if ($registro['nacionalidade']) {
         $lista_nacionalidade = array('NULL' => 'Selecione', 1 => 'Brasileiro', 2 => 'Naturalizado Brasileiro', 3 => 'Estrangeiro');
         $registro['nacionalidade'] = $lista_nacionalidade[$registro['nacionalidade']];
         $this->addDetalhe(array('Nacionalidade', $registro['nacionalidade']));
     }
     if ($registro['pais_origem']) {
         $this->addDetalhe(array('País de Origem', $registro['pais_origem']));
     }
     $responsavel = $tmp_obj->getResponsavelAluno();
     if ($responsavel) {
         $this->addDetalhe(array('Responsável Aluno', $responsavel['nome_responsavel']));
     }
     if ($registro['ref_idpes_responsavel']) {
         $obj_pessoa_resp = new clsPessoaFj($registro['ref_idpes_responsavel']);
         $det_pessoa_resp = $obj_pessoa_resp->detalhe();
         if ($det_pessoa_resp) {
             $registro['ref_idpes_responsavel'] = $det_pessoa_resp['nome'];
         }
         $this->addDetalhe(array('Responsável', $registro['ref_idpes_responsavel']));
     }
     if ($registro['nm_pai']) {
         $this->addDetalhe(array('Pai', $registro['nm_pai']));
     }
     if ($registro["nm_mae"]) {
         $this->addDetalhe(array('Mãe', $registro['nm_mae']));
     }
     if ($registro['fone_1']) {
         if ($registro['ddd_fone_1']) {
             $registro['ddd_fone_1'] = sprintf('(%s)&nbsp;', $registro['ddd_fone_1']);
         }
         $this->addDetalhe(array('Telefone 1', $registro['ddd_fone_1'] . $registro['fone_1']));
     }
     if ($registro['fone_2']) {
         if ($registro['ddd_fone_2']) {
             $registro['ddd_fone_2'] = sprintf('(%s)&nbsp;', $registro['ddd_fone_2']);
         }
         $this->addDetalhe(array('Telefone 2', $registro['ddd_fone_2'] . $registro['fone_2']));
     }
     if ($registro['fone_mov']) {
         if ($registro['ddd_mov']) {
             $registro['ddd_mov'] = sprintf('(%s)&nbsp;', $registro['ddd_mov']);
         }
         $this->addDetalhe(array('Celular', $registro['ddd_mov'] . $registro['fone_mov']));
     }
     if ($registro['fone_fax']) {
         if ($registro['ddd_fax']) {
             $registro['ddd_fax'] = sprintf('(%s)&nbsp;', $registro['ddd_fax']);
         }
         $this->addDetalhe(array('Fax', $registro['ddd_fax'] . $registro['fone_fax']));
     }
     if ($registro['email']) {
         $this->addDetalhe(array('E-mail', $registro['email']));
     }
     if ($registro['url']) {
         $this->addDetalhe(array('Página Pessoal', $registro['url']));
     }
     if ($registro['ref_cod_aluno_beneficio']) {
         $obj_beneficio = new clsPmieducarAlunoBeneficio($registro['ref_cod_aluno_beneficio']);
         $obj_beneficio_det = $obj_beneficio->detalhe();
         $this->addDetalhe(array('Benefício', $obj_beneficio_det['nm_beneficio']));
     }
     if ($registro['ref_cod_religiao']) {
         $obj_religiao = new clsPmieducarReligiao($registro['ref_cod_religiao']);
         $obj_religiao_det = $obj_religiao->detalhe();
         $this->addDetalhe(array('Religião', $obj_religiao_det['nm_religiao']));
     }
     if ($det_raca['nm_raca']) {
         $this->addDetalhe(array('Raça', $det_raca['nm_raca']));
     }
     if ($deficiencia_pessoa) {
         $tabela = '<table border="0" width="300" cellpadding="3"><tr bgcolor="#A1B3BD" align="center"><td>Deficiências</td></tr>';
         $cor = '#D1DADF';
         foreach ($deficiencia_pessoa as $indice => $valor) {
             $cor = $cor == '#D1DADF' ? '#E4E9ED' : '#D1DADF';
             $tabela .= sprintf('<tr bgcolor="%s" align="center"><td>%s</td></tr>', $cor, $valor);
         }
         $tabela .= '</table>';
         $this->addDetalhe(array('Deficiências', $tabela));
     }
     if ($registro['rg']) {
         $this->addDetalhe(array('RG', $registro['rg']));
     }
     if ($registro['data_exp_rg']) {
         $this->addDetalhe(array('Data de Expedição RG', $registro['data_exp_rg']));
     }
     if ($registro['idorg_exp_rg']) {
         $this->addDetalhe(array('Órgão Expedição RG', $registro['idorg_exp_rg']));
     }
     if ($registro['sigla_uf_exp_rg']) {
         $this->addDetalhe(array('Estado Expedidor', $registro['sigla_uf_exp_rg']));
     }
     /**
      * @todo CoreExt_Enum?
      */
     if ($registro['tipo_cert_civil']) {
         $lista_tipo_cert_civil = array();
         $lista_tipo_cert_civil["0"] = 'Selecione';
         $lista_tipo_cert_civil[91] = 'Nascimento';
         $lista_tipo_cert_civil[92] = 'Casamento';
         $this->addDetalhe(array('Tipo Certificado Civil', $registro['tipo_cert_civil']));
     }
     if ($registro['num_termo']) {
         $this->addDetalhe(array('Termo', $registro['num_termo']));
     }
     if ($registro['num_livro']) {
         $this->addDetalhe(array('Livro', $registro['num_livro']));
     }
     if ($registro['num_folha']) {
         $this->addDetalhe(array('Folha', $registro['num_folha']));
     }
     if ($registro['data_emissao_cert_civil']) {
         $this->addDetalhe(array('Emissão Certidão Civil', $registro['data_emissao_cert_civil']));
     }
     if ($registro['sigla_uf_cert_civil']) {
         $this->addDetalhe(array('Sigla Certidão Civil', $registro['sigla_uf_cert_civil']));
     }
     if ($registro['cartorio_cert_civil']) {
         $this->addDetalhe(array('Cartório', $registro['cartorio_cert_civil']));
     }
     if ($registro['num_tit_eleitor']) {
         $this->addDetalhe(array('Título de Eleitor', $registro['num_tit_eleitor']));
     }
     if ($registro['zona_tit_eleitor']) {
         $this->addDetalhe(array('Zona', $registro['zona_tit_eleitor']));
     }
     if ($registro['secao_tit_eleitor']) {
         $this->addDetalhe(array('Seção', $registro['secao_tit_eleitor']));
     }
     if ($registro['caminho_foto']) {
         $this->addDetalhe(array('Foto', sprintf('<img src="arquivos/educar/aluno/small/%s" border="0">', $registro['caminho_foto'])));
     }
     // Transporte escolar.
     $transporteMapper = new Transporte_Model_AlunoDataMapper();
     $transporteAluno = NULL;
     try {
         $transporteAluno = $transporteMapper->find(array('aluno' => $this->cod_aluno));
     } catch (Exception $e) {
     }
     $this->addDetalhe(array('Transporte escolar', isset($transporteAluno) ? 'Sim' : 'Não'));
     if ($transporteAluno) {
         $this->addDetalhe(array('Responsável transporte', $transporteAluno->responsavel));
     }
     // Adiciona uma aba com dados do Inep/Educacenso caso aluno tenha código Inep.
     if (isset($this->cod_aluno)) {
         $alunoMapper = new Educacenso_Model_AlunoDataMapper();
         $alunoInep = NULL;
         try {
             $alunoInep = $alunoMapper->find(array('aluno' => $this->cod_aluno));
         } catch (Exception $e) {
         }
         if ($alunoInep) {
             $this->addDetalhe(array('Código do aluno no Educacenso/Inep', $alunoInep->alunoInep));
             if (isset($alunoInep->nomeInep)) {
                 $this->addDetalhe(array('Nome do aluno no Educacenso/Inep', $alunoInep->nomeInep));
             }
         }
     }
     $this->addDetalhe(array('Matrícula', $this->montaTabelaMatricula()));
     // Verificação de permissão para cadastro.
     $obj_permissao = new clsPermissoes();
     if ($obj_permissao->permissao_cadastra(578, $this->pessoa_logada, 7)) {
         $this->url_novo = 'educar_aluno_cad.php';
         $this->url_editar = 'educar_aluno_cad.php?cod_aluno=' . $registro['cod_aluno'];
         $this->array_botao = array('Matrícula', 'Atualizar Histórico', 'Ficha do Aluno');
         $this->array_botao_url_script = array(sprintf('go("educar_matricula_lst.php?ref_cod_aluno=%d");', $registro['cod_aluno']), sprintf('go("educar_historico_escolar_lst.php?ref_cod_aluno=%d");', $registro['cod_aluno']), sprintf('showExpansivelImprimir(400, 200, "educar_relatorio_aluno_dados.php?ref_cod_aluno=%d", [], "Relatório i-Educar")', $registro['cod_aluno']));
     }
     $this->url_cancelar = 'educar_aluno_lst.php';
     $this->largura = '100%';
 }
 function Gerar()
 {
     @session_start();
     $id_pessoa = $_SESSION['id_pessoa'];
     $this->nome = "form1";
     $show = $_REQUEST['show'];
     $this->campoOculto("show", $show);
     if ($show == "todos") {
         $show = false;
     } else {
         $show = 1;
     }
     $this->chave_campo = $_GET['chave_campo'];
     if ($_GET["campos"]) {
         $parametros = new clsParametrosPesquisas();
         $parametros->deserializaCampos($_GET["campos"]);
         $_SESSION['campos'] = $parametros->geraArrayComAtributos();
         unset($_GET["campos"]);
     } else {
         $parametros = new clsParametrosPesquisas();
         $parametros->preencheAtributosComArray($_SESSION['campos']);
     }
     @session_write_close();
     $submit = false;
     foreach ($_GET as $key => $value) {
         $this->{$key} = $value;
     }
     if ($parametros->getPessoa() == 'F') {
         $this->addCabecalhos(array("CPF", "Nome"));
         // Filtros de Busca
         $this->campoTexto("campo_busca", "Pessoa", $this->campo_busca, 50, 255, false, false, false, "Código/Nome");
         $this->campoCpf("cpf", "CPF", $this->cpf ? int2CPF(idFederal2int($this->cpf)) : "");
         $chave_busca = @$_GET['campo_busca'];
         $cpf = @$_GET['cpf'];
         $busca = @$_GET['busca'];
         // Paginador
         $limite = 10;
         $iniciolimit = $_GET["pagina_{$this->nome}"] ? $_GET["pagina_{$this->nome}"] * $limite - $limite : 0;
         if (is_numeric($this->chave_campo)) {
             $chave = "[{$this->chave_campo}]";
         } else {
             $chave = "";
         }
         if ($busca == 'S') {
             if ($parametros->getPessoaNovo() == 'S') {
                 if ($parametros->getPessoaTela() == "window") {
                     $this->acao = "set_campo_pesquisa( \"" . $parametros->getPessoaCampo() . "\", \"0\", \"submit\" )";
                     $this->nome_acao = "Novo";
                 } elseif ($parametros->getPessoaTela() == "frame") {
                     $this->acao = "go( \"pesquisa_pessoa_cad.php?pessoa=F&cod=0&ref_cod_sistema=" . $parametros->getCodSistema() . "&pessoa_cpf=" . $parametros->getPessoaCPF() . "\" )";
                     $this->nome_acao = "Novo";
                 }
             }
             if (is_numeric($chave_busca)) {
                 $obj_pessoa = new clsPessoaFisica();
                 $lst_pessoa = $obj_pessoa->lista(null, $cpf ? idFederal2int($cpf) : null, $iniciolimit, $limite, false, $parametros->getCodSistema(), $chave_busca);
             } else {
                 $obj_pessoa = new clsPessoaFisica();
                 $lst_pessoa = $obj_pessoa->lista($chave_busca, $cpf ? idFederal2int($cpf) : null, $iniciolimit, $limite, false, $parametros->getCodSistema());
             }
         } else {
             $obj_pessoa = new clsPessoaFisica();
             $lst_pessoa = $obj_pessoa->lista(null, null, $iniciolimit, $limite, false, $parametros->getCodSistema());
         }
         if ($lst_pessoa) {
             foreach ($lst_pessoa as $pessoa) {
                 $funcao = " set_campo_pesquisa(";
                 $virgula = "";
                 $cont = 0;
                 $pessoa["cpf"] = is_numeric($pessoa["cpf"]) ? int2CPF($pessoa["cpf"]) : null;
                 foreach ($parametros->getCampoNome() as $campo) {
                     if ($parametros->getCampoTipo($cont) == "text") {
                         $funcao .= "{$virgula} '{$campo}{$chave}', '{$pessoa[$parametros->getCampoValor($cont)]}'";
                         $virgula = ",";
                     } elseif ($parametros->getCampoTipo($cont) == "select") {
                         $funcao .= "{$virgula} '{$campo}{$chave}', '{$pessoa[$parametros->getCampoIndice($cont)]}', '{$pessoa[$parametros->getCampoValor($cont)]}'";
                         $virgula = ",";
                     }
                     $cont++;
                 }
                 if ($parametros->getSubmit()) {
                     $funcao .= "{$virgula} 'submit' )";
                 } else {
                     $funcao .= " )";
                 }
                 if ($parametros->getPessoaEditar() == "S") {
                     if ($parametros->getPessoaTela() == "frame") {
                         $this->addLinhas(array("<a href='pesquisa_pessoa_cad.php?pessoa=F&cod={$pessoa["idpes"]}&ref_cod_sistema=" . $parametros->getCodSistema() . "'>{$pessoa["cpf"]}</a>", "<a href='pesquisa_pessoa_cad.php?pessoa=F&cod={$pessoa["idpes"]}&ref_cod_sistema=" . $parametros->getCodSistema() . "'>{$pessoa["nome"]}</a>"));
                     } else {
                         $this->addLinhas(array("<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$pessoa["cpf"]}</a>", "<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$pessoa["nome"]}</a>"));
                     }
                 } else {
                     $this->addLinhas(array("<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$pessoa["cpf"]}</a>", "<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$pessoa["nome"]}</a>"));
                 }
                 $total = $pessoa['total'];
             }
         } else {
             $this->addLinhas(array("Não existe nenhum resultado a ser apresentado."));
         }
     } elseif ($parametros->getPessoa() == 'J') {
         $this->addCabecalhos(array("CNPJ", "Nome"));
         // Filtros de Busca
         $this->campoTexto("campo_busca", "Pessoa", $this->campo_busca, 50, 255, false, false, false, "Código/Nome");
         if ($this->cnpj) {
             if (is_numeric($this->cnpj)) {
                 $this->cnpj = int2CNPJ($this->cnpj);
             }
         } else {
             $this->cnpj = "";
         }
         $this->campoCnpj("cnpj", "CNPJ", $this->cnpj);
         $chave_busca = @$_GET['campo_busca'];
         $cnpj = @$_GET['cnpj'];
         $busca = @$_GET['busca'];
         // Paginador
         $limite = 10;
         $iniciolimit = $_GET["pagina_{$this->nome}"] ? $_GET["pagina_{$this->nome}"] * $limite - $limite : 0;
         if ($busca == 'S') {
             if ($parametros->getPessoaNovo() == 'S') {
                 if ($parametros->getPessoaTela() == "window") {
                     $this->acao = "set_campo_pesquisa( \"" . $parametros->getPessoaCampo() . "\", \"0\", \"submit\" )";
                     $this->nome_acao = "Novo";
                 } elseif ($parametros->getPessoaTela() == "frame") {
                     $this->acao = "go( \"pesquisa_pessoa_cad.php?pessoa=J&cod=0\" )";
                     $this->nome_acao = "Novo";
                 }
             }
             if (is_numeric($chave_busca)) {
                 $obj_pessoa = new clsPessoaJuridica();
                 $lst_pessoa = $obj_pessoa->lista($cnpj ? idFederal2int($cnpj) : null, false, false, $iniciolimit, $limite, false, false, false, $chave_busca);
             } else {
                 $obj_pessoa = new clsPessoaJuridica();
                 $lst_pessoa = $obj_pessoa->lista($cnpj ? idFederal2int($cnpj) : null, $chave_busca, false, $iniciolimit, $limite);
             }
         } else {
             $obj_pessoa = new clsPessoaJuridica();
             $lst_pessoa = $obj_pessoa->lista(null, null, null, $iniciolimit, $limite);
         }
         if ($lst_pessoa) {
             foreach ($lst_pessoa as $pessoa) {
                 $funcao = " set_campo_pesquisa(";
                 $virgula = "";
                 $cont = 0;
                 $pessoa["cnpj"] = is_numeric($pessoa["cnpj"]) ? int2CNPJ($pessoa["cnpj"]) : null;
                 foreach ($parametros->getCampoNome() as $campo) {
                     if ($parametros->getCampoTipo($cont) == "text") {
                         $funcao .= "{$virgula} '{$campo}', '{$pessoa[$parametros->getCampoValor($cont)]}'";
                         $virgula = ",";
                     } elseif ($parametros->getCampoTipo($cont) == "select") {
                         $funcao .= "{$virgula} '{$campo}', '{$pessoa[$parametros->getCampoIndice($cont)]}', '{$pessoa[$parametros->getCampoValor($cont)]}'";
                         $virgula = ",";
                     }
                     $cont++;
                 }
                 if ($parametros->getSubmit()) {
                     $funcao .= "{$virgula} 'submit' )";
                 } else {
                     $funcao .= " )";
                 }
                 if ($campos["edita"]["permitir"] == "S") {
                     if ($parametros->getPessoaTela() == "frame") {
                         $this->addLinhas(array("<a href='pesquisa_pessoa_cad.php?pessoa=J&cod={$pessoa["idpes"]}'>{$pessoa["cnpj"]}</a>", "<a href='pesquisa_pessoa_cad.php?pessoa=J&cod={$pessoa["idpes"]}'>{$pessoa["nome"]}</a>"));
                     } else {
                         $this->addLinhas(array("<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$pessoa["cnpj"]}</a>", "<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$pessoa["nome"]}</a>"));
                     }
                 } else {
                     $this->addLinhas(array("<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$pessoa["cnpj"]}</a>", "<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$pessoa["nome"]}</a>"));
                 }
                 $total = $pessoa['total'];
             }
         } else {
             $this->addLinhas(array("Não existe nenhum resultado a ser apresentado."));
         }
     } elseif ($parametros->getPessoa() == 'FJ') {
         $this->addCabecalhos(array("CNPJ/CPF", "Nome"));
         // Filtros de Busca
         $this->campoTexto("campo_busca", "Pessoa", $this->campo_busca, 50, 255, false, false, false, "Código/Nome");
         $this->campoIdFederal("id_federal", "CNPJ/CPF", $this->id_federal ? int2IdFederal($this->id_federal) : "");
         $chave_busca = @$_GET['campo_busca'];
         $id_federal = @$_GET['id_federal'];
         $busca = @$_GET['busca'];
         // Paginador
         $limite = 10;
         $iniciolimit = $_GET["pagina_{$this->nome}"] ? $_GET["pagina_{$this->nome}"] * $limite - $limite : 0;
         if ($busca == 'S') {
             if ($parametros->getPessoaNovo() == 'S') {
                 if ($parametros->getPessoaTela() == "window") {
                     $this->acao = "set_campo_pesquisa( \"" . $parametros->getPessoaCampo() . "\", \"0\", \"submit\" )";
                     $this->nome_acao = "Novo";
                 } elseif ($parametros->getPessoaTela() == "frame") {
                     $this->acao = "go( \"pesquisa_pessoa_cad.php?pessoa=FJ&cod=0&ref_cod_sistema=" . $parametros->getCodSistema() . "&pessoa_cpf=" . $parametros->getPessoaCPF() . "\" )";
                     $this->nome_acao = "Novo";
                 }
             }
             if (is_numeric($chave_busca)) {
                 $obj_pessoa = new clsPessoaFj();
                 $lst_pessoa = $obj_pessoa->lista_rapida($chave_busca, null, idFederal2int($id_federal), $iniciolimit, $limite, null, "nome ASC", $parametros->getCodSistema());
             } else {
                 $obj_pessoa = new clsPessoaFj();
                 $lst_pessoa = $obj_pessoa->lista_rapida(null, $chave_busca, idFederal2int($id_federal), $iniciolimit, $limite, null, "nome ASC", $parametros->getCodSistema());
             }
         } else {
             $obj_pessoa = new clsPessoaFj();
             $lst_pessoa = $obj_pessoa->lista_rapida(null, null, null, $iniciolimit, $limite, null, "nome ASC", $parametros->getCodSistema());
         }
         if ($lst_pessoa) {
             foreach ($lst_pessoa as $pessoa) {
                 $funcao = " set_campo_pesquisa(";
                 $virgula = "";
                 $cont = 0;
                 foreach ($parametros->getCampoNome() as $campo) {
                     if ($parametros->getCampoTipo($cont) == "text") {
                         $funcao .= "{$virgula} '{$campo}', '{$pessoa[$parametros->getCampoValor($cont)]}'";
                         $virgula = ",";
                     } elseif ($parametros->getCampoTipo($cont) == "select") {
                         $funcao .= "{$virgula} '{$campo}', '{$pessoa[$parametros->getCampoIndice($cont)]}', '{$pessoa[$parametros->getCampoValor($cont)]}'";
                         $virgula = ",";
                     }
                     $cont++;
                 }
                 if ($parametros->getSubmit()) {
                     $funcao .= "{$virgula} 'submit' )";
                 } else {
                     $funcao .= " )";
                 }
                 $pessoa['cnpj'] = $pessoa['tipo'] == 'J' && $pessoa['cnpj'] ? int2CNPJ($pessoa['cnpj']) : null;
                 $pessoa['cpf'] = $pessoa['tipo'] == 'F' && $pessoa['cpf'] ? int2CPF($pessoa['cpf']) : null;
                 $obj_pes = new clsPessoa_($pessoa["idpes"]);
                 $det_pes = $obj_pes->detalhe();
                 if ($parametros->getPessoaEditar() == "S") {
                     if ($parametros->getPessoaTela() == "frame") {
                         if ($det_pes["tipo"] == "J") {
                             $this->addLinhas(array("<a href='pesquisa_pessoa_cad.php?pessoa={$det_pes["tipo"]}&cod={$pessoa["idpes"]}'>{$pessoa["cnpj"]}</a>", "<a href='pesquisa_pessoa_cad.php?pessoa={$det_pes["tipo"]}&cod={$pessoa["idpes"]}'>{$pessoa["nome"]}</a>"));
                         } elseif ($det_pes["tipo"] == "F") {
                             $this->addLinhas(array("<a href='pesquisa_pessoa_cad.php?pessoa={$det_pes["tipo"]}&cod={$pessoa["idpes"]}&ref_cod_sistema=" . $parametros->getCodSistema() . "'>{$pessoa["cpf"]}</a>", "<a href='pesquisa_pessoa_cad.php?pessoa={$det_pes["tipo"]}&cod={$pessoa["idpes"]}&ref_cod_sistema=" . $parametros->getCodSistema() . "'>{$pessoa["nome"]}</a>"));
                         }
                     } else {
                         if ($det_pes["tipo"] == "J") {
                             $this->addLinhas(array("<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$pessoa["cnpj"]}</a>", "<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$pessoa["nome"]}</a>"));
                         } else {
                             $this->addLinhas(array("<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$pessoa["cpf"]}</a>", "<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$pessoa["nome"]}</a>"));
                         }
                     }
                 } else {
                     if ($det_pes["tipo"] == "J") {
                         $this->addLinhas(array("<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$pessoa["cnpj"]}</a>", "<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$pessoa["nome"]}</a>"));
                     } else {
                         $this->addLinhas(array("<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$pessoa["cpf"]}</a>", "<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$pessoa["nome"]}</a>"));
                     }
                 }
                 $total = $pessoa['_total'];
             }
         } else {
             $this->addLinhas(array("Não existe nenhum resultado a ser apresentado."));
         }
     } else {
         if ($parametros->getPessoa() == 'FUNC') {
             $this->addCabecalhos(array("Matricula", "Nome"));
             // Filtros de Busca
             $this->campoTexto("campo_busca", "Pessoa", $this->campo_busca, 50, 255, false, false, false, "Código/Nome");
             $this->campoNumero("matricula", "Matricula", $this->matricula, 15, 255);
             //			$this->campoCpf( "cpf", "CPF", int2CPF($this->cpf) );
             $chave_busca = @$_GET['campo_busca'];
             $cpf = @$_GET['cpf'];
             $busca = @$_GET['busca'];
             // Paginador
             $limite = 10;
             $iniciolimit = $_GET["pagina_{$this->nome}"] ? $_GET["pagina_{$this->nome}"] * $limite - $limite : 0;
             if ($busca == 'S') {
                 if ($parametros->getPessoaNovo() == 'S') {
                     if ($parametros->getPessoaTela() == "window") {
                         $this->acao = "set_campo_pesquisa( \"" . $parametros->getPessoaCampo() . "\", \"0\", \"submit\" )";
                         $this->nome_acao = "Novo";
                     } elseif ($parametros->getPessoaTela() == "frame") {
                         $this->acao = "go( \"pesquisa_pessoa_cad.php?pessoa=F&cod=0&ref_cod_sistema=" . $parametros->getCodSistema() . "&pessoa_cpf=" . $parametros->getPessoaCPF() . "\" )";
                         $this->nome_acao = "Novo";
                     }
                 }
                 if (is_numeric($chave_busca)) {
                     $obj_funcionario = new clsFuncionario();
                     $lst_pessoa = $obj_funcionario->lista($this->matricula, false, $show, false, false, false, false, $iniciolimit, $limite, false, false, $this->campo_busca);
                     //					$obj_pessoa = new clsPessoaFisica();
                     //					$lst_pessoa = $obj_pessoa->lista( null, ( ( $cpf ) ? idFederal2int( $cpf ) : null ), $iniciolimit, $limite, false, $parametros->getCodSistema(), $chave_busca );
                 } else {
                     $obj_funcionario = new clsFuncionario();
                     $lst_pessoa = $obj_funcionario->lista($this->matricula, $this->campo_busca, $show, false, false, false, false, $iniciolimit, $limite);
                     //					$obj_pessoa = new clsPessoaFisica();
                     //					$lst_pessoa = $obj_pessoa->lista( $chave_busca, ( ( $cpf ) ? idFederal2int( $cpf ) : null ), $iniciolimit, $limite, false, $parametros->getCodSistema() );
                 }
             } else {
                 $obj_funcionario = new clsFuncionario();
                 $lst_pessoa = $obj_funcionario->lista(false, false, $show, false, false, false, false, $iniciolimit, $limite);
                 //				$obj_pessoa = new clsPessoaFisica();
                 //				$lst_pessoa = $obj_pessoa->lista( null, null, $iniciolimit, $limite, false, $parametros->getCodSistema() );
             }
             if ($lst_pessoa) {
                 foreach ($lst_pessoa as $pessoa) {
                     $funcao = " set_campo_pesquisa(";
                     $virgula = "";
                     $cont = 0;
                     $pessoa["cpf"] = is_numeric($pessoa["cpf"]) ? int2CPF($pessoa["cpf"]) : null;
                     foreach ($parametros->getCampoNome() as $campo) {
                         if ($parametros->getCampoTipo($cont) == "text") {
                             $funcao .= "{$virgula} '{$campo}', '{$pessoa[$parametros->getCampoValor($cont)]}'";
                             $virgula = ",";
                         } elseif ($parametros->getCampoTipo($cont) == "select") {
                             $funcao .= "{$virgula} '{$campo}', '{$pessoa[$parametros->getCampoIndice($cont)]}', '{$pessoa[$parametros->getCampoValor($cont)]}'";
                             $virgula = ",";
                         }
                         $cont++;
                     }
                     if ($parametros->getSubmit()) {
                         $funcao .= "{$virgula} 'submit' )";
                     } else {
                         $funcao .= " )";
                     }
                     if ($parametros->getPessoaEditar() == "S") {
                         if ($parametros->getPessoaTela() == "frame") {
                             $this->addLinhas(array("<a href='pesquisa_pessoa_cad.php?pessoa=F&cod={$pessoa["idpes"]}'>{$pessoa["matricula"]}</a>", "<a href='pesquisa_pessoa_cad.php?pessoa=F&cod={$pessoa["idpes"]}&ref_cod_sistema=" . $parametros->getCodSistema() . "'>{$pessoa["nome"]}</a>"));
                         } else {
                             $this->addLinhas(array("<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$pessoa["matricula"]}</a>", "<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$pessoa["nome"]}</a>"));
                         }
                     } else {
                         $this->addLinhas(array("<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$pessoa["matricula"]}</a>", "<a href='javascript:void( 0 );' onclick=\"javascript:{$funcao}\">{$pessoa["nome"]}</a>"));
                     }
                     $total = $pessoa['_total'];
                 }
             } else {
                 $this->addLinhas(array("Não existe nenhum resultado a ser apresentado."));
             }
         }
     }
     // Paginador
     $this->addPaginador2("pesquisa_pessoa_lst.php", $total, $_GET, $this->nome, $limite);
     // Define Largura da Página
     $this->largura = "100%";
 }
 function Editar()
 {
     @session_start();
     $pessoaFj = $_SESSION['id_pessoa'];
     $parametros = new clsParametrosPesquisas();
     if ($this->cep_) {
         $this->cep = idFederal2int($this->cep_);
     }
     if ($_SESSION["campos"]) {
         $parametros->preencheAtributosComArray($_SESSION['campos']);
     }
     session_write_close();
     if ($_POST["pessoa"] == "F") {
         if ($this->id_federal) {
             $this->id_federal = idFederal2int($this->id_federal);
             $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);
             $detCPF = $objCPF->detalhe();
             if ($detCPF) {
                 if ($detCPF["idpes"] != $this->cod_pessoa_fj) {
                     $this->mensagem = "CPF j&aacute; cadastrado.";
                     $this->id_federal = false;
                     return false;
                 }
             }
         }
         $this->data_nasc = dataToBanco($this->data_nasc);
         $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);
         $objPessoa->edita();
         if ($this->id_federal) {
             $this->id_federal = idFederal2Int($this->id_federal);
             $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, "NULL", $this->id_federal);
             $objFisica->edita();
         } else {
             $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, $this->ref_cod_sistema, $this->id_federal);
             $objFisica->edita();
         }
         $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 1, $this->telefone_1, $this->ddd_telefone_1);
         if ($objTelefone->detalhe()) {
             $objTelefone->edita();
         } else {
             $objTelefone->cadastra();
         }
         $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 2, $this->telefone_2, $this->ddd_telefone_2);
         if ($objTelefone->detalhe()) {
             $objTelefone->edita();
         } else {
             $objTelefone->cadastra();
         }
         $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 3, $this->telefone_mov, $this->ddd_telefone_mov);
         if ($objTelefone->detalhe()) {
             $objTelefone->edita();
         } else {
             $objTelefone->cadastra();
         }
         $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 4, $this->telefone_fax, $this->ddd_telefone_fax);
         if ($objTelefone->detalhe()) {
             $objTelefone->edita();
         } else {
             $objTelefone->cadastra();
         }
         $objEndereco = new clsPessoaEndereco($this->cod_pessoa_fj);
         $detEndereco = $objEndereco->detalhe();
         $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);
         if ($detEndereco && $this->cep && $this->idlog && $this->idbai) {
             $objEndereco2->edita();
         } elseif ($this->cep && $this->idlog && $this->idbai) {
             $objEndereco2->cadastra();
             $objEnderecoExterno = new clsEnderecoExterno($this->cod_pessoa_fj);
             if ($objEnderecoExterno->detalhe()) {
                 $objEnderecoExterno->exclui();
             }
         } elseif ($detEndereco) {
             $objEndereco2->exclui();
             $this->cep = $this->cep;
             $objEnderecoExterno = new clsEnderecoExterno($this->cod_pessoa_fj);
             $detEnderecoExterno = $objEnderecoExterno->detalhe();
             $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);
             if ($detEnderecoExterno) {
                 $objEnderecoExterno2->edita();
                 if ($detEndereco) {
                     $objEndereco->exclui();
                 }
             } else {
                 $objEnderecoExterno2->cadastra();
                 if ($detEndereco) {
                     $objEndereco->exclui();
                 }
             }
         } else {
             $this->cep = idFederal2int($this->cep);
             $objEnderecoExterno = new clsEnderecoExterno($this->cod_pessoa_fj);
             $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);
             if ($objEnderecoExterno->detalhe()) {
                 $objEnderecoExterno2->edita();
             } else {
                 $objEnderecoExterno2->cadastra();
                 if ($detEndereco) {
                     $objEndereco->exclui();
                 }
             }
         }
         if (is_numeric($this->cod_pessoa_fj)) {
             $obj_pessoa = new clsPessoaFj($this->cod_pessoa_fj);
             $pessoa = $obj_pessoa->lista_rapida($this->cod_pessoa_fj);
             $pessoa = $pessoa[0];
             $funcao = " set_campo_pesquisa(";
             $virgula = "";
             $cont = 0;
             foreach ($parametros->getCampoNome() as $campo) {
                 if ($parametros->getCampoTipo($cont) == "text") {
                     $funcao .= "{$virgula} '{$campo}', '{$pessoa[$parametros->getCampoValor($cont)]}'";
                     $virgula = ",";
                 } elseif ($parametros->getCampoTipo($cont) == "select") {
                     $funcao .= "{$virgula} '{$campo}', '{$pessoa[$parametros->getCampoIndice($cont)]}', '{$pessoa[$parametros->getCampoValor($cont)]}'";
                     $virgula = ",";
                 }
                 $cont++;
             }
             if ($parametros->getSubmit()) {
                 $funcao .= "{$virgula} 'submit' )";
             } else {
                 $funcao .= " )";
             }
             $this->executa_script = $funcao;
             /**
              * alteracao para executar script
              * em tabela dinamica
              * procon
              */
             if ($_GET['tab_dinamica'] == 'procon') {
                 $script = "function passaPraTraz(nome, id)\n\t\t\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\t\t\t// reclamada\n\t\t\t\t\t\t\t\t\twindow.parent.document.getElementById('reclamada[{$_GET['tab_dinamica_id']}]').value = nome;\n\t\t\t\t\t\t\t\t\twindow.parent.document.getElementById('reclamada_id[{$_GET['tab_dinamica_id']}]').value = id;\n\n\t\t\t\t\t\t\t\t\twindow.parent.fechaExpansivel('div_dinamico_'+(parent.DOM_divs.length*1-1));\n\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tpassaPraTraz('{$pessoa['nome']}',{$this->cod_pessoa_fj});";
                 $this->executa_script = $script;
             }
             return true;
         }
     } elseif ($_POST["pessoa"] == "J") {
         if ($this->id_federal) {
             $this->id_federal = idFederal2int($this->id_federal);
             $objCNPJ = new clsJuridica(false, $this->id_federal);
             $detCNPJ = $objCNPJ->detalhe();
             if ($detCNPJ) {
                 if ($detCNPJ["idpes"] != $this->cod_pessoa_fj) {
                     $this->mensagem = "CNPJ j&aacute; cadastrado.";
                     $this->id_federal = false;
                     return false;
                 }
             }
         }
         $this->id_federal = idFederal2int($this->id_federal);
         $this->insc_est = idFederal2int($this->insc_est);
         $objPessoa = new clsPessoa_($this->cod_pessoa_fj, $this->razao_social, $this->idpes_cad, $this->url, "J", false, false, $this->email);
         $objPessoa->edita();
         $objJuridica = new clsJuridica($this->cod_pessoa_fj, $this->id_federal, $this->fantasia, $this->insc_est, $this->capital_social);
         $objJuridica->edita();
         $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 1, $this->telefone_1, $this->ddd_telefone_1);
         if ($objTelefone->detalhe()) {
             $objTelefone->edita();
         } else {
             $objTelefone->cadastra();
         }
         $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 2, $this->telefone_2, $this->ddd_telefone_2);
         if ($objTelefone->detalhe()) {
             $objTelefone->edita();
         } else {
             $objTelefone->cadastra();
         }
         $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 3, $this->telefone_mov, $this->ddd_telefone_mov);
         if ($objTelefone->detalhe()) {
             $objTelefone->edita();
         } else {
             $objTelefone->cadastra();
         }
         $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 4, $this->telefone_fax, $this->ddd_telefone_fax);
         if ($objTelefone->detalhe()) {
             $objTelefone->edita();
         } else {
             $objTelefone->cadastra();
         }
         $objEndereco = new clsPessoaEndereco($this->cod_pessoa_fj);
         $detEndereco = $objEndereco->detalhe();
         $this->cep = $this->cep;
         $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);
         if ($detEndereco && $this->cep && $this->idlog && $this->idbai) {
             $objEndereco2->edita();
         } elseif ($this->cep && $this->idlog && $this->idbai) {
             $objEndereco2->cadastra();
         } elseif ($detEndereco) {
             $objEndereco2->exclui();
             $this->cep = $this->cep;
             $objEnderecoExterno = new clsEnderecoExterno($this->cod_pessoa_fj);
             $detEnderecoExterno = $objEnderecoExterno->detalhe();
             $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);
             if ($detEnderecoExterno) {
                 $objEnderecoExterno2->edita();
                 if ($detEndereco) {
                     $objEndereco->exclui();
                 }
             } else {
                 $objEnderecoExterno2->cadastra();
                 if ($detEndereco) {
                     $objEndereco->exclui();
                 }
             }
         }
         if (is_numeric($this->cod_pessoa_fj)) {
             $obj_pessoa = new clsPessoaFj($this->cod_pessoa_fj);
             $pessoa = $obj_pessoa->lista_rapida($this->cod_pessoa_fj);
             $pessoa = $pessoa[0];
             $funcao = " set_campo_pesquisa(";
             $virgula = "";
             $cont = 0;
             foreach ($parametros->getCampoNome() as $campo) {
                 if ($parametros->getCampoTipo($cont) == "text") {
                     $funcao .= "{$virgula} '{$campo}', '{$pessoa[$parametros->getCampoValor($cont)]}'";
                     $virgula = ",";
                 } elseif ($parametros->getCampoTipo($cont) == "select") {
                     $funcao .= "{$virgula} '{$campo}', '{$pessoa[$parametros->getCampoIndice($cont)]}', '{$pessoa[$parametros->getCampoValor($cont)]}'";
                     $virgula = ",";
                 }
                 $cont++;
             }
             if ($parametros->getSubmit()) {
                 $funcao .= "{$virgula} 'submit' )";
             } else {
                 $funcao .= " )";
             }
             $this->executa_script = $funcao;
             /**
              * alteracao para executar script
              * em tabela dinamica
              * procon
              */
             if ($_GET['tab_dinamica'] == 'procon') {
                 $script = "function passaPraTraz(nome, id)\n\t\t\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\t\t\t// reclamada\n\t\t\t\t\t\t\t\t\twindow.parent.document.getElementById('reclamada[{$_GET['tab_dinamica_id']}]').value = nome;\n\t\t\t\t\t\t\t\t\twindow.parent.document.getElementById('reclamada_id[{$_GET['tab_dinamica_id']}]').value = id;\n\n\t\t\t\t\t\t\t\t\twindow.parent.fechaExpansivel('div_dinamico_'+(parent.DOM_divs.length*1-1));\n\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tpassaPraTraz('{$pessoa['nome']}',{$this->cod_pessoa_fj});";
                 $this->executa_script = $script;
             }
             return true;
         }
     }
     return false;
 }
 * @since     Arquivo disponível desde a versão 1.0.0
 * @version   $Id$
 */
header('Content-type: text/xml');
require_once 'include/clsBanco.inc.php';
require_once 'include/funcoes.inc.php';
require_once 'include/pmieducar/geral.inc.php';
if ($_GET['cpf'] || $_GET['idpes']) {
    $xml = '<?xml version="1.0" encoding="ISO-8859-15"?>' . PHP_EOL;
    $xml .= '<query xmlns="sugestoes">' . PHP_EOL;
    $xml .= '<dados>' . PHP_EOL;
    $cpf = $_GET['cpf'];
    if ($_GET['idpes']) {
        $ref_idpes = $_GET['idpes'];
    } else {
        $cpf = idFederal2int($_GET['cpf']);
        $obj_pessoa_fisica = new clsPessoaFisica(NULL, $cpf);
        $lst_pessoa_fisica = $obj_pessoa_fisica->lista(NULL, $cpf);
        if (!$lst_pessoa_fisica) {
            echo $xml . '</dados></query>';
            die;
        }
        $ref_idpes = $lst_pessoa_fisica[0]['idpes'];
        $xml .= sprintf('<ref_idpes>%d</ref_idpes>', $ref_idpes) . PHP_EOL;
        $xml .= sprintf('<cpf>%s</cpf>', $cpf) . PHP_EOL;
    }
    if ($cod_aluno) {
        $obj_matricula = new clsPmieducarMatricula();
        $lst_matricula = $obj_matricula->lista(NULL, NULL, NULL, NULL, NULL, NULL, $cod_aluno);
    }
    if (!empty($ref_idpes)) {
 function Editar()
 {
     @session_start();
     $pessoaFj = $_SESSION['id_pessoa'];
     session_write_close();
     $obj = new clsGrupoModerador($this->cod_pessoa_fj, $this->cod_grupo);
     $detalhe = $obj->detalhe();
     if ($detalhe && $detalhe['ativo'] == 1) {
         header("Location: otopic_meus_grupos_det.php?cod_grupo={$this->cod_grupo}");
     }
     $objPessoa = new clsPessoa_($this->cod_pessoa_fj, $this->p_nm_pessoa, false, $this->http, false, $pessoaFj, date("Y-m-d H:i:s", time()), $this->email);
     $objPessoa->edita();
     $objFisica = new clsFisica($this->cod_pessoa_fj, false, $this->sexo);
     $objFisica->edita();
     $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 1, $this->telefone_1, $this->ddd_telefone_1);
     $objTelefone->cadastra();
     $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 2, $this->telefone_2, $this->ddd_telefone_2);
     $objTelefone->cadastra();
     $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 3, $this->telefone_mov, $this->ddd_telefone_mov);
     $objTelefone->cadastra();
     $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 4, $this->telefone_fax, $this->ddd_telefone_fax);
     $objTelefone->cadastra();
     if ($this->cep && $this->idbai && $this->idlog) {
         $objEndereco = new clsPessoaEndereco($this->cod_pessoa_fj);
         $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);
         if ($objEndereco->detalhe()) {
             $objEndereco2->edita();
         } else {
             $objEndereco2->cadastra();
         }
     } else {
         $this->cep_ = idFederal2int($this->cep_);
         $objEnderecoExterno = new clsEnderecoExterno($this->cod_pessoa_fj);
         $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);
         if ($objEnderecoExterno->detalhe()) {
             $objEnderecoExterno2->edita();
         } else {
             $objEnderecoExterno2->cadastra();
         }
     }
     $obj = new clsGrupoPessoa($this->cod_pessoa_fj, $this->cod_grupo);
     if (!$obj->detalhe()) {
         $obj = new clsGrupoPessoa($this->cod_pessoa_fj, $this->cod_grupo, $pessoaFj, false, $this->cod_grupo);
         if ($obj->cadastra()) {
             header("Location: otopic_meus_grupos_det.php?cod_grupo={$this->cod_grupo}");
         }
     } else {
         $obj = new clsGrupoPessoa($this->cod_pessoa_fj, $this->cod_grupo, $pessoaFj, false, $this->cod_grupo, false, 1);
         if ($obj->edita()) {
             header("Location: otopic_meus_grupos_det.php?cod_grupo={$this->cod_grupo}");
         }
     }
     return true;
 }
 function Novo()
 {
     session_start();
     $this->pessoa_logada = $_SESSION['id_pessoa'];
     session_write_close();
     if ($this->passo == 2) {
         return true;
     }
     $obj_reserva_vaga = new clsPmieducarReservaVaga(NULL, $this->ref_cod_escola, $this->ref_cod_serie, NULL, $this->pessoa_logada, $this->ref_cod_aluno, NULL, NULL, 1, $this->nm_aluno_ext, idFederal2int($this->cpf_responsavel));
     $cadastrou = $obj_reserva_vaga->cadastra();
     if ($cadastrou) {
         $this->mensagem .= 'Reserva de Vaga efetuada com sucesso.<br>';
         header('Location: educar_reservada_vaga_det.php?cod_reserva_vaga=' . $cadastrou);
         die;
     }
     $this->mensagem = 'Reserva de Vaga n&atilde;o realizada.<br>';
     return FALSE;
 }
Beispiel #17
0
 function Editar()
 {
     $this->cnpj = idFederal2int($this->cnpj);
     $this->insc_est = idFederal2int($this->insc_est);
     $objPessoa = new clsPessoa_($this->cod_pessoa_fj, $this->razao_social, $this->idpes_cad, $this->url, "J", false, false, $this->email);
     $objPessoa->edita();
     $objJuridica = new clsJuridica($this->cod_pessoa_fj, $this->cnpj, $this->fantasia, $this->insc_est, $this->capital_social);
     $objJuridica->edita();
     if ($this->telefone_1) {
         $this->telefone_1 = str_replace("-", "", $this->telefone_1);
         $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 1, $this->telefone_1, $this->ddd_telefone_1);
         if ($objTelefone->detalhe()) {
             $objTelefone->edita();
         } else {
             $objTelefone->cadastra();
         }
     }
     if ($this->telefone_2) {
         $this->telefone_2 = str_replace("-", "", $this->telefone_2);
         $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 2, $this->telefone_2, $this->ddd_telefone_2);
         if ($objTelefone->detalhe()) {
             $objTelefone->edita();
         } else {
             $objTelefone->cadastra();
         }
     }
     if ($this->telefone_mov) {
         $this->telefone_mov = str_replace("-", "", $this->telefone_mov);
         $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 3, $this->telefone_mov, $this->ddd_telefone_mov);
         if ($objTelefone->detalhe()) {
             $objTelefone->edita();
         } else {
             $objTelefone->cadastra();
         }
     }
     if ($this->telefone_fax) {
         $this->telefone_fax = str_replace("-", "", $this->telefone_fax);
         $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 4, $this->telefone_fax, $this->ddd_telefone_fax);
         if ($objTelefone->detalhe()) {
             $objTelefone->edita();
         } else {
             $objTelefone->cadastra();
         }
     }
     if ($this->cep && $this->idbai && $this->idlog) {
         $this->cep = idFederal2Int($this->cep);
         $objEndereco = new clsPessoaEndereco($this->cod_pessoa_fj);
         $objEndereco2 = new clsPessoaEndereco($this->cod_pessoa_fj, $this->cep, $this->idlog, $this->idbai, $this->numero, $this->complemento, false, $this->letra);
         if ($objEndereco->detalhe()) {
             $objEndereco2->edita();
         } else {
             $objEndereco2->cadastra();
         }
     } else {
         $this->cep_ = idFederal2int($this->cep_);
         $objEnderecoExterno = new clsEnderecoExterno($this->cod_pessoa_fj);
         $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);
         if ($objEnderecoExterno->detalhe()) {
             $objEnderecoExterno2->edita();
         } else {
             $objEnderecoExterno2->cadastra();
         }
     }
     header("Location: empresas_lst.php");
     return true;
 }
 function Editar()
 {
     @session_start();
     $this->pessoa_logada = $_SESSION['id_pessoa'];
     @session_write_close();
     $obj_permissoes = new clsPermissoes();
     $obj_permissoes->permissao_cadastra(561, $this->pessoa_logada, 3, "educar_escola_lst.php");
     //
     //		echo "<br>cep: ".$this->cep;
     //		echo "<br>cep_: ".$this->cep_;die;
     if ($this->cod_escola) {
         $obj = new clsPmieducarEscola($this->cod_escola, null, $this->pessoa_logada, $this->ref_cod_instituicao, $this->ref_cod_escola_localizacao, $this->ref_cod_escola_rede_ensino, $this->ref_idpes, $this->sigla, null, null, 1);
         $editou = $obj->edita();
     } else {
         $obj = new clsPmieducarEscola(null, $this->pessoa_logada, null, $this->ref_cod_instituicao, $this->ref_cod_escola_localizacao, $this->ref_cod_escola_rede_ensino, $this->ref_idpes, $this->sigla, null, null, 1);
         $editou = $obj->cadastra();
         $this->cod_escola = $editou;
     }
     if ($editou) {
         if ($this->com_cnpj) {
             $objPessoa = new clsPessoa_($this->ref_idpes, null, false, $this->p_http, false, $this->pessoa_logada, date("Y-m-d H:i:s", time()), $this->p_email);
             $editou1 = $objPessoa->edita();
             if ($editou1) {
                 $obj_pes_juridica = new clsJuridica($this->ref_idpes, $this->cnpj, $this->fantasia, false, false, false, $this->pessoa_logada);
                 $editou2 = $obj_pes_juridica->edita();
                 if ($editou2) {
                     $objTelefone = new clsPessoaTelefone($this->ref_idpes);
                     $objTelefone->excluiTodos();
                     $objTelefone = new clsPessoaTelefone($this->ref_idpes, 1, str_replace("-", "", $this->p_telefone_1), $this->p_ddd_telefone_1);
                     $objTelefone->cadastra();
                     $objTelefone = new clsPessoaTelefone($this->ref_idpes, 2, str_replace("-", "", $this->p_telefone_2), $this->p_ddd_telefone_2);
                     $objTelefone->cadastra();
                     $objTelefone = new clsPessoaTelefone($this->ref_idpes, 3, str_replace("-", "", $this->p_telefone_mov), $this->p_ddd_telefone_mov);
                     $objTelefone->cadastra();
                     $objTelefone = new clsPessoaTelefone($this->ref_idpes, 4, str_replace("-", "", $this->p_telefone_fax), $this->p_ddd_telefone_fax);
                     $objTelefone->cadastra();
                     $objEndereco = new clsPessoaEndereco($this->ref_idpes);
                     $detEndereco = $objEndereco->detalhe();
                     if ($this->cep) {
                         $this->cep_ = idFederal2int($this->cep);
                     }
                     $this->cep = $this->cep;
                     //echo "$this->ref_idpes, $this->cep_, $this->idlog, $this->idbai, $this->numero, $this->complemento, false, false, false, false, $this->andar ";die;
                     //echo "<pre>";print_r($this);die;
                     /*					$objEndereco2 = new clsPessoaEndereco( $this->ref_idpes, $this->cep_, $this->idlog, $this->idbai, $this->numero, $this->complemento, false, false, false, false, $this->andar );
                     						if ( $detEndereco && $this->cep_ && $this->idlog && $this->idbai )
                     							$objEndereco2->edita();
                     						elseif ( $this->cep_ && $this->idlog && $this->idbai )
                     							$objEndereco2->cadastra();
                     
                     						elseif ( $detEndereco )
                     						{
                     							$objEndereco2->exclui();
                     							//$this->cep = $this->cep;
                     							$objEnderecoExterno = new clsEnderecoExterno( $this->ref_idpes );
                     							$detEnderecoExterno = $objEnderecoExterno->detalhe();
                     
                     							//$this->cep = idFederal2int($this->cep) ;
                     							$objEnderecoExterno2 = new clsEnderecoExterno( $this->ref_idpes, "1", $this->idtlog, $this->logradouro, $this->numero, false, $this->complemento, $this->bairro, $this->cep_, $this->cidade, $this->sigla_uf, false, false, false, $this->andar );
                     							if( $detEnderecoExterno )
                     							{
                     								$objEnderecoExterno2->edita();
                     								if ( $detEndereco )
                     									$objEndereco->exclui();
                     							}
                     							else
                     							{
                     								$objEnderecoExterno2->cadastra();
                     								if ( $detEndereco )
                     									$objEndereco->exclui();
                     							}
                     						}
                     						else
                     						{
                     							$objEnderecoExterno = new clsEnderecoExterno( $this->ref_idpes );
                     							$detEnderecoExterno = $objEnderecoExterno->detalhe();
                     
                     							$objEnderecoExterno2 = new clsEnderecoExterno( $this->ref_idpes, "1", $this->idtlog, $this->logradouro, $this->numero, false, $this->complemento, $this->bairro, $this->cep_, $this->cidade, $this->sigla_uf, false, false, false, $this->andar );
                     							if( $detEnderecoExterno )
                     							{
                     								$objEnderecoExterno2->edita();
                     							}
                     							else
                     							{
                     								$objEnderecoExterno2->cadastra();
                     							}
                     						}*/
                     if (!$this->isEnderecoExterno) {
                         //							die("Interno");
                         //							echo "<br>cep: ".$this->cep_;
                         //							$this->cep = idFederal2Int( $this->cep );
                         $this->cep = $this->cep_;
                         //							echo "<br>cep: ".$this->cep;
                         //							echo "<br>clsPessoaEndereco( $this->ref_idpes, $this->cep, $this->idlog, $this->idbai, $this->numero, $this->complemento, false )";die;
                         $objEndereco = new clsPessoaEndereco($this->ref_idpes, $this->cep, $this->idlog, $this->idbai, $this->numero, $this->complemento, false);
                         if ($objEndereco->detalhe()) {
                             $objEndereco->edita();
                         } else {
                             $objEndereco->cadastra();
                         }
                     } else {
                         //							echo "<br>Externo";
                         //							echo "<br>cep_: ".$this->cep_;
                         $this->cep = idFederal2int($this->cep);
                         //							echo "<br>cep: ".$this->cep;
                         //							echo "<br>clsEnderecoExterno( $this->ref_idpes, 1, $this->idtlog, $this->logradouro, $this->numero, $this->letra, $this->complemento, $this->bairro, $this->cep, $this->cidade, $this->sigla_uf, false )";
                         $objEnderecoExterno = new clsEnderecoExterno($this->ref_idpes, "1", $this->idtlog, $this->logradouro, $this->numero, $this->letra, $this->complemento, $this->bairro, $this->cep, $this->cidade, $this->sigla_uf, false);
                         if ($objEnderecoExterno->existe()) {
                             //								echo "<br>editar";
                             $objEnderecoExterno->edita();
                         } else {
                             //								echo "<br>cadastra";
                             $objEnderecoExterno->cadastra();
                         }
                     }
                     //-----------------------EDITA CURSO------------------------//
                     $this->escola_curso = unserialize(urldecode($this->escola_curso));
                     $obj = new clsPmieducarEscolaCurso($this->cod_escola);
                     $excluiu = $obj->excluirTodos();
                     if ($excluiu) {
                         if ($this->escola_curso) {
                             //								die("com cnpj");
                             foreach ($this->escola_curso as $campo) {
                                 $obj = new clsPmieducarEscolaCurso($this->cod_escola, $campo, null, $this->pessoa_logada, null, null, 1);
                                 $cadastrou_ = $obj->cadastra();
                                 if (!$cadastrou_) {
                                     $this->mensagem = "Edi&ccedil;&atilde;o n&atilde;o realizada.<br>";
                                     echo "<!--\nErro ao editar clsPmieducarEscolaCurso\nvalores obrigat&oacute;rios\nis_numeric( {$this->cod_serie} ) && is_numeric( {$campo} ) && is_numeric( {$this->pessoa_logada} )\n-->";
                                     return false;
                                 }
                             }
                         }
                     }
                     //-----------------------FIM EDITA CURSO------------------------//
                     $this->mensagem .= "Edi&ccedil;&atilde;o efetuada com sucesso.<br>";
                     header("Location: educar_escola_lst.php");
                     die;
                     return true;
                 }
                 /*if($this->cep && $this->idbai && $this->idlog)
                 		{
                 			$objEndereco = new clsPessoaEndereco( $this->ref_idpes );
                 			$objEndereco2 = new clsPessoaEndereco($this->ref_idpes,$this->cep,$this->idlog,$this->idbai,$this->numero,$this->complemento, false,false, false, false, $this->andar);
                 			if( $objEndereco->detalhe() )
                 			{
                 				$objEndereco2->edita();
                 			}
                 			else
                 			{
                 				$objEndereco2->cadastra();
                 			}
                 			$objPessoa = new clsPessoaFj();
                 			list( $this->cidade, $this->bairro, $this->logradouro, $this->cep, $this->idtlog, $this->sigla_uf, $this->bloco, $this->apartamento, $this->andar ) = $objPessoa->queryRapida($this->ref_idpes, "cidade", "bairro", "logradouro", "cep", "idtlog", "sigla_uf", "bloco", "apartamento", "andar" );
                 		}
                 		else
                 		{
                 			$this->cep_ = idFederal2int($this->cep_);
                 			$objEnderecoExterno = new clsEnderecoExterno( $this->ref_idpes );
                 			$objEnderecoExterno2 = new clsEnderecoExterno( $this->ref_idpes,"1",$this->idtlog,$this->logradouro,$this->numero,false,$this->complemento,$this->bairro,$this->cep_,$this->cidade,$this->sigla_uf,false,false,false, $this->andar);
                 			if( $objEnderecoExterno->detalhe() )
                 			{
                 				$objEnderecoExterno2->edita();
                 			}
                 			else
                 			{
                 				$objEnderecoExterno2->cadastra();
                 			}
                 		}*/
             }
         } else {
             if ($this->sem_cnpj) {
                 $objComplemento = new clsPmieducarEscolaComplemento($this->cod_escola, $this->pessoa_logada, null, idFederal2int($this->cep_), $this->numero, $this->complemento, $this->p_email, $this->fantasia, $this->cidade, $this->bairro, $this->logradouro, $this->p_ddd_telefone_1, $this->p_telefone_1, $this->p_ddd_telefone_fax, $this->p_telefone_fax);
                 $editou1 = $objComplemento->edita();
                 if ($editou1) {
                     //-----------------------EDITA CURSO------------------------//
                     $this->escola_curso = unserialize(urldecode($this->escola_curso));
                     $obj = new clsPmieducarEscolaCurso($this->cod_escola);
                     $excluiu = $obj->excluirTodos();
                     if ($excluiu) {
                         if ($this->escola_curso) {
                             //							die("sem cnpj");
                             foreach ($this->escola_curso as $campo) {
                                 $obj = new clsPmieducarEscolaCurso($this->cod_escola, $campo, null, $this->pessoa_logada, null, null, 1);
                                 $cadastrou_ = $obj->cadastra();
                                 if (!$cadastrou_) {
                                     $this->mensagem = "Edi&ccedil;&atilde;o n&atilde;o realizada.<br>";
                                     echo "<!--\nErro ao editar clsPmieducarEscolaCurso\nvalores obrigat&oacute;rios\nis_numeric( {$this->cod_serie} ) && is_numeric( {$campo[$i]} ) && is_numeric( {$this->pessoa_logada} )\n-->";
                                     return false;
                                 }
                             }
                         }
                     }
                     //-----------------------FIM EDITA CURSO------------------------//
                     $this->mensagem .= "Edi&ccedil;&atilde;o efetuada com sucesso.<br>";
                     header("Location: educar_escola_lst.php");
                     die;
                     return true;
                 } else {
                     $this->mensagem = "Edi&ccedil;&atilde;o n&atilde;o realizada (clsPmieducarEscolaComplemento).<br>";
                     //					echo "<!--\nErro ao editar clsPmieducarEscola\nvalores obrigatorios\nif( is_numeric( $this->cod_escola ) && is_numeric( $this->pessoa_logada ) )\n-->";
                     return false;
                 }
             }
         }
     }
     $this->mensagem = "Edi&ccedil;&atilde;o n&atilde;o realizada.<br>";
     echo "<!--\nErro ao editar clsPmieducarEscola\nvalores obrigatorios\nif( is_numeric( {$this->cod_escola} ) && is_numeric( {$this->pessoa_logada} ) )\n-->";
     return false;
 }
Beispiel #19
0
 function Novo()
 {
     session_start();
     $this->pessoa_logada = $_SESSION['id_pessoa'];
     session_write_close();
     if (!$this->cpf && $this->cpf_2) {
         $cpf = idFederal2int($this->cpf_2);
         $obj_pessoa_fisica = new clsPessoaFisica();
         $lst_pessoa_fisica = $obj_pessoa_fisica->lista(NULL, $cpf);
         if ($lst_pessoa_fisica) {
             $this->mensagem = 'CPF Já Cadastrado';
             return FALSE;
         } else {
             die('CPF Não Existente');
         }
     }
     $obj_pessoa = new clsPessoa_($this->ref_idpes);
     if ($obj_pessoa->detalhe()) {
         $obj_pessoa = new clsPessoa_($this->ref_idpes, $this->nome, NULL, $this->url, NULL, $this->pessoa_logada, NULL, $this->email);
         if (!$obj_pessoa->edita()) {
             return false;
         }
     } else {
         $obj_pessoa = new clsPessoa_($this->ref_idpes, $this->nome, NULL, $this->url, 'F', $this->pessoa_logada, NULL, $this->email);
         if (!($this->ref_idpes = $obj_pessoa->cadastra())) {
             return FALSE;
         }
     }
     if (!$this->cpf) {
         $this->ref_cod_sistema = 1;
     } else {
         $this->ref_cod_sistema = 'NULL';
     }
     if (is_string($this->cpf_pai) && $this->cpf_pai != '') {
         $this->cpf_pai = idFederal2int($this->cpf_pai);
         $obj_cpf = 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->cpf_pai);
         $detalhe_cpf = $obj_cpf->detalheCPF();
         if ($detalhe_cpf) {
             $this->idpes_pai = $detalhe_cpf['idpes'];
             $obj_pessoa = new clsPessoa_($this->idpes_pai);
             $det_pessoa = $obj_pessoa->detalhe();
             if ($det_pessoa) {
                 if ($this->nm_pai) {
                     $obj_pessoa = new clsPessoa_($this->idpes_pai, $this->nm_pai);
                     $obj_pessoa->edita();
                 } else {
                     $this->nm_pai = $det_pessoa['nome'];
                 }
             }
         } else {
             // cria uma pessoa para o pai
             $obj_pessoa = new clsPessoa_(FALSE, $this->nm_pai, $this->pessoa_logada, FALSE, 'F');
             $idpes = $obj_pessoa->cadastra();
             if ($idpes) {
                 $this->idpes_pai = $idpes;
                 //cadastra como pesso Fisica
                 $obj_fisica = new clsFisica($idpes, FALSE, 'M', FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, $this->pessoa_logada, NULL, NULL, $this->cpf_pai);
                 $obj_fisica->cadastra();
             }
         }
     } else {
         $this->idpes_pai = "NULL";
     }
     if (is_string($this->cpf_mae) && $this->cpf_mae != "") {
         $this->cpf_mae = idFederal2int($this->cpf_mae);
         $obj_cpf = 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->cpf_mae);
         $detalhe_cpf = $obj_cpf->detalheCPF();
         if ($detalhe_cpf) {
             $this->idpes_mae = $detalhe_cpf['idpes'];
             $obj_pessoa = new clsPessoa_($this->idpes_mae);
             $det_pessoa = $obj_pessoa->detalhe();
             if ($det_pessoa) {
                 if ($this->nm_mae) {
                     $obj_pessoa = new clsPessoa_($this->idpes_mae, $this->nm_mae);
                     $obj_pessoa->edita();
                 } else {
                     $this->nm_mae = $det_pessoa['nome'];
                 }
             }
         } else {
             // cria uma pessoa para a mae
             $obj_pessoa = new clsPessoa_(FALSE, $this->nm_mae, $this->pessoa_logada, FALSE, 'F');
             $idpes = $obj_pessoa->cadastra();
             if ($idpes) {
                 $this->idpes_mae = $idpes;
                 //cadastra como pesso Fisica
                 $obj_fisica = new clsFisica($idpes, FALSE, 'F', FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, $this->pessoa_logada, NULL, NULL, $this->cpf_mae);
                 $obj_fisica->cadastra();
             }
         }
     } else {
         $this->idpes_mae = "NULL";
     }
     $obj_fisica = new clsFisica($this->ref_idpes, dataToBanco($this->data_nascimento), $this->sexo, $this->idpes_mae, $this->idpes_pai, $this->ref_idpes_responsavel, NULL, $this->ideciv, NULL, NULL, NULL, $this->nacionalidade, $this->pais_origem, NULL, $this->idmun_nascimento, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, $this->pessoa_logada, $this->ref_cod_sistema, $this->cpf);
     if ($obj_fisica->detalhe()) {
         if (!$this->ref_idpes_responsavel) {
             $this->ref_idpes_responsavel = "NULL";
         }
         $obj_fisica = new clsFisica($this->ref_idpes, dataToBanco($this->data_nascimento), $this->sexo, $this->idpes_mae, $this->idpes_pai, $this->ref_idpes_responsavel, NULL, $this->ideciv, NULL, NULL, NULL, $this->nacionalidade, $this->pais_origem, NULL, $this->idmun_nascimento, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, $this->pessoa_logada, $this->ref_cod_sistema);
         if (!$obj_fisica->edita()) {
             return FALSE;
         }
     } else {
         $obj_fisica = new clsFisica($this->ref_idpes, dataToBanco($this->data_nascimento), $this->sexo, $this->idpes_mae, $this->idpes_pai, $this->ref_idpes_responsavel, NULL, $this->ideciv, NULL, NULL, NULL, $this->nacionalidade, $this->pais_origem, NULL, $this->idmun_nascimento, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, $this->pessoa_logada, $this->ref_cod_sistema, $this->cpf);
         if (!$obj_fisica->cadastra()) {
             return FALSE;
         }
     }
     if (is_numeric($this->ref_cod_raca)) {
         $obj_fisica_raca = new clsCadastroFisicaRaca($this->ref_idpes);
         if ($obj_fisica_raca->existe()) {
             $obj_fisica_raca = new clsCadastroFisicaRaca($this->ref_idpes, $this->ref_cod_raca);
             $obj_fisica_raca->edita();
         } else {
             $obj_fisica_raca = new clsCadastroFisicaRaca($this->ref_idpes, $this->ref_cod_raca);
             $obj_fisica_raca->cadastra();
         }
     } else {
         $obj_fisica_raca = new clsCadastroFisicaRaca($this->ref_idpes, $this->ref_cod_raca);
         $obj_fisica_raca->excluir();
     }
     $objTelefone = new clsPessoaTelefone($this->ref_idpes, 1, $this->fone_1, $this->ddd_fone_1);
     if ($objTelefone->detalhe()) {
         $objTelefone->edita();
     } else {
         $objTelefone->cadastra();
     }
     $objTelefone = new clsPessoaTelefone($this->ref_idpes, 2, $this->fone_2, $this->ddd_fone_2);
     if ($objTelefone->detalhe()) {
         $objTelefone->edita();
     } else {
         $objTelefone->cadastra();
     }
     $objTelefone = new clsPessoaTelefone($this->ref_idpes, 3, $this->fone_mov, $this->ddd_mov);
     if ($objTelefone->detalhe()) {
         $objTelefone->edita();
     } else {
         $objTelefone->cadastra();
     }
     $objTelefone = new clsPessoaTelefone($this->ref_idpes, 4, $this->fone_fax, $this->ddd_fax);
     if ($objTelefone->detalhe()) {
         $objTelefone->edita();
     } else {
         $objTelefone->cadastra();
     }
     if ($this->isEnderecoExterno) {
         $this->cep_ = str_replace('-', '', $this->cep_);
         $obj_endereco = new clsEnderecoExterno($this->ref_idpes, 1, $this->ref_idtlog, $this->nm_logradouro, $this->numero, $this->letra, $this->complemento, $this->nm_bairro, $this->cep_, $this->cidade, $this->ref_sigla_uf_, NULL, $this->bloco, $this->apartamento, $this->andar, NULL, $this->pessoa_logada, $this->zona_localizacao);
         if ($obj_endereco->existe()) {
             if (!$obj_endereco->edita()) {
                 return FALSE;
             }
         } else {
             if (!$obj_endereco->cadastra()) {
                 return FALSE;
             }
         }
         if ($this->endereco_original_is_externo != $this->isEnderecoExterno) {
             $obj_endereco = new clsPessoaEndereco($this->ref_idpes);
             $obj_endereco->exclui();
         }
     } else {
         $obj_endereco = new clsPessoaEndereco($this->ref_idpes, $this->id_cep, $this->id_logradouro, $this->id_bairro, $this->numero, $this->complemento, NULL, $this->letra, $this->bloco, $this->apartamento, $this->andar, null, $this->pessoa_logada);
         if ($obj_endereco->existe()) {
             if (!$obj_endereco->edita()) {
                 return FALSE;
             }
         } else {
             if (!$obj_endereco->cadastra()) {
                 return FALSE;
             }
         }
         if ($this->endereco_original_is_externo != $this->isEnderecoExterno) {
             $obj_endereco = new clsEnderecoExterno($this->ref_idpes);
             $obj_endereco->exclui();
         }
     }
     $this->deficiencia_exc = $_POST['oc_defic_exc'];
     if ($this->deficiencia_exc) {
         foreach ($this->deficiencia_exc as $key => $deficiencia) {
             $obj_deficiencia_pessoa = new clsCadastroFisicaDeficiencia($this->ref_idpes, $deficiencia);
             if ($obj_deficiencia_pessoa->detalhe()) {
                 $obj_deficiencia_pessoa->excluir();
             }
         }
     }
     $this->deficiencia = $_POST['oc_defic'];
     if ($this->deficiencia) {
         foreach ($this->deficiencia as $key => $deficiencia) {
             $obj_deficiencia_pessoa = new clsCadastroFisicaDeficiencia($this->ref_idpes, $key);
             if (!$obj_deficiencia_pessoa->detalhe()) {
                 $obj_deficiencia_pessoa->cadastra();
             }
         }
     }
     if ($this->data_emissao_cart_trabalho) {
         $this->data_emissao_cart_trabalho = explode('/', $this->data_emissao_cart_trabalho);
         $this->data_emissao_cart_trabalho = "{$this->data_emissao_cart_trabalho[2]}/{$this->data_emissao_cart_trabalho[1]}/{$this->data_emissao_cart_trabalho[0]}";
     }
     if ($this->data_emissao_cert_civil) {
         $this->data_emissao_cert_civil = explode('/', $this->data_emissao_cert_civil);
         $this->data_emissao_cert_civil = "{$this->data_emissao_cert_civil[2]}/{$this->data_emissao_cert_civil[1]}/{$this->data_emissao_cert_civil[0]}";
     }
     if ($this->data_exp_rg) {
         $this->data_exp_rg = explode('/', $this->data_exp_rg);
         $this->data_exp_rg = "{$this->data_exp_rg[2]}/{$this->data_exp_rg[1]}/{$this->data_exp_rg[0]}";
     }
     $ObjDocumento = new clsDocumento($this->ref_idpes, $this->rg, $this->data_exp_rg, $this->sigla_uf_exp_rg, $this->tipo_cert_civil, $this->num_termo, $this->num_livro, $this->num_folha, $this->data_emissao_cert_civil, $this->sigla_uf_cert_civil, $this->cartorio_cert_civil, $this->num_cart_trabalho, $this->serie_cart_trabalho, $this->data_emissao_cart_trabalho, $this->sigla_uf_cart_trabalho, $this->num_tit_eleitor, $this->zona_tit_eleitor, $this->secao_tit_eleitor, $this->idorg_exp_rg);
     if ($ObjDocumento->detalhe()) {
         $ObjDocumento = new clsDocumento($this->ref_idpes, $this->rg, $this->data_exp_rg, $this->sigla_uf_exp_rg, $this->tipo_cert_civil, $this->num_termo, $this->num_livro, $this->num_folha, $this->data_emissao_cert_civil, $this->sigla_uf_cert_civil, $this->cartorio_cert_civil, $this->num_cart_trabalho, $this->serie_cart_trabalho, $this->data_emissao_cart_trabalho, $this->sigla_uf_cart_trabalho, $this->num_tit_eleitor, $this->zona_tit_eleitor, $this->secao_tit_eleitor, $this->idorg_exp_rg);
         if (!$ObjDocumento->edita()) {
             return FALSE;
         }
     } else {
         $ObjDocumento = new clsDocumento($this->ref_idpes, $this->rg, $this->data_exp_rg, $this->sigla_uf_exp_rg, $this->tipo_cert_civil, $this->num_termo, $this->num_livro, $this->num_folha, $this->data_emissao_cert_civil, $this->sigla_uf_cert_civil, $this->cartorio_cert_civil, $this->num_cart_trabalho, $this->serie_cart_trabalho, $this->data_emissao_cart_trabalho, $this->sigla_uf_cart_trabalho, $this->num_tit_eleitor, $this->zona_tit_eleitor, $this->secao_tit_eleitor, $this->idorg_exp_rg);
         if (!$ObjDocumento->cadastra()) {
             return FALSE;
         }
     }
     if ($this->foto && $this->foto['error'] == 0) {
         $this->foto = $this->geraFotos($this->foto['tmp_name']);
         $obj = new clsPmieducarAluno(NULL, $this->ref_cod_aluno_beneficio, $this->ref_cod_religiao, $this->pessoa_logada, $this->pessoa_logada, $this->ref_idpes, NULL, NULL, 1, $this->foto, $this->analfabeto, $this->nm_pai, $this->nm_mae);
         $obj_det = $obj->detalhe();
         if ($obj_det) {
             if ($obj_det['caminho_foto']) {
                 $this->caminho_foto = $obj_det['caminho_foto'];
             }
             $this->foto_excluida = 1;
         }
     } elseif ($this->foto_excluida == 1) {
         $this->foto = 'NULL';
     } elseif (!$this->foto_excluida) {
         $this->foto = $this->foto_antiga;
     }
     if ($this->foto_excluida) {
         if (file_exists('arquivos/educar/aluno/big/' . $this->caminho_foto)) {
             unlink('arquivos/educar/aluno/big/' . $this->caminho_foto);
         }
         if (file_exists('arquivos/educar/aluno/small/' . $this->caminho_foto)) {
             unlink('arquivos/educar/aluno/small/' . $this->caminho_foto);
         }
         if (file_exists('arquivos/educar/aluno/original/' . $this->caminho_foto)) {
             unlink('arquivos/educar/aluno/original/' . $this->caminho_foto);
         }
     }
     if (is_numeric($this->idpes_mae) && $this->idpes_mae != 'NULL') {
         $this->nm_mae = 'NULL';
     }
     if (is_numeric($this->idpes_pai) && $this->idpes_pai != 'NULL') {
         $this->nm_pai = 'NULL';
     }
     if (!$this->cod_aluno) {
         $obj = new clsPmieducarAluno(NULL, $this->ref_cod_aluno_beneficio, $this->ref_cod_religiao, $this->pessoa_logada, $this->pessoa_logada, $this->ref_idpes, NULL, NULL, 1, $this->foto, $this->analfabeto, $this->nm_pai, $this->nm_mae, $this->tipo_responsavel);
         if ($this->ref_idpes) {
             if ($obj->existePessoa()) {
                 $aluno = $obj->edita();
                 $this->cod_aluno = $aluno['cod_aluno'];
             } else {
                 $this->cod_aluno = $obj->cadastra();
             }
         }
     } else {
         $obj = new clsPmieducarAluno($this->cod_aluno, $this->ref_cod_aluno_beneficio, $this->ref_cod_religiao, $this->pessoa_logada, $this->pessoa_logada, $this->ref_idpes, NULL, NULL, 1, $this->foto, $this->analfabeto, $this->nm_pai, $this->nm_mae, $this->tipo_responsavel);
         if ($this->ref_idpes) {
             if ($obj->existePessoa()) {
                 $obj->edita();
             } else {
                 $obj->cadastra();
             }
         }
     }
     // Atualiza a informação de uso de transporte escolar.
     $this->_cadastraTransporte($this->cod_aluno, $this->transporte_aluno, $this->transporte_responsavel, $this->pessoa_logada);
     header('Location: educar_aluno_det.php?cod_aluno=' . $this->cod_aluno);
     die;
 }
 function Gerar()
 {
     @session_start();
     $this->pessoa_logada = $_SESSION['id_pessoa'];
     session_write_close();
     $this->titulo = "Aluno - Listagem";
     foreach ($_GET as $var => $val) {
         // passa todos os valores obtidos no GET para atributos do objeto
         $this->{$var} = $val === "" ? null : $val;
     }
     $this->campoNumero("cod_aluno", "C&oacute;digo Aluno", $this->cod_aluno, 20, 9, false);
     $this->campoNumero("cod_inep", "C&oacute;digo INEP", $this->cod_inep, 20, 12, false);
     $this->campoTexto("nome_aluno", "Nome do aluno", $this->nome_aluno, 50, 255, false);
     $this->campoData("data_nascimento", "Data de Nascimento", $this->data_nascimento);
     $this->campoTexto("nome_pai", "Nome do Pai", $this->nome_pai, 50, 255);
     $this->campoTexto("nome_mae", "Nome da Mãe", $this->nome_mae, 50, 255);
     $this->campoTexto("nome_responsavel", "Nome do Responsável", $this->nome_responsavel, 50, 255);
     $obj_permissoes = new clsPermissoes();
     $cod_escola = $obj_permissoes->getEscola($this->pessoa_logada);
     if ($cod_escola) {
         $this->campoCheck("meus_alunos", "Meus Alunos", $_GET['meus_alunos']);
         $ref_cod_escola = false;
         if ($_GET['meus_alunos']) {
             $ref_cod_escola = $cod_escola;
         }
     }
     $array_matriculado = array('S' => "Sim", 'N' => 'N&atilde;o');
     $nivel_usuario = $obj_permissoes->nivel_acesso($this->pessoa_logada);
     $this->addCabecalhos(array("C&oacute;digo Aluno", "Código INEP", "Nome do Aluno", "Nome da Mãe", "Nome do Respons&aacute;vel", "CPF Respons&aacute;vel"));
     // Paginador
     $this->limite = 20;
     $this->offset = $_GET["pagina_{$this->nome}"] ? $_GET["pagina_{$this->nome}"] * $this->limite - $this->limite : 0;
     $aluno = new clsPmieducarAluno();
     $aluno->setLimite($this->limite, $this->offset);
     $alunos = $aluno->lista2($this->cod_aluno, null, null, null, null, null, null, null, null, null, 1, null, $this->nome_aluno, null, idFederal2int($this->cpf_responsavel), null, null, null, $ref_cod_escola, null, $this->data_nascimento, $this->nome_pai, $this->nome_mae, $this->nome_responsavel, $this->cod_inep);
     $total = $aluno->_total;
     foreach ($alunos as $registro) {
         $alunoInepId = $this->tryLoadAlunoInepId($registro["cod_aluno"]);
         $nomeAluno = strtoupper($registro["nome_aluno"]);
         $nomeMae = strtoupper($this->loadNomeMae($registro));
         // responsavel
         $aluno->cod_aluno = $registro["cod_aluno"];
         $responsavel = $aluno->getResponsavelAluno();
         $nomeResponsavel = strtoupper($responsavel["nome_responsavel"]);
         $this->addLinhas(array("<a href=\"educar_aluno_det.php?cod_aluno={$registro["cod_aluno"]}\">{$registro["cod_aluno"]}</a>", "<a href=\"educar_aluno_det.php?cod_aluno={$registro["cod_aluno"]}\">{$alunoInepId}</a>", "<a href=\"educar_aluno_det.php?cod_aluno={$registro["cod_aluno"]}\">{$nomeAluno}</a>", "<a href=\"educar_aluno_det.php?cod_aluno={$registro["cod_aluno"]}\">{$nomeMae}</a>", "<a href=\"educar_aluno_det.php?cod_aluno={$registro["cod_aluno"]}\">{$nomeResponsavel}</a>", "<a href=\"educar_aluno_det.php?cod_aluno={$registro["cod_aluno"]}\">{$responsavel["cpf_responsavel"]}</a>"));
     }
     $this->addPaginador2("educar_aluno_lst.php", $total, $_GET, $this->nome, $this->limite);
     //** Verificacao de permissao para cadastro
     if ($obj_permissoes->permissao_cadastra(578, $this->pessoa_logada, 7)) {
         $this->acao = "go(\"/module/Cadastro/aluno\")";
         $this->nome_acao = "Novo";
         /*$this->array_botao = array("Ficha do Aluno (em branco)");
         		$this->array_botao_script = array( "showExpansivelImprimir(400, 200,  \"educar_relatorio_aluno_dados.php\",\"\", \"Relatório i-Educar\" )" );*/
     }
     //**
     $this->largura = "100%";
     $localizacao = new LocalizacaoSistema();
     $localizacao->entradaCaminhos(array($_SERVER['SERVER_NAME'] . "/intranet" => "In&iacute;cio", "educar_index.php" => "i-Educar - Escola", "" => "Listagem de alunos"));
     $this->enviaLocalizacao($localizacao->montar());
 }
 function Novo()
 {
     global $HTTP_POST_FILES;
     @session_start();
     $this->id_pessoa = @$_SESSION['id_pessoa'];
     session_write_close();
     $db = new clsBanco();
     $this->cep = idFederal2int($this->cep);
     if ($this->senha == $this->re_senha) {
         $db->Consulta("INSERT INTO compras_editais_empresa( nm_empresa, cnpj, email, data_hora, endereco, ref_sigla_uf, cidade, bairro, telefone, fax, cep, nome_contato, senha ) VALUES( '{$this->nm_empresa}', '{$this->cnpj}', '{$this->email}', NOW(), '{$this->endereco}', '{$this->ref_sigla_uf}', '{$this->cidade}', '{$this->bairro}', '{$this->telefone}','{$this->fax}', '{$this->cep}','{$this->nome_contato}', '{$this->senha}' )");
         $nome = $db->CampoUnico("SELECT nome FROM cadastro.pessoa WHERE idpes = {$this->id_pessoa}");
         $data_atual = date("d/m/Y H:i", time());
         $conteudo = "Cadastrando empresa_edital:<br>\nUsuario: {$this->id_pessoa} - {$nome}<br>\nhorario: {$data_atual}<br>\n<br>\n";
         $conteudo .= "Query:<br>\nINSERT INTO compras_editais_empresa( nm_empresa, cnpj, email, data_hora, endereco, ref_sigla_uf, cidade, bairro, telefone, fax, cep, nome_contato, senha ) VALUES( '{$this->nm_empresa}', '{$this->cnpj}', '{$this->email}', NOW(), '{$this->endereco}', '{$this->ref_sigla_uf}', '{$this->cidade}', '{$this->bairro}', '{$this->telefone}','{$this->fax}', '{$this->cep}','{$this->nome_contato}', '{$this->senha}' )";
         header("location: licitacoes_edital_empresa_lst.php");
         die;
     } else {
         $this->mensagem = "As senhas n&atilde;o conferem.";
     }
     return false;
 }
 function Gerar()
 {
     global $coreExt;
     @session_start();
     $_SESSION['campo1'] = $_GET['campo1'] ? $_GET['campo1'] : $_SESSION['campo1'];
     $_SESSION['campo2'] = $_GET['campo2'] ? $_GET['campo2'] : $_SESSION['campo2'];
     $_SESSION['campo3'] = $_GET['campo3'] ? $_GET['campo3'] : $_SESSION['campo3'];
     $_SESSION['campo4'] = $_GET['campo4'] ? $_GET['campo4'] : $_SESSION['campo4'];
     $_SESSION['campo5'] = $_GET['campo5'] ? $_GET['campo5'] : $_SESSION['campo5'];
     $_SESSION['campo6'] = $_GET['campo6'] ? $_GET['campo6'] : $_SESSION['campo6'];
     $_SESSION['campo7'] = $_GET['campo7'] ? $_GET['campo7'] : $_SESSION['campo7'];
     $_SESSION['campo8'] = $_GET['campo8'] ? $_GET['campo8'] : $_SESSION['campo8'];
     $_SESSION['campo9'] = $_GET['campo9'] ? $_GET['campo9'] : $_SESSION['campo9'];
     $_SESSION['campo10'] = $_GET['campo10'] ? $_GET['campo10'] : $_SESSION['campo10'];
     $_SESSION['campo11'] = $_GET['campo11'] ? $_GET['campo11'] : $_SESSION['campo11'];
     $_SESSION['campo12'] = $_GET['campo12'] ? $_GET['campo12'] : $_SESSION['campo12'];
     $_SESSION['campo13'] = $_GET['campo13'] ? $_GET['campo13'] : $_SESSION['campo13'];
     $_SESSION['campo14'] = $_GET['campo14'] ? $_GET['campo14'] : $_SESSION['campo14'];
     $this->nome = 'form1';
     $this->funcao_js = sprintf('cv_libera_campos(\'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\')', $_SESSION['campo10'], $_SESSION['campo11'], $_SESSION['campo7'], $_SESSION['campo1'], $_SESSION['campo12'], $_SESSION['campo4'], $_SESSION['campo9'], $_SESSION['campo14']);
     $this->titulo = 'Endereço';
     // Paginador
     $limite = 7;
     $iniciolimit = $_GET['pagina_' . $this->nome] ? $_GET['pagina_' . $this->nome] * $limite - $limite : 0;
     // Filtros
     $this->campoTexto('nm_bairro', 'Bairro', $_GET['nm_bairro'], 40, 255);
     $this->campoCep('nr_cep', 'CEP', $_GET['nr_cep']);
     $this->campoTexto('nm_logradouro', 'Logradouro', $_GET['nm_logradouro'], 50, 255);
     $this->campoTexto('cidade', 'Cidade', $_GET['cidade'], 60, 60);
     // uf
     $defaultProvince = isset($_GET['ref_sigla_uf']) ? $_GET['ref_sigla_uf'] : $coreExt['Config']->app->locale->province;
     $options = array('required' => false, 'label' => 'Estado', 'value' => $defaultProvince);
     $helperOptions = array('attrName' => 'ref_sigla_uf');
     $this->inputsHelper()->uf($options, $helperOptions);
     $this->addCabecalhos(array('Bairro', 'CEP', 'Logradouro', 'UF', 'Cidade'));
     // consulta dados
     $pre_select = '
   SELECT
     c.idlog, c.cep, c.idbai, u.sigla_uf, m.nome, t.idtlog, m.idmun, b.zona_localizacao, t.descricao ';
     $select = '
   FROM
     urbano.cep_logradouro_bairro c, public.bairro b, public.logradouro l,
     public.municipio m, public.uf u, urbano.tipo_logradouro t
   WHERE
     c.idlog = l.idlog AND
     c.idbai = b.idbai AND
     l.idmun = b.idmun AND
     l.idmun = m.idmun AND
     l.idtlog = t.idtlog AND
     m.sigla_uf = u.sigla_uf';
     $params = array();
     if (isset($_GET['nr_cep'])) {
         $params['c.cep'] = idFederal2int($_GET['nr_cep']);
     }
     if (isset($_GET['nm_bairro'])) {
         $params['b.nome'] = $_GET['nm_bairro'];
     }
     if (isset($_GET['nm_logradouro'])) {
         $params['l.nome'] = $_GET['nm_logradouro'];
     }
     if (isset($_GET['ref_sigla_uf'])) {
         $params['u.sigla_uf'] = $_GET['ref_sigla_uf'];
     }
     if (isset($_GET['cidade'])) {
         $params['m.nome'] = $_GET['cidade'];
     }
     $paramCount = 1;
     foreach ($params as $name => $value) {
         $select .= " AND {$name} ILIKE '%'||\${$paramCount}||'%'";
         $paramCount++;
     }
     $total = Portabilis_Utils_Database::selectField(' SELECT COUNT(0) ' . $select, array('params' => array_values($params)));
     $select .= sprintf(' LIMIT %s OFFSET %s', $limite, $iniciolimit);
     $result = Portabilis_Utils_Database::fetchPreparedQuery($pre_select . $select, array('params' => array_values($params)));
     foreach ($result as $record) {
         list($idlog, $cep, $idbai, $uf, $cidade, $tipoLogradouroId, $id_mun, $zona, $descricao) = $record;
         $cidade = addslashes($cidade);
         $logradouro = new clsLogradouro($idlog);
         $logradouro = $logradouro->detalhe();
         $logradouro = addslashes($logradouro['nome']);
         $bairro = new clsBairro($idbai);
         $bairro = $bairro->detalhe();
         $bairro = addslashes($bairro['nome']);
         $cep2 = int2CEP($cep);
         $s_end = '0';
         $url = sprintf('<a href="javascript:void(0);" onclick="cv_set_campo(\'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\');liberaCampos();parent.fixUpPlaceholderEndereco();">%%s</a>', $_SESSION['campo1'], $bairro . ' / Zona' . $zona, $_SESSION['campo2'], $idbai, $_SESSION['campo3'], $cep, $_SESSION['campo4'], $descricao . " " . $logradouro, $_SESSION['campo5'], $idlog, '', '', '', '', '', '', '', '', $_SESSION['campo10'], $cep2, $_SESSION['campo11'], $id_mun . ' - ' . $cidade . ' (' . $uf . ')', $_SESSION['campo12'], $_SESSION['campo13'], $id_mun, '', '');
         $this->addLinhas(array(sprintf($url, $bairro), sprintf($url, $cep2), sprintf($url, $logradouro), sprintf($url, $uf), sprintf($url, $cidade)));
     }
     $this->largura = '100%';
     $this->addPaginador2('educar_pesquisa_cep_log_bairro.php', $total, $_GET, $this->nome, $limite);
     /*
         if ($_GET['param']) {
           $this->rodape = '
             <table border="0" cellspacing="0" cellpadding="0" width="100%" align="center">
               <tr width="100%">
                 <td>
                   <div align="center">[ <a href="javascript:void(0);" onclick="liberaCamposOuvidoria()">Cadastrar Novo Endereço</a> ]</div>
                 </td>
               </tr>
             </table>';
         }
         else {
           $this->rodape = sprintf('
             <table border="0" cellspacing="0" cellpadding="0" width="100%%" align="center">
               <tr width="100%%">
                 <td>
                   <div align="center">[ <a href="javascript:void(0);" onclick="%s">Cadastrar Novo Endereço</a> ]</div>
                 </td>
               </tr>
             </table>',
             $this->funcao_js
           );
         }*/
     @session_write_close();
 }
Beispiel #23
0
 public function Editar()
 {
     session_start();
     $pessoaFj = $_SESSION['id_pessoa'];
     session_write_close();
     $objPessoa = new clsPessoa_($pessoaFj, FALSE, FALSE, $this->p_http, FALSE, $pessoaFj, date("Y-m-d H:i:s", time()), $this->p_email);
     $objPessoa->edita();
     $objFisica = new clsFisica($pessoaFj, FALSE, $this->p_sexo);
     $objFisica->edita();
     $objTelefone = new clsPessoaTelefone($pessoaFj);
     $objTelefone->excluiTodos();
     $objTelefone = new clsPessoaTelefone($pessoaFj, 1, str_replace("-", "", $this->p_telefone_1), $this->p_ddd_telefone_1);
     $objTelefone->cadastra();
     $objTelefone = new clsPessoaTelefone($pessoaFj, 2, str_replace("-", "", $this->p_telefone_2), $this->p_ddd_telefone_2);
     $objTelefone->cadastra();
     $objTelefone = new clsPessoaTelefone($pessoaFj, 3, str_replace("-", "", $this->p_telefone_mov), $this->p_ddd_telefone_mov);
     $objTelefone->cadastra();
     $objTelefone = new clsPessoaTelefone($pessoaFj, 4, str_replace("-", "", $this->p_telefone_fax), $this->p_ddd_telefone_fax);
     $objTelefone->cadastra();
     if ($this->cep && $this->idbai && $this->idlog) {
         $objEndereco = new clsPessoaEndereco($pessoaFj);
         $objEndereco2 = new clsPessoaEndereco($pessoaFj, $this->cep, $this->idlog, $this->idbai, $this->numero, $this->complemento, FALSE, $this->letra, $this->bloco, $this->apartamento, $this->andar);
         if ($objEndereco->detalhe()) {
             $objEndereco2->edita();
         } else {
             $objEndereco2->cadastra();
         }
         $objPessoa = new clsPessoaFj();
         list($this->cidade, $this->bairro, $this->logradouro, $this->cep, $this->idtlog, $this->sigla_uf, $this->bloco, $this->apartamento, $this->andar) = $objPessoa->queryRapida($pessoaFj, "cidade", "bairro", "logradouro", "cep", "idtlog", "sigla_uf", "bloco", "apartamento", "andar");
     } else {
         $this->cep_ = idFederal2int($this->cep_);
         $objEnderecoExterno = new clsEnderecoExterno($pessoaFj);
         $objEnderecoExterno2 = new clsEnderecoExterno($pessoaFj, "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);
         if ($objEnderecoExterno->detalhe()) {
             $objEnderecoExterno2->edita();
         } else {
             $objEnderecoExterno2->cadastra();
         }
     }
     // Verifica o maior setor selecionado
     for ($i = 0; $i < 5; $i++) {
         $varNm = "setor_{$i}";
         if ($this->{$varNm}) {
             $setor = $this->{$varNm};
         }
     }
     if ($setor) {
         $sql = " ref_cod_setor_new = '{$setor}', ";
     }
     if ($this->f_senha != $this->confere_senha) {
         $sql_funcionario = "UPDATE funcionario SET senha=md5('{$this->f_senha}'), data_troca_senha = NOW(), ref_cod_funcionario_vinculo='{$this->ref_cod_funcionario_vinculo}', {$sql} ramal='{$this->f_ramal}', ref_ref_cod_pessoa_fj='{$pessoaFj}', tempo_expira_senha = 30 WHERE ref_cod_pessoa_fj={$this->p_cod_pessoa_fj}";
     } else {
         if (empty($_SESSION['convidado'])) {
             $sql_funcionario = "UPDATE funcionario SET {$sql} ramal='{$this->f_ramal}', ref_cod_funcionario_vinculo='{$this->ref_cod_funcionario_vinculo}', ref_ref_cod_pessoa_fj='{$pessoaFj}' WHERE ref_cod_pessoa_fj={$this->p_cod_pessoa_fj}";
         } else {
             $sql_funcionario = "UPDATE funcionario SET {$sql} ramal='{$this->f_ramal}', ref_ref_cod_pessoa_fj='{$pessoaFj}' WHERE ref_cod_pessoa_fj={$this->p_cod_pessoa_fj}";
         }
     }
     $db = new clsBanco();
     $db->Consulta($sql_funcionario);
     if (empty($_SESSION['convidado'])) {
         if (!$_POST["reloading"]) {
         }
     } else {
         if ($_SESSION['motivo_visita'] == 'atualizar_cadastro_e_email') {
             echo "<script>document.location='solicita_email.php';</script>";
         } else {
             echo "<script>document.location='insmess_cad.php';</script>";
         }
     }
     header('Location: index.php');
     return TRUE;
 }
 function Gerar()
 {
     global $coreExt;
     @session_start();
     $_SESSION['campo1'] = $_GET['campo1'] ? $_GET['campo1'] : $_SESSION['campo1'];
     $_SESSION['campo2'] = $_GET['campo2'] ? $_GET['campo2'] : $_SESSION['campo2'];
     $_SESSION['campo3'] = $_GET['campo3'] ? $_GET['campo3'] : $_SESSION['campo3'];
     $_SESSION['campo4'] = $_GET['campo4'] ? $_GET['campo4'] : $_SESSION['campo4'];
     $_SESSION['campo5'] = $_GET['campo5'] ? $_GET['campo5'] : $_SESSION['campo5'];
     $_SESSION['campo6'] = $_GET['campo6'] ? $_GET['campo6'] : $_SESSION['campo6'];
     $_SESSION['campo7'] = $_GET['campo7'] ? $_GET['campo7'] : $_SESSION['campo7'];
     $_SESSION['campo8'] = $_GET['campo8'] ? $_GET['campo8'] : $_SESSION['campo8'];
     $_SESSION['campo9'] = $_GET['campo9'] ? $_GET['campo9'] : $_SESSION['campo9'];
     $_SESSION['campo10'] = $_GET['campo10'] ? $_GET['campo10'] : $_SESSION['campo10'];
     $_SESSION['campo11'] = $_GET['campo11'] ? $_GET['campo11'] : $_SESSION['campo11'];
     $_SESSION['campo12'] = $_GET['campo12'] ? $_GET['campo12'] : $_SESSION['campo12'];
     $_SESSION['campo13'] = $_GET['campo13'] ? $_GET['campo13'] : $_SESSION['campo13'];
     $_SESSION['campo14'] = $_GET['campo14'] ? $_GET['campo14'] : $_SESSION['campo14'];
     $this->nome = 'form1';
     $this->funcao_js = sprintf('cv_libera_campos(\'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\')', $_SESSION['campo10'], $_SESSION['campo11'], $_SESSION['campo7'], $_SESSION['campo1'], $_SESSION['campo12'], $_SESSION['campo4'], $_SESSION['campo9'], $_SESSION['campo14']);
     $this->titulo = 'Endereço';
     // Paginador
     $limite = 7;
     $iniciolimit = $_GET['pagina_' . $this->nome] ? $_GET['pagina_' . $this->nome] * $limite - $limite : 0;
     // Filtros
     $this->campoTexto('nm_bairro', 'Bairro', $_GET['nm_bairro'], 40, 255);
     $this->campoCep('nr_cep', 'CEP', $_GET['nr_cep']);
     $this->campoTexto('nm_logradouro', 'Logradouro', $_GET['nm_logradouro'], 50, 255);
     $this->campoTexto('cidade', 'Cidade', $_GET['cidade'], 60, 60);
     $obj_uf = new clsUf(FALSE, FALSE, 1);
     $lst_uf = $obj_uf->lista(FALSE, FALSE, FALSE, FALSE, FALSE, 'sigla_uf');
     $array_uf;
     foreach ($lst_uf as $uf) {
         $array_uf[$uf['sigla_uf']] = $uf['nome'];
     }
     if (!$_GET['ref_sigla_uf']) {
         $_GET['ref_sigla_uf'] = $coreExt['Config']->app->locale->province;
     }
     $this->campoLista('ref_sigla_uf', 'UF', $array_uf, $_GET['ref_sigla_uf'], '', FALSE, '');
     $this->addCabecalhos(array('Bairro', 'CEP', 'Logradouro', 'UF', 'Cidade'));
     $select = '
   SELECT
     c.idlog, c.cep, c.idbai, u.sigla_uf, m.nome, t.idtlog, m.idmun, b.zona_localizacao
   FROM
     urbano.cep_logradouro_bairro c, public.bairro b, public.logradouro l,
     public.municipio m, public.uf u, urbano.tipo_logradouro t
   WHERE
     c.idlog = l.idlog AND
     c.idbai = b.idbai AND
     l.idmun = b.idmun AND
     l.idmun = m.idmun AND
     l.idtlog = t.idtlog AND
     m.sigla_uf = u.sigla_uf';
     $select_count = '
   SELECT
     COUNT(*)
   FROM
     urbano.cep_logradouro_bairro c, public.bairro b, public.logradouro l,
     public.municipio m, public.uf u, urbano.tipo_logradouro t
   WHERE
     c.idlog = l.idlog AND
     c.idbai = b.idbai AND
     l.idmun = b.idmun AND
     l.idmun = m.idmun AND
     l.idtlog = t.idtlog AND
     m.sigla_uf = u.sigla_uf';
     if ($_GET['nm_bairro'] || $_GET['nr_cep'] || $_GET['nm_logradouro'] || $_GET['ref_sigla_uf'] || $_GET['cidade']) {
         if ($_GET['nr_cep']) {
             $num_cep = idFederal2int($_GET['nr_cep']);
             $select .= sprintf(' AND c.cep ILIKE \'%%%s%%\'', $num_cep);
             $select_count .= sprintf(' AND c.cep ILIKE \'%%%s%%\'', $num_cep);
         }
         if ($_GET['nm_bairro']) {
             $select .= sprintf(' AND b.nome ILIKE \'%%%s%%\'', $_GET['nm_bairro']);
             $select_count .= sprintf(' AND b.nome ILIKE \'%%%s%%\'', $_GET['nm_bairro']);
         }
         if ($_GET['nm_logradouro']) {
             $select .= sprintf(' AND l.nome ILIKE \'%%%s%%\'', $_GET['nm_logradouro']);
             $select_count .= sprintf(' AND l.nome ILIKE \'%%%s%%\'', $_GET['nm_logradouro']);
         }
         if ($_GET['ref_sigla_uf']) {
             $select .= sprintf(' AND u.sigla_uf ILIKE \'%%%s%%\'', $_GET['ref_sigla_uf']);
             $select_count .= sprintf(' AND u.sigla_uf ILIKE \'%%%s%%\'', $_GET['ref_sigla_uf']);
         }
         if ($_GET['cidade']) {
             $select .= sprintf(' AND m.nome ILIKE \'%%%s%%\'', $_GET['cidade']);
             $select_count .= sprintf(' AND m.nome ILIKE \'%%%s%%\'', $_GET['cidade']);
         }
     }
     $select .= sprintf(' LIMIT %s OFFSET %s', $limite, $iniciolimit);
     $db = new clsBanco();
     $total = $db->CampoUnico($select_count);
     $db->Consulta($select);
     while ($db->ProximoRegistro()) {
         list($idlog, $cep, $idbai, $uf, $cidade, $descricao, $id_mun, $zona) = array('', '', '', '', '', '', '', '');
         list($idlog, $cep, $idbai, $uf, $cidade, $descricao, $id_mun, $zona) = $db->Tupla();
         $logradouro = new clsLogradouro($idlog);
         $detalhe_logradouro = $logradouro->detalhe();
         $bairro = new clsBairro($idbai);
         $detalhe_bairro = $bairro->detalhe();
         $cep2 = int2CEP($cep);
         $s_end = '0';
         $descricao = urlencode($descricao);
         if ($_GET['param']) {
             $url = sprintf('<a href="javascript:void(0);" onclick="setaCamposOuvidoria(\'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\')">%%s</a>', $cep, $cep2, $uf, $uf, $id_mun, $cidade, $detalhe_bairro['idbai'], $detalhe_bairro['nome'], $descricao, $descricao, $detalhe_logradouro['idlog'], $detalhe_logradouro['nome']);
             $this->addLinhas(array(sprintf($url, $detalhe_bairro['nome']), sprintf($url, $cep2), sprintf($url, $detalhe_logradouro["nome"]), sprintf($url, $uf), sprintf($url, $cidade)));
         } else {
             $url = sprintf('<a href="javascript:void(0);" onclick="cv_set_campo(\'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\');">%%s</a>', $_SESSION['campo1'], $detalhe_bairro["nome"], $_SESSION['campo2'], $detalhe_bairro["idbai"], $_SESSION['campo3'], $cep, $_SESSION['campo4'], $detalhe_logradouro["nome"], $_SESSION['campo5'], $detalhe_logradouro["idlog"], $_SESSION['campo6'], $uf, $_SESSION['campo7'], $cidade, $_SESSION['campo8'], $descricao, $_SESSION['campo9'], $s_end, $_SESSION['campo10'], $cep2, $_SESSION['campo11'], $uf, $_SESSION['campo12'], $_SESSION['campo13'], $id_mun, $_SESSION['campo14'], $zona);
             $this->addLinhas(array(sprintf($url, $detalhe_bairro['nome']), sprintf($url, $cep2), sprintf($url, $detalhe_logradouro['nome']), sprintf($url, $uf), sprintf($url, $cidade)));
         }
     }
     $this->largura = '100%';
     $this->addPaginador2('educar_pesquisa_cep_log_bairro.php', $total, $_GET, $this->nome, $limite);
     if ($_GET['param']) {
         $this->rodape = '
     <table border="0" cellspacing="0" cellpadding="0" width="100%" align="center">
       <tr width="100%">
         <td>
           <div align="center">[ <a href="javascript:void(0);" onclick="liberaCamposOuvidoria()">Cadastrar Novo Endereço</a> ]</div>
         </td>
       </tr>
     </table>';
     } else {
         $this->rodape = sprintf('
     <table border="0" cellspacing="0" cellpadding="0" width="100%%" align="center">
       <tr width="100%%">
         <td>
           <div align="center">[ <a href="javascript:void(0);" onclick="%s">Cadastrar Novo Endereço</a> ]</div>
         </td>
       </tr>
     </table>', $this->funcao_js);
     }
     @session_write_close();
 }
Beispiel #25
0
 function Editar()
 {
     @session_start();
     $pessoaFj = $_SESSION['id_pessoa'];
     session_write_close();
     if ($this->id_federal) {
         $ref_cod_sistema = 'null';
         $this->id_federal = idFederal2int($this->id_federal);
         $objFisicaCpf = new clsFisica($this->cod_pessoa_fj);
         $detalhe_fisica = $objFisicaCpf->detalhe();
         if (!$detalhe_fisica['cpf']) {
             $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);
             if ($objCPF->detalhe()) {
                 $this->erros['id_federal'] = 'CPF já cadastrado.';
                 return FALSE;
             }
         }
     }
     $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);
     $objPessoa->edita();
     $this->data_nasc = dataToBanco($this->data_nasc);
     if ($this->id_federal) {
         $this->id_federal = idFederal2Int($this->id_federal);
         $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);
     } else {
         $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);
     }
     $objFisica->edita();
     if ($this->alterado) {
         $db = new clsBanco();
         $db->Consulta("UPDATE cadastro.fisica SET alterado = 'TRUE' WHERE idpes = '{$this->cod_pessoa_fj}'");
     }
     $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 1, $this->telefone_1, $this->ddd_telefone_1);
     $objTelefone->cadastra();
     $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 2, $this->telefone_2, $this->ddd_telefone_2);
     $objTelefone->cadastra();
     $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 3, $this->telefone_mov, $this->ddd_telefone_mov);
     $objTelefone->cadastra();
     $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 4, $this->telefone_fax, $this->ddd_telefone_fax);
     $objTelefone->cadastra();
     $objEndereco = new clsPessoaEndereco($this->cod_pessoa_fj);
     $this->cep = idFederal2Int($this->cep);
     $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);
     if ($objEndereco->detalhe() && $this->cep && $this->idlog && $this->idbai) {
         $objEndereco2->edita();
     } elseif ($this->cep && $this->idlog && $this->idbai) {
         $objEndereco2->cadastra();
     } elseif ($objEndereco->detalhe()) {
         $objEndereco2->exclui();
     } else {
         $this->cep_ = idFederal2int($this->cep_);
         $objEnderecoExterno = new clsEnderecoExterno($this->cod_pessoa_fj);
         $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, FALSE, FALSE, $this->zona_localizacao);
         if ($objEnderecoExterno->detalhe()) {
             $objEnderecoExterno2->edita();
         } else {
             $objEnderecoExterno2->cadastra();
         }
     }
     // Atualizada raça.
     $this->_cadastraRaca($this->cod_pessoa_fj, $this->cor_raca);
     echo '<script>document.location="atendidos_lst.php";</script>';
     return TRUE;
 }