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

(-)a/C4/Members.pm (-26 / +61 lines)
Lines 448-461 sub GetMember { Link Here
448
    $debug && warn $select, " ",values %information;
448
    $debug && warn $select, " ",values %information;
449
    my $sth = $dbh->prepare("$select");
449
    my $sth = $dbh->prepare("$select");
450
    $sth->execute(map{$information{$_}} keys %information);
450
    $sth->execute(map{$information{$_}} keys %information);
451
    my $data = $sth->fetchall_arrayref({});
451
    my $data = $sth->fetchrow_hashref;
452
    #FIXME interface to this routine now allows generation of a result set
452
    return $data if $data
453
    #so whole array should be returned but bowhere in the current code expects this
453
    # FIXME this routine can now support generation of a resultset
454
    if (@{$data} ) {
454
    # but until that is needed only what is expected by current
455
        return $data->[0];
455
    # routines will be generated and returned for the sake of
456
    }
456
    # perfomance.
457
458
    return;
459
}
457
}
460
458
461
=head2 GetMemberRelatives
459
=head2 GetMemberRelatives
Lines 738-749 sub AddMember { Link Here
738
        $data{'dateenrolled'} = output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } );
736
        $data{'dateenrolled'} = output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } );
739
    }
737
    }
740
738
741
    my $patron_category = $schema->resultset('Category')->find( $data{'categorycode'} );
739
    # Check the member category privacy level
740
    my $patron_privacy = GetCategoryPrivacy( $data{'categorycode'} );
742
    $data{'privacy'} =
741
    $data{'privacy'} =
743
        $patron_category->default_privacy() eq 'default' ? 1
742
        $patron_privacy eq 'default' ? 1
744
      : $patron_category->default_privacy() eq 'never'   ? 2
743
      : $patron_privacy eq 'never'   ? 2
745
      : $patron_category->default_privacy() eq 'forever' ? 0
744
      : $patron_privacy eq 'forever' ? 0
746
      :                                                    undef;
745
      : undef;
747
    # Make a copy of the plain text password for later use
746
    # Make a copy of the plain text password for later use
748
    my $plain_text_password = $data{'password'};
747
    my $plain_text_password = $data{'password'};
749
748
Lines 801-817 sub Check_Userid { Link Here
801
800
802
    return 0 unless ($uid); # userid is a unique column, we should assume NULL is not unique
801
    return 0 unless ($uid); # userid is a unique column, we should assume NULL is not unique
803
802
804
    return 0 if ( $uid eq C4::Context->config('user') );
803
    my $sql = 'SELECT borrowernumber FROM borrowers WHERE userid=?';
805
804
    $sql .= ' AND borrowernumber != ?' if $borrowernumber;
806
    my $rs = Koha::Database->new()->schema()->resultset('Borrower');
805
    my $dbh = C4::Context->dbh;
807
806
    my $sth = $dbh->prepare($sql);
808
    my $params;
807
    if ($borrowernumber) {
809
    $params->{userid} = $uid;
808
        $sth->execute( $uid, $borrowernumber );
810
    $params->{borrowernumber} = { '!=' => $borrowernumber } if ($borrowernumber);
809
    }
811
810
    else {
812
    my $count = $rs->count( $params );
811
        $sth->execute($uid);
813
812
    }
814
    return $count ? 0 : 1;
813
    my $data = $sth->fetchrow;
814
    return $data ? 0 : 1;
815
}
815
}
816
816
817
=head2 Generate_Userid
817
=head2 Generate_Userid
Lines 1308-1314 sub checkcardnumber { Link Here
1308
    return 0 unless defined $cardnumber;
1308
    return 0 unless defined $cardnumber;
1309
1309
1310
    my $dbh = C4::Context->dbh;
1310
    my $dbh = C4::Context->dbh;
1311
    my $query = "SELECT * FROM borrowers WHERE cardnumber=?";
1311
    my $query = "SELECT borrowernumber FROM borrowers WHERE cardnumber=?";
1312
    $query .= " AND borrowernumber <> ?" if ($borrowernumber);
1312
    $query .= " AND borrowernumber <> ?" if ($borrowernumber);
1313
    my $sth = $dbh->prepare($query);
1313
    my $sth = $dbh->prepare($query);
1314
    $sth->execute(
1314
    $sth->execute(
Lines 1316-1322 sub checkcardnumber { Link Here
1316
        ( $borrowernumber ? $borrowernumber : () )
1316
        ( $borrowernumber ? $borrowernumber : () )
1317
    );
1317
    );
1318
1318
1319
    return 1 if $sth->fetchrow_hashref;
1319
    return 1 if $sth->fetchrow;
1320
1320
1321
    my ( $min_length, $max_length ) = get_cardnumber_length();
1321
    my ( $min_length, $max_length ) = get_cardnumber_length();
1322
    return 2
1322
    return 2
Lines 2559-2564 WHERE categorycode = ? AND DATEDIFF( NOW(), dateenrolled ) > ? |; Link Here
2559
    return $cnt;
2559
    return $cnt;
2560
}
2560
}
2561
2561
2562
=head2 GetBorrowecategoryHash
2563
2564
    $arrayref_hashref = &GetBorrowercateforyHash;
2565
2566
    This function returns a hash of borrower categories where the keys are category
2567
    codes and values are category descriptions.
