Two suggestions. First, perhaps the users branch could be used, like from C4::Branch::mybranch() Then you wouldn't need to add the branch parameter to the sub
Second, perhaps instead of splitting the barcode string you should do something like s/(.*)0+(.*)/$1$2/ That should strip out all the zeros. On Wed, Nov 17, 2010 at 11:31 PM, Koustubha Kale <kmk...@anantcorp.com>wrote: ... > diff --git a/C4/Circulation.pm b/C4/Circulation.pm > index 10c3c11..08778ca 100644 > --- a/C4/Circulation.pm > +++ b/C4/Circulation.pm > @@ -136,7 +136,7 @@ System Pref options. > # FIXME -- these plugins should be moved out of Circulation.pm > # > sub barcodedecode { > - my ($barcode, $filter) = @_; > + my ($barcode, $filter, $branch) = @_; > $filter = C4::Context->preference('itemBarcodeInputFilter') unless > $filter; > $filter or return $barcode; # ensure filter is defined, else return > untouched barcode > if ($filter eq 'whitespace') { > @@ -155,6 +155,31 @@ sub barcodedecode { > # FIXME: $barcode could be "T1", causing warning: substr outside of > string > # Why drop the nonzero digit after the T? > # Why pass non-digits (or empty string) to "T%07d"? > + } elsif ($filter eq 'libsuite8') { > + # FIXME: This NEEDS major code cleanup. All help is much > appreciated > + use Scalar::Util qw(looks_like_number); > + my $barcode1=$barcode; > + my $branchcode=$branch."-"; > + if($barcode1 =~ m/^$branchcode/){ > + } > + else { > + my @chars; > + my @nums; > + my @m1=split(/ */, $barcode); > + foreach (@m1){ > + looks_like_number ($_) ? push(@nums,$_) : > push(@chars,$_); > + } > + my @n1; > + foreach(@nums){ > + if($_ > 0){ > + push(@n1,$_); > + } > + } > + my ($chars) = join('',@chars); > + my ($n1) = join('',@n1); > + $barcode = "$branchcode" . $chars . "-" . $n1; > + } > + > } > return $barcode; # return barcode, modified or not > } > diff --git a/circ/circulation.pl b/circ/circulation.pl > index 7c4a0dc..b358a84 100755 > --- a/circ/circulation.pl > +++ b/circ/circulation.pl > @@ -115,8 +115,8 @@ if (C4::Context->preference("UseTablesortForCirc")) { > > my $barcode = $query->param('barcode') || ''; > $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace > - > -$barcode = barcodedecode($barcode) if( $barcode && > C4::Context->preference('itemBarcodeInputFilter')); > +my $filter = C4::Context->preference('itemBarcodeInputFilter') || ''; > +$barcode = barcodedecode($barcode,$filter,$branch) if( $barcode && > C4::Context->preference('itemBarcodeInputFilter')); > my $stickyduedate = $query->param('stickyduedate') || > $session->param('stickyduedate'); > my $duedatespec = $query->param('duedatespec') || > $session->param('stickyduedate'); > my $issueconfirmed = $query->param('issueconfirmed'); > ...
_______________________________________________ Koha-patches mailing list Koha-patches@lists.koha-community.org http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-patches website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/