|
Lines 2750-2787
sub CanBookBeRenewed {
Link Here
|
| 2750 |
} |
2750 |
} |
| 2751 |
} |
2751 |
} |
| 2752 |
|
2752 |
|
| 2753 |
if ( defined $issuing_rule->norenewalbefore |
2753 |
#NOTE: If norenewalbefore is undef, $soonestrenewal will equal $now |
| 2754 |
and $issuing_rule->norenewalbefore ne "" ) |
2754 |
my $soonestrenewal = GetSoonestRenewDate($borrowernumber, $itemnumber); |
| 2755 |
{ |
2755 |
my $now = dt_from_string; |
| 2756 |
|
|
|
| 2757 |
# Calculate soonest renewal by subtracting 'No renewal before' from due date |
| 2758 |
my $soonestrenewal = dt_from_string( $issue->date_due, 'sql' )->subtract( |
| 2759 |
$issuing_rule->lengthunit => $issuing_rule->norenewalbefore ); |
| 2760 |
|
2756 |
|
| 2761 |
# Depending on syspref reset the exact time, only check the date |
2757 |
if ( $issue->auto_renew ){ |
| 2762 |
if ( C4::Context->preference('NoRenewalBeforePrecision') eq 'date' |
2758 |
if ( $soonestrenewal > $now ){ |
| 2763 |
and $issuing_rule->lengthunit eq 'days' ) |
2759 |
return ( 0, "auto_too_soon" ); |
| 2764 |
{ |
|
|
| 2765 |
$soonestrenewal->truncate( to => 'day' ); |
| 2766 |
} |
2760 |
} |
| 2767 |
|
2761 |
else { |
| 2768 |
if ( $soonestrenewal > DateTime->now( time_zone => C4::Context->tz() ) ) |
2762 |
#Fallback: if norenewalbefore is undef, don't renew before due date |
| 2769 |
{ |
2763 |
if ( dt_from_string( $issue->date_due, 'sql' ) > $now ){ |
| 2770 |
return ( 0, "auto_too_soon" ) if $issue->auto_renew; |
2764 |
return ( 0, "auto_too_soon" ); |
| 2771 |
return ( 0, "too_soon" ); |
2765 |
} |
| 2772 |
} |
2766 |
else { |
| 2773 |
elsif ( $issue->auto_renew ) { |
2767 |
return ( 0, "auto_renew" ); |
| 2774 |
return ( 0, "auto_renew" ); |
2768 |
} |
| 2775 |
} |
2769 |
} |
| 2776 |
} |
2770 |
} |
| 2777 |
|
2771 |
else { |
| 2778 |
# Fallback for automatic renewals: |
2772 |
if ( $soonestrenewal > $now ){ |
| 2779 |
# If norenewalbefore is undef, don't renew before due date. |
2773 |
return ( 0, "too_soon" ); |
| 2780 |
if ( $issue->auto_renew ) { |
2774 |
} |
| 2781 |
my $now = dt_from_string; |
|
|
| 2782 |
return ( 0, "auto_renew" ) |
| 2783 |
if $now >= dt_from_string( $issue->date_due, 'sql' ); |
| 2784 |
return ( 0, "auto_too_soon" ); |
| 2785 |
} |
2775 |
} |
| 2786 |
|
2776 |
|
| 2787 |
return ( 1, undef ); |
2777 |
return ( 1, undef ); |
| 2788 |
- |
|
|