Bug 26388: Do not show 'Renew all' or 'Renew selected' if no renewable items

Additionally, only include renewable items in 'Renew all'

To test:
1 - Check out some items to a patron, ideally:
    Some not renewable because set for auto renewal
    Some not renewable because of holds
    Some renewable
 2 - Confirm 'Renew selected' and 'Renew all' show on the opac
 3 - Click 'Renew all'
 4 - You get errors about the non-renewable items?
 5 - Check in all renewable items
 6 - Confirm you still see renew buttons
 7 - Apply patch
 8 - Refresh and you shoudl not see renew buttons
 9 - Check out a renewable item
10 - Click 'Renew all'
11 - Renewable item is renewed with no error
12 - Try again with 'Renew selected'
13 - Confirm it works as expected

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Nick Clemens 2020-09-04 13:18:53 +00:00 committed by Jonathan Druart
parent bdb64657f9
commit 763cc4eb2e
2 changed files with 6 additions and 2 deletions

View File

@ -422,7 +422,9 @@
<input type="hidden" name="from" value="opac_user" />
<input type="hidden" name="borrowernumber" value="[% borrowernumber | html %]" />
[% FOREACH ISSUE IN ISSUES %]
<input type="hidden" name="item" value="[% ISSUE.itemnumber | html %]" />
[% IF ISSUE.status %]
<input type="hidden" name="item" value="[% ISSUE.itemnumber | html %]" />
[% END %]
[% END %]
<input type="submit" class="btn btn-primary" value="Renew all" />
</form>

View File

@ -190,6 +190,7 @@ my @overdues;
my @issuedat;
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
my $pending_checkouts = $patron->pending_checkouts->search({}, { order_by => [ { -desc => 'date_due' }, { -asc => 'issue_id' } ] });
my $are_renewable_items = 0;
if ( $pending_checkouts->count ) { # Useless test
while ( my $c = $pending_checkouts->next ) {
my $issue = $c->unblessed_all_relateds;
@ -226,6 +227,7 @@ if ( $pending_checkouts->count ) { # Useless test
( $issue->{'renewalfee'}, $issue->{'renewalitemtype'} ) = GetIssuingCharges( $issue->{'itemnumber'}, $borrowernumber );
$issue->{itemtype_object} = Koha::ItemTypes->find( Koha::Items->find( $issue->{itemnumber} )->effective_itemtype );
if($status && C4::Context->preference("OpacRenewalAllowed")){
$are_renewable_items = 1;
$issue->{'status'} = $status;
}
@ -299,7 +301,7 @@ if ( $pending_checkouts->count ) { # Useless test
}
}
my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing');
$canrenew = 0 if ($overduesblockrenewing ne 'allow' and $overdues_count == $count);
$canrenew = 0 if ($overduesblockrenewing ne 'allow' and $overdues_count == $count) || !$are_renewable_items;
$template->param( ISSUES => \@issuedat );
$template->param( issues_count => $count );