From a8fe55124e0e8e8d88b3c9b525d615cafff1061f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9rick=20Capovilla?= Date: Tue, 15 Mar 2011 11:16:48 -0400 Subject: [PATCH] Bug 5867 : Improved the email checking when sending "Hold filled" notices. The subroutine for sending HOLD and HOLD_PRINT notices only checked the "email" field of the borrowers table and didn't check the value of the AutoEmailPrimaryAddress preference. With this patch, "Hold filled" notices can now be sent using the other email addresses of the member. http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=5867 Signed-off-by: Chris Cormack Signed-off-by: Ian Walls --- C4/Reserves.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index fde1223a88..83738408af 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -1662,10 +1662,21 @@ sub _koha_notify_reserve { my $dbh = C4::Context->dbh; my $borrower = C4::Members::GetMember(borrowernumber => $borrowernumber); + + # Try to get the borrower's email address + my $to_address; + my $which_address = C4::Context->preference('AutoEmailPrimaryAddress'); + # If the system preference is set to 'first valid' (value == OFF), look up email address + if ($which_address eq 'OFF') { + $to_address = C4::Members::GetFirstValidEmailAddress( $borrowernumber ); + } else { + $to_address = $borrower->{$which_address}; + } + my $letter_code; my $print_mode = 0; my $messagingprefs; - if ( $borrower->{'email'} || $borrower->{'smsalertnumber'} ) { + if ( $to_address || $borrower->{'smsalertnumber'} ) { $messagingprefs = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $borrowernumber, message_name => 'Hold_Filled' } ); return if ( !defined( $messagingprefs->{'letter_code'} ) ); -- 2.39.5