From e52469c0b7ca1720a1bfb6d4ef38d0cae19a9e71 Mon Sep 17 00:00:00 2001 From: Ian Walls Date: Mon, 17 Jan 2011 16:48:56 -0500 Subject: [PATCH] Bug 3577: autobarcode value_builder doesn't respect variable length branchcodes Content-Type: text/plain; charset="utf-8" This patch changes the hardcoded substring values in the select statement to work from the right instead of the left; that is, from position -4 (which should ALWAYS be the start of the 4-digit increment portion) rather than position 7 (which could easily include branchcode or date-only information) --- cataloguing/value_builder/barcode.pl | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/cataloguing/value_builder/barcode.pl b/cataloguing/value_builder/barcode.pl index 3c6ef74..c247737 100755 --- a/cataloguing/value_builder/barcode.pl +++ b/cataloguing/value_builder/barcode.pl @@ -99,7 +99,7 @@ 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,4) AS signed)) FROM items WHERE barcode REGEXP ?"; my $sth = $dbh->prepare($query); $sth->execute("^[a-zA-Z]{1,}$year"); while (my ($count)= $sth->fetchrow_array) { -- 1.5.6.5