From 908c515771b458bfc6d4aa1f43f66093964df6cc Mon Sep 17 00:00:00 2001 From: Joe Atzberger Date: Wed, 9 Jan 2008 13:14:26 -0600 Subject: [PATCH] VirtualShelves.pm - expanded SQL for shelf contents, fixes bug of no itemtypes displaying. Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- C4/VirtualShelves.pm | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/C4/VirtualShelves.pm b/C4/VirtualShelves.pm index c59f7f04b8..8312bc67f4 100644 --- a/C4/VirtualShelves.pm +++ b/C4/VirtualShelves.pm @@ -163,9 +163,13 @@ gives a desc sort. Returns a reference-to-array, whose elements are references-to-hash, as returned by C. +Note: the notforloan status comes from the itemtype, and where it equals 0 +it does not ensure that related items.notforloan status is likewise 0. The +caller has to check any items on their own, possibly with CanBookBeIssued +from C4::Circulation. + =cut -#' sub GetShelfContents { my ( $shelfnumber ,$sortfield) = @_; my $dbh=C4::Context->dbh(); @@ -174,23 +178,27 @@ sub GetShelfContents { $sthsort->execute($shelfnumber); ($sortfield) = $sthsort->fetchrow_array; } - my @itemlist; my $query = - " SELECT vc.biblionumber,vc.shelfnumber,biblio.* - FROM virtualshelfcontents vc LEFT JOIN biblio on vc.biblionumber=biblio.biblionumber + " SELECT vc.biblionumber, vc.shelfnumber, + biblio.*, biblioitems.itemtype, itemtypes.* + FROM virtualshelfcontents vc + LEFT JOIN biblio ON vc.biblionumber = biblio.biblionumber + LEFT JOIN biblioitems ON biblio.biblionumber = biblioitems.biblionumber + LEFT JOIN itemtypes ON biblioitems.itemtype = itemtypes.itemtype WHERE vc.shelfnumber=? "; - my @bind = ($shelfnumber); if($sortfield) { - #$sortfield = $dbh->quote($sortfield); $query .= " ORDER BY `$sortfield` "; $query .= " DESC " if ($sortfield eq 'copyrightdate'); } my $sth = $dbh->prepare($query); - $sth->execute(@bind); - while ( my $item = $sth->fetchrow_hashref ) { - push( @itemlist, $item ); - } - return ( \@itemlist ); + $sth->execute($shelfnumber); + return $sth->fetchall_arrayref({}); + # Like the perldoc says, + # returns reference-to-array, where each element is reference-to-hash of the row: + # like [ $sth->fetchrow_hashref(), $sth->fetchrow_hashref() ... ] + # Suitable for use in TMPL_LOOP. + # See http://search.cpan.org/~timb/DBI-1.601/DBI.pm#fetchall_arrayref + # or newer, for your version of DBI. } =item AddShelf -- 2.39.5