From b1a1974b8537b326e84d06850c308f33ffbf6f5f Mon Sep 17 00:00:00 2001 From: Eriksen Costa Paixão Date: Tue, 9 Mar 2010 16:33:54 +0000 Subject: [PATCH] #71 by Eriksen Costa: Atualizada interface de alocação de servidores: --- ieducar/intranet/educar_servidor_alocacao_cad.php | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------ ieducar/intranet/include/pmieducar/clsPmieducarServidorAlocacao.inc.php | 106 +++++++++++++++++++++++++++++++--------------------------------------------------------------------------- 2 files changed, 104 insertions(+), 117 deletions(-) diff --git a/ieducar/intranet/educar_servidor_alocacao_cad.php b/ieducar/intranet/educar_servidor_alocacao_cad.php index 9c83569..2aed2ea 100644 --- a/ieducar/intranet/educar_servidor_alocacao_cad.php +++ b/ieducar/intranet/educar_servidor_alocacao_cad.php @@ -84,6 +84,9 @@ class indice extends clsCadastro var $alocacao_array = array(); var $alocacao_excluida_array = array(); + static $escolasPeriodos = array(); + static $periodos = array(); + function Inicializar() { $retorno = 'Novo'; @@ -154,26 +157,21 @@ class indice extends clsCadastro $this->campoRotulo('nm_instituicao', 'Instituição', $inst_det['nm_instituicao']); $this->campoOculto('ref_ref_cod_instituicao', $this->ref_ref_cod_instituicao); - if (class_exists('clsPmieducarServidor')) { - $objTemp = new clsPmieducarServidor($this->ref_cod_servidor); - $det = $objTemp->detalhe(); - - if ($det) { - foreach ($det as $key => $registro) { - $this->$key = $registro; - } - } + // Dados do servidor + $objTemp = new clsPmieducarServidor($this->ref_cod_servidor); + $det = $objTemp->detalhe(); - if ($this->ref_cod_servidor) { - $objTemp = new clsFuncionario($this->ref_cod_servidor); - $detalhe = $objTemp->detalhe(); - $detalhe = $detalhe['idpes']->detalhe(); - $nm_servidor = $detalhe['nome']; + if ($det) { + foreach ($det as $key => $registro) { + $this->$key = $registro; } } - else { - echo ''; - $opcoes = array('' => 'Erro na geração'); + + if ($this->ref_cod_servidor) { + $objTemp = new clsFuncionario($this->ref_cod_servidor); + $detalhe = $objTemp->detalhe(); + $detalhe = $detalhe['idpes']->detalhe(); + $nm_servidor = $detalhe['nome']; } $this->campoRotulo('nm_servidor', 'Servidor', $nm_servidor); @@ -202,9 +200,7 @@ class indice extends clsCadastro unset($this->ref_cod_escola); } - /** - * Exclusão - */ + // Exclusão if ($this->alocacao_array) { foreach ($this->alocacao_array as $key => $alocacao) { if (is_numeric($_POST['excluir_periodo'])) { @@ -217,9 +213,7 @@ class indice extends clsCadastro } } - /** - * Carga Horária - */ + // Carga horária $total_horas = sprintf('%02d', (int) (floor($this->carga_horaria_disponivel))); $total_horas = sprintf('%02d', (int) (floor($this->carga_horaria_disponivel))); $total_minutos = sprintf('%02d', (int) ((floatval($this->carga_horaria_disponivel) - floatval($total_horas)) * 60)); @@ -257,29 +251,24 @@ class indice extends clsCadastro $this->campoOculto('excluir_periodo', ''); unset($aux); - if (class_exists('clsPmieducarEscola')) { - $obj_escola = new clsPmieducarEscola(); - $lista_escola = $obj_escola->lista(null, null, null, - $this->ref_ref_cod_instituicao, null, null, null, null, null, null, 1); + // Escolas + $obj_escola = new clsPmieducarEscola(); + $lista_escola = $obj_escola->lista(NULL, NULL, NULL, + $this->ref_ref_cod_instituicao, NULL, NULL, NULL, NULL, NULL, NULL, 1); - if ($lista_escola) { - $opcoes = array('' => 'Selecione'); - foreach ($lista_escola as $escola) { - $opcoes[$escola['cod_escola']] = $escola['nome']; - } + if ($lista_escola) { + $opcoes = array('' => 'Selecione'); + foreach ($lista_escola as $escola) { + $opcoes[$escola['cod_escola']] = $escola['nome']; } } - else { - $registro['ref_cod_escola'] = 'Erro na geração'; - echo ""; - } $periodo = array( - '' => 'Selecione', 1 => 'Matutino', 2 => 'Vespertino', 3 => 'Noturno' ); + self::$periodos = $periodo; $this->campoLista('ref_cod_escola', 'Escola', $opcoes, $this->ref_cod_escola, '', FALSE, '', '', FALSE, FALSE); @@ -290,6 +279,9 @@ class indice extends clsCadastro $this->campoHora('carga_horaria_alocada', 'Carga Horária', $this->carga_horaria_alocada, FALSE); + // Altera a string de descrição original do campo hora + $this->campos['carga_horaria_alocada'][6] = sprintf('Formato hh:mm (máximo de %d horas por período)', clsPmieducarServidorAlocacao::$cargaHorariaMax); + $this->campoOculto('alocacao_array', serialize($this->alocacao_array)); $this->campoOculto('alocacao_excluida_array', serialize($this->alocacao_excluida_array)); @@ -308,10 +300,10 @@ class indice extends clsCadastro $link_excluir = ''; if ($obj_permissoes->permissao_excluir(635, $this->pessoa_logada, 3)) { - $link_excluir = "__nome}.submit();\">"; + $link_excluir = "__nome}.submit();\">"; } - $obj_escola = new clsPmieducarEscola( $alocacao['ref_cod_escola'] ); + $obj_escola = new clsPmieducarEscola($alocacao['ref_cod_escola']); $det_escola = $obj_escola->detalhe(); $det_escola = $det_escola['nome']; @@ -328,6 +320,9 @@ class indice extends clsCadastro break; } + // Períodos usados na escola + self::$escolasPeriodos[$alocacao['ref_cod_escola']][$alocacao['periodo']] = $alocacao['periodo']; + $this->campoTextoInv('periodo_' . $key, '', $nm_periodo, 10, 10, FALSE, FALSE, TRUE, '', '', '', '', 'periodo'); @@ -382,7 +377,7 @@ class indice extends clsCadastro $achou = FALSE; foreach ($this->alocacao_array as $alocacao) { - if ($alocacao['periodo'] == $aux["periodo"]) { + if ($alocacao['periodo'] == $aux['periodo']) { $achou = TRUE; } } @@ -403,7 +398,13 @@ class indice extends clsCadastro $this->ref_cod_servidor, NULL, NULL, $this->ativo, $alocacao['carga_horaria_alocada'], $alocacao['periodo']); - $cadastrou = $obj->cadastra(); + $cadastrou = FALSE; + if (FALSE == $obj->lista(NULL, $this->ref_ref_cod_instituicao, + NULL, NULL, $alocacao['escola'], $this->ref_cod_servidor, NULL, NULL, + NULL, NULL, NULL, NULL, $alocacao['periodo']) + ) { + $cadastrou = $obj->cadastra(); + } if (!$cadastrou) { $this->mensagem = 'Cadastro não realizado.
'; @@ -428,7 +429,6 @@ class indice extends clsCadastro function Excluir() { return FALSE; - } } @@ -445,6 +445,31 @@ $pagina->addForm($miolo); $pagina->MakeAll(); ?>