educar_reservada_vaga_lst.php
9.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
<?php
/**
* i-Educar - Sistema de gestão escolar
*
* Copyright (C) 2006 Prefeitura Municipal de Itajaí
* <ctima@itajai.sc.gov.br>
*
* 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.
*
* @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
* @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
{
/**
* Referência a usuário da sessão
* @var int
*/
var $pessoa_logada = NULL;
/**
* Título no topo da página
* @var string
*/
var $titulo = '';
/**
* Limite de registros por página
* @var int
*/
var $limite = 0;
/**
* Início dos registros a serem exibidos (limit)
* @var int
*/
var $offset = 0;
// Atributos de mapeamento da tabela pmieducar.reserva_vaga
var
$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
*/
var
$ref_cod_escola = NULL,
$ref_cod_curso = NULL,
$ref_cod_instituicao = NULL,
$nm_aluno = NULL;
/**
* Sobrescreve clsListagem::Gerar().
* @see clsListagem::Gerar()
*/
function Gerar()
{
$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;
}
$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;
}
elseif (isset($_GET['ref_cod_escola'])) {
$this->ref_ref_cod_escola = intval($_GET['ref_cod_escola']);
}
// Referência de série
if ($this->ref_cod_serie) {
$this->ref_ref_cod_serie = $this->ref_cod_serie;
}
elseif (isset($_GET['ref_cod_serie'])) {
$this->ref_ref_cod_serie = intval($_GET['ref_cod_serie']);
}
// Campos do formulário
$this->campoTexto('nm_aluno', 'Aluno', $this->nm_aluno, 30, 255, FALSE, FALSE,
FALSE, '', '<img border="0" onclick="pesquisa_aluno();" id="ref_cod_aluno_lupa" name="ref_cod_aluno_lupa" src="imagens/lupa.png" />');
// 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'] . ' (aluno externo)';
}
// Array de dados formatados para apresentação
$lista_busca = array(
"<a href=\"educar_reservada_vaga_det.php?cod_reserva_vaga={$registro["cod_reserva_vaga"]}\">{$registro["ref_cod_aluno"]}</a>",
"<a href=\"educar_reservada_vaga_det.php?cod_reserva_vaga={$registro["cod_reserva_vaga"]}\">{$nm_serie}</a>",
"<a href=\"educar_reservada_vaga_det.php?cod_reserva_vaga={$registro["cod_reserva_vaga"]}\">{$registro["ref_cod_curso"]}</a>"
);
// Verifica por permissões
if ($nivel_usuario == 1) {
$lista_busca[] = "<a href=\"educar_reservada_vaga_det.php?cod_reserva_vaga={$registro["cod_reserva_vaga"]}\">{$nm_escola}</a>";
$lista_busca[] = "<a href=\"educar_reservada_vaga_det.php?cod_reserva_vaga={$registro["cod_reserva_vaga"]}\">{$registro["ref_cod_instituicao"]}</a>";
}
elseif ($nivel_usuario == 2) {
$lista_busca[] = "<a href=\"educar_reservada_vaga_det.php?cod_reserva_vaga={$registro["cod_reserva_vaga"]}\">{$nm_escola}</a>";
}
$this->addLinhas($lista_busca);
}
}
$this->addPaginador2('educar_reservada_vaga_lst.php', $total, $_GET,
$this->nome, $this->limite);
$this->largura = '100%';
$this->breadcrumb('Listagem de vagas reservadas', [
url('intranet/educar_index.php') => 'Escola',
]);
}
}
// Instancia objeto de página
$pagina = new clsIndexBase();
// Instancia objeto de conteúdo
$miolo = new indice();
// Atribui o conteúdo à página
$pagina->addForm($miolo);
// Gera o código HTML
$pagina->MakeAll();
?>
<script type="text/javascript">
document.getElementById('ref_cod_escola').onchange = function() {
getEscolaCurso();
}
document.getElementById('ref_cod_curso').onchange = function() {
getEscolaCursoSerie();
}
function pesquisa_aluno() {
pesquisa_valores_popless('educar_pesquisa_aluno.php')
}
</script>