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

(-)a/C4/Members.pm (-27 / +62 lines)
Lines 458-471 sub GetMember { Link Here
458
    $debug && warn $select, " ",values %information;
458
    $debug && warn $select, " ",values %information;
459
    my $sth = $dbh->prepare("$select");
459
    my $sth = $dbh->prepare("$select");
460
    $sth->execute(map{$information{$_}} keys %information);
460
    $sth->execute(map{$information{$_}} keys %information);
461
    my $data = $sth->fetchall_arrayref({});
461
    my $data = $sth->fetchrow_hashref;
462
    #FIXME interface to this routine now allows generation of a result set
462
    return $data if $data
463
    #so whole array should be returned but bowhere in the current code expects this
463
    # FIXME this routine can now support generation of a resultset
464
    if (@{$data} ) {
464
    # but until that is needed only what is expected by current
465
        return $data->[0];
465
    # routines will be generated and returned for the sake of
466
    }
466
    # perfomance.
467
468
    return;
469
}
467
}
470
468
471
=head2 GetMemberRelatives
469
=head2 GetMemberRelatives
Lines 747-759 sub AddMember { Link Here
747
    unless ( $data{'dateenrolled'} ) {
745
    unless ( $data{'dateenrolled'} ) {
748
        $data{'dateenrolled'} = C4::Dates->new()->output("iso");
746
        $data{'dateenrolled'} = C4::Dates->new()->output("iso");
749
    }
747
    }
750
748
    
751
    my $patron_category = $schema->resultset('Category')->find( $data{'categorycode'} );
749
    # Check the member category privacy level
750
    my $patron_privacy = GetCategoryPrivacy( $data{'categorycode'} );
752
    $data{'privacy'} =
751
    $data{'privacy'} =
753
        $patron_category->default_privacy() eq 'default' ? 1
752
        $patron_privacy eq 'default' ? 1
754
      : $patron_category->default_privacy() eq 'never'   ? 2
753
      : $patron_privacy eq 'never'   ? 2
755
      : $patron_category->default_privacy() eq 'forever' ? 0
754
      : $patron_privacy eq 'forever' ? 0
756
      :                                                    undef;
755
      : undef;
757
    # Make a copy of the plain text password for later use
756
    # Make a copy of the plain text password for later use
758
    my $plain_text_password = $data{'password'};
757
    my $plain_text_password = $data{'password'};
759
758
Lines 811-827 sub Check_Userid { Link Here
811
810
812
    return 0 unless ($uid); # userid is a unique column, we should assume NULL is not unique
811
    return 0 unless ($uid); # userid is a unique column, we should assume NULL is not unique
813
812
814
    return 0 if ( $uid eq C4::Context->config('user') );
813
    my $sql = 'SELECT borrowernumber FROM borrowers WHERE userid=?';
815
814
    $sql .= ' AND borrowernumber != ?' if $borrowernumber;
816
    my $rs = Koha::Database->new()->schema()->resultset('Borrower');
815
    my $dbh = C4::Context->dbh;
817
816
    my $sth = $dbh->prepare($sql);
818
    my $params;
817
    if ($borrowernumber) {
819
    $params->{userid} = $uid;
818
        $sth->execute( $uid, $borrowernumber );
820
    $params->{borrowernumber} = { '!=' => $borrowernumber } if ($borrowernumber);
819
    }
821
820
    else {
822
    my $count = $rs->count( $params );
821
        $sth->execute($uid);
823
822
    }
824
    return $count ? 0 : 1;
823
    my $data = $sth->fetchrow;
824
    return $data ? 0 : 1;
825
}
825
}
826
826
827
=head2 Generate_Userid
827
=head2 Generate_Userid
Lines 1318-1324 sub checkcardnumber { Link Here
1318
    return 0 unless defined $cardnumber;
1318
    return 0 unless defined $cardnumber;
1319
1319
1320
    my $dbh = C4::Context->dbh;
1320
    my $dbh = C4::Context->dbh;
1321
    my $query = "SELECT * FROM borrowers WHERE cardnumber=?";
1321
    my $query = "SELECT borrowernumber FROM borrowers WHERE cardnumber=?";
1322
    $query .= " AND borrowernumber <> ?" if ($borrowernumber);
1322
    $query .= " AND borrowernumber <> ?" if ($borrowernumber);
1323
    my $sth = $dbh->prepare($query);
1323
    my $sth = $dbh->prepare($query);
1324
    $sth->execute(
1324
    $sth->execute(
Lines 1326-1332 sub checkcardnumber { Link Here
1326
        ( $borrowernumber ? $borrowernumber : () )
1326
        ( $borrowernumber ? $borrowernumber : () )
1327
    );
1327
    );
1328
1328
1329
    return 1 if $sth->fetchrow_hashref;
1329
    return 1 if $sth->fetchrow;
1330
1330
1331
    my ( $min_length, $max_length ) = get_cardnumber_length();
1331
    my ( $min_length, $max_length ) = get_cardnumber_length();
1332
    return 2
1332
    return 2
Lines 2535-2540 WHERE categorycode = ? AND DATEDIFF( NOW(), dateenrolled ) > ? |; Link Here
2535
    return $cnt;
2535
    return $cnt;
2536
}
2536
}
2537
2537
2538
=head2 GetBorrowecategoryHash
2539
2540
    $arrayref_hashref = &GetBorrowercateforyHash;
2541
    
2542
    This function returns a hash of borrower categories where the keys are category
2543
    codes and values are category descriptions.
2544
2545
=cut
2546
2547
sub GetBorrowercategoryHash {
2548
    my $categories_list = GetBorrowercategoryList();
2549
    my %categories_hash = map { $_->{categorycode} => $_->{description} } @{$categories_list};
2550
    return %categories_hash;
2551
}
2552
2553
=head2 GetCategoryPrivacyHash
2554
2555
    $hashref = &GetCategoryPrivacyHash
2556
    Returns the default  privacy description of a patron's category given the category code.
2557
2558
=cut
2559
2560
sub GetCategoryPrivacy {
2561
    my ($categorycode) = @_; 
2562
    my $dbh = C4::Context->dbh;
2563
    my $sth = $dbh->prepare(
2564
            qq{
2565
               SELECT default_privacy
2566
               FROM categories
2567
               WHERE categorycode = ?
2568
            });
2569
    $sth->execute($categorycode);
2570
    return $sth->fetchrow;
2571
}
2572
            
2538
=head2 DeleteUnverifiedOpacRegistrations
2573
=head2 DeleteUnverifiedOpacRegistrations
2539
2574
2540
    Delete all unverified self registrations in borrower_modifications,
2575
    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