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_skipped, $count_enqueued ) = ( 0, 0 ); |
234 |
my ( $count_skipped, $count_renewed, $count_enqueued ) = ( 0, 0, 0 ); |
|
|
235 |
my $fees = {}; |
227 |
while ( my $recent = $upcoming_mem_expires->next ) { |
236 |
while ( my $recent = $upcoming_mem_expires->next ) { |
228 |
if ( $active && !$recent->is_active( { months => $active } ) ) { |
237 |
if ( $active && !$recent->is_active( { months => $active } ) ) { |
229 |
$count_skipped++; |
238 |
$count_skipped++; |
Lines 232-247
while ( my $recent = $upcoming_mem_expires->next ) {
Link Here
|
232 |
$count_skipped++; |
241 |
$count_skipped++; |
233 |
next; |
242 |
next; |
234 |
} |
243 |
} |
|
|
244 |
|
245 |
my ($which_notice, $substitute); |
246 |
if( $renew ) { |
247 |
$recent->renew_account; |
248 |
$which_notice = 'MEMBERSHIP_RENEWED'; |
249 |
$fees->{$recent->branchcode} = $recent->category->enrolmentfee if !exists $fees->{$recent->branchcode}; |
250 |
$substitute->{enrollment_fee} = $fees->{$recent->branchcode} if $fees->{$recent->branchcode} > 0; |
251 |
$count_renewed++; |
252 |
} else { |
253 |
$which_notice = $letter_type; |
254 |
} |
255 |
|
235 |
my $from_address = $recent->library->from_email_address; |
256 |
my $from_address = $recent->library->from_email_address; |
236 |
my $letter = C4::Letters::GetPreparedLetter( |
257 |
my $letter = C4::Letters::GetPreparedLetter( |
237 |
module => 'members', |
258 |
module => 'members', |
238 |
letter_code => $letter_type, |
259 |
letter_code => $which_notice, |
239 |
branchcode => $recent->branchcode, |
260 |
branchcode => $recent->branchcode, |
240 |
lang => $recent->lang, |
261 |
lang => $recent->lang, |
241 |
tables => { |
262 |
tables => { |
242 |
borrowers => $recent->borrowernumber, |
263 |
borrowers => $recent->borrowernumber, |
243 |
branches => $recent->branchcode, |
264 |
branches => $recent->branchcode, |
244 |
}, |
265 |
}, |
|
|
266 |
substitute => $substitute, |
245 |
); |
267 |
); |
246 |
last if !$letter; # Letters.pm already warned, just exit |
268 |
last if !$letter; # Letters.pm already warned, just exit |
247 |
if( $nomail ) { |
269 |
if( $nomail ) { |
Lines 260-272
while ( my $recent = $upcoming_mem_expires->next ) {
Link Here
|
260 |
if ($recent->smsalertnumber) { |
282 |
if ($recent->smsalertnumber) { |
261 |
my $smsletter = C4::Letters::GetPreparedLetter( |
283 |
my $smsletter = C4::Letters::GetPreparedLetter( |
262 |
module => 'members', |
284 |
module => 'members', |
263 |
letter_code => $letter_type, |
285 |
letter_code => $which_notice, |
264 |
branchcode => $recent->branchcode, |
286 |
branchcode => $recent->branchcode, |
265 |
lang => $recent->lang, |
287 |
lang => $recent->lang, |
266 |
tables => { |
288 |
tables => { |
267 |
borrowers => $recent->borrowernumber, |
289 |
borrowers => $recent->borrowernumber, |
268 |
branches => $recent->branchcode, |
290 |
branches => $recent->branchcode, |
269 |
}, |
291 |
}, |
|
|
292 |
substitute => $substitute, |
270 |
message_transport_type => 'sms', |
293 |
message_transport_type => 'sms', |
271 |
); |
294 |
); |
272 |
if ($smsletter) { |
295 |
if ($smsletter) { |
Lines 280-285
while ( my $recent = $upcoming_mem_expires->next ) {
Link Here
|
280 |
} |
303 |
} |
281 |
|
304 |
|
282 |
if ($verbose) { |
305 |
if ($verbose) { |
|
|
306 |
print "Membership renewed for $count_renewed patrons\n" if $count_renewed; |
283 |
print "Enqueued notices for $count_enqueued patrons\n"; |
307 |
print "Enqueued notices for $count_enqueued patrons\n"; |
284 |
print "Skipped $count_skipped inactive patrons\n" if $active; |
308 |
print "Skipped $count_skipped inactive patrons\n" if $active; |
285 |
print "Skipped $count_skipped active patrons\n" if $inactive; |
309 |
print "Skipped $count_skipped active patrons\n" if $inactive; |
286 |
- |
|
|