Commit b1a1974b8537b326e84d06850c308f33ffbf6f5f
1 parent
1d5a441b
Exists in
master
#71 by Eriksen Costa: Atualizada interface de alocação de servidores:
* Reforçada validação javascript para evitar cargas horárias maiores que {{{clsPmieducarServidorAlocacao::$cargaHorariaMax}}} (padrão 6h)
* Restrição da carga horária validada também no construtor de {{{clsPmieducarServidorAlocacao}}}
* Melhoria na interface com javascript e texto de ajuda para esclarecer que o valor máximo da alocação é de 6h (padrão) por período)
Showing
2 changed files
with
104 additions
and
117 deletions
Show diff stats
ieducar/intranet/educar_servidor_alocacao_cad.php
| @@ -84,6 +84,9 @@ class indice extends clsCadastro | @@ -84,6 +84,9 @@ class indice extends clsCadastro | ||
| 84 | var $alocacao_array = array(); | 84 | var $alocacao_array = array(); |
| 85 | var $alocacao_excluida_array = array(); | 85 | var $alocacao_excluida_array = array(); |
| 86 | 86 | ||
| 87 | + static $escolasPeriodos = array(); | ||
| 88 | + static $periodos = array(); | ||
| 89 | + | ||
| 87 | function Inicializar() | 90 | function Inicializar() |
| 88 | { | 91 | { |
| 89 | $retorno = 'Novo'; | 92 | $retorno = 'Novo'; |
| @@ -154,26 +157,21 @@ class indice extends clsCadastro | @@ -154,26 +157,21 @@ class indice extends clsCadastro | ||
| 154 | $this->campoRotulo('nm_instituicao', 'Instituição', $inst_det['nm_instituicao']); | 157 | $this->campoRotulo('nm_instituicao', 'Instituição', $inst_det['nm_instituicao']); |
| 155 | $this->campoOculto('ref_ref_cod_instituicao', $this->ref_ref_cod_instituicao); | 158 | $this->campoOculto('ref_ref_cod_instituicao', $this->ref_ref_cod_instituicao); |
| 156 | 159 | ||
| 157 | - if (class_exists('clsPmieducarServidor')) { | ||
| 158 | - $objTemp = new clsPmieducarServidor($this->ref_cod_servidor); | ||
| 159 | - $det = $objTemp->detalhe(); | ||
| 160 | - | ||
| 161 | - if ($det) { | ||
| 162 | - foreach ($det as $key => $registro) { | ||
| 163 | - $this->$key = $registro; | ||
| 164 | - } | ||
| 165 | - } | 160 | + // Dados do servidor |
| 161 | + $objTemp = new clsPmieducarServidor($this->ref_cod_servidor); | ||
| 162 | + $det = $objTemp->detalhe(); | ||
| 166 | 163 | ||
| 167 | - if ($this->ref_cod_servidor) { | ||
| 168 | - $objTemp = new clsFuncionario($this->ref_cod_servidor); | ||
| 169 | - $detalhe = $objTemp->detalhe(); | ||
| 170 | - $detalhe = $detalhe['idpes']->detalhe(); | ||
| 171 | - $nm_servidor = $detalhe['nome']; | 164 | + if ($det) { |
| 165 | + foreach ($det as $key => $registro) { | ||
| 166 | + $this->$key = $registro; | ||
| 172 | } | 167 | } |
| 173 | } | 168 | } |
| 174 | - else { | ||
| 175 | - echo '<!--\nErro\nClasse clsPmieducarServidor não encontrada\n-->'; | ||
| 176 | - $opcoes = array('' => 'Erro na geração'); | 169 | + |
| 170 | + if ($this->ref_cod_servidor) { | ||
| 171 | + $objTemp = new clsFuncionario($this->ref_cod_servidor); | ||
| 172 | + $detalhe = $objTemp->detalhe(); | ||
| 173 | + $detalhe = $detalhe['idpes']->detalhe(); | ||
| 174 | + $nm_servidor = $detalhe['nome']; | ||
| 177 | } | 175 | } |
| 178 | 176 | ||
| 179 | $this->campoRotulo('nm_servidor', 'Servidor', $nm_servidor); | 177 | $this->campoRotulo('nm_servidor', 'Servidor', $nm_servidor); |
| @@ -202,9 +200,7 @@ class indice extends clsCadastro | @@ -202,9 +200,7 @@ class indice extends clsCadastro | ||
| 202 | unset($this->ref_cod_escola); | 200 | unset($this->ref_cod_escola); |
| 203 | } | 201 | } |
| 204 | 202 | ||
| 205 | - /** | ||
| 206 | - * Exclusão | ||
| 207 | - */ | 203 | + // Exclusão |
| 208 | if ($this->alocacao_array) { | 204 | if ($this->alocacao_array) { |
| 209 | foreach ($this->alocacao_array as $key => $alocacao) { | 205 | foreach ($this->alocacao_array as $key => $alocacao) { |
| 210 | if (is_numeric($_POST['excluir_periodo'])) { | 206 | if (is_numeric($_POST['excluir_periodo'])) { |
| @@ -217,9 +213,7 @@ class indice extends clsCadastro | @@ -217,9 +213,7 @@ class indice extends clsCadastro | ||
| 217 | } | 213 | } |
| 218 | } | 214 | } |
| 219 | 215 | ||
| 220 | - /** | ||
| 221 | - * Carga Horária | ||
| 222 | - */ | 216 | + // Carga horária |
| 223 | $total_horas = sprintf('%02d', (int) (floor($this->carga_horaria_disponivel))); | 217 | $total_horas = sprintf('%02d', (int) (floor($this->carga_horaria_disponivel))); |
| 224 | $total_horas = sprintf('%02d', (int) (floor($this->carga_horaria_disponivel))); | 218 | $total_horas = sprintf('%02d', (int) (floor($this->carga_horaria_disponivel))); |
| 225 | $total_minutos = sprintf('%02d', (int) ((floatval($this->carga_horaria_disponivel) - floatval($total_horas)) * 60)); | 219 | $total_minutos = sprintf('%02d', (int) ((floatval($this->carga_horaria_disponivel) - floatval($total_horas)) * 60)); |
| @@ -257,29 +251,24 @@ class indice extends clsCadastro | @@ -257,29 +251,24 @@ class indice extends clsCadastro | ||
| 257 | $this->campoOculto('excluir_periodo', ''); | 251 | $this->campoOculto('excluir_periodo', ''); |
| 258 | unset($aux); | 252 | unset($aux); |
| 259 | 253 | ||
| 260 | - if (class_exists('clsPmieducarEscola')) { | ||
| 261 | - $obj_escola = new clsPmieducarEscola(); | ||
| 262 | - $lista_escola = $obj_escola->lista(null, null, null, | ||
| 263 | - $this->ref_ref_cod_instituicao, null, null, null, null, null, null, 1); | 254 | + // Escolas |
| 255 | + $obj_escola = new clsPmieducarEscola(); | ||
| 256 | + $lista_escola = $obj_escola->lista(NULL, NULL, NULL, | ||
| 257 | + $this->ref_ref_cod_instituicao, NULL, NULL, NULL, NULL, NULL, NULL, 1); | ||
| 264 | 258 | ||
| 265 | - if ($lista_escola) { | ||
| 266 | - $opcoes = array('' => 'Selecione'); | ||
| 267 | - foreach ($lista_escola as $escola) { | ||
| 268 | - $opcoes[$escola['cod_escola']] = $escola['nome']; | ||
| 269 | - } | 259 | + if ($lista_escola) { |
| 260 | + $opcoes = array('' => 'Selecione'); | ||
| 261 | + foreach ($lista_escola as $escola) { | ||
| 262 | + $opcoes[$escola['cod_escola']] = $escola['nome']; | ||
| 270 | } | 263 | } |
| 271 | } | 264 | } |
| 272 | - else { | ||
| 273 | - $registro['ref_cod_escola'] = 'Erro na geração'; | ||
| 274 | - echo "<!--\nErro\nClasse não existente: clsPmieducarEscola\n-->"; | ||
| 275 | - } | ||
| 276 | 265 | ||
| 277 | $periodo = array( | 266 | $periodo = array( |
| 278 | - '' => 'Selecione', | ||
| 279 | 1 => 'Matutino', | 267 | 1 => 'Matutino', |
| 280 | 2 => 'Vespertino', | 268 | 2 => 'Vespertino', |
| 281 | 3 => 'Noturno' | 269 | 3 => 'Noturno' |
| 282 | ); | 270 | ); |
| 271 | + self::$periodos = $periodo; | ||
| 283 | 272 | ||
| 284 | $this->campoLista('ref_cod_escola', 'Escola', $opcoes, $this->ref_cod_escola, | 273 | $this->campoLista('ref_cod_escola', 'Escola', $opcoes, $this->ref_cod_escola, |
| 285 | '', FALSE, '', '', FALSE, FALSE); | 274 | '', FALSE, '', '', FALSE, FALSE); |
| @@ -290,6 +279,9 @@ class indice extends clsCadastro | @@ -290,6 +279,9 @@ class indice extends clsCadastro | ||
| 290 | $this->campoHora('carga_horaria_alocada', 'Carga Horária', | 279 | $this->campoHora('carga_horaria_alocada', 'Carga Horária', |
| 291 | $this->carga_horaria_alocada, FALSE); | 280 | $this->carga_horaria_alocada, FALSE); |
| 292 | 281 | ||
| 282 | + // Altera a string de descrição original do campo hora | ||
| 283 | + $this->campos['carga_horaria_alocada'][6] = sprintf('Formato hh:mm (máximo de %d horas por período)', clsPmieducarServidorAlocacao::$cargaHorariaMax); | ||
| 284 | + | ||
| 293 | $this->campoOculto('alocacao_array', serialize($this->alocacao_array)); | 285 | $this->campoOculto('alocacao_array', serialize($this->alocacao_array)); |
| 294 | 286 | ||
| 295 | $this->campoOculto('alocacao_excluida_array', serialize($this->alocacao_excluida_array)); | 287 | $this->campoOculto('alocacao_excluida_array', serialize($this->alocacao_excluida_array)); |
| @@ -308,10 +300,10 @@ class indice extends clsCadastro | @@ -308,10 +300,10 @@ class indice extends clsCadastro | ||
| 308 | $link_excluir = ''; | 300 | $link_excluir = ''; |
| 309 | 301 | ||
| 310 | if ($obj_permissoes->permissao_excluir(635, $this->pessoa_logada, 3)) { | 302 | if ($obj_permissoes->permissao_excluir(635, $this->pessoa_logada, 3)) { |
| 311 | - $link_excluir = "<a href='#' onclick=\"getElementById('excluir_periodo').value = '{$key}'; getElementById( 'tipoacao' ).value = ''; {$this->__nome}.submit();\"><img src='imagens/nvp_bola_xis.gif' title='Excluir' border=0></a>"; | 303 | + $link_excluir = "<a href='#' onclick=\"getElementById('excluir_periodo').value = '{$key}'; getElementById('tipoacao').value = ''; {$this->__nome}.submit();\"><img src='imagens/nvp_bola_xis.gif' title='Excluir' border=0></a>"; |
| 312 | } | 304 | } |
| 313 | 305 | ||
| 314 | - $obj_escola = new clsPmieducarEscola( $alocacao['ref_cod_escola'] ); | 306 | + $obj_escola = new clsPmieducarEscola($alocacao['ref_cod_escola']); |
| 315 | $det_escola = $obj_escola->detalhe(); | 307 | $det_escola = $obj_escola->detalhe(); |
| 316 | $det_escola = $det_escola['nome']; | 308 | $det_escola = $det_escola['nome']; |
| 317 | 309 | ||
| @@ -328,6 +320,9 @@ class indice extends clsCadastro | @@ -328,6 +320,9 @@ class indice extends clsCadastro | ||
| 328 | break; | 320 | break; |
| 329 | } | 321 | } |
| 330 | 322 | ||
| 323 | + // Períodos usados na escola | ||
| 324 | + self::$escolasPeriodos[$alocacao['ref_cod_escola']][$alocacao['periodo']] = $alocacao['periodo']; | ||
| 325 | + | ||
| 331 | $this->campoTextoInv('periodo_' . $key, '', $nm_periodo, 10, 10, FALSE, | 326 | $this->campoTextoInv('periodo_' . $key, '', $nm_periodo, 10, 10, FALSE, |
| 332 | FALSE, TRUE, '', '', '', '', 'periodo'); | 327 | FALSE, TRUE, '', '', '', '', 'periodo'); |
| 333 | 328 | ||
| @@ -382,7 +377,7 @@ class indice extends clsCadastro | @@ -382,7 +377,7 @@ class indice extends clsCadastro | ||
| 382 | $achou = FALSE; | 377 | $achou = FALSE; |
| 383 | 378 | ||
| 384 | foreach ($this->alocacao_array as $alocacao) { | 379 | foreach ($this->alocacao_array as $alocacao) { |
| 385 | - if ($alocacao['periodo'] == $aux["periodo"]) { | 380 | + if ($alocacao['periodo'] == $aux['periodo']) { |
| 386 | $achou = TRUE; | 381 | $achou = TRUE; |
| 387 | } | 382 | } |
| 388 | } | 383 | } |
| @@ -403,7 +398,13 @@ class indice extends clsCadastro | @@ -403,7 +398,13 @@ class indice extends clsCadastro | ||
| 403 | $this->ref_cod_servidor, NULL, NULL, $this->ativo, | 398 | $this->ref_cod_servidor, NULL, NULL, $this->ativo, |
| 404 | $alocacao['carga_horaria_alocada'], $alocacao['periodo']); | 399 | $alocacao['carga_horaria_alocada'], $alocacao['periodo']); |
| 405 | 400 | ||
| 406 | - $cadastrou = $obj->cadastra(); | 401 | + $cadastrou = FALSE; |
| 402 | + if (FALSE == $obj->lista(NULL, $this->ref_ref_cod_instituicao, | ||
| 403 | + NULL, NULL, $alocacao['escola'], $this->ref_cod_servidor, NULL, NULL, | ||
| 404 | + NULL, NULL, NULL, NULL, $alocacao['periodo']) | ||
| 405 | + ) { | ||
| 406 | + $cadastrou = $obj->cadastra(); | ||
| 407 | + } | ||
| 407 | 408 | ||
| 408 | if (!$cadastrou) { | 409 | if (!$cadastrou) { |
| 409 | $this->mensagem = 'Cadastro não realizado.<br />'; | 410 | $this->mensagem = 'Cadastro não realizado.<br />'; |
| @@ -428,7 +429,6 @@ class indice extends clsCadastro | @@ -428,7 +429,6 @@ class indice extends clsCadastro | ||
| 428 | function Excluir() | 429 | function Excluir() |
| 429 | { | 430 | { |
| 430 | return FALSE; | 431 | return FALSE; |
| 431 | - | ||
| 432 | } | 432 | } |
| 433 | } | 433 | } |
| 434 | 434 | ||
| @@ -445,6 +445,31 @@ $pagina->addForm($miolo); | @@ -445,6 +445,31 @@ $pagina->addForm($miolo); | ||
| 445 | $pagina->MakeAll(); | 445 | $pagina->MakeAll(); |
| 446 | ?> | 446 | ?> |
| 447 | <script type="text/javascript"> | 447 | <script type="text/javascript"> |
| 448 | +var escolasPeriodos = <?php print json_encode(indice::$escolasPeriodos); ?>; | ||
| 449 | +var periodos = <?php print json_encode(indice::$periodos); ?>; | ||
| 450 | + | ||
| 451 | +window.onload = function() | ||
| 452 | +{ | ||
| 453 | + getPeriodos(document.getElementById('ref_cod_escola').value); | ||
| 454 | +} | ||
| 455 | + | ||
| 456 | +document.getElementById('ref_cod_escola').onchange = function() | ||
| 457 | +{ | ||
| 458 | + getPeriodos(document.getElementById('ref_cod_escola').value); | ||
| 459 | +} | ||
| 460 | + | ||
| 461 | +function getPeriodos(codEscola) | ||
| 462 | +{ | ||
| 463 | + obj = document.getElementById('periodo'); | ||
| 464 | + obj.length = 0; | ||
| 465 | + | ||
| 466 | + for (var ii in periodos) { | ||
| 467 | + if (!escolasPeriodos[codEscola] || !escolasPeriodos[codEscola][ii]) { | ||
| 468 | + obj.options[obj.length] = new Option(periodos[ii], i); | ||
| 469 | + } | ||
| 470 | + } | ||
| 471 | +} | ||
| 472 | + | ||
| 448 | function validaHora() | 473 | function validaHora() |
| 449 | { | 474 | { |
| 450 | var carga_horaria = document.getElementById('carga_horaria_alocada').value; | 475 | var carga_horaria = document.getElementById('carga_horaria_alocada').value; |
| @@ -473,8 +498,14 @@ function validaHora() | @@ -473,8 +498,14 @@ function validaHora() | ||
| 473 | var carga_horaria_alocada_ = document.getElementById('carga_horaria_alocada').value.split(":"); | 498 | var carga_horaria_alocada_ = document.getElementById('carga_horaria_alocada').value.split(":"); |
| 474 | 499 | ||
| 475 | hora_ = Date.UTC(1970, 01, 01, carga_horaria_alocada_[0], carga_horaria_alocada_[1], 0); | 500 | hora_ = Date.UTC(1970, 01, 01, carga_horaria_alocada_[0], carga_horaria_alocada_[1], 0); |
| 501 | + hora_max_ = Date.UTC(1970, 01, 01, <?php print clsPmieducarServidorAlocacao::$cargaHorariaMax ?>, 0, 0); | ||
| 476 | hora_restantes_ = Date.UTC(1970, 01, 01, horas_restantes[0], horas_restantes[1], 0); | 502 | hora_restantes_ = Date.UTC(1970, 01, 01, horas_restantes[0], horas_restantes[1], 0); |
| 477 | 503 | ||
| 504 | + if (hora_ > hora_max_) { | ||
| 505 | + alert("O número de horas máximo por período/escola é de 6h."); | ||
| 506 | + return false; | ||
| 507 | + } | ||
| 508 | + | ||
| 478 | if (hora_ > hora_restantes_) { | 509 | if (hora_ > hora_restantes_) { |
| 479 | alert("Atenção número de horas excedem o número de horas disponíveis! Por favor, corrija."); | 510 | alert("Atenção número de horas excedem o número de horas disponíveis! Por favor, corrija."); |
| 480 | document.getElementById('ref_cod_escola').value = ''; | 511 | document.getElementById('ref_cod_escola').value = ''; |
ieducar/intranet/include/pmieducar/clsPmieducarServidorAlocacao.inc.php
| @@ -55,6 +55,12 @@ class clsPmieducarServidorAlocacao | @@ -55,6 +55,12 @@ class clsPmieducarServidorAlocacao | ||
| 55 | var $periodo; | 55 | var $periodo; |
| 56 | 56 | ||
| 57 | /** | 57 | /** |
| 58 | + * Carga horária máxima para um período de alocação (em horas). | ||
| 59 | + * @var float | ||
| 60 | + */ | ||
| 61 | + static $cargaHorariaMax = 6.0; | ||
| 62 | + | ||
| 63 | + /** | ||
| 58 | * Armazena o total de resultados obtidos na última chamada ao método lista(). | 64 | * Armazena o total de resultados obtidos na última chamada ao método lista(). |
| 59 | * @var int | 65 | * @var int |
| 60 | */ | 66 | */ |
| @@ -125,89 +131,33 @@ class clsPmieducarServidorAlocacao | @@ -125,89 +131,33 @@ class clsPmieducarServidorAlocacao | ||
| 125 | $this->_campos_lista = $this->_todos_campos = 'cod_servidor_alocacao, ref_ref_cod_instituicao, ref_usuario_exc, ref_usuario_cad, ref_cod_escola, ref_cod_servidor, data_cadastro, data_exclusao, ativo, carga_horaria, periodo'; | 131 | $this->_campos_lista = $this->_todos_campos = 'cod_servidor_alocacao, ref_ref_cod_instituicao, ref_usuario_exc, ref_usuario_cad, ref_cod_escola, ref_cod_servidor, data_cadastro, data_exclusao, ativo, carga_horaria, periodo'; |
| 126 | 132 | ||
| 127 | if (is_numeric($ref_usuario_cad)) { | 133 | if (is_numeric($ref_usuario_cad)) { |
| 128 | - if (class_exists("clsPmieducarUsuario")) { | ||
| 129 | - $tmp_obj = new clsPmieducarUsuario($ref_usuario_cad); | ||
| 130 | - if (method_exists($tmp_obj, "existe")) { | ||
| 131 | - if ($tmp_obj->existe()) { | ||
| 132 | - $this->ref_usuario_cad = $ref_usuario_cad; | ||
| 133 | - } | ||
| 134 | - } | ||
| 135 | - elseif (method_exists($tmp_obj, "detalhe")) { | ||
| 136 | - if ($tmp_obj->detalhe()) { | ||
| 137 | - $this->ref_usuario_cad = $ref_usuario_cad; | ||
| 138 | - } | ||
| 139 | - } | ||
| 140 | - } | ||
| 141 | - else { | ||
| 142 | - if ($db->CampoUnico("SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_cad}'")) { | ||
| 143 | - $this->ref_usuario_cad = $ref_usuario_cad; | ||
| 144 | - } | 134 | + $usuario = new clsPmieducarUsuario($ref_usuario_cad); |
| 135 | + if ($usuario->existe()) { | ||
| 136 | + $this->ref_usuario_cad = $ref_usuario_cad; | ||
| 145 | } | 137 | } |
| 146 | } | 138 | } |
| 147 | 139 | ||
| 148 | if (is_numeric($ref_usuario_exc)) { | 140 | if (is_numeric($ref_usuario_exc)) { |
| 149 | - if (class_exists("clsPmieducarUsuario")) { | ||
| 150 | - $tmp_obj = new clsPmieducarUsuario($ref_usuario_exc); | ||
| 151 | - if (method_exists($tmp_obj, "existe")) { | ||
| 152 | - if ($tmp_obj->existe()) { | ||
| 153 | - $this->ref_usuario_exc = $ref_usuario_exc; | ||
| 154 | - } | ||
| 155 | - } | ||
| 156 | - elseif (method_exists($tmp_obj, "detalhe")) { | ||
| 157 | - if ($tmp_obj->detalhe()) { | ||
| 158 | - $this->ref_usuario_exc = $ref_usuario_exc; | ||
| 159 | - } | ||
| 160 | - } | ||
| 161 | - } | ||
| 162 | - else { | ||
| 163 | - if ($db->CampoUnico("SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_exc}'")) { | ||
| 164 | - $this->ref_usuario_exc = $ref_usuario_exc; | ||
| 165 | - } | 141 | + $usuario = new clsPmieducarUsuario($ref_usuario_exc); |
| 142 | + if ($usuario->existe()) { | ||
| 143 | + $this->ref_usuario_exc = $ref_usuario_exc; | ||
| 166 | } | 144 | } |
| 167 | } | 145 | } |
| 146 | + | ||
| 168 | if (is_numeric($ref_cod_escola)) { | 147 | if (is_numeric($ref_cod_escola)) { |
| 169 | - if (class_exists("clsPmieducarEscola")) { | ||
| 170 | - $tmp_obj = new clsPmieducarEscola($ref_cod_escola); | ||
| 171 | - if (method_exists($tmp_obj, "existe")) { | ||
| 172 | - if ($tmp_obj->existe()) { | ||
| 173 | - $this->ref_cod_escola = $ref_cod_escola; | ||
| 174 | - } | ||
| 175 | - } | ||
| 176 | - elseif (method_exists($tmp_obj, "detalhe")) { | ||
| 177 | - if ($tmp_obj->detalhe()) { | ||
| 178 | - $this->ref_cod_escola = $ref_cod_escola; | ||
| 179 | - } | ||
| 180 | - } | ||
| 181 | - } | ||
| 182 | - else { | ||
| 183 | - if ($db->CampoUnico("SELECT 1 FROM pmieducar.escola WHERE cod_escola = '{$ref_cod_escola}'")) { | ||
| 184 | - $this->ref_cod_escola = $ref_cod_escola; | ||
| 185 | - } | 148 | + $escola = new clsPmieducarEscola($ref_cod_escola); |
| 149 | + if ($escola->existe()) { | ||
| 150 | + $this->ref_cod_escola = $ref_cod_escola; | ||
| 186 | } | 151 | } |
| 187 | } | 152 | } |
| 188 | 153 | ||
| 189 | if (is_numeric($ref_cod_servidor) && is_numeric($ref_ref_cod_instituicao)) { | 154 | if (is_numeric($ref_cod_servidor) && is_numeric($ref_ref_cod_instituicao)) { |
| 190 | - if (class_exists("clsPmieducarServidor")) { | ||
| 191 | - $tmp_obj = new clsPmieducarServidor($ref_cod_servidor, NULL, NULL, NULL, | ||
| 192 | - NULL, NULL, NULL, $ref_ref_cod_instituicao); | ||
| 193 | - if (method_exists($tmp_obj, "existe")) { | ||
| 194 | - if ($tmp_obj->existe()) { | ||
| 195 | - $this->ref_cod_servidor = $ref_cod_servidor; | ||
| 196 | - $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao; | ||
| 197 | - } | ||
| 198 | - } | ||
| 199 | - elseif (method_exists($tmp_obj, "detalhe")) { | ||
| 200 | - if ($tmp_obj->detalhe()) { | ||
| 201 | - $this->ref_cod_servidor = $ref_cod_servidor; | ||
| 202 | - $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao; | ||
| 203 | - } | ||
| 204 | - } | ||
| 205 | - } | ||
| 206 | - else { | ||
| 207 | - if ($db->CampoUnico("SELECT 1 FROM pmieducar.servidor WHERE cod_servidor = '{$ref_cod_servidor}' AND ref_cod_instituicao = '{$ref_ref_cod_instituicao}'")) { | ||
| 208 | - $this->ref_cod_servidor = $ref_cod_servidor; | ||
| 209 | - $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao; | ||
| 210 | - } | 155 | + $servidor = new clsPmieducarServidor($ref_cod_servidor, NULL, NULL, NULL, |
| 156 | + NULL, NULL, NULL, $ref_ref_cod_instituicao); | ||
| 157 | + | ||
| 158 | + if ($servidor->existe()) { | ||
| 159 | + $this->ref_cod_servidor = $ref_cod_servidor; | ||
| 160 | + $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao; | ||
| 211 | } | 161 | } |
| 212 | } | 162 | } |
| 213 | 163 | ||
| @@ -227,8 +177,14 @@ class clsPmieducarServidorAlocacao | @@ -227,8 +177,14 @@ class clsPmieducarServidorAlocacao | ||
| 227 | $this->ativo = $ativo; | 177 | $this->ativo = $ativo; |
| 228 | } | 178 | } |
| 229 | 179 | ||
| 180 | + // Valida a carga horária | ||
| 230 | if (is_string($carga_horaria)) { | 181 | if (is_string($carga_horaria)) { |
| 231 | - $this->carga_horaria = $carga_horaria; | 182 | + $datetime = explode(':', $carga_horaria); |
| 183 | + $minutos = (((int) $datetime[0]) * 60) + (int) $datetime[1]; | ||
| 184 | + | ||
| 185 | + if ((self::$cargaHorariaMax * 60) >= $minutos) { | ||
| 186 | + $this->carga_horaria = $carga_horaria; | ||
| 187 | + } | ||
| 232 | } | 188 | } |
| 233 | 189 | ||
| 234 | if (is_numeric($periodo)) { | 190 | if (is_numeric($periodo)) { |
| @@ -379,7 +335,7 @@ class clsPmieducarServidorAlocacao | @@ -379,7 +335,7 @@ class clsPmieducarServidorAlocacao | ||
| 379 | $int_ref_cod_servidor = NULL, $date_data_cadastro_ini = NULL, | 335 | $int_ref_cod_servidor = NULL, $date_data_cadastro_ini = NULL, |
| 380 | $date_data_cadastro_fim = NULL, $date_data_exclusao_ini = NULL, | 336 | $date_data_cadastro_fim = NULL, $date_data_exclusao_ini = NULL, |
| 381 | $date_data_exclusao_fim = NULL, $int_ativo = NULL, $int_carga_horaria = NULL, | 337 | $date_data_exclusao_fim = NULL, $int_ativo = NULL, $int_carga_horaria = NULL, |
| 382 | - $int_periodo = NULL,$bool_busca_nome = FALSE, $boo_professor = NULL) | 338 | + $int_periodo = NULL, $bool_busca_nome = FALSE, $boo_professor = NULL) |
| 383 | { | 339 | { |
| 384 | $filtros = ''; | 340 | $filtros = ''; |
| 385 | $whereAnd = ' WHERE '; | 341 | $whereAnd = ' WHERE '; |
| @@ -533,7 +489,7 @@ class clsPmieducarServidorAlocacao | @@ -533,7 +489,7 @@ class clsPmieducarServidorAlocacao | ||
| 533 | { | 489 | { |
| 534 | if (is_numeric($this->cod_servidor_alocacao)) { | 490 | if (is_numeric($this->cod_servidor_alocacao)) { |
| 535 | $db = new clsBanco(); | 491 | $db = new clsBanco(); |
| 536 | - $db->Consulta( "SELECT {$this->_todos_campos} FROM {$this->_tabela} WHERE cod_servidor_alocacao = '{$this->cod_servidor_alocacao}'" ); | 492 | + $db->Consulta("SELECT {$this->_todos_campos} FROM {$this->_tabela} WHERE cod_servidor_alocacao = '{$this->cod_servidor_alocacao}'"); |
| 537 | $db->ProximoRegistro(); | 493 | $db->ProximoRegistro(); |
| 538 | return $db->Tupla(); | 494 | return $db->Tupla(); |
| 539 | } | 495 | } |