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