|
Lines 1836-1852
sub AddIssue {
Link Here
|
| 1836 |
$item_unblessed->{charge} = $charge; |
1836 |
$item_unblessed->{charge} = $charge; |
| 1837 |
} |
1837 |
} |
| 1838 |
} |
1838 |
} |
| 1839 |
|
1839 |
_updateNotForLoanFromYaml( $item_object, 'UpdateNotForLoanStatusOnCheckout' ); |
| 1840 |
my $rules = C4::Context->yaml_preference('UpdateNotForLoanStatusOnCheckout'); |
|
|
| 1841 |
if ($rules) { |
| 1842 |
foreach my $key ( keys %$rules ) { |
| 1843 |
if ( $item_object->notforloan eq $key ) { |
| 1844 |
$item_object->notforloan( $rules->{$key} ) |
| 1845 |
->store( { log_action => 0, skip_record_index => 1 } ); |
| 1846 |
last; |
| 1847 |
} |
| 1848 |
} |
| 1849 |
} |
| 1850 |
|
1840 |
|
| 1851 |
# Record the fact that this book was issued. |
1841 |
# Record the fact that this book was issued. |
| 1852 |
C4::Stats::UpdateStats( |
1842 |
C4::Stats::UpdateStats( |
|
Lines 2175-2181
sub AddReturn {
Link Here
|
| 2175 |
$branch = C4::Context->userenv->{'branch'} unless $branch; # we trust userenv to be a safe fallback/default |
2165 |
$branch = C4::Context->userenv->{'branch'} unless $branch; # we trust userenv to be a safe fallback/default |
| 2176 |
my $return_date_specified = !!$return_date; |
2166 |
my $return_date_specified = !!$return_date; |
| 2177 |
$return_date //= dt_from_string(); |
2167 |
$return_date //= dt_from_string(); |
| 2178 |
my $messages; |
2168 |
my $messages = {}; |
| 2179 |
my $patron; |
2169 |
my $patron; |
| 2180 |
my $doreturn = 1; |
2170 |
my $doreturn = 1; |
| 2181 |
my $validTransfer = 1; |
2171 |
my $validTransfer = 1; |
|
Lines 2256-2287
sub AddReturn {
Link Here
|
| 2256 |
$messages->{$loc_msg_key} = $loc_messages->{$loc_msg_key}; |
2246 |
$messages->{$loc_msg_key} = $loc_messages->{$loc_msg_key}; |
| 2257 |
} |
2247 |
} |
| 2258 |
|
2248 |
|
| 2259 |
my $rules = C4::Context->yaml_preference('UpdateNotForLoanStatusOnCheckin'); |
2249 |
_updateNotForLoanFromYaml( $item, 'UpdateNotForLoanStatusOnCheckin', $messages ); |
| 2260 |
if ($rules) { |
|
|
| 2261 |
if ( defined $rules->{ $item->itype } ) { |
| 2262 |
foreach my $notloan_rule_key ( keys %{ $rules->{ $item->itype } } ) { |
| 2263 |
if ( $item->notforloan eq $notloan_rule_key ) { |
| 2264 |
$messages->{'NotForLoanStatusUpdated'} = |
| 2265 |
{ from => $item->notforloan, to => $rules->{ $item->itype }->{$notloan_rule_key} }; |
| 2266 |
$item->notforloan( $rules->{ $item->itype }->{$notloan_rule_key} ) |
| 2267 |
->store( { log_action => 0, skip_record_index => 1, skip_holds_queue => 1 } ) |
| 2268 |
unless $rules->{ $item->itype }->{$notloan_rule_key} eq 'ONLYMESSAGE'; |
| 2269 |
last; |
| 2270 |
} |
| 2271 |
} |
| 2272 |
} elsif ( defined $rules->{'_ALL_'} ) { |
| 2273 |
foreach my $notloan_rule_key ( keys %{ $rules->{'_ALL_'} } ) { |
| 2274 |
if ( $item->notforloan eq $notloan_rule_key ) { |
| 2275 |
$messages->{'NotForLoanStatusUpdated'} = |
| 2276 |
{ from => $item->notforloan, to => $rules->{'_ALL_'}->{$notloan_rule_key} }; |
| 2277 |
$item->notforloan( $rules->{'_ALL_'}->{$notloan_rule_key} ) |
| 2278 |
->store( { log_action => 0, skip_record_index => 1, skip_holds_queue => 1 } ) |
| 2279 |
unless $rules->{'_ALL_'}->{$notloan_rule_key} eq 'ONLYMESSAGE'; |
| 2280 |
last; |
| 2281 |
} |
| 2282 |
} |
| 2283 |
} |
| 2284 |
} |
| 2285 |
|
2250 |
|
| 2286 |
# check if the return is allowed at this branch |
2251 |
# check if the return is allowed at this branch |
| 2287 |
my ( $returnallowed, $message ) = CanBookBeReturned( $item->unblessed, $branch ); |
2252 |
my ( $returnallowed, $message ) = CanBookBeReturned( $item->unblessed, $branch ); |
|
Lines 4807-4812
sub _CanBookBeAutoRenewed {
Link Here
|
| 4807 |
return "ok"; |
4772 |
return "ok"; |
| 4808 |
} |
4773 |
} |
| 4809 |
|
4774 |
|
|
|
4775 |
sub _updateNotForLoanFromYaml { |
| 4776 |
my ( $item, $NotForLoanUpdatePreference, $messages ) = @_; |
| 4777 |
|
| 4778 |
my $yaml = C4::Context->preference($NotForLoanUpdatePreference); |
| 4779 |
if ($yaml) { |
| 4780 |
$yaml = "$yaml\n\n"; |
| 4781 |
my $rules; |
| 4782 |
eval { $rules = YAML::XS::Load( Encode::encode_utf8($yaml) ); }; |
| 4783 |
if ($@) { |
| 4784 |
warn "Unable to parse $NotForLoanUpdatePreference syspref : $@"; |
| 4785 |
} else { |
| 4786 |
if ( defined $rules->{ $item->itype } ) { |
| 4787 |
foreach my $notloan_rule_key ( keys %{ $rules->{ $item->itype } } ) { |
| 4788 |
if ( $item->notforloan eq $notloan_rule_key ) { |
| 4789 |
$messages->{'NotForLoanStatusUpdated'} = |
| 4790 |
{ from => $item->notforloan, to => $rules->{ $item->itype }->{$notloan_rule_key} }; |
| 4791 |
$item->notforloan( $rules->{ $item->itype }->{$notloan_rule_key} ) |
| 4792 |
->store( { log_action => 0, skip_record_index => 1, skip_holds_queue => 1 } ) |
| 4793 |
unless $rules->{ $item->itype }->{$notloan_rule_key} eq 'ONLYMESSAGE'; |
| 4794 |
last; |
| 4795 |
} |
| 4796 |
} |
| 4797 |
} elsif ( defined $rules->{'_ALL_'} ) { |
| 4798 |
foreach my $notloan_rule_key ( keys %{ $rules->{'_ALL_'} } ) { |
| 4799 |
if ( $item->notforloan eq $notloan_rule_key ) { |
| 4800 |
$messages->{'NotForLoanStatusUpdated'} = |
| 4801 |
{ from => $item->notforloan, to => $rules->{'_ALL_'}->{$notloan_rule_key} }; |
| 4802 |
$item->notforloan( $rules->{'_ALL_'}->{$notloan_rule_key} ) |
| 4803 |
->store( { log_action => 0, skip_record_index => 1, skip_holds_queue => 1 } ) |
| 4804 |
unless $rules->{'_ALL_'}->{$notloan_rule_key} eq 'ONLYMESSAGE'; |
| 4805 |
last; |
| 4806 |
} |
| 4807 |
} |
| 4808 |
} |
| 4809 |
} |
| 4810 |
} |
| 4811 |
} |
| 4812 |
|
| 4810 |
1; |
4813 |
1; |
| 4811 |
|
4814 |
|
| 4812 |
__END__ |
4815 |
__END__ |
| 4813 |
- |
|
|