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

(-)a/C4/Circulation.pm (-3 / +15 lines)
Lines 2737-2743 sub CanBookBeRenewed { Link Here
2737
    return ( 0, "too_many" )
2737
    return ( 0, "too_many" )
2738
      if $issuingrule->{renewalsallowed} <= $itemissue->{renewals};
2738
      if $issuingrule->{renewalsallowed} <= $itemissue->{renewals};
2739
2739
2740
    if ( $issuingrule->{norenewalbefore} ) {
2740
    if ( defined $issuingrule->{norenewalbefore} ) {
2741
2741
2742
        # Get current time and add norenewalbefore.
2742
        # Get current time and add norenewalbefore.
2743
        # If this is smaller than date_due, it's too soon for renewal.
2743
        # If this is smaller than date_due, it's too soon for renewal.
Lines 2750-2758 sub CanBookBeRenewed { Link Here
2750
            return ( 0, "auto_too_soon" ) if $itemissue->{auto_renew};
2750
            return ( 0, "auto_too_soon" ) if $itemissue->{auto_renew};
2751
            return ( 0, "too_soon" );
2751
            return ( 0, "too_soon" );
2752
        }
2752
        }
2753
        else {
2754
            return ( 0, "auto_renew" ) if $itemissue->{auto_renew};
2755
            return ( 1, undef );
2756
        }
2757
    }
2758
2759
    # Fallback for automatic renewals:
2760
    # If norenewalbefore is undef, don't renew before due date.
2761
    elsif ( $itemissue->{auto_renew} ) {
2762
        return ( 0, "auto_renew" )
2763
          if DateTime->now( time_zone => C4::Context->tz() ) >=
2764
              $itemissue->{date_due};
2765
        return ( 0, "auto_too_soon" );
2753
    }
2766
    }
2754
2767
2755
    return ( 0, "auto_renew" ) if $itemissue->{auto_renew};
2756
    return ( 1, undef );
2768
    return ( 1, undef );
2757
}
2769
}
2758
2770
Lines 2966-2972 sub GetSoonestRenewDate { Link Here
2966
2978
2967
    my $now = DateTime->now( time_zone => C4::Context->tz() );
2979
    my $now = DateTime->now( time_zone => C4::Context->tz() );
2968
2980
2969
    if ( $issuingrule->{norenewalbefore} ) {
2981
    if ( defined $issuingrule->{norenewalbefore} ) {
2970
        my $soonestrenewal =
2982
        my $soonestrenewal =
2971
          $itemissue->{date_due}->subtract(
2983
          $itemissue->{date_due}->subtract(
2972
            $issuingrule->{lengthunit} => $issuingrule->{norenewalbefore} );
2984
            $issuingrule->{lengthunit} => $issuingrule->{norenewalbefore} );
(-)a/admin/smart-rules.pl (-2 / +1 lines)
Lines 114-120 elsif ($op eq 'add') { Link Here
114
    my $renewalsallowed  = $input->param('renewalsallowed');
114
    my $renewalsallowed  = $input->param('renewalsallowed');
115
    my $renewalperiod    = $input->param('renewalperiod');
115
    my $renewalperiod    = $input->param('renewalperiod');
116
    my $norenewalbefore  = $input->param('norenewalbefore');
116
    my $norenewalbefore  = $input->param('norenewalbefore');
117
    $norenewalbefore = undef if $norenewalbefore eq '0' or $norenewalbefore =~ /^\s*$/;
117
    $norenewalbefore = undef if $norenewalbefore =~ /^\s*$/;
118
    my $auto_renew = $input->param('auto_renew') eq 'yes' ? 1 : 0;
118
    my $auto_renew = $input->param('auto_renew') eq 'yes' ? 1 : 0;
119
    my $reservesallowed  = $input->param('reservesallowed');
119
    my $reservesallowed  = $input->param('reservesallowed');
120
    my $onshelfholds     = $input->param('onshelfholds') || 0;
120
    my $onshelfholds     = $input->param('onshelfholds') || 0;
121
- 

Return to bug 14101