Commit 49e101efa1d64659d1f4f8a66aaf447876ae6dce
1 parent
7e2dfd43
Exists in
master
#20 by Eriksen: Corrigido bug que impedia atualizar ou excluir um motivo de afastamento de servidor.
Showing
3 changed files
with
421 additions
and
362 deletions
Show diff stats
ieducar/intranet/educar_motivo_afastamento_cad.php
| 1 | 1 | <?php |
| 2 | -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | |
| 3 | - * * | |
| 4 | - * @author Prefeitura Municipal de Itajaí * | |
| 5 | - * @updated 29/03/2007 * | |
| 6 | - * Pacote: i-PLB Software Público Livre e Brasileiro * | |
| 7 | - * * | |
| 8 | - * Copyright (C) 2006 PMI - Prefeitura Municipal de Itajaí * | |
| 9 | - * ctima@itajai.sc.gov.br * | |
| 10 | - * * | |
| 11 | - * Este programa é software livre, você pode redistribuí-lo e/ou * | |
| 12 | - * modificá-lo sob os termos da Licença Pública Geral GNU, conforme * | |
| 13 | - * publicada pela Free Software Foundation, tanto a versão 2 da * | |
| 14 | - * Licença como (a seu critério) qualquer versão mais nova. * | |
| 15 | - * * | |
| 16 | - * Este programa é distribuído na expectativa de ser útil, mas SEM * | |
| 17 | - * QUALQUER GARANTIA. Sem mesmo a garantia implícita de COMERCIALI- * | |
| 18 | - * ZAÇÃO ou de ADEQUAÇÃO A QUALQUER PROPÓSITO EM PARTICULAR. Con- * | |
| 19 | - * sulte a Licença Pública Geral GNU para obter mais detalhes. * | |
| 20 | - * * | |
| 21 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU * | |
| 22 | - * junto com este programa. Se não, escreva para a Free Software * | |
| 23 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * | |
| 24 | - * 02111-1307, USA. * | |
| 25 | - * * | |
| 26 | - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | |
| 27 | 2 | /** |
| 28 | - * @author Adriano Erik Weiguert Nagasava | |
| 3 | + * | |
| 4 | + * @author Prefeitura Municipal de Itajaí | |
| 5 | + * @version SVN: $Id$ | |
| 6 | + * | |
| 7 | + * Pacote: i-PLB Software Público Livre e Brasileiro | |
| 8 | + * | |
| 9 | + * Copyright (C) 2006 PMI - Prefeitura Municipal de Itajaí | |
| 10 | + * ctima@itajai.sc.gov.br | |
| 11 | + * | |
| 12 | + * Este programa é software livre, você pode redistribuí-lo e/ou | |
| 13 | + * modificá-lo sob os termos da Licença Pública Geral GNU, conforme | |
| 14 | + * publicada pela Free Software Foundation, tanto a versão 2 da | |
| 15 | + * Licença como (a seu critério) qualquer versão mais nova. | |
| 16 | + * | |
| 17 | + * Este programa é distribuído na expectativa de ser útil, mas SEM | |
| 18 | + * QUALQUER GARANTIA. Sem mesmo a garantia implícita de COMERCIALI- | |
| 19 | + * ZAÇÃO ou de ADEQUAÇÃO A QUALQUER PROPÓSITO EM PARTICULAR. Con- | |
| 20 | + * sulte a Licença Pública Geral GNU para obter mais detalhes. | |
| 21 | + * | |
| 22 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU | |
| 23 | + * junto com este programa. Se não, escreva para a Free Software | |
| 24 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
| 25 | + * 02111-1307, USA. | |
| 26 | + * | |
| 29 | 27 | */ |
| 30 | -require_once ("include/clsBase.inc.php"); | |
| 31 | -require_once ("include/clsCadastro.inc.php"); | |
| 32 | -require_once ("include/clsBanco.inc.php"); | |
| 33 | -require_once( "include/pmieducar/geral.inc.php" ); | |
| 28 | + | |
| 29 | +require_once 'include/clsBase.inc.php'; | |
| 30 | +require_once 'include/clsCadastro.inc.php'; | |
| 31 | +require_once 'include/clsBanco.inc.php'; | |
| 32 | +require_once 'include/pmieducar/geral.inc.php'; | |
| 34 | 33 | |
| 35 | 34 | class clsIndexBase extends clsBase |
| 36 | 35 | { |
| ... | ... | @@ -48,18 +47,18 @@ class indice extends clsCadastro |
| 48 | 47 | * |
| 49 | 48 | * @var int |
| 50 | 49 | */ |
| 51 | - var $pessoa_logada; | |
| 52 | - | |
| 53 | - var $cod_motivo_afastamento; | |
| 54 | - var $ref_usuario_exc; | |
| 55 | - var $ref_usuario_cad; | |
| 56 | - var $nm_motivo; | |
| 57 | - var $descricao; | |
| 58 | - var $data_cadastro; | |
| 59 | - var $data_exclusao; | |
| 60 | - var $ativo; | |
| 61 | - //var $ref_cod_escola; | |
| 62 | - var $ref_cod_instituicao; | |
| 50 | + public $pessoa_logada = NULL; | |
| 51 | + | |
| 52 | + public | |
| 53 | + $cod_motivo_afastamento = NULL, | |
| 54 | + $ref_usuario_exc = NULL, | |
| 55 | + $ref_usuario_cad = NULL, | |
| 56 | + $nm_motivo = NULL, | |
| 57 | + $descricao = NULL, | |
| 58 | + $data_cadastro = NULL, | |
| 59 | + $data_exclusao = NULL, | |
| 60 | + $ativo = NULL, | |
| 61 | + $ref_cod_instituicao = NULL; | |
| 63 | 62 | |
| 64 | 63 | function Inicializar() |
| 65 | 64 | { |
| ... | ... | @@ -78,9 +77,10 @@ class indice extends clsCadastro |
| 78 | 77 | |
| 79 | 78 | $obj = new clsPmieducarMotivoAfastamento( $this->cod_motivo_afastamento ); |
| 80 | 79 | $registro = $obj->detalhe(); |
| 80 | + | |
| 81 | 81 | if( $registro ) |
| 82 | 82 | { |
| 83 | - foreach( $registro AS $campo => $val ) // passa todos os valores obtidos no registro para atributos do objeto | |
| 83 | + foreach( $registro AS $campo => $val ) // passa todos os valores obtidos no registro para atributos do objeto | |
| 84 | 84 | $this->$campo = $val; |
| 85 | 85 | |
| 86 | 86 | $obj_escola = new clsPmieducarEscola( $this->ref_cod_escola ); |
| ... | ... | @@ -93,9 +93,10 @@ class indice extends clsCadastro |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | $retorno = "Editar"; |
| 96 | + $this->ref_cod_instituicao = $registro['ref_cod_instituicao']; | |
| 96 | 97 | } |
| 97 | 98 | } |
| 98 | - $this->ref_cod_escola = $registro["ref_cod_escola"]; | |
| 99 | + | |
| 99 | 100 | $this->url_cancelar = ($retorno == "Editar") ? "educar_motivo_afastamento_det.php?cod_motivo_afastamento={$registro["cod_motivo_afastamento"]}" : "educar_motivo_afastamento_lst.php"; |
| 100 | 101 | $this->nome_url_cancelar = "Cancelar"; |
| 101 | 102 | return $retorno; |
| ... | ... | @@ -141,30 +142,33 @@ class indice extends clsCadastro |
| 141 | 142 | return false; |
| 142 | 143 | } |
| 143 | 144 | |
| 144 | - function Editar() | |
| 145 | - { | |
| 146 | - @session_start(); | |
| 147 | - $this->pessoa_logada = $_SESSION['id_pessoa']; | |
| 148 | - @session_write_close(); | |
| 149 | 145 | |
| 150 | - $obj_permissoes = new clsPermissoes(); | |
| 151 | - $obj_permissoes->permissao_cadastra( 633, $this->pessoa_logada, 7, "educar_motivo_afastamento_lst.php" ); | |
| 152 | 146 | |
| 147 | + public function Editar() { | |
| 148 | + session_start(); | |
| 149 | + $this->pessoa_logada = $_SESSION['id_pessoa']; | |
| 150 | + session_write_close(); | |
| 151 | + | |
| 152 | + $obj_permissoes = new clsPermissoes(); | |
| 153 | + $obj_permissoes->permissao_cadastra(633, $this->pessoa_logada, 7, | |
| 154 | + 'educar_motivo_afastamento_lst.php'); | |
| 155 | + | |
| 156 | + $obj = new clsPmieducarMotivoAfastamento($this->cod_motivo_afastamento, | |
| 157 | + $this->pessoa_logada, NULL, $this->nm_motivo, $this->descricao, NULL, | |
| 158 | + NULL, 1, $this->ref_cod_instituicao); | |
| 159 | + | |
| 160 | + $editou = $obj->edita(); | |
| 161 | + if ($editou) { | |
| 162 | + $this->mensagem .= 'Edição efetuada com sucesso.<br>'; | |
| 163 | + header('Location: educar_motivo_afastamento_lst.php'); | |
| 164 | + die(); | |
| 165 | + } | |
| 166 | + | |
| 167 | + $this->mensagem = 'Edição não realizada.<br>'; | |
| 168 | + return FALSE; | |
| 169 | + } | |
| 153 | 170 | |
| 154 | - $obj = new clsPmieducarMotivoAfastamento( $this->cod_motivo_afastamento, $this->pessoa_logada, null, $this->nm_motivo, $this->descricao, null, null, 1, $this->ref_cod_escola ); | |
| 155 | - $editou = $obj->edita(); | |
| 156 | - if( $editou ) | |
| 157 | - { | |
| 158 | - $this->mensagem .= "Edição efetuada com sucesso.<br>"; | |
| 159 | - header( "Location: educar_motivo_afastamento_lst.php" ); | |
| 160 | - die(); | |
| 161 | - return true; | |
| 162 | - } | |
| 163 | 171 | |
| 164 | - $this->mensagem = "Edição não realizada.<br>"; | |
| 165 | - echo "<!--\nErro ao editar clsPmieducarMotivoAfastamento\nvalores obrigatorios\nif( is_numeric( $this->cod_motivo_afastamento ) && is_numeric( $this->pessoa_logada ) )\n-->"; | |
| 166 | - return false; | |
| 167 | - } | |
| 168 | 172 | |
| 169 | 173 | function Excluir() |
| 170 | 174 | { |
| ... | ... | @@ -176,7 +180,9 @@ class indice extends clsCadastro |
| 176 | 180 | $obj_permissoes->permissao_excluir( 633, $this->pessoa_logada, 7, "educar_motivo_afastamento_lst.php" ); |
| 177 | 181 | |
| 178 | 182 | |
| 179 | - $obj = new clsPmieducarMotivoAfastamento( $this->cod_motivo_afastamento, $this->pessoa_logada, null, $this->nm_motivo, $this->descricao, null, null, 0, $this->ref_cod_escola ); | |
| 183 | + $obj = new clsPmieducarMotivoAfastamento($this->cod_motivo_afastamento, | |
| 184 | + $this->pessoa_logada, NULL, $this->nm_motivo, $this->descricao, NULL, | |
| 185 | + NULL, 0, $this->ref_cod_instituicao); | |
| 180 | 186 | $excluiu = $obj->excluir(); |
| 181 | 187 | if( $excluiu ) |
| 182 | 188 | { | ... | ... |
ieducar/intranet/include/pmieducar/clsPmieducarMotivoAfastamento.inc.php
| 1 | 1 | <?php |
| 2 | -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | |
| 3 | -* * | |
| 4 | -* @author Prefeitura Municipal de Itajaí * | |
| 5 | -* @updated 29/03/2007 * | |
| 6 | -* Pacote: i-PLB Software Público Livre e Brasileiro * | |
| 7 | -* * | |
| 8 | -* Copyright (C) 2006 PMI - Prefeitura Municipal de Itajaí * | |
| 9 | -* ctima@itajai.sc.gov.br * | |
| 10 | -* * | |
| 11 | -* Este programa é software livre, você pode redistribuí-lo e/ou * | |
| 12 | -* modificá-lo sob os termos da Licença Pública Geral GNU, conforme * | |
| 13 | -* publicada pela Free Software Foundation, tanto a versão 2 da * | |
| 14 | -* Licença como (a seu critério) qualquer versão mais nova. * | |
| 15 | -* * | |
| 16 | -* Este programa é distribuído na expectativa de ser útil, mas SEM * | |
| 17 | -* QUALQUER GARANTIA. Sem mesmo a garantia implícita de COMERCIALI- * | |
| 18 | -* ZAÇÃO ou de ADEQUAÇÃO A QUALQUER PROPÓSITO EM PARTICULAR. Con- * | |
| 19 | -* sulte a Licença Pública Geral GNU para obter mais detalhes. * | |
| 20 | -* * | |
| 21 | -* Você deve ter recebido uma cópia da Licença Pública Geral GNU * | |
| 22 | -* junto com este programa. Se não, escreva para a Free Software * | |
| 23 | -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * | |
| 24 | -* 02111-1307, USA. * | |
| 25 | -* * | |
| 26 | -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | |
| 27 | 2 | /** |
| 28 | -* @author Prefeitura Municipal de Itajaí | |
| 29 | -* | |
| 30 | -* Criado em 26/06/2006 16:19 pelo gerador automatico de classes | |
| 31 | -*/ | |
| 32 | - | |
| 33 | -require_once( "include/pmieducar/geral.inc.php" ); | |
| 34 | - | |
| 35 | -class clsPmieducarMotivoAfastamento | |
| 36 | -{ | |
| 37 | - var $cod_motivo_afastamento; | |
| 38 | - var $ref_usuario_exc; | |
| 39 | - var $ref_usuario_cad; | |
| 40 | - var $nm_motivo; | |
| 41 | - var $descricao; | |
| 42 | - var $data_cadastro; | |
| 43 | - var $data_exclusao; | |
| 44 | - var $ativo; | |
| 45 | - var $ref_cod_instituicao; | |
| 46 | - | |
| 47 | - // propriedades padrao | |
| 48 | - | |
| 49 | - /** | |
| 50 | - * Armazena o total de resultados obtidos na ultima chamada ao metodo lista | |
| 51 | - * | |
| 52 | - * @var int | |
| 53 | - */ | |
| 54 | - var $_total; | |
| 55 | - | |
| 56 | - /** | |
| 57 | - * Nome do schema | |
| 58 | - * | |
| 59 | - * @var string | |
| 60 | - */ | |
| 61 | - var $_schema; | |
| 62 | - | |
| 63 | - /** | |
| 64 | - * Nome da tabela | |
| 65 | - * | |
| 66 | - * @var string | |
| 67 | - */ | |
| 68 | - var $_tabela; | |
| 69 | - | |
| 70 | - /** | |
| 71 | - * Lista separada por virgula, com os campos que devem ser selecionados na proxima chamado ao metodo lista | |
| 72 | - * | |
| 73 | - * @var string | |
| 74 | - */ | |
| 75 | - var $_campos_lista; | |
| 76 | - | |
| 77 | - /** | |
| 78 | - * Lista com todos os campos da tabela separados por virgula, padrao para selecao no metodo lista | |
| 79 | - * | |
| 80 | - * @var string | |
| 81 | - */ | |
| 82 | - var $_todos_campos; | |
| 83 | - | |
| 84 | - /** | |
| 85 | - * Valor que define a quantidade de registros a ser retornada pelo metodo lista | |
| 86 | - * | |
| 87 | - * @var int | |
| 88 | - */ | |
| 89 | - var $_limite_quantidade; | |
| 3 | + * | |
| 4 | + * @author Prefeitura Municipal de Itajaí | |
| 5 | + * @version SVN: $Id$ | |
| 6 | + * | |
| 7 | + * Pacote: i-PLB Software Público Livre e Brasileiro | |
| 8 | + * | |
| 9 | + * Copyright (C) 2006 PMI - Prefeitura Municipal de Itajaí | |
| 10 | + * ctima@itajai.sc.gov.br | |
| 11 | + * | |
| 12 | + * Este programa é software livre, você pode redistribuí-lo e/ou | |
| 13 | + * modificá-lo sob os termos da Licença Pública Geral GNU, conforme | |
| 14 | + * publicada pela Free Software Foundation, tanto a versão 2 da | |
| 15 | + * Licença como (a seu critério) qualquer versão mais nova. | |
| 16 | + * | |
| 17 | + * Este programa é distribuído na expectativa de ser útil, mas SEM | |
| 18 | + * QUALQUER GARANTIA. Sem mesmo a garantia implícita de COMERCIALI- | |
| 19 | + * ZAÇÃO ou de ADEQUAÇÃO A QUALQUER PROPÓSITO EM PARTICULAR. Con- | |
| 20 | + * sulte a Licença Pública Geral GNU para obter mais detalhes. | |
| 21 | + * | |
| 22 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU | |
| 23 | + * junto com este programa. Se não, escreva para a Free Software | |
| 24 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
| 25 | + * 02111-1307, USA. | |
| 26 | + * | |
| 27 | + */ | |
| 28 | + | |
| 29 | +require_once 'include/pmieducar/geral.inc.php'; | |
| 30 | + | |
| 31 | +class clsPmieducarMotivoAfastamento { | |
| 32 | + | |
| 33 | + public | |
| 34 | + $cod_motivo_afastamento = NULL, | |
| 35 | + $ref_usuario_exc = NULL, | |
| 36 | + $ref_usuario_cad = NULL, | |
| 37 | + $nm_motivo = NULL, | |
| 38 | + $descricao = NULL, | |
| 39 | + $data_cadastro = NULL, | |
| 40 | + $data_exclusao = NULL, | |
| 41 | + $ativo = NULL, | |
| 42 | + $ref_cod_instituicao = NULL; | |
| 43 | + | |
| 44 | + /** | |
| 45 | + * Armazena o total de resultados obtidos na ultima chamada ao metodo lista | |
| 46 | + * | |
| 47 | + * @var int | |
| 48 | + */ | |
| 49 | + public $_total; | |
| 50 | + | |
| 51 | + /** | |
| 52 | + * Nome do schema | |
| 53 | + * | |
| 54 | + * @var string | |
| 55 | + */ | |
| 56 | + public $_schema; | |
| 57 | + | |
| 58 | + /** | |
| 59 | + * Nome da tabela | |
| 60 | + * | |
| 61 | + * @var string | |
| 62 | + */ | |
| 63 | + public $_tabela; | |
| 64 | + | |
| 65 | + /** | |
| 66 | + * Lista separada por virgula, com os campos que devem ser selecionados na proxima chamado ao metodo lista | |
| 67 | + * | |
| 68 | + * @var string | |
| 69 | + */ | |
| 70 | + public $_campos_lista; | |
| 71 | + | |
| 72 | + /** | |
| 73 | + * Lista com todos os campos da tabela separados por virgula, padrao para selecao no metodo lista | |
| 74 | + * | |
| 75 | + * @var string | |
| 76 | + */ | |
| 77 | + public $_todos_campos; | |
| 78 | + | |
| 79 | + /** | |
| 80 | + * Valor que define a quantidade de registros a ser retornada pelo metodo lista | |
| 81 | + * | |
| 82 | + * @var int | |
| 83 | + */ | |
| 84 | + public $_limite_quantidade; | |
| 90 | 85 | |
| 91 | 86 | /** |
| 92 | 87 | * Define o valor de offset no retorno dos registros no metodo lista |
| 93 | 88 | * |
| 94 | 89 | * @var int |
| 95 | 90 | */ |
| 96 | - var $_limite_offset; | |
| 97 | - | |
| 98 | - /** | |
| 99 | - * Define o campo padrao para ser usado como padrao de ordenacao no metodo lista | |
| 100 | - * | |
| 101 | - * @var string | |
| 102 | - */ | |
| 103 | - var $_campo_order_by; | |
| 91 | + public $_limite_offset; | |
| 92 | + | |
| 93 | + /** | |
| 94 | + * Define o campo padrao para ser usado como padrao de ordenacao no metodo lista | |
| 95 | + * | |
| 96 | + * @var string | |
| 97 | + */ | |
| 98 | + public $_campo_order_by; | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + /** | |
| 103 | + * Construtor (PHP 4). | |
| 104 | + * | |
| 105 | + * @return clsPmieducarMotivoAfastamento | |
| 106 | + */ | |
| 107 | + public function clsPmieducarMotivoAfastamento($cod_motivo_afastamento = NULL, | |
| 108 | + $ref_usuario_exc = NULL, $ref_usuario_cad = NULL, $nm_motivo = NULL, | |
| 109 | + $descricao = NULL, $data_cadastro = NULL, $data_exclusao = NULL, | |
| 110 | + $ativo = NULL, $ref_cod_instituicao = NULL) { | |
| 111 | + | |
| 112 | + $db = new clsBanco(); | |
| 113 | + $this->_schema = 'pmieducar.'; | |
| 114 | + $this->_tabela = "{$this->_schema}motivo_afastamento"; | |
| 115 | + | |
| 116 | + $this->_campos_lista = $this->_todos_campos = 'cod_motivo_afastamento, ref_usuario_exc, ref_usuario_cad, nm_motivo, descricao, data_cadastro, data_exclusao, ativo, ref_cod_instituicao'; | |
| 117 | + | |
| 118 | + if (is_numeric($ref_usuario_cad)) { | |
| 119 | + | |
| 120 | + if (class_exists('clsPmieducarUsuario')) { | |
| 121 | + $tmp_obj = new clsPmieducarUsuario( $ref_usuario_cad ); | |
| 122 | + if (method_exists($tmp_obj, 'existe')) { | |
| 123 | + if ($tmp_obj->existe()) { | |
| 124 | + $this->ref_usuario_cad = $ref_usuario_cad; | |
| 125 | + } | |
| 126 | + } | |
| 127 | + elseif (method_exists($tmp_obj, 'detalhe')) { | |
| 128 | + if ($tmp_obj->detalhe()) { | |
| 129 | + $this->ref_usuario_cad = $ref_usuario_cad; | |
| 130 | + } | |
| 131 | + } | |
| 132 | + } | |
| 133 | + else { | |
| 134 | + if ($db->CampoUnico("SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_cad}'")) { | |
| 135 | + $this->ref_usuario_cad = $ref_usuario_cad; | |
| 136 | + } | |
| 137 | + } | |
| 138 | + | |
| 139 | + } | |
| 140 | + | |
| 141 | + if (is_numeric($ref_usuario_exc)) { | |
| 142 | + if (class_exists('clsPmieducarUsuario')) { | |
| 143 | + $tmp_obj = new clsPmieducarUsuario($ref_usuario_exc); | |
| 144 | + if (method_exists($tmp_obj, 'existe')) { | |
| 145 | + if ($tmp_obj->existe()) { | |
| 146 | + $this->ref_usuario_exc = $ref_usuario_exc; | |
| 147 | + } | |
| 148 | + } | |
| 149 | + elseif (method_exists($tmp_obj, 'detalhe')) { | |
| 150 | + if ($tmp_obj->detalhe()) { | |
| 151 | + $this->ref_usuario_exc = $ref_usuario_exc; | |
| 152 | + } | |
| 153 | + } | |
| 154 | + } | |
| 155 | + else { | |
| 156 | + if ($db->CampoUnico("SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_exc}'")) { | |
| 157 | + $this->ref_usuario_exc = $ref_usuario_exc; | |
| 158 | + } | |
| 159 | + } | |
| 160 | + } | |
| 161 | + | |
| 162 | + if (is_numeric($cod_motivo_afastamento)) { | |
| 163 | + $this->cod_motivo_afastamento = $cod_motivo_afastamento; | |
| 164 | + } | |
| 165 | + | |
| 166 | + if (is_string($nm_motivo)) { | |
| 167 | + $this->nm_motivo = $nm_motivo; | |
| 168 | + } | |
| 169 | + | |
| 170 | + if (is_string( $descricao)) { | |
| 171 | + $this->descricao = $descricao; | |
| 172 | + } | |
| 173 | + | |
| 174 | + if (is_string($data_cadastro)) { | |
| 175 | + $this->data_cadastro = $data_cadastro; | |
| 176 | + } | |
| 177 | + | |
| 178 | + if (is_string($data_exclusao)) { | |
| 179 | + $this->data_exclusao = $data_exclusao; | |
| 180 | + } | |
| 181 | + | |
| 182 | + if (is_numeric($ativo)) { | |
| 183 | + $this->ativo = $ativo; | |
| 184 | + } | |
| 185 | + | |
| 186 | + if (is_numeric($ref_cod_instituicao)) { | |
| 187 | + if (class_exists('clsPmieducarInstituicao')) { | |
| 188 | + $tmp_obj = new clsPmieducarInstituicao( $ref_cod_instituicao ); | |
| 189 | + if (method_exists($tmp_obj, 'existe')) { | |
| 190 | + if ($tmp_obj->existe()) { | |
| 191 | + $this->ref_cod_instituicao = $ref_cod_instituicao; | |
| 192 | + } | |
| 193 | + } | |
| 194 | + elseif (method_exists($tmp_obj, 'detalhe')) { | |
| 195 | + if ($tmp_obj->detalhe()) { | |
| 196 | + $this->ref_cod_instituicao = $ref_cod_instituicao; | |
| 197 | + } | |
| 198 | + } | |
| 199 | + } | |
| 200 | + else { | |
| 201 | + if ($db->CampoUnico("SELECT 1 FROM pmieducar.instituicao WHERE cod_instituicao = '{$ref_cod_instituicao}'")) { | |
| 202 | + $this->ref_cod_instituicao = $ref_cod_instituicao; | |
| 203 | + } | |
| 204 | + } | |
| 205 | + } | |
| 206 | + | |
| 207 | + } | |
| 104 | 208 | |
| 105 | 209 | |
| 106 | - /** | |
| 107 | - * Construtor (PHP 4) | |
| 108 | - * | |
| 109 | - * @return object | |
| 110 | - */ | |
| 111 | - function clsPmieducarMotivoAfastamento( $cod_motivo_afastamento = null, $ref_usuario_exc = null, $ref_usuario_cad = null, $nm_motivo = null, $descricao = null, $data_cadastro = null, $data_exclusao = null, $ativo = null, $ref_cod_instituicao = null ) | |
| 112 | - { | |
| 113 | - $db = new clsBanco(); | |
| 114 | - $this->_schema = "pmieducar."; | |
| 115 | - $this->_tabela = "{$this->_schema}motivo_afastamento"; | |
| 116 | - | |
| 117 | - $this->_campos_lista = $this->_todos_campos = "cod_motivo_afastamento, ref_usuario_exc, ref_usuario_cad, nm_motivo, descricao, data_cadastro, data_exclusao, ativo, ref_cod_instituicao"; | |
| 118 | - | |
| 119 | - if( is_numeric( $ref_usuario_cad ) ) | |
| 120 | - { | |
| 121 | - if( class_exists( "clsPmieducarUsuario" ) ) | |
| 122 | - { | |
| 123 | - $tmp_obj = new clsPmieducarUsuario( $ref_usuario_cad ); | |
| 124 | - if( method_exists( $tmp_obj, "existe") ) | |
| 125 | - { | |
| 126 | - if( $tmp_obj->existe() ) | |
| 127 | - { | |
| 128 | - $this->ref_usuario_cad = $ref_usuario_cad; | |
| 129 | - } | |
| 130 | - } | |
| 131 | - else if( method_exists( $tmp_obj, "detalhe") ) | |
| 132 | - { | |
| 133 | - if( $tmp_obj->detalhe() ) | |
| 134 | - { | |
| 135 | - $this->ref_usuario_cad = $ref_usuario_cad; | |
| 136 | - } | |
| 137 | - } | |
| 138 | - } | |
| 139 | - else | |
| 140 | - { | |
| 141 | - if( $db->CampoUnico( "SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_cad}'" ) ) | |
| 142 | - { | |
| 143 | - $this->ref_usuario_cad = $ref_usuario_cad; | |
| 144 | - } | |
| 145 | - } | |
| 146 | - } | |
| 147 | - if( is_numeric( $ref_usuario_exc ) ) | |
| 148 | - { | |
| 149 | - if( class_exists( "clsPmieducarUsuario" ) ) | |
| 150 | - { | |
| 151 | - $tmp_obj = new clsPmieducarUsuario( $ref_usuario_exc ); | |
| 152 | - if( method_exists( $tmp_obj, "existe") ) | |
| 153 | - { | |
| 154 | - if( $tmp_obj->existe() ) | |
| 155 | - { | |
| 156 | - $this->ref_usuario_exc = $ref_usuario_exc; | |
| 157 | - } | |
| 158 | - } | |
| 159 | - else if( method_exists( $tmp_obj, "detalhe") ) | |
| 160 | - { | |
| 161 | - if( $tmp_obj->detalhe() ) | |
| 162 | - { | |
| 163 | - $this->ref_usuario_exc = $ref_usuario_exc; | |
| 164 | - } | |
| 165 | - } | |
| 166 | - } | |
| 167 | - else | |
| 168 | - { | |
| 169 | - if( $db->CampoUnico( "SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_exc}'" ) ) | |
| 170 | - { | |
| 171 | - $this->ref_usuario_exc = $ref_usuario_exc; | |
| 172 | - } | |
| 173 | - } | |
| 174 | - } | |
| 175 | - | |
| 176 | - | |
| 177 | - if( is_numeric( $cod_motivo_afastamento ) ) | |
| 178 | - { | |
| 179 | - $this->cod_motivo_afastamento = $cod_motivo_afastamento; | |
| 180 | - } | |
| 181 | - if( is_string( $nm_motivo ) ) | |
| 182 | - { | |
| 183 | - $this->nm_motivo = $nm_motivo; | |
| 184 | - } | |
| 185 | - if( is_string( $descricao ) ) | |
| 186 | - { | |
| 187 | - $this->descricao = $descricao; | |
| 188 | - } | |
| 189 | - if( is_string( $data_cadastro ) ) | |
| 190 | - { | |
| 191 | - $this->data_cadastro = $data_cadastro; | |
| 192 | - } | |
| 193 | - if( is_string( $data_exclusao ) ) | |
| 194 | - { | |
| 195 | - $this->data_exclusao = $data_exclusao; | |
| 196 | - } | |
| 197 | - if( is_numeric( $ativo ) ) | |
| 198 | - { | |
| 199 | - $this->ativo = $ativo; | |
| 200 | - } | |
| 201 | - if( is_numeric( $ref_cod_instituicao ) ) | |
| 202 | - { | |
| 203 | - if( class_exists( "clsPmieducarInstituicao" ) ) | |
| 204 | - { | |
| 205 | - $tmp_obj = new clsPmieducarInstituicao( $ref_cod_instituicao ); | |
| 206 | - if( method_exists( $tmp_obj, "existe") ) | |
| 207 | - { | |
| 208 | - if( $tmp_obj->existe() ) | |
| 209 | - { | |
| 210 | - $this->ref_cod_instituicao = $ref_cod_instituicao; | |
| 211 | - } | |
| 212 | - } | |
| 213 | - else if( method_exists( $tmp_obj, "detalhe") ) | |
| 214 | - { | |
| 215 | - if( $tmp_obj->detalhe() ) | |
| 216 | - { | |
| 217 | - $this->ref_cod_instituicao = $ref_cod_instituicao; | |
| 218 | - } | |
| 219 | - } | |
| 220 | - } | |
| 221 | - else | |
| 222 | - { | |
| 223 | - if( $db->CampoUnico( "SELECT 1 FROM pmieducar.instituicao WHERE cod_instituicao = '{$ref_cod_instituicao}'" ) ) | |
| 224 | - { | |
| 225 | - $this->ref_cod_instituicao = $ref_cod_instituicao; | |
| 226 | - } | |
| 227 | - } | |
| 228 | - } | |
| 229 | - } | |
| 230 | 210 | |
| 231 | 211 | /** |
| 232 | 212 | * Cria um novo registro |
| ... | ... | @@ -280,66 +260,73 @@ class clsPmieducarMotivoAfastamento |
| 280 | 260 | return false; |
| 281 | 261 | } |
| 282 | 262 | |
| 283 | - /** | |
| 284 | - * Edita os dados de um registro | |
| 285 | - * | |
| 286 | - * @return bool | |
| 287 | - */ | |
| 288 | - function edita() | |
| 289 | - { | |
| 290 | - if( is_numeric( $this->cod_motivo_afastamento ) && is_numeric( $this->ref_usuario_exc ) && is_numeric( $this->ref_cod_instituicao ) ) | |
| 291 | - { | |
| 292 | 263 | |
| 293 | - $db = new clsBanco(); | |
| 294 | - $set = ""; | |
| 295 | 264 | |
| 296 | - if( is_numeric( $this->ref_usuario_exc ) ) | |
| 297 | - { | |
| 298 | - $set .= "{$gruda}ref_usuario_exc = '{$this->ref_usuario_exc}'"; | |
| 299 | - $gruda = ", "; | |
| 300 | - } | |
| 301 | - if( is_numeric( $this->ref_usuario_cad ) ) | |
| 302 | - { | |
| 303 | - $set .= "{$gruda}ref_usuario_cad = '{$this->ref_usuario_cad}'"; | |
| 304 | - $gruda = ", "; | |
| 305 | - } | |
| 306 | - if( is_string( $this->nm_motivo ) ) | |
| 307 | - { | |
| 308 | - $set .= "{$gruda}nm_motivo = '{$this->nm_motivo}'"; | |
| 309 | - $gruda = ", "; | |
| 310 | - } | |
| 311 | - if( is_string( $this->descricao ) ) | |
| 312 | - { | |
| 313 | - $set .= "{$gruda}descricao = '{$this->descricao}'"; | |
| 314 | - $gruda = ", "; | |
| 315 | - } | |
| 316 | - if( is_string( $this->data_cadastro ) ) | |
| 317 | - { | |
| 318 | - $set .= "{$gruda}data_cadastro = '{$this->data_cadastro}'"; | |
| 319 | - $gruda = ", "; | |
| 320 | - } | |
| 321 | - $set .= "{$gruda}data_exclusao = NOW()"; | |
| 322 | - $gruda = ", "; | |
| 323 | - if( is_numeric( $this->ativo ) ) | |
| 324 | - { | |
| 325 | - $set .= "{$gruda}ativo = '{$this->ativo}'"; | |
| 326 | - $gruda = ", "; | |
| 327 | - } | |
| 328 | - if( is_numeric( $this->ref_cod_instituicao ) ) | |
| 329 | - { | |
| 330 | - $set .= "{$gruda}ref_cod_instituicao = '{$this->ref_cod_instituicao}'"; | |
| 331 | - $gruda = ", "; | |
| 332 | - } | |
| 265 | + /** | |
| 266 | + * Atualiza um registro. | |
| 267 | + * | |
| 268 | + * @param bool TRUE para que seja gravado a data atual no campo | |
| 269 | + * data_exclusao | |
| 270 | + * @return bool | |
| 271 | + */ | |
| 272 | + public function edita($setDataExclusao = FALSE) { | |
| 333 | 273 | |
| 274 | + if (is_numeric($this->cod_motivo_afastamento) && is_numeric($this->ref_usuario_exc) | |
| 275 | + && is_numeric($this->ref_cod_instituicao)) { | |
| 334 | 276 | |
| 335 | - if( $set ) | |
| 336 | - { | |
| 337 | - $db->Consulta( "UPDATE {$this->_tabela} SET $set WHERE cod_motivo_afastamento = '{$this->cod_motivo_afastamento}'" ); | |
| 338 | - return true; | |
| 339 | - } | |
| 340 | - } | |
| 341 | - return false; | |
| 342 | - } | |
| 277 | + $db = new clsBanco(); | |
| 278 | + $set = ''; | |
| 279 | + | |
| 280 | + if (is_numeric($this->ref_usuario_exc)) { | |
| 281 | + $set .= "{$gruda}ref_usuario_exc = '{$this->ref_usuario_exc}'"; | |
| 282 | + $gruda = ", "; | |
| 283 | + } | |
| 284 | + | |
| 285 | + if (is_numeric($this->ref_usuario_cad)) { | |
| 286 | + $set .= "{$gruda}ref_usuario_cad = '{$this->ref_usuario_cad}'"; | |
| 287 | + $gruda = ", "; | |
| 288 | + } | |
| 289 | + | |
| 290 | + if (is_string($this->nm_motivo)) { | |
| 291 | + $set .= "{$gruda}nm_motivo = '{$this->nm_motivo}'"; | |
| 292 | + $gruda = ", "; | |
| 293 | + } | |
| 294 | + | |
| 295 | + if (is_string($this->descricao)) { | |
| 296 | + $set .= "{$gruda}descricao = '{$this->descricao}'"; | |
| 297 | + $gruda = ", "; | |
| 298 | + } | |
| 299 | + | |
| 300 | + if (is_string($this->data_cadastro)) { | |
| 301 | + $set .= "{$gruda}data_cadastro = '{$this->data_cadastro}'"; | |
| 302 | + $gruda = ", "; | |
| 303 | + } | |
| 304 | + | |
| 305 | + if (is_numeric($this->ativo)) { | |
| 306 | + $set .= "{$gruda}ativo = '{$this->ativo}'"; | |
| 307 | + $gruda = ", "; | |
| 308 | + } | |
| 309 | + | |
| 310 | + if (is_numeric($this->ref_cod_instituicao)) { | |
| 311 | + $set .= "{$gruda}ref_cod_instituicao = '{$this->ref_cod_instituicao}'"; | |
| 312 | + $gruda = ", "; | |
| 313 | + } | |
| 314 | + | |
| 315 | + // Configura a data de exclusão para a data da execução do comando SQL | |
| 316 | + if ($setDataExclusao == TRUE) { | |
| 317 | + $set .= $gruda . ' data_exclusao = NOW()'; | |
| 318 | + } | |
| 319 | + | |
| 320 | + if ($set) { | |
| 321 | + $db->Consulta( "UPDATE {$this->_tabela} SET $set WHERE | |
| 322 | + cod_motivo_afastamento = '{$this->cod_motivo_afastamento}'"); | |
| 323 | + | |
| 324 | + return TRUE; | |
| 325 | + } | |
| 326 | + } | |
| 327 | + | |
| 328 | + return FALSE; | |
| 329 | + } | |
| 343 | 330 | |
| 344 | 331 | /** |
| 345 | 332 | * Retorna uma lista filtrados de acordo com os parametros |
| ... | ... | @@ -486,28 +473,29 @@ class clsPmieducarMotivoAfastamento |
| 486 | 473 | return false; |
| 487 | 474 | } |
| 488 | 475 | |
| 489 | - /** | |
| 490 | - * Exclui um registro | |
| 491 | - * | |
| 492 | - * @return bool | |
| 493 | - */ | |
| 494 | - function excluir() | |
| 495 | - { | |
| 496 | - if( is_numeric( $this->cod_motivo_afastamento ) && is_numeric( $this->ref_usuario_exc ) ) | |
| 497 | - { | |
| 498 | 476 | |
| 499 | - /* | |
| 500 | - delete | |
| 501 | - $db = new clsBanco(); | |
| 502 | - $db->Consulta( "DELETE FROM {$this->_tabela} WHERE cod_motivo_afastamento = '{$this->cod_motivo_afastamento}'" ); | |
| 503 | - return true; | |
| 504 | - */ | |
| 505 | 477 | |
| 506 | - $this->ativo = 0; | |
| 507 | - return $this->edita(); | |
| 508 | - } | |
| 509 | - return false; | |
| 510 | - } | |
| 478 | + | |
| 479 | + /** | |
| 480 | + * Marca um registro como inativo. | |
| 481 | + * | |
| 482 | + * O registro é marcado como inativo para que outros registros que usam | |
| 483 | + * esta tabela em um relacionamento possam recuperar a informação | |
| 484 | + * complementar, nesse caso, um motivo de afastamento. | |
| 485 | + * | |
| 486 | + * @return bool | |
| 487 | + */ | |
| 488 | + public function excluir() { | |
| 489 | + if (is_numeric($this->cod_motivo_afastamento) && is_numeric($this->ref_usuario_exc)) { | |
| 490 | + $this->ativo = 0; | |
| 491 | + | |
| 492 | + return $this->edita(TRUE); | |
| 493 | + } | |
| 494 | + | |
| 495 | + return FALSE; | |
| 496 | + } | |
| 497 | + | |
| 498 | + | |
| 511 | 499 | |
| 512 | 500 | /** |
| 513 | 501 | * Define quais campos da tabela serao selecionados na invocacao do metodo lista |
| ... | ... | @@ -589,5 +577,4 @@ class clsPmieducarMotivoAfastamento |
| 589 | 577 | return ""; |
| 590 | 578 | } |
| 591 | 579 | |
| 592 | -} | |
| 593 | -?> | |
| 594 | 580 | \ No newline at end of file |
| 581 | +} | |
| 595 | 582 | \ No newline at end of file | ... | ... |
ieducar/tests/functional/ServidorMotivoAfastamentoWebTest.class.php
0 → 100644
| ... | ... | @@ -0,0 +1,66 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * ServidorMotivoAfastamentoWebTest class. | |
| 5 | + * | |
| 6 | + * Testa as ações de atualizar e apagar um motivo de afastamento, como | |
| 7 | + * verificação da correção do bug #20. | |
| 8 | + * | |
| 9 | + * Esse teste precisa ser executado com o banco de dados distribuído na | |
| 10 | + * versão 1.0.0. | |
| 11 | + * | |
| 12 | + * @author Eriksen Costa <eriksen.paixao_bs@cobra.com.br> | |
| 13 | + * @since 1.0.1 | |
| 14 | + * @version SVN: $Id$ | |
| 15 | + */ | |
| 16 | + | |
| 17 | +require_once realpath(dirname(__FILE__) . '/../') . '/FunctionalBaseTest.class.php'; | |
| 18 | + | |
| 19 | +class ServidorMotivoAfastamentoWebTest extends FunctionalBaseTest { | |
| 20 | + | |
| 21 | + /** | |
| 22 | + * Os testes a seguir cobrem o bug report #20. | |
| 23 | + * | |
| 24 | + * @link http://svn.softwarepublico.gov.br/trac/ieducar/ticket/20 Bug report #20 | |
| 25 | + * @{ | |
| 26 | + */ | |
| 27 | + public function createNewEntry() { | |
| 28 | + $this->open("/intranet/educar_motivo_afastamento_lst.php"); | |
| 29 | + $this->clickAndWait("//input[@value=' Novo ']"); | |
| 30 | + $this->select("ref_cod_instituicao", "label=COBRA Tecnologia"); | |
| 31 | + $this->type("nm_motivo", "Motivo teste"); | |
| 32 | + $this->clickAndWait("btn_enviar"); | |
| 33 | + } | |
| 34 | + | |
| 35 | + public function testMotivoAfastamentoUpdate() { | |
| 36 | + $this->doLogin(); | |
| 37 | + $this->createNewEntry(); | |
| 38 | + | |
| 39 | + $this->open("/intranet/educar_motivo_afastamento_cad.php?cod_motivo_afastamento=1"); | |
| 40 | + $this->select("ref_cod_instituicao", "label=COBRA Tecnologia"); | |
| 41 | + $this->type("nm_motivo", "Motivo teste"); | |
| 42 | + $this->clickAndWait("btn_enviar"); | |
| 43 | + | |
| 44 | + $statusMessage = $this->isTextPresent("Edição não realizada."); | |
| 45 | + $this->assertTrue(!$statusMessage); | |
| 46 | + $this->doLogout(); | |
| 47 | + } | |
| 48 | + | |
| 49 | + public function testMotivoAfastamentoDelete() { | |
| 50 | + $this->doLogin(); | |
| 51 | + | |
| 52 | + $this->open("/intranet/educar_motivo_afastamento_lst.php"); | |
| 53 | + $this->clickAndWait("link=Motivo teste"); | |
| 54 | + $this->clickAndWait("//input[@value=' Editar ']"); | |
| 55 | + $this->clickAndWait("//input[@value=' Excluir ']"); | |
| 56 | + $this->assertTrue((bool)preg_match('/^Excluir registro[\s\S]$/',$this->getConfirmation())); | |
| 57 | + $statusMessage = $this->isTextPresent("Exclusão não realizada."); | |
| 58 | + $this->assertTrue(!$statusMessage); | |
| 59 | + | |
| 60 | + $this->doLogout(); | |
| 61 | + } | |
| 62 | + /** | |
| 63 | + * }@ | |
| 64 | + */ | |
| 65 | + | |
| 66 | +} | |
| 0 | 67 | \ No newline at end of file | ... | ... |