Commit 36f96796d21c751f9a5fb0cad242378194aa329d

Authored by gabrielms
1 parent b748dd10
Exists in master

Ajustado cadastro de exemplareso:

* Não permitir que um tombo seja cadastrado com dois nomes;
portabilis/ieducar#12
ieducar/intranet/educar_exemplar_cad.php
... ... @@ -5,25 +5,25 @@
5 5  
6 6 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
7 7 * *
8   - * @author Prefeitura Municipal de Itajaí *
  8 + * @author Prefeitura Municipal de Itajaí *
9 9 * @updated 29/03/2007 *
10   - * Pacote: i-PLB Software Público Livre e Brasileiro *
  10 + * Pacote: i-PLB Software Público Livre e Brasileiro *
11 11 * *
12   - * Copyright (C) 2006 PMI - Prefeitura Municipal de Itajaí *
  12 + * Copyright (C) 2006 PMI - Prefeitura Municipal de Itajaí *
13 13 * ctima@itajai.sc.gov.br *
14 14 * *
15   - * Este programa é software livre, você pode redistribuí-lo e/ou *
16   - * modificá-lo sob os termos da Licença Pública Geral GNU, conforme *
17   - * publicada pela Free Software Foundation, tanto a versão 2 da *
18   - * Licença como (a seu critério) qualquer versão mais nova. *
  15 + * Este programa é software livre, você pode redistribuí-lo e/ou *
  16 + * modificá-lo sob os termos da Licença Pública Geral GNU, conforme *
  17 + * publicada pela Free Software Foundation, tanto a versão 2 da *
  18 + * Licença como (a seu critério) qualquer versão mais nova. *
19 19 * *
20   - * Este programa é distribuído na expectativa de ser útil, mas SEM *
21   - * QUALQUER GARANTIA. Sem mesmo a garantia implícita de COMERCIALI- *
22   - * ZAÇÃO ou de ADEQUAÇÃO A QUALQUER PROPÓSITO EM PARTICULAR. Con- *
23   - * sulte a Licença Pública Geral GNU para obter mais detalhes. *
  20 + * Este programa é distribuído na expectativa de ser útil, mas SEM *
  21 + * QUALQUER GARANTIA. Sem mesmo a garantia implícita de COMERCIALI- *
  22 + * ZAÇÃO ou de ADEQUAÇÃO A QUALQUER PROPÓSITO EM PARTICULAR. Con- *
  23 + * sulte a Licença Pública Geral GNU para obter mais detalhes. *
24 24 * *
25   - * Você deve ter recebido uma cópia da Licença Pública Geral GNU *
26   - * junto com este programa. Se não, escreva para a Free Software *
  25 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU *
  26 + * junto com este programa. Se não, escreva para a Free Software *
27 27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA *
28 28 * 02111-1307, USA. *
29 29 * *
... ... @@ -160,10 +160,15 @@ class indice extends clsCadastro
160 160 $this->preco = str_replace(".","",$this->preco);
161 161 $this->preco = str_replace(",",".",$this->preco);
162 162  
163   - $this->data_aquisicao = dataToBanco($this->data_aquisicao);
164   -
165 163 for ($i = 0; $i < $this->qtd_livros; $i++)
166 164 {
  165 + $obj_temp = new clsPmieducarExemplar();
  166 + $tombo_valido = $obj_temp->retorna_tombo_valido($this->ref_cod_biblioteca,null,$this->tombo);
  167 + if (!$tombo_valido){
  168 + $this->mensagem = "Esse Tombo j&aacute; est&aacute; registrado";
  169 + return false;
  170 + }
  171 + $this->data_aquisicao = dataToBanco($this->data_aquisicao);
167 172 $obj = new clsPmieducarExemplar($this->cod_exemplar, $this->ref_cod_fonte, $this->ref_cod_motivo_baixa, $this->ref_cod_acervo, $this->ref_cod_situacao, $this->pessoa_logada, $this->pessoa_logada, $this->permite_emprestimo, $this->preco, $this->data_cadastro, $this->data_exclusao, $this->ativo, $this->data_aquisicao, $this->getTombo());
168 173 $cadastrou = $obj->cadastra();
169 174 if (!$cadastrou)
... ... @@ -193,7 +198,13 @@ class indice extends clsCadastro
193 198 $this->preco = str_replace(".","",$this->preco);
194 199 $this->preco = str_replace(",",".",$this->preco);
195 200  
196   - $this->data_aquisicao = dataToBanco($this->data_aquisicao);
  201 + $obj_temp = new clsPmieducarExemplar();
  202 + $tombo_valido = $obj_temp->retorna_tombo_valido($this->ref_cod_biblioteca,$this->cod_exemplar,$this->tombo);
  203 + if (!$tombo_valido){
  204 + $this->mensagem = "Esse Tombo j&aacute; est&aacute; registrado";
  205 + return false;
  206 + }
  207 + $this->data_aquisicao = dataToBanco($this->data_aquisicao);
197 208  
198 209 $obj = new clsPmieducarExemplar($this->cod_exemplar, $this->ref_cod_fonte, $this->ref_cod_motivo_baixa, $this->ref_cod_acervo, $this->ref_cod_situacao, $this->pessoa_logada, $this->pessoa_logada, $this->permite_emprestimo, $this->preco, $this->data_cadastro, $this->data_exclusao, $this->ativo, $this->data_aquisicao, $this->getTombo());
199 210 $editou = $obj->edita();
... ... @@ -241,7 +252,7 @@ class indice extends clsCadastro
241 252 $tombo = $exemplar->retorna_tombo_maximo($this->ref_cod_biblioteca, $this->cod_exemplar) + 1;
242 253 }
243 254 else {
244   - // após obter tombo reseta para na proxima chamada de getTombo buscar o proximo no banco
  255 + // após obter tombo reseta para na proxima chamada de getTombo buscar o proximo no banco
245 256 $tombo = $this->tombo;
246 257 $this->tombo = null;
247 258 }
... ...
ieducar/intranet/include/pmieducar/clsPmieducarExemplar.inc.php
1 1 <?php
2 2 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3 3 * *
4   -* @author Prefeitura Municipal de Itajaí *
  4 +* @author Prefeitura Municipal de Itajaí *
