Commit c7299884c5b6bc747490447f58e5e1a7d27635f4

Authored by Eriksen Costa Paixão
1 parent 8bcf8480
Exists in master

#32 by Eriksen: Corrigido execução de regra de negócio ao afastar servidor. A correção envolve:

 * Refactoring de código
 * Correção de código SQL com erro em clsPmieducarServidor::Listar()
 * Teste funcional ServidorAfastarWebTest atualizado para cobrir a correção

ieducar/intranet/educar_servidor_afastamento_cad.php
@@ -33,7 +33,6 @@ require_once 'include/pmieducar/geral.inc.php'; @@ -33,7 +33,6 @@ require_once 'include/pmieducar/geral.inc.php';
33 33
34 34
35 class clsIndexBase extends clsBase { 35 class clsIndexBase extends clsBase {
36 -  
37 public function Formular() { 36 public function Formular() {
38 $this->SetTitulo($this->_instituicao . ' i-Educar - Servidor Afastamento'); 37 $this->SetTitulo($this->_instituicao . ' i-Educar - Servidor Afastamento');
39 $this->processoAp = '635'; 38 $this->processoAp = '635';
@@ -46,11 +45,13 @@ class indice extends clsCadastro { @@ -46,11 +45,13 @@ class indice extends clsCadastro {
46 45
47 /** 46 /**
48 * Referência a usuário da sessão 47 * Referência a usuário da sessão
49 - *  
50 * @var int 48 * @var int
51 */ 49 */
52 public $pessoa_logada = NULL; 50 public $pessoa_logada = NULL;
53 51
  52 + /**
  53 + * Atributos de mapeamento dos campos de banco de dados
  54 + */
54 public 55 public
55 $ref_cod_servidor = NULL, 56 $ref_cod_servidor = NULL,
56 $sequencial = NULL, 57 $sequencial = NULL,
@@ -68,9 +69,8 @@ class indice extends clsCadastro { @@ -68,9 +69,8 @@ class indice extends clsCadastro {
68 $parametros = NULL; 69 $parametros = NULL;
69 70
70 /** 71 /**
71 - * Array dos dias da semana  
72 - *  
73 - * @var Array 72 + * Dias da semana
  73 + * @var array
74 */ 74 */
75 public $dias_da_semana = array( 75 public $dias_da_semana = array(
76 '' => 'Selecione', 76 '' => 'Selecione',
@@ -85,6 +85,10 @@ class indice extends clsCadastro { @@ -85,6 +85,10 @@ class indice extends clsCadastro {
85 85
86 86
87 87
  88 + /**
  89 + * Implementação do método clsCadastro::Inicializar()
  90 + * @see ieducar/intranet/include/clsCadastro#Inicializar()
  91 + */
88 public function Inicializar() { 92 public function Inicializar() {
89 session_start(); 93 session_start();
90 $this->pessoa_logada = $_SESSION['id_pessoa']; 94 $this->pessoa_logada = $_SESSION['id_pessoa'];
@@ -113,8 +117,7 @@ class indice extends clsCadastro { @@ -113,8 +117,7 @@ class indice extends clsCadastro {
113 $registro = $obj->detalhe(); 117 $registro = $obj->detalhe();
114 118
115 if ($registro) { 119 if ($registro) {
116 -  
117 - // passa todos os valores obtidos no registro para atributos do objeto 120 + // Passa todos os valores obtidos no registro para atributos do objeto
118 foreach ($registro as $campo => $val) { 121 foreach ($registro as $campo => $val) {
119 $this->$campo = $val; 122 $this->$campo = $val;
120 } 123 }
@@ -143,6 +146,10 @@ class indice extends clsCadastro { @@ -143,6 +146,10 @@ class indice extends clsCadastro {
143 146
144 147
145 148
  149 + /**
  150 + * Implementação do método clsCadastro::Gerar()
  151 + * @see ieducar/intranet/include/clsCadastro#Gerar()
  152 + */
146 public function Gerar() { 153 public function Gerar() {
147 $this->campoOculto('ref_cod_servidor', $this->ref_cod_servidor); 154 $this->campoOculto('ref_cod_servidor', $this->ref_cod_servidor);
148 $this->campoOculto('sequencial', $this->sequencial); 155 $this->campoOculto('sequencial', $this->sequencial);
@@ -153,13 +160,13 @@ class indice extends clsCadastro { @@ -153,13 +160,13 @@ class indice extends clsCadastro {
153 $objTemp = new clsPmieducarMotivoAfastamento(); 160 $objTemp = new clsPmieducarMotivoAfastamento();
154 $lista = $objTemp->lista(); 161 $lista = $objTemp->lista();
155 162
156 - if (is_array($lista) && count($lista)) { 163 + if (is_array($lista) && count($lista) > 0) {
157 foreach ($lista as $registro) { 164 foreach ($lista as $registro) {
158 $opcoes[$registro['cod_motivo_afastamento']] = $registro['nm_motivo']; 165 $opcoes[$registro['cod_motivo_afastamento']] = $registro['nm_motivo'];
159 } 166 }
160 } 167 }
161 else { 168 else {
162 - $opcoes = array('' => 'Erro na geracao'); 169 + $opcoes = array('' => 'Nenhum motivo de afastamento cadastrado');
163 } 170 }
164 171
165 if ($this->status == 'N') { 172 if ($this->status == 'N') {
@@ -171,123 +178,140 @@ class indice extends clsCadastro { @@ -171,123 +178,140 @@ class indice extends clsCadastro {
171 $opcoes, $this->ref_cod_motivo_afastamento, '', FALSE, '', '', TRUE); 178 $opcoes, $this->ref_cod_motivo_afastamento, '', FALSE, '', '', TRUE);
172 } 179 }
173 180
174 - // data 181 + // Datas para registro
  182 + // Se novo registro
175 if ($this->status == 'N') { 183 if ($this->status == 'N') {
176 $this->campoData('data_saida', 'Data de Afastamento', $this->data_saida, TRUE); 184 $this->campoData('data_saida', 'Data de Afastamento', $this->data_saida, TRUE);
177 } 185 }
  186 + // Se edição, mostra a data de afastamento
178 elseif ($this->status == 'E') { 187 elseif ($this->status == 'E') {
179 $this->campoRotulo('data_saida', 'Data de Afastamento', $this->data_saida); 188 $this->campoRotulo('data_saida', 'Data de Afastamento', $this->data_saida);
180 } 189 }
181 190
  191 + // Se edição, mostra campo para entrar com data de retorno
182 if ($this->status == 'E') { 192 if ($this->status == 'E') {
183 $this->campoData('data_retorno', 'Data de Retorno', $this->data_retorno, FALSE); 193 $this->campoData('data_retorno', 'Data de Retorno', $this->data_retorno, FALSE);
184 } 194 }
185 195
186 - if (class_exists('clsPmieducarServidor')) {  
187 - $obj_servidor = new clsPmieducarServidor($this->ref_cod_servidor,  
188 - NULL, NULL, NULL, NULL, NULL, 1, $this->ref_cod_instituicao); 196 + $obj_servidor = new clsPmieducarServidor($this->ref_cod_servidor,
  197 + NULL, NULL, NULL, NULL, NULL, 1, $this->ref_cod_instituicao);
189 198
190 - $det_servidor = $obj_servidor->detalhe(); 199 + $det_servidor = $obj_servidor->detalhe();
191 200
192 - if ($det_servidor) {  
193 201
194 - if (class_exists('clsPmieducarFuncao')) {  
195 - $obj_funcao = new clsPmieducarFuncao($det_servidor['ref_cod_funcao'],  
196 - NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, $this->ref_cod_instituicao); 202 + if ($det_servidor) {
  203 + $obj_funcao = new clsPmieducarFuncao($det_servidor['ref_cod_funcao'],
  204 + NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, $this->ref_cod_instituicao);
197 205
198 - $det_funcao = $obj_funcao->detalhe(); 206 + // Se for professor
  207 + if (TRUE == $obj_servidor->isProfessor()) {
  208 + $obj = new clsPmieducarQuadroHorarioHorarios();
199 209
200 - if ($det_funcao['professor'] == 1) {  
201 - $obj = new clsPmieducarQuadroHorarioHorarios();  
202 - $lista = $obj->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL,  
203 - $this->ref_cod_instituicao, NULL, $this->ref_cod_servidor, NULL,  
204 - NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL); 210 + // Pega a lista de aulas alocadas para este servidor
  211 + $lista = $obj->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  212 + $this->ref_cod_instituicao, NULL, $this->ref_cod_servidor, NULL,
  213 + NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL);
205 214
206 - if ($lista) {  
207 -  
208 - // Passa todos os valores obtidos no registro para atributos do objeto  
209 - foreach ($lista as $campo => $val) {  
210 - $temp = array();  
211 - $temp['hora_inicial'] = $val['hora_inicial'];  
212 - $temp['hora_final'] = $val['hora_final'];  
213 - $temp['dia_semana'] = $val['dia_semana'];  
214 - $temp['ref_cod_escola'] = $val['ref_cod_escola'];  
215 - $temp['ref_cod_substituto'] = $val['ref_servidor_substituto'];  
216 - $this->alocacao_array[] = $temp;  
217 - }  
218 -  
219 - if ($this->alocacao_array) {  
220 - $tamanho = sizeof($alocacao);  
221 - $script = "<script>\nvar num_alocacao = {$tamanho};\n";  
222 - $script .= "var array_servidores = Array();\n"; 215 + if ($lista) {
  216 + // Passa todos os valores obtidos no registro para atributos do objeto
  217 + foreach ($lista as $campo => $val) {
  218 + $temp = array();
  219 + $temp['hora_inicial'] = $val['hora_inicial'];
  220 + $temp['hora_final'] = $val['hora_final'];
  221 + $temp['dia_semana'] = $val['dia_semana'];
  222 + $temp['ref_cod_escola'] = $val['ref_cod_escola'];
  223 + $temp['ref_cod_disciplina'] = $val['ref_cod_disciplina'];
  224 + $temp['ref_cod_substituto'] = $val['ref_servidor_substituto'];
  225 + $this->alocacao_array[] = $temp;
  226 + }
223 227
224 - foreach ($this->alocacao_array as $key => $alocacao) {  
225 - $script .= "array_servidores[{$key}] = new Array();\n"; 228 + if ($this->alocacao_array) {
  229 + $tamanho = sizeof($alocacao);
  230 + $script = "<script>\nvar num_alocacao = {$tamanho};\n";
  231 + $script .= "var array_servidores = Array();\n";
226 232
227 - $hora_ini = explode(":", $alocacao['hora_inicial']);  
228 - $hora_fim = explode(":", $alocacao['hora_final']); 233 + foreach ($this->alocacao_array as $key => $alocacao) {
  234 + $script .= "array_servidores[{$key}] = new Array();\n";
229 235
230 - $horas_utilizadas = ($hora_fim[0] - $hora_ini[0]);  
231 - $minutos_utilizados = ($hora_fim[1] - $hora_ini[1]); 236 + $hora_ini = explode(":", $alocacao['hora_inicial']);
  237 + $hora_fim = explode(":", $alocacao['hora_final']);
232 238
233 - $horas = sprintf('%02d', (int) $horas_utilizadas);  
234 - $minutos = sprintf('%02d', (int) $minutos_utilizados); 239 + $horas_utilizadas = ($hora_fim[0] - $hora_ini[0]);
  240 + $minutos_utilizados = ($hora_fim[1] - $hora_ini[1]);
235 241
236 - $str_horas_utilizadas = "{$horas}:{$minutos}"; 242 + $horas = sprintf('%02d', (int) $horas_utilizadas);
  243 + $minutos = sprintf('%02d', (int) $minutos_utilizados);
237 244
238 - $script .= "array_servidores[{$key}][0] = '{$str_horas_utilizadas}';\n";  
239 - $script .= "array_servidores[{$key}][1] = '';\n\n"; 245 + $str_horas_utilizadas = "{$horas}:{$minutos}";
240 246
241 - $obj_escola = new clsPmieducarEscola($alocacao['ref_cod_escola']);  
242 - $det_escola = $obj_escola->detalhe();  
243 - $det_escola = $det_escola['nome'];  
244 - $nm_dia_semana = $this->dias_da_semana[$alocacao['dia_semana']]; 247 + $script .= "array_servidores[{$key}][0] = '{$str_horas_utilizadas}';\n";
  248 + $script .= "array_servidores[{$key}][1] = '';\n\n";
245 249
246 - $obj_subst = new clsPessoa_($alocacao['ref_cod_substituto']);  
247 - $det_subst = $obj_subst->detalhe(); 250 + $obj_escola = new clsPmieducarEscola($alocacao['ref_cod_escola']);
  251 + $det_escola = $obj_escola->detalhe();
  252 + $det_escola = $det_escola['nome'];
  253 + $nm_dia_semana = $this->dias_da_semana[$alocacao['dia_semana']];
248 254
249 - if ($this->status == 'N') {  
250 - $this->campoTextoInv("dia_semana_{$key}_", '', $nm_dia_semana,  
251 - 8, 8, FALSE, FALSE, TRUE, '', '', '', '', 'dia_semana'); 255 + $obj_subst = new clsPessoa_($alocacao['ref_cod_substituto']);
  256 + $det_subst = $obj_subst->detalhe();
252 257
253 - $this->campoTextoInv("hora_inicial_{$key}_", '', $alocacao['hora_inicial'],  
254 - 5, 5, FALSE, FALSE, TRUE, '', '', '', '', 'ds_hora_inicial_'); 258 + if ($this->status == 'N') {
  259 + $this->campoTextoInv("dia_semana_{$key}_", '', $nm_dia_semana,
  260 + 8, 8, FALSE, FALSE, TRUE, '', '', '', '', 'dia_semana');
255 261
256 - $this->campoTextoInv("hora_final_{$key}_", '', $alocacao['hora_final'],  
257 - 5, 5, FALSE, FALSE, TRUE, '', '', '', '', 'ds_hora_final_'); 262 + $this->campoTextoInv("hora_inicial_{$key}_", '', $alocacao['hora_inicial'],
  263 + 5, 5, FALSE, FALSE, TRUE, '', '', '', '', 'ds_hora_inicial_');
258 264
259 - $this->campoTextoInv("ref_cod_escola_{$key}", '', $det_escola,  
260 - 30, 255, FALSE, FALSE, TRUE, '', '', '', '', 'ref_cod_escola_'); 265 + $this->campoTextoInv("hora_final_{$key}_", '', $alocacao['hora_final'],
  266 + 5, 5, FALSE, FALSE, TRUE, '', '', '', '', 'ds_hora_final_');
261 267
262 - $this->campoTextoInv("ref_cod_servidor_substituto_{$key}_",  
263 - '', $det_subst['nome'], 30, 255, FALSE, FALSE, FALSE, '',  
264 - "<span name=\"ref_cod_servidor_substituto\" id=\"ref_cod_servidor_substituicao_{$key}\"><img border='0' onclick=\"pesquisa_valores_popless('educar_pesquisa_servidor_lst.php?campo1=ref_cod_servidor_substituto[{$key}]&campo2=ref_cod_servidor_substituto_{$key}_&ref_cod_instituicao={$this->ref_cod_instituicao}&dia_semana={$alocacao["dia_semana"]}&hora_inicial={$alocacao["hora_inicial"]}&hora_final={$alocacao["hora_final"]}&ref_cod_servidor={$this->ref_cod_servidor}&professor=1&ref_cod_escola={$alocacao['ref_cod_escola']}&horario=S', 'nome')\" src=\"imagens/lupa.png\" ></span>",  
265 - '', '', 'ref_cod_servidor_substituto');  
266 - } 268 + $this->campoTextoInv("ref_cod_escola_{$key}", '', $det_escola,
  269 + 30, 255, FALSE, FALSE, TRUE, '', '', '', '', 'ref_cod_escola_');
267 270
268 - $this->campoOculto("dia_semana_{$key}", $alocacao['dia_semana']);  
269 - $this->campoOculto("hora_inicial_{$key}", $alocacao['hora_inicial']);  
270 - $this->campoOculto("hora_final_{$key}", $alocacao['hora_final']);  
271 - $this->campoOculto("ref_cod_escola_{$key}", $alocacao['ref_cod_escola']);  
272 - $this->campoOculto("ref_cod_servidor_substituto[{$key}]", $alocacao['ref_cod_substituto']); 271 + $this->campoTextoInv("ref_cod_servidor_substituto_{$key}_",
  272 + '', $det_subst['nome'], 30, 255, FALSE, FALSE, FALSE, '',
  273 + "<span name=\"ref_cod_servidor_substituto\" id=\"ref_cod_servidor_substituicao_{$key}\"><img border='0' onclick=\"pesquisa_valores_popless('educar_pesquisa_servidor_lst.php?campo1=ref_cod_servidor_substituto[{$key}]&campo2=ref_cod_servidor_substituto_{$key}_&ref_cod_instituicao={$this->ref_cod_instituicao}&dia_semana={$alocacao["dia_semana"]}&hora_inicial={$alocacao["hora_inicial"]}&hora_final={$alocacao["hora_final"]}&ref_cod_servidor={$this->ref_cod_servidor}&professor=1&ref_cod_escola={$alocacao['ref_cod_escola']}&horario=S&ref_cod_disciplina={$alocacao['ref_cod_disciplina']}', 'nome')\" src=\"imagens/lupa.png\" ></span>",
  274 + '', '', 'ref_cod_servidor_substituto');
  275 + }
273 276
274 - } 277 + $this->campoOculto("dia_semana_{$key}", $alocacao['dia_semana']);
  278 + $this->campoOculto("hora_inicial_{$key}", $alocacao['hora_inicial']);
  279 + $this->campoOculto("hora_final_{$key}", $alocacao['hora_final']);
  280 + $this->campoOculto("ref_cod_escola_{$key}", $alocacao['ref_cod_escola']);
  281 + $this->campoOculto("ref_cod_servidor_substituto[{$key}]", $alocacao['ref_cod_substituto']);
  282 + }
275 283
276 - $script .= "\n</script>"; 284 + $script .= "\n</script>";
277 285
278 - // Print do Javascript  
279 - print $script;  
280 - }  
281 - } 286 + // Print do Javascript
  287 + print $script;
282 } 288 }
283 } 289 }
284 -  
285 } 290 }
  291 +
286 } 292 }
287 } 293 }
288 294
289 295
290 296
  297 + /**
  298 + * Implementação do método clsCadastro::Novo()
  299 + *
  300 + * Recebe os valores com códigos de servidor e instituição atual, junto com
  301 + * a data. Casos de uso:
  302 + * - Servidor sem função de professor: apenas é marcado que o servidor está
  303 + * afastado
  304 + * - Servidor com função de professor:
  305 + * - Verifica-se quais professores estão aptos a substituir o servidor,
  306 + * baseado em critérios como horário de aula, alocação na escola,
  307 + * disciplinas que ministra. Esse passo é realizado no método
  308 + * {@see $this->Novo()}, ao possibilitar a escolha do substituto ao
  309 + * usuário
  310 + *
  311 + * @see clsPmieducarServidorAfastamento
  312 + * @see ieducar/intranet/include/clsCadastro#Novo()
  313 + * @return bool FALSE em caso de falha
  314 + */
291 public function Novo() { 315 public function Novo() {
292 session_start(); 316 session_start();
293 $this->pessoa_logada = $_SESSION['id_pessoa']; 317 $this->pessoa_logada = $_SESSION['id_pessoa'];
@@ -296,187 +320,233 @@ class indice extends clsCadastro { @@ -296,187 +320,233 @@ class indice extends clsCadastro {
296 $this->ref_cod_servidor = isset($_POST['ref_cod_servidor']) ? 320 $this->ref_cod_servidor = isset($_POST['ref_cod_servidor']) ?
297 $_POST['ref_cod_servidor'] : NULL; 321 $_POST['ref_cod_servidor'] : NULL;
298 322
  323 + $urlPermite = sprintf(
  324 + "educar_servidor_det.php?cod_servidor=%d&ref_cod_instituicao=%d",
  325 + $this->ref_cod_servidor, $this->ref_cod_instituicao
  326 + );
  327 +
299 $obj_permissoes = new clsPermissoes(); 328 $obj_permissoes = new clsPermissoes();
300 - $obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 7,  
301 - "educar_servidor_det.php?cod_servidor={$this->ref_cod_servidor}&ref_cod_instituicao={$this->ref_cod_instituicao}"); 329 + $obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 7, $urlPermite);
302 330
303 $obj = new clsPmieducarServidorAfastamento($this->ref_cod_servidor, NULL, 331 $obj = new clsPmieducarServidorAfastamento($this->ref_cod_servidor, NULL,
304 $this->ref_cod_motivo_afastamento, NULL, $this->pessoa_logada, NULL, NULL, 332 $this->ref_cod_motivo_afastamento, NULL, $this->pessoa_logada, NULL, NULL,
305 $this->data_retorno, $this->data_saida, 1, $this->ref_cod_instituicao); 333 $this->data_retorno, $this->data_saida, 1, $this->ref_cod_instituicao);
306 334
307 $cadastrou = $obj->cadastra(); 335 $cadastrou = $obj->cadastra();
  336 +
308 if ($cadastrou) { 337 if ($cadastrou) {
  338 + if (is_array($_POST['ref_cod_servidor_substituto'])) {
  339 + /*
  340 + * Itera cada substituto e atualiza o quadro de horário com o código
  341 + * do servidor substituto, campos:
  342 + * - ref_cod_instituicao_substituto
  343 + * - ref_cod_servidor_substituto
  344 + */
  345 + foreach ($_POST['ref_cod_servidor_substituto'] as $key => $valor) {
  346 + $ref_cod_servidor_substituto = $valor;
  347 + $ref_cod_escola = $_POST["ref_cod_escola_{$key}"];
  348 + $dia_semana = $_POST["dia_semana_{$key}"];
  349 + $hora_inicial = urldecode($_POST["hora_inicial_{$key}"]);
  350 + $hora_final = urldecode($_POST["hora_final_{$key}"]);
  351 +
  352 + if (is_numeric($ref_cod_servidor_substituto) && is_numeric($ref_cod_escola) &&
  353 + is_numeric($dia_semana) && is_string($hora_inicial) &&
  354 + is_string($hora_final)) {
  355 +
  356 + $obj_horarios = new clsPmieducarQuadroHorarioHorarios(NULL, NULL,
  357 + $ref_cod_escola, NULL, NULL, NULL, $this->ref_cod_instituicao,
  358 + $ref_cod_servidor_substituto, $this->ref_cod_servidor,
  359 + $hora_inicial, $hora_final, NULL, NULL, 1, $dia_semana);
  360 +
  361 + $det_horarios = $obj_horarios->detalhe($ref_cod_escola);
  362 +
  363 + $obj_horario = new clsPmieducarQuadroHorarioHorarios(
  364 + $det_horarios['ref_cod_quadro_horario'], $det_horarios['ref_cod_serie'],
  365 + $det_horarios['ref_cod_escola'], $det_horarios['ref_cod_disciplina'],
  366 + $det_horarios['sequencial'], $det_horarios['ref_cod_instituicao_servidor'],
  367 + $det_horarios['ref_cod_instituicao_servidor'], $ref_cod_servidor_substituto,
  368 + $this->ref_cod_servidor, NULL, NULL, NULL, NULL, NULL, NULL);
  369 +
  370 + // Caso a atualização não tenha sucesso
  371 + if (!$obj_horario->edita()) {
  372 + $this->mensagem = "Cadastro n&atilde;o realizado.<br>";
309 373
310 - if(is_array($_POST['ref_cod_servidor_substituto']))  
311 - foreach ( $_POST['ref_cod_servidor_substituto'] as $key => $valor )  
312 - {  
313 - //if ( substr( $campo, 0, 28 ) == 'ref_cod_servidor_substituto_' )  
314 - // {  
315 - $ref_cod_servidor_substituto = $valor;  
316 - // }  
317 - //if ( substr( $campo, 0, 15 ) == 'ref_cod_escola_' )  
318 - $ref_cod_escola = $_POST["ref_cod_escola_{$key}"];  
319 - //if ( substr( $campo, 0, 11 ) == 'dia_semana_' )  
320 - $dia_semana = $_POST["dia_semana_{$key}"];  
321 - //if ( substr( $campo, 0, 13 ) == 'hora_inicial_' )  
322 - $hora_inicial = urldecode( $_POST["hora_inicial_{$key}"] );  
323 - // if ( substr( $campo, 0, 11 ) == 'hora_final_' )  
324 - $hora_final = urldecode( $_POST["hora_final_{$key}"] );  
325 -  
326 - if ( is_numeric( $ref_cod_servidor_substituto ) && is_numeric( $ref_cod_escola ) && is_numeric( $dia_semana ) && is_string( $hora_inicial ) && is_string( $hora_final ) )  
327 - {  
328 -  
329 - //if ( substr( $campo, 0, 28 ) == 'ref_cod_servidor_substituto_' )  
330 - //{die;  
331 - $obj_horarios = new clsPmieducarQuadroHorarioHorarios( null, null, $ref_cod_escola,null, null,null, $this->ref_cod_instituicao,$ref_cod_servidor_substituto, $this->ref_cod_servidor, $hora_inicial, $hora_final, null, null, 1, $dia_semana );  
332 - $det_horarios = $obj_horarios->detalhe($ref_cod_escola);  
333 - //echo " = new clsPmieducarQuadroHorarioHorarios( {$det_horarios["ref_cod_quadro_horario"]}, {$det_horarios["ref_cod_serie"]}, {$det_horarios["ref_cod_escola"]}, {$det_horarios["ref_cod_disciplina"]}, {$det_horarios["ref_ref_cod_turma"]}, {$det_horarios["sequencial"]}, {$det_horarios["ref_cod_instituicao_servidor"]}, null, {$ref_cod_servidor_substituto}, null, null, null, null, null, null, null );";die;  
334 - $obj_horario = new clsPmieducarQuadroHorarioHorarios( $det_horarios["ref_cod_quadro_horario"], $det_horarios["ref_cod_serie"], $det_horarios["ref_cod_escola"], $det_horarios["ref_cod_disciplina"], $det_horarios["sequencial"], $det_horarios["ref_cod_instituicao_servidor"],$det_horarios["ref_cod_instituicao_servidor"], $ref_cod_servidor_substituto, $this->ref_cod_servidor, null, null, null, null, null, null );  
335 - if( !$obj_horario->edita() )  
336 - {  
337 - $this->mensagem = "Cadastro n&atilde;o realizado.<br>";  
338 - return false;  
339 - }  
340 - //} 374 + return FALSE;
  375 + }
341 } 376 }
342 } 377 }
  378 +
343 $this->mensagem .= "Cadastro efetuado com sucesso.<br>"; 379 $this->mensagem .= "Cadastro efetuado com sucesso.<br>";
344 - header( "Location: educar_servidor_det.php?cod_servidor={$this->ref_cod_servidor}&ref_cod_instituicao={$this->ref_cod_instituicao}" ); 380 + header("Location: educar_servidor_det.php?cod_servidor={$this->ref_cod_servidor}&ref_cod_instituicao={$this->ref_cod_instituicao}");
345 die(); 381 die();
346 - return true;  
347 - }  
348 - else  
349 - {  
350 - $this->mensagem = "Cadastro n&atilde;o realizado.<br>";  
351 - return false;  
352 - }  
353 - $this->mensagem = "Cadastro n&atilde;o realizado.<br>";  
354 - echo "<!--\nErro ao cadastrar clsPmieducarServidorAfastamento\nvalores obrigatorios\nis_numeric( $this->ref_cod_servidor ) && is_numeric( $this->sequencial ) && is_numeric( $this->ref_ref_cod_instituicao ) && is_numeric( $this->ref_cod_motivo_afastamento ) && is_numeric( $this->ref_usuario_cad ) && is_string( $this->data_saida )\n-->";  
355 - return false; 382 + }
  383 + }
  384 + else {
  385 + $this->mensagem = "Cadastro n&atilde;o realizado.<br>";
  386 + return FALSE;
  387 + }
  388 +
  389 + $this->mensagem = "Cadastro n&atilde;o realizado.<br>";
  390 + return FALSE;
356 } 391 }
357 392
358 - function Editar()  
359 - {  
360 - @session_start(); 393 +
  394 +
  395 + /**
  396 + * Implementação do método clsCadastro::Editar()
  397 + *
  398 + * Esse método é chamado quando o usuário "Retorna um servidor". Dessa forma,
  399 + * caso seja professor, precisa atualizar a sua alocação na tabela
  400 + * pmieducar.quadro_horario_horarios, apagando os valores dos campos
  401 + * ref_cod_instituicao_ e ref_cod_servidor_ -substituto
  402 + *
  403 + * @see ieducar/intranet/include/clsCadastro#Editar()
  404 + */
  405 + public function Editar() {
  406 + session_start();
361 $this->pessoa_logada = $_SESSION['id_pessoa']; 407 $this->pessoa_logada = $_SESSION['id_pessoa'];
362 - @session_write_close(); 408 + session_write_close();
  409 +
  410 + $urlPermite = sprintf(
  411 + 'educar_servidor_det.php?cod_servidor=%d&ref_cod_instituicao=%d',
  412 + $this->ref_cod_servidor, $this->ref_cod_instituicao);
363 413
364 $obj_permissoes = new clsPermissoes(); 414 $obj_permissoes = new clsPermissoes();
365 - $obj_permissoes->permissao_cadastra( 635, $this->pessoa_logada, 7, "educar_servidor_det.php?cod_servidor={$this->ref_cod_servidor}&ref_cod_instituicao={$this->ref_cod_instituicao}" ); 415 + $obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 7, $urlPermite);
  416 +
  417 + $obj = new clsPmieducarServidorAfastamento($this->ref_cod_servidor,
  418 + $this->sequencial, $this->ref_cod_motivo_afastamento, $this->pessoa_logada,
  419 + NULL, NULL, NULL, $this->data_retorno, unserialize($this->data_saida), 1,
  420 + $this->ref_cod_instituicao );
366 421
367 - $obj = new clsPmieducarServidorAfastamento( $this->ref_cod_servidor, $this->sequencial, $this->ref_cod_motivo_afastamento, $this->pessoa_logada, null, null, null, $this->data_retorno, unserialize( $this->data_saida ), 1, $this->ref_cod_instituicao );  
368 $editou = $obj->edita(); 422 $editou = $obj->edita();
369 - if( $editou )  
370 - {  
371 - if(is_array($_POST['ref_cod_servidor_substituto']))  
372 - foreach ( $_POST['ref_cod_servidor_substituto'] as $key => $valor )  
373 - {  
374 - $ref_cod_servidor_substituto = $valor;  
375 -  
376 - //if ( substr( $campo, 0, 15 ) == 'ref_cod_escola_' )  
377 - $ref_cod_escola = $_POST["ref_cod_escola_{$key}"];  
378 - //if ( substr( $campo, 0, 11 ) == 'dia_semana_' )  
379 - $dia_semana = $_POST["dia_semana_{$key}"];  
380 - //if ( substr( $campo, 0, 13 ) == 'hora_inicial_' )  
381 - $hora_inicial = urldecode( $_POST["hora_inicial_{$key}"] );  
382 - // if ( substr( $campo, 0, 11 ) == 'hora_final_' )  
383 - $hora_final = urldecode( $_POST["hora_final_{$key}"] );  
384 -  
385 - if ( is_numeric( $ref_cod_servidor_substituto ) && is_numeric( $ref_cod_escola ) && is_numeric( $dia_semana ) && is_string( $hora_inicial ) && is_string( $hora_final ) )  
386 - {  
387 - //if ( substr( $campo, 0, 28 ) == 'ref_cod_servidor_substituto_' )  
388 - //{  
389 - $obj_horarios = new clsPmieducarQuadroHorarioHorarios( null, null, $ref_cod_escola,null, null,null, $this->ref_cod_instituicao,$ref_cod_servidor_substituto, $this->ref_cod_servidor, $hora_inicial, $hora_final, null, null, 1, $dia_semana );  
390 - $det_horarios = $obj_horarios->detalhe($ref_cod_escola);  
391 - //if ( is_string( $this->data_retorno ) && $this->data_retorno != '' )  
392 - //{  
393 - //$obj_horario = new clsPmieducarQuadroHorarioHorarios( $det_horarios["ref_cod_quadro_horario"], $det_horarios["ref_ref_cod_serie"], $det_horarios["ref_ref_cod_escola"], $det_horarios["ref_ref_cod_disciplina"], $det_horarios["ref_ref_cod_turma"], $det_horarios["sequencial"], null, null, null, null, null, null, null, null, null, null );  
394 - $obj_horario = new clsPmieducarQuadroHorarioHorarios( $det_horarios["ref_cod_quadro_horario"], $det_horarios["ref_cod_serie"], $det_horarios["ref_cod_escola"], $det_horarios["ref_cod_disciplina"], $det_horarios["sequencial"], null,$det_horarios["ref_cod_instituicao_servidor"], null, $this->ref_cod_servidor, null, null, null, null, null, null );  
395 - //}  
396 - /* else  
397 - {  
398 - // $obj_horario = new clsPmieducarQuadroHorarioHorarios( $det_horarios["ref_cod_quadro_horario"], $det_horarios["ref_ref_cod_serie"], $det_horarios["ref_ref_cod_escola"], $det_horarios["ref_ref_cod_disciplina"], $det_horarios["ref_ref_cod_turma"], $det_horarios["sequencial"], $det_horarios["ref_cod_instituicao_servidor"], null, $ref_cod_servidor_substituto, null, null, null, null, null, null, null );  
399 - $obj_horario = new clsPmieducarQuadroHorarioHorarios( $det_horarios["ref_cod_quadro_horario"], $det_horarios["ref_cod_serie"], $det_horarios["ref_cod_escola"], $det_horarios["ref_cod_disciplina"], $det_horarios["sequencial"], $det_horarios["ref_cod_instituicao_servidor"],$det_horarios["ref_cod_instituicao_servidor"], $ref_cod_servidor_substituto, $this->ref_cod_servidor, null, null, null, null, null, null );  
400 - }*/  
401 - if( !$obj_horario->edita() )  
402 - { 423 + if ($editou) {
  424 + if (is_array($_POST['ref_cod_servidor_substituto'])) {
  425 + foreach ($_POST['ref_cod_servidor_substituto'] as $key => $valor) {
  426 + $ref_cod_servidor_substituto = $valor;
  427 + $ref_cod_escola = $_POST["ref_cod_escola_{$key}"];
  428 + $dia_semana = $_POST["dia_semana_{$key}"];
  429 + $hora_inicial = urldecode($_POST["hora_inicial_{$key}"]);
  430 + $hora_final = urldecode($_POST["hora_final_{$key}"]);
  431 +
  432 + if (is_numeric($ref_cod_servidor_substituto) && is_numeric($ref_cod_escola) &&
  433 + is_numeric($dia_semana) && is_string($hora_inicial) &&
  434 + is_string($hora_final)) {
  435 +
  436 + $obj_horarios = new clsPmieducarQuadroHorarioHorarios(NULL, NULL,
  437 + $ref_cod_escola, NULL, NULL, NULL, $this->ref_cod_instituicao,
  438 + $ref_cod_servidor_substituto, $this->ref_cod_servidor, $hora_inicial,
  439 + $hora_final, NULL, NULL, 1, $dia_semana);
  440 +
  441 + $det_horarios = $obj_horarios->detalhe($ref_cod_escola);
  442 +
  443 + // Os valores NULL apagam os campos ref_cod_instituicao_ e
  444 + // ref_cod_servidor_ -substituto da tabela pmieducar.
  445 + // quadro_horario_horarios
  446 + $obj_horario = new clsPmieducarQuadroHorarioHorarios(
  447 + $det_horarios["ref_cod_quadro_horario"],
  448 + $det_horarios["ref_cod_serie"],
  449 + $det_horarios["ref_cod_escola"],
  450 + $det_horarios["ref_cod_disciplina"],
  451 + $det_horarios["sequencial"],
  452 + NULL,
  453 + $det_horarios["ref_cod_instituicao_servidor"],
  454 + NULL,
  455 + $this->ref_cod_servidor);
  456 +
  457 + if (!$obj_horario->edita()) {
403 $this->mensagem = "Cadastro n&atilde;o realizado.<br>"; 458 $this->mensagem = "Cadastro n&atilde;o realizado.<br>";
404 - return false; 459 + return FALSE;
405 } 460 }
406 - //} 461 +
  462 + }
407 } 463 }
408 } 464 }
  465 +
409 $this->mensagem .= "Edi&ccedil;&atilde;o efetuada com sucesso.<br>"; 466 $this->mensagem .= "Edi&ccedil;&atilde;o efetuada com sucesso.<br>";
410 - header( "Location: educar_servidor_det.php?cod_servidor={$this->ref_cod_servidor}&ref_cod_instituicao={$this->ref_cod_instituicao}" ); 467 + header("Location: educar_servidor_det.php?cod_servidor={$this->ref_cod_servidor}&ref_cod_instituicao={$this->ref_cod_instituicao}");
411 die(); 468 die();
412 - return true;  
413 } 469 }
414 470
415 $this->mensagem = "Edi&ccedil;&atilde;o n&atilde;o realizada.<br>"; 471 $this->mensagem = "Edi&ccedil;&atilde;o n&atilde;o realizada.<br>";
416 - echo "<!--\nErro ao editar clsPmieducarServidorAfastamento\nvalores obrigatorios\nif( is_numeric( $this->ref_cod_servidor ) && is_numeric( $this->sequencial ) && is_numeric( $this->ref_ref_cod_instituicao ) && is_numeric( $this->ref_usuario_exc ) )\n-->";  
417 - return false; 472 + return FALSE;
418 } 473 }
419 474
420 - function Excluir()  
421 - {  
422 - @session_start(); 475 +
  476 +
  477 + /**
  478 + * Implementação do método clsCadastro::Excluir()
  479 + * @see ieducar/intranet/include/clsCadastro#Excluir()
  480 + */
  481 + public function Excluir() {
  482 + session_start();
423 $this->pessoa_logada = $_SESSION['id_pessoa']; 483 $this->pessoa_logada = $_SESSION['id_pessoa'];
424 - @session_write_close(); 484 + session_write_close();
  485 +
  486 + $urlPermite = sprintf(
  487 + "educar_servidor_det.php?cod_servidor=%d&ref_cod_instituicao=%d",
  488 + $this->ref_cod_servidor, $this->ref_cod_instituicao);
425 489
426 $obj_permissoes = new clsPermissoes(); 490 $obj_permissoes = new clsPermissoes();
427 - $obj_permissoes->permissao_excluir( 635, $this->pessoa_logada, 7, "educar_servidor_det.php?cod_servidor={$this->ref_cod_servidor}&ref_cod_instituicao={$this->ref_cod_instituicao}" ); 491 + $obj_permissoes->permissao_excluir(635, $this->pessoa_logada, 7, $urlPermite);
428 492
  493 + $obj = new clsPmieducarServidorAfastamento($this->ref_cod_servidor,
  494 + $this->sequencial, $this->ref_ref_cod_instituicao,
  495 + $this->ref_cod_motivo_afastamento, $this->pessoa_logada,
  496 + $this->pessoa_logada, $this->data_cadastro, $this->data_exclusao,
  497 + $this->data_retorno, $this->data_saida, 0);
429 498
430 - $obj = new clsPmieducarServidorAfastamento($this->ref_cod_servidor, $this->sequencial, $this->ref_ref_cod_instituicao, $this->ref_cod_motivo_afastamento, $this->pessoa_logada, $this->pessoa_logada, $this->data_cadastro, $this->data_exclusao, $this->data_retorno, $this->data_saida, 0);  
431 $excluiu = $obj->excluir(); 499 $excluiu = $obj->excluir();
432 - if( $excluiu )  
433 - { 500 +
  501 + if ($excluiu) {
434 $this->mensagem .= "Exclus&atilde;o efetuada com sucesso.<br>"; 502 $this->mensagem .= "Exclus&atilde;o efetuada com sucesso.<br>";
435 - header( "Location: educar_servidor_afastamento_lst.php" ); 503 + header("Location: educar_servidor_afastamento_lst.php");
  504 +
436 die(); 505 die();
437 - return true;  
438 } 506 }
439 507
440 $this->mensagem = "Exclus&atilde;o n&atilde;o realizada.<br>"; 508 $this->mensagem = "Exclus&atilde;o n&atilde;o realizada.<br>";
441 - echo "<!--\nErro ao excluir clsPmieducarServidorAfastamento\nvalores obrigatorios\nif( is_numeric( $this->ref_cod_servidor ) && is_numeric( $this->sequencial ) && is_numeric( $this->ref_ref_cod_instituicao ) && is_numeric( $this->ref_usuario_exc ) )\n-->";  
442 - return false; 509 + return FALSE;
443 } 510 }
444 } 511 }
445 512
446 -// cria uma extensao da classe base 513 +// Instancia objeto de página
447 $pagina = new clsIndexBase(); 514 $pagina = new clsIndexBase();
448 -// cria o conteudo 515 +
  516 +// Instancia objeto de conteúdo
449 $miolo = new indice(); 517 $miolo = new indice();
450 -// adiciona o conteudo na clsBase  
451 -$pagina->addForm( $miolo );  
452 -// gera o html 518 +
  519 +// Atribui o conteúdo à página
  520 +$pagina->addForm($miolo);
  521 +
  522 +// Gera o código HTML
453 $pagina->MakeAll(); 523 $pagina->MakeAll();
454 ?> 524 ?>
455 -<script>  
456 - if ( document.getElementById( 'btn_enviar' ) )  
457 - {  
458 - document.getElementById( 'btn_enviar' ).onclick = function() { validaFormulario(); }  
459 - }  
460 - function validaFormulario()  
461 - {  
462 - var c = 0;  
463 - var loop = true;  
464 - do  
465 - {  
466 - if ( document.getElementById( 'ref_cod_servidor_substituto_' + c + '_' ) && document.getElementById( 'ref_cod_servidor_substituto_' + c ) )  
467 - {  
468 - if ( document.getElementById( 'ref_cod_servidor_substituto_' + c + '_' ).value == '' && document.getElementById( 'ref_cod_servidor_substituto_' + c ).value == '' )  
469 - {  
470 - alert( 'Você deve informar um substituto para cada horário.' );  
471 - return;  
472 - }  
473 - }  
474 - else  
475 - {  
476 - loop = false;  
477 - }  
478 - c++;  
479 - } while ( loop );  
480 - acao();  
481 - } 525 +
  526 +<script type="text/javascript">
  527 +if (document.getElementById('btn_enviar')) {
  528 + document.getElementById('btn_enviar').onclick = function() { validaFormulario(); }
  529 +}
  530 +
  531 +function validaFormulario() {
  532 + var c = 0;
  533 + var loop = true;
  534 +
  535 + do {
  536 + if (document.getElementById('ref_cod_servidor_substituto_' + c + '_')) {
  537 + if (document.getElementById('ref_cod_servidor_substituto_' + c + '_').value == '') {
  538 + alert('Você deve informar um substituto para cada horário.');
  539 +
  540 + return;
  541 + }
  542 + }
  543 + else {
  544 + loop = false;
  545 + }
  546 +
  547 + c++;
  548 + } while (loop);
  549 +
  550 + acao();
  551 +}
482 </script> 552 </script>
483 \ No newline at end of file 553 \ No newline at end of file
ieducar/intranet/include/pmieducar/clsPmieducarServidor.inc.php
@@ -670,7 +670,7 @@ class clsPmieducarServidor { @@ -670,7 +670,7 @@ class clsPmieducarServidor {
670 AND qhh.ativo = '1' 670 AND qhh.ativo = '1'
671 AND qhh.dia_semana <> '$int_dia_semana' 671 AND qhh.dia_semana <> '$int_dia_semana'
672 AND qhh.ref_servidor = a.ref_cod_servidor 672 AND qhh.ref_servidor = a.ref_cod_servidor
673 - GROUP BY qhh.ref_servidor ) ,'00:00') + '$str_hr_mat' + COALESCE( 673 + GROUP BY qhh.ref_servidor) ,'00:00') + '$str_hr_mat' + COALESCE(
674 (SELECT SUM( qhha.hora_final - qhha.hora_inicial ) 674 (SELECT SUM( qhha.hora_final - qhha.hora_inicial )
675 FROM pmieducar.quadro_horario_horarios_aux qhha 675 FROM pmieducar.quadro_horario_horarios_aux qhha
676 WHERE qhha.ref_cod_instituicao_servidor = '$int_ref_cod_instituicao' 676 WHERE qhha.ref_cod_instituicao_servidor = '$int_ref_cod_instituicao'
@@ -678,7 +678,7 @@ class clsPmieducarServidor { @@ -678,7 +678,7 @@ class clsPmieducarServidor {
678 AND hora_inicial >= '08:00' 678 AND hora_inicial >= '08:00'
679 AND hora_inicial <= '12:00' 679 AND hora_inicial <= '12:00'
680 AND qhha.ref_servidor = a.ref_cod_servidor 680 AND qhha.ref_servidor = a.ref_cod_servidor
681 - AND identificador = $int_identificador 681 + AND identificador = '$int_identificador'
682 GROUP BY qhha.ref_servidor),'00:00'))"; 682 GROUP BY qhha.ref_servidor),'00:00'))";
683 } 683 }
684 else { 684 else {
@@ -716,7 +716,7 @@ class clsPmieducarServidor { @@ -716,7 +716,7 @@ class clsPmieducarServidor {
716 AND qhha.ref_servidor = a.ref_cod_servidor 716 AND qhha.ref_servidor = a.ref_cod_servidor
717 AND hora_inicial >= '12:00' 717 AND hora_inicial >= '12:00'
718 AND hora_inicial <= '18:00' 718 AND hora_inicial <= '18:00'
719 - AND identificador = $int_identificador 719 + AND identificador = '$int_identificador'
720 GROUP BY qhha.ref_servidor),'00:00') )"; 720 GROUP BY qhha.ref_servidor),'00:00') )";
721 } 721 }
722 else { 722 else {
@@ -752,7 +752,7 @@ class clsPmieducarServidor { @@ -752,7 +752,7 @@ class clsPmieducarServidor {
752 AND qhha.ref_servidor = a.ref_cod_servidor 752 AND qhha.ref_servidor = a.ref_cod_servidor
753 AND hora_inicial >= '18:00' 753 AND hora_inicial >= '18:00'
754 AND hora_inicial <= '23:00' 754 AND hora_inicial <= '23:00'
755 - AND identificador = $int_identificador 755 + AND identificador = '$int_identificador'
756 GROUP BY qhha.ref_servidor),'00:00') )"; 756 GROUP BY qhha.ref_servidor),'00:00') )";
757 } 757 }
758 else { 758 else {
@@ -788,14 +788,26 @@ class clsPmieducarServidor { @@ -788,14 +788,26 @@ class clsPmieducarServidor {
788 if ($det_curso['falta_ch_globalizada']) { 788 if ($det_curso['falta_ch_globalizada']) {
789 // Busca professores independentemente da disciplina, somente verifica 789 // Busca professores independentemente da disciplina, somente verifica
790 // se é professor e se ministra a disciplina para o curso 790 // se é professor e se ministra a disciplina para o curso
791 - $filtros .= "{$whereAnd} EXISTS ( SELECT 1 FROM pmieducar.servidor_curso_ministra scm WHERE scm.ref_cod_curso = $int_ref_cod_curso AND scm.ref_ref_cod_instituicao = s.ref_cod_instituicao AND s.cod_servidor = scm.ref_cod_servidor)"; 791 + $filtros .= "
  792 + {$whereAnd} EXISTS
  793 + (SELECT 1
  794 + FROM pmieducar.servidor_curso_ministra scm
  795 + WHERE scm.ref_cod_curso = $int_ref_cod_curso AND
  796 + scm.ref_ref_cod_instituicao = s.ref_cod_instituicao AND
  797 + s.cod_servidor = scm.ref_cod_servidor)";
792 $whereAnd = " AND "; 798 $whereAnd = " AND ";
793 } 799 }
794 else { 800 else {
795 // Verifica se o professor está habilitado para ministrar a disciplina 801 // Verifica se o professor está habilitado para ministrar a disciplina
796 - if(is_numeric($int_ref_cod_disciplina)) {  
797 - $filtros .= "{$whereAnd} EXISTS ( SELECT 1 FROM pmieducar.servidor_disciplina sd WHERE sd.ref_cod_disciplina = $int_ref_cod_disciplina AND sd.ref_ref_cod_instituicao = s.ref_cod_instituicao AND s.cod_servidor = sd.ref_cod_servidor)";  
798 - $whereAnd = " AND "; 802 + if (is_numeric($int_ref_cod_disciplina)) {
  803 + $filtros .= "
  804 + {$whereAnd} EXISTS
  805 + (SELECT 1
  806 + FROM pmieducar.servidor_disciplina sd
  807 + WHERE sd.ref_cod_disciplina = $int_ref_cod_disciplina AND
  808 + sd.ref_ref_cod_instituicao = s.ref_cod_instituicao AND
  809 + s.cod_servidor = sd.ref_cod_servidor)";
  810 + $whereAnd = " AND ";
799 } 811 }
800 } 812 }
801 813
ieducar/tests/functional/ServidorAfastarWebTest.class.php
@@ -21,6 +21,9 @@ @@ -21,6 +21,9 @@
21 * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. 21 * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
22 */ 22 */
23 23
  24 +require_once realpath(dirname(__FILE__) . '/../') . '/FunctionalBaseTest.class.php';
  25 +
  26 +
24 /** 27 /**
25 * ServidorAfastarWebTest class. 28 * ServidorAfastarWebTest class.
26 * 29 *
@@ -34,9 +37,6 @@ @@ -34,9 +37,6 @@
34 * @since Classe disponível desde a versão 1.0.1 37 * @since Classe disponível desde a versão 1.0.1
35 * @version $Id$ 38 * @version $Id$
36 */ 39 */
37 -  
38 -require_once realpath(dirname(__FILE__) . '/../') . '/FunctionalBaseTest.class.php';  
39 -  
40 class ServidorAfastarWebTest extends FunctionalBaseTest { 40 class ServidorAfastarWebTest extends FunctionalBaseTest {
41 41
42 private 42 private
@@ -144,6 +144,9 @@ class ServidorAfastarWebTest extends FunctionalBaseTest { @@ -144,6 +144,9 @@ class ServidorAfastarWebTest extends FunctionalBaseTest {
144 public function testServidorAfastar() { 144 public function testServidorAfastar() {
145 $this->doLogin(); 145 $this->doLogin();
146 146
  147 + // ID da pessoa/servidor
  148 + $id = $this->slPessoaID;
  149 +
147 $this->open('/intranet/educar_servidor_lst.php'); 150 $this->open('/intranet/educar_servidor_lst.php');
148 $this->clickAndWait('link=' . $this->slPessoaNome); 151 $this->clickAndWait('link=' . $this->slPessoaNome);
149 $this->clickAndWait("//input[@value='Afastar Servidor']"); 152 $this->clickAndWait("//input[@value='Afastar Servidor']");
@@ -154,9 +157,20 @@ class ServidorAfastarWebTest extends FunctionalBaseTest { @@ -154,9 +157,20 @@ class ServidorAfastarWebTest extends FunctionalBaseTest {
154 $data = date('d/m/Y', (time() + (60 * 60 * 24 * 10))); 157 $data = date('d/m/Y', (time() + (60 * 60 * 24 * 10)));
155 $this->type('data_saida', $data); 158 $this->type('data_saida', $data);
156 159
157 - $this->clickAndWait('btn_enviar');  
158 - $this->assertTrue($this->isTextPresent($this->slPessoaMatricula)); 160 + // Verifica se a opção de busca de substituinte está presente, já que este
  161 + // servidor é professor e tem aulas alocadas no quadro de horários.
  162 + $searchButton = "//img[@onclick=\"pesquisa_valores_popless('educar_pesquisa_servidor_lst.php?campo1=ref_cod_servidor_substituto[0]&campo2=ref_cod_servidor_substituto_0_&ref_cod_instituicao=2&dia_semana=3&hora_inicial=09:00:00&hora_final=10:00:00&ref_cod_servidor=". $id ."&professor=1&ref_cod_escola=1&horario=S&ref_cod_disciplina=6', 'nome')\"]";
  163 + $this->assertTrue($this->isElementPresent($searchButton));
  164 +
  165 + // Clica no botão, seleciona o frame e verifica se existem resultados
  166 + // (válido apenas para o estado atual do banco de dados)
  167 + $this->click($searchButton);
  168 + sleep(10);
  169 + $this->selectFrame('temp_win_popless');
  170 + $this->assertTrue(!$this->isTextPresent('Não há informação para ser apresentada'));
159 171
  172 + // Retorna ao frame principal
  173 + $this->selectFrame('relative=up');
160 $this->doLogout(); 174 $this->doLogout();
161 } 175 }
162 176