From 8b09b141e2d7abd972df5a194c06599c0fb5d173 Mon Sep 17 00:00:00 2001 From: Eriksen Costa Paixão Date: Mon, 25 May 2009 14:10:26 +0000 Subject: [PATCH] --- ieducar/intranet/educar_reservada_vaga_lst.php | 532 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 1 file changed, 268 insertions(+), 264 deletions(-) diff --git a/ieducar/intranet/educar_reservada_vaga_lst.php b/ieducar/intranet/educar_reservada_vaga_lst.php index c685a91..d9b116f 100644 --- a/ieducar/intranet/educar_reservada_vaga_lst.php +++ b/ieducar/intranet/educar_reservada_vaga_lst.php @@ -1,279 +1,283 @@ SetTitulo( "{$this->_instituicao} i-Educar - Vagas Reservadas" ); - $this->processoAp = "639"; - } + +/* + * i-Educar - Sistema de gestão escolar + * + * Copyright (C) 2006 Prefeitura Municipal de Itajaí + * + * + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) + * qualquer versão posterior. + * + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral + * do GNU para mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto + * com este programa; se não, escreva para a Free Software Foundation, Inc., no + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + */ + +/** + * Listagem de reserva de vagas. + * + * @author Eriksen Costa Paixão + * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL + * @package Core + * @subpackage ReservaVaga + * @since Arquivo disponível desde a versão 1.0.0 + * @version $Id$ + */ + +require_once 'include/clsBase.inc.php'; +require_once 'include/clsListagem.inc.php'; +require_once 'include/clsBanco.inc.php'; +require_once 'include/pmieducar/geral.inc.php'; + + +class clsIndexBase extends clsBase { + public function Formular() { + $this->SetTitulo($this->_instituicao . ' i-Educar - Vagas Reservadas'); + $this->processoAp = '639'; + } } -class indice extends clsListagem -{ - /** - * Referencia pega da session para o idpes do usuario atual - * - * @var int - */ - var $pessoa_logada; - - /** - * Titulo no topo da pagina - * - * @var int - */ - var $titulo; - - /** - * Quantidade de registros a ser apresentada em cada pagina - * - * @var int - */ - var $limite; - - /** - * Inicio dos registros a serem exibidos (limit) - * - * @var int - */ - var $offset; - - var $cod_reserva_vaga; - var $ref_ref_cod_escola; - var $ref_ref_cod_serie; - var $ref_usuario_exc; - var $ref_usuario_cad; - var $ref_cod_aluno; - var $data_cadastro; - var $data_exclusao; - var $ativo; - - var $ref_cod_escola; - var $ref_cod_curso; - var $ref_cod_instituicao; - var $nm_aluno; - - function Gerar() - { - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - session_write_close(); - - $this->titulo = "Vagas Reservadas - 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( - "Aluno", - "Série", - "Curso" - ); - - $obj_permissao = new clsPermissoes(); - $nivel_usuario = $obj_permissao->nivel_acesso($this->pessoa_logada); - if ($nivel_usuario == 1) - { - $lista_busca[] = "Escola"; - $lista_busca[] = "Instituição"; - } - else if ($nivel_usuario == 2) - { - $lista_busca[] = "Escola"; - } - $this->addCabecalhos($lista_busca); - - $get_escola = true; -// $get_escola_curso = true; - $get_curso = true; - $get_escola_curso_serie = true; - include("include/pmieducar/educar_campo_lista.php"); - - if ( $this->ref_cod_escola ) - { - $this->ref_ref_cod_escola = $this->ref_cod_escola; - } - - $this->campoTexto("nm_aluno", "Aluno", $this->nm_aluno, 30, 255, false, false, false, "", ""); - $this->campoOculto("ref_cod_aluno", $this->ref_cod_aluno); - - // Paginador - $this->limite = 20; - $this->offset = ( $_GET["pagina_{$this->nome}"] ) ? $_GET["pagina_{$this->nome}"]*$this->limite-$this->limite: 0; - - $obj_reserva_vaga = new clsPmieducarReservaVaga(); - $obj_reserva_vaga->setOrderby( "data_cadastro ASC" ); - $obj_reserva_vaga->setLimite( $this->limite, $this->offset ); - - $lista = $obj_reserva_vaga->lista( - $this->cod_reserva_vaga, - $this->ref_ref_cod_escola, - $this->ref_ref_cod_serie, - null, - null, - $this->ref_cod_aluno, - null, - null, - null, - null, - 1, - $this->ref_cod_instituicao, - $this->ref_cod_curso - ); - - $total = $obj_reserva_vaga->_total; - - // monta a lista - if( is_array( $lista ) && count( $lista ) ) - { - foreach ( $lista AS $registro ) - { - if( class_exists( "clsPmieducarSerie" ) ) - { - $obj_serie = new clsPmieducarSerie( $registro["ref_ref_cod_serie"] ); - $det_serie = $obj_serie->detalhe(); - $nm_serie = $det_serie["nm_serie"]; - } - else - { - $registro["ref_ref_cod_serie"] = "Erro na geração"; - echo ""; - } - if( class_exists( "clsPmieducarCurso" ) ) - { - $obj_curso = new clsPmieducarCurso( $registro["ref_cod_curso"] ); - $det_curso = $obj_curso->detalhe(); - $registro["ref_cod_curso"] = $det_curso["nm_curso"]; - } - else - { - $registro["ref_cod_serie"] = "Erro na geração"; - echo ""; - } - if( class_exists( "clsPmieducarEscola" ) ) - { - $obj_escola = new clsPmieducarEscola( $registro["ref_ref_cod_escola"] ); - $det_escola = $obj_escola->detalhe(); - $nm_escola = $det_escola["nome"]; - } - else - { - $registro["ref_ref_cod_escola"] = "Erro na geração"; - echo ""; - } - 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_escola"] = "Erro na geração"; - echo ""; - } - if( class_exists( "clsPmieducarAluno" ) ) - { - $obj_aluno = new clsPmieducarAluno( $registro["ref_cod_aluno"] ); - $det_aluno = $obj_aluno->detalhe(); - $ref_idpes = $det_aluno["ref_idpes"]; - - if( class_exists( "clsPessoa_" ) ) - { - $obj_pessoa = new clsPessoa_( $ref_idpes ); - $det_pessoa = $obj_pessoa->detalhe(); - $registro["ref_cod_aluno"] = $det_pessoa["nome"]; - } - else - { - $registro["ref_cod_aluno"] = "Erro na geração"; - echo ""; - } - } - else - { - $registro["ref_cod_aluno"] = "Erro na geração"; - echo ""; - } - - $lista_busca = array( - "{$registro["ref_cod_aluno"]}", - "{$nm_serie}", - "{$registro["ref_cod_curso"]}" - ); - - if ($nivel_usuario == 1) - { - $lista_busca[] = "{$nm_escola}"; - $lista_busca[] = "{$registro["ref_cod_instituicao"]}"; - } - else if ($nivel_usuario == 2) - { - $lista_busca[] = "{$nm_escola}"; - } - $this->addLinhas($lista_busca); - } - } - $this->addPaginador2( "educar_reservada_vaga_lst.php", $total, $_GET, $this->nome, $this->limite ); - $this->largura = "100%"; - } + +class indice extends clsListagem { + + /** + * Referência a usuário da sessão + * @var int + */ + public $pessoa_logada = NULL; + + /** + * Título no topo da paágina + * @var string + */ + public $titulo = ''; + + /** + * Limite de registros por página + * @var int + */ + public $limite = 0; + + /** + * Início dos registros a serem exibidos (limit) + * @var int + */ + public $offset = 0; + + /** + * Atributos de mapeamento da tabela pmieducar.reserva_vaga + * @var mixed + */ + public + $cod_reserva_vaga = NULL, + $ref_ref_cod_escola = NULL, + $ref_ref_cod_serie = NULL, + $ref_usuario_exc = NULL, + $ref_usuario_cad = NULL, + $ref_cod_aluno = NULL, + $data_cadastro = NULL, + $data_exclusao = NULL, + $ativo = NULL; + + /** + * Atributos para apresentação + * @var mixed + */ + public + $ref_cod_escola = NULL, + $ref_cod_curso = NULL, + $ref_cod_instituicao = NULL, + $nm_aluno = NULL; + + + + /** + * Implementação de clsListagem::Gerar() + * @see ieducar/intranet/include/clsListagem#Gerar() + */ + public function Gerar() { + session_start(); + $this->pessoa_logada = $_SESSION['id_pessoa']; + session_write_close(); + + $this->titulo = 'Vagas Reservadas - Listagem'; + + // Passa todos os valores obtidos no GET para atributos do objeto + foreach ($_GET as $var => $val) { + $this->$var = ($val === '') ? NULL : $val; + } + + $this->addBanner('imagens/nvp_top_intranet.jpg', 'imagens/nvp_vert_intranet.jpg', 'Intranet'); + + $lista_busca = array( + 'Aluno', + 'Série', + 'Curso' + ); + + // Recupera ní­vel de acesso do usuário logado + $obj_permissao = new clsPermissoes(); + $nivel_usuario = $obj_permissao->nivel_acesso($this->pessoa_logada); + + if ($nivel_usuario == 1) { + $lista_busca[] = 'Escola'; + $lista_busca[] = 'Instituição'; + } + elseif ($nivel_usuario == 2) { + $lista_busca[] = 'Escola'; + } + $this->addCabecalhos($lista_busca); + + // Lista de opçõees para o formulário de pesquisa rápida + $get_escola = TRUE; + $get_curso = TRUE; + $get_escola_curso_serie = TRUE; + include 'include/pmieducar/educar_campo_lista.php'; + + // Referência de escola + if ($this->ref_cod_escola) { + $this->ref_ref_cod_escola = $this->ref_cod_escola; + } + + // Campos do formulário + $this->campoTexto('nm_aluno', 'Aluno', $this->nm_aluno, 30, 255, FALSE, FALSE, + FALSE, '', ''); + + // Código do aluno (retornado de pop-up de busca da pesquisa de alunos - lupa) + $this->campoOculto('ref_cod_aluno', $this->ref_cod_aluno); + + // Paginador + $this->limite = 20; + $this->offset = $_GET["pagina_{$this->nome}"] ? + ($_GET["pagina_{$this->nome}"] * $this->limite - $this->limite) + : 0; + + // Instância objeto de mapeamento relacional com o tabela pmieducar.reserva_vaga + $obj_reserva_vaga = new clsPmieducarReservaVaga(); + $obj_reserva_vaga->setOrderby('data_cadastro ASC'); + $obj_reserva_vaga->setLimite($this->limite, $this->offset); + + // Lista os registros usando os valores passados pelos filtros + $lista = $obj_reserva_vaga->lista( + $this->cod_reserva_vaga, + $this->ref_ref_cod_escola, + $this->ref_ref_cod_serie, + NULL, + NULL, + $this->ref_cod_aluno, + NULL, + NULL, + NULL, + NULL, + 1, + $this->ref_cod_instituicao, + $this->ref_cod_curso + ); + + // Pega o total de registros encontrados + $total = $obj_reserva_vaga->_total; + + // Itera sobre resultados montando a lista de apresentação + if (is_array($lista) && count($lista)) { + foreach ($lista as $registro) { + // Recupera nome da série da reserva de vaga + $obj_serie = new clsPmieducarSerie($registro['ref_ref_cod_serie']); + $det_serie = $obj_serie->detalhe(); + $nm_serie = $det_serie['nm_serie']; + + // Recupera o nome do curso da reserva de vaga + $obj_curso = new clsPmieducarCurso($registro['ref_cod_curso']); + $det_curso = $obj_curso->detalhe(); + $registro['ref_cod_curso'] = $det_curso['nm_curso']; + + // Recupera o nome da escola da reserva de vaga + $obj_escola = new clsPmieducarEscola($registro['ref_ref_cod_escola']); + $det_escola = $obj_escola->detalhe(); + $nm_escola = $det_escola['nome']; + + // Recupera o nome da instituição da reserva de vaga + $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']; + + /* + * Se for um aluno previamente cadastrado, procuramos seu nome, primeiro + * buscando a referência de Pessoa e depois pesquisando a tabela para + * carregar o nome + */ + if ($registro['ref_cod_aluno']) { + // Pesquisa por aluno para pegar o identificador de Pessoa + $obj_aluno = new clsPmieducarAluno($registro['ref_cod_aluno']); + $det_aluno = $obj_aluno->detalhe(); + $ref_idpes = $det_aluno['ref_idpes']; + + // Pesquisa a tabela de pessoa para recuperar o nome + $obj_pessoa = new clsPessoa_($ref_idpes); + $det_pessoa = $obj_pessoa->detalhe(); + $registro['ref_cod_aluno'] = $det_pessoa['nome']; + } + else { + $registro['ref_cod_aluno'] = $registro['nm_aluno']; + } + + // Array de dados formatados para apresentação + $lista_busca = array( + "{$registro["ref_cod_aluno"]}", + "{$nm_serie}", + "{$registro["ref_cod_curso"]}" + ); + + // Verifica por permissões + if ($nivel_usuario == 1) { + $lista_busca[] = "{$nm_escola}"; + $lista_busca[] = "{$registro["ref_cod_instituicao"]}"; + } + elseif ($nivel_usuario == 2) { + $lista_busca[] = "{$nm_escola}"; + } + + $this->addLinhas($lista_busca); + } + } + + $this->addPaginador2('educar_reservada_vaga_lst.php', $total, $_GET, + $this->nome, $this->limite); + + $this->largura = '100%'; + } } -// cria uma extensao da classe base + +// Instancia objeto de página $pagina = new clsIndexBase(); -// cria o conteudo + +// Instancia objeto de conteúdo $miolo = new indice(); -// adiciona o conteudo na clsBase -$pagina->addForm( $miolo ); -// gera o html + +// Atribui o conteúdo à  página +$pagina->addForm($miolo); + +// Gera o código HTML $pagina->MakeAll(); ?> - \ No newline at end of file -- libgit2 0.21.2