2568
2569
=cut
2570
2571
sub GetBorrowercategoryHash {
2572
    my $categories_list = GetBorrowercategoryList();
2573
    my %categories_hash = map { $_->{categorycode} => $_->{description} } @{$categories_list};
2574
    return %categories_hash;
2575
}
2576
2577
=head2 GetCategoryPrivacyHash
2578
2579
    $hashref = &GetCategoryPrivacyHash
2580
    Returns the default  privacy description of a patron's category given the category code.
2581
2582
=cut
2583
2584
sub GetCategoryPrivacy {
2585
    my ($categorycode) = @_;
2586
    my $dbh = C4::Context->dbh;
2587
    my $sth = $dbh->prepare(
2588
            qq{
2589
               SELECT default_privacy
2590
               FROM categories
2591
               WHERE categorycode = ?
2592
            });
2593
    $sth->execute($categorycode);
2594
    return $sth->fetchrow;
2595
}
2596
2562
=head2 DeleteUnverifiedOpacRegistrations
2597
=head2 DeleteUnverifiedOpacRegistrations
2563
2598
2564
    Delete all unverified self registrations in borrower_modifications,
2599
    Delete all unverified self registrations in borrower_modifications,
(-)a/tools/import_borrowers.pl (-5 / +6 lines)
Lines 40-46 use warnings; Link Here
40
use C4::Auth;
40
use C4::Auth;
41
use C4::Output;
41
use C4::Output;
42
use C4::Context;
42
use C4::Context;
43
use C4::Branch qw/GetBranchesLoop GetBranchName/;
43
use C4::Branch qw/GetBranchesLoop GetBranches/;
44
use C4::Members;
44
use C4::Members;
45
use C4::Members::Attributes qw(:all);
45
use C4::Members::Attributes qw(:all);
46
use C4::Members::AttributeTypes;
46
use C4::Members::AttributeTypes;
Lines 144-149 if ( $uploadborrowers && length($uploadborrowers) > 0 ) { Link Here
144
    my $today_iso = output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' });
144
    my $today_iso = output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' });
145
    my @criticals = qw(surname branchcode categorycode);    # there probably should be others
145
    my @criticals = qw(surname branchcode categorycode);    # there probably should be others
146
    my @bad_dates;  # I've had a few.
146
    my @bad_dates;  # I've had a few.
147
    my $all_branches   = GetBranches();
148
    my %all_categories = C4::Members::GetBorrowercategoryHash();
147
    LINE: while ( my $borrowerline = <$handle> ) {
149
    LINE: while ( my $borrowerline = <$handle> ) {
148
        my %borrower;
150
        my %borrower;
149
        my @missing_criticals;
151
        my @missing_criticals;
Lines 178-190 if ( $uploadborrowers && length($uploadborrowers) > 0 ) { Link Here
178
        #warn join(':',%borrower);
180
        #warn join(':',%borrower);
179
        if ($borrower{categorycode}) {
181
        if ($borrower{categorycode}) {
180
            push @missing_criticals, {key=>'categorycode', line=>$. , lineraw=>$borrowerline, value=>$borrower{categorycode}, category_map=>1}
182
            push @missing_criticals, {key=>'categorycode', line=>$. , lineraw=>$borrowerline, value=>$borrower{categorycode}, category_map=>1}
181
                unless GetBorrowercategory($borrower{categorycode});
183
                unless $all_categories{ $borrower{categorycode} }
182
        } else {
184
        } else {
183
            push @missing_criticals, {key=>'categorycode', line=>$. , lineraw=>$borrowerline};
185
            push @missing_criticals, {key=>'categorycode', line=>$. , lineraw=>$borrowerline};
184
        }
186
        }
185
        if ($borrower{branchcode}) {
187
        if ($borrower{branchcode}) {
186
            push @missing_criticals, {key=>'branchcode', line=>$. , lineraw=>$borrowerline, value=>$borrower{branchcode}, branch_map=>1}
188
            push @missing_criticals, {key=>'branchcode', line=>$. , lineraw=>$borrowerline, value=>$borrower{branchcode}, branch_map=>1}
187
                unless GetBranchName($borrower{branchcode});
189
                unless $all_branches->{ $borrower{branchcode} }->{branchname};
188
        } else {
190
        } else {
189
            push @missing_criticals, {key=>'branchcode', line=>$. , lineraw=>$borrowerline};
191
            push @missing_criticals, {key=>'branchcode', line=>$. , lineraw=>$borrowerline};
190
        }
192
        }
Lines 314-320 if ( $uploadborrowers && length($uploadborrowers) > 0 ) { Link Here
314
            $template->param('lastoverwritten'=>$borrower{'surname'}.' / '.$borrowernumber);
316
            $template->param('lastoverwritten'=>$borrower{'surname'}.' / '.$borrowernumber);
315
        } else {
317
        } else {
316
            # FIXME: fixup_cardnumber says to lock table, but the web interface doesn't so this doesn't either.
318
            # FIXME: fixup_cardnumber says to lock table, but the web interface doesn't so this doesn't either.
317
            # At least this is closer to AddMember than in members/memberentry.pl
319
            # At least this is closer to AddMembes $all_categories{ $borrower{categorycode} } than in members/memberentry.pl
318
            if (!$borrower{'cardnumber'}) {
320
            if (!$borrower{'cardnumber'}) {
319
                $borrower{'cardnumber'} = fixup_cardnumber(undef);
321
                $borrower{'cardnumber'} = fixup_cardnumber(undef);
320
            }
322
            }
321
- 

Return to bug 15103