Bug 31735: Optimize OPAC checkouts view

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
David Gustafsson 2022-10-10 17:18:03 +02:00 committed by Tomas Cohen Arazi
parent ddc2906b77
commit f523b0d98b
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
3 changed files with 15 additions and 9 deletions

View file

@ -455,7 +455,7 @@
[% IF ISSUE.renewed %]<span class="blabel label-success">Renewed!</span><br />[% END %]
[% IF ( ISSUE.status ) %]
[% IF ( canrenew ) %]
<input type="checkbox" name="item" value="[% ISSUE.itemnumber | uri %]"/> <a href="/cgi-bin/koha/opac-renew.pl?from=opac_user&amp;item=[% ISSUE.itemnumber | uri %]&amp;borrowernumber=[% ISSUE.borrowernumber | uri %]">Renew</a>
<input type="checkbox" name="issue" value="[% ISSUE.issue_id | uri %]"/> <a href="/cgi-bin/koha/opac-renew.pl?from=opac_user&amp;issue=[% ISSUE.issue_id | uri %]&amp;borrowernumber=[% ISSUE.borrowernumber | uri %]">Renew</a>
[% END %]
[% IF ISSUE.renewalfee > 0 %]
<span class="renewalfee label label-warning">Fee for item type '[% ItemTypes.GetDescription( ISSUE.renewalitemtype) | html %]': [% ISSUE.renewalfee | $Price %]</span>

View file

@ -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 . "|";

View file

@ -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")){