[Koha-patches] [PATCH 5/7] bug 3481 followup - improve CartToShelf
Galen Charlton
gmcharlt at gmail.com
Sun Aug 23 19:07:04 CEST 2009
* 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 <gmcharlt at gmail.com>
---
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 30b22e0..1778a1c 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 3bf48d7..6215804 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
--
1.6.3.3
More information about the Koha-patches
mailing list