Lines 2478-2483
sub AddEnrolmentFeeIfNeeded {
Link Here
|
2478 |
} |
2478 |
} |
2479 |
} |
2479 |
} |
2480 |
|
2480 |
|
|
|
2481 |
=head2 HasOverdues |
2482 |
|
2483 |
HasOverdues( $borrowernumber ); |
2484 |
|
2485 |
=cut |
2486 |
|
2481 |
sub HasOverdues { |
2487 |
sub HasOverdues { |
2482 |
my ( $borrowernumber ) = @_; |
2488 |
my ( $borrowernumber ) = @_; |
2483 |
|
2489 |
|
Lines 2489-2494
sub HasOverdues {
Link Here
|
2489 |
return $count; |
2495 |
return $count; |
2490 |
} |
2496 |
} |
2491 |
|
2497 |
|
|
|
2498 |
=head2 SendAutoEmail |
2499 |
|
2500 |
SendAutoEmail( $borrowerdata, $template ); |
2501 |
|
2502 |
Send an alert with login detail (account notice) when userid or password |
2503 |
has been changed, if pref AutoEmailOpacUser has been enabled. |
2504 |
The hashref $borrowerdata should contain the keys: |
2505 |
borrowernumber, branchcode, userid, password, email, emailpro, B_email |
2506 |
The template parameter refers to a template object. Errors are passed |
2507 |
via the template. |
2508 |
|
2509 |
=cut |
2510 |
|
2511 |
sub SendAutoEmail { #optionally send account detail notice |
2512 |
my ( $dataref, $template ) = @_; |
2513 |
|
2514 |
# check AutoEmailOpacUser syspref first |
2515 |
return if !C4::Context->preference("AutoEmailOpacUser"); |
2516 |
# no mail too if no userid or password |
2517 |
return if ref($dataref) ne 'HASH' || !$dataref->{userid} || |
2518 |
!$dataref->{password}; |
2519 |
|
2520 |
# first look for defined primary email addres, otherwise try others |
2521 |
my $emailaddr; |
2522 |
my $primary = C4::Context->preference("AutoEmailPrimaryAddress"); |
2523 |
return if !$primary; |
2524 |
if( $primary ne 'OFF' && $dataref->{primary} && |
2525 |
$dataref->{$primary} =~ /\w\@\w/ ) { |
2526 |
$emailaddr = $dataref->{$primary}; |
2527 |
} elsif( $dataref->{email} && $dataref->{email} =~ /\w\@\w/ ) { |
2528 |
$emailaddr = $dataref->{email}; |
2529 |
} elsif( $dataref->{emailpro} && $dataref->{emailpro} =~ /\w\@\w/ ) { |
2530 |
$emailaddr = $dataref->{emailpro}; |
2531 |
} elsif( $dataref->{B_email} && $dataref->{B_email} =~ /\w\@\w/ ) { |
2532 |
$emailaddr = $dataref->{B_email}; |
2533 |
} |
2534 |
return if !$emailaddr; |
2535 |
|
2536 |
# if we manage to find a valid email address, send notice |
2537 |
$dataref->{emailaddr} = $emailaddr; |
2538 |
my $err; |
2539 |
eval { $err = SendAlerts ( 'members', $dataref, "ACCTDETAILS" ); }; |
2540 |
if ( $@ ) { |
2541 |
$template->param(error_alert => $@); |
2542 |
} elsif ( ref($err) eq "HASH" && defined $err->{error} && |
2543 |
$err->{error} eq "no_email" ) { |
2544 |
$template->{VARS}->{'error_alert'} = "no_email"; |
2545 |
} else { |
2546 |
$template->{VARS}->{'info_alert'} = 1; |
2547 |
} |
2548 |
} |
2549 |
|
2492 |
END { } # module clean-up code here (global destructor) |
2550 |
END { } # module clean-up code here (global destructor) |
2493 |
|
2551 |
|
2494 |
1; |
2552 |
1; |