From 95e6073c5e00edd7f3d1031f6e69e9ff8e01b935 Mon Sep 17 00:00:00 2001 From: Eriksen Costa Paixão Date: Wed, 7 Jul 2010 10:48:43 +0000 Subject: [PATCH] Refactoring para coding standards --- ieducar/intranet/educar_calendario_pesquisas.php | 671 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 file changed, 327 insertions(+), 344 deletions(-) diff --git a/ieducar/intranet/educar_calendario_pesquisas.php b/ieducar/intranet/educar_calendario_pesquisas.php index 2ad4017..202827f 100644 --- a/ieducar/intranet/educar_calendario_pesquisas.php +++ b/ieducar/intranet/educar_calendario_pesquisas.php @@ -1,345 +1,328 @@ nivel_acesso($this->pessoa_logada); - if($nivel_usuario <=4 && !empty($nivel_usuario)){ - $retorno .= ' - - - Filtros de busca - - - '; - - $retorno .= '
'; - if ($obrigatorio) - { - $instituicao_obrigatorio = $escola_obrigatorio = true; - } - else - { - $instituicao_obrigatorio = isset($instituicao_obrigatorio) ? $instituicao_obrigatorio : $obrigatorio; - $escola_obrigatorio = isset($escola_obrigatorio) ? $escola_obrigatorio : $obrigatorio; - } - - if ($desabilitado) - { - $instituicao_desabilitado = $escola_desabilitado = true; - } - else - { - $instituicao_desabilitado = isset($instituicao_desabilitado) ? $instituicao_desabilitado : $desabilitado; - $escola_desabilitado = isset($escola_desabilitado) ? $escola_desabilitado : $desabilitado; - } - - $obj_permissoes = new clsPermissoes(); - $nivel_usuario = $obj_permissoes->nivel_acesso($this->pessoa_logada); - - if( $nivel_usuario == 1 ) - { - if( class_exists( "clsPmieducarInstituicao" ) ) - { - $opcoes = array( "" => "Selecione" ); - $obj_instituicao = new clsPmieducarInstituicao(); - $obj_instituicao->setCamposLista("cod_instituicao, nm_instituicao"); - $obj_instituicao->setOrderby("nm_instituicao ASC"); - $lista = $obj_instituicao->lista(null,null,null,null,null,null,null,null,null,null,null,null,null,1); - if ( is_array( $lista ) && count( $lista ) ) - { - foreach ( $lista as $registro ) - { - $opcoes["{$registro['cod_instituicao']}"] = "{$registro['nm_instituicao']}"; - } - } - } - else - { - echo ""; - $opcoes = array( "" => "Erro na geração" ); - } - if ($get_escola) - { - $retorno .= ' - - Instituição - * -
- - '; - $retorno .= ''; - $retorno .= ""; - $retorno .= ' - - '; - //$this->campoLista( "ref_cod_instituicao", "Instituição", $opcoes, $this->ref_cod_instituicao,"getDuplo();",null,null,null,$instituicao_desabilitado,$instituicao_obrigatorio); - } - } - if ( $nivel_usuario == 2 ) { - if ( $get_instituicao ) - { - $obj_per = new clsPermissoes(); - $this->ref_cod_instituicao = $obj_per->getInstituicao( $this->pessoa_logada ); - $retorno .= ""; - // $this->campoOculto( "ref_cod_instituicao", $this->ref_cod_instituicao ); - } - } - elseif ( $nivel_usuario != 1 ) - { - $obj_usuario = new clsPmieducarUsuario($this->pessoa_logada); - $det_usuario = $obj_usuario->detalhe(); - $this->ref_cod_instituicao = $det_usuario["ref_cod_instituicao"]; - if ($nivel_usuario == 4 || $nivel_usuario == 8) - { - $obj_usuario = new clsPmieducarUsuario($this->pessoa_logada); - $det_usuario = $obj_usuario->detalhe(); - $this->ref_cod_escola = $det_usuario["ref_cod_escola"]; - - } - } - - if ($nivel_usuario == 1 || $nivel_usuario == 2) - { - if ($get_escola) - { - if( class_exists( "clsPmieducarEscola" ) ) - { - $opcoes_escola = array( "" => "Selecione" ); - $todas_escolas = "escola = new Array();\n"; - $obj_escola = new clsPmieducarEscola(); - $lista = $obj_escola->lista(null,null,null,null,null,null,null,null,null,null,1); - if ( is_array( $lista ) && count( $lista ) ) - { - foreach ( $lista as $registro ) - { - $todas_escolas .= "escola[escola.length] = new Array( {$registro["cod_escola"]}, '{$registro['nome']}', {$registro["ref_cod_instituicao"]} );\n"; - } - } - echo ""; - } - else - { - echo ""; - $opcoes_escola = array( "" => "Erro na geração" ); - } - if ($this->ref_cod_instituicao) - { - if( class_exists( "clsPmieducarEscola" ) ) - { - $opcoes_escola = array( "" => "Selecione" ); - $obj_escola = new clsPmieducarEscola(); - $lista = $obj_escola->lista(null,null,null,$this->ref_cod_instituicao,null,null,null,null,null,null,1); - if ( is_array( $lista ) && count( $lista ) ) - { - foreach ( $lista as $registro ) - { - $opcoes_escola["{$registro["cod_escola"]}"] = "{$registro['nome']}"; - } - } - } - else - { - echo ""; - $opcoes_escola = array( "" => "Erro na geração" ); - } - } - if ($get_escola) - { - $retorno .= ' - - Escola - * -
- - '; - $retorno .= ''; - - $disabled = !$this->ref_cod_escola && $nivel_usuario == 1? "disabled='true' " : "" ; - $retorno .= " "; - $retorno .= ' - - '; - - //$this->campoLista( "ref_cod_instituicao", "Instituição", $opcoes, $this->ref_cod_instituicao,"getDuplo();",null,null,null,$instituicao_desabilitado,$instituicao_obrigatorio); - } - //$this->campoLista( "ref_cod_escola", "Escola", $opcoes_escola, $this->ref_cod_escola,null,null,null,null,$escola_desabilitado,$escola_obrigatorio ); - } - } - - if (isset($get_cabecalho)) - { - if ($nivel_usuario == 1 || $nivel_usuario == 2) - ${$get_cabecalho}[] = "Escola"; - if ($nivel_usuario == 1) - ${$get_cabecalho}[] = "Instituição"; - } - - $validacao = ""; - if($nivel_usuario== 1){ - $validacao = 'if(!document.getElementById("ref_cod_instituicao").value){ - alert("Por favor, selecione uma instituicao"); - return false; - } - if(!document.getElementById("ref_cod_escola").value){ - alert("Por favor, selecione uma escola"); - return false; - } '; - }elseif($nivel_usuario== 2 ){ - $validacao = ' - if(!document.getElementById("ref_cod_escola").value){ - alert("Por favor, selecione uma escola"); - return false; - } '; - } - $retorno .= ' - - Ano - * -
- - '; - $retorno .= ''; - $retorno .= " '; + + reset($opcoes); + + while (list($chave, $texto) = each($opcoes)) { + $retorno .= sprintf( + '"; + } + + $retorno .= ''; + $retorno .= ''; + } + } + + if ($nivel_usuario == 2) { + if ($get_instituicao) { + $obj_per = new clsPermissoes(); + $this->ref_cod_instituicao = $obj_per->getInstituicao($this->pessoa_logada); + $retorno .= sprintf( + '', + $this->ref_cod_instituicao + ); + } + } + elseif ($nivel_usuario != 1) { + $obj_usuario = new clsPmieducarUsuario($this->pessoa_logada); + $det_usuario = $obj_usuario->detalhe(); + $this->ref_cod_instituicao = $det_usuario['ref_cod_instituicao']; + + if ($nivel_usuario == 4 || $nivel_usuario == 8) { + $obj_usuario = new clsPmieducarUsuario($this->pessoa_logada); + $det_usuario = $obj_usuario->detalhe(); + $this->ref_cod_escola = $det_usuario['ref_cod_escola']; + } + } + + if ($nivel_usuario == 1 || $nivel_usuario == 2) { + if ($get_escola) { + if (class_exists('clsPmieducarEscola')) { + $opcoes_escola = array('' => 'Selecione'); + + $todas_escolas = 'escola = new Array();' . "\n"; + $obj_escola = new clsPmieducarEscola(); + + $lista = $obj_escola->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, 1); + + if (is_array($lista) && count($lista)) { + foreach ($lista as $registro) { + $todas_escolas .= sprintf( + 'escola[escola.length] = new Array(%s, \'%s\', %s);' . "\n", + $registro['cod_escola'], $registro['nome'], $registro['ref_cod_instituicao'] + ); + } + } + + echo sprintf('', $todas_escolas); + } + else { + $opcoes_escola = array('' => 'Erro na geração'); + } + + if ($this->ref_cod_instituicao) { + if (class_exists('clsPmieducarEscola')) { + $opcoes_escola = array('' => 'Selecione'); + $obj_escola = new clsPmieducarEscola(); + $lista = $obj_escola->lista(NULL, NULL, NULL, $this->ref_cod_instituicao, + NULL, NULL, NULL, NULL, NULL, NULL, 1); + + if (is_array($lista) && count($lista)) { + foreach ($lista as $registro) { + $opcoes_escola[$registro['cod_escola']] = $registro['nome']; + } + } + } + else { + $opcoes_escola = array('' => 'Erro na geração'); + } + } + + if ($get_escola) { + $retorno .= ' + + + Escola + *
+ + '; + + $retorno .= ''; + + $disabled = !$this->ref_cod_escola && $nivel_usuario == 1 ? 'disabled="true" ' : ''; + $retorno .= sprintf( + ' '; + $retorno .= ''; + } + } + } + + if (isset($get_cabecalho)) { + if ($nivel_usuario == 1 || $nivel_usuario == 2) { + ${$get_cabecalho}[] = 'Escola'; + } + if ($nivel_usuario == 1) { + ${$get_cabecalho}[] = 'Instituição'; + } + } + + $validacao = ''; + + if ($nivel_usuario == 1) { + $validacao = ' + if (!document.getElementById("ref_cod_instituicao").value) { + alert("Por favor, selecione uma instituicao"); + return false; + } + if (!document.getElementById("ref_cod_escola").value) { + alert("Por favor, selecione uma escola"); + return false; + } '; + } + elseif ($nivel_usuario == 2) { + $validacao = ' + if (!document.getElementById("ref_cod_escola").value){ + alert("Por favor, selecione uma escola"); + return false; + } '; + } + + $retorno .= ' + + + Ano + *
+ + '; + $retorno .= ''; + $retorno .= " '; + $retorno .= ''; + + $retorno .= ''; + + $retorno .= sprintf(" + + + + + + + + + + +   + ", $validacao); +?> + + + + +