Ejemplo n.º 1
0
 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);
 }
    function renderHTML()
    {
        if ($_POST) {
            foreach ($_POST as $key => $value) {
                $this->{$key} = $value;
            }
        }
        if ($this->ref_ref_cod_serie) {
            $this->ref_cod_serie = $this->ref_ref_cod_serie;
        }
        $fonte = 'arial';
        $corTexto = '#000000';
        if ($this->ref_cod_escola) {
            $obj_escola = new clsPmieducarEscola($this->ref_cod_escola);
            $det_escola = $obj_escola->detalhe();
            $this->nm_escola = $det_escola['nome'];
            $obj_instituicao = new clsPmieducarInstituicao($det_escola['ref_cod_instituicao']);
            $det_instituicao = $obj_instituicao->detalhe();
            $this->nm_instituicao = $det_instituicao['nm_instituicao'];
        }
        if (is_numeric($this->ref_cod_serie)) {
            $obj_serie = new clsPmieducarSerie($this->ref_cod_serie);
            $det_serie = $obj_serie->detalhe();
            $this->nm_serie_ = $det_serie["nm_serie"];
        }
        if (is_numeric($this->ref_cod_turma)) {
            $obj_turma = new clsPmieducarTurma($this->ref_cod_turma);
            $det_turma = $obj_turma->detalhe();
            $this->nm_turma_ = $det_turma["nm_turma"];
        }
        $this->pdf = new clsPDF("Registro de Matrículas - {$this->ano}", "Registro de Matrículas", "A4", "", false, false);
        $this->pdf->largura = 842.0;
        $this->pdf->altura = 595.0;
        $this->page_y = 125;
        if ($this->is_padrao || $this->ano == 2007) {
            $this->semestre = null;
        }
        $obj_matricula = new clsPmieducarMatricula();
        $obj_matricula->setOrderby("ref_ref_cod_escola, ref_ref_cod_serie, ref_cod_curso");
        $lista_matricula = $obj_matricula->lista(null, null, $this->ref_cod_escola, $this->ref_cod_serie, null, null, null, array(1, 2, 3), null, null, null, null, 1, $this->ano, $this->ref_cod_curso, $this->ref_cod_instituicao, null, null, null, null, null, null, null, null, null, null, null, null, null, null, $this->semestre, $this->ref_cod_turma);
        if ($lista_matricula) {
            $obj_series = new clsPmieducarSerie();
            $lst_series = $obj_series->lista(null, null, null, $this->ref_cod_curso, null, null, null, null, null, null, null, null, 1, $this->ref_cod_instituicao, null, null, null, $this->ref_cod_escola);
            if ($lst_series) {
                $lst_series2 = array();
                foreach ($lst_series as $serie) {
                    $lst_series2[$serie['cod_serie']] = $serie;
                }
                $lst_series = $lst_series2;
                unset($lst_series2);
            }
            $obj_turmas = new clsPmieducarTurma();
            $lst_turmas = $obj_turmas->lista(null, null, null, $this->ref_cod_serie, $this->ref_cod_escola, null, null, null, null, null, null, null, null, null, 1, null, null, null, null, null, null, null, null, null, $this->ref_cod_curso, $this->ref_cod_instituicao);
            if ($lst_turmas) {
                $lst_turmas2 = array();
                foreach ($lst_turmas as $turma) {
                    $lst_turmas2[$turma['cod_turma']] = $turma;
                }
                $lst_turmas = $lst_turmas2;
                unset($lst_turmas2);
            }
            $obj_cursos = new clsPmieducarCurso();
            $lst_cursos = $obj_cursos->lista(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 1, null, $this->ref_cod_instituicao);
            if ($lst_cursos) {
                $lst_curso2 = array();
                foreach ($lst_cursos as $curso) {
                    $lst_cursos2[$curso['cod_curso']] = $curso;
                }
                $lst_cursos = $lst_cursos2;
                unset($lst_curso2);
            }
            $altura_caixa = 45;
            //$curso = $lst_cursos[$lista_matricula[0]['cod_curso']];
            //$this->nm_curso = $curso['nm_curso'];
            $ultimo_cod = $lista_matricula[0]['cod_curso'];
            $this->pdf->OpenPage();
            $this->addCabecalho();
            $this->addTitulo();
            foreach ($lista_matricula as $matricula) {
                $this->nm_curso = $lst_cursos[$matricula['ref_cod_curso']]['nm_curso'];
                if ($this->page_y > 530 || $ultimo_cod != $matricula['ref_cod_curso']) {
                    $this->pdf->ClosePage();
                    $this->pdf->OpenPage();
                    $this->page_y = 125;
                    $this->addCabecalho();
                    $this->addTitulo();
                }
                $obj_pessoa = new clsPessoaFisica($matricula['ref_idpes']);
                $det_pessoa = $obj_pessoa->detalhe();
                $nacionalidade = array('NULL' => "Selecione", '1' => "Brasileiro", '2' => "Naturalizado Brasileiro", '3' => "Estrangeiro");
                $nacionalidade = $nacionalidade[$det_pessoa['nacionalidade']];
                $det_municipio = $det_pessoa['idmun_nascimento']->detalhe();
                $data_nasc = explode("-", $det_pessoa['data_nasc']);
                $idade = calculoIdade($data_nasc[2], $data_nasc[1], $data_nasc[0]);
                $data_nasc = implode("/", array($data_nasc[2], $data_nasc[1], $data_nasc[0]));
                $y_escrita = $this->page_y + $altura_caixa / 4;
                $obj_aluno = new clsPmieducarAluno($matricula['ref_cod_aluno']);
                $det_aluno = $obj_aluno->detalhe();
                $obj_fisica = new clsFisica($det_aluno["ref_idpes"]);
                $det_fisica = $obj_fisica->detalhe();
                if (!$det_aluno['nm_mae']) {
                    if ($det_fisica["idpes_mae"]) {
                        $obj_ref_idpes = new clsPessoa_($det_fisica["idpes_mae"]);
                        $det_ref_idpes = $obj_ref_idpes->detalhe();
                        $det_aluno['nm_mae'] = $det_ref_idpes['nome'];
                    } elseif ($det_fisica['nome_mae']) {
                        $det_aluno['nm_mae'] = $det_fisica['nome_mae'];
                    }
                }
                if (!$det_aluno['nm_pai']) {
                    if ($det_fisica["idpes_pai"]) {
                        $obj_ref_idpes = new clsPessoa_($det_fisica["idpes_pai"]);
                        $det_ref_idpes = $obj_ref_idpes->detalhe();
                        $det_aluno['nm_pai'] = $det_ref_idpes["nome"];
                    } elseif ($det_fisica['nome_pai']) {
                        $det_aluno['nome_pai'] = $det_fisica['nome_pai'];
                    }
                }
                if ($det_aluno['tipo_responsavel'] == 'r' || $det_aluno['tipo_responsavel'] == '') {
                    if ($det_fisica["idpes_responsavel"]) {
                        $obj_ref_idpes = new clsPessoa_($det_fisica["idpes_responsavel"]);
                        $det_ref_idpes = $obj_ref_idpes->detalhe();
                        if ($det_aluno['nome_pai']) {
                            if ($det_aluno['nm_responsavel'] != $det_aluno['nome_pai']) {
                                $det_aluno['nm_responsavel'] = $det_ref_idpes["nome"];
                            }
                        } elseif ($det_aluno['nome_mae']) {
                            if ($det_aluno['nm_responsavel'] != $det_aluno['nome_mae']) {
                                $det_aluno['nm_responsavel'] = $det_ref_idpes["nome"];
                            }
                        } else {
                            $det_aluno['nm_responsavel'] = $det_ref_idpes["nome"];
                        }
                    } elseif ($det_fisica['nome_responsavel']) {
                        if ($det_aluno['nome_pai']) {
                            if ($det_fisica['nome_responsavel'] != $det_aluno['nome_pai']) {
                                $det_aluno['nm_responsavel'] = $det_fisica['nome_responsavel'];
                            }
                        } elseif ($det_aluno['nome_mae']) {
                            if ($det_fisica['nome_responsavel'] != $det_aluno['nome_mae']) {
                                $det_aluno['nm_responsavel'] = $det_fisica['nome_responsavel'];
                            }
                        } else {
                            $det_aluno['nm_responsavel'] = $det_fisica['nome_responsavel'];
                        }
                    }
                }
                if ($det_aluno['nm_pai']) {
                    $det_aluno['nm_pai'] = "{$det_aluno['nm_pai']}\n";
                }
                if ($det_aluno['nm_mae']) {
                    $det_aluno['nm_mae'] = "{$det_aluno['nm_mae']}\n";
                }
                $filiacao = "{$det_aluno['nm_pai']}{$det_aluno['nm_mae']}{$det_aluno['nm_responsavel']}";
                $obj_matricula_turma = new clsPmieducarMatriculaTurma();
                $lst_matricula_turma = $obj_matricula_turma->lista($matricula['cod_matricula'], null, null, null, null, null, null, null, 1, $matricula['ref_ref_cod_serie'], $matricula['ref_cod_curso'], $matricula['ref_ref_cod_escola'], null, $matricula['ref_cod_aluno'], null, null, null);
                if (is_array($lst_matricula_turma)) {
                    $lst_matricula_turma = array_shift($lst_matricula_turma);
                    $hora_inicial = $lst_turmas[$lst_matricula_turma['ref_cod_turma']]['hora_inicial'];
                    $hora_final = $lst_turmas[$lst_matricula_turma['ref_cod_turma']]['hora_final'];
                    if ($hora_inicial >= '07:00' and $hora_inicial <= '12:00') {
                        $turno = 'Matutino';
                    } else {
                        if ($hora_inicial > '12:00' and $hora_inicial <= '18:00') {
                            $turno = 'Vespertino';
                        } else {
                            $turno = 'Noturno';
                        }
                    }
                } else {
                    $turno = 'N/A';
                }
                $obj_endereco = new clsPessoaEndereco($det_aluno["ref_idpes"]);
                if ($obj_endereco_det = $obj_endereco->detalhe()) {
                    $id_cep = $obj_endereco_det['cep']->cep;
                    $id_bairro = $obj_endereco_det['idbai']->detalhe();
                    $id_logradouro = $obj_endereco_det['idlog']->detalhe();
                    $id_mun = $id_bairro['idmun']->detalhe();
                    $id_logradouro = $id_logradouro['idlog']->detalhe();
                    $idtlog = $id_logradouro[1];
                    $numero = $obj_endereco_det['numero'];
                    $letra = $obj_endereco_det['letra'];
                    $complemento = $obj_endereco_det['complemento'];
                    $andar = $obj_endereco_det['andar'];
                    $apto = $obj_endereco_det['apartamento'];
                    $bloco = $obj_endereco_det['bloco'];
                    $cidade = $id_mun['nome'];
                    $bairro = $id_bairro['nome'];
                    $logradouro = $id_logradouro['nome'];
                    //$endereco_uf =  $obj_endereco_det['sigla_uf'];
                    $endereco_uf = $id_bairro['idmun']->sigla_uf;
                    $cep = int2CEP($id_cep);
                } else {
                    $obj_endereco = new clsEnderecoExterno($det_aluno["ref_idpes"]);
                    if ($obj_endereco_det = $obj_endereco->detalhe()) {
                        $id_cep = $obj_endereco_det['cep'];
                        $cidade = $obj_endereco_det['cidade'];
                        $bairro = $obj_endereco_det['bairro'];
                        $logradouro = $obj_endereco_det['logradouro'];
                        $numero = $obj_endereco_det['numero'];
                        $letra = $obj_endereco_det['letra'];
                        $complemento = $obj_endereco_det['complemento'];
                        $andar = $obj_endereco_det['andar'];
                        $apto = $obj_endereco_det['apartamento'];
                        $bloco = $obj_endereco_det['bloco'];
                        $idtlog = $obj_endereco_det['idtlog']->idtlog;
                        $endereco_uf = $obj_endereco_det['sigla_uf']->sigla_uf;
                        $cep = int2CEP($id_cep);
                    }
                }
                $idtlog = ucfirst(strtolower($idtlog));
                $logradouro = minimiza_capitaliza($logradouro);
                $cidade = minimiza_capitaliza($cidade);
                $endereco = "{$idtlog} {$logradouro},{$numero} {$letra} {$complemento} {$apto} {$bloco} {$andar}\n{$cep} {$bairro}, {$cidade} {$endereco_uf}";
                $this->pdf->quadrado_relativo(30, $this->page_y, 782, $altura_caixa);
                $this->pdf->quadrado_relativo(30, $this->page_y, 40, $altura_caixa);
                $this->pdf->quadrado_relativo(70, $this->page_y, 50, $altura_caixa);
                $this->pdf->quadrado_relativo(115, $this->page_y, 175, $altura_caixa);
                $this->pdf->quadrado_relativo(285, $this->page_y, 55, $altura_caixa);
                $this->pdf->quadrado_relativo(335, $this->page_y, 190, $altura_caixa);
                $this->pdf->quadrado_relativo(520, $this->page_y, 160, $altura_caixa);
                $this->pdf->quadrado_relativo(680, $this->page_y, 80, $altura_caixa);
                $this->pdf->escreve_relativo("{$matricula['ref_cod_aluno']}", 30, $y_escrita + 5, 40, $altura_caixa, $fonte, 8, $corTexto, 'center');
                $this->pdf->escreve_relativo("{$matricula['cod_matricula']}", 70, $y_escrita + 5, 50, $altura_caixa, $fonte, 8, $corTexto, 'center');
                $this->pdf->escreve_relativo("{$matricula['nome']}\n{$endereco}", 115, $y_escrita - 3, 175, $altura_caixa, $fonte, 8, $corTexto, 'center');
                $this->pdf->escreve_relativo("{$data_nasc}\n{$idade} anos", 285, $y_escrita + 5, 50, $altura_caixa, $fonte, 8, $corTexto, 'center');
                $this->pdf->escreve_relativo("{$filiacao}", 335, $y_escrita + 5, 175, $altura_caixa, $fonte, 8, $corTexto, 'center');
                if ($this->campo_assinatura) {
                    $this->pdf->escreve_relativo(" ", 520, $y_escrita + 2, 160, $altura_caixa, $fonte, 8, $corTexto, 'center');
                } else {
                    $this->pdf->escreve_relativo("{$nacionalidade}\n{$det_municipio['nome']}", 520, $y_escrita + 2, 160, $altura_caixa, $fonte, 8, $corTexto, 'center');
                }
                $obj_matricula_turma2 = new clsPmieducarMatriculaTurma();
                $det_matricula_turma2 = $obj_matricula_turma2->lista($matricula["cod_matricula"], null, null, null, null, null, null, null, 1);
                if (is_array($det_matricula_turma2)) {
                    $det_matricula_turma2 = array_shift($det_matricula_turma2);
                    $obj_turma = new clsPmieducarTurma($det_matricula_turma2["ref_cod_turma"]);
                    $det_turma = $obj_turma->detalhe();
                }
                $this->pdf->escreve_relativo("{$lst_series[$matricula['ref_ref_cod_serie']]['nm_serie']}\n{$det_turma["nm_turma"]}", 680, $y_escrita + 5, 80, $altura_caixa, $fonte, 8, $corTexto, 'center');
                $this->pdf->escreve_relativo("{$turno}", 760, $y_escrita + 5, 50, $altura_caixa, $fonte, 8, $corTexto, 'center');
                $this->page_y += $altura_caixa;
                $ultimo_cod = $matricula['ref_cod_curso'];
            }
            $this->pdf->ClosePage();
        } else {
            echo '<script>
	     					alert("A turma não possui matrículas");
	     					window.parent.fechaExpansivel(\'div_dinamico_\'+(window.parent.DOM_divs.length-1));
			     		  </script>';
            return true;
            return;
        }
        $this->pdf->CloseFile();
        $this->get_link = $this->pdf->GetLink();
        echo "<script>window.onload=function(){parent.EscondeDiv('LoadImprimir');window.location='download.php?filename=" . $this->get_link . "'}</script>";
        echo "<html><center>Se o download não iniciar automaticamente <br /><a target='_blank' href='" . $this->get_link . "' style='font-size: 16px; color: #000000; text-decoration: underline;'>clique aqui!</a><br><br>\n\t\t\t<span style='font-size: 10px;'>Para visualizar os arquivos PDF, é necessário instalar o Adobe Acrobat Reader.<br>\n\n\t\t\tClique na Imagem para Baixar o instalador<br><br>\n\t\t\t<a href=\"http://www.adobe.com.br/products/acrobat/readstep2.html\" target=\"new\"><br><img src=\"imagens/acrobat.gif\" width=\"88\" height=\"31\" border=\"0\"></a>\n\t\t\t</span>\n\t\t\t</center>";
    }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
 function Gerar()
 {
     $this->url_cancelar = $this->retorno == 'Editar' ? 'atendidos_det.php?cod_pessoa=' . $this->cod_pessoa_fj : 'atendidos_lst.php';
     $this->campoCpf('id_federal', 'CPF', $this->id_federal, FALSE);
     $this->campoOculto('cod_pessoa_fj', $this->cod_pessoa_fj);
     $this->campoTexto('nm_pessoa', 'Nome', $this->nm_pessoa, '50', '255', TRUE);
     $foto = false;
     if (is_numeric($this->cod_pessoa_fj)) {
         $objFoto = new ClsCadastroFisicaFoto($this->cod_pessoa_fj);
         $detalheFoto = $objFoto->detalhe();
         if (count($detalheFoto)) {
             $foto = $detalheFoto['caminho'];
         }
     } else {
         $foto = false;
     }
     if ($foto != false) {
         $this->campoRotulo('fotoAtual_', 'Foto atual', '<img height="117" src="' . $foto . '"/>');
         $this->campoArquivo('file', 'Trocar foto', $this->arquivoFoto, 40, '<br/> <span style="font-style: italic; font-size= 10px;">* Recomenda-se imagens nos formatos jpeg, jpg, png e gif. Tamanho máximo: 150KB</span>');
     } else {
         $this->campoArquivo('file', 'Foto', $this->arquivoFoto, 40, '<br/> <span style="font-style: italic; font-size= 10px;">* Recomenda-se imagens nos formatos jpeg, jpg, png e gif. Tamanho máximo: 150KB</span>');
     }
     // ao cadastrar pessoa do pai ou mãe apartir do cadastro de outra pessoa,
     // é enviado o tipo de cadastro (pai ou mae).
     $parentType = isset($_REQUEST['parent_type']) ? $_REQUEST['parent_type'] : '';
     $naturalidadeObrigatoria = $parentType == '' ? true : false;
     // sexo
     $sexo = $this->sexo;
     // sugere sexo quando cadastrando o pai ou mãe
     if (!$sexo && $parentType == 'pai') {
         $sexo = 'M';
     } elseif (!$sexo && $parentType == 'mae') {
         $sexo = 'F';
     }
     $options = array('label' => 'Sexo / Estado civil', 'value' => $sexo, 'resources' => array('' => 'Sexo', 'M' => 'Masculino', 'F' => 'Feminino'), 'inline' => true);
     $this->inputsHelper()->select('sexo', $options);
     // estado civil
     $this->inputsHelper()->estadoCivil(array('label' => '', 'required' => empty($parentType)));
     // data nascimento
     $options = array('label' => 'Data nascimento', 'value' => $this->data_nasc, 'required' => empty($parentType));
     $this->inputsHelper()->date('data_nasc', $options);
     // pai, mãe
     $this->inputPai();
     $this->inputMae();
     // documentos
     $documentos = new clsDocumento();
     $documentos->idpes = $this->cod_pessoa_fj;
     $documentos = $documentos->detalhe();
     // rg
     // o rg é obrigatorio ao cadastrar pai ou mãe, exceto se configurado como opcional.
     $required = !empty($parentType);
     if ($required && $GLOBALS['coreExt']['Config']->app->rg_pessoa_fisica_pais_opcional) {
         $required = false;
     }
     $options = array('required' => $required, 'label' => 'RG / Data emissão', 'placeholder' => 'Documento identidade', 'value' => $documentos['rg'], 'max_length' => 20, 'size' => 27, 'inline' => true);
     $this->inputsHelper()->integer('rg', $options);
     // data emissão rg
     $options = array('required' => false, 'label' => '', 'placeholder' => 'Data emissão', 'value' => $documentos['data_exp_rg'], 'size' => 19);
     $this->inputsHelper()->date('data_emissao_rg', $options);
     // orgão emissão rg
     $selectOptions = array(null => 'Orgão emissor');
     $orgaos = new clsOrgaoEmissorRg();
     $orgaos = $orgaos->lista();
     foreach ($orgaos as $orgao) {
         $selectOptions[$orgao['idorg_rg']] = $orgao['sigla'];
     }
     $selectOptions = Portabilis_Array_Utils::sortByValue($selectOptions);
     $options = array('required' => false, 'label' => '', 'value' => $documentos['idorg_exp_rg'], 'resources' => $selectOptions, 'inline' => true);
     $this->inputsHelper()->select('orgao_emissao_rg', $options);
     // uf emissão rg
     $options = array('required' => false, 'label' => '', 'value' => $documentos['sigla_uf_exp_rg']);
     $helperOptions = array('attrName' => 'uf_emissao_rg');
     $this->inputsHelper()->uf($options, $helperOptions);
     // Código NIS (PIS/PASEP)
     $options = array('required' => false, 'label' => 'NIS (PIS/PASEP)', 'placeholder' => '', 'value' => $this->nis_pis_pasep, 'max_length' => 11, 'size' => 20);
     $this->inputsHelper()->integer('nis_pis_pasep', $options);
     // Carteira do SUS
     $options = array('required' => false, 'label' => 'Número da carteira do SUS', 'placeholder' => '', 'value' => $this->sus, 'max_length' => 20, 'size' => 20);
     $this->inputsHelper()->text('sus', $options);
     // tipo de certidao civil
     $selectOptions = array(null => 'Tipo certidão civil', 'certidao_nascimento_novo_formato' => 'Nascimento (novo formato)', 91 => 'Nascimento (antigo formato)', 92 => 'Casamento');
     // caso certidao nascimento novo formato tenha sido informado,
     // considera este o tipo da certidão
     if (!empty($documentos['certidao_nascimento'])) {
         $tipoCertidaoCivil = 'certidao_nascimento_novo_formato';
     } else {
         $tipoCertidaoCivil = $documentos['tipo_cert_civil'];
     }
     $options = array('required' => false, 'label' => 'Tipo certidão civil', 'value' => $tipoCertidaoCivil, 'resources' => $selectOptions, 'inline' => true);
     $this->inputsHelper()->select('tipo_certidao_civil', $options);
     // termo certidao civil
     $options = array('required' => false, 'label' => '', 'placeholder' => 'Termo', 'value' => $documentos['num_termo'], 'max_length' => 8, 'inline' => true);
     $this->inputsHelper()->integer('termo_certidao_civil', $options);
     // livro certidao civil
     $options = array('required' => false, 'label' => '', 'placeholder' => 'Livro', 'value' => $documentos['num_livro'], 'max_length' => 8, 'size' => 15, 'inline' => true);
     $this->inputsHelper()->text('livro_certidao_civil', $options);
     // folha certidao civil
     $options = array('required' => false, 'label' => '', 'placeholder' => 'Folha', 'value' => $documentos['num_folha'], 'max_length' => 4, 'inline' => true);
     $this->inputsHelper()->integer('folha_certidao_civil', $options);
     // certidao nascimento (novo padrão)
     $options = array('required' => false, 'label' => '', 'placeholder' => 'Certidão nascimento', 'value' => $documentos['certidao_nascimento'], 'max_length' => 50, 'size' => 50);
     $this->inputsHelper()->text('certidao_nascimento', $options);
     // uf emissão certidão civil
     $options = array('required' => false, 'label' => 'Estado emissão / Data emissão', 'value' => $documentos['sigla_uf_cert_civil'], 'inline' => true);
     $helperOptions = array('attrName' => 'uf_emissao_certidao_civil');
     $this->inputsHelper()->uf($options, $helperOptions);
     // data emissão certidão civil
     $options = array('required' => false, 'label' => '', 'placeholder' => 'Data emissão', 'value' => $documentos['data_emissao_cert_civil']);
     $this->inputsHelper()->date('data_emissao_certidao_civil', $options);
     // cartório emissão certidão civil
     $options = array('required' => false, 'label' => 'Cartório emissão', 'value' => $documentos['cartorio_cert_civil'], 'cols' => 45, 'max_length' => 150);
     $this->inputsHelper()->textArea('cartorio_emissao_certidao_civil', $options);
     // carteira de trabalho
     $options = array('required' => false, 'label' => 'Carteira de trabalho / Série', 'placeholder' => 'Carteira de trabalho', 'value' => $documentos['num_cart_trabalho'], 'max_length' => 7, 'inline' => true);
     $this->inputsHelper()->integer('carteira_trabalho', $options);
     // serie carteira de trabalho
     $options = array('required' => false, 'label' => '', 'placeholder' => 'Série', 'value' => $documentos['serie_cart_trabalho'], 'max_length' => 5);
     $this->inputsHelper()->integer('serie_carteira_trabalho', $options);
     // uf emissão carteira de trabalho
     $options = array('required' => false, 'label' => 'Estado emissão / Data emissão', 'value' => $documentos['sigla_uf_cart_trabalho'], 'inline' => true);
     $helperOptions = array('attrName' => 'uf_emissao_carteira_trabalho');
     $this->inputsHelper()->uf($options, $helperOptions);
     // data emissão carteira de trabalho
     $options = array('required' => false, 'label' => '', 'placeholder' => 'Data emissão', 'value' => $documentos['data_emissao_cart_trabalho']);
     $this->inputsHelper()->date('data_emissao_carteira_trabalho', $options);
     // titulo eleitor
     $options = array('required' => false, 'label' => 'Titulo eleitor / Zona / Seção', 'placeholder' => 'Titulo eleitor', 'value' => $documentos['num_tit_eleitor'], 'max_length' => 13, 'inline' => true);
     $this->inputsHelper()->integer('titulo_eleitor', $options);
     // zona titulo eleitor
     $options = array('required' => false, 'label' => '', 'placeholder' => 'Zona', 'value' => $documentos['zona_tit_eleitor'], 'max_length' => 4, 'inline' => true);
     $this->inputsHelper()->integer('zona_titulo_eleitor', $options);
     // seção titulo eleitor
     $options = array('required' => false, 'label' => '', 'placeholder' => 'Seção', 'value' => $documentos['secao_tit_eleitor'], 'max_length' => 4);
     $this->inputsHelper()->integer('secao_titulo_eleitor', $options);
     // Cor/raça.
     $racas = new clsCadastroRaca();
     $racas = $racas->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL, TRUE);
     $selectOptions = array('' => 'Raça');
     foreach ($racas as $raca) {
         $selectOptions[$raca['cod_raca']] = $raca['nm_raca'];
     }
     $selectOptions = Portabilis_Array_Utils::sortByValue($selectOptions);
     $this->campoLista('cor_raca', 'Raça', $selectOptions, $this->cod_raca, '', FALSE, '', '', '', FALSE);
     // nacionalidade
     // tipos
     $tiposNacionalidade = array(null => 'Selecione', '1' => 'Brasileiro', '2' => 'Naturalizado brasileiro', '3' => 'Estrangeiro');
     $options = array('label' => 'Nacionalidade', 'resources' => $tiposNacionalidade, 'required' => false, 'inline' => true, 'value' => $this->tipo_nacionalidade);
     $this->inputsHelper()->select('tipo_nacionalidade', $options);
     // pais origem
     $options = array('label' => '', 'placeholder' => 'Informe o nome do pais', 'required' => true);
     $hiddenInputOptions = array('options' => array('value' => $this->pais_origem_id));
     $helperOptions = array('objectName' => 'pais_origem', 'hiddenInputOptions' => $hiddenInputOptions);
     $this->inputsHelper()->simpleSearchPais('nome', $options, $helperOptions);
     // naturalidade
     //$options       = array('label' => 'Naturalidade', 'required'   => true);
     $options = array('label' => 'Naturalidade', 'required' => $naturalidadeObrigatoria);
     $helperOptions = array('objectName' => 'naturalidade', 'hiddenInputOptions' => array('options' => array('value' => $this->naturalidade_id)));
     $this->inputsHelper()->simpleSearchMunicipio('nome', $options, $helperOptions);
     // Detalhes do Endereço
     if ($this->idlog) {
         $objLogradouro = new clsLogradouro($this->idlog);
         $detalheLogradouro = $objLogradouro->detalhe();
         if ($detalheLogradouro) {
             $this->municipio_id = $detalheLogradouro['idmun'];
         }
         // Caso seja um endereço externo, tentamos então recuperar a cidade pelo cep
     } elseif ($this->cep) {
         $numCep = idFederal2int($this->cep);
         $sql = "SELECT idmun, count(idmun) as count_mun FROM public.logradouro l, urbano.cep_logradouro cl \n              WHERE cl.idlog = l.idlog AND cl.cep = '{$numCep}' group by idmun order by count_mun desc limit 1";
         $options = array('return_only' => 'first-field');
         $result = Portabilis_Utils_Database::fetchPreparedQuery($sql, $options);
         if ($result) {
             $this->municipio_id = $result;
         }
     }
     if ($this->cod_pessoa_fj) {
         $objPE = new clsPessoaEndereco($this->cod_pessoa_fj);
         $det = $objPE->detalhe();
         if ($det) {
             $this->bairro_id = $det['idbai'];
             $this->logradouro_id = $det['idlog'];
         }
     }
     if (!($this->bairro_id && $this->municipio_id && $this->logradouro_id)) {
         $this->bairro_id = null;
         $this->municipio_id = null;
         $this->logradouro_id = null;
     }
     $this->campoOculto('idbai', $this->idbai);
     $this->campoOculto('idlog', $this->idlog);
     $this->campoOculto('cep', $this->cep);
     $this->campoOculto('ref_sigla_uf', $this->sigla_uf);
     $this->campoOculto('ref_idtlog', $this->idtlog);
     $this->campoOculto('id_cidade', $this->cidade);
     // o endereçamento é opcional
     $enderecamentoObrigatorio = false;
     // Caso o cep já esteja definido, os campos já vem desbloqueados inicialmente
     $desativarCamposDefinidosViaCep = empty($this->cep);
     $this->campoRotulo('', '<b> Endereçamento</b>', '', '', 'Digite um CEP ou clique na lupa para<br/> busca avançada para começar');
     $this->campoCep('cep_', 'CEP', $this->cep, $enderecamentoObrigatorio, '-', "&nbsp;<img id='lupa' src=\"imagens/lupa.png\" border=\"0\" onclick=\"showExpansivel(500, 550, '<iframe name=\\'miolo\\' id=\\'miolo\\' frameborder=\\'0\\' height=\\'100%\\' width=\\'500\\' marginheight=\\'0\\' marginwidth=\\'0\\' src=\\'educar_pesquisa_cep_log_bairro2.php?campo1=bairro&campo2=idbai&campo3=cep&campo4=logradouro&campo5=idlog&campo6=ref_sigla_uf&campo7=cidade&campo8=ref_idtlog&campo9=isEnderecoExterno&campo10=cep_&campo11=municipio_municipio&campo12=idtlog&campo13=municipio_id&campo14=zona_localizacao\\'></iframe>');\">", false);
     $options = array('label' => Portabilis_String_Utils::toLatin1('Município'), 'required' => $enderecamentoObrigatorio, 'disabled' => $desativarCamposDefinidosViaCep);
     $helperOptions = array('objectName' => 'municipio', 'hiddenInputOptions' => array('options' => array('value' => $this->municipio_id)));
     $this->inputsHelper()->simpleSearchMunicipio('municipio', $options, $helperOptions);
     $helperOptions = array('hiddenInputOptions' => array('options' => array('value' => $this->bairro_id)));
     $options = array('label' => Portabilis_String_Utils::toLatin1('Bairro / Zona de Localização - <b>Buscar</b>'), 'required' => $enderecamentoObrigatorio, 'disabled' => $desativarCamposDefinidosViaCep);
     $this->inputsHelper()->simpleSearchBairro('bairro', $options, $helperOptions);
     $options = array('label' => 'Bairro / Zona de Localização - <b>Cadastrar</b>', 'placeholder' => 'Bairro', 'value' => $this->bairro, 'max_length' => 40, 'disabled' => $desativarCamposDefinidosViaCep, 'inline' => true, 'required' => $enderecamentoObrigatorio);
     $this->inputsHelper()->text('bairro', $options);
     // zona localização
     $zonas = App_Model_ZonaLocalizacao::getInstance();
     $zonas = $zonas->getEnums();
     $zonas = Portabilis_Array_Utils::insertIn(null, 'Zona localização', $zonas);
     $options = array('label' => '', 'placeholder' => 'Zona localização ', 'value' => $this->zona_localizacao, 'disabled' => $desativarCamposDefinidosViaCep, 'resources' => $zonas, 'required' => $enderecamentoObrigatorio);
     $this->inputsHelper()->select('zona_localizacao', $options);
     $helperOptions = array('hiddenInputOptions' => array('options' => array('value' => $this->logradouro_id)));
     $options = array('label' => 'Tipo / Logradouro - <b>Buscar</b>', 'required' => $enderecamentoObrigatorio, 'disabled' => $desativarCamposDefinidosViaCep);
     $this->inputsHelper()->simpleSearchLogradouro('logradouro', $options, $helperOptions);
     // tipo logradouro
     $options = array('label' => 'Tipo / Logradouro - <b>Cadastrar</b>', 'value' => $this->idtlog, 'disabled' => $desativarCamposDefinidosViaCep, 'inline' => true, 'required' => $enderecamentoObrigatorio);
     $helperOptions = array('attrName' => 'idtlog');
     $this->inputsHelper()->tipoLogradouro($options, $helperOptions);
     // logradouro
     $options = array('label' => '', 'placeholder' => 'Logradouro', 'value' => $this->logradouro, 'max_length' => 150, 'disabled' => $desativarCamposDefinidosViaCep, 'required' => $enderecamentoObrigatorio);
     $this->inputsHelper()->text('logradouro', $options);
     // complemento
     $options = array('required' => false, 'value' => $this->complemento, 'max_length' => 20);
     $this->inputsHelper()->text('complemento', $options);
     // numero
     $options = array('required' => false, 'label' => 'Número / Letra', 'placeholder' => 'Número', 'value' => $this->numero, 'max_length' => 6, 'inline' => true);
     $this->inputsHelper()->integer('numero', $options);
     // letra
     $options = array('required' => false, 'label' => '', 'placeholder' => 'Letra', 'value' => $this->letra, 'max_length' => 1, 'size' => 15);
     $this->inputsHelper()->text('letra', $options);
     // apartamento
     $options = array('required' => false, 'label' => 'Nº apartamento / Bloco / Andar', 'placeholder' => 'Nº apartamento', 'value' => $this->apartamento, 'max_length' => 6, 'inline' => true);
     $this->inputsHelper()->integer('apartamento', $options);
     // bloco
     $options = array('required' => false, 'label' => '', 'placeholder' => 'Bloco', 'value' => $this->bloco, 'max_length' => 20, 'size' => 15, 'inline' => true);
     $this->inputsHelper()->text('bloco', $options);
     // andar
     $options = array('required' => false, 'label' => '', 'placeholder' => 'Andar', 'value' => $this->andar, 'max_length' => 2);
     $this->inputsHelper()->integer('andar', $options);
     // contato
     $this->inputTelefone('1', 'Telefone residencial');
     $this->inputTelefone('mov', 'Celular');
     $this->inputTelefone('2', 'Telefone adicional');
     $this->inputTelefone('fax', 'Fax');
     $this->campoTexto('email', 'E-mail', $this->email, '50', '255', FALSE);
     // after change pessoa pai / mae
     if ($parentType) {
         $this->inputsHelper()->hidden('parent_type', array('value' => $parentType));
     }
     $styles = array('/modules/Portabilis/Assets/Stylesheets/Frontend.css', '/modules/Portabilis/Assets/Stylesheets/Frontend/Resource.css', '/modules/Cadastro/Assets/Stylesheets/PessoaFisica.css');
     Portabilis_View_Helper_Application::loadStylesheet($this, $styles);
     $script = array('/modules/Cadastro/Assets/Javascripts/PessoaFisica.js', '/modules/Cadastro/Assets/Javascripts/Endereco.js');
     Portabilis_View_Helper_Application::loadJavascript($this, $script);
     $this->campoCep('cep_', 'CEP', $this->cep, $enderecamentoObrigatorio, '-', "&nbsp;<img id='lupa' src=\"imagens/lupa.png\" border=\"0\" onclick=\"showExpansivel(500, 550, '<iframe name=\\'miolo\\' id=\\'miolo\\' frameborder=\\'0\\' height=\\'100%\\' width=\\'500\\' marginheight=\\'0\\' marginwidth=\\'0\\' src=\\'educar_pesquisa_cep_log_bairro2.php?campo1=bairro_bairro&campo2=bairro_id&campo3=cep&campo4=logradouro_logradouro&campo5=logradouro_id&campo6=ref_sigla_uf&campo7=cidade&campo8=ref_idtlog&campo9=isEnderecoExterno&campo10=cep_&campo11=municipio_municipio&campo12=idtlog&campo13=municipio_id&campo14=zona_localizacao\\'></iframe>');\">", false);
 }
