Lines 1497-1518
Returns the empty string if no email address.
Link Here
|
1497 |
|
1497 |
|
1498 |
sub GetNoticeEmailAddress { |
1498 |
sub GetNoticeEmailAddress { |
1499 |
my $borrowernumber = shift; |
1499 |
my $borrowernumber = shift; |
|
|
1500 |
my $dbh = C4::Context->dbh(); |
1501 |
|
1502 |
my $member = C4::Members::GetMember( 'borrowernumber' => $borrowernumber ); |
1503 |
my $guarantorid = $member->{'guarantorid'}; |
1504 |
|
1505 |
my $borrowerNumberToSendEmail = $guarantorid ? $guarantorid : $borrowernumber; |
1500 |
|
1506 |
|
1501 |
my $which_address = C4::Context->preference("AutoEmailPrimaryAddress"); |
1507 |
my $which_address = C4::Context->preference("AutoEmailPrimaryAddress"); |
1502 |
# if syspref is set to 'first valid' (value == OFF), look up email address |
1508 |
# if syspref is set to 'first valid' (value == OFF), look up email address |
|
|
1509 |
my $to_address = $member->{$which_address}; |
1503 |
if ( $which_address eq 'OFF' ) { |
1510 |
if ( $which_address eq 'OFF' ) { |
1504 |
return GetFirstValidEmailAddress($borrowernumber); |
1511 |
$to_address = GetFirstValidEmailAddress($borrowerNumberToSendEmail); |
1505 |
} |
1512 |
} elsif( $guarantorid ) { |
1506 |
# specified email address field |
1513 |
my $guarantor = C4::Members::GetMember( 'borrowernumber' => $guarantorid ); |
1507 |
my $dbh = C4::Context->dbh; |
1514 |
if ( $guarantor ){ |
1508 |
my $sth = $dbh->prepare( qq{ |
1515 |
$to_address = $guarantor->{ $which_address }; |
1509 |
SELECT $which_address AS primaryemail |
1516 |
} |
1510 |
FROM borrowers |
1517 |
} |
1511 |
WHERE borrowernumber=? |
1518 |
return $to_address || ''; |
1512 |
} ); |
|
|
1513 |
$sth->execute($borrowernumber); |
1514 |
my $data = $sth->fetchrow_hashref; |
1515 |
return $data->{'primaryemail'} || ''; |
1516 |
} |
1519 |
} |
1517 |
|
1520 |
|
1518 |
=head2 GetExpiryDate |
1521 |
=head2 GetExpiryDate |
1519 |
- |
|
|