adding statcats to htmlholdings
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 16 Jun 2006 03:05:33 +0000 (03:05 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 16 Jun 2006 03:05:33 +0000 (03:05 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@4643 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm
Open-ILS/xsl/MARC21slim2HTMLCard-holdings.xsl

index 132858e..e1c0d28 100644 (file)
@@ -177,7 +177,14 @@ sub new_record_holdings {
        my $tree = $_storage->request(
                "open-ils.cstore.direct.biblio.record_entry.retrieve",
                $bib,
-               {flesh => 3, flesh_fields => [qw/call_numbers copies location status owning_lib circ_lib/] }
+               { flesh         => 5,
+                 flesh_fields  => {
+                                       bre     => [qw/call_numbers/],
+                                       acn     => [qw/copies owning_lib/],
+                                       acp     => [qw/location status circ_lib stat_cat_entries notes/],
+                                       asce    => [qw/stat_cat/],
+                               }
+               }
        )->gather(1);
 
        my ($year,$month,$day) = reverse( (localtime)[3,4,5] );
@@ -220,18 +227,24 @@ sub new_record_holdings {
 
                        my $cp_bc = $cp->barcode;
 
-                       $xml .= "<hold:copy id='$cp_tag' barcode='$cp_bc'><hold:status>$cp_stat</hold:status><hold:location>$cp_loc</hold:location><hold:circlib>$cp_lib</hold:circlib><hold:notes>";
+                       $xml .= "<hold:copy id='$cp_tag' barcode='$cp_bc'><hold:status>$cp_stat</hold:status>".
+                               "<hold:location>$cp_loc</hold:location><hold:circlib>$cp_lib</hold:circlib><hold:notes>";
 
-                       #for my $note ( @{$_storage->request( "open-ils.cstore.direct.asset.copy_note.search.atomic" => {owning_copy => $cp->id, pub => "t" })->gather(1)} ) {
-                       #       $xml .= sprintf('<hold:note date="%s" title="%s">%s</hold:note>',$note->create_date, escape($note->title), escape($note->value));
+                       #if ($cp->notes) {
+                       #       for my $note ( @{$cp->notes} ) {
+                       #               next unless ( $sce->stat_cat->pub eq 't' );
+                       #               $xml .= sprintf('<hold:note date="%s" title="%s">%s</hold:note>',$note->create_date, escape($note->title), escape($note->value));
+                       #       }
                        #}
 
                        $xml .= "</hold:notes><hold:statcats>";
 
-                       #for my $sce ( @{$_storage->request( "open-ils.cstore.direct.asset.stat_cat_entry_copy_map.search.atomic" => { owning_copy => $cp->id })->gather(1)} ) {
-                       #       my $sc = $holdings_data_cache{statcat}{$sce->stat_cat_entry};
-                       #       $xml .= sprintf('<hold:statcat>%s</hold:statcat>',escape($sc->value));
-                       #}
+                       if ($cp->stat_cat_entries) {
+                               for my $sce ( @{$cp->stat_cat_entries} ) {
+                                       next unless ( $sce->stat_cat->opac_visible eq 't' );
+                                       $xml .= sprintf('<hold:statcat name="%s">%s</hold:statcat>',escape($sce->stat_cat->name) ,escape($sce->value));
+                               }
+                       }
 
                        $xml .= "</hold:statcats></hold:copy>";
                }
index 999b2a2..ef327cb 100755 (executable)
   </xsl:template>
 
   <xsl:template match="hold:copy">
-      <li> <xsl:value-of select="./@barcode"/>
+      <li> <xsl:value-of select="@barcode"/>
         <ul>
          <li>Circulating from <b><xsl:value-of select="hold:circlib"/></b></li>
          <li>Located at <b><xsl:value-of select="hold:location"/></b></li>
          <li>Status is <b><xsl:value-of select="hold:status"/></b></li>
+         <xsl:apply-templates select="hold:statcats"/>
        </ul>
       </li>
   </xsl:template>
 
+  <xsl:template match="hold:statcats">
+    <xsl:if test="count(hold:statcat) &gt; 0">
+      <li>Statistical Catagories
+        <ul>
+        <xsl:apply-templates select="hold:statcat">
+          <xsl:sort select="@name"/>
+        </xsl:apply-templates>
+        </ul>
+      </li>
+    </xsl:if>
+  </xsl:template>
+
+  <xsl:template match="hold:statcat">
+      <li> <b><xsl:value-of select="@name"/></b>: <xsl:value-of select="."/> </li>
+  </xsl:template>
+
   <xsl:template match="marc:controlfield">
       <span class="oclc">#<xsl:value-of select="substring(.,4)"/></span>
   </xsl:template>