Commit 36f96796d21c751f9a5fb0cad242378194aa329d
1 parent
b748dd10
Exists in
master
Ajustado cadastro de exemplareso:
* Não permitir que um tombo seja cadastrado com dois nomes; portabilis/ieducar#12
Showing
2 changed files
with
69 additions
and
32 deletions
Show diff stats
ieducar/intranet/educar_exemplar_cad.php
@@ -5,25 +5,25 @@ | @@ -5,25 +5,25 @@ | ||
5 | 5 | ||
6 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | 6 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
7 | * * | 7 | * * |
8 | - * @author Prefeitura Municipal de Itajaí * | 8 | + * @author Prefeitura Municipal de Itajaà * |
9 | * @updated 29/03/2007 * | 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 | * ctima@itajai.sc.gov.br * | 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 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * | 27 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * |
28 | * 02111-1307, USA. * | 28 | * 02111-1307, USA. * |
29 | * * | 29 | * * |
@@ -160,10 +160,15 @@ class indice extends clsCadastro | @@ -160,10 +160,15 @@ class indice extends clsCadastro | ||
160 | $this->preco = str_replace(".","",$this->preco); | 160 | $this->preco = str_replace(".","",$this->preco); |
161 | $this->preco = str_replace(",",".",$this->preco); | 161 | $this->preco = str_replace(",",".",$this->preco); |
162 | 162 | ||
163 | - $this->data_aquisicao = dataToBanco($this->data_aquisicao); | ||
164 | - | ||
165 | for ($i = 0; $i < $this->qtd_livros; $i++) | 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á está registrado"; | ||
169 | + return false; | ||
170 | + } | ||
171 | + $this->data_aquisicao = dataToBanco($this->data_aquisicao); | ||
167 | $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()); | 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 | $cadastrou = $obj->cadastra(); | 173 | $cadastrou = $obj->cadastra(); |
169 | if (!$cadastrou) | 174 | if (!$cadastrou) |
@@ -193,7 +198,13 @@ class indice extends clsCadastro | @@ -193,7 +198,13 @@ class indice extends clsCadastro | ||
193 | $this->preco = str_replace(".","",$this->preco); | 198 | $this->preco = str_replace(".","",$this->preco); |
194 | $this->preco = str_replace(",",".",$this->preco); | 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á está registrado"; | ||
205 | + return false; | ||
206 | + } | ||
207 | + $this->data_aquisicao = dataToBanco($this->data_aquisicao); | ||
197 | 208 | ||
198 | $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()); | 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 | $editou = $obj->edita(); | 210 | $editou = $obj->edita(); |
@@ -241,7 +252,7 @@ class indice extends clsCadastro | @@ -241,7 +252,7 @@ class indice extends clsCadastro | ||
241 | $tombo = $exemplar->retorna_tombo_maximo($this->ref_cod_biblioteca, $this->cod_exemplar) + 1; | 252 | $tombo = $exemplar->retorna_tombo_maximo($this->ref_cod_biblioteca, $this->cod_exemplar) + 1; |
242 | } | 253 | } |
243 | else { | 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 | $tombo = $this->tombo; | 256 | $tombo = $this->tombo; |
246 | $this->tombo = null; | 257 | $this->tombo = null; |
247 | } | 258 | } |
ieducar/intranet/include/pmieducar/clsPmieducarExemplar.inc.php
1 | <?php | 1 | <?php |
2 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | 2 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
3 | * * | 3 | * * |
4 | -* @author Prefeitura Municipal de Itajaí * | 4 | +* @author Prefeitura Municipal de Itajaà * |
5 | * @updated 29/03/2007 * | 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 | * ctima@itajai.sc.gov.br * | 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 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * | 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * |
24 | * 02111-1307, USA. * | 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 | * Criado em 17/07/2006 09:18 pelo gerador automatico de classes | 30 | * Criado em 17/07/2006 09:18 pelo gerador automatico de classes |
31 | */ | 31 | */ |
@@ -503,6 +503,32 @@ class clsPmieducarExemplar | @@ -503,6 +503,32 @@ class clsPmieducarExemplar | ||
503 | } | 503 | } |
504 | return false; | 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 | * Retorna uma lista filtrados de acordo com os parametros | 534 | * Retorna uma lista filtrados de acordo com os parametros |
@@ -690,7 +716,7 @@ class clsPmieducarExemplar | @@ -690,7 +716,7 @@ class clsPmieducarExemplar | ||
690 | 716 | ||
691 | function retorna_tombo_maximo($bibliotecaId, $exceptExemplarId = null) { | 717 | function retorna_tombo_maximo($bibliotecaId, $exceptExemplarId = null) { |
692 | if (empty($bibliotecaId)) | 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 | // sem esta regra ao editar o ultimo exemplar sem informar o tombo, seria pego o proprio tombo. | 721 | // sem esta regra ao editar o ultimo exemplar sem informar o tombo, seria pego o proprio tombo. |
696 | if (! empty($exceptExemplarId)) | 722 | if (! empty($exceptExemplarId)) |