|
Lines 30-37
use MARC::Record;
Link Here
|
| 30 |
use C4::ClassSource; |
30 |
use C4::ClassSource; |
| 31 |
use C4::Log; |
31 |
use C4::Log; |
| 32 |
use List::MoreUtils qw/any/; |
32 |
use List::MoreUtils qw/any/; |
|
|
33 |
use DateTime::Format::MySQL; |
| 33 |
use Data::Dumper; # used as part of logging item record changes, not just for |
34 |
use Data::Dumper; # used as part of logging item record changes, not just for |
| 34 |
# debugging; so please don't remove this |
35 |
# debugging; so please don't remove this |
|
|
36 |
use Koha::DateUtils qw/dt_from_string/; |
| 35 |
|
37 |
|
| 36 |
use vars qw($VERSION @ISA @EXPORT); |
38 |
use vars qw($VERSION @ISA @EXPORT); |
| 37 |
|
39 |
|
|
Lines 535-550
sub ModItem {
Link Here
|
| 535 |
|
537 |
|
| 536 |
$item->{onloan} = undef if $item->{itemlost}; |
538 |
$item->{onloan} = undef if $item->{itemlost}; |
| 537 |
|
539 |
|
| 538 |
for my $field ( qw( itemlost wthdrawn ) ) { |
540 |
|
| 539 |
if ( defined( $item->{$field} ) ) { |
541 |
my @fields = qw( itemlost wthdrawn ); |
| 540 |
if ( $item->{$field} ) { |
542 |
|
| 541 |
$item->{$field . '_on'} = DateTime::Format::MySQL->format_datetime( DateTime->now() ); |
543 |
# Only call GetItem if we need to set an "on" date field |
| 542 |
} else { |
544 |
if ( $item->{itemlost} || $item->{wthdrawn} ) { |
| 543 |
$item->{$field . '_on'} = undef; |
545 |
my $pre_mod_item = GetItem( $item->{'itemnumber'} ); |
|
|
546 |
for my $field (@fields) { |
| 547 |
if ( defined( $item->{$field} ) |
| 548 |
and not pre_mod_item->{$field} |
| 549 |
and $item->{$field} ) |
| 550 |
{ |
| 551 |
$item->{ $field . '_on' } = |
| 552 |
DateTime::Format::MySQL->format_datetime( dt_from_string() ); |
| 544 |
} |
553 |
} |
| 545 |
} |
554 |
} |
| 546 |
} |
555 |
} |
| 547 |
|
556 |
|
|
|
557 |
# If the field is defined but empty, we are removing and, |
| 558 |
# and thus need to clear out the 'on' field as well |
| 559 |
for my $field (@fields) { |
| 560 |
if ( defined( $item->{$field} ) && !$item->{$field} ) { |
| 561 |
$item->{ $field . '_on' } = undef; |
| 562 |
} |
| 563 |
} |
| 564 |
|
| 565 |
|
| 548 |
_set_derived_columns_for_mod($item); |
566 |
_set_derived_columns_for_mod($item); |
| 549 |
_do_column_fixes_for_mod($item); |
567 |
_do_column_fixes_for_mod($item); |
| 550 |
# FIXME add checks |
568 |
# FIXME add checks |
| 551 |
- |
|
|