示例#1
0
 function Gerar()
 {
     $obj_permissoes = new clsPermissoes();
     //		echo "<pre>";print_r($_POST);die;
     if (!$this->sem_cnpj && !$this->com_cnpj) {
         $parametros = new clsParametrosPesquisas();
         $parametros->setSubmit(1);
         $parametros->setPessoa('J');
         $parametros->setPessoaCampo('sem_cnpj');
         $parametros->setPessoaNovo("S");
         $parametros->setPessoaCPF("N");
         $parametros->setPessoaTela('window');
         $this->campoOculto("sem_cnpj", "");
         $parametros->setCodSistema(13);
         $parametros->adicionaCampoTexto("cnpj", "cnpj");
         $this->campoCnpjPesq("cnpj", "CNPJ", $this->cnpj, "pesquisa_pessoa_lst.php", $parametros->serializaCampos(), true);
         //			$this->acao_enviar = "obj = document.getElementById(\"cnpj\");if(obj.value != \"\" ) {document.getElementById(\"formcadastro\").submit(); } else { acao(); }";
         $this->acao_enviar = false;
         $this->url_cancelar = false;
         $this->array_botao = array("Continuar", "Cancelar");
         $this->array_botao_url_script = array("obj = document.getElementById('cnpj');if(obj.value != '' ) { acao(); } else { acao(); }", "go('educar_escola_lst.php');");
     } else {
         if ($_POST) {
             foreach ($_POST as $campo => $val) {
                 if ($campo != 'tipoacao' && $campo != 'sem_cnpj') {
                     $this->{$campo} = $this->{$campo} ? $this->{$campo} : $val;
                 }
             }
         }
         if ($this->sem_cnpj) {
             $this->campoOculto("sem_cnpj", $this->sem_cnpj);
             // cadastro novo sem CNPJ
             $this->p_ddd_telefone_1 = $this->p_ddd_telefone_1 == null ? "" : $this->p_ddd_telefone_1;
             $this->p_ddd_telefone_fax = $this->p_ddd_telefone_fax == null ? "" : $this->p_ddd_telefone_fax;
             if ($this->ref_idpes) {
                 $objTemp = new clsPessoaJuridica($this->ref_idpes);
                 $detalhe = $objTemp->detalhe();
             }
             //				$this->campoOculto( "passo", 4 );
             //				$this->campoOculto( "sem_cnpj", 0 );
             $this->campoOculto("cod_escola", $this->cod_escola);
             // text
             $this->campoTexto("fantasia", "Escola", $this->fantasia, 30, 255, true);
             $this->campoTexto("sigla", "Sigla", $this->sigla, 30, 255, true);
             // foreign keys
             $nivel = $obj_permissoes->nivel_acesso($this->pessoa_logada);
             if ($nivel == 1) {
                 $cabecalhos[] = "Instituicao";
                 $objInstituicao = new clsPmieducarInstituicao();
                 $opcoes = array("" => "Selecione");
                 $objInstituicao->setOrderby("nm_instituicao ASC");
                 $lista = $objInstituicao->lista();
                 if (is_array($lista)) {
                     foreach ($lista as $linha) {
                         $opcoes[$linha["cod_instituicao"]] = $linha["nm_instituicao"];
                     }
                 }
                 $this->campoLista("ref_cod_instituicao", "Institui&ccedil;&atilde;o", $opcoes, $this->ref_cod_instituicao);
             } else {
                 $this->ref_cod_instituicao = $obj_permissoes->getInstituicao($this->pessoa_logada);
                 if ($this->ref_cod_instituicao) {
                     $this->campoOculto("ref_cod_instituicao", $this->ref_cod_instituicao);
                 } else {
                     die("Usu�rio n�o � do nivel poli-institucional e n�o possui uma institui��o");
                 }
             }
             $opcoes = array("" => "Selecione");
             if (class_exists("clsPmieducarEscolaRedeEnsino")) {
                 /*$todas_redes_ensino = "rede_ensino = new Array();\n";
                 		$objTemp = new clsPmieducarEscolaRedeEnsino();
                 		$lista = $objTemp->lista();
                 		if ( is_array( $lista ) && count( $lista ) )
                 		{
                 			foreach ( $lista as $registro )
                 			{
                 				$todas_redes_ensino .= "rede_ensino[rede_ensino.length] = new Array( {$registro["cod_escola_rede_ensino"]}, '{$registro['nm_rede']}', {$registro["ref_cod_instituicao"]} );\n";
                 			}
                 		}
                 		echo "<script>{$todas_redes_ensino}</script>";*/
                 // EDITAR
                 $script = "javascript:showExpansivelIframe(520, 120, 'educar_escola_rede_ensino_cad_pop.php');";
                 if ($this->ref_cod_instituicao) {
                     $objTemp = new clsPmieducarEscolaRedeEnsino();
                     $lista = $objTemp->lista(null, null, null, null, null, null, null, null, 1, $this->ref_cod_instituicao);
                     if (is_array($lista) && count($lista)) {
                         foreach ($lista as $registro) {
                             $opcoes["{$registro['cod_escola_rede_ensino']}"] = "{$registro['nm_rede']}";
                         }
                     }
                     $script = "<img id='img_rede_ensino' style='display: \\'\\'' src='imagens/banco_imagens/escreve.gif' style='cursor:hand; cursor:pointer;' border='0' onclick=\"{$script}\">";
                 } else {
                     $script = "<img id='img_rede_ensino' style='display: none;'  src='imagens/banco_imagens/escreve.gif' style='cursor:hand; cursor:pointer;' border='0' onclick=\"{$script}\">";
                 }
             } else {
                 echo "<!--\nErro\nClasse clsPmieducarEscolaRedeEnsino nao encontrada\n-->";
                 $opcoes = array("" => "Erro na geracao");
             }
             $this->campoLista("ref_cod_escola_rede_ensino", "Rede Ensino", $opcoes, $this->ref_cod_escola_rede_ensino, "", false, "", $script);
             $opcoes = array("" => "Selecione");
             if (class_exists("clsPmieducarEscolaLocalizacao")) {
                 /*$todas_escolas_localizacao = "escola_localizacao = new Array();\n";
                 		$objTemp = new clsPmieducarEscolaLocalizacao();
                 		$lista = $objTemp->lista();
                 		if ( is_array( $lista ) && count( $lista ) )
                 		{
                 			foreach ( $lista as $registro )
                 			{
                 				$todas_escolas_localizacao .= "escola_localizacao[escola_localizacao.length] = new Array( {$registro["cod_escola_localizacao"]}, '{$registro['nm_localizacao']}', {$registro["ref_cod_instituicao"]} );\n";
                 			}
                 		}
                 		echo "<script>{$todas_escolas_localizacao}</script>";*/
                 // EDITAR
                 $script = "javascript:showExpansivelIframe(520, 120, 'educar_escola_localizacao_cad_pop.php');";
                 if ($this->ref_cod_instituicao) {
                     $objTemp = new clsPmieducarEscolaLocalizacao();
                     $lista = $objTemp->lista(null, null, null, null, null, null, null, null, 1, $this->ref_cod_instituicao);
                     if (is_array($lista) && count($lista)) {
                         foreach ($lista as $registro) {
                             $opcoes["{$registro['cod_escola_localizacao']}"] = "{$registro['nm_localizacao']}";
                         }
                     }
                     $script = "<img id='img_localizacao' style='display: \\'\\'' src='imagens/banco_imagens/escreve.gif' style='cursor:hand; cursor:pointer;' border='0' onclick=\"{$script}\">";
                 } else {
                     $script = "<img id='img_localizacao' style='display: none;'  src='imagens/banco_imagens/escreve.gif' style='cursor:hand; cursor:pointer;' border='0' onclick=\"{$script}\">";
                 }
             } else {
                 echo "<!--\nErro\nClasse clsPmieducarEscolaLocalizacao nao encontrada\n-->";
                 $opcoes = array("" => "Erro na geracao");
             }
             $this->campoLista("ref_cod_escola_localizacao", "Escola Localiza&ccedil;&atilde;o", $opcoes, $this->ref_cod_escola_localizacao, "", false, "", $script);
             if (is_numeric($this->cep)) {
                 $this->cep = int2CEP($this->cep);
             }
             //				$this->campoCep( "cep","CEP", $this->cep,true,"-",false,false );
             $this->campoCep("cep", "CEP", $this->cep, true, "-", false, false);
             $this->campoTexto("cidade", "Cidade", $this->cidade, "50", "255", true);
             $this->campoTexto("bairro", "Bairro", $this->bairro, "50", "20", true);
             $this->campoTexto("logradouro", "Logradouro", $this->logradouro, "50", "255", true);
             $this->campoTexto("complemento", "Complemento", $this->complemento, "22", "20", false);
             $this->campoNumero("numero", "Número", $this->numero, "6", "6", true);
             $this->campoTexto("p_ddd_telefone_1", "DDD Telefone 1", $this->p_ddd_telefone_1, "2", "2", false);
             $this->campoTexto("p_telefone_1", "Telefone 1", $this->p_telefone_1, "10", "15", false);
             $this->campoTexto("p_ddd_telefone_fax", "DDD Fax", $this->p_ddd_telefone_fax, "2", "2", false);
             $this->campoTexto("p_telefone_fax", "Fax", $this->p_telefone_fax, "10", "15", false);
             $this->campoTexto("p_email", "E-mail", $this->p_email, "50", "255", false);
         }
         if ($this->com_cnpj) {
             $this->campoOculto("com_cnpj", $this->com_cnpj);
             //				die("com CNPJ");
             //				echo "<br>cep: ".$this->cep;
             //				echo "<br>cep_: ".$this->cep_;
             if (!$this->cod_escola) {
                 $this->cnpj = urldecode($_POST['cnpj']);
                 $this->cnpj = idFederal2int($this->cnpj);
                 //					echo int2IdFederal($this->cnpj);
                 $this->cnpj = int2IdFederal($this->cnpj);
             }
             //				echo "sakdmk: ".$this->cnpj;die;
             // cadastro novo com CNPJ
             //echo "hehehe".idFederal2int($this->cnpj);echo "kiki".int2IdFederal($this->cnpj);die;
             $objJuridica = new clsPessoaJuridica(false, idFederal2int($this->cnpj));
             $det = $objJuridica->detalhe();
             $this->ref_idpes = $det["idpes"];
             //				if( $this->ref_idpes )
             //				{
             //					$this->p_ddd_telefone_1 = ( $this->p_ddd_telefone_1 == null ) ? "": is_numeric( $this->p_ddd_telefone_1 );
             //					$this->p_ddd_telefone_2 = ( $this->p_ddd_telefone_2 == null ) ? "": is_numeric( $this->p_ddd_telefone_2 );
             //					$this->p_ddd_telefone_3 = ( $this->p_ddd_telefone_3 == null ) ? "": is_numeric( $this->p_ddd_telefone_3 );
             //					$obj_pessoa = new clsPessoa_( $this->ref_idpes );
             //					$det_pessoa = $obj_pessoa->detalhe();
             //$this->fantasia = $det_pessoa["nome"];
             //					$this->nm_escola = $det["nome"];
             if (!$this->fantasia) {
                 $this->fantasia = $det["fantasia"];
             }
             if ($this->passou) {
                 $this->cnpj = is_numeric($this->cnpj) ? $this->cnpj : idFederal2int($this->cnpj);
                 $this->cnpj = int2IdFederal($this->cnpj);
             }
             //
             $this->campoRotulo("cnpj_", "CNPJ", $this->cnpj);
             $this->campoOculto("cnpj", idFederal2int($this->cnpj));
             $this->campoOculto("ref_idpes", $this->ref_idpes);
             //					$this->campoOculto( "passo", 3 );
             $this->campoOculto("cod_escola", $this->cod_escola);
             // text
             $this->campoTexto("fantasia", "Escola", $this->fantasia, 30, 255, true);
             $this->campoTexto("sigla", "Sigla", $this->sigla, 30, 255, true);
             // foreign keys
             $nivel = $obj_permissoes->nivel_acesso($this->pessoa_logada);
             if ($nivel == 1) {
                 $cabecalhos[] = "Instituicao";
                 $objInstituicao = new clsPmieducarInstituicao();
                 $opcoes = array("" => "Selecione");
                 $objInstituicao->setOrderby("nm_instituicao ASC");
                 $lista = $objInstituicao->lista();
                 if (is_array($lista)) {
                     foreach ($lista as $linha) {
                         $opcoes[$linha["cod_instituicao"]] = $linha["nm_instituicao"];
                     }
                 }
                 $this->campoLista("ref_cod_instituicao", "Instituicao", $opcoes, $this->ref_cod_instituicao);
             } else {
                 $this->ref_cod_instituicao = $obj_permissoes->getInstituicao($this->pessoa_logada);
                 if ($this->ref_cod_instituicao) {
                     $this->campoOculto("ref_cod_instituicao", $this->ref_cod_instituicao);
                 } else {
                     die("Usu�rio n�o � do nivel poli-institucional e n�o possui uma institui��o");
                 }
             }
             $opcoes = array("" => "Selecione");
             if (class_exists("clsPmieducarEscolaRedeEnsino")) {
                 /*$todas_redes_ensino = "rede_ensino = new Array();\n";
                 		$objTemp = new clsPmieducarEscolaRedeEnsino();
                 		$lista = $objTemp->lista( null,null,null,null,null,null,null,null,1 );
                 		if ( is_array( $lista ) && count( $lista ) )
                 		{
                 			foreach ( $lista as $registro )
                 			{
                 				$todas_redes_ensino .= "rede_ensino[rede_ensino.length] = new Array( {$registro["cod_escola_rede_ensino"]}, '{$registro['nm_rede']}', {$registro["ref_cod_instituicao"]} );\n";
                 			}
                 		}
                 		echo "<script>{$todas_redes_ensino}</script>";*/
                 // EDITAR
                 $script = "javascript:showExpansivelIframe(520, 120, 'educar_escola_rede_ensino_cad_pop.php');";
                 if ($this->ref_cod_instituicao) {
                     $objTemp = new clsPmieducarEscolaRedeEnsino();
                     $lista = $objTemp->lista(null, null, null, null, null, null, null, null, 1, $this->ref_cod_instituicao);
                     if (is_array($lista) && count($lista)) {
                         foreach ($lista as $registro) {
                             $opcoes["{$registro['cod_escola_rede_ensino']}"] = "{$registro['nm_rede']}";
                         }
                     }
                     $script = "<img id='img_rede_ensino' style='display:\\'\\'' src='imagens/banco_imagens/escreve.gif' style='cursor:hand; cursor:pointer;' border='0' onclick=\"{$script}\">";
                 } else {
                     $script = "<img id='img_rede_ensino' style='display: none;'  src='imagens/banco_imagens/escreve.gif' style='cursor:hand; cursor:pointer;' border='0' onclick=\"{$script}\">";
                 }
             } else {
                 echo "<!--\nErro\nClasse clsPmieducarEscolaRedeEnsino nao encontrada\n-->";
                 $opcoes = array("" => "Erro na geracao");
             }
             $this->campoLista("ref_cod_escola_rede_ensino", "Rede Ensino", $opcoes, $this->ref_cod_escola_rede_ensino, "", false, "", $script);
             $opcoes = array("" => "Selecione");
             if (class_exists("clsPmieducarEscolaLocalizacao")) {
                 /*$todas_escolas_localizacao = "escola_localizacao = new Array();\n";
                 		$objTemp = new clsPmieducarEscolaLocalizacao();
                 		$lista = $objTemp->lista( null,null,null,null,null,null,null,null,1 );
                 		if ( is_array( $lista ) && count( $lista ) )
                 		{
                 			foreach ( $lista as $registro )
                 			{
                 				$todas_escolas_localizacao .= "escola_localizacao[escola_localizacao.length] = new Array( {$registro["cod_escola_localizacao"]}, '{$registro['nm_localizacao']}', {$registro["ref_cod_instituicao"]} );\n";
                 			}
                 		}
                 		echo "<script>{$todas_escolas_localizacao}</script>";*/
                 // EDITAR
                 $script = "javascript:showExpansivelIframe(520, 120, 'educar_escola_localizacao_cad_pop.php');";
                 if ($this->ref_cod_instituicao) {
                     $objTemp = new clsPmieducarEscolaLocalizacao();
                     $lista = $objTemp->lista(null, null, null, null, null, null, null, null, 1, $this->ref_cod_instituicao);
                     if (is_array($lista) && count($lista)) {
                         foreach ($lista as $registro) {
                             $opcoes["{$registro['cod_escola_localizacao']}"] = "{$registro['nm_localizacao']}";
                         }
                     }
                     $script = "<img id='img_localizacao' style='display:\\'\\'' src='imagens/banco_imagens/escreve.gif' style='cursor:hand; cursor:pointer;' border='0' onclick=\"{$script}\">";
                 } else {
                     $script = "<img id='img_localizacao' style='display: none;' src='imagens/banco_imagens/escreve.gif' style='cursor:hand; cursor:pointer;' border='0' onclick=\"{$script}\">";
                 }
             } else {
                 echo "<!--\nErro\nClasse clsPmieducarEscolaLocalizacao nao encontrada\n-->";
                 $opcoes = array("" => "Erro na geracao");
             }
             $this->campoLista("ref_cod_escola_localizacao", "Escola Localiza&ccedil;&atilde;o", $opcoes, $this->ref_cod_escola_localizacao, "", false, "", $script);
             // Detalhes do Endereco
             $objUf = new clsUf();
             $listauf = $objUf->lista();
             $listaEstado = array("" => "Selecione");
             if ($listauf) {
                 foreach ($listauf as $uf) {
                     $listaEstado[$uf['sigla_uf']] = $uf['sigla_uf'];
                 }
             }
             $objTipoLog = new clsTipoLogradouro();
             $listaTipoLog = $objTipoLog->lista();
             $listaTLog = array("" => "Selecione");
             if ($listaTipoLog) {
                 foreach ($listaTipoLog as $tipoLog) {
                     $listaTLog[urldecode($tipoLog['idtlog'])] = $tipoLog['descricao'];
                 }
             }
             $this->campoOculto("isEnderecoExterno", $this->isEnderecoExterno);
             //	echo "$this->cep ,$this->sigla_uf ";
             $this->campoOculto("cep_", $this->cep_);
             $this->campoOculto("sigla_uf_", $this->sigla_uf_);
             $this->campoOculto("cidade_", $this->cidade_);
             $this->campoOculto("bairro_", $this->bairro_);
             $this->campoOculto("idbai", $this->idbai);
             $this->campoOculto("logradouro_", $this->logradouro_);
             $this->campoOculto("idlog", $this->idlog);
             $this->campoOculto("idtlog_", $this->idtlog_);
             $disabled = $this->isEnderecoExterno ? false : true;
             if ($this->idlog && $this->idbai && $this->cep && $this->ref_idpes) {
                 $this->campoOculto("cep_", $this->cep);
                 $this->cep_ = int2CEP($this->cep);
                 //$this->campoLista( "ref_cod_escola_localizacao", "Escola Localizac&atilde;o", $opcoes, $this->ref_cod_escola_localizacao );
                 //						$this->campoCep("cep_","CEP", int2CEP($this->cep),true,"-","&nbsp;<img src=\"imagens/lupa.png\" border=\"0\" onclick=\"pesquisa_valores_f('pesquisa_cep3.php', 'enderecos')\" style=\"cursor: hand;\">",true);
                 //						$this->campoCep( "cep_", "CEP", int2CEP( $this->cep ), true, "-", "&nbsp;<img src=\"imagens/lupa.png\" border=\"0\" onclick=\"pesquisa_valores_f( 'pesquisa_cep_lst.php', 'enderecos' )\" style=\"cursor: hand;\">", false );
                 //$this->campoCep( "cep", "CEP", int2CEP( $this->cep ), true, "-", "&nbsp;<img src=\"imagens/lupa.png\" border=\"0\" onclick=\"pesquisa_valores_popless('pesquisa_cep_lst.php', 'enderecos')\" style=\"cursor: hand;\">", true );
                 $this->campoCep("cep", "CEP", $this->cep_, true, "-", "<img id='lupa' src=\"imagens/lupa.png\" border=\"0\" onclick=\"showExpansivel( 500,500, '<iframe name=\\'miolo\\' id=\\'miolo\\' frameborder=\\'0\\' height=\\'100%\\' width=\\'500\\' marginheight=\\'0\\' marginwidth=\\'0\\' src=\\'educar_pesquisa_cep_log_bairro.php?campo1=bairro&campo2=idbai&campo3=cep_&campo4=logradouro&campo5=idlog&campo6=sigla_uf_&campo7=cidade&campo8=idtlog_&campo9=isEnderecoExterno&campo10=cep&campo11=sigla_uf&campo12=idtlog&campo13=cidade_\\'></iframe>');\">", $disabled);
                 $this->campoLista("sigla_uf", "Estado", $listaEstado, $this->sigla_uf, false, false, false, false, true, true);
                 $this->campoTexto("cidade", "Cidade", $this->cidade, "50", "255", true, false, false, "", "", "", "onKeyUp", true);
                 $this->campoTexto("bairro", "Bairro", $this->bairro, "50", "255", true, false, false, "", "", "", "onKeyUp", true);
                 $this->campoLista("idtlog", "Tipo Logradouro", $listaTLog, $this->idtlog, false, false, false, false, true, true);
                 $this->campoTexto("logradouro", "Logradouro", $this->logradouro, "50", "255", true, false, false, "", "", "", "onKeyUp", true);
                 $this->campoTexto("complemento", "Complemento", $this->complemento, "22", "20", false, false);
                 $this->campoNumero("numero", "Número", $this->numero, "6", "6", false);
                 $this->campoNumero("andar", "Andar", $this->andar, "2", "2", false);
             } elseif ($this->ref_idpes && $this->cep) {
                 $this->cep = is_numeric($this->cep) ? int2CEP($this->cep) : $this->cep;
                 //						$this->campoCep("cep_","CEP", int2CEP($this->cep),true,"-","&nbsp;<img src=\"imagens/lupa.png\" border=\"0\" onclick=\"pesquisa_valores_f('pesquisa_cep3.php', 'enderecos')\" style=\"cursor: hand;\">",false);
                 //						$this->campoCep( "cep_", "CEP", int2CEP( $this->cep ), true, "-", "&nbsp;<img src=\"imagens/lupa.png\" border=\"0\" onclick=\"pesquisa_valores_f( 'pesquisa_cep_lst.php', 'enderecos' )\" style=\"cursor: hand;\">", false );
                 //$this->campoCep( "cep", "CEP", int2CEP( $this->cep ), true, "-", "&nbsp;<img src=\"imagens/lupa.png\" border=\"0\" onclick=\"pesquisa_valores_popless('pesquisa_cep_lst.php', 'enderecos')\" style=\"cursor: hand;\">", false );
                 $this->campoCep("cep", "CEP", $this->cep, true, "-", "<img id='lupa' src=\"imagens/lupa.png\" border=\"0\" onclick=\"showExpansivel( 500,500, '<iframe name=\\'miolo\\' id=\\'miolo\\' frameborder=\\'0\\' height=\\'100%\\' width=\\'500\\' marginheight=\\'0\\' marginwidth=\\'0\\' src=\\'educar_pesquisa_cep_log_bairro.php?campo1=bairro&campo2=idbai&campo3=cep_&campo4=logradouro&campo5=idlog&campo6=sigla_uf_&campo7=cidade&campo8=idtlog_&campo9=isEnderecoExterno&campo10=cep&campo11=sigla_uf&campo12=idtlog&campo13=cidade_\\'></iframe>');\">");
                 $this->campoLista("sigla_uf", "Estado", $listaEstado, $this->sigla_uf, "", false, "", "", false, true);
                 $this->campoTexto("cidade", "Cidade", $this->cidade, "50", "255", true, false, false, "", "", "", "onKeyUp", false);
                 $this->campoTexto("bairro", "Bairro", $this->bairro, "50", "255", true, false, false, "", "", "", "onKeyUp", false);
                 $this->campoLista("idtlog", "Tipo Logradouro", $listaTLog, $this->idtlog, "", false, "", "", false, true);
                 $this->campoTexto("logradouro", "Logradouro", $this->logradouro, "50", "255", true, false, false, "", "", "", "onKeyUp", false);
                 $this->campoTexto("complemento", "Complemento", $this->complemento, "22", "20", false, false, false, "", "", "", "onKeyUp", false);
                 $this->campoNumero("numero", "Número", $this->numero, 6, 6, false, "", "");
                 $this->campoNumero("andar", "Andar", $this->andar, "2", "2", false);
             } else {
                 if (!$this->isEnderecoExterno) {
                     $obj_bairro = new clsBairro($this->idbai);
                     $this->cep_ = int2CEP($this->cep_);
                     $obj_bairro_det = $obj_bairro->detalhe();
                     if ($obj_bairro_det) {
                         $this->bairro = $obj_bairro_det["nome"];
                     }
                     $obj_log = new clsLogradouro($this->idlog);
                     $obj_log_det = $obj_log->detalhe();
                     if ($obj_log_det) {
                         $this->logradouro = $obj_log_det["nome"];
                         $this->idtlog = $obj_log_det["idtlog"]->idtlog;
                         $obj_mun = new clsMunicipio($obj_log_det["idmun"]);
                         $det_mun = $obj_mun->detalhe();
                         if ($det_mun) {
                             $this->cidade = strtoupper(ucfirst(strtolower($det_mun["nome"])));
                         }
                         $this->sigla_uf = $this->sigla_uf_ = $det_mun['sigla_uf']->sigla_uf;
                     }
                 } else {
                     $this->cep_ = $this->cep;
                 }
                 /*$obj_bairro = new clsBairro($obj_endereco_det["ref_idbai"]);
                 					$obj_bairro_det = $obj_bairro->detalhe();
                 
                 					if($obj_bairro_det){
                 
                 						$this->bairro = $obj_bairro_det["nome"];
                 					}*/
                 //						$this->campoCep("cep_","CEP", int2CEP($this->cep),true,"-","&nbsp;<img src=\"imagens/lupa.png\" border=\"0\" onclick=\"pesquisa_valores_f('pesquisa_cep3.php', 'enderecos')\" style=\"cursor: hand;\">",true);
                 //						$this->campoCep( "cep_", "CEP", int2CEP( $this->cep ), true, "-", "&nbsp;<img src=\"imagens/lupa.png\" border=\"0\" onclick=\"pesquisa_valores_f( 'pesquisa_cep_lst.php', 'enderecos' )\" style=\"cursor: hand;\">", false );
                 //						$this->campoCep( "cep_", "CEP", int2CEP( $this->cep ), true, "-", "&nbsp;<img src=\"imagens/lupa.png\" border=\"0\" onclick=\"pesquisa_valores_popless('pesquisa_cep_lst.php', 'enderecos')\" style=\"cursor: hand;\">", false );
                 $this->campoCep("cep", "CEP", $this->cep_, true, "-", "<img id='lupa' src=\"imagens/lupa.png\" border=\"0\" onclick=\"showExpansivel( 500,500, '<iframe name=\\'miolo\\' id=\\'miolo\\' frameborder=\\'0\\' height=\\'100%\\' width=\\'500\\' marginheight=\\'0\\' marginwidth=\\'0\\' src=\\'educar_pesquisa_cep_log_bairro.php?campo1=bairro&campo2=idbai&campo3=cep_&campo4=logradouro&campo5=idlog&campo6=sigla_uf_&campo7=cidade&campo8=idtlog_&campo9=isEnderecoExterno&campo10=cep&campo11=sigla_uf&campo12=idtlog&campo13=cidade_\\'></iframe>');\">", $disabled);
                 //	$this->campoCep("cep_", "CEP", $this->cep_, true, "-", "<img id='lupa' src=\"imagens/lupa.png\" border=\"0\" onclick=\"showExpansivel( 500,500, '<iframe name=\'miolo\' id=\'miolo\' frameborder=\'0\' height=\'100%\' width=\'500\' marginheight=\'0\' marginwidth=\'0\' src=\'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\'></iframe>');\">", $disabled);
                 $this->campoLista("sigla_uf", "Estado", $listaEstado, $this->sigla_uf, false, false, false, false, $disabled, true);
                 $this->campoTexto("cidade", "Cidade", $this->cidade, "50", "255", true, false, false, "", "", "", "", $disabled, true);
                 $this->campoTexto("bairro", "Bairro", $this->bairro, "50", "20", true, false, false, "", "", "", "", $disabled, true);
                 $this->campoLista("idtlog", "Tipo Logradouro", $listaTLog, $this->idtlog, false, false, false, false, $disabled, true);
                 $this->campoTexto("logradouro", "Logradouro", $this->logradouro, "50", "255", true, false, false, "", "", "", "", $disabled, true);
                 $this->campoTexto("complemento", "Complemento", $this->complemento, "22", "20", false, false, false);
                 $this->campoNumero("numero", "N&uacute;mero", $this->numero, "6", "6", false);
                 $this->campoNumero("andar", "Andar", $this->andar, "2", "2", false);
             }
             $this->campoNumero("p_ddd_telefone_1", "DDD Telefone 1", $this->p_ddd_telefone_1, 2, 2, false);
             $this->campoNumero("p_telefone_1", "Telefone 1", $this->p_telefone_1, 10, 15, false);
             $this->campoNumero("p_ddd_telefone_2", "DDD Telefone 2", $this->p_ddd_telefone_2, 2, 2, false);
             $this->campoNumero("p_telefone_2", "Telefone", $this->p_telefone_2, 10, 15, false);
             $this->campoNumero("p_ddd_telefone_fax", "DDD Fax", $this->p_ddd_telefone_fax, 2, 2, false);
             $this->campoNumero("p_telefone_fax", "Fax", $this->p_telefone_fax, 10, 15, false);
             $this->campoTexto("p_http", "Site", $this->p_http, "50", "255", false);
             $this->campoTexto("p_email", "E-mail", $this->p_email, "50", "255", false);
             //				}
             //				else
             //				{
             //					$this->mensagem = "nop";
             //				}
             $this->passou = true;
             $this->campoOculto("passou", $this->passou);
         }
         //			else if ( $this->passo == 3 )
         //			{
         //
         //
         //
         //			}
         if ($_POST["escola_curso"]) {
             $this->escola_curso = unserialize(urldecode($_POST["escola_curso"]));
         }
         if (is_numeric($this->cod_escola) && !$_POST) {
             $obj = new clsPmieducarEscolaCurso($this->cod_escola);
             $registros = $obj->lista($this->cod_escola);
             if ($registros) {
                 foreach ($registros as $campo) {
                     $this->escola_curso[$campo["ref_cod_curso"]] = $campo["ref_cod_curso"];
                 }
             }
         }
         if ($_POST["ref_cod_curso"]) {
             $this->escola_curso[$_POST["ref_cod_curso"]] = $_POST["ref_cod_curso"];
             unset($this->ref_cod_curso);
         }
         $this->campoQuebra();
         $this->campoOculto("excluir_curso", "");
         unset($aux);
         if ($this->escola_curso) {
             //				echo "<pre>";print_r($this->escola_curso);
             foreach ($this->escola_curso as $curso) {
                 if ($this->excluir_curso == $curso) {
                     unset($this->escola_curso[$curso]);
                     // = null;
                     $this->excluir_curso = null;
                 } else {
                     $obj_curso = new clsPmieducarCurso($curso);
                     $obj_curso_det = $obj_curso->detalhe();
                     $nm_curso = $obj_curso_det["nm_curso"];
                     $this->campoTextoInv("ref_cod_curso_{$curso}", "", $nm_curso, 30, 255, false, false, false, "", "<a href='#' onclick=\"getElementById('excluir_curso').value = '{$curso}'; getElementById('tipoacao').value = ''; {$this->__nome}.submit();\"><img src='imagens/nvp_bola_xis.gif' title='Excluir' border=0></a>");
                     $aux[$curso] = $curso;
                 }
             }
             unset($this->escola_curso);
             $this->escola_curso = $aux;
         }
         $this->campoOculto("escola_curso", serialize($this->escola_curso));
         $opcoes = array("" => "Selecione");
         if (class_exists("clsPmieducarCurso")) {
             /*$todos_cursos = "curso = new Array();\n";
             		$objTemp = new clsPmieducarCurso();
             		$objTemp->setOrderby("nm_curso");
             		$lista = $objTemp->lista( null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1 );
             		if ( is_array( $lista ) && count( $lista ) )
             		{
             			foreach ( $lista as $registro )
             			{
             				$todos_cursos .= "curso[curso.length] = new Array({$registro["cod_curso"]},'{$registro["nm_curso"]}', {$registro["ref_cod_instituicao"]});\n";
             			}
             		}
             		echo "<script>{$todos_cursos}</script>";*/
             // EDITAR
             if ($this->cod_escola || $this->ref_cod_instituicao) {
                 $objTemp = new clsPmieducarCurso();
                 $objTemp->setOrderby("nm_curso");
                 $lista = $objTemp->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 (is_array($lista) && count($lista)) {
                     foreach ($lista as $registro) {
                         $opcoes["{$registro['cod_curso']}"] = "{$registro['nm_curso']}";
                     }
                 }
             }
         } else {
             echo "<!--\nErro\nClasse clsPmieducarCurso n&atilde;o encontrada\n-->";
             $opcoes = array("" => "Erro na gera&ccedil;&atilde;o");
         }
         if ($aux) {
             $this->campoLista("ref_cod_curso", "Curso", $opcoes, $this->ref_cod_curso, "", false, "", "<a href='#' onclick=\"getElementById('incluir_curso').value = 'S'; getElementById('tipoacao').value = ''; {$this->__nome}.submit();\"><img src='imagens/nvp_bot_adiciona.gif' title='Incluir' border=0></a>", false, false);
         } else {
             $this->campoLista("ref_cod_curso", "Curso", $opcoes, $this->ref_cod_curso, "", false, "", "<a href='#' onclick=\"getElementById('incluir_curso').value = 'S'; getElementById('tipoacao').value = ''; {$this->__nome}.submit();\"><img src='imagens/nvp_bot_adiciona.gif' title='Incluir' border=0></a>");
         }
         $this->campoOculto("incluir_curso", "");
         $this->campoQuebra();
     }
 }
 function Gerar()
 {
     @session_start();
     $this->pessoa_logada = $_SESSION['id_pessoa'];
     session_write_close();
     $this->titulo = "Escola Localiza&ccedil;&atilde;o - Listagem";
     foreach ($_GET as $var => $val) {
         // passa todos os valores obtidos no GET para atributos do objeto
         $this->{$var} = $val === "" ? null : $val;
     }
     $this->addBanner("imagens/nvp_top_intranet.jpg", "imagens/nvp_vert_intranet.jpg", "Intranet");
     $lista_busca = array("Localiza&ccedil;&atilde;o");
     $obj_permissoes = new clsPermissoes();
     $nivel_usuario = $obj_permissoes->nivel_acesso($this->pessoa_logada);
     if ($nivel_usuario == 1) {
         $lista_busca[] = "Institui&ccedil;&atilde;o";
     }
     $this->addCabecalhos($lista_busca);
     // Filtros de Foreign Keys
     include "include/pmieducar/educar_campo_lista.php";
     // outros Filtros
     $this->campoTexto("nm_localizacao", "Localiza&ccedil;&atilde;o", $this->nm_localizacao, 30, 255, false);
     // Paginador
     $this->limite = 20;
     $this->offset = $_GET["pagina_{$this->nome}"] ? $_GET["pagina_{$this->nome}"] * $this->limite - $this->limite : 0;
     $obj_escola_localizacao = new clsPmieducarEscolaLocalizacao();
     $obj_escola_localizacao->setOrderby("nm_localizacao ASC");
     $obj_escola_localizacao->setLimite($this->limite, $this->offset);
     $lista = $obj_escola_localizacao->lista(null, null, null, $this->nm_localizacao, null, null, null, null, 1, $this->ref_cod_instituicao);
     $total = $obj_escola_localizacao->_total;
     // monta a lista
     if (is_array($lista) && count($lista)) {
         foreach ($lista as $registro) {
             // pega detalhes de foreign_keys
             if (class_exists("clsPmieducarInstituicao")) {
                 $obj_ref_cod_instituicao = new clsPmieducarInstituicao($registro["ref_cod_instituicao"]);
                 $det_ref_cod_instituicao = $obj_ref_cod_instituicao->detalhe();
                 $registro["ref_cod_instituicao"] = $det_ref_cod_instituicao["nm_instituicao"];
             } else {
                 $registro["ref_cod_instituicao"] = "Erro na geracao";
                 echo "<!--\nErro\nClasse nao existente: clsPmieducarInstituicao\n-->";
             }
             $lista_busca = array("<a href=\"educar_escola_localizacao_det.php?cod_escola_localizacao={$registro["cod_escola_localizacao"]}\">{$registro["nm_localizacao"]}</a>");
             if ($nivel_usuario == 1) {
                 $lista_busca[] = "<a href=\"educar_escola_localizacao_det.php?cod_escola_localizacao={$registro["cod_escola_localizacao"]}\">{$registro["ref_cod_instituicao"]}</a>";
             }
             $this->addLinhas($lista_busca);
         }
     }
     $this->addPaginador2("educar_escola_localizacao_lst.php", $total, $_GET, $this->nome, $this->limite);
     if ($obj_permissoes->permissao_cadastra(562, $this->pessoa_logada, 3)) {
         $this->acao = "go(\"educar_escola_localizacao_cad.php\")";
         $this->nome_acao = "Novo";
     }
     $this->largura = "100%";
 }