@@ -, +, @@
---
C4/Circulation.pm | 15 +++++++++++++++
catalogue/updateitem.pl | 2 ++
.../bug_20844-add_LOST_WAITING_HOLD_notice.perl | 6 ++++++
.../bug_20844-add_SendLostHoldNotices_syspref.perl | 6 ++++++
.../data/mysql/en/mandatory/sample_notices.yml | 19 +++++++++++++++++++
.../en/modules/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
--- a/C4/Circulation.pm
+++ a/C4/Circulation.pm
@@ -3949,6 +3949,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 {
--- a/catalogue/updateitem.pl
+++ a/catalogue/updateitem.pl
@@ -47,6 +47,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 );
--- a/installer/data/mysql/atomicupdate/bug_20844-add_LOST_WAITING_HOLD_notice.perl
+++ a/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 %],
Your hold awaiting pickup is no longer available. The item is lost.
Please contact the library for more information.
Thank you,
[% branch.branchname %]") });
+
+ NewVersion( $DBversion, 20844, "Add LOST_WAITING_HOLD notice");
+}
--- a/installer/data/mysql/atomicupdate/bug_20844-add_SendLostHoldNotices_syspref.perl
+++ a/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");
+}
--- a/installer/data/mysql/en/mandatory/sample_notices.yml
+++ a/installer/data/mysql/en/mandatory/sample_notices.yml
@@ -1745,3 +1745,22 @@ tables:
- "
This is to confirm that someone enabled two factor authentication on your account.
" - "If you did not do this, someone else may be using your account. Please contact technical support.
" - "Your library
" + + - 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 %]" --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -668,6 +668,12 @@ Circulation: no: "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 client, split the holds queue into separate tables by - pref: HoldsSplitQueue choices: --- a/t/db_dependent/Reserves.t +++ a/t/db_dependent/Reserves.t @@ -1410,13 +1410,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 @@ -1427,6 +1428,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 %],