Lines 24-29
use Encode qw( decode_utf8 );
Link Here
|
24 |
use Try::Tiny qw( catch try ); |
24 |
use Try::Tiny qw( catch try ); |
25 |
|
25 |
|
26 |
use C4::Members qw( checkcardnumber ); |
26 |
use C4::Members qw( checkcardnumber ); |
|
|
27 |
use C4::Letters qw( GetPreparedLetter EnqueueLetter ); |
27 |
|
28 |
|
28 |
use Koha::Libraries; |
29 |
use Koha::Libraries; |
29 |
use Koha::Patrons; |
30 |
use Koha::Patrons; |
Lines 74-79
sub import_patrons {
Link Here
|
74 |
my $overwrite_cardnumber = $params->{overwrite_cardnumber}; |
75 |
my $overwrite_cardnumber = $params->{overwrite_cardnumber}; |
75 |
my $overwrite_passwords = $params->{overwrite_passwords}; |
76 |
my $overwrite_passwords = $params->{overwrite_passwords}; |
76 |
my $dry_run = $params->{dry_run}; |
77 |
my $dry_run = $params->{dry_run}; |
|
|
78 |
my $send_welcome = $params->{send_welcome}; |
77 |
my $extended = C4::Context->preference('ExtendedPatronAttributes'); |
79 |
my $extended = C4::Context->preference('ExtendedPatronAttributes'); |
78 |
my $set_messaging_prefs = C4::Context->preference('EnhancedMessagingPreferences'); |
80 |
my $set_messaging_prefs = C4::Context->preference('EnhancedMessagingPreferences'); |
79 |
|
81 |
|
Lines 196-206
sub import_patrons {
Link Here
|
196 |
} |
198 |
} |
197 |
} |
199 |
} |
198 |
|
200 |
|
|
|
201 |
my $is_new = 0; |
199 |
if ($patron) { |
202 |
if ($patron) { |
200 |
$member = $patron->unblessed; |
203 |
$member = $patron->unblessed; |
201 |
$borrowernumber = $member->{'borrowernumber'}; |
204 |
$borrowernumber = $member->{'borrowernumber'}; |
202 |
} else { |
205 |
} else { |
203 |
$member = {}; |
206 |
$member = {}; |
|
|
207 |
$is_new = 1; |
204 |
} |
208 |
} |
205 |
|
209 |
|
206 |
if ( C4::Members::checkcardnumber( $borrower{cardnumber}, $borrowernumber ) ) { |
210 |
if ( C4::Members::checkcardnumber( $borrower{cardnumber}, $borrowernumber ) ) { |
Lines 277-283
sub import_patrons {
Link Here
|
277 |
} |
281 |
} |
278 |
} |
282 |
} |
279 |
|
283 |
|
280 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
|
|
281 |
try { |
284 |
try { |
282 |
$schema->storage->txn_do(sub { |
285 |
$schema->storage->txn_do(sub { |
283 |
$patron->set(\%borrower)->store; |
286 |
$patron->set(\%borrower)->store; |
Lines 373-379
sub import_patrons {
Link Here
|
373 |
else { |
376 |
else { |
374 |
try { |
377 |
try { |
375 |
$schema->storage->txn_do(sub { |
378 |
$schema->storage->txn_do(sub { |
376 |
my $patron = Koha::Patron->new(\%borrower)->store; |
379 |
$patron = Koha::Patron->new(\%borrower)->store; |
377 |
$borrowernumber = $patron->id; |
380 |
$borrowernumber = $patron->id; |
378 |
|
381 |
|
379 |
if ( $patron->is_debarred ) { |
382 |
if ( $patron->is_debarred ) { |
Lines 439-444
sub import_patrons {
Link Here
|
439 |
|
442 |
|
440 |
next LINE unless $success; |
443 |
next LINE unless $success; |
441 |
|
444 |
|
|
|
445 |
# Send ACCTDETAILS welcome email is the user is new and we're set to send mail |
446 |
if ($send_welcome && $is_new) { |
447 |
my $emailaddr = $patron->notice_email_address; |
448 |
|
449 |
# if we manage to find a valid email address, send notice |
450 |
if ($emailaddr) { |
451 |
eval { |
452 |
my $letter = GetPreparedLetter( |
453 |
module => 'members', |
454 |
letter_code => 'ACCTDETAILS', |
455 |
branchcode => $patron->branchcode,, |
456 |
lang => $patron->lang || 'default', |
457 |
tables => { |
458 |
'branches' => $patron->branchcode, |
459 |
'borrowers' => $patron->borrowernumber, |
460 |
}, |
461 |
want_librarian => 1, |
462 |
) or return; |
463 |
|
464 |
my $message_id = EnqueueLetter( |
465 |
{ |
466 |
letter => $letter, |
467 |
borrowernumber => $patron->id, |
468 |
to_address => $emailaddr, |
469 |
message_transport_type => 'email' |
470 |
} |
471 |
); |
472 |
}; |
473 |
if ($@) { |
474 |
push @errors, { welcome_email_err => 1, borrowernumber => $borrowernumber }; |
475 |
} else { |
476 |
push( |
477 |
@feedback, |
478 |
{ |
479 |
feedback => 1, |
480 |
name => 'welcome_sent', |
481 |
value => $borrower{'surname'} . ' / ' . $borrowernumber . ' / ' . $emailaddr |
482 |
} |
483 |
); |
484 |
} |
485 |
} |
486 |
} |
487 |
|
442 |
# Add a guarantor if we are given a relationship |
488 |
# Add a guarantor if we are given a relationship |
443 |
if ( $guarantor_id ) { |
489 |
if ( $guarantor_id ) { |
444 |
my $relationship = Koha::Patron::Relationships->find( |
490 |
my $relationship = Koha::Patron::Relationships->find( |