|
Lines 30-39
use Koha::Checkouts;
Link Here
|
| 30 |
use Koha::TemplateUtils qw( process_tt ); |
30 |
use Koha::TemplateUtils qw( process_tt ); |
| 31 |
use Koha::Patron::Messages; |
31 |
use Koha::Patron::Messages; |
| 32 |
use Koha::DateUtils qw(dt_from_string output_pref); |
32 |
use Koha::DateUtils qw(dt_from_string output_pref); |
|
|
33 |
use Date::Calc qw/Today Date_to_Days/; |
| 33 |
|
34 |
|
| 34 |
our $kp; # koha patron |
35 |
our $kp; # koha patron |
| 35 |
|
36 |
|
| 36 |
=head1 METHODS |
37 |
=head1 Methods |
| 37 |
|
38 |
|
| 38 |
=cut |
39 |
=cut |
| 39 |
|
40 |
|
|
Lines 64-77
sub new {
Link Here
|
| 64 |
my $pw = $kp->{password}; |
65 |
my $pw = $kp->{password}; |
| 65 |
my $flags = C4::Members::patronflags( $kp ); |
66 |
my $flags = C4::Members::patronflags( $kp ); |
| 66 |
my $debarred = $patron->is_debarred; |
67 |
my $debarred = $patron->is_debarred; |
| 67 |
my ($day, $month, $year) = (localtime)[3,4,5]; |
68 |
siplog( "LOG_DEBUG", "Debarred = %s : ", ( $debarred || 'undef' ) ); # Do we need more debug info here? |
| 68 |
my $today = sprintf '%04d-%02d-%02d', $year+1900, $month+1, $day; |
69 |
my $expired = 0; |
| 69 |
my $expired = ($today gt $kp->{dateexpiry}) ? 1 : 0; |
70 |
if ( $kp->{'dateexpiry'} && C4::Context->preference('NotifyBorrowerDeparture') ) { |
| 70 |
if ($expired) { |
71 |
my ( $today_year, $today_month, $today_day ) = Today(); |
| 71 |
if ($kp->{opacnote} ) { |
72 |
my ( $warning_year, $warning_month, $warning_day ) = split /-/, $kp->{'dateexpiry'}; |
| 72 |
$kp->{opacnote} .= q{ }; |
73 |
my $days_to_expiry = Date_to_Days( $warning_year, $warning_month, $warning_day ) - |
|
|
74 |
Date_to_Days( $today_year, $today_month, $today_day ); |
| 75 |
my $dt = dt_from_string( $kp->{'dateexpiry'}, 'iso' ); |
| 76 |
my $dateexpiry = output_pref( { dt => $dt, dateonly => 1 } ); |
| 77 |
if ( $days_to_expiry < 0 ) { |
| 78 |
|
| 79 |
#borrower card has expired, warn the borrower |
| 80 |
if ( $kp->{opacnote} ) { |
| 81 |
$kp->{opacnote} .= q{ }; |
| 82 |
} |
| 83 |
$kp->{opacnote} .= "Your account has expired as of $dateexpiry"; |
| 84 |
$expired = 1; |
| 85 |
} elsif ( $days_to_expiry < C4::Context->preference('NotifyBorrowerDeparture') ) { |
| 86 |
|
| 87 |
# borrower card soon to expire, warn the borrower |
| 88 |
if ( $kp->{opacnote} ) { |
| 89 |
$kp->{opacnote} .= q{ }; |
| 90 |
} |
| 91 |
$kp->{opacnote} .= "Your card will expire on $dateexpiry"; |
| 73 |
} |
92 |
} |
| 74 |
$kp->{opacnote} .= 'PATRON EXPIRED'; |
|
|
| 75 |
} |
93 |
} |
| 76 |
my %ilspatron; |
94 |
my %ilspatron; |
| 77 |
my $adr = _get_address($kp); |
95 |
my $adr = _get_address($kp); |