Bugzilla – Attachment 102957 Details for
Bug 20453
Send notification when hold is cancelled by librarian
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20453: Send notice when cancelling a hold from intranet
Bug-20453-Send-notice-when-cancelling-a-hold-from-.patch (text/plain), 7.01 KB, created by
Aleisha Amohia
on 2020-04-15 04:50:33 UTC
(
hide
)
Description:
Bug 20453: Send notice when cancelling a hold from intranet
Filename:
MIME Type:
Creator:
Aleisha Amohia
Created:
2020-04-15 04:50:33 UTC
Size:
7.01 KB
patch
obsolete
>From f3249e42a91d702c8df22bfe01e94c0293b4760c Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Tue, 4 Feb 2020 03:30:30 +0000 >Subject: [PATCH] Bug 20453: Send notice when cancelling a hold from intranet > >To test: >1) Apply patch >2) Place a reserve for Borrower A >3) Cancel the reserve from reserve/request.pl >4) Go to Borrower A's account page and look at Notices tab >5) Confirm the HOLD_MANUAL_CANCEL notice is pending >6) Place a reserve for Borrower A again >7) Go to Circulation -> Holds to pull >8) Cancel the hold >9) Repeat steps 4 and 5 >10) Place a reserve for Borrower A again >11) Go to Borrower A's account page and look at the Holds table (under > Check out tab or Details tab) >12) Cancel hold using 'Cancel marked holds' button >13) Repeat steps 4 and 5 > >Sponsored-by: Waikato Institute of Technology >--- > C4/Reserves.pm | 38 +++++++++++++++++++++++++++++++++++--- > circ/pendingreserves.pl | 32 +++++++++++++++++++++++++++++++- > reserve/request.pl | 16 ++++++++++++++++ > 3 files changed, 82 insertions(+), 4 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index ffb5d32eeb..f9604b8a10 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -1004,9 +1004,24 @@ sub ModReserve { > $hold ||= Koha::Holds->find($reserve_id); > > if ( $rank eq "del" ) { >+ my $hold_branchcode = $hold->branchcode; >+ my $hold_biblionumber = $hold->biblionumber; >+ my $hold_borrowernumber = $hold->borrowernumber; >+ my $hold_borrower = Koha::Patrons->find( $hold_borrowernumber ); > $hold->cancel; >- } >- elsif ($rank =~ /^\d+/ and $rank > 0) { >+ >+ # send notice to user that their hold has been cancelled >+ my $letter = C4::Letters::GetPreparedLetter ( >+ module => 'reserves', >+ letter_code => 'HOLD_MANUAL_CANCEL', >+ branchcode => $hold_branchcode, >+ tables => { >+ 'biblio', $hold_biblionumber, >+ 'borrowers', $hold_borrowernumber >+ } >+ ); >+ C4::Message->enqueue($letter, $hold_borrower->unblessed, 'email'); >+ } elsif ($rank =~ /^\d+/ and $rank > 0) { > logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, Dumper($hold->unblessed) ) > if C4::Context->preference('HoldsLog'); > >@@ -1203,7 +1218,24 @@ sub ModReserveCancelAll { > #step 1 : cancel the reservation > my $holds = Koha::Holds->search({ itemnumber => $itemnumber, borrowernumber => $borrowernumber }); > return unless $holds->count; >- $holds->next->cancel; >+ my $hold = $holds->next; >+ my $hold_branchcode = $hold->branchcode; >+ my $hold_biblionumber = $hold->biblionumber; >+ my $hold_borrowernumber = $hold->borrowernumber; >+ my $hold_borrower = Koha::Patrons->find( $hold_borrowernumber ); >+ $hold->cancel; >+ >+ # send notice to user that their hold has been cancelled >+ my $letter = C4::Letters::GetPreparedLetter ( >+ module => 'reserves', >+ letter_code => 'HOLD_MANUAL_CANCEL', >+ branchcode => $hold_branchcode, >+ tables => { >+ 'biblio', $hold_biblionumber, >+ 'borrowers', $hold_borrowernumber >+ } >+ ); >+ C4::Message->enqueue($letter, $hold_borrower->unblessed, 'email'); > > #step 2 launch the subroutine of the others reserves > ( $messages, $nextreservinfo ) = GetOtherReserves($itemnumber); >diff --git a/circ/pendingreserves.pl b/circ/pendingreserves.pl >index 7f2062942a..40ea41ba14 100755 >--- a/circ/pendingreserves.pl >+++ b/circ/pendingreserves.pl >@@ -56,15 +56,34 @@ my @messages; > if ( $op eq 'cancel_reserve' and $reserve_id ) { > my $hold = Koha::Holds->find( $reserve_id ); > if ( $hold ) { >+ my $hold_branchcode = $hold->branchcode; >+ my $hold_biblionumber = $hold->biblionumber; >+ my $hold_borrowernumber = $hold->borrowernumber; >+ my $hold_borrower = Koha::Patrons->find( $hold_borrowernumber ); > $hold->cancel; > push @messages, { type => 'message', code => 'hold_cancelled' }; >+ >+ # send notice to user that their hold has been cancelled >+ my $letter = C4::Letters::GetPreparedLetter ( >+ module => 'reserves', >+ letter_code => 'HOLD_MANUAL_CANCEL', >+ branchcode => $hold_branchcode, >+ tables => { >+ 'biblio', $hold_biblionumber, >+ 'borrowers', $hold_borrowernumber >+ } >+ ); >+ C4::Message->enqueue($letter, $hold_borrower->unblessed, 'email'); > } > } elsif ( $op =~ m|^mark_as_lost| ) { > my $hold = Koha::Holds->find( $reserve_id ); >+ my $hold_branchcode = $hold->branchcode; >+ my $hold_biblionumber = $hold->biblionumber; >+ my $hold_borrowernumber = $hold->borrowernumber; >+ my $patron = $hold->borrower; > die "wrong reserve_id" unless $hold; # This is a bit rude, but we are not supposed to get a wrong reserve_id > my $item = $hold->item; > if ( $item and C4::Context->preference('CanMarkHoldsToPullAsLost') =~ m|^allow| ) { >- my $patron = $hold->borrower; > C4::Circulation::LostItem( $item->itemnumber, "pendingreserves" ); > if ( $op eq 'mark_as_lost_and_notify' and C4::Context->preference('CanMarkHoldsToPullAsLost') eq 'allow_and_notify' ) { > my $library = $hold->branch; >@@ -123,6 +142,17 @@ if ( $op eq 'cancel_reserve' and $reserve_id ) { > } > } > >+ # send notice to user that their hold has been cancelled >+ my $letter = C4::Letters::GetPreparedLetter ( >+ module => 'reserves', >+ letter_code => 'HOLD_MANUAL_CANCEL', >+ branchcode => $hold_branchcode, >+ tables => { >+ 'biblio', $hold_biblionumber, >+ 'borrowers', $hold_borrowernumber >+ } >+ ); >+ C4::Message->enqueue($letter, $patron->unblessed, 'email'); > } elsif ( not $item ) { > push @messages, { type => 'alert', code => 'hold_placed_at_biblio_level'}; > } # else the url parameters have been modified and the user is not allowed to continue >diff --git a/reserve/request.pl b/reserve/request.pl >index 61f853d085..eb28f1ad04 100755 >--- a/reserve/request.pl >+++ b/reserve/request.pl >@@ -107,7 +107,23 @@ if ( $action eq 'move' ) { > } elsif ( $action eq 'cancel' ) { > my $reserve_id = $input->param('reserve_id'); > my $hold = Koha::Holds->find( $reserve_id ); >+ my $hold_branchcode = $hold->branchcode; >+ my $hold_biblionumber = $hold->biblionumber; >+ my $hold_borrowernumber = $hold->borrowernumber; >+ my $hold_borrower = Koha::Patrons->find( $hold_borrowernumber ); > $hold->cancel if $hold; >+ >+ # send notice to user that their hold has been cancelled >+ my $letter = C4::Letters::GetPreparedLetter ( >+ module => 'reserves', >+ letter_code => 'HOLD_MANUAL_CANCEL', >+ branchcode => $hold_branchcode, >+ tables => { >+ 'biblio', $hold_biblionumber, >+ 'borrowers', $hold_borrowernumber >+ } >+ ); >+ C4::Message->enqueue($letter, $hold_borrower->unblessed, 'email'); > } elsif ( $action eq 'setLowestPriority' ) { > my $reserve_id = $input->param('reserve_id'); > ToggleLowestPriority( $reserve_id ); >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20453
:
99546
|
99547
|
102170
|
102171
|
102956
|
102957
|
102958
|
103994
|
103995
|
103996
|
107449
|
110092
|
110093
|
110094
|
110178
|
110179
|
110180