Lines 47-53
overdue_notices.pl - prepare messages to be sent to patrons for overdue items
Link Here
|
47 |
|
47 |
|
48 |
=head1 SYNOPSIS |
48 |
=head1 SYNOPSIS |
49 |
|
49 |
|
50 |
overdue_notices.pl [ -n ] [ -library <branchcode> ] [ -library <branchcode>...] [ -max <number of days> ] [ -csv [ <filename> ] ] [ -itemscontent <field list> ] |
50 |
overdue_notices.pl |
|
|
51 |
[ -n ][ -library <branchcode> ][ -library <branchcode> ... ] |
52 |
[ -max <number of days> ][ -csv [<filename>] ][ -itemscontent <field list> ] |
53 |
[ -email <email_type> ... ] |
51 |
|
54 |
|
52 |
Options: |
55 |
Options: |
53 |
-help brief help message |
56 |
-help brief help message |
Lines 60-65
overdue_notices.pl [ -n ] [ -library <branchcode> ] [ -library <branchcode>...]
Link Here
|
60 |
-itemscontent <list of fields> item information in templates |
63 |
-itemscontent <list of fields> item information in templates |
61 |
-borcat <categorycode> category code that must be included |
64 |
-borcat <categorycode> category code that must be included |
62 |
-borcatout <categorycode> category code that must be excluded |
65 |
-borcatout <categorycode> category code that must be excluded |
|
|
66 |
-email <email_type> type of email that will be used. Can be 'email', 'emailpro' or 'B_email'. Repeatable. |
63 |
|
67 |
|
64 |
=head1 OPTIONS |
68 |
=head1 OPTIONS |
65 |
|
69 |
|
Lines 143-148
Default items.content lists only those items that fall in the
Link Here
|
143 |
range of the currently processing notice. |
147 |
range of the currently processing notice. |
144 |
Choose list-all to include all overdue items in the list (limited by B<-max> setting). |
148 |
Choose list-all to include all overdue items in the list (limited by B<-max> setting). |
145 |
|
149 |
|
|
|
150 |
=item B<-email> |
151 |
|
152 |
Allows to specify which type of email will be used. Can be email, emailpro or B_email. Repeatable. |
153 |
|
146 |
=back |
154 |
=back |
147 |
|
155 |
|
148 |
=head1 DESCRIPTION |
156 |
=head1 DESCRIPTION |
Lines 252-257
my $verbose = 0;
Link Here
|
252 |
my $nomail = 0; |
260 |
my $nomail = 0; |
253 |
my $MAX = 90; |
261 |
my $MAX = 90; |
254 |
my @branchcodes; # Branch(es) passed as parameter |
262 |
my @branchcodes; # Branch(es) passed as parameter |
|
|
263 |
my @emails_to_use; # Emails to use for messaging |
264 |
my @emails; # Emails given in command-line parameters |
255 |
my $csvfilename; |
265 |
my $csvfilename; |
256 |
my $htmlfilename; |
266 |
my $htmlfilename; |
257 |
my $triggered = 0; |
267 |
my $triggered = 0; |
Lines 274-279
GetOptions(
Link Here
|
274 |
't|triggered' => \$triggered, |
284 |
't|triggered' => \$triggered, |
275 |
'borcat=s' => \@myborcat, |
285 |
'borcat=s' => \@myborcat, |
276 |
'borcatout=s' => \@myborcatout, |
286 |
'borcatout=s' => \@myborcatout, |
|
|
287 |
'email=s' => \@emails, |
277 |
) or pod2usage(2); |
288 |
) or pod2usage(2); |
278 |
pod2usage(1) if $help; |
289 |
pod2usage(1) if $help; |
279 |
pod2usage( -verbose => 2 ) if $man; |
290 |
pod2usage( -verbose => 2 ) if $man; |
Lines 459-464
END_SQL
Link Here
|
459 |
) = $sth->fetchrow ) |
470 |
) = $sth->fetchrow ) |
460 |
{ |
471 |
{ |
461 |
$verbose and warn "borrower $firstname, $lastname ($borrowernumber) has items triggering level $i."; |
472 |
$verbose and warn "borrower $firstname, $lastname ($borrowernumber) has items triggering level $i."; |
|
|
473 |
@emails_to_use = (); |
474 |
if ( @emails && !$nomail ) { |
475 |
my $validemails = |
476 |
C4::Members::GetValidEmailAddresses($borrowernumber); |
477 |
foreach (@emails) { |
478 |
push @emails_to_use, $validemails->{$_} |
479 |
if ( defined $validemails->{$_} ); |
480 |
} |
481 |
$email = 1 if (@emails_to_use); |
482 |
} |
483 |
else { |
484 |
$email = |
485 |
C4::Members::GetFirstValidEmailAddress($borrowernumber); |
486 |
push @emails_to_use, $email; |
487 |
} |
488 |
|
489 |
my $letter = C4::Letters::getletter( 'circulation', $overdue_rules->{"letter$i"}, $branchcode ); |
490 |
|
491 |
unless ($letter) { |
492 |
$verbose and warn "Message '$overdue_rules->{letter$i}' content not found"; |
493 |
|
494 |
# might as well skip while PERIOD, no other borrowers are going to work. |
495 |
# FIXME : Does this mean a letter must be defined in order to trigger a debar ? |
496 |
next PERIOD; |
497 |
} |
462 |
|
498 |
|
463 |
if ( $overdue_rules->{"debarred$i"} ) { |
499 |
if ( $overdue_rules->{"debarred$i"} ) { |
464 |
|
500 |
|
Lines 488-494
END_SQL
Link Here
|
488 |
} |
524 |
} |
489 |
$sth2->finish; |
525 |
$sth2->finish; |
490 |
|
526 |
|
491 |
my $letter = parse_letter( |
527 |
$letter = parse_letter( |
492 |
{ letter_code => $overdue_rules->{"letter$i"}, |
528 |
{ letter_code => $overdue_rules->{"letter$i"}, |
493 |
borrowernumber => $borrowernumber, |
529 |
borrowernumber => $borrowernumber, |
494 |
branchcode => $branchcode, |
530 |
branchcode => $branchcode, |
Lines 538-549
END_SQL
Link Here
|
538 |
} |
574 |
} |
539 |
); |
575 |
); |
540 |
} else { |
576 |
} else { |
541 |
if ($email) { |
577 |
if (scalar(@emails_to_use) > 0 ) { |
542 |
C4::Letters::EnqueueLetter( |
578 |
C4::Letters::EnqueueLetter( |
543 |
{ letter => $letter, |
579 |
{ letter => $letter, |
544 |
borrowernumber => $borrowernumber, |
580 |
borrowernumber => $borrowernumber, |
545 |
message_transport_type => 'email', |
581 |
message_transport_type => 'email', |
546 |
from_address => $admin_email_address, |
582 |
from_address => $admin_email_address, |
|
|
583 |
to_address => join(',', @emails_to_use), |
547 |
} |
584 |
} |
548 |
); |
585 |
); |
549 |
} else { |
586 |
} else { |
550 |
- |
|
|