|
Lines 40-46
Options:
Link Here
|
| 40 |
-b --branch <branchname> only deal with patrons from this library/branch |
40 |
-b --branch <branchname> only deal with patrons from this library/branch |
| 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 membership expiry notice |
|
|
44 |
--letter_renew <code> use a specific membership renewal notice (needs --renew too) |
| 44 |
--active=X only deal with active patrons (active within X months) |
45 |
--active=X only deal with active patrons (active within X months) |
| 45 |
--inactive=X only deal with inactive patrons (inactive within X months) |
46 |
--inactive=X only deal with inactive patrons (inactive within X months) |
| 46 |
--renew renew patrons and send notice (instead of expiry notice only) |
47 |
--renew renew patrons and send notice (instead of expiry notice only) |
|
Lines 101-107
will only notify patrons who have been seen.
Link Here
|
| 101 |
|
102 |
|
| 102 |
=item B<-letter> |
103 |
=item B<-letter> |
| 103 |
|
104 |
|
| 104 |
Optional parameter to use another notice than the default: MEMBERSHIP_EXPIRY |
105 |
Optional parameter to use another expiry notice than the default: MEMBERSHIP_EXPIRY |
|
|
106 |
|
| 107 |
=item B<-letter_renew> |
| 108 |
|
| 109 |
Optional parameter to use another renewal notice than the default: MEMBERSHIP_RENEWED |
| 105 |
|
110 |
|
| 106 |
=item B<-active> |
111 |
=item B<-active> |
| 107 |
|
112 |
|
|
Lines 173-183
my $help = 0;
Link Here
|
| 173 |
my $man = 0; |
178 |
my $man = 0; |
| 174 |
my $before = 0; |
179 |
my $before = 0; |
| 175 |
my $after = 0; |
180 |
my $after = 0; |
| 176 |
my ( $branch, $letter_type ); |
181 |
my $branch; |
| 177 |
my @where; |
182 |
my @where; |
| 178 |
my $active; |
183 |
my $active; |
| 179 |
my $inactive; |
184 |
my $inactive; |
| 180 |
my $renew; |
185 |
my $renew; |
|
|
186 |
my $letter_expiry; |
| 187 |
my $letter_renew; |
| 181 |
|
188 |
|
| 182 |
my $command_line_options = join(" ",@ARGV); |
189 |
my $command_line_options = join(" ",@ARGV); |
| 183 |
|
190 |
|
|
Lines 190-201
GetOptions(
Link Here
|
| 190 |
'branch:s' => \$branch, |
197 |
'branch:s' => \$branch, |
| 191 |
'before:i' => \$before, |
198 |
'before:i' => \$before, |
| 192 |
'after:i' => \$after, |
199 |
'after:i' => \$after, |
| 193 |
'letter:s' => \$letter_type, |
200 |
'letter:s' => \$letter_expiry, |
|
|
201 |
'letter_renew:s' => \$letter_renew, |
| 194 |
'where=s' => \@where, |
202 |
'where=s' => \@where, |
| 195 |
'active:i' => \$active, |
203 |
'active:i' => \$active, |
| 196 |
'inactive:i' => \$inactive, |
204 |
'inactive:i' => \$inactive, |
| 197 |
'renew' => \$renew, |
205 |
'renew' => \$renew, |
| 198 |
) or pod2usage(2); |
206 |
) or pod2usage(2); |
|
|
207 |
$letter_expiry = 'MEMBERSHIP_EXPIRY' if !$letter_expiry; |
| 208 |
$letter_renew = 'MEMBERSHIP_RENEWED' if !$letter_renew; |
| 199 |
|
209 |
|
| 200 |
pod2usage( -verbose => 2 ) if $man; |
210 |
pod2usage( -verbose => 2 ) if $man; |
| 201 |
pod2usage(1) if $help || !$confirm; |
211 |
pod2usage(1) if $help || !$confirm; |
|
Lines 230-236
warn 'found ' . $upcoming_mem_expires->count . ' soon expiring members'
Link Here
|
| 230 |
if $verbose; |
240 |
if $verbose; |
| 231 |
|
241 |
|
| 232 |
# main loop |
242 |
# main loop |
| 233 |
$letter_type = 'MEMBERSHIP_EXPIRY' if !$letter_type; |
|
|
| 234 |
my ( $count_skipped, $count_renewed, $count_enqueued ) = ( 0, 0, 0 ); |
243 |
my ( $count_skipped, $count_renewed, $count_enqueued ) = ( 0, 0, 0 ); |
| 235 |
while ( my $recent = $upcoming_mem_expires->next ) { |
244 |
while ( my $recent = $upcoming_mem_expires->next ) { |
| 236 |
if ( $active && !$recent->is_active( { months => $active } ) ) { |
245 |
if ( $active && !$recent->is_active( { months => $active } ) ) { |
|
Lines 244-253
while ( my $recent = $upcoming_mem_expires->next ) {
Link Here
|
| 244 |
my $which_notice; |
253 |
my $which_notice; |
| 245 |
if ($renew) { |
254 |
if ($renew) { |
| 246 |
$recent->renew_account; |
255 |
$recent->renew_account; |
| 247 |
$which_notice = 'MEMBERSHIP_RENEWED'; |
256 |
$which_notice = $letter_renew; |
| 248 |
$count_renewed++; |
257 |
$count_renewed++; |
| 249 |
} else { |
258 |
} else { |
| 250 |
$which_notice = $letter_type; |
259 |
$which_notice = $letter_expiry; |
| 251 |
} |
260 |
} |
| 252 |
|
261 |
|
| 253 |
my $from_address = $recent->library->from_email_address; |
262 |
my $from_address = $recent->library->from_email_address; |
| 254 |
- |
|
|