KMAIN-1829 Bib Call Number on Holds
authorDan Reuther <dreuther@catalystitservices.com>
Tue, 29 Sep 2015 16:26:52 +0000 (12:26 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Problem: Call Number wouldn't show up in list view of
patron holds screen when status was "Waiting for Copy."

Solution: Add check to Call Number column for specific
copy, and if nonexistant, pull from MARC info for selected
item.

Signed-off-by: Kyle Huckins <khuckins@catalystdevworks.com>
---

Modified by berick to avoid bib call number / MARC processing when a
call number is available, since this is already a heavy API call.
Replaced some tabs.  Added some comments.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
Open-ILS/xul/staff_client/server/patron/holds.js

index a0fb2c5..131e512 100644 (file)
@@ -20,6 +20,8 @@ use strict; use warnings;
 use OpenILS::Application::AppUtils;
 use DateTime;
 use Data::Dumper;
+use MARC::Record;
+use MARC::File::XML (BinaryEncoding => 'UTF-8');
 use OpenSRF::EX qw(:try);
 use OpenILS::Perm;
 use OpenILS::Event;
@@ -3461,6 +3463,21 @@ sub uber_hold_impl {
 
     my( $mvr, $volume, $copy, $issuance, $part, $bre ) = find_hold_mvr($e, $hold, $args);
 
+    # --------------------
+    # KCLS - include bib call number if no asset.call_number is available
+    my $bibcn;
+    if (!$volume) {
+        my $marc;
+        eval { $marc = MARC::Record->new_from_xml($bre->marc()) };
+        if ($@) {
+            $logger->error(
+                "Error processing MARC record for bib ".$bre->id." $@"); 
+        } else {
+            $bibcn = $marc->subfield('092',"a"); 
+        }
+    }
+    # --------------------
+
     flesh_hold_notices([$hold], $e) unless $args->{suppress_notices};
     flesh_hold_transits([$hold]) unless $args->{suppress_transits};
 
@@ -3470,6 +3487,8 @@ sub uber_hold_impl {
     my $resp = {
         hold    => $hold,
         bre_id  => $bre->id,
+        # Allows data from the bib call number to be used
+        ($bibcn    ? (bibcn          => $bibcn)    : ()), 
         ($copy     ? (copy           => $copy)     : ()),
         ($volume   ? (volume         => $volume)   : ()),
         ($issuance ? (issuance       => $issuance) : ()),
index 35bf91a..de69e91 100644 (file)
@@ -94,7 +94,19 @@ patron.holds.prototype = {
                                     row.my.status = blob.status;
                                     row.my.ahr.status( blob.status );
                                     row.my.acp = blob.copy;
-                                    row.my.acn = blob.volume;
+                                    // KCLS --------------------------
+                                    // If we're waiting for Copy, create a new ACN object and
+                                    // generate its data using the bib call number.
+                                    if (!blob.volume) {
+                                        var bibacn = new acn();
+                                        bibacn.id("No Copy"); //Mocks an ID, required for the Call Number to show.
+                                        bibacn.label("Bib: " + blob.bibcn);
+                                        bibacn.prefix(-1); //Prevents acnp errors
+                                        bibacn.suffix(-1); //Prevents acns errors
+                                        row.my.acn = bibacn;
+                                    } else { //Otherwise, use the data from the current copy.
+                                        row.my.acn = blob.volume;
+                                    }
                                     row.my.mvr = blob.mvr;
                                     row.my.part = blob.part;
                                     if (blob.part) {