From 30c375ae8bf35488e1afeef4f5a211ff90d3a448 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Thu, 26 Oct 2023 21:06:56 +0000 Subject: [PATCH] Bug 17617: Confirmation email to patron when hold is placed This enhancement adds a new notice HOLDPLACED_PATRON that will be sent to a patron when a hold is placed for them. It depends on the new system preference EmailPatronWhenHoldIsPlaced to be enabled. To test: 1) Update database and restart services 2) Go to Koha Administration -> System preferences and search for the new EmailPatronWhenHoldIsPlaced syspref. It should be disabled by default - leave it disabled for now. 3) Search for a record and go to the Holds tab. Place a hold for your patron. 4) Go to your patron's account and go to the Notices tab. Confirm the HOLDPLACED_PATRON notice was NOT queued. 5) Enable the EmailPatronWhenHoldIsPlaced syspref. 6) Repeat steps 3 and 4. Confirm the HOLDPLACED_PATRON notice WAS generated and queued. 7) Confirm tests pass t/db_dependent/Holds.t Sponsored-by: Fire and Emergency New Zealand Signed-off-by: Kelly Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi --- C4/Reserves.pm | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index d86e9f46f9..872abfa13b 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -166,7 +166,7 @@ BEGIN { } ); -Adds reserve and generates HOLDPLACED message. +Adds reserve and generates HOLDPLACED message and HOLDPLACED_PATRON message. The following tables are available witin the HOLDPLACED message: @@ -177,6 +177,11 @@ The following tables are available witin the HOLDPLACED message: items reserves +The following tables are available within the HOLDPLACED_PATRON message: + + borrowers + reserves + =cut sub AddReserve { @@ -306,6 +311,33 @@ sub AddReserve { } } + # Send email to patron if syspref is active + if ( C4::Context->preference("EmailPatronWhenHoldIsPlaced") ) { + my $patron = $hold->patron; + if ( + my $letter = C4::Letters::GetPreparedLetter( + module => 'reserves', + letter_code => 'HOLDPLACED_PATRON', + branchcode => $branch, + lang => $patron->lang, + tables => { + borrowers => $patron->unblessed, + reserves => $hold->unblessed, + }, + ) + ) + { + C4::Letters::EnqueueLetter( + { + letter => $letter, + borrowernumber => $borrowernumber, + message_transport_type => 'email', + to_address => $patron->notice_email_address, + } + ); + } + } + Koha::Plugins->call('after_hold_create', $hold); Koha::Plugins->call( 'after_hold_action', -- 2.39.5