Bug 5213 - Suffix number sequence not resetting properly in hmyymmincr barcode autogen pattern
Two things are happening. First, the SELECT does not account for a branchcode greater than 2 chars. This is fixed by just selecting the final four digits representing the incremental suffix from the barcode field. Second, the incremental suffix (4 digits) is not rolling back over to zero when reaching 9999. This pattern probably needs help. It should allow for cataloging of 10000 items per month as is. I would not recommend doing barcode numbering this way, but need to support it since it is in use in at least one library. This patch also impliments strict and warnings per Bug 2505 Signed-off-by: Stéphane Delaune <stephane.delaune@biblibre.com> Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
This commit is contained in:
parent
d58092dd96
commit
8ca5d5ff85
1 changed files with 8 additions and 6 deletions
|
@ -1,8 +1,6 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# $Id: barcode.pl,v 1.1.2.2 2006/09/20 02:24:42 kados Exp $
|
||||
|
||||
# Copyright 2000-2002 Katipo Communications
|
||||
# Parts copyright 2008-2010 Foundations Bible College
|
||||
#
|
||||
# This file is part of Koha.
|
||||
#
|
||||
|
@ -19,10 +17,13 @@
|
|||
# with Koha; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
#use strict;
|
||||
#use warnings; FIXME - Bug 2505
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine'; # otherwise loading up multiple plugins fills the log with subroutine redefine warnings
|
||||
|
||||
use C4::Context;
|
||||
require C4::Dates;
|
||||
|
||||
my $DEBUG = 0;
|
||||
|
||||
=head1
|
||||
|
@ -99,11 +100,12 @@ sub plugin_javascript {
|
|||
}
|
||||
elsif ($autoBarcodeType eq 'hbyymmincr') { # Generates a barcode where hb = home branch Code, yymm = year/month catalogued, incr = incremental number, reset yearly -fbcit
|
||||
$year = substr($year, -2);
|
||||
$query = "SELECT MAX(CAST(SUBSTRING(barcode,7,4) AS signed)) FROM items WHERE barcode REGEXP ?";
|
||||
$query = "SELECT MAX(CAST(SUBSTRING(barcode,-4) AS signed)) AS number FROM items WHERE barcode REGEXP ?";
|
||||
my $sth = $dbh->prepare($query);
|
||||
$sth->execute("^[a-zA-Z]{1,}$year");
|
||||
while (my ($count)= $sth->fetchrow_array) {
|
||||
$nextnum = $count if $count;
|
||||
$nextnum = 0 if $nextnum == 9999; # this sequence only allows for cataloging 10000 books per month
|
||||
warn "Existing incremental number = $nextnum" if $DEBUG;
|
||||
}
|
||||
$nextnum++;
|
||||
|
|
Loading…
Reference in a new issue