From 6561fa6f9128acb353d9cabd1341754f0174884d Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 22 Jan 2016 02:09:54 +0000 Subject: [PATCH] Bug 10612 [QA Followup] - fix issues 1 - Use Koha::List::Patron 2 - Return only non-empty lists for deletion selection 3 - Fix _skip_bo... to accept patro_list_patrons3 - Fix _skip_borrowers_with_fines_or_issues to accept patro_list_patrons3 4 - Fix missed closing quote in cleanborrowers.tt --- .../prog/en/modules/tools/cleanborrowers.tt | 2 +- tools/cleanborrowers.pl | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/cleanborrowers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/cleanborrowers.tt index f4781e7..e89b7e3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/cleanborrowers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/cleanborrowers.tt @@ -162,7 +162,7 @@ -
Cancel
diff --git a/tools/cleanborrowers.pl b/tools/cleanborrowers.pl index 3b30118..b986460 100755 --- a/tools/cleanborrowers.pl +++ b/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( @@ -189,8 +193,8 @@ sub _skip_borrowers_with_nonzero_balance { my $borrowers = shift; my $balance; @$borrowers = map { - (undef, undef, $balance) = GetMemberIssuesAndFines( $_->{borrowernumber} ); - ($balance != 0) ? (): ($_); + (undef, $issues, $balance) = GetMemberIssuesAndFines( $_->{borrowernumber} || $_->get_column('borrowernumber') ); + ($balance != 0 || $issues!= 0) ? (): ($_); } @$borrowers; } -- 2.1.4