From 733602406aca2504befc5c0e9a042f0024e2b60d Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 8 Jan 2018 13:19:51 -0300 Subject: [PATCH] Bug 17553: Move GetOverduesForPatron to Koha::Patron->get_overdues With the help of Koha::Object->unblessed_all_relateds we are going to replace GetOverduesForPatron without introducing regressions (hopefully) on both template notice syntaxes. Test plan: 0/ Do not apply any patches 1/ Check some items in to a given patron, with and without overdues. 2/ Print the overdues slip (Circulation module > Print > Print overdues) 3/ Apply these patches 4/ Print again and compare the result => The 2 generated slips must be exactly the same --- C4/Members.pm | 21 --------------------- members/print_overdues.pl | 8 ++++++-- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index faa497f98c..0a0875518d 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -69,8 +69,6 @@ BEGIN { &GetBorrowersToExpunge &IssueSlip - - GetOverduesForPatron ); #Modify data @@ -1190,25 +1188,6 @@ WHERE borrowernumber = 0 AND DATEDIFF( NOW(), timestamp ) > ?|; return $cnt eq '0E0'? 0: $cnt; } -sub GetOverduesForPatron { - my ( $borrowernumber ) = @_; - - my $sql = " - SELECT * - FROM issues, items, biblio, biblioitems - WHERE items.itemnumber=issues.itemnumber - AND biblio.biblionumber = items.biblionumber - AND biblio.biblionumber = biblioitems.biblionumber - AND issues.borrowernumber = ? - AND date_due < NOW() - "; - - my $sth = C4::Context->dbh->prepare( $sql ); - $sth->execute( $borrowernumber ); - - return $sth->fetchall_arrayref({}); -} - END { } # module clean-up code here (global destructor) 1; diff --git a/members/print_overdues.pl b/members/print_overdues.pl index b63dec94be..8b61b36d25 100755 --- a/members/print_overdues.pl +++ b/members/print_overdues.pl @@ -24,9 +24,10 @@ use CGI; use C4::Context; use C4::Auth; use C4::Output; -use C4::Members qw(GetOverduesForPatron); use C4::Overdues qw(parse_overdues_letter); +use Koha::Patrons; + my $input = new CGI; my $flagsrequired = { circulate => "circulate_remaining_permissions" }; @@ -45,7 +46,10 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( my $borrowernumber = $input->param('borrowernumber'); my $branchcode = C4::Context->userenv->{'branch'}; -my $overdues = GetOverduesForPatron($borrowernumber); +my $overdues = [ + map { $_->unblessed_all_relateds } + @{ Koha::Patrons->find($borrowernumber)->get_overdues } +]; my $letter = parse_overdues_letter( { -- 2.11.0