educar_pesquisa_servidor_lst.php
14.8 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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
<?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>
* @category i-Educar
* @license @@license@@
* @package iEd_Pmieducar
* @since Arquivo disponÃvel desde a versão 1.0.0
* @version $Id$
*/
use Illuminate\Support\Facades\Session;
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';
/**
* clsIndexBase class.
*
* @author Prefeitura Municipal de Itajaà <ctima@itajai.sc.gov.br>
* @category i-Educar
* @license @@license@@
* @package iEd_Pmieducar
* @since Classe disponÃvel desde a versão 1.0.0
* @version @@package_version@@
*/
class clsIndexBase extends clsBase
{
public function Formular()
{
$this->SetTitulo($this->_instituicao . ' i-Educar - Servidor');
$this->processoAp = '0';
$this->renderMenu = FALSE;
$this->renderMenuSuspenso = FALSE;
}
}
/**
* indice class.
*
* @author Prefeitura Municipal de Itajaà <ctima@itajai.sc.gov.br>
* @category i-Educar
* @license @@license@@
* @package iEd_Pmieducar
* @since Classe disponÃvel desde a versão 1.0.0
* @version @@package_version@@
*/
class indice extends clsListagem
{
var $pessoa_logada;
var $titulo;
var $limite;
var $offset;
var $cod_servidor;
var $ref_idesco;
var $ref_cod_funcao;
var $carga_horaria;
var $data_cadastro;
var $data_exclusao;
var $ativo;
var $horario;
var $lst_matriculas;
var $ref_cod_instituicao;
var $professor;
var $ref_cod_escola;
var $nome_servidor;
var $ref_cod_servidor;
var $periodo;
var $carga_horaria_usada;
var $min_mat;
var $min_ves;
var $min_not;
var $dia_semana;
var $ref_cod_disciplina;
var $ref_cod_curso;
var $matutino = FALSE;
var $vespertino = FALSE;
var $noturno = FALSE;
var $identificador;
var $ano_alocacao;
function Gerar()
{
Session::put([
'campo1' => $_GET['campo1'] ?? Session::get('campo1'),
'campo2' => $_GET['campo2'] ?? Session::get('campo2'),
'dia_semana' => $_GET['dia_semana'] ?? Session::get('dia_semana'),
'hora_inicial' => $_GET['hora_inicial'] ?? Session::get('hora_inicial'),
'hora_final' => $_GET['hora_final'] ?? Session::get('hora_final'),
'professor' => $_GET['professor'] ?? Session::get('professor'),
'horario' => $_GET['horario'] ?? Session::get('horario'),
'ref_cod_escola' => $_GET['ref_cod_escola'] ?? Session::get('ref_cod_escola'),
'min_mat' => $_GET['min_mat'] ?? Session::get('min_mat'),
'min_ves' => $_GET['min_ves'] ?? Session::get('min_ves'),
'min_not' => $_GET['min_not'] ?? Session::get('min_not'),
'ref_cod_disciplina' => $_GET['ref_cod_disciplina'] ?? Session::get('ref_cod_disciplina'),
'ref_cod_curso' => $_GET['ref_cod_curso'] ?? Session::get('ref_cod_curso'),
'ano_alocacao' => $_GET['ano_alocacao'] ?? Session::get('ano_alocacao'),
'identificador' => $_GET['identificador'] ?? Session::get('identificador'),
'lst_matriculas' => $_GET['lst_matriculas'] ?? Session::get('lst_matriculas'),
'ref_cod_instituicao' => $_GET['ref_cod_instituicao'] ? $_GET['ref_cod_instituicao'] : Session::get('ref_cod_instituicao'),
'ref_cod_servidor' => $_GET['ref_cod_servidor'] ? $_GET['ref_cod_servidor'] : Session::get('ref_cod_servidor'),
]);
if (!isset($_GET['tipo'])) {
Session::forget([
'setAllField1',
'setAllField2',
'tipo',
]);
}
$this->ref_cod_escola = Session::get('ref_cod_escola');
$this->ref_cod_instituicao = Session::get('ref_cod_instituicao');
$this->ref_cod_servidor = Session::get('ref_cod_servidor');
$this->professor = Session::get('professor');
$this->horario = Session::get('horario');
$this->min_mat = Session::get('min_mat');
$this->min_ves = Session::get('min_ves');
$this->min_not = Session::get('min_not');
$this->ref_cod_disciplina = Session::get('ref_cod_disciplina');
$this->ref_cod_curso = Session::get('ref_cod_curso');
$this->identificador = Session::get('identificador');
$this->ano_alocacao = Session::get('ano_alocacao');
$this->lst_matriculas = Session::get('lst_matriculas');
Session::put('tipo', $_GET['tipo'] ?? Session::get('tipo'));
$this->titulo = 'Servidores Públicos - Listagem';
// Passa todos os valores obtidos no GET para atributos do objeto
foreach ($_GET as $var => $val) {
$this->$var = $val === '' ? NULL : $val;
}
if (isset($this->lst_matriculas)) {
$this->lst_matriculas = urldecode($this->lst_matriculas);
}
$string1 = ($this->min_mat - floor($this->min_mat / 60) * 60);
$string1 = str_repeat(0, 2 - strlen($string1)).$string1;
$string2 = floor($this->min_mat / 60);
$string2 = str_repeat(0, 2 - strlen($string2)).$string2;
$hr_mat = $string2.':'.$string1;
$string1 = ($this->min_ves - floor($this->min_ves / 60) * 60);
$string1 = str_repeat(0, 2 - strlen($string1)).$string1;
$string2 = floor($this->min_ves / 60);
$string2 = str_repeat(0, 2 - strlen($string2)).$string2;
$hr_ves = $string2.':'.$string1;
$string1 = ($this->min_not - floor($this->min_not / 60) * 60);
$string1 = str_repeat(0, 2 - strlen($string1)).$string1;
$string2 = floor($this->min_not / 60);
$string2 = str_repeat(0, 2 - strlen($string2)).$string2;
$hr_not = $string2.':'.$string1;
$hora_inicial_ = explode(':', Session::get('hora_inicial'));
$hora_final_ = explode(':', Session::get('hora_final'));
$horas_ini = sprintf('%02d', (int) abs($hora_final_[0]) - abs($hora_inicial_[0]));
$minutos_ini = sprintf('%02d', (int) abs($hora_final_[1]) - abs($hora_inicial_[1]));
$h_m_ini = ($hora_inicial_[0] * 60) + $hora_inicial_[1];
$h_m_fim = ($hora_final_[0] * 60) + $hora_final_[1];
if ($h_m_ini >= 480 && $h_m_ini <= 720) {
$this->matutino = TRUE;
if ($h_m_fim >= 721 && $h_m_fim <= 1080) {
$this->vespertino = TRUE;
}
elseif (($h_m_fim >= 1801 && $h_m_fim <= 1439) || ($h_m_fim == 0)) {
$this->noturno = TRUE;
}
}
elseif ($h_m_ini >= 721 && $h_m_ini <= 1080) {
$this->vespertino = TRUE;
if (($h_m_fim >= 1081 && $h_m_fim <= 1439)) {
$this->noturno = TRUE;
}
}
elseif (($h_m_ini >= 1081 && $h_m_ini <= 1439) || ($h_m_ini == 0)) {
$this->noturno = TRUE;
}
$this->addCabecalhos(array(
'Nome do Servidor',
'Matrícula',
'Instituição'
));
$this->campoTexto('nome_servidor', 'Nome Servidor', $this->nome_servidor, 30, 255, FALSE);
$this->campoOculto('tipo', $_GET['tipo']);
// Paginador
$this->limite = 20;
$this->offset = ($_GET['pagina_{$this->nome}']) ? $_GET['pagina_{$this->nome}'] * $this->limite-$this->limite: 0;
$obj_servidor = new clsPmieducarServidor();
$obj_servidor->setOrderby('carga_horaria ASC');
$obj_servidor->setLimite($this->limite, $this->offset);
if (Session::has(['dia_semana', 'hora_inicial', 'hora_final'])) {
$array_hora = [
Session::get('dia_semana'),
Session::get('hora_inicial'),
Session::get('hora_final')
];
}
// Marca a disciplina como NULL se não for informada, restringindo a busca
// aos professores e não selecionar aqueles em que o curso não seja
// globalizado e sem disciplinas cadastradas
$this->ref_cod_disciplina = $this->ref_cod_disciplina ?
$this->ref_cod_disciplina : NULL;
// Passa NULL para $alocacao_escola_instituicao senão o seu filtro anula
// um anterior (referente a selecionar somente servidores não alocados),
// selecionando apenas servidores alocados na instituição
$lista = $obj_servidor->lista(
NULL,
NULL,
$this->ref_idesco,
$this->carga_horaria,
NULL,
NULL,
NULL,
NULL,
1,
$this->ref_cod_instituicao,
Session::get('tipo'),
$array_hora,
$this->ref_cod_servidor,
$this->nome_servidor,
TRUE,
$this->horario,
FALSE,
$this->lst_matriculas,
$this->matutino,
$this->vespertino,
$this->noturno,
$this->ref_cod_escola,
$hr_mat,
$hr_ves,
$hr_not,
Session::get('dia_semana'),
$this->ref_cod_escola,
$this->identificador,
$this->ref_cod_curso,
$this->ref_cod_disciplina,
NULL,
NULL,
$this->ano_alocacao
);
// Se for uma listagem de professores, recupera as disciplinas dadas para
// comparação com a de outros professores (somente quando a busca é para
// substituição de servidores)
$disciplinas = array();
if ('true' == $this->professor) {
$disciplinas = $obj_servidor->getServidorDisciplinasQuadroHorarioHorarios(
$this->ref_cod_servidor, $this->ref_cod_instituicao);
}
$total = $obj_servidor->_total;
// pega detalhes de foreign_keys
$obj_ref_cod_instituicao = new clsPmieducarInstituicao( $lista[0]["ref_cod_instituicao"] );
$det_ref_cod_instituicao = $obj_ref_cod_instituicao->detalhe();
$nm_instituicao = $det_ref_cod_instituicao["nm_instituicao"];
// monta a lista
if (is_array($lista) && count($lista)) {
foreach ($lista as $registro) {
$obj_cod_servidor = new clsFuncionario( $registro['cod_servidor'] );
$det_cod_servidor = $obj_cod_servidor->detalhe();
$registro['matricula'] = $det_cod_servidor['matricula'];
// Se servidor for professor, verifica se possui as mesmas
// disciplinas do servidor a ser substituido (este passo somente é
// executado ao buscar um servidor substituto)
if ($this->professor == 'true') {
$disciplinasSubstituto = clsPmieducarServidor::getServidorDisciplinas(
$registro['cod_servidor'], $this->ref_cod_instituicao);
// Se os arrays diferirem, passa para o próximo resultado
if ($disciplinasSubstituto != $disciplinas) {
continue;
}
}
$campo1 = Session::get('campo1');
$campo2 = Session::get('campo2');
if (Session::get('tipo')) {
if (is_string($campo1) && is_string($campo2)) {
if (is_string( Session::get('horario'))) {
$script = " onclick=\"addVal1('{$campo1}','{$registro['nome']}','{$registro['cod_servidor']}'); addVal1('{$campo2}','{$registro['cod_servidor']}','{$registro['nome']}'); $setAll fecha();\"";
}
else {
$script = " onclick=\"addVal1('{$campo1}','{$registro['cod_servidor']}', '{$registro['nome']}'); addVal1('{$campo2}','{$registro['nome']}', '{$registro['cod_servidor']}'); $setAll fecha();\"";
}
}
elseif (is_string($campo1)) {
$script = " onclick=\"addVal1('{$campo1}','{$registro['cod_servidor']}','{$registro['nome']}'); $setAll fecha();\"";
}
}
else {
if (is_string($campo1) && is_string($campo2)) {
$script = " onclick=\"addVal1('{$campo1}','{$registro['cod_servidor']}','{$registro['nome']}'); addVal1('{$campo2}','{$registro['cod_servidor']}','{$registro['nome']}'); $setAll fecha();\"";
}
elseif (is_string($campo2)) {
$script = " onclick=\"addVal1('{$campo2}','{$registro['cod_servidor']}','{$registro['nome']}'); $setAll fecha();\"";
}
elseif (is_string($campo1)) {
$script = " onclick=\"addVal1('{$campo1}','{$registro['cod_servidor']}','{$registro['nome']}'); $setAll fecha();\"";
}
}
$this->addLinhas(array(
"<a href=\"javascript:void(0);\" $script>{$registro["nome"]}</a>",
"<a href=\"javascript:void(0);\" $script>{$registro["matricula"]}</a>",
"<a href=\"javascript:void(0);\" $script>{$nm_instituicao}</a>"
) );
}
}
$this->addPaginador2('educar_pesquisa_servidor_lst.php', $total, $_GET,
$this->nome, $this->limite);
$obj_permissoes = new clsPermissoes();
$this->largura = '100%';
}
}
// 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">
function addVal1(campo,opcao, valor)
{
if (window.parent.document.getElementById(campo)) {
if (window.parent.document.getElementById(campo).type == 'select-one') {
obj = window.parent.document.getElementById(campo);
novoIndice = obj.options.length;
obj.options[novoIndice] = new Option(valor);
valor = obj.options[novoIndice];
valor.value = opcao.toString();
valor.selected = true;
obj.onchange();
}
else if (window.parent.document.getElementById(campo)) {
obj = window.parent.document.getElementById(campo);
obj.value = valor;
}
}
}
function fecha()
{
window.parent.fechaExpansivel('div_dinamico_' + (parent.DOM_divs.length * 1 - 1));
}
function setAll(field,value)
{
var elements = window.parent.document.getElementsByName(field);
for (var ct = 0;ct < elements.length; ct++) {
elements[ct].value = value;
}
}
function clearAll()
{
var elements = window.parent.document.getElementsByName('ref_cod_servidor_substituto');
for (var ct = 0;ct < elements.length;ct++) {
elements[ct].value = '';
}
for (var ct =0;ct < num_alocacao;ct++) {
var elements = window.parent.document.getElementById('ref_cod_servidor_substituto_' + ct).value='';
}
}
function getArrayHora(hora)
{
var array_h;
if(hora) {
array_h = hora.split(':');
}
else {
array_h = new Array(0,0);
}
return array_h;
}
</script>