Bug 1003 Added lists to bib details pages
authorNicole Engard <nengard@gmail.com>
Thu, 27 Aug 2009 15:22:15 +0000 (11:22 -0400)
committerGalen Charlton <gmcharlt@gmail.com>
Sun, 6 Sep 2009 16:58:36 +0000 (12:58 -0400)
This patch adds links to all public lists that a bib
record belongs to to the detail page in the OPAC and
the Inranet. If the item is not in any lists nothing
shows on the detail page.  The same goes if virtualshelves
is turned OFF.

Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
C4/VirtualShelves.pm
catalogue/detail.pl
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl
koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl
opac/opac-detail.pl

index 76786e9..5047550 100644 (file)
@@ -44,6 +44,7 @@ BEGIN {
             &ModShelf
             &ShelfPossibleAction
             &DelFromShelf &DelShelf
+            &GetBibliosShelves
        );
         @EXPORT_OK = qw(
             &GetShelvesSummary &GetRecentShelves
@@ -532,6 +533,24 @@ sub DelShelf {
        return $sth->execute(shift);
 }
 
+=item GetBibShelves
+
+This finds all the lists that this bib record is in.
+
+=cut
+
+sub GetBibliosShelves {
+  my ( $biblionumber )  = @_;
+  my $dbh = C4::Context->dbh;
+  my $sth = $dbh->prepare('SELECT vs.shelfname, vs.shelfnumber FROM virtualshelves vs LEFT JOIN virtualshelfcontents vc ON (vs.shelfnumber= vc.shelfnumber) WHERE vs.category != 1 AND vc.biblionumber= ?');
+  $sth->execute( $biblionumber );
+  my @lists;
+  while (my $data = $sth->fetchrow_hashref){
+    push @lists,$data;
+  }
+  return \@lists;
+}
+
 =item RefreshShelvesSummary
 
        ($total, $pubshelves, $barshelves) = RefreshShelvesSummary($sessionID, $loggedinuser, $row_count);
index 9c9ebe9..6c2afdc 100755 (executable)
@@ -35,6 +35,7 @@ use C4::Serials;
 use C4::XISBN qw(get_xisbns get_biblionumber_from_isbn);
 use C4::External::Amazon;
 use C4::Search;                # enabled_staff_search_views
+use C4::VirtualShelves;
 
 # use Smart::Comments;
 
@@ -225,6 +226,12 @@ $template->param(
 
 # $debug and $template->param(debug_display => 1);
 
+# Lists
+
+if (C4::Context->preference("virtualshelves") ) {
+   $template->param( 'GetShelves' => GetBibliosShelves( $biblionumber ) );
+}
+
 # XISBN Stuff
 if (C4::Context->preference("FRBRizeEditions")==1) {
     eval {
index e330f7f..251c6df 100644 (file)
@@ -100,6 +100,7 @@ function verify_images() {
             <!-- /TMPL_LOOP --></ul>
 </li>
     <!-- /TMPL_IF -->
+    
     <!-- TMPL_IF name="OpacUrl" -->
        <li><strong>OPAC View:</strong>
        <a href="http://<!-- TMPL_VAR name="OpacUrl" -->/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->" target="_blank">Open in new window</a>
@@ -150,6 +151,16 @@ function verify_images() {
                 <!-- /TMPL_LOOP -->
             </li>
         <!-- /TMPL_IF -->
+        <!--This grabs all of the lists a bib record appears in -->
+        <!-- TMPL_IF NAME="GetShelves" -->
+               <li><strong>Lists that include this title: </strong>
+               <ul>
+               <!-- TMPL_LOOP NAME="GetShelves" -->
+                       <li><a href="/cgi-bin/koha/virtualshelves/shelves.pl?viewshelf=<!-- TMPL_VAR NAME="shelfnumber" -->"><!-- TMPL_VAR NAME="shelfname" --></a></li>
+               <!-- /TMPL_LOOP -->
+               </ul>
+               </li>
+        <!-- /TMPL_IF -->
         </ul>
 </div>
 </div>
index 12a5003..ae40837 100644 (file)
@@ -216,6 +216,15 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
     </span>
 <!-- /TMPL_IF --> 
 
+<!--This grabs all of the lists a bib record appears in -->
+<!-- TMPL_IF NAME="GetShelves" -->
+       <span class="results_summary"><span class="label">List(s) this item appears in: </span>
+       <!-- TMPL_LOOP NAME="GetShelves" -->
+               <a href="/cgi-bin/koha/opac-shelves.pl?viewshelf=<!-- TMPL_VAR NAME="shelfnumber" -->&sortfield=title"><!-- TMPL_VAR NAME="shelfname" --></a> 
+               <!-- TMPL_IF NAME="__LAST__" --><!-- TMPL_ELSE -->|<!-- /TMPL_IF -->
+       <!-- /TMPL_LOOP -->
+       </span>
+<!-- /TMPL_IF -->
 
     <!-- TMPL_IF NAME="TagsShowOnDetail" -->
         <div class="results_summary">
index dd73cfc..cae305a 100755 (executable)
@@ -38,6 +38,7 @@ use C4::External::Syndetics qw(get_syndetics_index get_syndetics_summary get_syn
 use C4::Review;
 use C4::Serials;
 use C4::Members;
+use C4::VirtualShelves;
 use C4::XSLT;
 
 BEGIN {
@@ -266,6 +267,13 @@ $template->param(
     loggedincommenter   => $loggedincommenter
 );
 
+# Lists
+
+if (C4::Context->preference("virtualshelves") ) {
+   $template->param( 'GetShelves' => GetBibliosShelves( $biblionumber ) );
+}
+
+
 # XISBN Stuff
 if (C4::Context->preference("OPACFRBRizeEditions")==1) {
     eval {