Adding experimental OPACShelfBrowser feature -- to try, create a new syspref called...
authorJoshua Ferraro <jmf@liblime.com>
Mon, 17 Mar 2008 01:25:46 +0000 (21:25 -0400)
committerJoshua Ferraro <jmf@liblime.com>
Mon, 17 Mar 2008 01:26:30 +0000 (20:26 -0500)
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/Auth.pm
koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl
opac/opac-detail.pl

index 817ae2e..412b509 100755 (executable)
@@ -299,6 +299,7 @@ sub get_template_and_user {
             opacbookbag            => "" . C4::Context->preference("opacbookbag"),
             TemplateEncoding       => "". C4::Context->preference("TemplateEncoding"),
             AmazonContent          => "" . C4::Context->preference("AmazonContent"),
+            OPACShelfBrowser       => "". C4::Context->preference("OPACShelfBrowser"),
             OPACAmazonSimilarItems => "" . C4::Context->preference("OPACAmazonSimilarItems"),
             LibraryName            => "" . C4::Context->preference("LibraryName"),
             LibraryNameTitle       => "" . $LibraryNameTitle,
index 0784c99..2b9f323 100755 (executable)
@@ -7,8 +7,20 @@
        }); 
 //]]>
 </script>
+<style type="text/css">
+
+#shelfbrowser dl {text-align:center;font-size:.95em;margin-top:25px;}
+#shelfbrowser dt,dd {width:10.5em;float:left;}
+#shelfbrowser dt {margin-bottom:5.5em;}
+#shelfbrowser dd {margin:90px 0 0 -10.5em;}
+#shelfbrowser img {vertical-align:bottom;border:1px solid #999;padding:2px;background:#fff;}
+#shelfbrowser em {display:block;font-weight:bold;margin-bottom:5px;}
+#shelfbrowser dl a:hover img,dl a:active img,dl a:focus img {background:#f33;}
+
+</style>
 </head>
 <body>
+
 <!--TMPL_INCLUDE NAME="masthead.inc" -->
 
 <!-- TMPL_IF NAME="OpacNav" --><div id="doc3" class="yui-t1"><!-- TMPL_ELSE --><div id="doc3" class="yui-t7"><!-- /TMPL_IF -->
        <!-- TMPL_IF NAME="OPACFRBRizeEditions" --><li><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->#editions">Editions</a></li><!-- /TMPL_IF -->
        
        <!-- TMPL_IF NAME="AmazonContent" --><li><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->#amazonreviews">Amazon Reviews</a></li><!-- /TMPL_IF -->
+
 </ul>
 
 <div id="holdings">
         <tr>
             <td><!-- TMPL_IF NAME="imageurl" --><img src="<!-- TMPL_VAR NAME="imageurl" -->" title="<!-- TMPL_VAR name="description" -->" alt="<!-- TMPL_VAR NAME="description" -->" /><!-- /TMPL_IF --> <!-- TMPL_VAR name="description" -->
                     </td>
