View | Details | Raw Unified | Return to bug 15494
Collapse All | Expand All

(-)a/C4/Circulation.pm (-2 / +37 lines)
Lines 54-60 use Koha::Holds; Link Here
54
use Koha::RefundLostItemFeeRule;
54
use Koha::RefundLostItemFeeRule;
55
use Koha::RefundLostItemFeeRules;
55
use Koha::RefundLostItemFeeRules;
56
use Carp;
56
use Carp;
57
use List::MoreUtils qw( uniq );
57
use List::MoreUtils qw( uniq any );
58
use YAML qw/Load/;
58
use Scalar::Util qw( looks_like_number );
59
use Scalar::Util qw( looks_like_number );
59
use Date::Calc qw(
60
use Date::Calc qw(
60
  Today
61
  Today
Lines 2657-2662 sub CanBookBeRenewed { Link Here
2657
    my $itemissue = GetItemIssue($itemnumber) or return ( 0, 'no_checkout' );
2658
    my $itemissue = GetItemIssue($itemnumber) or return ( 0, 'no_checkout' );
2658
    return ( 0, 'onsite_checkout' ) if $itemissue->{onsite_checkout};
2659
    return ( 0, 'onsite_checkout' ) if $itemissue->{onsite_checkout};
2659
2660
2661
    return ( 0, 'item_denied_renewal') if _item_denied_renewal({ item => $item });
2662
2660
    $borrowernumber ||= $itemissue->{borrowernumber};
2663
    $borrowernumber ||= $itemissue->{borrowernumber};
2661
    my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber )
2664
    my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber )
2662
      or return;
2665
      or return;
Lines 4102-4107 sub _CalculateAndUpdateFine { Link Here
4102
    }
4105
    }
4103
}
4106
}
4104
4107
4108
sub _item_denied_renewal {
4109
    my ($params) = @_;
4110
4111
    my $item = $params->{item};
4112
    unless ($item)    { carp "No item passed in!" && return }
4113
4114
    my $yaml = C4::Context->preference('ItemsDeniedRenewal');
4115
    return () if (! $yaml =~ /\S/ );
4116
    $yaml = "$yaml\n\n"; # YAML is anal on ending \n. Surplus does not hurt
4117
    my $denyingrules;
4118
    eval {
4119
        $denyingrules = YAML::Load($yaml);
4120
    };
4121
    if ($@) {
4122
        warn "Unable to parse ItemsDeniedRenewal syspref : $@";
4123
        return ();
4124
    }
4125
    foreach my $field (keys %$denyingrules) {
4126
        my $val;
4127
        if (exists $item->{$field}) {
4128
            $val = $item->{$field};
4129
        }
4130
        $val = '' unless defined $val;
4131
        # If the results matches the values in the yaml file
4132
        if (any { $val eq $_ } @{$denyingrules->{$field}}) {
4133
             # We return true if match found
4134
            return 1;
4135
        }
4136
    }
4137
    return 0;
4138
}
4139
4140
4105
1;
4141
1;
4106
4142
4107
__END__
4143
__END__
4108
- 

Return to bug 15494