From c2a70e181148a5339994436278f9eb6554950b70 Mon Sep 17 00:00:00 2001 From: rangi Date: Thu, 22 Mar 2001 22:20:29 +0000 Subject: [PATCH] Changes made by Glen to allow the circulation module to work with a ASCII-wand, or CueCat (weird encoded) input equally well. Do not bother installing the CueCat driver or any other software - it's not needed. --- circ/circulation.pl | 75 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 70 insertions(+), 5 deletions(-) diff --git a/circ/circulation.pl b/circ/circulation.pl index 89eab0b7c5..45ae183ab1 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -13,7 +13,7 @@ my $circbackgroundcolor='#ffffcc'; my $circbackgroundcolor='white'; my $linecolor1='#bbbbbb'; my $linecolor2='#dddddd'; -my $backgroundimage="/images/background-mem.gif"; +my $backgroundimage="/koha/images/background-mem.gif"; my $query=new CGI; my $branches=getbranches(\%env); my $printers=getprinters(\%env); @@ -83,13 +83,13 @@ print << "EOF"; $branchname - + Branch/Printer - + $printername @@ -166,6 +166,34 @@ EOF } +sub decode { + ($encoded) = @_; + $seq = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-'; + @s = map { index($seq,$_); } split(//,$encoded); + $l = ($#s+1) % 4; + if ($l) + { + if ($l == 1) + { + print "Error!"; + return; + } + $l = 4-$l; + $#s += $l; + } + $r = ''; + while ($#s >= 0) + { + $n = (($s[0] << 6 | $s[1]) << 6 | $s[2]) << 6 | $s[3]; + $r .=chr(($n >> 16) ^ 67) . + chr(($n >> 8 & 255) ^ 67) . + chr(($n & 255) ^ 67); + @s = @s[4..$#s]; + } + $r = substr($r,0,length($r)-$l); + return $r; +} + sub returns { my %returneditems; print << "EOF"; @@ -176,6 +204,16 @@ EOF my $counter=$1; (next) if ($counter>20); my $barcode=$query->param("ri-$counter"); + # I'm not POSITIVE this decode belongs here - can't tell what causes it to run. + # decode cuecat + chomp($barcode); + @fields = split(/\./,$barcode); + @results = map(decode($_), @fields[1..$#fields]); + if ($#results == 2) + { + $barcode=$results[2]; + } + # end decode my $duedate=$query->param("dd-$counter"); my $borrowernumber=$query->param("bn-$counter"); $counter++; @@ -187,6 +225,15 @@ EOF $ritext.="\n"; } if (my $barcode=$query->param('barcode')) { + # decode cuecat + chomp($barcode); + @fields = split(/\./,$barcode); + @results = map(decode($_), @fields[1..$#fields]); + if ($#results == 2) + { + $barcode=$results[2]; + } + # end decode $ritext.="\n"; $returneditems{0}=$barcode; } @@ -203,6 +250,15 @@ EOF $ritext EOF if ((my $barcode=$query->param('barcode')) || (%returneditems)) { + # decode cuecat + chomp($barcode); + @fields = split(/\./,$barcode); + @results = map(decode($_), @fields[1..$#fields]); + if ($#results == 2) + { + $barcode=$results[2]; + } + # end decode my ($iteminformation, $borrower, $messages, $overduecharge) = returnbook(\%env, $barcode); (my $nosuchitem=1) unless ($iteminformation); @@ -340,11 +396,11 @@ EOF my $todaysdate = (1900+$datearr[5]).'-'.sprintf ("%0.2d", ($datearr[4]+1)).'-'.sprintf ("%0.2d", $datearr[3]); my $overduetext="$duedate"; ($overduetext="$duedate") if ($duedate lt $todaysdate); - ($duedate) || ($overduetext=""); + ($duedate) || ($overduetext=""); my $borrowernumber=$riborrowernumber{$_}; my ($borrower) = getpatroninformation(\%env,$borrowernumber,0); my ($iteminformation) = getiteminformation(\%env, 0, $barcode); - print "$overduetext{'biblionumber'}&type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$barcode$iteminformation->{'title'}$iteminformation->{'author'}$iteminformation->{'itemtype'}{'borrowernumber'} onClick=\"openWindow(this,'Member', 480, 640)\">$borrower->{'cardnumber'} $borrower->{'firstname'} $borrower->{'surname'}\n"; + print "$overduetext{'biblionumber'}&type=intra onClick=\"openWindow(this, 'Item', 480, 640)\">$barcode$iteminformation->{'title'}$iteminformation->{'author'}$iteminformation->{'itemtype'}{'borrowernumber'} onClick=\"openWindow(this,'Member', 480, 640)\">$borrower->{'cardnumber'} $borrower->{'firstname'} $borrower->{'surname'}\n"; } print "\n"; } else { @@ -398,6 +454,15 @@ EOF my $month=$query->param('month'); my $day=$query->param('day'); if (my $barcode=$query->param('barcode')) { + # decode cuecat + chomp($barcode); + @fields = split(/\./,$barcode); + @results = map(decode($_), @fields[1..$#fields]); + if ($#results == 2) + { + $barcode=$results[2]; + } + # end decode my $invalidduedate=0; $env{'datedue'}=''; if (($year eq 0) && ($month eq 0) && ($year eq 0)) { -- 2.39.5