adding checkdigit parameter that choose how to check the members cardnumber.
authortipaul <tipaul>
Tue, 18 Mar 2003 10:58:19 +0000 (10:58 +0000)
committertipaul <tipaul>
Tue, 18 Mar 2003 10:58:19 +0000 (10:58 +0000)
At the moment :
* none = no checking
* katipo = checked as before

C4/Input.pm
updater/updatedatabase

index 49955f3..b058d9a 100644 (file)
@@ -20,6 +20,7 @@ package C4::Input; #assumes C4/Input
 
 use strict;
 require Exporter;
+use C4::Context;
 
 use vars qw($VERSION @ISA @EXPORT);
 
@@ -78,29 +79,31 @@ C<$env> is ignored.
 =cut
 #'
 sub checkdigit {
-  my ($env,$infl) =  @_;
-  $infl = uc $infl;
-  my @weightings = (8,4,6,3,5,2,1);
-  my $sum;
-  my $i = 1;
-  my $valid = 0;
-  #  print $infl."<br>";
-
-  foreach $i (1..7) {
-    my $temp1 = $weightings[$i-1];
-    my $temp2 = substr($infl,$i,1);
-    $sum += $temp1 * $temp2;
-#    print "$sum $temp1 $temp2<br>";
-  }
-  my $rem = ($sum%11);
-  if ($rem == 10) {
-    $rem = "X";
-  }
-  #print $rem."<br>";
-  if ($rem eq substr($infl,8,1)) {
-    $valid = 1;
-  }
-  return $valid;
+       if (C4::Context->preference("checkdigit") eq "none") {
+               warn "XXcheckdigit : ".C4::Context->preference("checkdigit");
+               return 1;
+       } else {
+               my ($env,$infl) =  @_;
+               $infl = uc $infl;
+               my @weightings = (8,4,6,3,5,2,1);
+               my $sum;
+               my $i = 1;
+               my $valid = 0;
+
+               foreach $i (1..7) {
+                       my $temp1 = $weightings[$i-1];
+                       my $temp2 = substr($infl,$i,1);
+                       $sum += $temp1 * $temp2;
+               }
+               my $rem = ($sum%11);
+               if ($rem == 10) {
+               $rem = "X";
+               }
+               if ($rem eq substr($infl,8,1)) {
+                       $valid = 1;
+               }
+               return $valid;
+       }
 } # sub checkdigit
 
 =item checkvalidisbn
index 41a6c56..3bca095 100755 (executable)
@@ -278,6 +278,7 @@ my %tabledata=(
        { uniquefieldrequired => 'variable', variable => 'timeout', value => '12000000', explanation => 'login timeout' },
        { uniquefieldrequired => 'variable', variable => 'marc', value => 'ON', explanation => 'MARC support (ON or OFF)' },
        { uniquefieldrequired => 'variable', variable => 'marcflavour', value => 'MARC21', explanation => 'your MARC flavor (MARC21 or UNIMARC) used for character encoding' },
+       { uniquefieldrequired => 'variable', variable => 'checkdigit', value => 'katipo', explanation => 'none= no check on member cardnumber. katipo= katipo check' },
     ],
 
 );
@@ -543,6 +544,12 @@ $sth->finish;
 exit;
 
 # $Log$
+# Revision 1.38  2003/03/18 10:58:19  tipaul
+# adding checkdigit parameter that choose how to check the members cardnumber.
+# At the moment :
+# * none = no checking
+# * katipo = checked as before
+#
 # Revision 1.37  2003/01/30 01:47:48  acli
 # Corrected syntax error reported by Benedict
 #