Bug 22537: Suspend all hold button appears even if the hold can no longer be suspended.
authorOwen Leonard <oleonard@myacpl.org>
Fri, 26 Apr 2019 13:55:31 +0000 (13:55 +0000)
committerroot <root@f1ebe1bec408>
Mon, 29 Apr 2019 11:33:38 +0000 (11:33 +0000)
This patch adds to the user summary page in the OPAC a check for waiting
or in-transit holds. If all holds are waiting or in transit the "Suspend
all" controls will be hidden.

This patch also adds a missing $KohaDates filter to the "suspended
until" date.

To test, apply the patch and log in to the OPAC as a patron with holds.
Test these conditions:

 - All holds are waiting and/or in transit
   - The "Suspend holds" controls at the bottom of the page should not
     appear.
 - Some holds are waiting and/or in transit
   - The "Suspend holds" controls should appear.

Signed-off-by: Marjorie <marjorie.barry-vila@collecto.ca>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc

index e96a73c..b3bb1cf 100644 (file)
                 </tr>
             </thead>
             <tbody>
+                [% SET all_holds_waiting = 1 %]
                 [% FOREACH HOLD IN HOLDS %]
+                    [% UNLESS ( HOLD.is_waiting || HOLD.is_in_transit ) %]
+                        [% SET all_holds_waiting = 0 %]
+                    [% END %]
                     [% IF ( HOLD.is_waiting ) %]
                         [% IF ( HOLD.is_at_destination ) %]
                             [% IF ( HOLD.is_found ) %]
                                     Item in transit from <b> [% Branches.GetName( transfer.frombranch ) | html %]</b> since
                                     [% transfer.datesent | $KohaDates %]
                                 [% ELSIF ( HOLD.suspend ) %]
-                                    Suspended [% IF ( HOLD.suspend_until ) %] until [% HOLD.suspend_until | html %] [% END %]
+                                    Suspended [% IF ( HOLD.suspend_until ) %] until [% HOLD.suspend_until | $KohaDates %] [% END %]
                                 [% ELSE %]
                                     [% IF HOLD.itemtype %]
                                         Pending for next available item of item type '[% ItemTypes.GetDescription( HOLD.itemtype ) | html %]'
         </table>
 
         [% IF SuspendHoldsOpac and ! onlyinfo %]
-            <div>
-                <form class="form-inline" action="/cgi-bin/koha/opac-modrequest-suspend.pl" method="post">
-                    <button type="submit" name="submit" class="btn" onclick="return confirmDelete(MSG_CONFIRM_SUSPEND_HOLDS);"><i class="fa fa-pause"></i> Suspend all holds</button>
-                    <input type="hidden" name="suspend" value="1" />
+            [% UNLESS ( all_holds_waiting ) %]
+                <div>
+                    <form class="form-inline" id="suspend_all_holds" action="/cgi-bin/koha/opac-modrequest-suspend.pl" method="post">
+                        <button type="submit" id="suspend_all_submit" class="btn"><i class="fa fa-pause"></i> Suspend all holds</button>
+                        <input type="hidden" name="suspend" value="1" />
 
-                    [% IF AutoResumeSuspendedHolds %]
-                        <label for="suspend_until"> until </label>
-                        <input type="text" 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 to suspend indefinitely</a>
-                    [% END %]
-                </form>
-            </div>
-            <br/>
-            <div>
-                <form action="/cgi-bin/koha/opac-modrequest-suspend.pl" method="post">
-                    <button type="submit" name="submit" class="btn" onclick="return confirmDelete(MSG_CONFIRM_RESUME_HOLDS);"><i class="fa fa-play"></i> Resume all suspended holds</button>
-                    <input type="hidden" name="suspend" value="0" />
-                </form>
-            </div>
+                        [% IF AutoResumeSuspendedHolds %]
+                            <label for="suspend_until"> until </label>
+                            <input type="text" 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 to suspend indefinitely</a>
+                        [% END %]
+                    </form>
+                </div>
+                <br/>
+                <div>
+                    <form id="resume_all_holds" action="/cgi-bin/koha/opac-modrequest-suspend.pl" method="post">
+                        <button type="submit" id="resume_all_submit" class="btn"><i class="fa fa-play"></i> Resume all suspended holds</button>
+                        <input type="hidden" name="suspend" value="0" />
+                    </form>
+                </div>
+            [% END %]
         [% END %]
     </div> <!-- / #opac-user-holds -->
 [% END # / #HOLDS.count %]