@@ -, +, @@ --- C4/Items.pm | 23 ++++++++++++++--------- 1 files changed, 14 insertions(+), 9 deletions(-) --- a/C4/Items.pm +++ a/C4/Items.pm @@ -33,6 +33,7 @@ use List::MoreUtils qw/any/; use DateTime::Format::MySQL; use Data::Dumper; # used as part of logging item record changes, not just for # debugging; so please don't remove this +use Koha::DateUtils qw/dt_from_string/; use vars qw($VERSION @ISA @EXPORT); @@ -536,16 +537,20 @@ sub ModItem { $item->{onloan} = undef if $item->{itemlost}; - for my $field ( qw( itemlost wthdrawn ) ) { - if ( defined( $item->{$field} ) ) { - my $pre_mod_item = GetItem($item->{'itemnumber'}); - unless ( $pre_mod_item->{$field} ) { - if ( $item->{$field} ) { - $item->{$field . '_on'} = DateTime::Format::MySQL->format_datetime( DateTime->now() ); - } + if ( $item->{itemlost} || $item->{wthdrawn} ) { + my $pre_mod_item = GetItem( $item->{'itemnumber'} ); + for my $field (qw( itemlost wthdrawn )) { + if ( defined( $item->{$field} ) ) { + unless ( $pre_mod_item->{$field} ) { + if ( $item->{$field} ) { + $item->{ $field . '_on' } = + DateTime::Format::MySQL->format_datetime( dt_from_string() ); + } + } + } + else { + $item->{ $field . '_on' } = undef; } - } else { - $item->{$field . '_on'} = undef; } } --