diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 613163bfbd..ecd5e18d01 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -53,7 +53,7 @@ BEGIN { # FIXME subs that should probably be elsewhere push @EXPORT, qw( &FixOverduesOnReturn - &cuecatbarcodedecode + &barcodedecode ); # subs to deal with issuing a book @@ -108,27 +108,35 @@ Also deals with stocktaking. =over 4 -=item Decodes a segment of a string emitted by a CueCat barcode scanner and -returns it. +=item Generic filter function for barcode string. =back =cut -# FIXME - At least, I'm pretty sure this is for decoding CueCat stuff. # FIXME From Paul : i don't understand what this sub does & why it has to be called on every circ. Speak of this with chris maybe ? +# FIXME -- the &decode fcn below should be wrapped into this one. -sub cuecatbarcodedecode { +sub barcodedecode { my ($barcode) = @_; - chomp($barcode); - my @fields = split( /\./, $barcode ); - my @results = map( decode($_), @fields[ 1 .. $#fields ] ); - if ( $#results == 2 ) { - return $results[2]; - } - else { - return $barcode; - } + my $filter = C4::Context->preference('itemBarcodeInputFilter'); + if($filter eq 'whitespace') { + $barcode =~ s/\s//g; + return $barcode; + } elsif($filter eq 'cuecat') { + chomp($barcode); + my @fields = split( /\./, $barcode ); + my @results = map( decode($_), @fields[ 1 .. $#fields ] ); + if ( $#results == 2 ) { + return $results[2]; + } + else { + return $barcode; + } + } elsif($filter eq 'T-prefix') { + my $num = ( $barcode =~ /^[Tt] /) ? substr($barcode,2) + 0 : $barcode; + return sprintf( "T%07d",$num); + } } =head2 decode diff --git a/circ/circulation.pl b/circ/circulation.pl index e36f911069..943656aa5e 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -120,9 +120,7 @@ $printer = C4::Context->userenv->{'branchprinter'}; my $barcode = $query->param('barcode') || ''; -# strip whitespace -$barcode =~ s/\s*//g; - +$barcode = barcodedecode($barcode) if(C4::Context->preference('itemBarcodeInputFilter')); my $year = $query->param('year'); my $month = $query->param('month'); my $day = $query->param('day'); @@ -262,7 +260,6 @@ if ($borrowernumber) { # if ($barcode) { - # $barcode = cuecatbarcodedecode($barcode); # always check for blockers on issuing my ( $error, $question ) = CanBookBeIssued( $borrower, $barcode, $datedue , $inprocess ); diff --git a/circ/returns.pl b/circ/returns.pl index c97bd60ba0..bb8ab0be03 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -90,8 +90,8 @@ foreach ( $query->param ) { my $borrowernumber = $query->param("bn-$counter"); $counter++; - # decode cuecat - $barcode = cuecatbarcodedecode($barcode); + # decode barcode + $barcode = barcodedecode($barcode) if(C4::Context->preference('itemBarcodeInputFilter')); ###################### #Are these lines still useful ? @@ -165,7 +165,7 @@ my $messages; my $issueinformation; my $barcode = $query->param('barcode'); # strip whitespace -$barcode =~ s/\s*//g; +# $barcode =~ s/\s*//g; - use barcodedecode for this; whitespace is not invalid. my $exemptfine = $query->param('exemptfine'); my $dotransfer = $query->param('dotransfer'); @@ -178,8 +178,7 @@ if ($dotransfer){ # actually return book and prepare item table..... if ($barcode) { - # decode cuecat - $barcode = cuecatbarcodedecode($barcode); + $barcode = barcodedecode($barcode) if(C4::Context->preference('itemBarcodeInputFilter')); # # save the return # diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql b/installer/data/mysql/en/mandatory/sysprefs.sql index 1185a385ca..0ad3d60872 100644 --- a/installer/data/mysql/en/mandatory/sysprefs.sql +++ b/installer/data/mysql/en/mandatory/sysprefs.sql @@ -149,7 +149,7 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('libraryAddress','','The address to use for printing receipts, overdues, etc. if different than physical address',NULL,'free'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('finesMode','test','Choose the fines mode, \'off\', \'test\' (emails admin report) or \'production\' (accrue overdue fines). Requires accruefines cronjob.','off|test|production','Choice'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('globalDueDate','','If set, allows a global static due date for all checkouts',NULL,'free'); -INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('itemBarcodeInputFilter','','If set, allows specification of a item barcode input filter','cuecat','Choice'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('itemBarcodeInputFilter','','If set, allows specification of a item barcode input filter','whitespace|T-prefix|cuecat','Choice'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('singleBranchMode',0,'Operate in Single-branch mode, hide branch selection in the OPAC',NULL,'YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('URLLinkText','','Text to display as the link anchor in the OPAC',NULL,'free'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('noOPACUserLogin',0,'If ON, disables the OPAC User Login',NULL,'YesNo'); diff --git a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql b/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql index 1af9ad8843..32c84b2d62 100644 --- a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql +++ b/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql @@ -154,7 +154,7 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('libraryAddress','','L''adresse pour l''impression des reçus, des amendes... si elle est différente de l''adresse physique de la bibliothèque',NULL,'free'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('finesMode','test','Choisissez un mode pour le calcul des amendes : Test ou Production.','test|production','Choice'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('globalDueDate','','Si défini, autorise une date de retour statique pour tous les prêts',NULL,'free'); -INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('itemBarcodeInputFilter','','If set, allows specification of a item barcode input filter','cuecat','Choice'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('itemBarcodeInputFilter','','If set, allows specification of a item barcode input filter','whitespace|T-prefix|cuecat','Choice'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('singleBranchMode',0,'Operate in Single-branch mode, hide branch selection in the OPAC',NULL,'YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('URLLinkText','','Text to display as the link anchor in the OPAC',NULL,'free'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('noOPACUserLogin',0,'If ON, disables the OPAC User Login',NULL,'YesNo');