5 5 * @updated 29/03/2007 *
6   -* Pacote: i-PLB Software Público Livre e Brasileiro *
  6 +* Pacote: i-PLB Software Público Livre e Brasileiro *
7 7 * *
8   -* Copyright (C) 2006 PMI - Prefeitura Municipal de Itajaí *
  8 +* Copyright (C) 2006 PMI - Prefeitura Municipal de Itajaí *
9 9 * ctima@itajai.sc.gov.br *
10 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. *
  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 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. *
  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 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 *
  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 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA *
24 24 * 02111-1307, USA. *
25 25 * *
26 26 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
27 27 /**
28   -* @author Prefeitura Municipal de Itaja�
  28 +* @author Prefeitura Municipal de Itaja�
29 29 *
30 30 * Criado em 17/07/2006 09:18 pelo gerador automatico de classes
31 31 */
... ... @@ -503,6 +503,32 @@ class clsPmieducarExemplar
503 503 }
504 504 return false;
505 505 }
  506 + /**
  507 + * Verifica se o tombo a ser cadastrado j� n�o foi cadastrado
  508 + *
  509 + * @return boolean
  510 + */
  511 + function retorna_tombo_valido($bibliotecaId, $exceptExemplarId = null, $tombo=null) {
  512 + if (empty($bibliotecaId))
  513 + throw new Exception("Deve ser enviado um argumento '\$bibliotecaId' ao método 'retorna_tombo_maximo'");
  514 + if (empty($tombo))
  515 + return true;
  516 + // Sem essa regra ao editar e salvar com o mesmo tombo retornaria falso
  517 + if (! empty($exceptExemplarId))
  518 + $exceptExemplar = " and exemplar.cod_exemplar != $exceptExemplarId";
  519 + else
  520 + $exceptExemplar = '';
  521 +
  522 + $sql = "SELECT tombo FROM pmieducar.exemplar, pmieducar.acervo WHERE exemplar.ativo = 1 and exemplar.ref_cod_acervo = acervo.cod_acervo and tombo = $tombo and acervo.ref_cod_biblioteca = $bibliotecaId $exceptExemplar";
  523 +
  524 + $db = new clsBanco();
  525 + $consulta = $db->CampoUnico($sql);
  526 + if ($consulta==$tombo){
  527 + return false;
  528 + } else {
  529 + return true;
  530 + }
  531 + }
506 532  
507 533 /**
508 534 * Retorna uma lista filtrados de acordo com os parametros
... ... @@ -690,7 +716,7 @@ class clsPmieducarExemplar
690 716  
691 717 function retorna_tombo_maximo($bibliotecaId, $exceptExemplarId = null) {
692 718 if (empty($bibliotecaId))
693   - throw new Exception("Deve ser enviado um argumento '\$bibliotecaId' ao método 'retorna_tombo_maximo'");
  719 + throw new Exception("Deve ser enviado um argumento '\$bibliotecaId' ao método 'retorna_tombo_maximo'");
694 720  
695 721 // sem esta regra ao editar o ultimo exemplar sem informar o tombo, seria pego o proprio tombo.
696 722 if (! empty($exceptExemplarId))
... ...