Bug 6835 - Ability to specify types of email address in overdue_notices.pl
Adds the -email option to overdue_notices.pl, which is repeatable -email value can be: - 'email' - 'emailpro' or - 'B_email' - perltidy done - in production for a BibLibre customer - validated by the customer Signed-off-by: Claire Hernandez <claire.hernandez@biblibre.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
This commit is contained in:
parent
af87780385
commit
f229047549
1 changed files with 41 additions and 4 deletions
|
@ -47,7 +47,10 @@ overdue_notices.pl - prepare messages to be sent to patrons for overdue items
|
|||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
overdue_notices.pl [ -n ] [ -library <branchcode> ] [ -library <branchcode>...] [ -max <number of days> ] [ -csv [ <filename> ] ] [ -itemscontent <field list> ]
|
||||
overdue_notices.pl
|
||||
[ -n ][ -library <branchcode> ][ -library <branchcode> ... ]
|
||||
[ -max <number of days> ][ -csv [<filename>] ][ -itemscontent <field list> ]
|
||||
[ -email <email_type> ... ]
|
||||
|
||||
Options:
|
||||
-help brief help message
|
||||
|
@ -60,6 +63,7 @@ overdue_notices.pl [ -n ] [ -library <branchcode> ] [ -library <branchcode>...]
|
|||
-itemscontent <list of fields> item information in templates
|
||||
-borcat <categorycode> category code that must be included
|
||||
-borcatout <categorycode> category code that must be excluded
|
||||
-email <email_type> type of email that will be used. Can be 'email', 'emailpro' or 'B_email'. Repeatable.
|
||||
|
||||
=head1 OPTIONS
|
||||
|
||||
|
@ -147,6 +151,10 @@ Choose list-all to include all overdue items in the list (limited by B<-max> set
|
|||
|
||||
use it in order to send overdues on a specific date and not Now.
|
||||
|
||||
=item B<-email>
|
||||
|
||||
Allows to specify which type of email will be used. Can be email, emailpro or B_email. Repeatable.
|
||||
|
||||
=back
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
@ -256,6 +264,8 @@ my $verbose = 0;
|
|||
my $nomail = 0;
|
||||
my $MAX = 90;
|
||||
my @branchcodes; # Branch(es) passed as parameter
|
||||
my @emails_to_use; # Emails to use for messaging
|
||||
my @emails; # Emails given in command-line parameters
|
||||
my $csvfilename;
|
||||
my $htmlfilename;
|
||||
my $triggered = 0;
|
||||
|
@ -280,6 +290,7 @@ GetOptions(
|
|||
'date' => \$date,
|
||||
'borcat=s' => \@myborcat,
|
||||
'borcatout=s' => \@myborcatout,
|
||||
'email=s' => \@emails,
|
||||
) or pod2usage(2);
|
||||
pod2usage(1) if $help;
|
||||
pod2usage( -verbose => 2 ) if $man;
|
||||
|
@ -472,6 +483,31 @@ END_SQL
|
|||
) = $sth->fetchrow )
|
||||
{
|
||||
$verbose and warn "borrower $firstname, $lastname ($borrowernumber) has items triggering level $i.";
|
||||
@emails_to_use = ();
|
||||
if ( !$nomail) {
|
||||
if ( @emails ) {
|
||||
my $memberinfos = C4::Members::GetMember(borrowernumber => $borrowernumber);
|
||||
foreach (@emails) {
|
||||
push @emails_to_use, $memberinfos->{$_}
|
||||
if ($memberinfos->{$_} ne '');
|
||||
}
|
||||
}
|
||||
else {
|
||||
$email =
|
||||
C4::Members::GetFirstValidEmailAddress($borrowernumber);
|
||||
push @emails_to_use, $email if ($email ne '');
|
||||
}
|
||||
}
|
||||
|
||||
my $letter = C4::Letters::getletter( 'circulation', $overdue_rules->{"letter$i"}, $branchcode );
|
||||
|
||||
unless ($letter) {
|
||||
$verbose and warn "Message '$overdue_rules->{letter$i}' content not found";
|
||||
|
||||
# might as well skip while PERIOD, no other borrowers are going to work.
|
||||
# FIXME : Does this mean a letter must be defined in order to trigger a debar ?
|
||||
next PERIOD;
|
||||
}
|
||||
|
||||
if ( $overdue_rules->{"debarred$i"} ) {
|
||||
|
||||
|
@ -489,7 +525,7 @@ END_SQL
|
|||
my $j = 0;
|
||||
my $exceededPrintNoticesMaxLines = 0;
|
||||
while ( my $item_info = $sth2->fetchrow_hashref() ) {
|
||||
if ( ( !$email || $nomail ) && $PrintNoticesMaxLines && $j >= $PrintNoticesMaxLines ) {
|
||||
if ( ( scalar(@emails_to_use) == 0 || $nomail ) && $PrintNoticesMaxLines && $j >= $PrintNoticesMaxLines ) {
|
||||
$exceededPrintNoticesMaxLines = 1;
|
||||
last;
|
||||
}
|
||||
|
@ -501,7 +537,7 @@ END_SQL
|
|||
}
|
||||
$sth2->finish;
|
||||
|
||||
my $letter = parse_letter(
|
||||
$letter = parse_letter(
|
||||
{ letter_code => $overdue_rules->{"letter$i"},
|
||||
borrowernumber => $borrowernumber,
|
||||
branchcode => $branchcode,
|
||||
|
@ -552,12 +588,13 @@ END_SQL
|
|||
}
|
||||
);
|
||||
} else {
|
||||
if ($email) {
|
||||
if (scalar(@emails_to_use) > 0 ) {
|
||||
C4::Letters::EnqueueLetter(
|
||||
{ letter => $letter,
|
||||
borrowernumber => $borrowernumber,
|
||||
message_transport_type => 'email',
|
||||
from_address => $admin_email_address,
|
||||
to_address => join(',', @emails_to_use),
|
||||
}
|
||||
);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue