Bug fix to OPAC shelf browsing query statement
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. Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
This commit is contained in:
parent
d32d5bfb9b
commit
d5d21fe101
2 changed files with 31 additions and 5 deletions
|
@ -368,7 +368,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>
|
||||
|
|
|
@ -420,7 +420,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
|
||||
|
@ -428,7 +430,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=?");
|
||||
|
@ -444,7 +457,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
|
||||
|
@ -452,7 +467,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=?");
|
||||
|
|
Loading…
Reference in a new issue