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

(-)a/Koha/Item.pm (-17 / +14 lines)
Lines 2784-2790 sub location_update_trigger { Link Here
2784
    my ( $self, $action ) = @_;
2784
    my ( $self, $action ) = @_;
2785
2785
2786
    my $new_location = $self->_check_location_update_rules($action);
2786
    my $new_location = $self->_check_location_update_rules($action);
2787
    if (defined $new_location) {
2787
    if ( defined $new_location ) {
2788
        my $messages = {
2788
        my $messages = {
2789
            'ItemLocationUpdated' => {
2789
            'ItemLocationUpdated' => {
2790
                from => $self->location,
2790
                from => $self->location,
Lines 2804-2810 sub location_update_trigger { Link Here
2804
}
2804
}
2805
2805
2806
sub _check_location_update_rules {
2806
sub _check_location_update_rules {
2807
    my ($self, $action) = @_;
2807
    my ( $self, $action ) = @_;
2808
    my ( $update_loc_rules, $messages );
2808
    my ( $update_loc_rules, $messages );
2809
    if ( $action eq 'checkin' ) {
2809
    if ( $action eq 'checkin' ) {
2810
        $update_loc_rules = C4::Context->yaml_preference('UpdateItemLocationOnCheckin');
2810
        $update_loc_rules = C4::Context->yaml_preference('UpdateItemLocationOnCheckin');
Lines 2813-2842 sub _check_location_update_rules { Link Here
2813
    }
2813
    }
2814
2814
2815
    if ($update_loc_rules) {
2815
    if ($update_loc_rules) {
2816
        if (defined($update_loc_rules->{'_ALL_'})) {
2816
        if ( defined( $update_loc_rules->{'_ALL_'} ) ) {
2817
            return $self->_check_location_update_rule($update_loc_rules->{'_ALL_'});
2817
            return $self->_check_location_update_rule( $update_loc_rules->{'_ALL_'} );
2818
        }
2818
        } elsif ( defined( $update_loc_rules->{ $self->location || '_BLANK_' } ) ) {
2819
        elsif (defined($update_loc_rules->{$self->location||'_BLANK_'})) {
2819
            return $self->_check_location_update_rule( $update_loc_rules->{ $self->location || '_BLANK_' } );
2820
            return $self->_check_location_update_rule($update_loc_rules->{$self->location||'_BLANK_'});
2820
        } elsif ( defined( $update_loc_rules->{'_DEFAULT_'} ) ) {
2821
        }
2821
            return $self->_check_location_update_rule( $update_loc_rules->{'_DEFAULT_'} );
2822
        elsif (defined($update_loc_rules->{'_DEFAULT_'})) {
2823
            return $self->_check_location_update_rule($update_loc_rules->{'_DEFAULT_'});
2824
        }
2822
        }
2825
    }
2823
    }
2826
}
2824
}
2827
2825
2828
2829
sub _check_location_update_rule {
2826
sub _check_location_update_rule {
2830
    my ($self, $update_loc_rule) = @_;
2827
    my ( $self, $update_loc_rule ) = @_;
2831
2828
2832
    if ($update_loc_rule eq '_PERM_') {
2829
    if ( $update_loc_rule eq '_PERM_' ) {
2833
        $update_loc_rule = $self->permanent_location;
2830
        $update_loc_rule = $self->permanent_location;
2834
    }
2831
    }
2835
    if ($update_loc_rule eq '_BLANK_') {
2832
    if ( $update_loc_rule eq '_BLANK_' ) {
2836
        $update_loc_rule = '';
2833
        $update_loc_rule = '';
2837
    }
2834
    }
2838
    if ((defined($self->location) && $self->location ne $update_loc_rule) ||
2835
    if (   ( defined( $self->location ) && $self->location ne $update_loc_rule )
2839
        (not(defined($self->location)) && $update_loc_rule ne "" )) {
2836
        || ( not( defined( $self->location ) ) && $update_loc_rule ne "" ) )
2837
    {
2840
        return $update_loc_rule;
2838
        return $update_loc_rule;
2841
    }
2839
    }
2842
    return undef;
2840
    return undef;
2843
- 

Return to bug 29326