-            <td><!-- TMPL_VAR NAME="branchname" --> <!-- TMPL_VAR name="location" --> <!-- TMPL_IF NAME="itemcallnumber" --> <!-- TMPL_VAR NAME="itemcallnumber" --><!-- /TMPL_IF --></td>
+            <td><!-- TMPL_VAR NAME="branchname" --> <!-- TMPL_VAR name="location" --> <!-- TMPL_IF NAME="itemcallnumber" --> <!-- TMPL_VAR NAME="itemcallnumber" --><!-- /TMPL_IF --><!-- TMPL_IF NAME="OPACShelfBrowser" -->(<a href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;shelfbrowse_itemnumber=<!-- TMPL_VAR NAME="itemnumber" -->#shelfbrowser">Browse Shelf</a>)<!-- /TMPL_IF --></td>
             <td><!-- TMPL_IF name="bi_notforloan" -->
                     Not for loan
                 <!-- TMPL_ELSE -->
 <!-- TMPL_ELSE -->
 <p>No physical items for this record</p>
 <!-- /TMPL_IF -->
+<!-- TMPL_IF NAME="OpenOPACShelfBrowser" -->
+<div id="shelfbrowser">
+<p>
+<a href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Close Shelf Browser</a>
+Browsing <!-- TMPL_VAR NAME="starting_homebranch" --> <!-- TMPL_VAR NAME="starting_location" -->
+</p>
+        <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="shelfbrowser_prev_biblionumber" -->&amp;shelfbrowse_itemnumber=<!-- TMPL_VAR NAME="shelfbrowser_prev_itemnumber" -->#shelfbrowser">Previous</a>
+        <dl>
+<!-- TMPL_LOOP NAME="PREVIOUS_SHELF_BROWSE" -->
+        <dt> <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;shelfbrowse_itemnumber=<!-- TMPL_VAR NAME="itemnumber" -->#shelfbrowser"><img alt="img" src="http://images.amazon.com/images/P/<!-- TMPL_VAR NAME="isbn"-->.01._SS50_.jpg" /></a></dt><dd><!-- TMPL_VAR NAME="title" --></dd>
+<!-- /TMPL_LOOP -->
+<!-- TMPL_LOOP NAME="NEXT_SHELF_BROWSE" -->
+        <dt> <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;shelfbrowse_itemnumber=<!-- TMPL_VAR NAME="itemnumber" -->#shelfbrowser"><img alt="img" src="http://images.amazon.com/images/P/<!-- TMPL_VAR NAME="isbn"-->.01._SS50_.jpg" /></a></dt><dd><!-- TMPL_VAR NAME="title" --></dd>
+<!-- /TMPL_LOOP -->
+        </dl>
+        <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="shelfbrowser_next_biblionumber" -->&amp;shelfbrowse_itemnumber=<!-- TMPL_VAR NAME="shelfbrowser_next_itemnumber" -->#shelfbrowser">Next</a>
+</div>
+<!-- /TMPL_IF -->
 </div>
 
 <div id="descriptions">
 <p>No other editions found.</p>
 <!-- /TMPL_IF -->
 </div><!-- /TMPL_IF -->
-
-
 <!-- TMPL_IF NAME="AmazonContent" -->
 <!-- Amazon Reviews -->
 <div id="amazonreviews">
 </div>
 <!-- /Amazon Reviews -->
 <!-- /TMPL_IF-->
-</div>
 
 </div>
 </div>
+
+</div>
 </div>
        <!-- TMPL_IF NAME="OpacNav" --><div class="yui-b"><!--TMPL_INCLUDE NAME="navigation.inc" --></div><!-- /TMPL_IF -->
 
index 49690a0..01c5d88 100755 (executable)
@@ -102,8 +102,8 @@ foreach my $itm (@items) {
         $itm->{'description'} = $itemtypes->{$itemtype}->{'description'};
     }
        
-        #get collection code description, too
-        $itm->{'ccode'}  = GetAuthorisedValueDesc('','',   $itm->{'ccode'} ,'','','CCODE');
+    #get collection code description, too
+    $itm->{'ccode'}  = GetAuthorisedValueDesc('','',   $itm->{'ccode'} ,'','','CCODE');
 }
 
 $template->param( norequests => $norequests, RequestOnOpac=>$RequestOnOpac );
@@ -178,7 +178,7 @@ if (C4::Context->preference("OPACFRBRizeEditions")==1) {
     };
     if ($@) { warn "XISBN Failed $@"; }
 }
