educar_servidor_substituicao_cad.php
8.67 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
<?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$
*/
require_once 'include/clsBase.inc.php';
require_once 'include/clsCadastro.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
{
function Formular()
{
$this->SetTitulo($this->_instituicao . ' Servidores - Servidor Substituição');
$this->processoAp = 635;
}
}
/**
* 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 clsCadastro
{
var $pessoa_logada;
var $cod_servidor_alocacao;
var $ref_ref_cod_instituicao;
var $ref_usuario_exc;
var $ref_usuario_cad;
var $ref_cod_escola;
var $ref_cod_servidor;
var $dia_semana;
var $hora_inicial;
var $hora_final;
var $data_cadastro;
var $data_exclusao;
var $ativo;
var $todos;
var $alocacao_array = array();
var $professor;
function Inicializar()
{
$retorno = 'Novo';
$this->ref_cod_servidor = $_GET['ref_cod_servidor'];
$this->ref_ref_cod_instituicao = $_GET['ref_cod_instituicao'];
$obj_permissoes = new clsPermissoes();
$obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 3,
'educar_servidor_lst.php');
if (is_numeric($this->ref_cod_servidor) && is_numeric($this->ref_ref_cod_instituicao)) {
$retorno = 'Novo';
$obj_servidor = new clsPmieducarServidor($this->ref_cod_servidor,
NULL, NULL, NULL, NULL, NULL, NULL, $this->ref_ref_cod_instituicao);
$det_servidor = $obj_servidor->detalhe();
// Nenhum servidor com o código de servidor e instituição
if (!$det_servidor) {
$this->simpleRedirect('educar_servidor_lst.php');
}
$this->professor = $obj_servidor->isProfessor() == TRUE ? 'true' : 'false';
$obj = new clsPmieducarServidorAlocacao();
$lista = $obj->lista(NULL, $this->ref_ref_cod_instituicao, NULL,
NULL, NULL, $this->ref_cod_servidor, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, 1);
if ($lista) {
// passa todos os valores obtidos no registro para atributos do objeto
foreach ($lista as $campo => $val){
$temp = array();
$temp['carga_horaria'] = $val['carga_horaria'];
$temp['periodo'] = $val['periodo'];
$temp['ref_cod_escola'] = $val['ref_cod_escola'];
$this->alocacao_array[] = $temp;
}
$retorno = 'Novo';
}
$this->carga_horaria = $det_servidor['carga_horaria'];
}
else {
$this->simpleRedirect('educar_servidor_lst.php');
}
$this->url_cancelar = sprintf(
'educar_servidor_det.php?cod_servidor=%d&ref_cod_instituicao=%d',
$this->ref_cod_servidor, $this->ref_ref_cod_instituicao);
$this->nome_url_cancelar = 'Cancelar';
$this->breadcrumb('Substituir servidor', [
url('intranet/educar_servidores_index.php') => 'Servidores',
]);
return $retorno;
}
function Gerar()
{
$obj_inst = new clsPmieducarInstituicao($this->ref_ref_cod_instituicao);
$inst_det = $obj_inst->detalhe();
$this->campoRotulo('nm_instituicao', 'Instituição', $inst_det['nm_instituicao']);
$this->campoOculto('ref_ref_cod_instituicao', $this->ref_ref_cod_instituicao);
$opcoes = array('' => 'Selecione');
$objTemp = new clsPmieducarServidor($this->ref_cod_servidor);
$det = $objTemp->detalhe();
if ($det) {
foreach ($det as $key => $registro) {
$this->$key = $registro;
}
}
if ($this->ref_cod_servidor) {
$objPessoa = new clsPessoa_($this->ref_cod_servidor);
$detalhePessoa = $objPessoa->detalhe();
$nm_servidor = $detalhePessoa['nome'];
}
$this->campoRotulo('nm_servidor', 'Servidor', $nm_servidor);
$this->campoOculto('ref_cod_servidor', $this->ref_cod_servidor);
$this->campoOculto('professor',$this->professor);
$url = sprintf(
'educar_pesquisa_servidor_lst.php?campo1=ref_cod_servidor_todos_&campo2=ref_cod_servidor_todos&ref_cod_instituicao=%d&ref_cod_servidor=%d&tipo=livre&professor=%d',
$this->ref_ref_cod_instituicao, $this->ref_cod_servidor, $this->professor
);
$img = sprintf(
'<img border="0" onclick="pesquisa_valores_popless(\'%s\', \'nome\')" src="imagens/lupa.png">',
$url
);
$this->campoTextoInv('ref_cod_servidor_todos_', 'Substituir por:', '',
30, 255, TRUE, FALSE, FALSE, '', $img,
'', '', '');
$this->campoOculto('ref_cod_servidor_todos', '');
$this->campoOculto('alocacao_array', serialize($this->alocacao_array));
$this->acao_enviar = 'acao2()';
}
function Novo()
{
$professor = isset($_POST['professor']) ? strtolower($_POST['professor']) : 'FALSE';
$substituto = isset($_POST['ref_cod_servidor_todos']) ? $_POST['ref_cod_servidor_todos'] : NULL;
$permissoes = new clsPermissoes();
$permissoes->permissao_cadastra(635, $this->pessoa_logada, 3,
'educar_servidor_alocacao_lst.php');
$this->alocacao_array = array();
if ($_POST['alocacao_array']) {
$this->alocacao_array = unserialize(urldecode($_POST['alocacao_array']));
}
if ($this->alocacao_array) {
// Substitui todas as alocações
foreach ($this->alocacao_array as $key => $alocacao) {
$obj = new clsPmieducarServidorAlocacao(NULL, $this->ref_ref_cod_instituicao,
$this->pessoa_logada, $this->pessoa_logada, $alocacao['ref_cod_escola'],
$this->ref_cod_servidor, NULL, NULL, NULL, $alocacao['carga_horaria'],
$alocacao['periodo']);
$return = $obj->lista(NULL, $this->ref_ref_cod_instituicao, NULL, NULL,
$alocacao['ref_cod_escola'], $this->ref_cod_servidor, NULL, NULL, NULL,
NULL, 1, $alocacao['carga_horaria']);
if (FALSE !== $return) {
$substituiu = $obj->substituir_servidor($substituto);
if (!$substituiu) {
$this->mensagem = "Substituicao não realizado.<br>";
return FALSE;
}
}
}
// Substituição do servidor no quadro de horários (caso seja professor)
if ('true' == $professor) {
$quadroHorarios = new clsPmieducarQuadroHorarioHorarios(NULL, NULL, NULL,
NULL, NULL, NULL, $this->ref_ref_cod_instituicao, NULL, $this->ref_cod_servidor,
NULL, NULL, NULL, NULL, 1, NULL, NULL);
$quadroHorarios->substituir_servidor($substituto);
}
}
$this->mensagem .= 'Cadastro efetuado com sucesso.<br>';
$destination = 'educar_servidor_det.php?cod_servidor=%s&ref_cod_instituicao=%s';
$destination = sprintf($destination, $this->ref_cod_servidor, $this->ref_ref_cod_instituicao);
$this->simpleRedirect($destination);
}
function Editar()
{
return FALSE;
}
function Excluir()
{
return FALSE;
}
}
// 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 acao2()
{
if (document.getElementById('ref_cod_servidor_todos').value == ''){
alert("Selecione um servidor substituto!");
return false;
}
acao();
}
</script>