Commit what I've done so far today.
authorJason Stephenson <jason@sigio.com>
Sun, 13 Aug 2017 17:49:38 +0000 (13:49 -0400)
committerJason Stephenson <jason@sigio.com>
Fri, 29 Sep 2017 22:46:52 +0000 (18:46 -0400)
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/src/templates/opac/parts/multi_hold_select.tt2 [new file with mode: 0644]
Open-ILS/src/templates/opac/parts/place_hold.tt2

index 8295e12..bfea5a1 100644 (file)
@@ -1000,6 +1000,23 @@ sub load_place_hold {
 
     return $self->generic_redirect unless @targets;
 
+    # Check for multiple hold placement via the num_copies widget.
+    my $num_copies = int($cgi->param('num_copies')); # if undefined, we get 0.
+    if ($num_copies > 1) {
+        # Only if we have 1 hold target and no parts.
+        if (scalar(@targets) == 1 && !scalar(@parts)) {
+            # Also, only for M and T holds.
+            if ($ctx->{hold_type} eq 'M' || $ctx->{hold_type} eq 'T') {
+                # Add the extra holds to @targets. NOTE: We start with
+                # 1 and go to < $num_copies to account for the
+                # existing target.
+                for (my $i = 1; $i < $num_copies; $i++) {
+                    push(@targets, $targets[0]);
+                }
+            }
+        }
+    }
+
     $logger->info("Looking at hold_type: " . $ctx->{hold_type} . " and targets: @targets");
 
     $ctx->{staff_recipient} = $self->editor->retrieve_actor_user([
diff --git a/Open-ILS/src/templates/opac/parts/multi_hold_select.tt2 b/Open-ILS/src/templates/opac/parts/multi_hold_select.tt2
new file mode 100644 (file)
index 0000000..020245b
--- /dev/null
@@ -0,0 +1,15 @@
+[%  # Check if we need to do anything.
+    hold_type = CGI.param('hold_type');
+    max_holds = ctx.get_org_setting(ctx.default_pickup_lib, 'circ.holds.max_duplicate_holds');
+    can_dup = ctx.has_perm('CREATE_DUPLICATE_HOLDS', ctx.default_pickup_lib);
+    IF ctx.hold_data.size == 1 && (hold_type == 'M' || hold_type == 'T') && max_holds && max_holds > 1 && can_dup;
+%]
+<p>
+<label for="num_copies">[% l('Number of copies') %]</label>
+<select id="num_copies" name="num_copies" title="[% l('Number of copies') %]">
+[% FOR num IN [1..max_holds] %]
+<option value="[% num %]">[% num %]</option>
+[% END %]
+</select>
+</p>
+[% END %]
index 73192ba..2286852 100644 (file)
@@ -151,6 +151,7 @@ function toggleActivationDate() {
                         <input type='hidden' name='part' value=''/>
                         [% END %]
                     [% END %]
+                   [% INCLUDE "opac/parts/multi_hold_select.tt2" IF NOT (this_hold_disallowed AND hdata.part_required); %]
                     [% IF NOT metarecords.disabled %]
                         [% IF CGI.param('hold_type') == 'T' AND hdata.record.metarecord AND !hdata.part_required %]
                         <!-- Grab the bre_id so that we can restore it if user accidentally clicks advanced options -->