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

(-)a/C4/Circulation.pm (-2 / +37 lines)
Lines 58-64 use Koha::RefundLostItemFeeRules; Link Here
58
use Koha::Account::Lines;
58
use Koha::Account::Lines;
59
use Koha::Account::Offsets;
59
use Koha::Account::Offsets;
60
use Carp;
60
use Carp;
61
use List::MoreUtils qw( uniq );
61
use List::MoreUtils qw( uniq any );
62
use Scalar::Util qw( looks_like_number );
62
use Scalar::Util qw( looks_like_number );
63
use Date::Calc qw(
63
use Date::Calc qw(
64
  Today
64
  Today
Lines 2595-2600 sub CanBookBeRenewed { Link Here
2595
    my $item      = GetItem($itemnumber)      or return ( 0, 'no_item' );
2595
    my $item      = GetItem($itemnumber)      or return ( 0, 'no_item' );
2596
    my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return ( 0, 'no_checkout' );
2596
    my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } ) or return ( 0, 'no_checkout' );
2597
    return ( 0, 'onsite_checkout' ) if $issue->onsite_checkout;
2597
    return ( 0, 'onsite_checkout' ) if $issue->onsite_checkout;
2598
    return ( 0, 'item_denied_renewal') if _item_denied_renewal({ item => $item });
2599
2598
2600
2599
    $borrowernumber ||= $issue->borrowernumber;
2601
    $borrowernumber ||= $issue->borrowernumber;
2600
    my $patron = Koha::Patrons->find( $borrowernumber )
2602
    my $patron = Koha::Patrons->find( $borrowernumber )
Lines 4100-4105 sub _CalculateAndUpdateFine { Link Here
4100
    }
4102
    }
4101
}
4103
}
4102
4104
4105
sub _item_denied_renewal {
4106
    my ($params) = @_;
4107
4108
    my $item = $params->{item};
4109
    return unless $item;
4110
4111
    my $yaml = C4::Context->preference('ItemsDeniedRenewal');
4112
    my @lines = split /\n/, $yaml;
4113
    my $denyingrules;
4114
    foreach my $line (@lines){
4115
        my ($field,$array) = split /:/, $line;
4116
        $array =~ s/[ [\]\r]//g;
4117
        my @array = split /,/, $array;
4118
        @array = map { $_ eq 'NULL' ? undef : $_ } @array;
4119
        @array = map { $_ eq '""' || $_ eq "''" ? undef : $_ } @array;
4120
        $denyingrules->{$field} = \@array;
4121
    }
4122
    return unless $denyingrules;
4123
    foreach my $field (keys %$denyingrules) {
4124
        my $val = $item->{$field};
4125
        if( !defined $val) {
4126
            if ( any { !defined $_ }  @{$denyingrules->{$field}} ){
4127
                return 1;
4128
            }
4129
        } elsif (any { $val eq $_ } @{$denyingrules->{$field}}) {
4130
           # If the results matches the values in the syspref
4131
           # We return true if match found
4132
            return 1;
4133
        }
4134
    }
4135
    return 0;
4136
}
4137
4138
4103
1;
4139
1;
4104
4140
4105
__END__
4141
__END__
4106
- 

Return to bug 15494