From 46412d9a769bb0c9282652745b3a551849ae9a99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?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 --- C4/Reserves.pm | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 87e2325..65f99e1 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'} ) ); -- 1.7.4.1