Bugzilla – Attachment 159063 Details for
Bug 20844
Reset a hold when it is missing after allocation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20844: (follow-up) SendLostHoldNotices
Bug-20844-follow-up-SendLostHoldNotices.patch (text/plain), 9.05 KB, created by
Aleisha Amohia
on 2023-11-16 21:18:29 UTC
(
hide
)
Description:
Bug 20844: (follow-up) SendLostHoldNotices
Filename:
MIME Type:
Creator:
Aleisha Amohia
Created:
2023-11-16 21:18:29 UTC
Size:
9.05 KB
patch
obsolete
>From d09c8c88f90ed4a2e3b2a70faf5d65b0615af769 Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Thu, 26 Mar 2020 17:13:15 +0000 >Subject: [PATCH] Bug 20844: (follow-up) SendLostHoldNotices > >This patch adds a new syspref SendLostHoldNotices > >Test: >1) Update database and restart memcached >2) Enable the SendLostHoldNotices system preference >3) Place a hold on an item >4) Check in the item and set the hold to waiting >5) Go to edit the item and set an item lost status >6) Check the borrower's notices and confirm the notice has been enqueued >7) Confirm the notice is not sent twice when reverting or cancelling the >hold >8) Confirm notice enqueues as expected for a bib-level hold > >Sponsored-by: Catalyst IT >--- > C4/Circulation.pm | 15 +++++++++++++ > catalogue/updateitem.pl | 2 ++ > ...ug_20844-add_LOST_WAITING_HOLD_notice.perl | 6 +++++ > ...20844-add_SendLostHoldNotices_syspref.perl | 6 +++++ > .../mysql/en/mandatory/sample_notices.yml | 19 ++++++++++++++++ > .../admin/preferences/circulation.pref | 6 +++++ > t/db_dependent/Reserves.t | 22 +++++++++++++++++-- > 7 files changed, 74 insertions(+), 2 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_20844-add_LOST_WAITING_HOLD_notice.perl > create mode 100644 installer/data/mysql/atomicupdate/bug_20844-add_SendLostHoldNotices_syspref.perl > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 7ec9f09cc11..a22735bb922 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -4123,6 +4123,21 @@ sub LostItem{ > $hold = C4::Reserves::RevertWaitingStatus({ itemnumber => $itemnumber }); > } > } >+ >+ # SendLostHoldNotices >+ my $item = Koha::Items->find( $itemnumber ); >+ if ( C4::Context->preference('SendLostHoldNotices') && defined $hold && $item->itemlost ){ >+ my $letter = C4::Letters::GetPreparedLetter( >+ module => 'reserves', >+ letter_code => 'LOST_WAITING_HOLD', >+ branchcode => $hold->branchcode, >+ tables => { >+ borrowers => $hold->borrowernumber, >+ branches => $hold->branchcode, >+ }, >+ ); >+ C4::Message->enqueue($letter, $hold->borrower->unblessed, 'email'); >+ } > } > > sub GetOfflineOperations { >diff --git a/catalogue/updateitem.pl b/catalogue/updateitem.pl >index 2638d1f2b4d..8774ae2d37f 100755 >--- a/catalogue/updateitem.pl >+++ b/catalogue/updateitem.pl >@@ -48,6 +48,8 @@ if ( defined $cancelhold ){ > } elsif ( defined $reverthold ){ > $cancelhold = 0; > LostItem($itemnumber, 'moredetail', 0, { cancel_reserve => $cancelhold }); >+} else { >+ $cancelhold = undef; > } > if ( defined $redirecturl ){ > print $cgi->redirect( $redirecturl . $biblionumber ); >diff --git a/installer/data/mysql/atomicupdate/bug_20844-add_LOST_WAITING_HOLD_notice.perl b/installer/data/mysql/atomicupdate/bug_20844-add_LOST_WAITING_HOLD_notice.perl >new file mode 100644 >index 00000000000..4dc14f9606f >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_20844-add_LOST_WAITING_HOLD_notice.perl >@@ -0,0 +1,6 @@ >+$DBversion = 'XXX'; >+if( CheckVersion( $DBversion ) ) { >+ $dbh->do(q{INSERT IGNORE INTO letter (module, code, branchcode, name, is_html, title, message_transport_type, content) VALUES ('reserves','LOST_WAITING_HOLD','','Waiting hold marked lost','0','Your waiting hold has been marked lost','email',"Dear [% borrower.firstname %] [% borrowers.surname %],<br><br>Your hold awaiting pickup is no longer available. The item is lost.<br><br>Please contact the library for more information.<br><br>Thank you,<br><br>[% branch.branchname %]") }); >+ >+ NewVersion( $DBversion, 20844, "Add LOST_WAITING_HOLD notice"); >+} >diff --git a/installer/data/mysql/atomicupdate/bug_20844-add_SendLostHoldNotices_syspref.perl b/installer/data/mysql/atomicupdate/bug_20844-add_SendLostHoldNotices_syspref.perl >new file mode 100644 >index 00000000000..46b5f69da47 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_20844-add_SendLostHoldNotices_syspref.perl >@@ -0,0 +1,6 @@ >+$DBversion = 'XXX'; >+if( CheckVersion( $DBversion ) ) { >+ $dbh->do(q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('SendLostHoldNotices', '0', NULL, 'Send a notice to a borrower if their reserved and waiting item is marked as lost', 'YesNo') }); >+ >+ NewVersion( $DBversion, 20844, "Add SendLostHoldNotices system preference"); >+} >diff --git a/installer/data/mysql/en/mandatory/sample_notices.yml b/installer/data/mysql/en/mandatory/sample_notices.yml >index 9675b3eb4f1..657ba30c075 100644 >--- a/installer/data/mysql/en/mandatory/sample_notices.yml >+++ b/installer/data/mysql/en/mandatory/sample_notices.yml >@@ -2467,3 +2467,22 @@ tables: > - "Your hold on [% hold.biblio.title %] ([% hold.biblio.id %]) has been confirmed." > - "You will be notified by the library when your item is available for pickup." > - "Thank you!" >+ >+ - module: reserves >+ code: LOST_WAITING_HOLD >+ branchcode: "" >+ name: "Waiting hold marked lost" >+ is_html: 0 >+ title: "Your waiting hold has been marked lost" >+ message_transport_type: email >+ lang: default >+ content: >+ - "Dear [% borrower.firstname %] [% borrowers.surname %]," >+ - "" >+ - "Your hold awaiting pickup is no longer available. The item is lost." >+ - "" >+ - "Please contact the library for more information." >+ - "" >+ - "Thank you," >+ - "" >+ - "[% branch.branchname %]" >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >index 10a64594fcc..713b7df1e63 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >@@ -688,6 +688,12 @@ Circulation: > 1: Revert > 0: "Don't revert" > - waiting status of a hold if the allocated item is marked as Lost. >+ - >+ - pref: SendLostHoldNotices >+ choices: >+ yes: Send >+ no: "Don't send" >+ - a notice to a borrower if their reserved and waiting item is marked as Lost. > - > - In the staff interface, split the holds queue into separate tables by > - pref: HoldsSplitQueue >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index 176f19ca48b..72c9d3ac2a5 100755 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -1407,13 +1407,14 @@ subtest 'ModReserveAffect logging' => sub { > > subtest 'Waiting item is marked as lost' => sub { > >- plan tests => 15; >+ plan tests => 17; > > # Set up data > my $biblio = $builder->build_sample_biblio(); > my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber }); > my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >- >+ t::lib::Mocks::mock_preference( 'SendLostHoldNotices', 0 ); >+ $dbh->do(q|DELETE FROM message_queue|); > ## TEST 1: BIBLIO-LEVEL HOLD > > # place biblio-level hold >@@ -1424,6 +1425,8 @@ subtest 'Waiting item is marked as lost' => sub { > }); > my $hold = Koha::Holds->find( $reserve_id ); > >+ $dbh->do(q{INSERT IGNORE INTO letter (module, code, branchcode, name, is_html, title, message_transport_type, content) VALUES ('reserves','LOST_WAITING_HOLD','','Waiting hold marked lost','0','Your waiting hold has been marked lost','email',"Dear [% borrower.firstname %] [% borrowers.surname %],<br><br>Your hold awaiting pickup is no longer available. The item is lost.<br><br>Please contact the library for more information.<br><br>Thank you,<br><br>[% branch.branchname %]") }); >+ > is( $hold->item_level_hold, 0, 'Biblio-level hold placed' ); > > # set hold as waiting and assign item >@@ -1491,7 +1494,15 @@ subtest 'Waiting item is marked as lost' => sub { > $hold->cancel; > $item->itemlost( 0 ); > >+ my $message_count = $dbh->selectall_arrayref(q{ >+ SELECT COUNT(*) >+ FROM message_queue >+ WHERE letter_code = 'LOST_WAITING_HOLD' >+ }); >+ is( $message_count->[0]->[0], 0, 'No notices enqueued because SendLostHoldNotices disabled' ); >+ > # TEST 3: ITEM-LEVEL HOLD, CANCEL >+ t::lib::Mocks::mock_preference( 'SendLostHoldNotices', 1 ); > > # place item-level hold > $reserve_id = AddReserve({ >@@ -1525,6 +1536,13 @@ subtest 'Waiting item is marked as lost' => sub { > C4::Circulation::LostItem( $item->itemnumber, 'test', 0, { cancel_reserve => 1 }); > $hold = Koha::Holds->find( $reserve_id ); > is( Koha::Holds->find( $reserve_id ), undef, 'Hold has been cancelled with RevertLostBibLevelHolds enabled' ); >+ >+ $message_count = $dbh->selectall_arrayref(q{ >+ SELECT COUNT(*) >+ FROM message_queue >+ WHERE letter_code = 'LOST_WAITING_HOLD' >+ }); >+ is( $message_count->[0]->[0], 2, 'LOST_WAITING_HOLD notice enqueued with each call to LostItem' ); > }; > > sub count_hold_print_messages { >-- >2.30.2
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 20844
:
79267
|
80760
|
80761
|
80890
|
80891
|
81045
|
81531
|
81623
|
81624
|
81640
|
81697
|
81698
|
81710
|
81711
|
81712
|
102334
|
102335
|
102336
|
113208
|
113209
|
113210
|
118264
|
118265
|
118266
|
125437
|
125438
|
125439
|
140214
|
140215
|
140216
|
150348
|
150349
|
150350
|
150480
|
159062
|
159063
|
159064
|
159065
|
159111
|
170263
|
170264