@@ -, +, @@ an Item is edited when it's location is CART|PROC. "Save changes" This is not good since now the location data is forever lost again (Bugg 7817). The "cart_to_shelf.pl --hours 24"-script cannot return the Item to the proper place ;( overwritten by 'CART'. --- C4/Items.pm | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) --- a/C4/Items.pm +++ a/C4/Items.pm @@ -956,6 +956,22 @@ sub GetItemLocation { return \%itemlocation; } +=head GetRealItemLocations + + my $locations = C4::Items::GetRealItemLocations($itemnumber); + +A convenience function of getting just the Item location and permanent_location +@PARAM1, Long, the koha-items.itemnumber +@RETURNS, Reference to Hash, with koha.items.location and permanent_location as hash keys. + +=cut +sub GetRealItemLocations { + my $itemnumber = shift; + my $sth = C4::Context->dbh()->prepare('SELECT location, permanent_location FROM items WHERE itemnumber = ?'); + $sth->execute($itemnumber); + return $sth->fetchrow_hashref(); +} + =head2 GetLostItems $items = GetLostItems( $where, $orderby ); @@ -2030,7 +2046,15 @@ sub _do_column_fixes_for_mod { $item->{'withdrawn'} = 0; } if (exists $item->{'location'} && !$item->{'permanent_location'}) { - $item->{'permanent_location'} = $item->{'location'}; + if ($item->{'location'} ne 'CART' && $item->{'location'} ne 'PROC') { + $item->{'permanent_location'} = $item->{'location'}; + } + else { + #Preserve the old permanent_location in face of adversity! + #Don't let it fall to 'PROC' or 'CART'. Otherwise it will be forever lost! + my $locations = GetRealItemLocations( $item->{itemnumber} ); + $item->{'permanent_location'} = $locations->{'permanent_location'}; + } } if (exists $item->{'timestamp'}) { delete $item->{'timestamp'}; --