From 36f96796d21c751f9a5fb0cad242378194aa329d Mon Sep 17 00:00:00 2001 From: gabrielms Date: Thu, 13 Nov 2014 17:02:27 -0200 Subject: [PATCH] Ajustado cadastro de exemplareso: * Não permitir que um tombo seja cadastrado com dois nomes; portabilis/ieducar#12 --- ieducar/intranet/educar_exemplar_cad.php | 45 ++++++++++++++++++++++++++++----------------- ieducar/intranet/include/pmieducar/clsPmieducarExemplar.inc.php | 56 +++++++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 69 insertions(+), 32 deletions(-) diff --git a/ieducar/intranet/educar_exemplar_cad.php b/ieducar/intranet/educar_exemplar_cad.php index cf6083f..4a7c8c8 100644 --- a/ieducar/intranet/educar_exemplar_cad.php +++ b/ieducar/intranet/educar_exemplar_cad.php @@ -5,25 +5,25 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * @author Prefeitura Municipal de Itajaí * + * @author Prefeitura Municipal de Itajaí * * @updated 29/03/2007 * - * Pacote: i-PLB Software Público Livre e Brasileiro * + * Pacote: i-PLB Software Público Livre e Brasileiro * * * - * Copyright (C) 2006 PMI - Prefeitura Municipal de Itajaí * + * Copyright (C) 2006 PMI - Prefeitura Municipal de Itajaí * * ctima@itajai.sc.gov.br * * * - * Este programa é software livre, você pode redistribuí-lo e/ou * - * modificá-lo sob os termos da Licença Pública Geral GNU, conforme * - * publicada pela Free Software Foundation, tanto a versão 2 da * - * Licença como (a seu critério) qualquer versão mais nova. * + * Este programa é software livre, você pode redistribuí-lo e/ou * + * modificá-lo sob os termos da Licença Pública Geral GNU, conforme * + * publicada pela Free Software Foundation, tanto a versão 2 da * + * Licença como (a seu critério) qualquer versão mais nova. * * * - * Este programa é distribuído na expectativa de ser útil, mas SEM * - * QUALQUER GARANTIA. Sem mesmo a garantia implícita de COMERCIALI- * - * ZAÇÃO ou de ADEQUAÇÃO A QUALQUER PROPÓSITO EM PARTICULAR. Con- * - * sulte a Licença Pública Geral GNU para obter mais detalhes. * + * Este programa é distribuído na expectativa de ser útil, mas SEM * + * QUALQUER GARANTIA. Sem mesmo a garantia implícita de COMERCIALI- * + * ZAÇÃO ou de ADEQUAÇÃO A QUALQUER PROPÓSITO EM PARTICULAR. Con- * + * sulte a Licença Pública Geral GNU para obter mais detalhes. * * * - * Você deve ter recebido uma cópia da Licença Pública Geral GNU * - * junto com este programa. Se não, escreva para a Free Software * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU * + * junto com este programa. Se não, escreva para a Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * * 02111-1307, USA. * * * @@ -160,10 +160,15 @@ class indice extends clsCadastro $this->preco = str_replace(".","",$this->preco); $this->preco = str_replace(",",".",$this->preco); - $this->data_aquisicao = dataToBanco($this->data_aquisicao); - for ($i = 0; $i < $this->qtd_livros; $i++) { + $obj_temp = new clsPmieducarExemplar(); + $tombo_valido = $obj_temp->retorna_tombo_valido($this->ref_cod_biblioteca,null,$this->tombo); + if (!$tombo_valido){ + $this->mensagem = "Esse Tombo já está registrado"; + return false; + } + $this->data_aquisicao = dataToBanco($this->data_aquisicao); $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()); $cadastrou = $obj->cadastra(); if (!$cadastrou) @@ -193,7 +198,13 @@ class indice extends clsCadastro $this->preco = str_replace(".","",$this->preco); $this->preco = str_replace(",",".",$this->preco); - $this->data_aquisicao = dataToBanco($this->data_aquisicao); + $obj_temp = new clsPmieducarExemplar(); + $tombo_valido = $obj_temp->retorna_tombo_valido($this->ref_cod_biblioteca,$this->cod_exemplar,$this->tombo); + if (!$tombo_valido){ + $this->mensagem = "Esse Tombo já está registrado"; + return false; + } + $this->data_aquisicao = dataToBanco($this->data_aquisicao); $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()); $editou = $obj->edita(); @@ -241,7 +252,7 @@ class indice extends clsCadastro $tombo = $exemplar->retorna_tombo_maximo($this->ref_cod_biblioteca, $this->cod_exemplar) + 1; } else { - // após obter tombo reseta para na proxima chamada de getTombo buscar o proximo no banco + // após obter tombo reseta para na proxima chamada de getTombo buscar o proximo no banco $tombo = $this->tombo; $this->tombo = null; } diff --git a/ieducar/intranet/include/pmieducar/clsPmieducarExemplar.inc.php b/ieducar/intranet/include/pmieducar/clsPmieducarExemplar.inc.php index 120fa75..f10b1f6 100644 --- a/ieducar/intranet/include/pmieducar/clsPmieducarExemplar.inc.php +++ b/ieducar/intranet/include/pmieducar/clsPmieducarExemplar.inc.php @@ -1,31 +1,31 @@ CampoUnico($sql); + if ($consulta==$tombo){ + return false; + } else { + return true; + } + } /** * Retorna uma lista filtrados de acordo com os parametros @@ -690,7 +716,7 @@ class clsPmieducarExemplar function retorna_tombo_maximo($bibliotecaId, $exceptExemplarId = null) { if (empty($bibliotecaId)) - throw new Exception("Deve ser enviado um argumento '\$bibliotecaId' ao método 'retorna_tombo_maximo'"); + throw new Exception("Deve ser enviado um argumento '\$bibliotecaId' ao método 'retorna_tombo_maximo'"); // sem esta regra ao editar o ultimo exemplar sem informar o tombo, seria pego o proprio tombo. if (! empty($exceptExemplarId)) -- libgit2 0.21.2