Bug 16873: Improve renewal error messages on self check

When a patron is not allowed to renew from the self check module, the
only message displayed is "No renewals allowed".
It would be nicer to let him/her know that the renewal is not allowed
because it's a on-site checkout or automatic renewal.

To do so we can call CanBookBeRenewed instead of CanBookBeIssued and get
the renewal error.

Test plan:
0/ Switch off AllowSelfCheckReturns
1/ check out an item and tick "auto renewal"
2/ Go on the self check module
=> auto renewal message is displayed
3/ check out an item and tick "on-site checkout"
4/ Go on the self check module
=> on-site checkout message is displayed
5/ check out an item without ticking any checkboxes (regular checkout)
Renew it to reach the max renew allowed
6/ Go on the self check module
=> regular checkout message is displayed
7/ Switch on AllowSelfCheckReturns and repeat previous steps
=> "Return this item" button is displayed in addition of the renewal
error message

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Katrin Fischer  <katrin.fischer@bsz-bw.de>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2016-08-19 12:01:32 +01:00 committed by Kyle M Hall
parent 2d769cd508
commit 8dce1cde3a
2 changed files with 19 additions and 16 deletions

View file

@ -250,15 +250,7 @@
<form action="/cgi-bin/koha/sco/sco-main.pl" method="post"> <form action="/cgi-bin/koha/sco/sco-main.pl" method="post">
<input type="hidden" name="patronid" value="[% patronid %]" /> <input type="hidden" name="patronid" value="[% patronid %]" />
<input type="hidden" name="barcode" value="[% ISSUE.barcode %]" /> <input type="hidden" name="barcode" value="[% ISSUE.barcode %]" />
[% IF ( ISSUE.norenew ) %] [% IF ISSUE.can_be_renewed %]
[% IF ( AllowSelfCheckReturns ) %]
<input type="submit" value="Check in item" name="confirm" class="btn return" />
<input type="hidden" name="op" value="returnbook" />
<input type="hidden" name="confirmed" value="" />
[% ELSE %]
<span>No renewals allowed</span>
[% END %]
[% ELSE %]
<input type="hidden" name="op" value="checkout" /> <input type="hidden" name="op" value="checkout" />
<input type="hidden" name="confirmed" value="1" /> <input type="hidden" name="confirmed" value="1" />
[% UNLESS ( ISSUE.renew ) %] [% UNLESS ( ISSUE.renew ) %]
@ -266,6 +258,19 @@
[% ELSE %] [% ELSE %]
<input type="submit" value="Renew item" class="btn renew" /> <input type="submit" value="Renew item" class="btn renew" />
[% END %] [% END %]
[% ELSE %]
[% IF ISSUE.renew_error == 'auto_renew' OR ISSUE.renew_error == 'auto_too_soon' %]
<span>This item has been scheduled for automatic renewal and cannot be renewed</span>
[% ELSIF ISSUE.renew_error == 'onsite_checkout' %]
<span>This is a on-site checkout, it cannot be renewed.</span>
[% ELSE %]
<span>No renewals allowed</span>
[% END %]
[% IF AllowSelfCheckReturns %]
<input type="submit" value="Check in item" name="confirm" class="btn return" />
<input type="hidden" name="op" value="returnbook" />
<input type="hidden" name="confirmed" value="" />
[% END %]
[% END %] [% END %]
</form> </form>
</td> </td>

View file

@ -226,14 +226,12 @@ if ($borrower->{cardnumber}) {
my @issues; my @issues;
my ($issueslist) = GetPendingIssues( $borrower->{'borrowernumber'} ); my ($issueslist) = GetPendingIssues( $borrower->{'borrowernumber'} );
foreach my $it (@$issueslist) { foreach my $it (@$issueslist) {
my ($renewokay, $renewerror) = CanBookBeIssued( my ($can_be_renewed, $renew_error) = CanBookBeRenewed(
$borrower, $borrower->{borrowernumber},
$it->{'barcode'}, $it->{itemnumber},
undef,
0,
C4::Context->preference("AllowItemsOnHoldCheckoutSCO")
); );
$it->{'norenew'} = 1 if $renewokay->{'NO_MORE_RENEWALS'}; $it->{can_be_renewed} = $can_be_renewed;
$it->{renew_error} = $renew_error;
$it->{date_due} = $it->{date_due_sql}; $it->{date_due} = $it->{date_due_sql};
push @issues, $it; push @issues, $it;
} }