Bug 6598 [REVISED] OPACFineNoRenewals syspreference does not stop user renewing in opac

This patch standardizes the condition under which renewal controls
are displayed at the page (as opposed to item) level. In some
places "canrenew" was used, in others "patron_flagged" was used.
Now "canrenew" controls renew controls and "patron_flagged" only
triggers the display of user warnings.

This patch also allows for renewal information to be displayed
for each item in situations where OPAC renewals are allowed but
disabled for whatever reason. This gives the patron information
about used/available renew counts but hides renew controls.

Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
This commit is contained in:
Owen Leonard 2011-10-11 14:52:19 -04:00 committed by Paul Poulain
parent edee01dd0f
commit 0027fe0cc3
2 changed files with 12 additions and 15 deletions

View file

@ -58,7 +58,6 @@ $.tablesorter.addParser({
<div id="yui-main"> <div id="yui-main">
<div class="yui-b"><div class="yui-g"> <div class="yui-b"><div class="yui-g">
<div id="userdetails" class="container"> <div id="userdetails" class="container">
[% IF ( bor_messages ) %] [% IF ( bor_messages ) %]
<div class="dialog message"> <div class="dialog message">
<h3>Messages For You</h3> <h3>Messages For You</h3>
@ -89,7 +88,7 @@ $.tablesorter.addParser({
</div> </div>
[% END %] [% END %]
[% IF ( BORROWER_INF.flagged ) %] [% IF ( patron_flagged ) %]
<div class="dialog alert"> <div class="dialog alert">
<ul> <ul>
[% IF ( userdebarred ) %] [% IF ( userdebarred ) %]
@ -196,7 +195,7 @@ $.tablesorter.addParser({
[% IF ( show_barcode ) %]<th>Barcode</th>[% END %] [% IF ( show_barcode ) %]<th>Barcode</th>[% END %]
<th>Call No.</th> <th>Call No.</th>
[% IF ( OpacRenewalAllowed ) %] [% IF ( OpacRenewalAllowed ) %]
[% UNLESS patron_flagged %]<th class="{sorter: false}">Renew</th>[% END %] <th class="{sorter: false}">Renew</th>
[% END %] [% END %]
[% IF ( OPACFinesTab ) %] [% IF ( OPACFinesTab ) %]
<th>Fines</th> <th>Fines</th>
@ -244,12 +243,10 @@ $.tablesorter.addParser({
[% IF ( show_barcode ) %]<td>[% ISSUE.barcode %]</td>[% END %] [% IF ( show_barcode ) %]<td>[% ISSUE.barcode %]</td>[% END %]
<td>[% ISSUE.itemcallnumber %]</td> <td>[% ISSUE.itemcallnumber %]</td>
[% IF ( OpacRenewalAllowed ) %] [% IF ( OpacRenewalAllowed ) %]
[% UNLESS patron_flagged %] <td>[% IF ( ISSUE.status ) %][% IF ( canrenew ) %]<input type="checkbox" name="item" value="[% ISSUE.itemnumber %]"/> <a href="/cgi-bin/koha/opac-renew.pl?from=opac_user&amp;item=[% ISSUE.itemnumber %]&amp;borrowernumber=[% ISSUE.borrowernumber %]">Renew</a>[% END %] <span class="renewals">([% ISSUE.renewsleft %] of [% ISSUE.renewsallowed %] renewals remaining)</span>
<td>[% IF ( ISSUE.status ) %]<input type="checkbox" name="item" value="[% ISSUE.itemnumber %]"/> <a href="/cgi-bin/koha/opac-renew.pl?from=opac_user&amp;item=[% ISSUE.itemnumber %]&amp;borrowernumber=[% ISSUE.borrowernumber %]">Renew</a> <span class="renewals">([% ISSUE.renewsleft %] of [% ISSUE.renewsallowed %] renewals remaining)</span>
[% ELSE %] [% ELSE %]
Not renewable[% IF ( ISSUE.too_many ) %] <span class="renewals">([% ISSUE.renewsleft %] of [% ISSUE.renewsallowed %] renewals remaining)</span>[% ELSE %][% IF ( ISSUE.on_reserve ) %] <span class="renewals">(On hold)</span>[% END %][% END %] Not renewable[% IF ( ISSUE.too_many ) %] <span class="renewals">([% ISSUE.renewsleft %] of [% ISSUE.renewsallowed %] renewals remaining)</span>[% ELSE %][% IF ( ISSUE.on_reserve ) %] <span class="renewals">(On hold)</span>[% END %][% END %]
[% END %]</td> [% END %]</td>
[% END %]
[% END %] [% END %]
[% IF ( OPACFinesTab ) %] [% IF ( OPACFinesTab ) %]
<td>[% IF ( ISSUE.charges ) %]Yes[% ELSE %]No[% END %]</td> <td>[% IF ( ISSUE.charges ) %]Yes[% ELSE %]No[% END %]</td>
@ -271,7 +268,7 @@ $.tablesorter.addParser({
[% FOREACH ISSUE IN ISSUES %] [% FOREACH ISSUE IN ISSUES %]
<input type="hidden" name="item" value="[% ISSUE.itemnumber %]" /> <input type="hidden" name="item" value="[% ISSUE.itemnumber %]" />
[% END %] [% END %]
[% UNLESS patron_flagged %]<input type="submit" value="Renew All" />[% END %] <input type="submit" value="Renew All" />
</form> </form>
[% END %] [% END %]
[% ELSE %] [% ELSE %]
@ -293,7 +290,8 @@ $.tablesorter.addParser({
<th>Call No.</th> <th>Call No.</th>
<th>Due</th> <th>Due</th>
[% IF ( OpacRenewalAllowed ) %] [% IF ( OpacRenewalAllowed ) %]
[% UNLESS patron_flagged %]<th class="{sorter: false}">Renew</th>[% END %][% END %] <th class="{sorter: false}">Renew</th>
[% END %]
[% IF ( OPACFinesTab ) %] [% IF ( OPACFinesTab ) %]
<th>Fines</th> <th>Fines</th>
[% END %] [% END %]
@ -325,15 +323,14 @@ $.tablesorter.addParser({
<td>[% OVERDUE.itemcallnumber %]</td> <td>[% OVERDUE.itemcallnumber %]</td>
<td>[% OVERDUE.date_due %]</td> <td>[% OVERDUE.date_due %]</td>
[% IF ( OpacRenewalAllowed ) %] [% IF ( OpacRenewalAllowed ) %]
[% UNLESS patron_flagged %]
<td> <td>
[% IF ( OVERDUE.debarred ) %]Account Frozen [% IF ( OVERDUE.debarred ) %]Account Frozen
[% ELSIF ( OVERDUE.status ) %] [% ELSIF ( OVERDUE.status ) %]
<a href="/cgi-bin/koha/opac-renew.pl?from=opac_user&amp;item=[% OVERDUE.itemnumber %]&amp;bornum=[% OVERDUE.borrowernumber %]">Renew</a> <span class="renewals">([% OVERDUE.renewsleft %] of [% OVERDUE.renewsallowed %] renewals remaining)</span> [% IF ( canrenew ) %]<a href="/cgi-bin/koha/opac-renew.pl?from=opac_user&amp;item=[% OVERDUE.itemnumber %]&amp;bornum=[% OVERDUE.borrowernumber %]">Renew</a>[% END %] <span class="renewals">([% OVERDUE.renewsleft %] of [% OVERDUE.renewsallowed %] renewals remaining)</span>
[% ELSIF ( OVERDUE.onreserve ) %]On Reserve [% ELSIF ( OVERDUE.onreserve ) %]On hold
[% ELSE %]No renewals left [% ELSE %]No renewals left
[% END %] [% END %]
</td>[% END %][% END %] </td>[% END %]
[% IF ( OPACFinesTab ) %] [% IF ( OPACFinesTab ) %]
<td>[% IF ( OVERDUE.charges ) %]Yes[% ELSE %]No[% END %]</td> <td>[% IF ( OVERDUE.charges ) %]Yes[% ELSE %]No[% END %]</td>
[% END %] [% END %]

View file

@ -67,6 +67,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
my $OPACDisplayRequestPriority = (C4::Context->preference("OPACDisplayRequestPriority")) ? 1 : 0; my $OPACDisplayRequestPriority = (C4::Context->preference("OPACDisplayRequestPriority")) ? 1 : 0;
my $patronupdate = $query->param('patronupdate'); my $patronupdate = $query->param('patronupdate');
my $canrenew = 1;
# get borrower information .... # get borrower information ....
my ( $borr ) = GetMemberDetails( $borrowernumber ); my ( $borr ) = GetMemberDetails( $borrowernumber );
@ -92,6 +93,7 @@ if ($debar) {
if ( $userdebarred || $borr->{'gonenoaddress'} || $borr->{'lost'} ) { if ( $userdebarred || $borr->{'gonenoaddress'} || $borr->{'lost'} ) {
$borr->{'flagged'} = 1; $borr->{'flagged'} = 1;
$canrenew = 0;
} }
if ( $borr->{'amountoutstanding'} > 5 ) { if ( $borr->{'amountoutstanding'} > 5 ) {
@ -105,6 +107,7 @@ $no_renewal_amt ||= 0;
if ( $borr->{amountoutstanding} > $no_renewal_amt ) { if ( $borr->{amountoutstanding} > $no_renewal_amt ) {
$borr->{'flagged'} = 1; $borr->{'flagged'} = 1;
$canrenew = 0;
$template->param( $template->param(
renewal_blocked_fines => sprintf( '%.02f', $no_renewal_amt ), renewal_blocked_fines => sprintf( '%.02f', $no_renewal_amt ),
); );
@ -144,13 +147,11 @@ $template->param( BORROWER_INFO => \@bordat,
#get issued items .... #get issued items ....
my $count = 0; my $count = 0;
my $toggle = 0;
my $overdues_count = 0; my $overdues_count = 0;
my @overdues; my @overdues;
my @issuedat; my @issuedat;
my $itemtypes = GetItemTypes(); my $itemtypes = GetItemTypes();
my ($issues) = GetPendingIssues($borrowernumber); my ($issues) = GetPendingIssues($borrowernumber);
my $canrenew = 0;
if ($issues){ if ($issues){
foreach my $issue ( sort { $b->{'date_due'} cmp $a->{'date_due'} } @$issues ) { foreach my $issue ( sort { $b->{'date_due'} cmp $a->{'date_due'} } @$issues ) {
# check for reserves # check for reserves
@ -181,7 +182,6 @@ if ($issues){
($issue->{'renewcount'},$issue->{'renewsallowed'},$issue->{'renewsleft'}) = GetRenewCount($borrowernumber, $issue->{'itemnumber'}); ($issue->{'renewcount'},$issue->{'renewsallowed'},$issue->{'renewsleft'}) = GetRenewCount($borrowernumber, $issue->{'itemnumber'});
if($status && C4::Context->preference("OpacRenewalAllowed")){ if($status && C4::Context->preference("OpacRenewalAllowed")){
$issue->{'status'} = $status; $issue->{'status'} = $status;
$canrenew = 1;
} }
$issue->{'too_many'} = 1 if $renewerror and $renewerror eq 'too_many'; $issue->{'too_many'} = 1 if $renewerror and $renewerror eq 'too_many';
$issue->{'on_reserve'} = 1 if $renewerror and $renewerror eq 'on_reserve'; $issue->{'on_reserve'} = 1 if $renewerror and $renewerror eq 'on_reserve';