$opcoes_escola["{$registro["cod_escola"]}"] = "{$registro['nome']}";
            }
        }
    }
    if ($get_biblioteca) {
        $this->campoLista("ref_cod_escola", "Escola", $opcoes_escola, $this->ref_cod_escola, "getBiblioteca(2);", null, null, null, $escola_desabilitado, $escola_obrigatorio);
    } else {
        $this->campoLista("ref_cod_escola", "Escola", $opcoes_escola, $this->ref_cod_escola, null, null, null, null, $escola_desabilitado, $escola_obrigatorio);
    }
}
if ($get_curso) {
    $opcoes_curso = array("" => "Selecione");
    // EDITAR
    if ($this->ref_cod_escola) {
        $obj_escola_curso = new clsPmieducarEscolaCurso();
        $lst_escola_curso = $obj_escola_curso->lista($this->ref_cod_escola, null, null, null, null, null, null, null, 1);
        if (is_array($lst_escola_curso) && count($lst_escola_curso)) {
            foreach ($lst_escola_curso as $escola_curso) {
                $opcoes_curso["{$escola_curso["ref_cod_curso"]}"] = $escola_curso['nm_curso'];
            }
        }
    } else {
        if ($this->ref_cod_instituicao) {
            $opcoes_curso = array("" => "Selecione");
            $obj_curso = new clsPmieducarCurso();
            $obj_curso->setOrderby("nm_curso ASC");
            if ($sem_padrao) {
                $lista = $obj_curso->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, 0);
            } else {
                $lista = $obj_curso->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);
            }
示例#2
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 renderHTML()
    {
        if ($_POST) {
            foreach ($_POST as $key => $value) {
                $this->{$key} = $value;
            }
        }
        if (!$_POST) {
            echo '<script>
	     			alert("Erro ao gerar relatório!\\nNão existem dados!");
	     			window.parent.fechaExpansivel(\'div_dinamico_\'+(window.parent.DOM_divs.length-1));
	     		</script>';
            return true;
        }
        $obj_instituicao = new clsPmieducarInstituicao($this->ref_cod_instituicao);
        $det_instituicao = $obj_instituicao->detalhe();
        $this->nm_instituicao = $det_instituicao["nm_instituicao"];
        $obj_curso2 = new clsPmieducarCurso($this->ref_cod_curso);
        $det_curso2 = $obj_curso2->detalhe();
        $this->nm_curso = $det_curso2["nm_curso"];
        if ($this->escola_sem_avaliacao == 1) {
            $this->escola_sem_avaliacao = true;
        } elseif ($this->escola_sem_avaliacao == 2) {
            $this->escola_sem_avaliacao = false;
        } else {
            $this->escola_sem_avaliacao = null;
        }
        $obj_escolas = new clsPmieducarEscola();
        $obj_escolas->setOrderby("ref_cod_escola_localizacao, nome");
        $this->lst_escola = $obj_escolas->lista($this->ref_cod_escola, null, null, $this->ref_cod_instituicao, null, null, null, null, null, null, 1, null, $this->escola_sem_avaliacao);
        $lst_curso = array();
        if (is_numeric($this->ref_cod_escola)) {
            $obj_escola_curso = new clsPmieducarEscolaCurso();
            $lst_escola_curso = $obj_escola_curso->lista($this->ref_cod_escola, $this->ref_cod_curso, null, null, null, null, null, null, 1, null, $this->ref_cod_instituicao, true);
            foreach ($lst_escola_curso as $escola_curso) {
                $obj_curso = new clsPmieducarCurso($escola_curso["ref_cod_curso"]);
                $lst_curso[] = $obj_curso->detalhe();
            }
        } else {
            if (is_numeric($this->ref_cod_curso)) {
                $obj_curso = new clsPmieducarCurso($this->ref_cod_curso);
                $lst_curso[] = $obj_curso->detalhe();
            } else {
                $obj_curso = new clsPmieducarCurso();
                $lst_curso = $obj_curso->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);
            }
        }
        $this->pdf = new clsPDF("Levantamento Turma por Período e Aluno - {$this->ano}", "Levantamento Turma por Período e Aluno - {$this->ano}", "A4", "", false, false);
        $this->pdf->largura = 842.0;
        $this->pdf->altura = 595.0;
        $fonte = 'arial';
        $corTexto = '#000000';
        $altura_linha = 23;
        $inicio_escrita_y = 175;
        $this->pdf->OpenPage();
        $this->addCabecalho();
        foreach ($lst_curso as $curso) {
            $this->escreveEscolas($curso);
        }
        $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>";
    }
 						foreach ( $lst_escola_curso as $escola_curso )
 						{
 							//$obj_curso = new clsPmieducarCurso( $escola_curso["ref_cod_curso"] );
 						//$det_curso = $obj_curso->he();
 							if(isset($curso_padrao_ano_escolar) && $det_curso['padrao_ano_escolar'] != $curso_padrao_ano_escolar)
 								continue;
 							$todos_cursos_escola .= "escola_curso[escola_curso.length] = new Array( {$escola_curso["ref_cod_curso"]}, '{$escola_curso['nm_curso']}', {$escola_curso["ref_cod_escola"]}, {$escola_curso["padrao_ano_escolar"]} );\n";
 						}
 					}
 				}
 				echo "<script>{$todos_cursos_escola}</script>";*/
 $opcoes_curso = array("" => "Selecione");
 // EDITAR
 if ($this->ref_cod_escola) {
     $obj_esc_cur = new clsPmieducarEscolaCurso();
     $lst_esc_cur = $obj_esc_cur->lista($this->ref_cod_escola, null, null, null, null, null, null, null, 1);
     if (is_array($lst_esc_cur) && count($lst_esc_cur)) {
         foreach ($lst_esc_cur as $detalhe) {
             //							$obj_curso = new clsPmieducarCurso( $detalhe["ref_cod_curso"] );
             //							$det_curso = $obj_curso->detalhe();
             //							if ( is_array( $det_curso ) && count( $det_curso ) )
             //							{
             $opcoes_curso["{$detalhe['ref_cod_curso']}"] = "{$detalhe['nm_curso']}";
             //							}
         }
     }
 }
 /*elseif($this->ref_cod_curso)
 				{
 					$obj_curso = new clsPmieducarCurso();
 					$obj_curso->setOrderby("nm_curso ASC");
    }
    $this->campoLista("ref_ref_cod_serie", "Série", $opcoes, $this->ref_ref_cod_serie, "", false, "", "", false, $obrigatorio);
} elseif ($privilegio == 1) {
    // foreign keys
    include "include/pmieducar/educar_pesquisa_instituicao_escola.php";
    $opcoes = array("" => "Selecione");
    if (class_exists("clsPmieducarEscola")) {
        $obj_escola = new clsPmieducarEscola(null, null, null, $permissoes->getInstituicao($this->pessoa_logada), null, null, null, null, null, null, 1);
        $lst_escola = $obj_escola->lista(null, null, null, $permissoes->getInstituicao($this->pessoa_logada), null, null, null, null, null, null, 1);
        if ($lst_escola) {
            $cursos = '';
            $series = '';
            foreach ($lst_escola as $escola) {
                if (class_exists("clsPmieducarEscolaCurso")) {
                    $objTemp = new clsPmieducarEscolaCurso();
                    $lista = $objTemp->lista($escola["cod_escola"], null, null, null, null, null, null, null, 1);
                    $cursos .= " escola['_{$escola["cod_escola"]}'] = new Array();\n";
                    if ($lista) {
                        foreach ($lista as $registro) {
                            if (class_exists("clsPmieducarCurso")) {
                                $objTemp = new clsPmieducarCurso($registro["ref_cod_curso"]);
                                $detalhe = $objTemp->detalhe();
                                $series .= " curso['_{$registro["ref_cod_curso"]}'] = new Array();\n";
                                $cursos .= " escola['_{$registro["ref_cod_escola"]}'][escola['_{$registro["ref_cod_escola"]}'].length] = new Array( {$detalhe["cod_curso"]}, '{$detalhe["nm_curso"]}' );\n";
                                if ($editar) {
                                    $opcoes["{$registro["ref_cod_curso"]}"] = "{$detalhe["nm_curso"]}";
                                } else {
                                    $opcoes[""] = "Selecione um curso";
                                }
                                if (class_exists("clsPmieducarSerie")) {
                                    $objSe = new clsPmieducarSerie(null, null, null, $registro["ref_cod_curso"], null, null, null, null, null, null, 1);