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

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

Return to bug 14101