Adding barcode_decode syspref

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
This commit is contained in:
Ryan Higgins 2008-02-20 06:55:09 +13:00 committed by Joshua Ferraro
parent 5a900838c0
commit 1cd6263dde
5 changed files with 29 additions and 25 deletions

View file

@ -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

View file

@ -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 );

View file

@ -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
#

View file

@ -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');

View file

@ -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');