@@ -, +, @@ --- tools/cleanborrowers.pl | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) --- a/tools/cleanborrowers.pl +++ a/tools/cleanborrowers.pl @@ -85,9 +85,8 @@ if ( $step == 2 ) { my $patrons_to_delete; if ($patron_list_id) { - my @patron_list_patrons = - Koha::Database->new()->schema()->resultset('PatronListPatron') - ->search( { patron_list_id => $patron_list_id } ); + my @patron_list = GetPatronLists( {patron_list_id=>$patron_list_id}); + my @patron_list_patrons = $patron_list[0]->patron_list_patrons(); $patrons_to_delete = \@patron_list_patrons; } else { @@ -125,9 +124,8 @@ elsif ( $step == 3 ) { if ($do_delete) { my $patrons_to_delete; if ($patron_list_id) { - my @patron_list_patrons = - Koha::Database->new()->schema()->resultset('PatronListPatron') - ->search( { patron_list_id => $patron_list_id } ); + my @patron_lists = GetPatronLists( { patron_list_id => $patron_list_id } ); + my @patron_list_patrons = $patron_lists[0]->patron_list_patrons(); $patrons_to_delete = \@patron_list_patrons; } else { @@ -170,7 +168,13 @@ elsif ( $step == 3 ) { testrun => ( $radio eq "testrun" ) ? 1: 0, ); } else { # $step == 1 - $template->param( patron_lists => [ GetPatronLists() ] ); + my @all_lists = GetPatronLists(); + my @non_empty_lists; + foreach my $list (@all_lists){ + my @patrons = $list->patron_list_patrons(); + if( scalar @patrons ) { push(@non_empty_lists,$list) } + } + $template->param( patron_lists => [ @non_empty_lists ] ); } $template->param( @@ -190,7 +194,7 @@ sub _skip_borrowers_with_nonzero_balance_or_issues { my $balance; my $issues; @$borrowers = map { - (undef, $issues, $balance) = GetMemberIssuesAndFines( $_->{borrowernumber} ); + (undef, $issues, $balance) = GetMemberIssuesAndFines( $_->{borrowernumber} || $_->get_column('borrowernumber') ); ($balance != 0 || $issues!= 0) ? (): ($_); } @$borrowers; } --