Lines 1796-1820
sub AddIssue {
Link Here
|
1796 |
$item_unblessed->{charge} = $charge; |
1796 |
$item_unblessed->{charge} = $charge; |
1797 |
} |
1797 |
} |
1798 |
} |
1798 |
} |
1799 |
|
1799 |
_updateNotForLoanFromYaml( $item_object, 'UpdateNotForLoanStatusOnCheckout' ); |
1800 |
my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckout'); |
|
|
1801 |
if ($yaml) { |
1802 |
$yaml = "$yaml\n\n"; |
1803 |
|
1804 |
my $rules; |
1805 |
eval { $rules = YAML::XS::Load(Encode::encode_utf8($yaml)); }; |
1806 |
if ($@) { |
1807 |
warn "Unable to parse UpdateNotForLoanStatusOnCheckout syspref : $@"; |
1808 |
} |
1809 |
else { |
1810 |
foreach my $key ( keys %$rules ) { |
1811 |
if ( $item_object->notforloan eq $key ) { |
1812 |
$item_object->notforloan($rules->{$key})->store({ log_action => 0, skip_record_index => 1 }); |
1813 |
last; |
1814 |
} |
1815 |
} |
1816 |
} |
1817 |
} |
1818 |
|
1800 |
|
1819 |
# Record the fact that this book was issued. |
1801 |
# Record the fact that this book was issued. |
1820 |
C4::Stats::UpdateStats( |
1802 |
C4::Stats::UpdateStats( |
Lines 2140-2146
sub AddReturn {
Link Here
|
2140 |
$branch = C4::Context->userenv->{'branch'} unless $branch; # we trust userenv to be a safe fallback/default |
2122 |
$branch = C4::Context->userenv->{'branch'} unless $branch; # we trust userenv to be a safe fallback/default |
2141 |
my $return_date_specified = !!$return_date; |
2123 |
my $return_date_specified = !!$return_date; |
2142 |
$return_date //= dt_from_string(); |
2124 |
$return_date //= dt_from_string(); |
2143 |
my $messages; |
2125 |
my $messages = {}; |
2144 |
my $patron; |
2126 |
my $patron; |
2145 |
my $doreturn = 1; |
2127 |
my $doreturn = 1; |
2146 |
my $validTransfer = 1; |
2128 |
my $validTransfer = 1; |
Lines 2216-2253
sub AddReturn {
Link Here
|
2216 |
$messages->{ $loc_msg_key } = $loc_messages->{ $loc_msg_key }; |
2198 |
$messages->{ $loc_msg_key } = $loc_messages->{ $loc_msg_key }; |
2217 |
} |
2199 |
} |
2218 |
|
2200 |
|
2219 |
my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckin'); |
2201 |
_updateNotForLoanFromYaml( $item, 'UpdateNotForLoanStatusOnCheckin', $messages ); |
2220 |
if ($yaml) { |
|
|
2221 |
$yaml = "$yaml\n\n"; # YAML is anal on ending \n. Surplus does not hurt |
2222 |
my $rules; |
2223 |
eval { $rules = YAML::XS::Load(Encode::encode_utf8($yaml)); }; |
2224 |
if ($@) { |
2225 |
warn "Unable to parse UpdateNotForLoanStatusOnCheckin syspref : $@"; |
2226 |
} |
2227 |
else { |
2228 |
if ( defined $rules->{$item->itype} ) { |
2229 |
foreach my $notloan_rule_key (keys %{ $rules->{$item->itype}} ) { |
2230 |
if ( $item->notforloan eq $notloan_rule_key ) { |
2231 |
$messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{$item->itype}->{$notloan_rule_key} }; |
2232 |
$item->notforloan( $rules->{ $item->itype }->{$notloan_rule_key} ) |
2233 |
->store( { log_action => 0, skip_record_index => 1, skip_holds_queue => 1 } ) |
2234 |
unless $rules->{ $item->itype }->{$notloan_rule_key} eq 'ONLYMESSAGE'; |
2235 |
last; |
2236 |
} |
2237 |
} |
2238 |
} elsif ( defined $rules->{'_ALL_'} ) { |
2239 |
foreach my $notloan_rule_key (keys %{ $rules->{'_ALL_'}} ) { |
2240 |
if ( $item->notforloan eq $notloan_rule_key ) { |
2241 |
$messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{'_ALL_'}->{$notloan_rule_key} }; |
2242 |
$item->notforloan( $rules->{'_ALL_'}->{$notloan_rule_key} ) |
2243 |
->store( { log_action => 0, skip_record_index => 1, skip_holds_queue => 1 } ) |
2244 |
unless $rules->{ '_ALL_' }->{$notloan_rule_key} eq 'ONLYMESSAGE'; |
2245 |
last; |
2246 |
} |
2247 |
} |
2248 |
} |
2249 |
} |
2250 |
} |
2251 |
|
2202 |
|
2252 |
# check if the return is allowed at this branch |
2203 |
# check if the return is allowed at this branch |
2253 |
my ($returnallowed, $message) = CanBookBeReturned($item->unblessed, $branch); |
2204 |
my ($returnallowed, $message) = CanBookBeReturned($item->unblessed, $branch); |
Lines 4634-4639
sub _CanBookBeAutoRenewed {
Link Here
|
4634 |
return "ok"; |
4585 |
return "ok"; |
4635 |
} |
4586 |
} |
4636 |
|
4587 |
|
|
|
4588 |
sub _updateNotForLoanFromYaml { |
4589 |
my ( $item, $NotForLoanUpdatePreference, $messages ) = @_; |
4590 |
|
4591 |
my $yaml = C4::Context->preference($NotForLoanUpdatePreference); |
4592 |
if ($yaml) { |
4593 |
$yaml = "$yaml\n\n"; |
4594 |
my $rules; |
4595 |
eval { $rules = YAML::XS::Load( Encode::encode_utf8($yaml) ); }; |
4596 |
if ($@) { |
4597 |
warn "Unable to parse $NotForLoanUpdatePreference syspref : $@"; |
4598 |
} else { |
4599 |
if ( defined $rules->{ $item->itype } ) { |
4600 |
foreach my $notloan_rule_key ( keys %{ $rules->{ $item->itype } } ) { |
4601 |
if ( $item->notforloan eq $notloan_rule_key ) { |
4602 |
$messages->{'NotForLoanStatusUpdated'} = |
4603 |
{ from => $item->notforloan, to => $rules->{ $item->itype }->{$notloan_rule_key} }; |
4604 |
$item->notforloan( $rules->{ $item->itype }->{$notloan_rule_key} ) |
4605 |
->store( { log_action => 0, skip_record_index => 1, skip_holds_queue => 1 } ) |
4606 |
unless $rules->{ $item->itype }->{$notloan_rule_key} eq 'ONLYMESSAGE'; |
4607 |
last; |
4608 |
} |
4609 |
} |
4610 |
} elsif ( defined $rules->{'_ALL_'} ) { |
4611 |
foreach my $notloan_rule_key ( keys %{ $rules->{'_ALL_'} } ) { |
4612 |
if ( $item->notforloan eq $notloan_rule_key ) { |
4613 |
$messages->{'NotForLoanStatusUpdated'} = |
4614 |
{ from => $item->notforloan, to => $rules->{'_ALL_'}->{$notloan_rule_key} }; |
4615 |
$item->notforloan( $rules->{'_ALL_'}->{$notloan_rule_key} ) |
4616 |
->store( { log_action => 0, skip_record_index => 1, skip_holds_queue => 1 } ) |
4617 |
unless $rules->{'_ALL_'}->{$notloan_rule_key} eq 'ONLYMESSAGE'; |
4618 |
last; |
4619 |
} |
4620 |
} |
4621 |
} |
4622 |
} |
4623 |
} |
4624 |
} |
4637 |
|
4625 |
|
4638 |
1; |
4626 |
1; |
4639 |
|
4627 |
|
4640 |
- |
|
|