From b4c63e9a02fbce2109373d0eb043b9dc54d90825 Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Sat, 9 Sep 2017 15:56:59 -0400 Subject: [PATCH] Change the logic for trigger multiple holds. --- .../lib/OpenILS/WWW/EGCatLoader/Account.pm | 26 ++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-) 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 bfea5a1463..174615c555 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm @@ -1004,7 +1004,7 @@ sub load_place_hold { 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)) { + if (scalar(@targets) == 1 && !$parts[0]) { # 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 @@ -1258,15 +1258,23 @@ sub load_place_hold { # like a real P-type hold. my (@p_holds, @t_holds); - for my $idx (0..$#parts) { - my $hdata = $hold_data[$idx]; - if (my $part = $parts[$idx]) { - $hdata->{target_id} = $part; - $hdata->{selected_part} = $part; - push(@p_holds, $hdata); - } else { - push(@t_holds, $hdata); + # Now that we have the num_copies field for mutliple title and + # metarecord hold placement, the number of holds and parts + # arrays can get out of sync. We only want to parse out parts + # if the numbers are equal. + if ($#hold_data == $#parts) { + for my $idx (0..$#parts) { + my $hdata = $hold_data[$idx]; + if (my $part = $parts[$idx]) { + $hdata->{target_id} = $part; + $hdata->{selected_part} = $part; + push(@p_holds, $hdata); + } else { + push(@t_holds, $hdata); + } } + } else { + @t_holds = @hold_data; } $self->apache->log->warn("$#parts : @t_holds"); -- 2.11.0