@@ -, +, @@ email address for which you have access) --- Koha/Patrons/Import.pm | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) --- a/Koha/Patrons/Import.pm +++ a/Koha/Patrons/Import.pm @@ -24,6 +24,7 @@ use Encode qw( decode_utf8 ); use Try::Tiny qw( catch try ); use C4::Members qw( checkcardnumber ); +use C4::Letters qw( SendAlerts ); use Koha::Libraries; use Koha::Patrons; @@ -277,7 +278,6 @@ sub import_patrons { } } - my $patron = Koha::Patrons->find( $borrowernumber ); try { $schema->storage->txn_do(sub { $patron->set(\%borrower)->store; @@ -373,7 +373,7 @@ sub import_patrons { else { try { $schema->storage->txn_do(sub { - my $patron = Koha::Patron->new(\%borrower)->store; + $patron = Koha::Patron->new(\%borrower)->store; $borrowernumber = $patron->id; if ( $patron->is_debarred ) { @@ -437,6 +437,27 @@ sub import_patrons { }; } + if ($success) { + + # 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 + && $patron->plain_text_password ) + { + my $emailaddr = $patron->notice_email_address; + + # if we manage to find a valid email address, send notice + if ($emailaddr) { + $borrower{emailaddr} = $emailaddr; + my $err; + eval { + $err = + SendAlerts( 'members', \%borrower, "ACCTDETAILS" ); + }; + } + } + } + next LINE unless $success; # Add a guarantor if we are given a relationship --