From b3d4bb5f364cca24d02b64ace7de884290f21992 Mon Sep 17 00:00:00 2001
From: Bill Ott <bott@grpl.org>
Date: Tue, 20 Aug 2013 11:19:27 -0400
Subject: [PATCH] LP 1189989: Add suspend option when placing hold

Return of an option from JSPAC, the ability to immediately suspend a
hold when it's placed.

TODO: As noted in the code for editing a hold, a calendar selection
would be preferred to requiring users to enter a valid date manually.

This commit was a patch submitted by Bill Ott to Launchpad in August
2013.  Jason Stephenson applied the patch on April 22, 2017 and
resolved conflicts caused by the addition of a metarecords hold
feature in the TPAC.  The revised patch was committed with the
original author and commit timestamp.

Signed-off-by: Bill Ott <bott@grpl.org>
Signed-off-by: Jason Stephenson <jason@sigio.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
---
 Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm | 9 ++++++++-
 Open-ILS/src/templates/opac/parts/place_hold.tt2             | 8 ++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
index 9f96bfd3f2..91edcb6c3c 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
@@ -1289,6 +1289,11 @@ sub attempt_hold_placement {
 
     my @create_targets = map {$_->{target_id}} (grep { !$_->{hold_failed} } @hold_data);
 
+    my $thaw_date;
+    if ($cgi->param('hold_suspend') && $cgi->param('thaw_date') =~ m:^(\d{2})/(\d{2})/(\d{4})$:){
+        $thaw_date = "$3-$1-$2";
+    }
+
     if(@create_targets) {
 
         # holdable formats may be different for each MR hold.
@@ -1307,7 +1312,9 @@ sub attempt_hold_placement {
                 patronid => $usr,
                 pickup_lib => $pickup_lib,
                 hold_type => $hold_type,
-                holdable_formats_map => $holdable_formats
+                holdable_formats_map => $holdable_formats,
+                frozen => $cgi->param('hold_suspend'),
+                thaw_date => $thaw_date
             }),
             \@create_targets
         );
diff --git a/Open-ILS/src/templates/opac/parts/place_hold.tt2 b/Open-ILS/src/templates/opac/parts/place_hold.tt2
index 8bf17134e6..0a759f02d3 100644
--- a/Open-ILS/src/templates/opac/parts/place_hold.tt2
+++ b/Open-ILS/src/templates/opac/parts/place_hold.tt2
@@ -202,6 +202,14 @@
                 </blockquote>
                 [% END %]
             </blockquote>
+            <blockquote>
+                <input type="checkbox" name="hold_suspend" value="t"/>[% l('Suspend This Hold?') %]
+            </blockquote>
+            <blockquote>
+                [% l('If suspended, activate on') %]
+		<input type="text" name="thaw_date" value="[% thaw_date | html %]" />
+		<em>[% l('Enter date in MM/DD/YYYY format') %]</em>
+            </blockquote>
         </p>
         <input id="place_hold_submit" type="submit" name="submit" 
             value="[% l('Submit') %]" title="[% l('Submit') %]"
-- 
2.11.0