From ab10146f54927f2e6097efcfc8ebfdee1290e862 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 8 Jan 2018 12:06:59 -0300 Subject: [PATCH] Bug 19935: Replace GetPendingIssues - sco-main Same as previously, we do not need all the prefetched values here, just a few. Test plan: Use the self checkout module to check some items out --- opac/sco/sco-main.pl | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/opac/sco/sco-main.pl b/opac/sco/sco-main.pl index 5b30be05e6..608c8633d6 100755 --- a/opac/sco/sco-main.pl +++ b/opac/sco/sco-main.pl @@ -108,10 +108,10 @@ if (C4::Context->preference('SelfCheckoutByLogin') && !$patronid) { ($resval, $patronid) = checkpw($dbh, $patronlogin, $patronpw); } -my $borrower; +my ( $borrower, $patron ); if ( $patronid ) { - $borrower = Koha::Patrons->find( { cardnumber => $patronid } ); - $borrower = $borrower->unblessed if $borrower; + $patron = Koha::Patrons->find( { cardnumber => $patronid } ); + $borrower = $patron->unblessed if $patron; } my $branch = $issuer->{branchcode}; @@ -245,24 +245,25 @@ if ($borrower) { # warn "issuer's branchcode: " . $issuer->{branchcode}; # warn "user's branchcode: " . $borrower->{branchcode}; my $borrowername = sprintf "%s %s", ($borrower->{firstname} || ''), ($borrower->{surname} || ''); - my @issues; - my ($issueslist) = GetPendingIssues( $borrower->{'borrowernumber'} ); - foreach my $it (@$issueslist) { + my $pending_checkouts = $patron->pending_checkouts; + my @checkouts; + while ( my $c = $pending_checkouts->next ) { + my $checkout = $c->unblessed_all_relateds; my ($can_be_renewed, $renew_error) = CanBookBeRenewed( $borrower->{borrowernumber}, - $it->{itemnumber}, + $checkout->{itemnumber}, ); - $it->{can_be_renewed} = $can_be_renewed; - $it->{renew_error} = $renew_error; - $it->{date_due} = $it->{date_due_sql}; - push @issues, $it; + $checkout->{can_be_renewed} = $can_be_renewed; # In the future this will be $checkout->can_be_renewed + $checkout->{renew_error} = $renew_error; + $checkout->{overdue} = $c->is_overdue; + push @checkouts, $checkout; } $template->param( validuser => 1, borrowername => $borrowername, - issues_count => scalar(@issues), - ISSUES => \@issues, + issues_count => scalar(@checkouts), + ISSUES => \@checkouts, patronid => $patronid, patronlogin => $patronlogin, patronpw => $patronpw, -- 2.11.0