From 0ba77131d558cc1431e21e0cfdf3e133caded1ad Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Mon, 27 Nov 2017 00:56:41 +0000 Subject: [PATCH] Bug 19532: Send notice to user to pickup recalled returned item Send a PICKUP_RECALLED_ITEM notice to the user who requested a recall when the item is checked in. --- C4/Letters.pm | 1 + circ/returns.pl | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index d7971af..2ec28ba 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -843,6 +843,7 @@ sub _parseletter_sth { ($table eq 'aqorders' ) ? "SELECT * FROM $table WHERE ordernumber = ?" : ($table eq 'opac_news' ) ? "SELECT * FROM $table WHERE idnew = ?" : ($table eq 'article_requests') ? "SELECT * FROM $table WHERE id = ?" : + ($table eq 'recalls' ) ? "SELECT * FROM $table WHERE recall_id = ?" : ($table eq 'borrower_modifications') ? "SELECT * FROM $table WHERE verification_token = ?" : ($table eq 'subscription') ? "SELECT * FROM $table WHERE subscriptionid = ?" : ($table eq 'serial') ? "SELECT * FROM $table WHERE serialid = ?" : diff --git a/circ/returns.pl b/circ/returns.pl index 284e882..21b5983 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -49,6 +49,8 @@ use C4::Members; use C4::Members::Messaging; use C4::Koha; # FIXME : is it still useful ? use C4::RotatingCollections; +use C4::Letters; +use C4::Message; use Koha::AuthorisedValues; use Koha::DateUtils; use Koha::Calendar; @@ -58,6 +60,8 @@ use Koha::Holds; use Koha::Items; use Koha::Patrons; use Koha::Recalls; +use Koha::IssuingRules; +use Koha::Biblios; my $query = new CGI; @@ -195,7 +199,28 @@ if ( $query->param('reserve_id') ) { if ( $query->param('recall_id') ){ my $recall = Koha::Recalls->find(scalar $query->param('recall_id')); - $recall->update({ status => 'W', waitingdate => dt_from_string() }); + my $recall_borrower = $recall->borrower; + my $item = Koha::Items->find($recall->itemnumber); + my $biblio = Koha::Biblios->find($item->biblionumber); + + my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule({ categorycode => $recall_borrower->categorycode, itemtype => $item->itype, branchcode => $item->holdingbranch }); + my $shelf_time = $issuing_rule->recall_shelf_time || C4::Context->preference('RecallsMaxPickUpDelay'); + my $expirationdate = dt_from_string()->add( $issuing_rule->lengthunit => $shelf_time ); + $recall->update({ status => 'W', waitingdate => dt_from_string(), expirationdate => $expirationdate }); + + # send notice to user who requested recall to pick up item + my $letter = C4::Letters::GetPreparedLetter ( + module => 'circulation', + letter_code => 'PICKUP_RECALLED_ITEM', + branchcode => $recall->branchcode, + tables => { + 'biblio', $biblio->biblionumber, + 'borrowers', $recall_borrower->borrowernumber, + 'items', $item->itemnumber, + 'recalls', $recall->recall_id, + }, + ); + C4::Message->enqueue($letter, $recall_borrower->unblessed, 'email'); } my $borrower; -- 2.1.4