Commit b461a041 authored by Mason James's avatar Mason James Committed by Joshua Ferraro

bug-2149, added new block to C4::Letters::SendAlerts() to email 'account...

bug-2149, added new block to C4::Letters::SendAlerts() to email 'account creation' notice, and new block in memberentry.pl to call SendAlerts().
Signed-off-by: default avatarJoshua Ferraro <jmf@liblime.com>
parent a5f90c7d
......@@ -434,6 +434,23 @@ sub SendAlerts {
}
warn
"sending to From $userenv->{emailaddress} subj $innerletter->{title} Mess $innerletter->{content}";
}
# send an "account details" notice to a newly created user
elsif ( $type eq 'members' ) {
$letter->{content} =~ s/<<borrowers.title>>/$externalid->{'title'}/g;
$letter->{content} =~ s/<<borrowers.firstname>>/$externalid->{'firstname'}/g;
$letter->{content} =~ s/<<borrowers.surname>>/$externalid->{'surname'}/g;
$letter->{content} =~ s/<<borrowers.cardnumber>>/$externalid->{'cardnumber'}/g;
$letter->{content} =~ s/<<borrowers.password>>/$externalid->{'password'}/g;
my %mail = (
To => $externalid->{'emailaddr'},
From => C4::Context->preference("KohaAdminEmailAddress"),
Subject => $letter->{'title'},
Message => $letter->{'content'},
'Content-Type' => 'text/plain; charset="utf8"',
);
sendmail(%mail);
}
}
......
......@@ -35,10 +35,9 @@ use C4::Koha;
use C4::Dates qw/format_date format_date_in_iso/;
use C4::Input;
use C4::Log;
use C4::Letters;
use C4::Branch; # GetBranches
#use Smart::Comments;
use vars qw($debug);
BEGIN {
......@@ -240,7 +239,35 @@ if ((!$nok) and ($op eq 'insert' or $op eq 'save')){
$debug and warn "$op dates: " . join "\t", map {"$_: $newdata{$_}"} qw(dateofbirth dateenrolled dateexpiry);
if ($op eq 'insert'){
# we know it's not a duplicate borrowernumber or there would already be an error
$borrowernumber = &AddMember(%newdata);
$borrowernumber = &AddMember(%newdata);
# If 'AutoEmailOpacUser' syspref is on, email user their account details from the 'notice' that matches the user's branchcode.
if ( C4::Context->preference("AutoEmailOpacUser") == 1 && $newdata{'userid'} && $newdata{'password'}) {
#look for defined primary email address, if blank - attempt to use borr.email and borr.emailpro instead
my $emailaddr;
if (C4::Context->preference("AutoEmailPrimaryAddress") ne 'OFF' &&
$newdata{C4::Context->preference("AutoEmailPrimaryAddress")} =~ /\w\@\w/ ) {
$emailaddr = $newdata{C4::Context->preference("AutoEmailPrimaryAddress")}
}
elsif ($newdata{email} =~ /\w\@\w/) {
$emailaddr = $newdata{email}
}
elsif ($newdata{emailpro} =~ /\w\@\w/) {
$emailaddr = $newdata{emailpro}
}
elsif ($newdata{B_email} =~ /\w\@\w/) {
$emailaddr = $newdata{B_email}
}
# if we manage to find a valid email address, send notice
if ($emailaddr) {
$newdata{emailaddr} = $emailaddr;
my $letter = getletter ('members', "ACCTDETAILS:$newdata{'branchcode'}") ;
# if $branch notice fails, then email a default notice instead.
$letter = getletter ('members', "ACCTDETAILS") if !$letter;
SendAlerts ( 'members' , \%newdata , $letter ) if $letter
}
}
if ($data{'organisations'}){
# need to add the members organisations
my @orgs=split(/\|/,$data{'organisations'});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment