Bug 10774: Allow individual holds to be suspended and resumed from the OPAC
authorKyle M Hall <kyle@bywatersolutions.com>
Wed, 21 Aug 2013 11:30:54 +0000 (07:30 -0400)
committerGalen Charlton <gmc@esilibrary.com>
Fri, 10 Jan 2014 15:22:49 +0000 (15:22 +0000)
Right now, holds can only be suspended and resumed from the OPAC as a
whole. It would be nice to be able to suspend and resume holds on a hold
by hold basis from the OPAC.

Test Plan:
1) Apply this patch
2) Log in to the OPAC
3) Place a number of holds
4) Browse to "my summary" and select the holds tab
5) From here, test the following actions
   a) Suspend a hold indefinitely ( no resume date )
   b) Suspend a hold with a date to automatically resume
   c) Manually resume a suspended hold
6) Disable AutoResumeSuspendedHolds, ensure the suspend until date field
   is no longer visible.
7) Disable SuspendHoldsOpac, ensure all suspension related fields are
   no longer visible.

Signed-off-by: Chris Rohde <crohde@roseville.ca.us>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>

koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt
opac/opac-modrequest-suspend.pl

index 12b9f23..62a852b 100644 (file)
@@ -47,7 +47,7 @@ var MSG_CONFIRM_RESUME_HOLDS  = _("Are you sure you want to resume all suspended
             $("#renewall").submit();
         });
         $("#checkoutst caption").append("<div id=\"renewcontrols\"><a id=\"renewselected_link\" href=\"#\">"+_("Renew selected")+"</a> <a id=\"renewall_link\" href=\"#\">"+_("Renew all")+"</a></div>");[% END %]
-        $( "#suspend_until" ).datepicker({ minDate: 1 }); // Require that "until date" be in the future
+        $( ".suspend-until" ).datepicker({ minDate: 1 }); // Require that "until date" be in the future
             });
 //]]>
 </script>
@@ -351,20 +351,28 @@ var MSG_CONFIRM_RESUME_HOLDS  = _("Are you sure you want to resume all suspended
         <div id="opac-user-holds">
         <table id="holdst">
         <caption>Holds <span class="count">([% reserves_count %] total)</span></caption>
-            <!-- RESERVES TABLE ROWS -->
-            <thead><tr>
+
+        <!-- RESERVES TABLE ROWS -->
+        <thead>
+            <tr>
                 <th>Title</th>
                 <th class="psort">Placed on</th>
-                [% IF OpacHoldNotes %]<th>Notes</th>[% END %]
-        <th>Expires on</th>
+                [% IF OpacHoldNotes %]
+                    <th>Notes</th>
+                [% END %]
+                <th>Expires on</th>
                 <th>Pick up location</th>
-               [% IF ( showpriority ) %]
-                       <th>Priority</th>
-               [% END %]
+                [% IF ( showpriority ) %]
+                    <th>Priority</th>
+                [% END %]
                 <th>Status</th>
-        <th class="nosort">Modify</th>
-            </tr></thead>
-                       <tbody>
+                <th class="nosort">Modify</th>
+                [% IF SuspendHoldsOpac %]
+                    <th class="nosort" >Suspend individual holds</th>
+                [% END %]
+            </tr>
+        </thead>
+        <tbody>
             [% FOREACH RESERVE IN RESERVES %]
            [% IF ( RESERVE.wait ) %]
                         [% IF ( RESERVE.atdestination ) %]
@@ -428,6 +436,27 @@ var MSG_CONFIRM_RESUME_HOLDS  = _("Are you sure you want to resume all suspended
                [% END %]
                </td>
 
+        [% IF SuspendHoldsOpac %]
+            <td>
+                [% IF ( RESERVE.cancelable ) %]
+                    <form action="/cgi-bin/koha/opac-modrequest-suspend.pl" method="post">
+                        <input type="hidden" name="reserve_id" value="[% RESERVE.reserve_id %]" />
+
+                        [% IF RESERVE.suspend %]
+                            <input type="submit" name="submit" value="Resume suspended hold" />
+                        [% ELSE %]
+                            <input type="submit" name="submit" class="icon delete cancel" value="Suspend hold" />
+
+                            [% IF AutoResumeSuspendedHolds %]
+                                <label for="suspend_until_[% RESERVE.reserve_id %]"> until </label>
+                                <input name="suspend_until" id="suspend_until_[% RESERVE.reserve_id %]" class="suspend-until" readonly="readonly" size="10" />
+                                <a href="#" style="font-size:85%;text-decoration:none;" onclick="document.getElementById('suspend_until_[% RESERVE.reserve_id %]').value='';return false;">Clear date</a>
+                            [% END %]
+                        [% END %]
+                    </form>
+                [% END %]
+            </td>
+        [% END %]
 
             </tr>
             [% END %]
@@ -442,7 +471,7 @@ var MSG_CONFIRM_RESUME_HOLDS  = _("Are you sure you want to resume all suspended
 
              [% IF AutoResumeSuspendedHolds %]
              <label for="suspend_until"> until </label>
-              <input name="suspend_until" id="suspend_until" readonly="readonly" size="10" />
+              <input name="suspend_until" id="suspend_until" class="suspend-until" readonly="readonly" size="10" />
               <a href="#" style="font-size:85%;text-decoration:none;" onclick="document.getElementById('suspend_until').value='';return false;">Clear date</a></p>
               [% END %]
             </form>
index ec15265..e153538 100755 (executable)
@@ -36,11 +36,17 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
 
 my $suspend       = $query->param('suspend');
 my $suspend_until = $query->param('suspend_until') || undef;
+my $reserve_id    = $query->param('reserve_id');
 
-SuspendAll(
-    borrowernumber => $borrowernumber,
-    suspend        => $suspend,
-    suspend_until  => $suspend_until,
-);
+if ($reserve_id) {
+    ToggleSuspend( $reserve_id, $suspend_until );
+}
+else {
+    SuspendAll(
+        borrowernumber => $borrowernumber,
+        suspend        => $suspend,
+        suspend_until  => $suspend_until,
+    );
+}
 
 print $query->redirect("/cgi-bin/koha/opac-user.pl#opac-user-holds");