-if ( $borr->{dateexpiry} && C4::Context->preference('NotifyBorrowerDeparture') &&
- Date_to_Days(Add_Delta_Days($warning_year,$warning_month,$warning_day,- C4::Context->preference('NotifyBorrowerDeparture'))) <
- Date_to_Days( $today_year, $today_month, $today_day ) )
-{
- # borrower card soon to expire, warn the borrower
- $borr->{'warndeparture'} = $borr->{dateexpiry};
- if (C4::Context->preference('ReturnBeforeExpiry')){
- $borr->{'returnbeforeexpiry'} = 1;
- }
+if ( $borr->{dateexpiry} && Date_to_Days( $today_year, $today_month, $today_day ) > Date_to_Days( $warning_year, $warning_month, $warning_day ) ) {
+ $borr->{'warnexpired'} = 1;
+}
+elsif ( $borr->{dateexpiry} && C4::Context->preference('NotifyBorrowerDeparture') &&
+ Date_to_Days(Add_Delta_Days($warning_year, $warning_month, $warning_day,- C4::Context->preference('NotifyBorrowerDeparture'))) <
+ Date_to_Days( $today_year, $today_month, $today_day ) ) {
+ # borrower card soon to expire, warn the borrower
+ $borr->{'warndeparture'} = $borr->{dateexpiry};
+ if (C4::Context->preference('ReturnBeforeExpiry')){
+ $borr->{'returnbeforeexpiry'} = 1;
+ }