From 0bdabffa5d78de7bfd80413b61f2177d18c8cbf6 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 6 Jan 2014 12:37:02 -0500 Subject: [PATCH] Bug 8836 - Resurrect Rotating Collections - Followup 5 - Don't transfer issued and waiting items Items in a rotating collection are automatcially transferred when a collection is transferred. This is a problem for currently checked out items and items on hold marked as "Waiting". This patch resolves this issue by skipping the transfer for those items. When the items are then returned, the librarian will be alerted to transfer the item to the library currently holding that rotating collection. --- C4/RotatingCollections.pm | 19 +++++++++++-------- 1 files changed, 11 insertions(+), 8 deletions(-) diff --git a/C4/RotatingCollections.pm b/C4/RotatingCollections.pm index 6030089..0c5d163 100644 --- a/C4/RotatingCollections.pm +++ b/C4/RotatingCollections.pm @@ -26,6 +26,7 @@ use Modern::Perl; use C4::Context; use C4::Circulation; +use C4::Reserves qw(GetReserveStatus); use DBI; @@ -424,17 +425,19 @@ sub TransferCollection { ); $sth->execute( $colBranchcode, $colId ) or return ( 0, 4, $sth->errstr() ); - $sth = $dbh->prepare( - "SELECT barcode FROM items, collections_tracking - WHERE items.itemnumber = collections_tracking.itemnumber - AND collections_tracking.colId = ?" - ); + $sth = $dbh->prepare(q{ + SELECT items.itemnumber, items.barcode FROM collections_tracking + LEFT JOIN items ON collections_tracking.itemnumber = items.itemnumber + LEFT JOIN issues ON items.itemnumber = issues.itemnumber + WHERE issues.borrowernumber IS NULL + AND collections_tracking.colId = ? + }); $sth->execute($colId) or return ( 0, 4, $sth->errstr ); my @results; while ( my $item = $sth->fetchrow_hashref ) { - my ( $dotransfer, $messages, $iteminformation ) = - transferbook( $colBranchcode, $item->{'barcode'}, - my $ignore_reserves = 1 ); + transferbook( $colBranchcode, $item->{barcode}, + my $ignore_reserves = 1 ) + unless ( GetReserveStatus( $item->{itemnumber} ) eq "Waiting" ); } return 1; -- 1.7.2.5