TPAC: Add prefixes and suffixes to call number displays
authorDan Scott <dscott@laurentian.ca>
Tue, 6 Dec 2011 07:16:16 +0000 (02:16 -0500)
committerThomas Berezansky <tsbere@mvlc.org>
Wed, 14 Dec 2011 18:55:29 +0000 (13:55 -0500)
Call numbers can be associated with prefixes and suffixes meant for
display purposes; display these with the call numbers in search results
and record details.

Thanks to Lebbeous and Bill for the assist in sorting out the remaining
portion of the hairy json_query for the record display.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>

Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
Open-ILS/src/templates/opac/parts/misc_util.tt2
Open-ILS/src/templates/opac/parts/record/summary.tt2

index 0f714c9..113da1d 100644 (file)
@@ -37,7 +37,7 @@ sub load_record {
         $self->mk_copy_query($rec_id, $org, $depth, $copy_limit, $copy_offset)
     );
 
-    my (undef, @rec_data) = $self->get_records_and_facets([$rec_id], undef, {flesh => '{holdings_xml,mra,acp}'});
+    my (undef, @rec_data) = $self->get_records_and_facets([$rec_id], undef, {flesh => '{holdings_xml,mra,acp,acnp,acns}'});
     $ctx->{bre_id} = $rec_data[0]->{id};
     $ctx->{marc_xml} = $rec_data[0]->{marc_xml};
 
@@ -152,13 +152,24 @@ sub mk_copy_query {
                 {column => 'id', alias => 'call_number'}
             ],
             circ => ['due_date'],
+            acnp => [
+                {column => 'label', alias => 'call_number_prefix_label'},
+                {column => 'id', alias => 'call_number_prefix'}
+            ],
+            acns => [
+                {column => 'label', alias => 'call_number_suffix_label'},
+                {column => 'id', alias => 'call_number_suffix'}
+            ]
         },
 
         from => {
             acp => {
-                acn => {
-                    join => {bre => {filter => {id => $rec_id }}},
-                    filter => {deleted => 'f'}
+                acn => { 
+                    join => { 
+                        acnp => { fkey => 'prefix' },
+                        acns => { fkey => 'suffix' }
+                    },
+                    filter => [{deleted => 'f'}, {record => $rec_id}],
                 },
                 circ => { # If the copy is circulating, retrieve the open circ
                     type => 'left',
@@ -170,7 +181,9 @@ sub mk_copy_query {
             }
         },
 
-        where => {'+acp' => {deleted => 'f' }},
+        where => {
+            '+acp' => {deleted => 'f' }
+        },
 
         order_by => [
             {class => 'aou', field => 'name'}, 
index 93f90b6..cfaef71 100644 (file)
@@ -257,7 +257,7 @@ sub load_rresults {
     my ($facets, @data) = $self->get_records_and_facets(
         $rec_ids, $results->{facet_key}, 
         {
-            flesh => '{holdings_xml,mra,acp}',
+            flesh => '{holdings_xml,mra,acp,acnp,acns}',
             site => $site,
             depth => $depth
         }
@@ -362,7 +362,7 @@ sub item_barcode_shortcut {
         }
 
         my ($facets, @data) = $self->get_records_and_facets(
-            $rec_ids, undef, {flesh => "{holdings_xml,mra}"}
+            $rec_ids, undef, {flesh => "{holdings_xml,mra,acnp,acns}"}
         );
 
         $self->ctx->{records} = [@data];
@@ -449,7 +449,7 @@ sub marc_expert_search {
     }
 
     my ($facets, @data) = $self->get_records_and_facets(
-        $self->ctx->{ids}, undef, {flesh => "{holdings_xml,mra}"}
+        $self->ctx->{ids}, undef, {flesh => "{holdings_xml,mra,acnp,acns}"}
     );
 
     $self->ctx->{records} = [@data];
index db30d6b..6efc585 100644 (file)
 
             # Check volume visibility - could push this into XPath
             vol.label = volume.getAttribute('label');
+
+            # Prepend prefix, if any
+            prefix = volume.findnodes('./*[local-name()="call_number_prefix"][@ident!="-1"]');
+            IF prefix.getAttribute('label') != '';
+                vol.label = prefix.getAttribute('label') _ " " _ vol.label;
+            END;
+
+            # Append prefix, if any
+            suffix = volume.findnodes('./*[local-name()="call_number_suffix"][@ident!="-1"]');
+            IF suffix.getAttribute('label') != '';
+                vol.label = vol.label _ " " _ suffix.getAttribute('label');
+            END;
+
             vol.id = volume.getAttribute('id');
             NEXT IF volume.getAttribute('opac_visible') == 'false';
             NEXT IF volume.getAttribute('deleted') == 'true';
index 540c30d..d2e7cd1 100644 (file)
@@ -118,7 +118,19 @@ IF num_uris > 0;
     <tbody class="copy_details_table">
         [%- last_cn = 0;
         FOR copy_info IN ctx.copies;
-            NEXT IF copy_info.call_number_label == '##URI##' %]
+            callnum = copy_info.call_number_label;
+            NEXT IF callnum == '##URI##';
+
+            callnum_prefix = copy_info.call_number_prefix_label;
+            IF callnum_prefix != "";
+                callnum = callnum_prefix _ " " _ callnum;
+            END;
+
+            callnum_suffix = copy_info.call_number_suffix_label;
+            IF callnum_suffix != "";
+                callnum = callnum  _ " " _ callnum_suffix;
+            END;
+        -%]
         <tr>
             <td header='copy_header_library'>
             [%-
@@ -126,7 +138,7 @@ IF num_uris > 0;
                 org_name | html
             -%]
             </td>
-            <td header='copy_header_callnumber'>[% copy_info.call_number_label | html %]</td>
+            <td header='copy_header_callnumber'>[% callnum | html %]</td>
             <td header='copy_header_barcode'>[% copy_info.barcode | html %]</td>
             <td header='copy_header_shelfloc'>[% copy_info.copy_location | html %]</td>
             [%- IF ctx.is_staff %]