TPAC: Display monograph parts
authorDan Scott <dan@coffeecode.net>
Fri, 23 Dec 2011 06:56:02 +0000 (01:56 -0500)
committerThomas Berezansky <tsbere@mvlc.org>
Fri, 23 Dec 2011 13:19:51 +0000 (08:19 -0500)
In search results and record details, display monograph parts if
associated with a copy. Uses unapi for search results and json_query for
record details. Only generates the "Part" column in the copy table if
that record actually has a monograph part; otherwise the column is not
generated.

Signed-off-by: Dan Scott <dan@coffeecode.net>
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/copy_table.tt2
Open-ILS/src/templates/opac/parts/result/table.tt2

index 113da1d..97a6fa5 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,acnp,acns}'});
+    my (undef, @rec_data) = $self->get_records_and_facets([$rec_id], undef, {flesh => '{holdings_xml,bmp,mra,acp,acnp,acns}'});
     $ctx->{bre_id} = $rec_data[0]->{id};
     $ctx->{marc_xml} = $rec_data[0]->{marc_xml};
 
@@ -159,6 +159,9 @@ sub mk_copy_query {
             acns => [
                 {column => 'label', alias => 'call_number_suffix_label'},
                 {column => 'id', alias => 'call_number_suffix'}
+            ],
+            bmp => [
+                {column => 'label', alias => 'part_label'},
             ]
         },
 
@@ -177,7 +180,13 @@ sub mk_copy_query {
                 },
                 acpl => {},
                 ccs => {},
-                aou => {}
+                aou => {},
+                acpm => {
+                    type => 'left',
+                    join => {
+                        bmp => { type => 'left' }
+                    }
+                }
             }
         },
 
index f803f7f..0db757b 100644 (file)
@@ -285,7 +285,7 @@ sub load_rresults {
     my ($facets, @data) = $self->get_records_and_facets(
         $rec_ids, $results->{facet_key}, 
         {
-            flesh => '{holdings_xml,mra,acp,acnp,acns}',
+            flesh => '{holdings_xml,mra,acp,acnp,acns,bmp}',
             site => $site,
             depth => $depth
         }
@@ -400,7 +400,7 @@ sub item_barcode_shortcut {
         }
 
         my ($facets, @data) = $self->get_records_and_facets(
-            $rec_ids, undef, {flesh => "{holdings_xml,mra,acnp,acns}"}
+            $rec_ids, undef, {flesh => "{holdings_xml,mra,acnp,acns,bmp}"}
         );
 
         $self->ctx->{records} = [@data];
index bb3857a..b18e678 100644 (file)
             ELSE;
                 copies = volume.findnodes('./*[local-name()="copies"]/*[local-name()="copy"]');
                 FOR copy IN copies;
+                    parts = copy.findnodes('./*[local-name()="monograph_parts"]/*[local-name()="monograph_part"]');
+                    FOREACH part IN parts;
+                        part_label = part.getAttribute('label');
+                        LAST IF part_label != '';
+                    END;
                     # Check copy visibility
                     cp.deleted = copy.getAttribute('deleted');    
                     cp.visible = copy.getAttribute('opac_visible');
 
                     holding = {
                         label => vol.label,
+                        part_label => part_label,
                         location => loc.textContent,
                         library => circlib.textContent,
                         status => status.textContent
                         barcode => copy.getAttribute('barcode')
                     };
                     args.holdings.push(holding);
+                    part_label = '';
                 END;
             END;
         END;
index 4255e13..f6af5b1 100644 (file)
@@ -1,8 +1,19 @@
+[%-
+FOREACH copy_info IN ctx.copies;
+    IF copy_info.part_label != '';
+        has_parts = 'true';
+        LAST;
+    END;
+END;
+%]
 <table cellpadding="0" cellspacing="0" border="0" width="100%" id="rdetails_status">
     <thead>
         <tr>
             <th id='copy_header_library'>[% l("Location") %]</th>
             <th id='copy_header_callnmber'>[% l("Call Number") %]</th>
+            [%- IF has_parts == 'true' %]
+            <th id='copy_header_part'>[% l("Part") %]</th>
+            [%- END %]
             <th id='copy_header_barcode'>[% l("Barcode") %]</th>
             <th id='copy_header_shelfloc'>[% l("Shelving Location") %]</th>
             [%- IF ctx.is_staff %]
@@ -38,6 +49,9 @@
             -%]
             </td>
             <td header='copy_header_callnumber'>[% callnum | html %]</td>
+            [%- IF has_parts == 'true' %]
+            <td header='copy_header_part'>[% copy_info.part_label | html %]</td>
+            [%- END %]
             <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 %]
index 83a877f..a5a9ea3 100644 (file)
                                                                 <td><a href="[% uri.href %]">[% uri.link | html %]</a>[% ' - ' _ uri.note | html IF uri.note %]</td>
                                                             </tr>
                                                             [% END %]
-                                                            [% IF args.holdings.size > 0 %]
+                                                            [%- IF args.holdings.size > 0;
+                                                                FOREACH copy IN args.holdings;
+                                                                    IF copy.part_label != '';
+                                                                        has_parts = 'true';
+                                                                        LAST;
+                                                                    END;
+                                                                END;
+                                                            %]
                                                             <tr name='bib_cn_list' class='result_table_title_cell'>
                                                                 <td colspan='2'>
                                                                     <table class='result_holdings_table'>
                                                                             <th>[% l('Library') %]</th>
                                                                             <th>[% l('Shelving location') %]</th>
                                                                             <th>[% l('Call number') %]</th>
+                                                                            [%- IF has_parts == 'true'; %]
+                                                                            <th>[% l('Part') %]</th>
+                                                                            [%- END %]
                                                                             <th>[% l('Status') %]</th>
                                                                         </tr></thead>
                                                                         <tbody>
                                                                             <td>[% copy.library | html %]</td>
                                                                             <td>[% copy.location | html %]</td>
                                                                             <td>[% copy.label | html %]</td>
+                                                                            [%- IF has_parts == 'true'; %]
+                                                                            <td>[% copy.part_label %]</td>
+                                                                            [%- END %]
                                                                             <td>[% copy.status | html %]</td>
                                                                         </tr>
                                                                 [% END %]
                                                                     </table>
                                                                 </td>
                                                             </tr>
-                                                        [% END %]
+                                                            [%- has_parts = 'false';
+                                                                END;
+                                                             %]
                                                         [% END %] <!-- END detail_record_view -->
                                                     </table>
                                                     [% PROCESS "opac/parts/result/copy_counts.tt2" %]