View | Details | Raw Unified | Return to bug 9673
Collapse All | Expand All

(-)a/C4/Items.pm (-7 / +26 lines)
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
                unless ( $pre_mod_item->{$field} ) {
549
                    if ( $item->{$field} ) {
550
                        $item->{ $field . '_on' } =
551
                          DateTime::Format::MySQL->format_datetime(
552
                            dt_from_string() );
553
                    }
554
                }
544
            }
555
            }
545
        }
556
        }
546
    }
557
    }
547
558
559
    # If the field is defined but empty, we are removing and,
560
    # and thus need to clear out the 'on' field as well
561
    for my $field (@fields) {
562
        if ( defined( $item->{$field} ) && !$item->{$field} ) {
563
            $item->{ $field . '_on' } = undef;
564
        }
565
    }
566
567
548
    _set_derived_columns_for_mod($item);
568
    _set_derived_columns_for_mod($item);
549
    _do_column_fixes_for_mod($item);
569
    _do_column_fixes_for_mod($item);
550
    # FIXME add checks
570
    # FIXME add checks
551
- 

Return to bug 9673