From 5ca8af3083558d8a492581a485d4726cae4e3388 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Holger=20Mei=C3=9Fner?= <h.meissner.82@web.de>
Date: Fri, 24 Jan 2014 11:32:29 +0100
Subject: [PATCH 4/5] Bug 7413: Allow OPAC renewal x days before due date
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This patch makes the bootstrap version of opac-user.tt handle the
new renewal error "too_soon".

To test:
1) Set global syspref "opacthemes" to bootstrap.
2) Test the sames things as in previous patch, only for opac-user.tt.
3) Confirm that additionally to "Not renewable yet", the number of
   remaining renewals is displayed.

Sponsored-by: Hochschule für Gesundheit (hsg), Germany
---
 koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt |    9 +++++++--
 opac/opac-user.pl                                     |    8 ++++++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt
index a16dc47..5409171 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt
@@ -206,14 +206,19 @@
                                                             [% END %]
                                                             <span class="renewals">([% ISSUE.renewsleft %] of [% ISSUE.renewsallowed %] renewals remaining)</span>
                                                         [% ELSE %]
-                                                            Not renewable
-                                                                [% IF ( ISSUE.too_many ) %]
+                                                            [% IF ( ISSUE.too_many ) %]
+                                                                Not renewable
+                                                                <span class="renewals">([% ISSUE.renewsleft %] of [% ISSUE.renewsallowed %] renewals remaining)</span>
+                                                            [% ELSE %]
+                                                                [% IF ( ISSUE.too_soon ) %]
+                                                                    Not renewable yet
                                                                     <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 %]
                                                         [% END %]
                                                     </td>
                                                 [% END %]
diff --git a/opac/opac-user.pl b/opac/opac-user.pl
index 02002a3..e34c488 100755
--- a/opac/opac-user.pl
+++ b/opac/opac-user.pl
@@ -182,8 +182,12 @@ if ($issues){
         if($status && C4::Context->preference("OpacRenewalAllowed")){
             $issue->{'status'} = $status;
         }
-        $issue->{'too_many'} = 1 if $renewerror and $renewerror eq 'too_many';
-        $issue->{'on_reserve'} = 1 if $renewerror and $renewerror eq 'on_reserve';
+
+        if ( $renewerror ) {
+            $issue->{'too_many'}   = 1 if $renewerror eq 'too_many';
+            $issue->{'too_soon'}   = 1 if $renewerror eq 'too_soon';
+            $issue->{'on_reserve'} = 1 if $renewerror eq 'on_reserve';
+        }
 
         if ( $issue->{'overdue'} ) {
             push @overdues, $issue;
-- 
1.7.10.4