BugFix - ReturnToShelvingCart
authorKyle M Hall <kyle.m.hall@gmail.com>
Thu, 8 Oct 2009 12:13:13 +0000 (12:13 +0000)
committerPaul Poulain <paul.poulain@biblibre.com>
Tue, 24 Jul 2012 13:05:23 +0000 (15:05 +0200)
If the ReturnToShelvingCart syspref is on, and something needs to go in transit,
the shelving cart setting is overriding the transit.

What seems to be happening is this:
  * Item is checked in, and flagged as needing to go in transit from A to B.
  * Item is immediately flagged as shelving cart, though.  Current display says both shelving cart and in transit.
  * After the cart-to-shelf script runs, item comes out of transit and
    shows as being available at the destination library, although it hasn't
    arrived yet and no one has manually checked it in.

http://bugs.koha-community.org/show_bug.cgi?id=3701

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
C4/Circulation.pm
C4/Items.pm
circ/returns.pl

index 9508c78..d17519d 100644 (file)
@@ -1659,12 +1659,15 @@ sub AddReturn {
             );
             $sth->execute( $item->{'itemnumber'} );
             # if we have a reservation with valid transfer, we can set it's status to 'W'
+            ShelfToCart( $item->{'itemnumber'} ) if ( C4::Context->preference("ReturnToShelvingCart") );
             C4::Reserves::ModReserveStatus($item->{'itemnumber'}, 'W');
         } else {
             $messages->{'WrongTransfer'}     = $tobranch;
             $messages->{'WrongTransferItem'} = $item->{'itemnumber'};
         }
         $validTransfert = 1;
+    } else {
+        ShelfToCart( $item->{'itemnumber'} ) if ( C4::Context->preference("ReturnToShelvingCart") );
     }
 
     # fix up the accounts.....
index 2afe537..a9c0a16 100644 (file)
@@ -48,7 +48,7 @@ BEGIN {
         AddItem
         AddItemBatchFromMarc
         ModItemFromMarc
-               Item2Marc
+    Item2Marc
         ModItem
         ModDateLastSeen
         ModItemTransfer
@@ -72,10 +72,12 @@ BEGIN {
         GetItemnumberFromBarcode
         GetBarcodeFromItemnumber
         GetHiddenItemnumbers
-               DelItemCheck
-               MoveItemFromBiblio 
-               GetLatestAcquisitions
+        DelItemCheck
+    MoveItemFromBiblio
+    GetLatestAcquisitions
+
         CartToShelf
+        ShelfToCart
 
        GetAnalyticsCount
         GetItemHolds
@@ -190,7 +192,30 @@ sub CartToShelf {
     }
 
     my $item = GetItem($itemnumber);
-    $item->{location} = $item->{permanent_location};
+    if ( $item->{location} eq 'CART' ) {
+        $item->{location} = $item->{permanent_location};
+        ModItem($item, undef, $itemnumber);
+    }
+}
+
+=head2 ShelfToCart
+
+  ShelfToCart($itemnumber);
+
+Set the current shelving location of the item
+to shelving cart ('CART').
+
+=cut
+
+sub ShelfToCart {
+    my ( $itemnumber ) = @_;
+
+    unless ( $itemnumber ) {
+        croak "FAILED ShelfToCart() - no itemnumber supplied";
+    }
+
+    my $item = GetItem($itemnumber);
+    $item->{'location'} = 'CART';
     ModItem($item, undef, $itemnumber);
 }
 
@@ -542,6 +567,9 @@ sub ModItemTransfer {
 
     my $dbh = C4::Context->dbh;
 
+    # Remove the 'shelving cart' location status if it is being used.
+    CartToShelf( $itemnumber ) if ( C4::Context->preference("ReturnToShelvingCart") );
+
     #new entry in branchtransfers....
     my $sth = $dbh->prepare(
         "INSERT INTO branchtransfers (itemnumber, frombranch, datesent, tobranch)
index b9127da..1fbdcaf 100755 (executable)
@@ -212,12 +212,6 @@ if ($barcode) {
         }
     }
 
-    if ( C4::Context->preference("ReturnToShelvingCart") ) {
-        my $item = GetItem( $itemnumber );
-        $item->{'location'} = 'CART';
-        ModItem( $item, $item->{'biblionumber'}, $item->{'itemnumber'} );
-    }
-
 #
 # save the return
 #