bug 2252 - check correct items for item-specific holds
authorGalen Charlton <galen.charlton@liblime.com>
Tue, 17 Jun 2008 15:12:25 +0000 (10:12 -0500)
committerJoshua Ferraro <jmf@liblime.com>
Tue, 17 Jun 2008 18:09:41 +0000 (13:09 -0500)
C4::Reserves::_Findgroupreserves(), instead of
getting all requests for a bib, now gets only the
requests that are title-level (itemnumber is null)
or for that specific item.  This prevents an item
from filling an item-level hold for a different item
attached to the same bib, which is the expected
behavior for item-level holds.

[LL Bug 22]

Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/Reserves.pm

index 6fedf23..7b9345a 100644 (file)
@@ -638,7 +638,7 @@ sub CheckReserves {
 
     # get the reserves...
     # Find this item in the reserves
-    my @reserves = _Findgroupreserve( $bibitem, $biblio );
+    my @reserves = _Findgroupreserve( $bibitem, $biblio, $item );
     my $count    = scalar @reserves;
 
     # $priority and $highest are used to find the most important item
@@ -1169,7 +1169,7 @@ sub _FixPriority {
 
 =item _Findgroupreserve
 
-  @results = &_Findgroupreserve($biblioitemnumber, $biblionumber);
+  @results = &_Findgroupreserve($biblioitemnumber, $biblionumber, $itemnumber);
 
 ****** FIXME ******
 I don't know what this does, because I don't understand how reserve
@@ -1186,7 +1186,7 @@ C<biblioitemnumber>.
 =cut
 
 sub _Findgroupreserve {
-    my ( $bibitem, $biblio ) = @_;
+    my ( $bibitem, $biblio, $itemnumber ) = @_;
     my $dbh   = C4::Context->dbh;
     my $query = qq/
         SELECT reserves.biblionumber AS biblionumber,
@@ -1207,9 +1207,10 @@ sub _Findgroupreserve {
           AND reserves.borrowernumber = reserveconstraints.borrowernumber
           AND reserves.reservedate    =reserveconstraints.reservedate )
           OR  reserves.constrainttype='a' )
+          AND (reserves.itemnumber IS NULL OR reserves.itemnumber = ?)
     /;
     my $sth = $dbh->prepare($query);
-    $sth->execute( $biblio, $bibitem );
+    $sth->execute( $biblio, $bibitem, $itemnumber );
     my @results;
     while ( my $data = $sth->fetchrow_hashref ) {
         push( @results, $data );