JBAS-2169 SCKO holds receipt target sorting repair
authorBill Erickson <berickxx@gmail.com>
Wed, 9 Jan 2019 15:59:17 +0000 (10:59 -0500)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Ensure the list of hold targets is in the same order as the user data
array provided by the caller for printing the holds receipt.  This
allows the UI to pass the hold status (queue pos, ready-for-pickup) and
have the values link to the correct hold when compiling the print
template.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm

index a966d74..becdadf 100644 (file)
@@ -1920,6 +1920,18 @@ sub fire_circ_events {
 
     return undef unless @$targets;
 
+    # KCLS JBAS-2169 -- Alternate fix for LP#1370694
+    # Sort targets to match target-id order provided by the caller.
+    # This guarantees correct user-data / target linking for active 
+    # (i.e. print) hooks.
+    my @tmp;
+    for my $id (@$target_ids) {
+        # circ/hold/usr all have an "id" field.
+        my ($target) = grep {$_->id == $id} @$targets;
+        push(@tmp, $target);
+    }
+    $targets = \@tmp;
+
     if ($hook eq 'email.selfcheck.checkout') {
         # KCLS JBAS-1728
         # Avoid firing passive email events here.  Create the events,