If the items.location field was NULL, then the current
SQL query would produce no results. I have turned this
into a conditional block that removes the location condition
in the query if the location is not specified.
In addition, there was a small change to opac-detail.tmpl
that changed Library to Shelves when the shelf browser was
open. This removes a potential redundant Library Library
display if Library is contained in the starting_homebranch.
---
.../opac-tmpl/prog/en/modules/opac-detail.tmpl | 2 +-
opac/opac-detail.pl | 34 +++++++++++++++++--
2 files changed, 31 insertions(+), 5 deletions(-)
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 c4123e8..ab99bea 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl
@@ -358,7 +358,7 @@
<!-- TMPL_IF NAME="OpenOPACShelfBrowser" -->
<div id="shelfbrowser">
-<h5 style="text-align: center;"><!-- TMPL_IF NAME="starting_homebranch"
-->Browsing <!-- TMPL_VAR NAME="starting_homebranch" --> Library<!-- /TMPL_IF
--><!-- TMPL_IF NAME="starting_location" -->, Shelving Location:</span><!--
TMPL_VAR NAME="starting_location" --> <!-- /TMPL_IF --> <a style="font-size:
75%;" href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR
NAME="biblionumber" -->">Close Shelf Browser</a></h5>
+<h5 style="text-align: center;"><!-- TMPL_IF NAME="starting_homebranch"
-->Browsing <!-- TMPL_VAR NAME="starting_homebranch" --> Shelves<!-- /TMPL_IF
--><!-- TMPL_IF NAME="starting_location" -->, Shelving Location:</span><!--
TMPL_VAR NAME="starting_location" --> <!-- /TMPL_IF --> <a style="font-size:
75%;" href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR
NAME="biblionumber" -->">Close Shelf Browser</a></h5>
<table><tr>
diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl
index f98f30e..e8b31fd 100755
--- a/opac/opac-detail.pl
+++ b/opac/opac-detail.pl
@@ -419,7 +419,9 @@ if (C4::Context->preference("OPACShelfBrowser")) {
## 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("
+ my $sth_shelfbrowse_previous;
+ if (defined $starting_location->{code}) {
+ $sth_shelfbrowse_previous = $dbh->prepare("
SELECT *
FROM items
WHERE
@@ -427,7 +429,18 @@ if (C4::Context->preference("OPACShelfBrowser")) {
homebranch = ? AND location = ?
ORDER BY cn_sort DESC, itemnumber LIMIT 3
");
- $sth_shelfbrowse_previous->execute($starting_cn_sort,
$starting_itemnumber, $starting_cn_sort, $starting_homebranch->{code},
$starting_location->{code});
+ $sth_shelfbrowse_previous->execute($starting_cn_sort,
$starting_itemnumber, $starting_cn_sort, $starting_homebranch->{code},
$starting_location->{code});
+ } else {
+ $sth_shelfbrowse_previous = $dbh->prepare("
+ SELECT *
+ FROM items
+ WHERE
+ ((cn_sort = ? AND itemnumber < ?) OR cn_sort < ?) AND
+ homebranch = ?
+ ORDER BY cn_sort DESC, itemnumber LIMIT 3
+ ");
+ $sth_shelfbrowse_previous->execute($starting_cn_sort,
$starting_itemnumber, $starting_cn_sort, $starting_homebranch->{code});
+ }
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=?");
@@ -443,7 +456,9 @@ if (C4::Context->preference("OPACShelfBrowser")) {
}
## List of Next Items; this also intentionally catches the current item
- my $sth_shelfbrowse_next = $dbh->prepare("
+ my $sth_shelfbrowse_next;
+ if (defined $starting_location->{code}) {
+ $sth_shelfbrowse_next = $dbh->prepare("
SELECT *
FROM items
WHERE
@@ -451,7 +466,18 @@ if (C4::Context->preference("OPACShelfBrowser")) {
homebranch = ? AND location = ?
ORDER BY cn_sort, itemnumber LIMIT 3
");
- $sth_shelfbrowse_next->execute($starting_cn_sort, $starting_itemnumber,
$starting_cn_sort, $starting_homebranch->{code}, $starting_location->{code});
+ $sth_shelfbrowse_next->execute($starting_cn_sort, $starting_itemnumber,
$starting_cn_sort, $starting_homebranch->{code}, $starting_location->{code});
+ } else {
+ $sth_shelfbrowse_next = $dbh->prepare("
+ SELECT *
+ FROM items
+ WHERE
+ ((cn_sort = ? AND itemnumber >= ?) OR cn_sort > ?) AND
+ homebranch = ?
+ ORDER BY cn_sort, itemnumber LIMIT 3
+ ");
+ $sth_shelfbrowse_next->execute($starting_cn_sort, $starting_itemnumber,
$starting_cn_sort, $starting_homebranch->{code});
+ }
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=?");
--
1.5.6.5
_______________________________________________
Koha-patches mailing list
[email protected]
http://lists.koha.org/mailman/listinfo/koha-patches