Bug 7413: (follow-up) teach renew interface about too_soon
authorGalen Charlton <gmc@esilibrary.com>
Tue, 8 Apr 2014 23:22:05 +0000 (23:22 +0000)
committerGalen Charlton <gmc@esilibrary.com>
Tue, 8 Apr 2014 23:22:05 +0000 (23:22 +0000)
This patch ensures that the new staff interface for renewals
recognizes when premature renewals are requested.  If the
AllowRenewalLimitOverride system preference is enabled, staff members
are able to override the block:

To test:

[1] Set up a loan policy with a "no renewal before" value and
    check out an item.
[2] In the renewal page, verify that attempting to renew the loan
    results in an error forbidding the renew.
[3] If AllowRenewalLimitOverride is enabled, the operator should
    also be given the option to override the block.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
circ/renew.pl
koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt

index 8cde633..26c7bf0 100755 (executable)
@@ -47,6 +47,7 @@ my $override_holds = $cgi->param('override_holds');
 
 my ( $item, $issue, $borrower );
 my $error = q{};
+my $soonest_renew_date;
 
 if ($barcode) {
     $item = $schema->resultset("Item")->single( { barcode => $barcode } );
@@ -75,6 +76,12 @@ if ($barcode) {
                     }
                 }
 
+                if ( $error && ($error eq 'too_soon') ) {
+                    $soonest_renew_date = C4::Circulation::GetSoonestRenewDate(
+                        $borrower->borrowernumber(),
+                        $item->itemnumber(),
+                    );
+                }
                 if ($can_renew) {
                     my $date_due = AddRenewal( undef, $item->itemnumber() );
                     $template->param( date_due => $date_due );
@@ -96,7 +103,8 @@ if ($barcode) {
         item     => $item,
         issue    => $issue,
         borrower => $borrower,
-        error    => $error
+        error    => $error,
+        soonestrenewdate => $soonest_renew_date,
     );
 }
 
index c7bb1af..3ebd006 100644 (file)
                                     </form>
                                 [% END %]
 
+                            [% ELSIF error == "too_soon" %]
+
+                                <p>[% item.biblio.title | $EncodeUTF8 %] [% item.biblioitem.subtitle | $EncodeUTF8 %] ( [% item.barcode %] ) cannot be renewed before [% soonestrenewdate | $KohaDates %]. </p>
+
+                                [% IF Koha.Preference('AllowRenewalLimitOverride') %]
+                                    <form method="post" action="/cgi-bin/koha/circ/renew.pl">
+                                        <input type="hidden" name="barcode" value="[% item.barcode %]"/>
+                                        <input type="hidden" name="override_limit" value="1" />
+                                        <input type="submit" class="approve" value="Override and renew" />
+                                    </form>
+                                [% END %]
+
                             [% ELSIF error == "on_reserve" %]
 
                                 <p>This item is on hold for another patron.</p>