|
Lines 2704-2709
FIXME: It should return I<$self>. See bug 35270.
Link Here
|
| 2704 |
sub location_update_trigger { |
2704 |
sub location_update_trigger { |
| 2705 |
my ( $self, $action ) = @_; |
2705 |
my ( $self, $action ) = @_; |
| 2706 |
|
2706 |
|
|
|
2707 |
if (my $new_location = $self->_check_location_update_rules($action)) { |
| 2708 |
my $messages = { |
| 2709 |
'ItemLocationUpdated' => { |
| 2710 |
from => $self->location, |
| 2711 |
to => $new_location, |
| 2712 |
} |
| 2713 |
}; |
| 2714 |
$self->location($new_location)->store( |
| 2715 |
{ |
| 2716 |
log_action => 0, |
| 2717 |
skip_record_index => 1, |
| 2718 |
skip_holds_queue => 1 |
| 2719 |
} |
| 2720 |
); |
| 2721 |
return $messages; |
| 2722 |
} |
| 2723 |
return undef; |
| 2724 |
} |
| 2725 |
|
| 2726 |
sub _check_location_update_rules { |
| 2727 |
my ($self, $action) = @_; |
| 2707 |
my ( $update_loc_rules, $messages ); |
2728 |
my ( $update_loc_rules, $messages ); |
| 2708 |
if ( $action eq 'checkin' ) { |
2729 |
if ( $action eq 'checkin' ) { |
| 2709 |
$update_loc_rules = C4::Context->yaml_preference('UpdateItemLocationOnCheckin'); |
2730 |
$update_loc_rules = C4::Context->yaml_preference('UpdateItemLocationOnCheckin'); |
|
Lines 2712-2777
sub location_update_trigger {
Link Here
|
| 2712 |
} |
2733 |
} |
| 2713 |
|
2734 |
|
| 2714 |
if ($update_loc_rules) { |
2735 |
if ($update_loc_rules) { |
| 2715 |
if ( defined $update_loc_rules->{_ALL_} ) { |
2736 |
if (defined($update_loc_rules->{'_ALL_'})) { |
| 2716 |
if ( $update_loc_rules->{_ALL_} eq '_PERM_' ) { |
2737 |
return $self->_check_location_update_rule($update_loc_rules->{'_ALL_'}); |
| 2717 |
$update_loc_rules->{_ALL_} = $self->permanent_location; |
2738 |
} |
| 2718 |
} |
2739 |
elsif (defined($update_loc_rules->{$self->location//''})) { |
| 2719 |
if ( $update_loc_rules->{_ALL_} eq '_BLANK_' ) { |
2740 |
return $self->_check_location_update_rule($update_loc_rules->{$self->location}); |
| 2720 |
$update_loc_rules->{_ALL_} = ''; |
2741 |
} |
| 2721 |
} |
2742 |
elsif (defined($update_loc_rules->{'_DEFAULT_'})) { |
| 2722 |
if ( |
2743 |
return $self->_check_location_update_rule($update_loc_rules->{'_DEFAULT_'}); |
| 2723 |
( defined $self->location && $self->location ne $update_loc_rules->{_ALL_} ) |
|
|
| 2724 |
|| ( !defined $self->location |
| 2725 |
&& $update_loc_rules->{_ALL_} ne "" ) |
| 2726 |
) |
| 2727 |
{ |
| 2728 |
$messages->{'ItemLocationUpdated'} = |
| 2729 |
{ from => $self->location, to => $update_loc_rules->{_ALL_} }; |
| 2730 |
$self->location( $update_loc_rules->{_ALL_} )->store( |
| 2731 |
{ |
| 2732 |
log_action => 0, |
| 2733 |
skip_record_index => 1, |
| 2734 |
skip_holds_queue => 1 |
| 2735 |
} |
| 2736 |
); |
| 2737 |
} |
| 2738 |
} else { |
| 2739 |
foreach my $key ( keys %$update_loc_rules ) { |
| 2740 |
if ( $update_loc_rules->{$key} eq '_PERM_' ) { |
| 2741 |
$update_loc_rules->{$key} = $self->permanent_location; |
| 2742 |
} elsif ( $update_loc_rules->{$key} eq '_BLANK_' ) { |
| 2743 |
$update_loc_rules->{$key} = ''; |
| 2744 |
} |
| 2745 |
if ( |
| 2746 |
( |
| 2747 |
defined $self->location |
| 2748 |
&& $self->location eq $key |
| 2749 |
&& $self->location ne $update_loc_rules->{$key} |
| 2750 |
) |
| 2751 |
|| ( $key eq '_BLANK_' |
| 2752 |
&& ( !defined $self->location || $self->location eq '' ) |
| 2753 |
&& $update_loc_rules->{$key} ne '' ) |
| 2754 |
) |
| 2755 |
{ |
| 2756 |
$messages->{'ItemLocationUpdated'} = { |
| 2757 |
from => $self->location, |
| 2758 |
to => $update_loc_rules->{$key} |
| 2759 |
}; |
| 2760 |
$self->location( $update_loc_rules->{$key} )->store( |
| 2761 |
{ |
| 2762 |
log_action => 0, |
| 2763 |
skip_record_index => 1, |
| 2764 |
skip_holds_queue => 1 |
| 2765 |
} |
| 2766 |
); |
| 2767 |
last; |
| 2768 |
} |
| 2769 |
} |
| 2770 |
} |
2744 |
} |
| 2771 |
} |
2745 |
} |
| 2772 |
return $messages; |
|
|
| 2773 |
} |
2746 |
} |
| 2774 |
|
2747 |
|
|
|
2748 |
sub _check_location_update_rule { |
| 2749 |
my ($self, $update_loc_rule) = @_; |
| 2750 |
|
| 2751 |
if ($update_loc_rule eq '_PERM_') { |
| 2752 |
$update_loc_rule = $self->permanent_location; |
| 2753 |
} |
| 2754 |
if ($update_loc_rule eq '_BLANK_') { |
| 2755 |
$update_loc_rule = ''; |
| 2756 |
} |
| 2757 |
if ((defined($self->location) && $self->location ne $update_loc_rule) || |
| 2758 |
(not(defined($self->location)) && $update_loc_rule ne "" )) { |
| 2759 |
return $update_loc_rule; |
| 2760 |
} |
| 2761 |
return undef; |
| 2762 |
} |
| 2775 |
|
2763 |
|
| 2776 |
=head3 z3950_status |
2764 |
=head3 z3950_status |
| 2777 |
|
2765 |
|
| 2778 |
- |
|
|