From dafb3e20da9cb470bde058c924d655413e462739 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Sun, 23 Aug 2009 12:51:12 -0400 Subject: [PATCH] bug 3481 followup - improve CartToShelf * added POD * removed optional $barcode argument - in all cases, itemnumber is known, and we should stick with itemnumber when retrieving an existing item * use ModItem to do the update so that indexer will know to reindex bib - otherwise, can't do an accurate search of items that are on the shelving cart. Signed-off-by: Galen Charlton --- C4/Circulation.pm | 2 +- C4/Items.pm | 40 ++++++++++++++++++++++------------------ 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 30b22e0718..1778a1c912 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1001,7 +1001,7 @@ sub AddIssue { ); $sth->finish; if ( C4::Context->preference('ReturnToShelvingCart') ) { ## ReturnToShelvingCart is on, anything issued should be taken off the cart. - CartToShelf( '', $barcode ); + CartToShelf( $item->{'itemnumber'} ); } $item->{'issues'}++; ModItem({ issues => $item->{'issues'}, diff --git a/C4/Items.pm b/C4/Items.pm index 3bf48d7470..621580436f 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -156,28 +156,32 @@ sub GetItem { return $data; } # sub GetItem -sub CartToShelf { - my ( $itemnumber, $barcode ) = @_; +=head2 CartToShelf - my ( $field, $value ); +=over 4 - if ( $itemnumber ) { - $field = 'itemnumber'; - $value = $itemnumber; - } elsif ( $barcode ) { - $field = 'barcode'; - $value = $barcode; - } else { - $barcode ||= 'UNDEFINED'; - $itemnumber ||= 'UNDEFINED'; - croak "FAILED CartToShelf( $itemnumber, $barcode )"; - } +CartToShelf($itemnumber); - my $sql = "UPDATE items SET items.location = items.permanent_location WHERE $field = ?"; +=back - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare( $sql ); - $sth->execute( $value ); +Set the current shelving location of the item record +to its stored permanent shelving location. This is +primarily used to indicate when an item whose current +location is a special processing ('PROC') or shelving cart +('CART') location is back in the stacks. + +=cut + +sub CartToShelf { + my ( $itemnumber ) = @_; + + unless ( $itemnumber ) { + croak "FAILED CartToShelf() - no itemnumber supplied"; + } + + my $item = GetItem($itemnumber); + $item->{location} = $item->{permanent_location}; + ModItem($item, undef, $itemnumber); } =head2 AddItemFromMarc -- 2.39.5