View | Details | Raw Unified | Return to bug 20264
Collapse All | Expand All

(-)a/C4/Members.pm (-50 / +6 lines)
Lines 534-542 mode, to avoid database corruption. Link Here
534
534
535
=cut
535
=cut
536
536
537
use vars qw( @weightings );
538
my @weightings = ( 8, 4, 6, 3, 5, 2, 1 );
539
540
sub fixup_cardnumber {
537
sub fixup_cardnumber {
541
    my ($cardnumber) = @_;
538
    my ($cardnumber) = @_;
542
    my $autonumber_members = C4::Context->boolean_preference('autoMemberNum') || 0;
539
    my $autonumber_members = C4::Context->boolean_preference('autoMemberNum') || 0;
Lines 545-600 sub fixup_cardnumber { Link Here
545
    # automatically. Should be either "1" or something else.
542
    # automatically. Should be either "1" or something else.
546
    # Defaults to "0", which is interpreted as "no".
543
    # Defaults to "0", which is interpreted as "no".
547
544
548
    #     if ($cardnumber !~ /\S/ && $autonumber_members) {
549
    ($autonumber_members) or return $cardnumber;
545
    ($autonumber_members) or return $cardnumber;
550
    my $checkdigit = C4::Context->preference('checkdigit');
551
    my $dbh = C4::Context->dbh;
546
    my $dbh = C4::Context->dbh;
552
    if ( $checkdigit and $checkdigit eq 'katipo' ) {
553
554
        # if checkdigit is selected, calculate katipo-style cardnumber.
555
        # otherwise, just use the max()
556
        # purpose: generate checksum'd member numbers.
557
        # We'll assume we just got the max value of digits 2-8 of member #'s
558
        # from the database and our job is to increment that by one,
559
        # determine the 1st and 9th digits and return the full string.
560
        my $sth = $dbh->prepare(
561
            "select max(substring(borrowers.cardnumber,2,7)) as new_num from borrowers"
562
        );
563
        $sth->execute;
564
        my $data = $sth->fetchrow_hashref;
565
        $cardnumber = $data->{new_num};
566
        if ( !$cardnumber ) {    # If DB has no values,
567
            $cardnumber = 1000000;    # start at 1000000
568
        } else {
569
            $cardnumber += 1;
570
        }
571
572
        my $sum = 0;
573
        for ( my $i = 0 ; $i < 8 ; $i += 1 ) {
574
            # read weightings, left to right, 1 char at a time
575
            my $temp1 = $weightings[$i];
576
547
577
            # sequence left to right, 1 char at a time
548
    my $sth = $dbh->prepare(
578
            my $temp2 = substr( $cardnumber, $i, 1 );
549
        'SELECT MAX( CAST( cardnumber AS SIGNED ) ) FROM borrowers WHERE cardnumber REGEXP "^-?[0-9]+$"'
579
550
    );
580
            # mult each char 1-7 by its corresponding weighting
551
    $sth->execute;
581
            $sum += $temp1 * $temp2;
552
    my ($result) = $sth->fetchrow;
582
        }
553
    return $result + 1;
583
584
        my $rem = ( $sum % 11 );
585
        $rem = 'X' if $rem == 10;
586
587
        return "V$cardnumber$rem";
588
     } else {
589
590
        my $sth = $dbh->prepare(
591
            'SELECT MAX( CAST( cardnumber AS SIGNED ) ) FROM borrowers WHERE cardnumber REGEXP "^-?[0-9]+$"'
592
        );
593
        $sth->execute;
594
        my ($result) = $sth->fetchrow;
595
        return $result + 1;
596
    }
597
    return $cardnumber;     # just here as a fallback/reminder 
598
}
554
}
599
555
600
=head2 GetPendingIssues
556
=head2 GetPendingIssues
(-)a/C4/UsageStats.pm (-1 lines)
Lines 291-297 sub BuildReport { Link Here
291
        AutoEmailPrimaryAddress
291
        AutoEmailPrimaryAddress
292
        autoMemberNum
292
        autoMemberNum
293
        BorrowerRenewalPeriodBase
293
        BorrowerRenewalPeriodBase
294
        checkdigit
295
        EnableBorrowerFiles
294
        EnableBorrowerFiles
296
        EnhancedMessagingPreferences
295
        EnhancedMessagingPreferences
297
        ExtendedPatronAttributes
296
        ExtendedPatronAttributes
(-)a/installer/data/mysql/atomicupdate/bug_20264_remove_checkdigit.sql (+1 lines)
Line 0 Link Here
1
DELETE FROM systempreferences WHERE variable="checkdigit";
(-)a/installer/data/mysql/sysprefs.sql (-1 lines)
Lines 102-108 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
102
('casServerUrl','https://localhost:8443/cas','','URL of the cas server','Free'),
102
('casServerUrl','https://localhost:8443/cas','','URL of the cas server','Free'),
103
('CatalogModuleRelink','0',NULL,'If OFF the linker will never replace the authids that are set in the cataloging module.','YesNo'),
103
('CatalogModuleRelink','0',NULL,'If OFF the linker will never replace the authids that are set in the cataloging module.','YesNo'),
104
('CataloguingLog','1',NULL,'If ON, log edit/create/delete actions on bibliographic data. WARNING: this feature is very resource consuming.','YesNo'),
104
('CataloguingLog','1',NULL,'If ON, log edit/create/delete actions on bibliographic data. WARNING: this feature is very resource consuming.','YesNo'),
105
('checkdigit','none','none|katipo','If ON, enable checks on patron cardnumber: none or \"Katipo\" style checks','Choice'),
106
('CheckPrevCheckout','hardno','hardyes|softyes|softno|hardno','By default, for every item checked out, should we warn if the patron has borrowed that item in the past?','Choice'),
105
('CheckPrevCheckout','hardno','hardyes|softyes|softno|hardno','By default, for every item checked out, should we warn if the patron has borrowed that item in the past?','Choice'),
107
('CircAutocompl','1',NULL,'If ON, autocompletion is enabled for the Circulation input','YesNo'),
106
('CircAutocompl','1',NULL,'If ON, autocompletion is enabled for the Circulation input','YesNo'),
108
('CircAutoPrintQuickSlip','qslip',NULL,'Choose what should happen when an empty barcode field is submitted in circulation: Display a print quick slip window, Display a print slip window or Clear the screen.','Choice'),
107
('CircAutoPrintQuickSlip','qslip',NULL,'Choose what should happen when an empty barcode field is submitted in circulation: Display a print quick slip window, Display a print slip window or Clear the screen.','Choice'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (-6 lines)
Lines 55-66 Patrons: Link Here
55
               hardno: "Do not"
55
               hardno: "Do not"
56
         - " check borrower checkout history to see if the current item has been checked out before."
56
         - " check borrower checkout history to see if the current item has been checked out before."
57
     -
57
     -
58
         - pref: checkdigit
59
           choices:
60
               none: "Don't"
61
               katipo: Do
62
         - check and construct borrower card numbers in the Katipo style. This overrides <code>autoMemberNum</code> if on.
63
     -
64
         - pref: EnhancedMessagingPreferences
58
         - pref: EnhancedMessagingPreferences
65
           choices:
59
           choices:
66
               yes: Allow
60
               yes: Allow
(-)a/t/db_dependent/UsageStats.t (-2 lines)
Lines 545-551 sub mocking_systempreferences_to_a_set_value { Link Here
545
        AutoEmailPrimaryAddress
545
        AutoEmailPrimaryAddress
546
        autoMemberNum
546
        autoMemberNum
547
        BorrowerRenewalPeriodBase
547
        BorrowerRenewalPeriodBase
548
        checkdigit
549
        EnableBorrowerFiles
548
        EnableBorrowerFiles
550
        EnhancedMessagingPreferences
549
        EnhancedMessagingPreferences
551
        ExtendedPatronAttributes
550
        ExtendedPatronAttributes
552
- 

Return to bug 20264