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

(-)a/C4/Circulation.pm (-5 / +21 lines)
Lines 2817-2828 sub CanBookBeRenewed { Link Here
2817
        return ( 0, 'overdue');
2817
        return ( 0, 'overdue');
2818
    }
2818
    }
2819
2819
2820
    if ( $issuingrule->{norenewalbefore} ) {
2820
    if ( defined $issuingrule->{norenewalbefore}
2821
        and $issuingrule->{norenewalbefore} ne "" )
2822
    {
2821
2823
2822
        # Get current time and add norenewalbefore.
2824
        # Get current time and add norenewalbefore.
2823
        # If this is smaller than date_due, it's too soon for renewal.
2825
        # If this is smaller than date_due, it's too soon for renewal.
2826
        my $now = dt_from_string;
2824
        if (
2827
        if (
2825
            DateTime->now( time_zone => C4::Context->tz() )->add(
2828
            $now->add(
2826
                $issuingrule->{lengthunit} => $issuingrule->{norenewalbefore}
2829
                $issuingrule->{lengthunit} => $issuingrule->{norenewalbefore}
2827
            ) < $itemissue->{date_due}
2830
            ) < $itemissue->{date_due}
2828
          )
2831
          )
Lines 2830-2838 sub CanBookBeRenewed { Link Here
2830
            return ( 0, "auto_too_soon" ) if $itemissue->{auto_renew};
2833
            return ( 0, "auto_too_soon" ) if $itemissue->{auto_renew};
2831
            return ( 0, "too_soon" );
2834
            return ( 0, "too_soon" );
2832
        }
2835
        }
2836
        elsif ( $itemissue->{auto_renew} ) {
2837
            return ( 0, "auto_renew" );
2838
        }
2839
    }
2840
2841
    # Fallback for automatic renewals:
2842
    # If norenewalbefore is undef, don't renew before due date.
2843
    elsif ( $itemissue->{auto_renew} ) {
2844
        my $now = dt_from_string;
2845
        return ( 0, "auto_renew" )
2846
          if $now >= $itemissue->{date_due};
2847
        return ( 0, "auto_too_soon" );
2833
    }
2848
    }
2834
2849
2835
    return ( 0, "auto_renew" ) if $itemissue->{auto_renew};
2836
    return ( 1, undef );
2850
    return ( 1, undef );
2837
}
2851
}
2838
2852
Lines 3044-3052 sub GetSoonestRenewDate { Link Here
3044
    my $issuingrule =
3058
    my $issuingrule =
3045
      GetIssuingRule( $borrower->{categorycode}, $item->{itype}, $branchcode );
3059
      GetIssuingRule( $borrower->{categorycode}, $item->{itype}, $branchcode );
3046
3060
3047
    my $now = DateTime->now( time_zone => C4::Context->tz() );
3061
    my $now = dt_from_string;
3048
3062
3049
    if ( $issuingrule->{norenewalbefore} ) {
3063
    if ( defined $issuingrule->{norenewalbefore}
3064
        and $issuingrule->{norenewalbefore} ne "" )
3065
    {
3050
        my $soonestrenewal =
3066
        my $soonestrenewal =
3051
          $itemissue->{date_due}->subtract(
3067
          $itemissue->{date_due}->subtract(
3052
            $issuingrule->{lengthunit} => $issuingrule->{norenewalbefore} );
3068
            $issuingrule->{lengthunit} => $issuingrule->{norenewalbefore} );
(-)a/admin/smart-rules.pl (-2 / +1 lines)
Lines 117-123 elsif ($op eq 'add') { Link Here
117
    my $renewalsallowed  = $input->param('renewalsallowed');
117
    my $renewalsallowed  = $input->param('renewalsallowed');
118
    my $renewalperiod    = $input->param('renewalperiod');
118
    my $renewalperiod    = $input->param('renewalperiod');
119
    my $norenewalbefore  = $input->param('norenewalbefore');
119
    my $norenewalbefore  = $input->param('norenewalbefore');
120
    $norenewalbefore = undef if $norenewalbefore eq '0' or $norenewalbefore =~ /^\s*$/;
120
    $norenewalbefore = undef if $norenewalbefore =~ /^\s*$/;
121
    my $auto_renew = $input->param('auto_renew') eq 'yes' ? 1 : 0;
121
    my $auto_renew = $input->param('auto_renew') eq 'yes' ? 1 : 0;
122
    my $reservesallowed  = $input->param('reservesallowed');
122
    my $reservesallowed  = $input->param('reservesallowed');
123
    my $onshelfholds     = $input->param('onshelfholds') || 0;
123
    my $onshelfholds     = $input->param('onshelfholds') || 0;
124
- 

Return to bug 14101