From f523b0d98b612b8230dabe0b35209bbd6b0aae0b Mon Sep 17 00:00:00 2001 From: David Gustafsson Date: Mon, 10 Oct 2022 17:18:03 +0200 Subject: [PATCH] Bug 31735: Optimize OPAC checkouts view Signed-off-by: Nick Clemens Signed-off-by: Kyle M Hall Signed-off-by: David Nind Signed-off-by: Tomas Cohen Arazi --- .../bootstrap/en/modules/opac-user.tt | 2 +- opac/opac-renew.pl | 20 ++++++++++++------- opac/opac-user.pl | 2 +- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt index 27e1b6b07b..94a6d657e1 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -455,7 +455,7 @@ [% IF ISSUE.renewed %]Renewed!
[% END %] [% IF ( ISSUE.status ) %] [% IF ( canrenew ) %] - Renew + Renew [% END %] [% IF ISSUE.renewalfee > 0 %] Fee for item type '[% ItemTypes.GetDescription( ISSUE.renewalitemtype) | html %]': [% ISSUE.renewalfee | $Price %] diff --git a/opac/opac-renew.pl b/opac/opac-renew.pl index 9e8efa0c5e..b3464e4eed 100755 --- a/opac/opac-renew.pl +++ b/opac/opac-renew.pl @@ -38,8 +38,8 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( query => $query, type => "opac", } -); -my @items = $query->multi_param('item'); +); +my @issues = $query->multi_param('issue'); my $opacrenew = C4::Context->preference("OpacRenewalAllowed"); @@ -55,13 +55,19 @@ if ( $patron->category->effective_BlockExpiredPatronOpacActions } else { my @renewed; - for my $itemnumber (@items) { - my $item = Koha::Items->find($itemnumber); + my $issues = Koha::Checkouts->search( + { + issue_id => { -in => \@issues } + }, { + prefetch => 'item' + } + ); + while( my $issue = $issues->next) { my ( $status, $error ) = - CanBookBeRenewed( $patron, $item->checkout ); #TODO: Pass issue numbers instead + CanBookBeRenewed( $patron, $issue ); if ( $status == 1 && $opacrenew == 1 ) { - AddRenewal( $borrowernumber, $itemnumber, undef, undef, undef, undef, 0 ); - push( @renewed, $itemnumber ); + AddRenewal( $borrowernumber, $issue->itemnumber, undef, undef, undef, undef, 0 ); + push( @renewed, $issue->itemnumber ); } else { $errorstring .= $error . "|"; diff --git a/opac/opac-user.pl b/opac/opac-user.pl index b39b7493c0..0564a1df90 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -240,7 +240,7 @@ if ( $pending_checkouts->count ) { # Useless test $issue->{'unseencount'}, $issue->{'unseenallowed'}, $issue->{'unseenleft'} - ) = GetRenewCount($borrowernumber, $issue->{'itemnumber'}); + ) = GetRenewCount($patron, $c->item); ( $issue->{'renewalfee'}, $issue->{'renewalitemtype'} ) = GetIssuingCharges( $issue->{'itemnumber'}, $borrowernumber ); $issue->{itemtype_object} = Koha::ItemTypes->find( $c->item->effective_itemtype ); if($status && C4::Context->preference("OpacRenewalAllowed")){ -- 2.39.5