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

(-)a/C4/Members.pm (-50 / +6 lines)
Lines 468-476 mode, to avoid database corruption. Link Here
468
468
469
=cut
469
=cut
470
470
471
use vars qw( @weightings );
472
my @weightings = ( 8, 4, 6, 3, 5, 2, 1 );
473
474
sub fixup_cardnumber {
471
sub fixup_cardnumber {
475
    my ($cardnumber) = @_;
472
    my ($cardnumber) = @_;
476
    my $autonumber_members = C4::Context->boolean_preference('autoMemberNum') || 0;
473
    my $autonumber_members = C4::Context->boolean_preference('autoMemberNum') || 0;
Lines 479-534 sub fixup_cardnumber { Link Here
479
    # automatically. Should be either "1" or something else.
476
    # automatically. Should be either "1" or something else.
480
    # Defaults to "0", which is interpreted as "no".
477
    # Defaults to "0", which is interpreted as "no".
481
478
482
    #     if ($cardnumber !~ /\S/ && $autonumber_members) {
483
    ($autonumber_members) or return $cardnumber;
479
    ($autonumber_members) or return $cardnumber;
484
    my $checkdigit = C4::Context->preference('checkdigit');
485
    my $dbh = C4::Context->dbh;
480
    my $dbh = C4::Context->dbh;
486
    if ( $checkdigit and $checkdigit eq 'katipo' ) {
487
488
        # if checkdigit is selected, calculate katipo-style cardnumber.
489
        # otherwise, just use the max()
490
        # purpose: generate checksum'd member numbers.
491
        # We'll assume we just got the max value of digits 2-8 of member #'s
492
        # from the database and our job is to increment that by one,
493
        # determine the 1st and 9th digits and return the full string.
494
        my $sth = $dbh->prepare(
495
            "select max(substring(borrowers.cardnumber,2,7)) as new_num from borrowers"
496
        );
497
        $sth->execute;
498
        my $data = $sth->fetchrow_hashref;
499
        $cardnumber = $data->{new_num};
500
        if ( !$cardnumber ) {    # If DB has no values,
501
            $cardnumber = 1000000;    # start at 1000000
502
        } else {
503
            $cardnumber += 1;
504
        }
505
506
        my $sum = 0;
507
        for ( my $i = 0 ; $i < 8 ; $i += 1 ) {
508
            # read weightings, left to right, 1 char at a time
509
            my $temp1 = $weightings[$i];
510
481
511
            # sequence left to right, 1 char at a time
482
    my $sth = $dbh->prepare(
512
            my $temp2 = substr( $cardnumber, $i, 1 );
483
        'SELECT MAX( CAST( cardnumber AS SIGNED ) ) FROM borrowers WHERE cardnumber REGEXP "^-?[0-9]+$"'
513
484
    );
514
            # mult each char 1-7 by its corresponding weighting
485
    $sth->execute;
515
            $sum += $temp1 * $temp2;
486
    my ($result) = $sth->fetchrow;
516
        }
487
    return $result + 1;
517
518
        my $rem = ( $sum % 11 );
519
        $rem = 'X' if $rem == 10;
520
521
        return "V$cardnumber$rem";
522
     } else {
523
524
        my $sth = $dbh->prepare(
525
            'SELECT MAX( CAST( cardnumber AS SIGNED ) ) FROM borrowers WHERE cardnumber REGEXP "^-?[0-9]+$"'
526
        );
527
        $sth->execute;
528
        my ($result) = $sth->fetchrow;
529
        return $result + 1;
530
    }
531
    return $cardnumber;     # just here as a fallback/reminder 
532
}
488
}
533
489
534
=head2 GetAllIssues
490
=head2 GetAllIssues
(-)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