Commit 269ca229bad86ad4d25efd514e55271191e4cdee

Authored by Eriksen Costa Paixão
1 parent 49e101ef
Exists in master

#21 by Eriksen: Corrigido bug que impedia apagar uma categoria de servidor do banco de dados.

ieducar/intranet/educar_categoria_nivel_lst.php
1 1 <?php
2   -require_once ("include/clsBase.inc.php");
3   -require_once ("include/clsListagem.inc.php");
4   -require_once ("include/clsBanco.inc.php");
5   -require_once( "include/pmieducar/geral.inc.php" );
6   -
7   -class clsIndexBase extends clsBase
8   -{
9   - function Formular()
10   - {
11   - $this->SetTitulo( "Prefeitura de Itaja&iacute; - Listagem Categoria N&iacute;vel" );
12   - $this->processoAp = "829";
13   - }
  2 +/**
  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/clsBase.inc.php';
  30 +require_once 'include/clsListagem.inc.php';
  31 +require_once 'include/clsBanco.inc.php';
  32 +require_once 'include/pmieducar/geral.inc.php';
  33 +
  34 +
  35 +
  36 +class clsIndexBase extends clsBase {
  37 + public function Formular() {
  38 + $this->SetTitulo("Prefeitura de Itaja&iacute; - Listagem Categoria N&iacute;vel");
  39 + $this->processoAp = "829";
  40 + }
14 41 }
15 42  
16   -class indice extends clsListagem
17   -{
18   - /**
19   - * Referencia pega da session para o idpes do usuario atual
20   - *
21   - * @var int
22   - */
23   - var $__pessoa_logada;
24   -
25   - /**
26   - * Titulo no topo da pagina
27   - *
28   - * @var int
29   - */
30   - var $__titulo;
31   -
32   - /**
33   - * Quantidade de registros a ser apresentada em cada pagina
34   - *
35   - * @var int
36   - */
37   - var $__limite;
38   -
39   - /**
40   - * Inicio dos registros a serem exibidos (limit)
41   - *
42   - * @var int
43   - */
44   - var $__offset;
45   -
46   - var $cod_categoria_nivel;
47   - var $ref_usuario_exc;
48   - var $ref_usuario_cad;
49   - var $nm_categoria_nivel;
50   - var $data_cadastro;
51   - var $data_exclusao;
52   - var $ativo;
53   -
54   - function Gerar()
55   - {
56   - @session_start();
57   - $this->__pessoa_logada = $_SESSION['id_pessoa'];
58   - session_write_close();
59   -
60   - $this->__titulo = "Categoria Nivel - Listagem";
61   -
62   - foreach( $_GET AS $var => $val ) // passa todos os valores obtidos no GET para atributos do objeto
63   - $this->$var = ( $val === "" ) ? null: $val;
64   -
65   - $this->addBanner( "http://ieducar.dccobra.com.br/intranet/imagens/nvp_top_intranet.jpg", "http://ieducar.dccobra.com.br/intranet/imagens/nvp_vert_intranet.jpg", "Intranet" );
66   -
67   - $this->addCabecalhos( array(
68   - //"Categoria Nivel",
69   - "Nome Categoria Nivel"
70   - ) );
71   -
72   - // Filtros de Foreign Keys
73   -
74   -
75   - // outros Filtros
76   - $this->campoTexto( "nm_categoria_nivel", "Nome Categoria Nivel", $this->nm_categoria_nivel, 30, 255, false );
77   -
78   -
79   - // Paginador
80   - $this->__limite = 20;
81   - $this->__offset = ( $_GET["pagina_{$this->nome}"] ) ? $_GET["pagina_{$this->nome}"]*$this->__limite-$this->__limite: 0;
82   -
83   - $obj_categoria_nivel = new clsPmieducarCategoriaNivel();
84   - $obj_categoria_nivel->setOrderby( "nm_categoria_nivel ASC" );
85   - $obj_categoria_nivel->setLimite( $this->__limite, $this->__offset );
86   -
87   - $lista = $obj_categoria_nivel->lista(
88   - null,
89   - null,
90   - $this->nm_categoria_nivel,
91   - null,
92   - null,
93   - 1
94   - );
95   -
96   - $total = $obj_categoria_nivel->_total;
97   -
98   - // monta a lista
99   - if( is_array( $lista ) && count( $lista ) )
100   - {
101   - foreach ( $lista AS $registro )
102   - {
103   - // muda os campos data
104   - $registro["data_cadastro_time"] = strtotime( substr( $registro["data_cadastro"], 0, 16 ) );
105   - $registro["data_cadastro_br"] = date( "d/m/Y H:i", $registro["data_cadastro_time"] );
106   -
107   - $registro["data_exclusao_time"] = strtotime( substr( $registro["data_exclusao"], 0, 16 ) );
108   - $registro["data_exclusao_br"] = date( "d/m/Y H:i", $registro["data_exclusao_time"] );
109   -
110   -
111   - // pega detalhes de foreign_keys
112   - if( class_exists( "clsPmieducarUsuario" ) )
113   - {
114   - $obj_ref_usuario_cad = new clsPmieducarUsuario( $registro["ref_usuario_cad"] );
115   - $det_ref_usuario_cad = $obj_ref_usuario_cad->detalhe();
116   - $registro["ref_usuario_cad"] = $det_ref_usuario_cad["data_cadastro"];
117   - }
118   - else
119   - {
120   - $registro["ref_usuario_cad"] = "Erro na geracao";
121   - echo "<!--\nErro\nClasse nao existente: clsPmieducarUsuario\n-->";
122   - }
123   -
124   - if( class_exists( "clsPmieducarUsuario" ) )
125   - {
126   - $obj_ref_usuario_exc = new clsPmieducarUsuario( $registro["ref_usuario_exc"] );
127   - $det_ref_usuario_exc = $obj_ref_usuario_exc->detalhe();
128   - $registro["ref_usuario_exc"] = $det_ref_usuario_exc["data_cadastro"];
129   - }
130   - else
131   - {
132   - $registro["ref_usuario_exc"] = "Erro na geracao";
133   - echo "<!--\nErro\nClasse nao existente: clsPmieducarUsuario\n-->";
134   - }
135   -
136   -
137   - $this->addLinhas( array(
138   - //"<a href=\"educar_categoria_nivel_det.php?cod_categoria_nivel={$registro["cod_categoria_nivel"]}\">{$registro["cod_categoria_nivel"]}</a>",
139   - "<a href=\"educar_categoria_nivel_det.php?cod_categoria_nivel={$registro["cod_categoria_nivel"]}\">{$registro["nm_categoria_nivel"]}</a>"
140   - ) );
141   - }
142   - }
143   - $this->addPaginador2( "educar_categoria_nivel_lst.php", $total, $_GET, $this->nome, $this->__limite );
144   - $obj_permissoes = new clsPermissoes();
145   - if( $obj_permissoes->permissao_cadastra( 829, $this->__pessoa_logada, 3, null, true ) )
146   - {
147   - $this->acao = "go(\"educar_categoria_nivel_cad.php\")";
148   - $this->nome_acao = "Novo";
149   - }
150   -
151   - $this->largura = "100%";
152   - }
  43 +
  44 +
  45 +class indice extends clsListagem {
  46 + /**
  47 + * Referencia pega da session para o idpes do usuario atual
  48 + *
  49 + * @var int
  50 + */
  51 + var $__pessoa_logada;
  52 +
  53 + /**
  54 + * Titulo no topo da pagina
  55 + *
  56 + * @var int
  57 + */
  58 + var $__titulo;
  59 +
  60 + /**
  61 + * Quantidade de registros a ser apresentada em cada pagina
  62 + *
  63 + * @var int
  64 + */
  65 + var $__limite;
  66 +
  67 + /**
  68 + * Inicio dos registros a serem exibidos (limit)
  69 + *
  70 + * @var int
  71 + */
  72 + var $__offset;
  73 +
  74 + var $cod_categoria_nivel;
  75 + var $ref_usuario_exc;
  76 + var $ref_usuario_cad;
  77 + var $nm_categoria_nivel;
  78 + var $data_cadastro;
  79 + var $data_exclusao;
  80 + var $ativo;
  81 +
  82 + public function Gerar() {
  83 + session_start();
  84 + $this->__pessoa_logada = $_SESSION['id_pessoa'];
  85 + session_write_close();
  86 +
  87 + $this->__titulo = 'Categoria Nivel - Listagem';
  88 +
  89 + // passa todos os valores obtidos no GET para atributos do objeto
  90 + foreach ($_GET as $var => $val) {
  91 + $this->$var = ($val === "") ? NULL : $val;
  92 + }
  93 +
  94 + $this->addBanner('http://ieducar.dccobra.com.br/intranet/imagens/nvp_top_intranet.jpg", "http://ieducar.dccobra.com.br/intranet/imagens/nvp_vert_intranet.jpg', 'Intranet');
  95 +
  96 + $this->addCabecalhos(array(
  97 + 'Nome Categoria Nivel'
  98 + ));
  99 +
  100 + // Filtros
  101 + $this->campoTexto('nm_categoria_nivel', 'Nome Categoria Nivel',
  102 + $this->nm_categoria_nivel, 30, 255, FALSE);
  103 +
  104 + // Paginador
  105 + $this->__limite = 20;
  106 + $this->__offset = ($_GET['pagina_' . $this->nome]) ?
  107 + $_GET['pagina_' . $this->nome] * $this->__limite-$this->__limite : 0;
  108 +
  109 + $obj_categoria_nivel = new clsPmieducarCategoriaNivel();
  110 + $obj_categoria_nivel->setOrderby('nm_categoria_nivel ASC');
  111 + $obj_categoria_nivel->setLimite($this->__limite, $this->__offset);
  112 +
  113 + $lista = $obj_categoria_nivel->lista(
  114 + NULL, NULL, $this->nm_categoria_nivel, NULL, NULL, NULL, NULL, NULL, 1
  115 + );
  116 +
  117 + $total = $obj_categoria_nivel->_total;
  118 +
  119 + // Monta a lista
  120 + if (is_array($lista) && count($lista)) {
  121 + foreach ($lista as $registro) {
  122 + // muda os campos data
  123 + $registro['data_cadastro_time'] = strtotime( substr( $registro['data_cadastro'], 0, 16));
  124 + $registro['data_cadastro_br'] = date('d/m/Y H:i', $registro['data_cadastro_time']);
  125 +
  126 + $registro['data_exclusao_time'] = strtotime(substr( $registro['data_exclusao'], 0, 16));
  127 + $registro['data_exclusao_br'] = date('d/m/Y H:i', $registro['data_exclusao_time']);
  128 +
  129 + // pega detalhes de foreign_keys
  130 + if (class_exists('clsPmieducarUsuario')) {
  131 + $obj_ref_usuario_cad = new clsPmieducarUsuario($registro['ref_usuario_cad']);
  132 + $det_ref_usuario_cad = $obj_ref_usuario_cad->detalhe();
  133 + $registro['ref_usuario_cad'] = $det_ref_usuario_cad['data_cadastro'];
  134 + }
  135 + else {
  136 + $registro['ref_usuario_cad'] = 'Erro na geracao';
  137 + }
  138 +
  139 + if (class_exists('clsPmieducarUsuario')) {
  140 + $obj_ref_usuario_exc = new clsPmieducarUsuario( $registro['ref_usuario_exc']);
  141 + $det_ref_usuario_exc = $obj_ref_usuario_exc->detalhe();
  142 + $registro['ref_usuario_exc'] = $det_ref_usuario_exc['data_cadastro'];
  143 + }
  144 + else {
  145 + $registro['ref_usuario_exc'] = 'Erro na geracao';
  146 + }
  147 +
  148 + $this->addLinhas(array(
  149 + sprintf('<a href="educar_categoria_nivel_det.php?cod_categoria_nivel=%s">%s</a>',
  150 + $registro['cod_categoria_nivel'], $registro['nm_categoria_nivel'])
  151 + ));
  152 + }
  153 + }
  154 +
  155 + $this->addPaginador2('educar_categoria_nivel_lst.php', $total, $_GET,
  156 + $this->nome, $this->__limite);
  157 +
  158 + $obj_permissoes = new clsPermissoes();
  159 + if ($obj_permissoes->permissao_cadastra(829, $this->__pessoa_logada, 3,
  160 + NULL, TRUE)) {
  161 + $this->acao = 'go("educar_categoria_nivel_cad.php")';
  162 + $this->nome_acao = 'Novo';
  163 + }
  164 +
  165 + $this->largura = '100%';
  166 + }
153 167 }
154   -// cria uma extensao da classe base
  168 +
  169 +
  170 +
  171 +// Instancia a classe da página
155 172 $pagina = new clsIndexBase();
156   -// cria o conteudo
  173 +
  174 +// Instancia o conteúdo
157 175 $miolo = new indice();
158   -// adiciona o conteudo na clsBase
  176 +
  177 +// Passa o conteúdo para a classe da página
159 178 $pagina->addForm( $miolo );
160   -// gera o html
161   -$pagina->MakeAll();
162   -?>
  179 +
  180 +// Imprime o HTML
  181 +$pagina->MakeAll();
163 182 \ No newline at end of file
... ...
ieducar/tests/functional/ServidorCategoriaNivelWebTest.class.php 0 → 100644
... ... @@ -0,0 +1,51 @@
  1 +<?php
  2 +
  3 +/**
  4 + * ServidorCategoriaNivelWebTest class.
  5 + *
  6 + * Testa as ações de atualizar um nível de categoria, como verificação
  7 + * da correção do bug #21.
  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 ServidorCategoriaNivelWebTest extends FunctionalBaseTest {
  20 +
  21 + private $slStringTest = 'Selenese Nivel Teste';
  22 +
  23 + protected function tearDown() {
  24 + require_once 'include/pmieducar/clsPmieducarCategoriaNivel.inc.php';
  25 +
  26 + $db = new clsBanco();
  27 + $categoriaNivel = new clsPmieducarCategoriaNivel();
  28 + $sql = sprintf('DELETE FROM %s WHERE %s = \'%s\'',
  29 + $categoriaNivel->_tabela, 'nm_categoria_nivel', $this->slStringTest);
  30 +
  31 + $db->Consulta($sql);
  32 + }
  33 +
  34 + private function createNewEntry() {
  35 + $this->open("/intranet/educar_categoria_nivel_lst.php");
  36 + $this->clickAndWait("//input[@value=' Novo ']");
  37 + $this->type("nm_categoria_nivel", $this->slStringTest);
  38 + $this->clickAndWait("btn_enviar");
  39 + }
  40 +
  41 + public function testCategoriaNivelDelete() {
  42 + $this->doLogin();
  43 + $this->createNewEntry();
  44 +
  45 + $this->clickAndWait("link=" . $this->slStringTest);
  46 + $this->clickAndWait("//input[@value=' Editar ']");
  47 + $this->clickAndWait("//input[@value=' Excluir ']");
  48 + $this->assertTrue((bool) preg_match('/^Excluir registro[\s\S]$/', $this->getConfirmation()));
  49 + $this->assertTrue(!$this->isTextPresent($this->slStringTest));
  50 + }
  51 +}
0 52 \ No newline at end of file
... ...