From f51890c4073ac5527a0f79dd705ce724f9341963 Mon Sep 17 00:00:00 2001 From: Joshua Ferraro Date: Sun, 16 Mar 2008 21:25:46 -0400 Subject: [PATCH] Adding experimental OPACShelfBrowser feature -- to try, create a new syspref called OPACShelfBrowser, and set it to 1 Signed-off-by: Joshua Ferraro --- C4/Auth.pm | 1 + .../prog/en/modules/opac-detail.tmpl | 38 ++++++++++-- opac/opac-detail.pl | 62 ++++++++++++++++++- 3 files changed, 94 insertions(+), 7 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 817ae2e0b8..412b509c54 100755 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -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, diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl index 0784c99cc1..2b9f323b77 100755 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl @@ -7,8 +7,20 @@ }); //]]> + +
@@ -226,6 +238,7 @@
  • #editions">Editions
  • #amazonreviews">Amazon Reviews
  • +
    @@ -403,8 +434,6 @@

    No other editions found.

    - -
    @@ -434,9 +463,10 @@
    -
    + +
    diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 49690a0e5d..01c5d88256 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -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; -- 2.20.1