Ejemplo n.º 5
0
 $ref_idpes_responsavel = $det_fisica['idpes_responsavel'];
 $idpes_pai = $det_fisica['idpes_pai'];
 $idpes_mae = $det_fisica['idpes_mae'];
 $xml .= sprintf('<idpes_pai>%d</idpes_pai>', $idpes_pai) . PHP_EOL;
 $xml .= sprintf('<idpes_mae>%d</idpes_mae>', $idpes_mae) . PHP_EOL;
 $obj_aluno = new clsPmieducarAluno(NULL, NULL, NULL, NULL, NULL, $ref_idpes);
 $detalhe_aluno = $obj_aluno->detalhe();
 if ($detalhe_aluno) {
     $nm_pai = $detalhe_aluno['nm_pai'];
     $nm_mae = $detalhe_aluno['nm_mae'];
     $xml .= sprintf('<nm_pai>%s</nm_pai>', $nm_pai) . PHP_EOL;
     $xml .= sprintf('<nm_mae>%s</nm_mae>', $nm_mae) . PHP_EOL;
 }
 $obj_endereco = new clsPessoaEndereco($ref_idpes);
 $zona = NULL;
 if ($obj_endereco_det = $obj_endereco->detalhe()) {
     $isEnderecoExterno = 0;
     $id_cep = $obj_endereco_det['cep']->cep;
     $id_bairro = $obj_endereco_det['idbai']->idbai;
     $id_logradouro = $obj_endereco_det['idlog']->idlog;
     $numero = $obj_endereco_det['numero'];
     $letra = $obj_endereco_det['letra'];
     $complemento = $obj_endereco_det['complemento'];
     $andar = $obj_endereco_det['andar'];
     $apartamento = $obj_endereco_det['apartamento'];
     $bloco = $obj_endereco_det['bloco'];
     $ref_idtlog = $obj_endereco_det['idtlog'];
     $nm_bairro = $obj_endereco_det['bairro'];
     $nm_logradouro = $obj_endereco_det['logradouro'];
     $zona = $obj_endereco_det['zona_localizacao'];
     $cep_ = int2CEP($id_cep);
Ejemplo n.º 6
0
 function Gerar()
 {
     $this->fexcluir = FALSE;
     $this->campoTabInicio('educar_cad', '', TRUE);
     $this->campoOculto('retorno', $this->retorno);
     $this->campoOculto('bloqueado', 1);
     if (is_int((int) $this->cpf) && !empty($this->cpf)) {
         $cpf = int2CPF($this->cpf);
     } else {
         $cpf = $this->cpf;
     }
     if (!$this->cod_aluno) {
         $this->campoAdicionaTab('CPF', $this->tab_habilitado);
         $opcoes = array('' => 'Pesquise a pessoa clicando na lupa ao lado');
         $this->campoCpf('cpf_', 'CPF', $cpf, FALSE, '<img border="0" onclick="pesquisa_valores_popless(\'educar_pesquisa_aluno_lst2.php?campo1=ref_idpes&campo3=cpf&campo4=cpf_\', \'nome\')" src="imagens/lupa.png">');
     }
     $this->campoOculto('ref_idpes', $this->ref_idpes);
     $this->campoAdicionaTab('Dados Pessoais', $this->tab_habilitado);
     if ($this->cod_aluno) {
         $obj_matricula = new clsPmieducarMatricula();
         $lst_matricula = $obj_matricula->lista(NULL, NULL, NULL, NULL, NULL, NULL, $this->cod_aluno);
     }
     if (!empty($this->ref_idpes)) {
         $obj_aluno = new clsPmieducarAluno();
         $lista_aluno = $obj_aluno->lista(NULL, NULL, NULL, NULL, NULL, $this->ref_idpes, NULL, NULL, NULL, NULL);
         if ($lista_aluno) {
             $det_aluno = array_shift($lista_aluno);
         }
     }
     if ($det_aluno['cod_aluno']) {
         $this->cod_aluno = $det_aluno['cod_aluno'];
         $this->ref_cod_aluno_beneficio = $det_aluno['ref_cod_aluno_beneficio'];
         $this->ref_cod_religiao = $det_aluno['ref_cod_religiao'];
         $this->caminho_foto = $det_aluno['caminho_foto'];
     }
     $this->campoOculto('cod_aluno', $this->cod_aluno);
     $this->campoOculto('ref_idpes', $this->ref_idpes);
     if ($this->ref_idpes != 'NULL') {
         if ($this->ref_idpes) {
             $obj_pessoa = new clsPessoaFj($this->ref_idpes);
             $det_pessoa = $obj_pessoa->detalhe();
             $obj_fisica = new clsFisica($this->ref_idpes);
             $det_fisica = $obj_fisica->detalhe();
             $obj_fisica_raca = new clsCadastroFisicaRaca($this->ref_idpes);
             $det_fisica_raca = $obj_fisica_raca->detalhe();
             $this->ref_cod_raca = $det_fisica_raca['ref_cod_raca'];
             $this->nome = $det_pessoa['nome'];
             $this->email = $det_pessoa['email'];
             $this->ideciv = $det_fisica['ideciv']->ideciv;
             $this->data_nascimento = dataToBrasil($det_fisica['data_nasc']);
             $this->cpf = $det_fisica['cpf'];
             $obj_documento = new clsDocumento($this->ref_idpes);
             $obj_documento_det = $obj_documento->detalhe();
             $this->ddd_fone_1 = $det_pessoa['ddd_1'];
             $this->fone_1 = $det_pessoa['fone_1'];
             $this->ddd_fone_2 = $det_pessoa['ddd_2'];
             $this->fone_2 = $det_pessoa['fone_2'];
             $this->ddd_fax = $det_pessoa['ddd_fax'];
             $this->fone_fax = $det_pessoa['fone_fax'];
             $this->ddd_mov = $det_pessoa['ddd_mov'];
             $this->fone_mov = $det_pessoa['fone_mov'];
             $this->email = $det_pessoa['email'];
             $this->url = $det_pessoa['url'];
             $this->sexo = $det_fisica['sexo'];
             $this->nacionalidade = $det_fisica['nacionalidade'];
             $this->idmun_nascimento = $det_fisica['idmun_nascimento']->idmun;
             $detalhe_pais_origem = $det_fisica['idpais_estrangeiro']->detalhe();
             $this->pais_origem = $detalhe_pais_origem['idpais'];
             $this->ref_idpes_responsavel = $det_fisica['idpes_responsavel'];
             $this->idpes_pai = $det_fisica['idpes_pai'];
             $this->idpes_mae = $det_fisica['idpes_mae'];
             $obj_aluno = new clsPmieducarAluno(NULL, NULL, NULL, NULL, NULL, $this->ref_idpes);
             $detalhe_aluno = $obj_aluno->detalhe();
             if ($detalhe_aluno) {
                 $this->nm_pai = $detalhe_aluno['nm_pai'];
                 $this->nm_mae = $detalhe_aluno['nm_mae'];
             }
             $obj_endereco = new clsPessoaEndereco($this->ref_idpes);
             if ($obj_endereco_det = $obj_endereco->detalhe()) {
                 $this->isEnderecoExterno = 0;
                 $this->id_cep = $obj_endereco_det['cep']->cep;
                 $this->id_bairro = $obj_endereco_det['idbai']->idbai;
                 $this->id_logradouro = $obj_endereco_det['idlog']->idlog;
                 $this->numero = $obj_endereco_det['numero'];
                 $this->letra = $obj_endereco_det['letra'];
                 $this->complemento = $obj_endereco_det['complemento'];
                 $this->andar = $obj_endereco_det['andar'];
                 $this->apartamento = $obj_endereco_det['apartamento'];
                 $this->bloco = $obj_endereco_det['bloco'];
                 $this->ref_idtlog = $obj_endereco_det['idtlog'];
                 $this->nm_bairro = $obj_endereco_det['bairro'];
                 $this->nm_logradouro = $obj_endereco_det['logradouro'];
                 $this->cep_ = int2CEP($this->id_cep);
             } else {
                 $obj_endereco = new clsEnderecoExterno($this->ref_idpes);
                 if ($obj_endereco_det = $obj_endereco->detalhe()) {
                     $this->isEnderecoExterno = 1;
                     $this->id_cep = $obj_endereco_det['cep'];
                     $this->cidade = $obj_endereco_det['cidade'];
                     $this->nm_bairro = $obj_endereco_det['bairro'];
                     $this->nm_logradouro = $obj_endereco_det['logradouro'];
                     $this->id_bairro = NULL;
                     $this->id_logradouro = NULL;
                     $this->numero = $obj_endereco_det['numero'];
                     $this->letra = $obj_endereco_det['letra'];
                     $this->complemento = $obj_endereco_det['complemento'];
                     $this->andar = $obj_endereco_det['andar'];
                     $this->apartamento = $obj_endereco_det['apartamento'];
                     $this->bloco = $obj_endereco_det['bloco'];
                     $this->ref_idtlog = $this->idtlog = $obj_endereco_det['idtlog']->idtlog;
                     $this->ref_sigla_uf = $this->ref_sigla_uf_ = $obj_endereco_det['sigla_uf']->sigla_uf;
                     $this->cep_ = int2CEP($this->id_cep);
                 }
             }
             $this->zona_localizacao = $obj_endereco_det['zona_localizacao'];
         }
     }
     if ($this->isEnderecoExterno == 0) {
         $obj_bairro = new clsBairro($this->id_bairro);
         $this->cep_ = int2CEP($this->id_cep);
         $obj_bairro_det = $obj_bairro->detalhe();
         if ($obj_bairro_det) {
             $this->nm_bairro = $obj_bairro_det["nome"];
         }
         $obj_log = new clsLogradouro($this->id_logradouro);
         $obj_log_det = $obj_log->detalhe();
         if ($obj_log_det) {
             $this->nm_logradouro = $obj_log_det["nome"];
             $this->ref_idtlog = $obj_log_det["idtlog"]->idtlog;
             $obj_mun = new clsMunicipio($obj_log_det["idmun"]);
             $det_mun = $obj_mun->detalhe();
             if ($det_mun) {
                 $this->cidade = ucfirst(strtolower($det_mun["nome"]));
             }
             $this->ref_sigla_uf = $this->ref_sigla_uf_ = $det_mun['sigla_uf']->sigla_uf;
         }
         $obj_bairro = new clsBairro($obj_endereco_det["ref_idbai"]);
         $obj_bairro_det = $obj_bairro->detalhe();
         if ($obj_bairro_det) {
             $this->nm_bairro = $obj_bairro_det["nome"];
         }
     }
     $this->campoTexto('nome', 'Nome', $this->nome, 30, 100, TRUE);
     if ($this->cpf && $this->ref_idpes) {
         if (!$this->cpf) {
             $this->campoRotulo('cpf_2', 'CPF', $this->cpf);
         } else {
             $this->campoRotulo('cpf_2', 'CPF', int2CPF($this->cpf));
         }
     } else {
         if (!$this->cpf) {
             $this->campoCpf('cpf_2', 'CPF', $this->cpf);
             $this->campoOculto('sem_cpf', 1);
         } else {
             $this->campoCpf('cpf_2', 'CPF', int2CPF($this->cpf), FALSE);
         }
     }
     $this->campoData('data_nascimento', 'Data de Nascimento', $this->data_nascimento, TRUE);
     $lista = array('' => 'Selecione', 'F' => 'Feminino', 'M' => 'Masculino');
     $this->campoLista('sexo', 'Sexo', $lista, $this->sexo);
     $obj_estado_civil = new clsEstadoCivil();
     $obj_estado_civil_lista = $obj_estado_civil->lista();
     $lista_estado_civil = array('' => 'Selecione');
     if ($obj_estado_civil_lista) {
         foreach ($obj_estado_civil_lista as $estado_civil) {
             $lista_estado_civil[$estado_civil['ideciv']] = $estado_civil['descricao'];
         }
     }
     $this->campoLista('ideciv', 'Estado Civil', $lista_estado_civil, $this->ideciv);
     $obj_religiao = new clsPmieducarReligiao();
     $obj_religia_lista = $obj_religiao->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1);
     $lista_religiao = array('NULL' => 'Selecione');
     if ($obj_religia_lista) {
         foreach ($obj_religia_lista as $religiao) {
             $lista_religiao[$religiao["cod_religiao"]] = $religiao["nm_religiao"];
         }
     }
     $this->campoLista('ref_cod_religiao', 'Religi&atilde;o', $lista_religiao, $this->ref_cod_religiao, '', FALSE, '', '', '', FALSE);
     $opcoes_raca = array('' => 'Selecione');
     $obj_raca = new clsCadastroRaca();
     $lst_raca = $obj_raca->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL, TRUE);
     if ($lst_raca) {
         foreach ($lst_raca as $raca) {
             $opcoes_raca[$raca['cod_raca']] = $raca['nm_raca'];
         }
     }
     $this->campoLista('ref_cod_raca', 'Ra&ccedil;a', $opcoes_raca, $this->ref_cod_raca, '', FALSE, '', '', '', FALSE);
     $this->campoQuebra2('#224488');
     if ($this->idpes_pai) {
         $obj_pessoa_pai = new clsPessoaFj($this->idpes_pai);
         $det_pessoa_pai = $obj_pessoa_pai->detalhe();
         if ($det_pessoa_pai) {
             $this->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) {
             $this->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']);
             }
         }
     }
     $this->campoTexto('nm_pai', 'Nome do Pai', $this->nm_pai, 30, 255, FALSE);
     $this->campoCpf('cpf_pai', 'CPF pai', $this->cpf_pai, FALSE, $this->cpf_pai ? '' : ' &nbsp; &nbsp; (preencher sempre que possível)');
     $this->campoTexto('nm_mae', 'Nome da M&atilde;e', $this->nm_mae, 30, 255, FALSE);
     $this->campoCpf('cpf_mae', 'CPF mãe', $this->cpf_mae, FALSE, $this->cpf_mae ? '' : ' &nbsp; &nbsp; (preencher sempre que possível)');
     $lista = array('' => 'Responsável');
     if ($this->ref_idpes_responsavel != 'NULL') {
         $obj_pessoa_resp = new clsPessoaFj($this->ref_idpes_responsavel);
         $det_pessoa_resp = $obj_pessoa_resp->detalhe();
         if ($det_pessoa_resp) {
             $lista[$det_pessoa_resp['idpes']] = $det_pessoa_resp['nome'];
         }
     }
     $parametros = new clsParametrosPesquisas();
     $parametros->setSubmit(0);
     $parametros->adicionaCampoSelect('ref_idpes_responsavel', 'idpes', 'nome');
     $parametros->setPessoa('F');
     $parametros->setPessoaNovo('S');
     $parametros->setPessoaCPF('N');
     $parametros->setPessoaTela('frame');
     $parametros->setCodSistema(1);
     $this->campoListaPesq('ref_idpes_responsavel', 'Responsavel', $lista, $this->ref_idpes_responsavel, 'pesquisa_pessoa_lst.php', '', FALSE, '', '', NULL, NULL, '', FALSE, $parametros->serializaCampos(), FALSE);
     $this->campoQuebra2('#224488');
     if ($this->tipo_responsavel) {
         if ($this->nm_pai) {
             $this->tipo_responsavel = 'p';
         } elseif ($this->nm_mae) {
             $this->tipo_responsavel = 'm';
         } elseif ($this->ref_idpes_responsavel) {
             $this->tipo_responsavel = 'r';
         }
     }
     $opcoes = array('p' => 'Pai', 'm' => 'M&atilde;e', 'r' => 'Respons&aacute;vel');
     $this->campoRadio('tipo_responsavel', 'Respons&aacute;vel', $opcoes, $this->tipo_responsavel);
     $this->campoQuebra2('#224488');
     $disabled = $this->isEnderecoExterno ? FALSE : TRUE;
     $this->campoOculto('isEnderecoExterno', $this->isEnderecoExterno);
     $urlPesquisaCep = 'educar_pesquisa_cep_log_bairro.php?' . 'campo1=nm_bairro&campo2=id_bairro&campo3=id_cep&campo4=nm_logradouro&' . 'campo5=id_logradouro&campo6=ref_sigla_uf&campo7=cidade&' . 'campo8=ref_idtlog_&campo9=isEnderecoExterno&campo10=cep_&' . 'campo11=ref_sigla_uf_&campo12=ref_idtlog&campo13=id_cidade&' . 'campo14=zona_localizacao';
     $urlPesquisaCep = sprintf("<img id='lupa' src=\"imagens/lupa.png\" border=\"0\" onclick=\"showExpansivel( 500,500, '<iframe name=\\'miolo\\' id=\\'miolo\\' frameborder=\\'0\\' height=\\'100%%\\' width=\\'500\\' marginheight=\\'0\\' marginwidth=\\'0\\' src=\\'%s\\'></iframe>');\">", $urlPesquisaCep);
     $this->campoCep('cep_', 'CEP', $this->cep_, TRUE, '-', $urlPesquisaCep, $disabled);
     $this->campoTexto('cidade', 'Cidade', $this->cidade, 30, 255, TRUE, FALSE, TRUE, '', '', '', '', $disabled);
     $obj_uf = new clsUf(FALSE, FALSE, 1);
     $lst_uf = $obj_uf->lista(FALSE, FALSE, FALSE, FALSE, FALSE, 'sigla_uf');
     $array_uf = array('' => 'Selecione um estado');
     foreach ($lst_uf as $uf) {
         $array_uf[$uf['sigla_uf']] = $uf['nome'];
     }
     $this->campoLista('ref_sigla_uf_', ' &nbsp; Estado', $array_uf, $this->ref_sigla_uf, '', FALSE, '', '', $disabled);
     $this->campoTexto('nm_bairro', 'Bairro', $this->nm_bairro, 30, 255, TRUE, FALSE, FALSE, '', '', '', '', $disabled);
     $tipo_logradouro_array = array('' => 'Tipo de Logradouro');
     $obj_tipo_logradouro = new clsTipoLogradouro();
     $obj_tipo_logradouro_lista = $obj_tipo_logradouro->lista();
     if ($obj_tipo_logradouro_lista) {
         foreach ($obj_tipo_logradouro_lista as $key => $tipo_log) {
             $tipo_logradouro_array[$tipo_log["idtlog"]] = $tipo_log["descricao"];
         }
     }
     $this->campoLista('ref_idtlog', 'Logradouro', $tipo_logradouro_array, $this->ref_idtlog, '', TRUE, '', '', $this->isEnderecoExterno ? FALSE : TRUE, TRUE);
     $this->campoTexto('nm_logradouro', 'Logradouro', $this->nm_logradouro, 30, 255, TRUE, FALSE, FALSE, '', '', '', '', $disabled);
     $zl = App_Model_ZonaLocalizacao::getInstance();
     $this->campoLista('zona_localizacao', 'Zona Localização', $zl->getEnums(), $this->zona_localizacao, FALSE, FALSE, FALSE, FALSE, $disabled);
     $this->campoNumero('numero', 'N&uacute;mero', $this->numero, 4, 6, FALSE, '', '', FALSE, FALSE, TRUE);
     $this->campoTexto('letra', ' &nbsp; Letra', $this->letra, 4, 1, FALSE);
     $this->campoTexto('complemento', 'Complemento', $this->complemento, 30, 50, FALSE);
     $this->campoTexto('bloco', 'Bloco', $this->bloco, 30, 50, FALSE);
     $this->campoNumero('andar', 'Andar', $this->andar, 4, 2, FALSE, '', '', FALSE, FALSE, TRUE);
     $this->campoNumero('apartamento', ' &nbsp; Apartamento', $this->apartamento, 4, 6, FALSE);
     $this->campoLista('nacionalidade', 'Nacionalidade', $lista_nacionalidade, $this->nacionalidade, 'tmpObj = document.getElementById("pais_origem"); if(this.value != 1) { tmpObj.disabled = false; } else { tmpObj.selectedIndex = 27; tmpObj.disabled = true; }', TRUE, '', '', '', FALSE);
     $lista_mun_nasc = array('NULL' => 'Selecione a cidade');
     $obj_mun_nasc = new clsMunicipio($this->idmun_nascimento);
     $det_mun_nasc = $obj_mun_nasc->detalhe();
     if ($det_mun_nasc["nome"]) {
         $lista_mun_nasc[$det_mun_nasc["idmun"]] = $det_mun_nasc["nome"];
     }
     $this->campoListaPesq('idmun_nascimento', 'Naturalidade', $lista_mun_nasc, $this->idmun_nascimento, 'educar_pesquisa_municipio_lst.php?campo1=idmun_nascimento', '', FALSE, '', '', NULL, NULL, '', TRUE);
     $this->nacionalidade = $this->nacionalidade ? $this->nacionalidade : 1;
     $lista_nacionalidade = array('NULL' => 'Selecione', '1' => 'Brasileiro', '2' => 'Naturalizado Brasileiro', '3' => 'Estrangeiro');
     $this->campoLista('nacionalidade', 'Nacionalidade', $lista_nacionalidade, $this->nacionalidade, 'tmpObj = document.getElementById("pais_origem"); if(this.value != 1) { tmpObj.disabled = false; } else { tmpObj.selectedIndex = 27; tmpObj.disabled = true; }', TRUE, '', '', '', FALSE);
     $lista_pais_origem = array('NULL' => 'País de origem');
     $obj_pais = new clsPais();
     $obj_pais_lista = $obj_pais->lista(NULL, NULL, NULL, '', '', 'nome asc');
     if ($obj_pais_lista) {
         foreach ($obj_pais_lista as $key => $pais) {
             $lista_pais_origem[$pais['idpais']] = $pais['nome'];
         }
     }
     // se a nacionalidade for "BRASILEIRO" seleciona o brasil e deixa inativo
     $this->pais_origem = $this->nacionalidade == 1 ? 1 : $this->pais_origem;
     $this->campoLista('pais_origem', ' &nbsp; País de Origem', $lista_pais_origem, $this->pais_origem, '', '', '', '', $this->nacionalidade == 1, FALSE);
     $this->campoQuebra2('#224488');
     // Transporte escolar
     $transporteMapper = new Transporte_Model_AlunoDataMapper();
     $transporte = NULL;
     try {
         $transporte = $transporteMapper->find(array($this->cod_aluno));
     } catch (Exception $e) {
     }
     $bit = App_Model_SimNao::getInstance();
     $this->campoLista('transporte_aluno', 'Transporte', $bit->getEnums(), !is_null($transporte) ? 1 : 0, 'transporteResponsavel();');
     $responsavel = Transporte_Model_Responsavel::getInstance();
     $this->campoLista('transporte_responsavel', 'Responsável', $responsavel->getEnums(), !is_null($transporte) ? $transporte->get('responsavel') : 0);
     $this->campoQuebra2('#224488');
     $obj_beneficio = new clsPmieducarAlunoBeneficio();
     $obj_beneficio_lista = $obj_beneficio->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1);
     $lista_beneficio = array('NULL' => 'Selecione');
     if ($obj_beneficio_lista) {
         foreach ($obj_beneficio_lista as $beneficio) {
             $lista_beneficio[$beneficio['cod_aluno_beneficio']] = $beneficio['nm_beneficio'];
         }
     }
     $this->campoLista('ref_cod_aluno_beneficio', 'Benef&iacute;cio', $lista_beneficio, $this->ref_cod_aluno_beneficio, '', FALSE, '', '', FALSE, FALSE);
     $lista_analfabeto = array(1 => 'N&atilde;o', 0 => 'Sim');
     $this->campoLista('analfabeto', 'Alfabetizado', $lista_analfabeto, $this->analfabeto, '', FALSE, '', '', FALSE, FALSE);
     $this->campoNumero('ddd_fone_1', 'Telefone', $this->ddd_fone_1, 1, 3, FALSE, '', '', FALSE, FALSE, TRUE);
     $this->campoNumero('fone_1', 'Telefone', $this->fone_1, 11, 11);
     $this->campoNumero('ddd_mov', 'Celular', $this->ddd_mov, 1, 3, FALSE, '', '', FALSE, FALSE, TRUE);
     $this->campoNumero('fone_mov', 'Celular', $this->fone_mov, 11, 11);
     $this->campoEmail('email', 'Email', $this->email, 30, 255, FALSE);
     if (!empty($this->caminho_foto)) {
         $this->campoRotulo('foto_antiga_', 'Arquivo', sprintf('
       <img src="arquivos/educar/aluno/small/%s" border="0">
         <a href="javascript:void(0);" onclick="document.getElementById(\'foto_excluida\').value=1; setVisibility(\'tr_foto_antiga_\', false); setVisibility(\'tr_foto\', true);"><img src="imagens/nvp_bola_xis.gif" border="0"></a>', $this->caminho_foto));
     }
     $this->campoOculto('foto_excluida', 0);
     $this->campoArquivo('foto', 'Foto', '', '20', '', FALSE);
     $this->campoOculto('id_bairro', $this->id_bairro);
     $this->campoOculto('id_cep', $this->id_cep);
     $this->campoOculto('id_logradouro', $this->id_logradouro);
     $this->campoOculto('id_cidade', $this->id_cidade);
     $this->campoOculto('ref_idtlog_', $this->ref_idtlog);
     $this->campoOculto('ref_sigla_uf', $this->ref_sigla_uf);
     $this->campoTexto('nome', 'Nome', $this->nome, 30, 100, TRUE);
     if ($this->cpf && $this->ref_idpes) {
         if (!$this->cpf) {
             $this->campoRotulo('cpf_2', 'CPF', $this->cpf);
         } else {
             $this->campoRotulo('cpf_2', 'CPF', int2CPF($this->cpf));
         }
     } else {
         if (!$this->cpf) {
             $this->campoOculto('sem_cpf', 1);
         }
     }
     $this->campoData('data_nascimento', 'Data de Nascimento', $this->data_nascimento, TRUE);
     $lista = array('' => 'Selecione', 'F' => 'Feminino', 'M' => 'Masculino');
     $this->campoLista('sexo', 'Sexo', $lista, $this->sexo);
     $obj_estado_civil = new clsEstadoCivil();
     $obj_estado_civil_lista = $obj_estado_civil->lista();
     $lista_estado_civil = array('' => 'Selecione');
     if ($obj_estado_civil_lista) {
         foreach ($obj_estado_civil_lista as $estado_civil) {
             $lista_estado_civil[$estado_civil['ideciv']] = $estado_civil['descricao'];
         }
     }
     $this->campoLista('ideciv', 'Estado Civil', $lista_estado_civil, $this->ideciv);
     $obj_religiao = new clsPmieducarReligiao();
     $obj_religia_lista = $obj_religiao->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1);
     $lista_religiao = array('NULL' => 'Selecione');
     if ($obj_religia_lista) {
         foreach ($obj_religia_lista as $religiao) {
             $lista_religiao[$religiao['cod_religiao']] = $religiao['nm_religiao'];
         }
     }
     $this->campoLista('ref_cod_religiao', 'Religi&atilde;o', $lista_religiao, $this->ref_cod_religiao, '', FALSE, '', '', '', FALSE);
     $opcoes_raca = array('' => 'Selecione');
     $obj_raca = new clsCadastroRaca();
     $lst_raca = $obj_raca->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL, TRUE);
     if ($lst_raca) {
         foreach ($lst_raca as $raca) {
             $opcoes_raca[$raca['cod_raca']] = $raca['nm_raca'];
         }
     }
     $this->campoLista('ref_cod_raca', 'Ra&ccedil;a', $opcoes_raca, $this->ref_cod_raca, '', FALSE, '', '', '', FALSE);
     $this->campoQuebra2('#224488');
     if ($this->idpes_pai) {
         $obj_pessoa_pai = new clsPessoaFj($this->idpes_pai);
         $det_pessoa_pai = $obj_pessoa_pai->detalhe();
         if ($det_pessoa_pai) {
             $this->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) {
             $this->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']);
             }
         }
     }
     $this->campoTexto('nm_pai', 'Nome do Pai', $this->nm_pai, 30, 255, FALSE);
     $this->campoCpf('cpf_pai', 'CPF pai', $this->cpf_pai, FALSE, $this->cpf_pai ? '' : ' &nbsp; &nbsp; (preencher sempre que possível)');
     $this->campoTexto('nm_mae', 'Nome da M&atilde;e', $this->nm_mae, 30, 255, FALSE);
     $this->campoCpf('cpf_mae', 'CPF mãe', $this->cpf_mae, FALSE, $this->cpf_mae ? '' : ' &nbsp; &nbsp; (preencher sempre que possível)');
     $lista = array('' => 'Responsável');
     if ($this->ref_idpes_responsavel != 'NULL') {
         $obj_pessoa_resp = new clsPessoaFj($this->ref_idpes_responsavel);
         $det_pessoa_resp = $obj_pessoa_resp->detalhe();
         if ($det_pessoa_resp) {
             $lista[$det_pessoa_resp['idpes']] = $det_pessoa_resp['nome'];
         }
     }
     $parametros = new clsParametrosPesquisas();
     $parametros->setSubmit(0);
     $parametros->adicionaCampoSelect('ref_idpes_responsavel', 'idpes', 'nome');
     $parametros->setPessoa('F');
     $parametros->setPessoaNovo('S');
     $parametros->setPessoaCPF('N');
     $parametros->setPessoaTela('frame');
     $parametros->setCodSistema(1);
     $this->campoListaPesq('ref_idpes_responsavel', 'Responsavel', $lista, $this->ref_idpes_responsavel, 'pesquisa_pessoa_lst.php', '', FALSE, '', '', NULL, NULL, '', FALSE, $parametros->serializaCampos(), FALSE);
     $this->campoQuebra2('#224488');
     if (!$this->tipo_responsavel) {
         if ($this->nm_pai) {
             $this->tipo_responsavel = 'p';
         } elseif ($this->nm_mae) {
             $this->tipo_responsavel = 'm';
         } elseif ($this->ref_idpes_responsavel) {
             $this->tipo_responsavel = 'r';
         }
     }
     $opcoes = array('' => 'Sem Responsável', 'p' => 'Pai', 'm' => 'M&atilde;e', 'r' => 'Respons&aacute;vel');
     $this->campoRadio('tipo_responsavel', 'Respons&aacute;vel', $opcoes, $this->tipo_responsavel);
     $this->campoQuebra2('#224488');
     $disabled = $this->isEnderecoExterno ? FALSE : TRUE;
     $this->campoOculto('isEnderecoExterno', $this->isEnderecoExterno);
     $this->campoCep('cep_', 'CEP', $this->cep_, TRUE, '-', $urlPesquisaCep, $disabled);
     $this->campoTexto('cidade', 'Cidade', $this->cidade, 30, 255, TRUE, FALSE, TRUE, '', '', '', '', $disabled);
     $obj_uf = new clsUf(FALSE, FALSE, 1);
     $lst_uf = $obj_uf->lista(FALSE, FALSE, FALSE, FALSE, FALSE, 'sigla_uf');
     $array_uf = array('' => 'Selecione um estado');
     foreach ($lst_uf as $uf) {
         $array_uf[$uf['sigla_uf']] = $uf['nome'];
     }
     $this->campoLista('ref_sigla_uf_', ' &nbsp; Estado', $array_uf, $this->ref_sigla_uf, '', FALSE, '', '', $disabled);
     $this->campoTexto('nm_bairro', 'Bairro', $this->nm_bairro, 30, 255, TRUE, FALSE, FALSE, '', '', '', '', $disabled);
     $tipo_logradouro_array = array('' => 'Tipo de Logradouro');
     $obj_tipo_logradouro = new clsTipoLogradouro();
     $obj_tipo_logradouro_lista = $obj_tipo_logradouro->lista();
     if ($obj_tipo_logradouro_lista) {
         foreach ($obj_tipo_logradouro_lista as $key => $tipo_log) {
             $tipo_logradouro_array[$tipo_log['idtlog']] = $tipo_log['descricao'];
         }
     }
     $this->campoLista('ref_idtlog', 'Logradouro', $tipo_logradouro_array, $this->ref_idtlog, '', TRUE, '', '', $this->isEnderecoExterno ? FALSE : TRUE, TRUE);
     $this->campoTexto('nm_logradouro', 'Logradouro', $this->nm_logradouro, 30, 255, TRUE, FALSE, FALSE, '', '', '', '', $disabled);
     $this->campoNumero('numero', 'N&uacute;mero', $this->numero, 4, 6, FALSE, '', '', FALSE, FALSE, TRUE);
     $this->campoTexto('letra', ' &nbsp; Letra', $this->letra, 4, 1, FALSE);
     $this->campoTexto('complemento', 'Complemento', $this->complemento, 30, 50, FALSE);
     $this->campoTexto('bloco', 'Bloco', $this->bloco, 30, 50, FALSE);
     $this->campoNumero('andar', 'Andar', $this->andar, 4, 2, FALSE, '', '', FALSE, FALSE, TRUE);
     $this->campoNumero('apartamento', ' &nbsp; Apartamento', $this->apartamento, 4, 6, FALSE);
     $lista_mun_nasc = array('NULL' => 'Selecione a cidade');
     $obj_mun_nasc = new clsMunicipio($this->idmun_nascimento);
     $det_mun_nasc = $obj_mun_nasc->detalhe();
     if ($det_mun_nasc['nome']) {
         $lista_mun_nasc[$det_mun_nasc['idmun']] = $det_mun_nasc['nome'];
     }
     $this->campoListaPesq('idmun_nascimento', 'Naturalidade', $lista_mun_nasc, $this->idmun_nascimento, 'educar_pesquisa_municipio_lst.php?campo1=idmun_nascimento', '', FALSE, '', '', NULL, NULL, '', TRUE);
     $this->nacionalidade = $this->nacionalidade ? $this->nacionalidade : 1;
     $lista_nacionalidade = array('NULL' => 'Selecione', '1' => 'Brasileiro', '2' => 'Naturalizado Brasileiro', '3' => 'Estrangeiro');
     $this->campoLista('nacionalidade', 'Nacionalidade', $lista_nacionalidade, $this->nacionalidade, "tmpObj = document.getElementById('pais_origem'); if (this.value!=1) { tmpObj.disabled = false; } else { tmpObj.selectedIndex = 27; tmpObj.disabled = true; }", TRUE, '', '', '', FALSE);
     $lista_pais_origem = array('NULL' => 'País de origem');
     $obj_pais = new clsPais();
     $obj_pais_lista = $obj_pais->lista(null, null, null, '', '', 'nome asc');
     if ($obj_pais_lista) {
         foreach ($obj_pais_lista as $key => $pais) {
             $lista_pais_origem[$pais['idpais']] = $pais['nome'];
         }
     }
     // se a nacionalidade for "BRASILEIRO" seleciona o brasil e deixa inativo
     $this->pais_origem = $this->nacionalidade == 1 ? 1 : $this->pais_origem;
     $this->campoLista('pais_origem', ' &nbsp; País de Origem', $lista_pais_origem, $this->pais_origem, '', '', '', '', $this->nacionalidade == 1, FALSE);
     $this->campoQuebra2('#224488');
     $obj_beneficio = new clsPmieducarAlunoBeneficio();
     $obj_beneficio_lista = $obj_beneficio->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1);
     $lista_beneficio = array('NULL' => "Selecione");
     if ($obj_beneficio_lista) {
         foreach ($obj_beneficio_lista as $beneficio) {
             $lista_beneficio[$beneficio['cod_aluno_beneficio']] = $beneficio['nm_beneficio'];
         }
     }
     $this->campoLista('ref_cod_aluno_beneficio', 'Benef&iacute;cio', $lista_beneficio, $this->ref_cod_aluno_beneficio, '', FALSE, '', '', FALSE, FALSE);
     $lista_analfabeto = array(1 => 'N&atilde;o', 0 => 'Sim');
     $this->campoLista('analfabeto', 'Alfabetizado', $lista_analfabeto, $this->analfabeto, '', FALSE, '', '', FALSE, FALSE);
     $this->campoNumero('ddd_fone_1', 'Telefone', $this->ddd_fone_1, 1, 3, FALSE, '', '', FALSE, FALSE, TRUE);
     $this->campoNumero('fone_1', 'Telefone', $this->fone_1, 11, 11);
     $this->campoNumero('ddd_mov', 'Celular', $this->ddd_mov, 1, 3, FALSE, '', '', FALSE, FALSE, TRUE);
     $this->campoNumero('fone_mov', 'Celular', $this->fone_mov, 11, 11);
     $this->campoEmail('email', 'Email', $this->email, 30, 255, FALSE);
     if (!empty($this->caminho_foto)) {
         $this->campoRotulo('foto_antiga_', 'Arquivo', sprintf('<img src="arquivos/educar/aluno/small/%s" border="0"> <a href="javascript:void(0);" onclick="document.getElementById(\'foto_excluida\').value=1; setVisibility(\'tr_foto_antiga_\', false); setVisibility(\'tr_foto\',true);"> <img src="imagens/nvp_bola_xis.gif" border="0"></a>', $this->caminho_foto));
     }
     $this->campoArquivo('foto', 'Foto', '', '20', '', FALSE);
     $this->campoOculto('id_bairro', $this->id_bairro);
     $this->campoOculto('id_cep', $this->id_cep);
     $this->campoOculto('id_logradouro', $this->id_logradouro);
     $this->campoOculto('id_cidade', $this->id_cidade);
     $this->campoOculto('ref_idtlog_', $this->ref_idtlog);
     $this->campoOculto('ref_sigla_uf', $this->ref_sigla_uf);
     $this->campoOculto('cpf', $this->cpf);
     $this->campoAdicionaTab('Deficiência', $this->tab_habilitado);
     if ($this->ref_idpes) {
         $obj_deficiencia_pessoa = new clsCadastroFisicaDeficiencia();
         $obj_deficiencia_pessoa_lista = $obj_deficiencia_pessoa->lista($this->ref_idpes);
     }
     if ($this->inc != 2 && !$this->exc) {
         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'];
             }
             $deficiencia_aluno = array();
             $deficiencia_aluno = $deficiencia_pessoa;
         }
     }
     $obj_deficiencias = new clsCadastroDeficiencia();
     $lista_deficiencias = $obj_deficiencias->lista();
     $lista = array('' => 'Selecione');
     if ($lista_deficiencias) {
         foreach ($lista_deficiencias as $deficiencia) {
             $lista[$deficiencia['cod_deficiencia']] = $deficiencia['nm_deficiencia'];
         }
     }
     $oculto = $tabela = '';
     if ($deficiencia_aluno) {
         foreach ($deficiencia_aluno as $indice => $valor) {
             $cor_fundo = $cor_fundo == '#D1DADF' ? '#E4E9ED' : '#D1DADF';
             $tabela .= "<tr id=\"tr_{$indice}\" bgcolor=\"{$cor_fundo}\" style=\"padding-right: 10px;\">";
             $tabela .= "<td>{$valor}</td>";
             $tabela .= "<td align=\"right\" style=\"padding-right: 10px;\">";
             $tabela .= "<img border=\"0\" onclick=\"excluirLinhaDeficiencia({$indice})\"\n                      style=\"cursor: pointer;\" src=\"imagens/banco_imagens/excluirrr.gif\"\n                      title=\"Excluir\">";
             $tabela .= "</td></tr>";
             $oculto .= "<input type=\"hidden\" id=\"oc_defic[{$indice}]\" name=\"oc_defic[{$indice}]\" value=\"{$indice}\">";
         }
     }
     $this->campoLista('ref_cod_pessoa_deficiencia', 'Defici&ecirc;ncia', $lista, $this->ref_cod_pessoa_deficiencia, '', FALSE, '', '', FALSE, $obrigatorio);
     $this->campoRotulo('incluir2', 'Incluir defici&ecirc;ncia', "<a href='#' onclick=\"adicionaDeficiencia();\"><img src='imagens/banco_imagens/entrada2.gif' title='Incluir' border=0></a>");
     $this->campoRotulo("tab_defic", "Deficiências", "<table id='tabela_deficiencia' cellspacing='0' cellpadding='2'><tbody>{$tabela}</tbody></table><div id='ocultos_defic'>{$oculto}</div>");
     $this->campoOculto('inc', '');
     $this->campoOculto('exc', '');
     $this->campoAdicionaTab('Outros Dados', $this->tab_habilitado);
     if ($this->ref_idpes) {
         $ObjDocumento = new clsDocumento($this->ref_idpes);
         $detalheDocumento = $ObjDocumento->detalhe();
         $this->rg = $detalheDocumento['rg'];
         if ($detalheDocumento['data_exp_rg']) {
             $this->data_exp_rg = date('d/m/Y', strtotime(substr($detalheDocumento['data_exp_rg'], 0, 19)));
         }
         $this->sigla_uf_exp_rg = $detalheDocumento['sigla_uf_exp_rg'];
         $this->tipo_cert_civil = $detalheDocumento['tipo_cert_civil'];
         $this->num_termo = $detalheDocumento['num_termo'];
         $this->num_livro = $detalheDocumento['num_livro'];
         $this->num_folha = $detalheDocumento['num_folha'];
         if ($detalheDocumento['data_emissao_cert_civil']) {
             $this->data_emissao_cert_civil = date('d/m/Y', strtotime(substr($detalheDocumento['data_emissao_cert_civil'], 0, 19)));
         }
         $this->sigla_uf_cert_civil = $detalheDocumento['sigla_uf_cert_civil'];
         $this->cartorio_cert_civil = $detalheDocumento['cartorio_cert_civil'];
         $this->num_cart_trabalho = $detalheDocumento['num_cart_trabalho'];
         $this->serie_cart_trabalho = $detalheDocumento['serie_cart_trabalho'];
         if ($detalheDocumento['data_emissao_cart_trabalho']) {
             $this->data_emissao_cart_trabalho = date("d/m/Y", strtotime(substr($detalheDocumento['data_emissao_cart_trabalho'], 0, 19)));
         }
         $this->sigla_uf_cart_trabalho = $detalheDocumento['sigla_uf_cart_trabalho'];
         $this->num_tit_eleitor = $detalheDocumento['num_tit_eleitor'];
         $this->zona_tit_eleitor = $detalheDocumento['zona_tit_eleitor'];
         $this->secao_tit_eleitor = $detalheDocumento['secao_tit_eleitor'];
         $this->idorg_exp_rg = $detalheDocumento['idorg_exp_rg'];
     }
     $objUf = new clsUf();
     $listauf = $objUf->lista();
     $listaEstado = array('0' => 'Selecione');
     if ($listauf) {
         foreach ($listauf as $uf) {
             $listaEstado[$uf['sigla_uf']] = $uf['sigla_uf'];
         }
     }
     $objOrgaoEmissorRg = new clsOrgaoEmissorRg();
     $listaOrgaoEmissorRg = $objOrgaoEmissorRg->lista();
     $listaOrgao = array('0' => 'Selecione');
     if ($listaOrgaoEmissorRg) {
         foreach ($listaOrgaoEmissorRg as $orgaoemissor) {
             $listaOrgao[$orgaoemissor['idorg_rg']] = $orgaoemissor['sigla'];
         }
     }
     $this->campoOculto('idpes', $this->idpes);
     $this->campoTexto('rg', 'Rg', $this->rg, '10', '10', FALSE);
     $this->campoData('data_exp_rg', 'Data Expedição RG', $this->data_exp_rg, FALSE);
     $this->campoLista('idorg_exp_rg', 'Órgão Expedição RG', $listaOrgao, $this->idorg_exp_rg, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE);
     $this->campoLista('sigla_uf_exp_rg', 'Estado Expedidor', $listaEstado, $this->sigla_uf_exp_rg, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE);
     $lista_tipo_cert_civil = array();
     $lista_tipo_cert_civil['0'] = 'Selecione';
     $lista_tipo_cert_civil[91] = 'Nascimento';
     $lista_tipo_cert_civil[92] = 'Casamento';
     $this->campoLista('tipo_cert_civil', 'Tipo Certificado Civil', $lista_tipo_cert_civil, $this->tipo_cert_civil, NULL, NULL, NULL, NULL, NULL, FALSE);
     $this->campoTexto('num_termo', 'Termo', $this->num_termo, '8', '8', FALSE);
     $this->campoTexto('num_livro', 'Livro', $this->num_livro, '8', '8', FALSE);
     $this->campoTexto('num_folha', 'Folha', $this->num_folha, '4', '4', FALSE);
     $this->campoData('data_emissao_cert_civil', 'Emissão Certidão Civil', $this->data_emissao_cert_civil, FALSE);
     $this->campoLista('sigla_uf_cert_civil', 'Sigla Certidão Civil', $listaEstado, $this->sigla_uf_cert_civil, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE);
     $this->campoMemo('cartorio_cert_civil', 'Cartório', $this->cartorio_cert_civil, '35', '4', FALSE, FALSE);
     $this->campoTexto('num_tit_eleitor', 'Título de Eleitor', $this->num_tit_eleitor, '13', '13', FALSE);
     $this->campoTexto('zona_tit_eleitor', 'Zona', $this->zona_tit_eleitor, '4', '4', FALSE);
     $this->campoTexto('secao_tit_eleitor', 'Seção', $this->secao_tit_eleitor, '10', '10', FALSE);
     // 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->campoAdicionaTab('Educacenso/Inep', $this->tab_habilitado);
             $this->campoRotulo('_inep_cod_aluno', 'Código do aluno no Educacenso/Inep', $alunoInep->alunoInep);
             if (isset($alunoInep->nomeInep)) {
                 $this->campoRotulo('_inep_nome_aluno', 'Nome do aluno no Educacenso/Inep', $alunoInep->nomeInep);
             }
         }
     }
     $this->campoTabFim();
 }
Ejemplo n.º 7
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;
 }
Ejemplo n.º 8
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;
 }
Ejemplo n.º 9
0
 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;
 }
Ejemplo n.º 10
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%';
 }
Ejemplo n.º 11
0
 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;
 }
Ejemplo n.º 12
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;
 }