-
+# Amazon.com Stuff
 if ( C4::Context->preference("OPACAmazonContent") == 1 ) {
     my $similar_products_exist;
     my $amazon_details = &get_amazon_details( $xisbn );
@@ -200,5 +200,61 @@ if ( C4::Context->preference("OPACAmazonContent") == 1 ) {
     $template->param( AMAZON_SIMILAR_PRODUCTS => \@similar_products );
     $template->param( AMAZON_EDITORIAL_REVIEWS    => $editorial_reviews );
 }
+# Shelf Browser Stuff
+if (C4::Context->preference("OPACShelfBrowser")) {
+# pick the first itemnumber unless one was selected by the user
+my $starting_itemnumber = $query->param('shelfbrowse_itemnumber'); # || $items[0]->{itemnumber};
+$template->param( OpenOPACShelfBrowser => 1) if $starting_itemnumber;
+# find the right cn_sort value for this item
+my ($starting_cn_sort, $starting_homebranch, $starting_location);
+my $sth_get_cn_sort = $dbh->prepare("SELECT cn_sort,homebranch,location from items where itemnumber=?");
+$sth_get_cn_sort->execute($starting_itemnumber);
+while (my $result = $sth_get_cn_sort->fetchrow_hashref()) {
+    $starting_cn_sort = $result->{'cn_sort'};
+    $starting_homebranch = $result->{'homebranch'};
+    $starting_location = $result->{'location'};
+}
+
+## List of Previous Items
+# order by cn_sort, which should include everything we need for ordering purposes (though not
+# for limits, those need to be handled separately
+my $sth_shelfbrowse_previous = $dbh->prepare("SELECT * FROM items WHERE CONCAT(cn_sort,itemnumber) <= ? AND homebranch=? AND location=? ORDER BY CONCAT(cn_sort,itemnumber) DESC LIMIT 3");
+$sth_shelfbrowse_previous->execute($starting_cn_sort.$starting_itemnumber, $starting_homebranch, $starting_location);
+my @previous_items;
+while (my $this_item = $sth_shelfbrowse_previous->fetchrow_hashref()) {
+    my $sth_get_biblio = $dbh->prepare("SELECT biblio.*,biblioitems.isbn AS isbn FROM biblio LEFT JOIN biblioitems ON biblio.biblionumber=biblioitems.biblionumber WHERE biblio.biblionumber=?");
+    $sth_get_biblio->execute($this_item->{biblionumber});
+    while (my $this_biblio = $sth_get_biblio->fetchrow_hashref()) {
+        $this_item->{'title'} = $this_biblio->{'title'};
+        $this_item->{'isbn'} = $this_biblio->{'isbn'};
+    }
+    unshift @previous_items, $this_item;
+}
+my $throwaway = pop @previous_items;
+## List of Next Items
+my $sth_shelfbrowse_next = $dbh->prepare("SELECT * FROM items WHERE CONCAT(cn_sort,itemnumber) >= ? AND homebranch=? AND location=? ORDER BY CONCAT(cn_sort,itemnumber) ASC LIMIT 3");
+$sth_shelfbrowse_next->execute($starting_cn_sort.$starting_itemnumber, $starting_homebranch, $starting_location);
+my @next_items;
+while (my $this_item = $sth_shelfbrowse_next->fetchrow_hashref()) {
+    my $sth_get_biblio = $dbh->prepare("SELECT biblio.*,biblioitems.isbn AS isbn FROM biblio LEFT JOIN biblioitems ON biblio.biblionumber=biblioitems.biblionumber WHERE biblio.biblionumber=?");
+    $sth_get_biblio->execute($this_item->{biblionumber});
+    while (my $this_biblio = $sth_get_biblio->fetchrow_hashref()) {
+        $this_item->{'title'} = $this_biblio->{'title'};
+        $this_item->{'isbn'} = $this_biblio->{'isbn'};
+    }
+    push @next_items, $this_item;
+}
+
+$template->param(
+    starting_homebranch => $starting_homebranch,
+    starting_location => $starting_location,
+    shelfbrowser_prev_itemnumber => $previous_items[0]->{itemnumber},
+    shelfbrowser_next_itemnumber => $next_items[-1]->{itemnumber},
+    shelfbrowser_prev_biblionumber => $previous_items[0]->{biblionumber},
+    shelfbrowser_next_biblionumber => $next_items[-1]->{biblionumber},
+    PREVIOUS_SHELF_BROWSE => \@previous_items,
+    NEXT_SHELF_BROWSE => \@next_items,
+);
+}
 
 output_html_with_http_headers $query, $cookie, $template->output;