|
Lines 55-61
use Koha::Holds;
Link Here
|
| 55 |
use Koha::RefundLostItemFeeRule; |
55 |
use Koha::RefundLostItemFeeRule; |
| 56 |
use Koha::RefundLostItemFeeRules; |
56 |
use Koha::RefundLostItemFeeRules; |
| 57 |
use Carp; |
57 |
use Carp; |
| 58 |
use List::MoreUtils qw( uniq ); |
58 |
use List::MoreUtils qw( uniq any ); |
|
|
59 |
use YAML qw/Load/; |
| 59 |
use Scalar::Util qw( looks_like_number ); |
60 |
use Scalar::Util qw( looks_like_number ); |
| 60 |
use Date::Calc qw( |
61 |
use Date::Calc qw( |
| 61 |
Today |
62 |
Today |
|
Lines 2607-2612
sub CanBookBeRenewed {
Link Here
|
| 2607 |
my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return ( 0, 'no_checkout' ); |
2608 |
my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return ( 0, 'no_checkout' ); |
| 2608 |
return ( 0, 'onsite_checkout' ) if $issue->onsite_checkout; |
2609 |
return ( 0, 'onsite_checkout' ) if $issue->onsite_checkout; |
| 2609 |
|
2610 |
|
|
|
2611 |
return ( 0, 'item_denied_renewal') if _item_denied_renewal({ item => $item }); |
| 2612 |
|
| 2610 |
$borrowernumber ||= $issue->borrowernumber; |
2613 |
$borrowernumber ||= $issue->borrowernumber; |
| 2611 |
my $patron = Koha::Patrons->find( $borrowernumber ) |
2614 |
my $patron = Koha::Patrons->find( $borrowernumber ) |
| 2612 |
or return; |
2615 |
or return; |
|
Lines 4062-4067
sub _CalculateAndUpdateFine {
Link Here
|
| 4062 |
} |
4065 |
} |
| 4063 |
} |
4066 |
} |
| 4064 |
|
4067 |
|
|
|
4068 |
sub _item_denied_renewal { |
| 4069 |
my ($params) = @_; |
| 4070 |
|
| 4071 |
my $item = $params->{item}; |
| 4072 |
unless ($item) { carp "No item passed in!" && return } |
| 4073 |
|
| 4074 |
my $yaml = C4::Context->preference('ItemsDeniedRenewal'); |
| 4075 |
return () if (! $yaml =~ /\S/ ); |
| 4076 |
$yaml = "$yaml\n\n"; # YAML is anal on ending \n. Surplus does not hurt |
| 4077 |
my $denyingrules; |
| 4078 |
eval { |
| 4079 |
$denyingrules = YAML::Load($yaml); |
| 4080 |
}; |
| 4081 |
if ($@) { |
| 4082 |
warn "Unable to parse ItemsDeniedRenewal syspref : $@"; |
| 4083 |
return (); |
| 4084 |
} |
| 4085 |
foreach my $field (keys %$denyingrules) { |
| 4086 |
my $val; |
| 4087 |
if (exists $item->{$field}) { |
| 4088 |
$val = $item->{$field}; |
| 4089 |
} |
| 4090 |
$val = '' unless defined $val; |
| 4091 |
# If the results matches the values in the yaml file |
| 4092 |
if (any { $val eq $_ } @{$denyingrules->{$field}}) { |
| 4093 |
# We return true if match found |
| 4094 |
return 1; |
| 4095 |
} |
| 4096 |
} |
| 4097 |
return 0; |
| 4098 |
} |
| 4099 |
|
| 4100 |
|
| 4065 |
1; |
4101 |
1; |
| 4066 |
|
4102 |
|
| 4067 |
__END__ |
4103 |
__END__ |
| 4068 |
- |
|
|