From d4b680155247ef0289e8728a7416a734410c12f6 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 Signed-off-by: Benjamin Rokseth Signed-off-by: Josef Moravec Signed-off-by: Jonathan Druart --- C4/Members.pm | 21 --------------------- members/print_overdues.pl | 5 +++-- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index b14f907bd2..5438184b9c 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -69,8 +69,6 @@ BEGIN { &GetBorrowersToExpunge &IssueSlip - - GetOverduesForPatron ); #Modify data @@ -1089,25 +1087,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 1606ce2d80..4fd9c389e2 100755 --- a/members/print_overdues.pl +++ b/members/print_overdues.pl @@ -24,7 +24,6 @@ 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; @@ -51,7 +50,9 @@ my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in" my $patron = Koha::Patrons->find( $borrowernumber ); output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } ); -my $overdues = GetOverduesForPatron($borrowernumber); +my $overdues = [ + map { $_->unblessed_all_relateds } $patron->get_overdues +]; my $letter = parse_overdues_letter( { -- 2.39.5