Lines 2-8
Link Here
|
2 |
|
2 |
|
3 |
# This file is part of Koha. |
3 |
# This file is part of Koha. |
4 |
# |
4 |
# |
5 |
# Copyright (C) 2015 Amit Gupta (amitddng135@gmail.com) |
5 |
# Copyright 2023 Koha development team |
|
|
6 |
# Copyright 2015 Amit Gupta (amitddng135@gmail.com) |
6 |
# |
7 |
# |
7 |
# Koha is free software; you can redistribute it and/or modify it |
8 |
# Koha is free software; you can redistribute it and/or modify it |
8 |
# under the terms of the GNU General Public License as published by |
9 |
# under the terms of the GNU General Public License as published by |
Lines 40-45
Options:
Link Here
|
40 |
--before=X include patrons expiring a number of days BEFORE the date set by the preference |
41 |
--before=X include patrons expiring a number of days BEFORE the date set by the preference |
41 |
--after=X include patrons expiring a number of days AFTER the date set by the preference |
42 |
--after=X include patrons expiring a number of days AFTER the date set by the preference |
42 |
-l --letter <lettercode> use a specific notice rather than the default |
43 |
-l --letter <lettercode> use a specific notice rather than the default |
|
|
44 |
--active=X only send notices to active patrons (active within X months) |
45 |
--inactive=X only send notices to inactive patrons (inactive within X months) |
43 |
|
46 |
|
44 |
=head1 DESCRIPTION |
47 |
=head1 DESCRIPTION |
45 |
|
48 |
|
Lines 99-104
will only notify patrons who have been seen.
Link Here
|
99 |
|
102 |
|
100 |
Optional parameter to use another notice than the default: MEMBERSHIP_EXPIRY |
103 |
Optional parameter to use another notice than the default: MEMBERSHIP_EXPIRY |
101 |
|
104 |
|
|
|
105 |
=item B<-active> |
106 |
|
107 |
Optional parameter to include active patrons only (active within passed number of months). |
108 |
|
109 |
=item B<-inactive> |
110 |
|
111 |
Optional parameter to include inactive patrons only (inactive within passed number of months). |
112 |
This allows you to skip active patrons when you renew them automatically (see bug 28688). |
113 |
|
102 |
=back |
114 |
=back |
103 |
|
115 |
|
104 |
=head1 CONFIGURATION |
116 |
=head1 CONFIGURATION |
Lines 157-162
my $before = 0;
Link Here
|
157 |
my $after = 0; |
169 |
my $after = 0; |
158 |
my ( $branch, $letter_type ); |
170 |
my ( $branch, $letter_type ); |
159 |
my @where; |
171 |
my @where; |
|
|
172 |
my $active; |
173 |
my $inactive; |
160 |
|
174 |
|
161 |
my $command_line_options = join(" ",@ARGV); |
175 |
my $command_line_options = join(" ",@ARGV); |
162 |
|
176 |
|
Lines 171-180
GetOptions(
Link Here
|
171 |
'after:i' => \$after, |
185 |
'after:i' => \$after, |
172 |
'letter:s' => \$letter_type, |
186 |
'letter:s' => \$letter_type, |
173 |
'where=s' => \@where, |
187 |
'where=s' => \@where, |
|
|
188 |
'active:i' => \$active, |
189 |
'inactive:i' => \$inactive, |
174 |
) or pod2usage(2); |
190 |
) or pod2usage(2); |
175 |
|
191 |
|
176 |
pod2usage( -verbose => 2 ) if $man; |
192 |
pod2usage( -verbose => 2 ) if $man; |
177 |
pod2usage(1) if $help || !$confirm; |
193 |
pod2usage(1) if $help || !$confirm; |
|
|
194 |
if( defined($active) && defined($inactive) ) { |
195 |
print "Sorry, it is not possible to pass both -active as well as -inactive.\n"; |
196 |
exit; |
197 |
} |
178 |
|
198 |
|
179 |
cronlogaction({ info => $command_line_options }); |
199 |
cronlogaction({ info => $command_line_options }); |
180 |
|
200 |
|
Lines 203-209
warn 'found ' . $upcoming_mem_expires->count . ' soon expiring members'
Link Here
|
203 |
|
223 |
|
204 |
# main loop |
224 |
# main loop |
205 |
$letter_type = 'MEMBERSHIP_EXPIRY' if !$letter_type; |
225 |
$letter_type = 'MEMBERSHIP_EXPIRY' if !$letter_type; |
|
|
226 |
my ( $count_active, $count_inactive, $count_enqueued ) = ( 0, 0, 0 ); |
206 |
while ( my $recent = $upcoming_mem_expires->next ) { |
227 |
while ( my $recent = $upcoming_mem_expires->next ) { |
|
|
228 |
my $patron_active = $recent->is_active({ months => $active // $inactive }); # checked already that only one is defined |
229 |
if( defined($active) && !$patron_active ) { |
230 |
$count_inactive++; |
231 |
next; |
232 |
} elsif( defined($inactive) && $patron_active ) { |
233 |
$count_active++; |
234 |
next; |
235 |
} |
207 |
my $from_address = $recent->library->from_email_address; |
236 |
my $from_address = $recent->library->from_email_address; |
208 |
my $letter = C4::Letters::GetPreparedLetter( |
237 |
my $letter = C4::Letters::GetPreparedLetter( |
209 |
module => 'members', |
238 |
module => 'members', |
Lines 227-232
while ( my $recent = $upcoming_mem_expires->next ) {
Link Here
|
227 |
from_address => $from_address, |
256 |
from_address => $from_address, |
228 |
message_transport_type => 'email', |
257 |
message_transport_type => 'email', |
229 |
}); |
258 |
}); |
|
|
259 |
$count_enqueued++; |
230 |
|
260 |
|
231 |
if ($recent->smsalertnumber) { |
261 |
if ($recent->smsalertnumber) { |
232 |
my $smsletter = C4::Letters::GetPreparedLetter( |
262 |
my $smsletter = C4::Letters::GetPreparedLetter( |
Lines 250-253
while ( my $recent = $upcoming_mem_expires->next ) {
Link Here
|
250 |
} |
280 |
} |
251 |
} |
281 |
} |
252 |
|
282 |
|
|
|
283 |
if( $verbose ) { |
284 |
print "Enqueued notices for $count_enqueued patrons\n"; |
285 |
print "Skipped $count_active active patrons\n" if $count_active; |
286 |
print "Skipped $count_inactive inactive patrons\n" if $count_inactive; |
287 |
} |
288 |
|
253 |
cronlogaction({ action => 'End', info => "COMPLETED" }); |
289 |
cronlogaction({ action => 'End', info => "COMPLETED" }); |
254 |
- |
|
|