Lines 21-27
package C4::Circulation;
Link Here
|
21 |
use Modern::Perl; |
21 |
use Modern::Perl; |
22 |
use DateTime; |
22 |
use DateTime; |
23 |
use POSIX qw( floor ); |
23 |
use POSIX qw( floor ); |
24 |
use YAML::XS; |
|
|
25 |
use Encode; |
24 |
use Encode; |
26 |
|
25 |
|
27 |
use C4::Context; |
26 |
use C4::Context; |
Lines 1742-1762
sub AddIssue {
Link Here
|
1742 |
} |
1741 |
} |
1743 |
} |
1742 |
} |
1744 |
|
1743 |
|
1745 |
my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckout'); |
1744 |
my $rules = C4::Context->yaml_preference('UpdateNotForLoanStatusOnCheckout'); |
1746 |
if ($yaml) { |
1745 |
if ($rules) { |
1747 |
$yaml = "$yaml\n\n"; |
1746 |
foreach my $key ( keys %$rules ) { |
1748 |
|
1747 |
if ( $item_object->notforloan eq $key ) { |
1749 |
my $rules; |
1748 |
$item_object->notforloan($rules->{$key})->store({ log_action => 0, skip_record_index => 1 }); |
1750 |
eval { $rules = YAML::XS::Load(Encode::encode_utf8($yaml)); }; |
1749 |
last; |
1751 |
if ($@) { |
|
|
1752 |
warn "Unable to parse UpdateNotForLoanStatusOnCheckout syspref : $@"; |
1753 |
} |
1754 |
else { |
1755 |
foreach my $key ( keys %$rules ) { |
1756 |
if ( $item_object->notforloan eq $key ) { |
1757 |
$item_object->notforloan($rules->{$key})->store({ log_action => 0, skip_record_index => 1 }); |
1758 |
last; |
1759 |
} |
1760 |
} |
1750 |
} |
1761 |
} |
1751 |
} |
1762 |
} |
1752 |
} |
Lines 2164-2184
sub AddReturn {
Link Here
|
2164 |
} |
2154 |
} |
2165 |
} |
2155 |
} |
2166 |
|
2156 |
|
2167 |
my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckin'); |
2157 |
my $rules = C4::Context->yaml_preference('UpdateNotForLoanStatusOnCheckin'); |
2168 |
if ($yaml) { |
2158 |
if ($rules) { |
2169 |
$yaml = "$yaml\n\n"; # YAML is anal on ending \n. Surplus does not hurt |
2159 |
foreach my $key ( keys %$rules ) { |
2170 |
my $rules; |
2160 |
if ( $item->notforloan eq $key ) { |
2171 |
eval { $rules = YAML::XS::Load(Encode::encode_utf8($yaml)); }; |
2161 |
$messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{$key} }; |
2172 |
if ($@) { |
2162 |
$item->notforloan($rules->{$key})->store({ log_action => 0, skip_record_index => 1, skip_holds_queue => 1 }) unless $rules->{$key} eq 'ONLYMESSAGE'; |
2173 |
warn "Unable to parse UpdateNotForLoanStatusOnCheckin syspref : $@"; |
2163 |
last; |
2174 |
} |
|
|
2175 |
else { |
2176 |
foreach my $key ( keys %$rules ) { |
2177 |
if ( $item->notforloan eq $key ) { |
2178 |
$messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{$key} }; |
2179 |
$item->notforloan($rules->{$key})->store({ log_action => 0, skip_record_index => 1, skip_holds_queue => 1 }) unless $rules->{$key} eq 'ONLYMESSAGE'; |
2180 |
last; |
2181 |
} |
2182 |
} |
2164 |
} |
2183 |
} |
2165 |
} |
2184 |
} |
2166 |
} |