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

(-)a/C4/Members.pm (-48 lines)
Lines 73-79 BEGIN { Link Here
73
        &GetBorNotifyAcctRecord
73
        &GetBorNotifyAcctRecord
74
74
75
        &GetBorrowersToExpunge
75
        &GetBorrowersToExpunge
76
        &GetBorrowersWhoHaveNeverBorrowed
77
        &GetBorrowersWithIssuesHistoryOlderThan
76
        &GetBorrowersWithIssuesHistoryOlderThan
78
77
79
        &GetUpcomingMembershipExpires
78
        &GetUpcomingMembershipExpires
Lines 1200-1252 sub GetBorrowersToExpunge { Link Here
1200
    return \@results;
1199
    return \@results;
1201
}
1200
}
1202
1201
1203
=head2 GetBorrowersWhoHaveNeverBorrowed
1204
1205
  $results = &GetBorrowersWhoHaveNeverBorrowed
1206
1207
This function get all borrowers who have never borrowed.
1208
1209
I<$result> is a ref to an array which all elements are a hasref.
1210
1211
=cut
1212
1213
sub GetBorrowersWhoHaveNeverBorrowed {
1214
    my $filterbranch = shift || 
1215
                        ((C4::Context->preference('IndependentBranches')
1216
                             && C4::Context->userenv 
1217
                             && !C4::Context->IsSuperLibrarian()
1218
                             && C4::Context->userenv->{branch})
1219
                         ? C4::Context->userenv->{branch}
1220
                         : "");  
1221
    my $dbh   = C4::Context->dbh;
1222
    my $query = "
1223
        SELECT borrowers.borrowernumber,max(timestamp) as latestissue
1224
        FROM   borrowers
1225
          LEFT JOIN issues ON borrowers.borrowernumber = issues.borrowernumber
1226
        WHERE issues.borrowernumber IS NULL
1227
   ";
1228
    my @query_params;
1229
    if ($filterbranch && $filterbranch ne ""){ 
1230
        $query.=" AND borrowers.branchcode= ?";
1231
        push @query_params,$filterbranch;
1232
    }
1233
    warn $query if $debug;
1234
  
1235
    my $sth = $dbh->prepare($query);
1236
    if (scalar(@query_params)>0){  
1237
        $sth->execute(@query_params);
1238
    } 
1239
    else {
1240
        $sth->execute;
1241
    }      
1242
    
1243
    my @results;
1244
    while ( my $data = $sth->fetchrow_hashref ) {
1245
        push @results, $data;
1246
    }
1247
    return \@results;
1248
}
1249
1250
=head2 GetBorrowersWithIssuesHistoryOlderThan
1202
=head2 GetBorrowersWithIssuesHistoryOlderThan
1251
1203
1252
  $results = &GetBorrowersWithIssuesHistoryOlderThan($date)
1204
  $results = &GetBorrowersWithIssuesHistoryOlderThan($date)
(-)a/tools/cleanborrowers.pl (-2 / +1 lines)
Lines 36-42 use Modern::Perl; Link Here
36
use CGI qw ( -utf8 );
36
use CGI qw ( -utf8 );
37
use C4::Auth;
37
use C4::Auth;
38
use C4::Output;
38
use C4::Output;
39
use C4::Members;        # GetBorrowersWhoHavexxxBorrowed.
39
use C4::Members;
40
use C4::Circulation;    # AnonymiseIssueHistory.
40
use C4::Circulation;    # AnonymiseIssueHistory.
41
use Koha::DateUtils qw( dt_from_string output_pref );
41
use Koha::DateUtils qw( dt_from_string output_pref );
42
use Koha::Patron::Categories;
42
use Koha::Patron::Categories;
43
- 

Return to bug 17824