From: David Birmingham Date: Thu, 30 Apr 2009 16:54:48 +0000 (-0400) Subject: Bug fix to OPAC shelf browsing query statement X-Git-Tag: v3.00.02-stable~93 X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;h=c2e1684b98c1b14d631e5024e244f6910e0af827;p=koha.git 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 Signed-off-by: Henri-Damien LAURENT --- 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 bee0ec779b..6c739e6181 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl @@ -309,7 +309,7 @@
-
Browsing Library, Shelving Location: ">Close Shelf Browser
+
Browsing Shelves, Shelving Location: ">Close Shelf Browser
diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 85eeaa70ca..8100886966 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -321,7 +321,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 @@ -329,7 +331,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=?"); @@ -346,7 +359,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 @@ -354,7 +369,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=?");