Lines 41-48
Options:
Link Here
|
41 |
--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 |
42 |
--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 |
43 |
-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) |
44 |
--active=X only deal with active patrons (active within X months) |
45 |
--inactive=X only send notices to inactive patrons (inactive within X months) |
45 |
--inactive=X only deal with inactive patrons (inactive within X months) |
|
|
46 |
--renew renew patrons and send notice (instead of expiry notice only) |
46 |
|
47 |
|
47 |
=head1 DESCRIPTION |
48 |
=head1 DESCRIPTION |
48 |
|
49 |
|
Lines 109-115
Optional parameter to include active patrons only (active within passed number o
Link Here
|
109 |
=item B<-inactive> |
110 |
=item B<-inactive> |
110 |
|
111 |
|
111 |
Optional parameter to include inactive patrons only (inactive within passed number of months). |
112 |
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 |
This allows you to e.g. send expiry warnings only to inactive patrons. |
|
|
114 |
|
115 |
=item B<-renew> |
116 |
|
117 |
Optional parameter to automatically renew patrons instead of sending them an expiry notice. |
118 |
They will be informed by a patron renewal notice. |
113 |
|
119 |
|
114 |
=back |
120 |
=back |
115 |
|
121 |
|
Lines 171-176
my ( $branch, $letter_type );
Link Here
|
171 |
my @where; |
177 |
my @where; |
172 |
my $active; |
178 |
my $active; |
173 |
my $inactive; |
179 |
my $inactive; |
|
|
180 |
my $renew; |
174 |
|
181 |
|
175 |
my $command_line_options = join(" ",@ARGV); |
182 |
my $command_line_options = join(" ",@ARGV); |
176 |
|
183 |
|
Lines 187-192
GetOptions(
Link Here
|
187 |
'where=s' => \@where, |
194 |
'where=s' => \@where, |
188 |
'active:i' => \$active, |
195 |
'active:i' => \$active, |
189 |
'inactive:i' => \$inactive, |
196 |
'inactive:i' => \$inactive, |
|
|
197 |
'renew' => \$renew, |
190 |
) or pod2usage(2); |
198 |
) or pod2usage(2); |
191 |
|
199 |
|
192 |
pod2usage( -verbose => 2 ) if $man; |
200 |
pod2usage( -verbose => 2 ) if $man; |
Lines 223-229
warn 'found ' . $upcoming_mem_expires->count . ' soon expiring members'
Link Here
|
223 |
|
231 |
|
224 |
# main loop |
232 |
# main loop |
225 |
$letter_type = 'MEMBERSHIP_EXPIRY' if !$letter_type; |
233 |
$letter_type = 'MEMBERSHIP_EXPIRY' if !$letter_type; |
226 |
my ( $count_active, $count_inactive, $count_enqueued ) = ( 0, 0, 0 ); |
234 |
my ( $count_active, $count_inactive, $count_renewed, $count_enqueued ) = ( 0, 0, 0, 0 ); |
|
|
235 |
my $fees = {}; |
227 |
while ( my $recent = $upcoming_mem_expires->next ) { |
236 |
while ( my $recent = $upcoming_mem_expires->next ) { |
228 |
my $patron_active = $recent->is_active({ months => $active // $inactive }); # checked already that only one is defined |
237 |
my $patron_active = $recent->is_active({ months => $active // $inactive }); # checked already that only one is defined |
229 |
if( defined($active) && !$patron_active ) { |
238 |
if( defined($active) && !$patron_active ) { |
Lines 233-248
while ( my $recent = $upcoming_mem_expires->next ) {
Link Here
|
233 |
$count_active++; |
242 |
$count_active++; |
234 |
next; |
243 |
next; |
235 |
} |
244 |
} |
|
|
245 |
|
246 |
my ($which_notice, $substitute); |
247 |
if( $renew ) { |
248 |
$recent->renew_account; |
249 |
$which_notice = 'MEMBERSHIP_RENEWED'; |
250 |
$fees->{$recent->branchcode} = $recent->category->enrolmentfee if !exists $fees->{$recent->branchcode}; |
251 |
$substitute->{enrollment_fee} = $fees->{$recent->branchcode} if $fees->{$recent->branchcode} > 0; |
252 |
$count_renewed++; |
253 |
} else { |
254 |
$which_notice = $letter_type; |
255 |
} |
256 |
|
236 |
my $from_address = $recent->library->from_email_address; |
257 |
my $from_address = $recent->library->from_email_address; |
237 |
my $letter = C4::Letters::GetPreparedLetter( |
258 |
my $letter = C4::Letters::GetPreparedLetter( |
238 |
module => 'members', |
259 |
module => 'members', |
239 |
letter_code => $letter_type, |
260 |
letter_code => $which_notice, |
240 |
branchcode => $recent->branchcode, |
261 |
branchcode => $recent->branchcode, |
241 |
lang => $recent->lang, |
262 |
lang => $recent->lang, |
242 |
tables => { |
263 |
tables => { |
243 |
borrowers => $recent->borrowernumber, |
264 |
borrowers => $recent->borrowernumber, |
244 |
branches => $recent->branchcode, |
265 |
branches => $recent->branchcode, |
245 |
}, |
266 |
}, |
|
|
267 |
substitute => $substitute, |
246 |
); |
268 |
); |
247 |
last if !$letter; # Letters.pm already warned, just exit |
269 |
last if !$letter; # Letters.pm already warned, just exit |
248 |
if( $nomail ) { |
270 |
if( $nomail ) { |
Lines 261-273
while ( my $recent = $upcoming_mem_expires->next ) {
Link Here
|
261 |
if ($recent->smsalertnumber) { |
283 |
if ($recent->smsalertnumber) { |
262 |
my $smsletter = C4::Letters::GetPreparedLetter( |
284 |
my $smsletter = C4::Letters::GetPreparedLetter( |
263 |
module => 'members', |
285 |
module => 'members', |
264 |
letter_code => $letter_type, |
286 |
letter_code => $which_notice, |
265 |
branchcode => $recent->branchcode, |
287 |
branchcode => $recent->branchcode, |
266 |
lang => $recent->lang, |
288 |
lang => $recent->lang, |
267 |
tables => { |
289 |
tables => { |
268 |
borrowers => $recent->borrowernumber, |
290 |
borrowers => $recent->borrowernumber, |
269 |
branches => $recent->branchcode, |
291 |
branches => $recent->branchcode, |
270 |
}, |
292 |
}, |
|
|
293 |
substitute => $substitute, |
271 |
message_transport_type => 'sms', |
294 |
message_transport_type => 'sms', |
272 |
); |
295 |
); |
273 |
if ($smsletter) { |
296 |
if ($smsletter) { |
Lines 281-286
while ( my $recent = $upcoming_mem_expires->next ) {
Link Here
|
281 |
} |
304 |
} |
282 |
|
305 |
|
283 |
if( $verbose ) { |
306 |
if( $verbose ) { |
|
|
307 |
print "Membership renewed for $count_renewed patrons\n" if $count_renewed; |
284 |
print "Enqueued notices for $count_enqueued patrons\n"; |
308 |
print "Enqueued notices for $count_enqueued patrons\n"; |
285 |
print "Skipped $count_active active patrons\n" if $count_active; |
309 |
print "Skipped $count_active active patrons\n" if $count_active; |
286 |
print "Skipped $count_inactive inactive patrons\n" if $count_inactive; |
310 |
print "Skipped $count_inactive inactive patrons\n" if $count_inactive; |
287 |
- |
|
|