@@ -, +, @@
---
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 +++++++++++++++++++
.../mysql/fr-CA/obligatoire/sample_notices.sql | 4 +++-
.../mysql/fr-FR/1-Obligatoire/sample_notices.sql | 4 +++-
installer/data/mysql/it-IT/necessari/notices.sql | 4 +++-
.../mysql/nb-NO/1-Obligatorisk/sample_notices.sql | 4 +++-
.../data/mysql/pl-PL/mandatory/sample_notices.sql | 4 +++-
.../data/mysql/ru-RU/mandatory/sample_notices.sql | 4 +++-
.../data/mysql/uk-UA/mandatory/sample_notices.sql | 4 +++-
.../en/modules/admin/preferences/circulation.pref | 6 ++++++
t/db_dependent/Reserves.t | 22 ++++++++++++++++++++--
14 files changed, 95 insertions(+), 9 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
@@ -3936,6 +3936,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
@@ -49,6 +49,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
@@ -1478,3 +1478,22 @@ tables:
- "Barcode: [% item.barcode %]
"
- "
"
- "[% END %]"
+
+ - 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/installer/data/mysql/fr-CA/obligatoire/sample_notices.sql
+++ a/installer/data/mysql/fr-CA/obligatoire/sample_notices.sql
@@ -36,7 +36,9 @@ Checked in items for [% borrower.title %] [% borrower.firstname %] [% borrower.i
[% item.biblio.title %]
Barcode: [% item.barcode %]
-[% END %]", 'print');
+[% END %]", 'print'),
+('reserves','LOST_WAITING_HOLD','','Waiting hold marked lost',0,'Your waiting hold has been marked lost',"Dear [% borrower.firstname %] [% borrowers.surname %],\n\nYour hold awaiting pickup is no longer available. The item is lost.\n\nPlease contact the library for more information.\n\nThank you,\n\n[% branch.branchname %]",'email')
+;
INSERT INTO `letter` (module, code, name, title, content, is_html, message_transport_type)
VALUES ('suggestions','NEW_SUGGESTION','Nouvelle suggestion','Nouvelle suggestion','Suggestion en attente
--- a/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql
+++ a/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql
@@ -23,7 +23,9 @@ VALUES
('suggestions','TO_PROCESS','Avis au propriétaire du poste budgétaire', 'Une suggestion est prête à être traitée','<> <>,\n\nUne nouvelle suggestion est prête à être traitée : <> / <>.\n\nMerci,\n\n<>', 'email'),
('suggestions', 'NOTIFY_MANAGER', 'Notify manager of a suggestion', "A suggestion has been assigned to you", "Dear [% borrower.firstname %] [% borrower.surname %],\nA suggestion has been assigned to you: [% suggestion.title %].\nThank you,\n[% branch.branchname %]", 'email'),
('members', 'DISCHARGE', 'Quitus', 'Quitus pour <> <>', 'Quitus
\r\n\r\nLa librairie <> certifies que lecteur suivant :\r\n\r\n <> <>\r\n Numéro de carte : <>\r\n\r\na bien retourné tous ses documents.', 'email'),
-('members', 'PROBLEM_REPORT','OPAC problem report','OPAC problem report','Username: <>\n\nProblem page: <>\n\nTitle: <>\n\nMessage: <>','email');
+('members', 'PROBLEM_REPORT','OPAC problem report','OPAC problem report','Username: <>\n\nProblem page: <>\n\nTitle: <>\n\nMessage: <>','email'),
+('reserves','LOST_WAITING_HOLD','Waiting hold marked lost','Your waiting hold has been marked lost',"Dear [% borrower.firstname %] [% borrowers.surname %],\n\nYour hold awaiting pickup is no longer available. The item is lost.\n\nPlease contact the library for more information.\n\nThank you,\n\n[% branch.branchname %]",'email')
+;
INSERT INTO `letter` (module, code, name, title, content, is_html, message_transport_type)
VALUES ('suggestions','NEW_SUGGESTION','New suggestion','New suggestion','Suggestion pendin g approval
--- a/installer/data/mysql/it-IT/necessari/notices.sql
+++ a/installer/data/mysql/it-IT/necessari/notices.sql
@@ -28,7 +28,9 @@ biblio.title>>\r\n----\r\nGrazie per aver visitaro <>.', 'e
('suggestions','TO_PROCESS','Notifica al proprietario del fondo', 'Un suggeerimento è pronto per essere lavorato','Caro bibliotecario <> <>,\n\n c\'è un nuovo suggerimento pronto per essere lavorato: <> by <>.\n\n Grazie dell\'attenzione,\n\n<>', 'email'),
('suggestions', 'NOTIFY_MANAGER', 'Notify manager of a suggestion', "A suggestion has been assigned to you", "Dear [% borrower.firstname %] [% borrower.surname %],\nA suggestion has been assigned to you: [% suggestion.title %].\nThank you,\n[% branch.branchname %]", 'email'),
('members', 'DISCHARGE', 'Liberatoria', 'Liberatoria per <> <>', 'Liberatoria
\r\n\r\nLa biblioteca <> certifica che il seguente utente :\r\n\r\n <> <>\r\n Numero tessera : <>\r\n\r\nha restituito tutti i documenti ricevuti.', 'email'),
-('members', 'PROBLEM_REPORT','OPAC problem report','OPAC problem report','Username: <>\n\nProblem page: <>\n\nTitle: <>\n\nMessage: <>','email');
+('members', 'PROBLEM_REPORT','OPAC problem report','OPAC problem report','Username: <>\n\nProblem page: <>\n\nTitle: <>\n\nMessage: <>','email'),
+('reserves','LOST_WAITING_HOLD','Waiting hold marked lost','Your waiting hold has been marked lost',"Dear [% borrower.firstname %] [% borrowers.surname %],\n\nYour hold awaiting pickup is no longer available. The item is lost.\n\nPlease contact the library for more information.\n\nThank you,\n\n[% branch.branchname %]",'email')
+;
INSERT INTO `letter` (module, code, name, title, content, is_html, message_transport_type)
VALUES ('suggestions','NEW_SUGGESTION','New suggestion','New suggestion','Suggestion pendin g approval
--- a/installer/data/mysql/nb-NO/1-Obligatorisk/sample_notices.sql
+++ a/installer/data/mysql/nb-NO/1-Obligatorisk/sample_notices.sql
@@ -43,7 +43,9 @@ VALUES ('circulation','ODUE','Purring','Purring på dokument','<> <>,\n\nA new suggestion is ready to be processed: <> by <>.\n\nThank you,\n\n<>', 'email'),
('suggestions', 'NOTIFY_MANAGER', 'Notify manager of a suggestion', "A suggestion has been assigned to you", "Dear [% borrower.firstname %] [% borrower.surname %],\nA suggestion has been assigned to you: [% suggestion.title %].\nThank you,\n[% branch.branchname %]", 'email'),
('members', 'DISCHARGE', 'Discharge', 'Discharge for <> <>', 'Discharge
\r\n\r\nThe library <> certifies that the following borrower :\r\n\r\n <> <>\r\n Cardnumber : <>\r\n\r\nreturned all his documents.', 'email'),
-('members', 'PROBLEM_REPORT','OPAC problem report','OPAC problem report','Username: <>\n\nProblem page: <>\n\nTitle: <>\n\nMessage: <>','email');
+('members', 'PROBLEM_REPORT','OPAC problem report','OPAC problem report','Username: <>\n\nProblem page: <>\n\nTitle: <>\n\nMessage: <>','email'),
+('reserves','LOST_WAITING_HOLD','Waiting hold marked lost','Your waiting hold has been marked lost',"Dear [% borrower.firstname %] [% borrowers.surname %],\n\nYour hold awaiting pickup is no longer available. The item is lost.\n\nPlease contact the library for more information.\n\nThank you,\n\n[% branch.branchname %]",'email')
+;
INSERT INTO `letter` (module, code, name, title, content, is_html, message_transport_type)
VALUES ('suggestions','NEW_SUGGESTION','New suggestion','New suggestion','Suggestion pendin g approval
--- a/installer/data/mysql/pl-PL/mandatory/sample_notices.sql
+++ a/installer/data/mysql/pl-PL/mandatory/sample_notices.sql
@@ -22,7 +22,9 @@ VALUES ('circulation','ODUE','Overdue notice','Item overdue','Dear <> <>,\n\nA new suggestion is ready to be processed: <> by <>.\n\nThank you,\n\n<>', 'email'),
('suggestions', 'NOTIFY_MANAGER', 'Notify manager of a suggestion', "A suggestion has been assigned to you", "Dear [% borrower.firstname %] [% borrower.surname %],\nA suggestion has been assigned to you: [% suggestion.title %].\nThank you,\n[% branch.branchname %]", 'email'),
('members', 'DISCHARGE', 'Discharge', 'Discharge for <> <>', 'Discharge
\r\n\r\nThe library <> certifies that the following borrower :\r\n\r\n <> <>\r\n Cardnumber : <>\r\n\r\nreturned all his documents.', 'email'),
-('members', 'PROBLEM_REPORT','OPAC problem report','OPAC problem report','Username: <>\n\nProblem page: <>\n\nTitle: <>\n\nMessage: <>','email');
+('members', 'PROBLEM_REPORT','OPAC problem report','OPAC problem report','Username: <>\n\nProblem page: <>\n\nTitle: <>\n\nMessage: <>','email'),
+('reserves','LOST_WAITING_HOLD','Waiting hold marked lost','Your waiting hold has been marked lost',"Dear [% borrower.firstname %] [% borrowers.surname %],\n\nYour hold awaiting pickup is no longer available. The item is lost.\n\nPlease contact the library for more information.\n\nThank you,\n\n[% branch.branchname %]",'email')
+;
INSERT INTO `letter` (module, code, name, title, content, is_html, message_transport_type)
VALUES ('suggestions','NEW_SUGGESTION','New suggestion','New suggestion','Suggestion pendin g approval
--- a/installer/data/mysql/ru-RU/mandatory/sample_notices.sql
+++ a/installer/data/mysql/ru-RU/mandatory/sample_notices.sql
@@ -21,7 +21,9 @@ VALUES ('circulation','ODUE','Overdue notice','Item overdue','Dear <> <>,\n\nA new suggestion is ready to be processed: <> by <>.\n\nThank you,\n\n<>', 'email'),
('suggestions', 'NOTIFY_MANAGER', 'Notify manager of a suggestion', "A suggestion has been assigned to you", "Dear [% borrower.firstname %] [% borrower.surname %],\nA suggestion has been assigned to you: [% suggestion.title %].\nThank you,\n[% branch.branchname %]", 'email'),
('members', 'DISCHARGE', 'Discharge', 'Discharge for <> <>', 'Discharge
\r\n\r\nThe library <> certifies that the following borrower :\r\n\r\n <> <>\r\n Cardnumber : <>\r\n\r\nreturned all his documents.', 'email'),
-('members', 'PROBLEM_REPORT','OPAC problem report','OPAC problem report','Username: <>\n\nProblem page: <>\n\nTitle: <>\n\nMessage: <>','email');
+('members', 'PROBLEM_REPORT','OPAC problem report','OPAC problem report','Username: <>\n\nProblem page: <>\n\nTitle: <>\n\nMessage: <>','email'),
+('reserves','LOST_WAITING_HOLD','Waiting hold marked lost','Your waiting hold has been marked lost',"Dear [% borrower.firstname %] [% borrowers.surname %],\n\nYour hold awaiting pickup is no longer available. The item is lost.\n\nPlease contact the library for more information.\n\nThank you,\n\n[% branch.branchname %]",'email')
+;
INSERT INTO `letter` (module, code, name, title, content, is_html, message_transport_type)
VALUES ('suggestions','NEW_SUGGESTION','New suggestion','New suggestion','Suggestion pendin g approval
--- a/installer/data/mysql/uk-UA/mandatory/sample_notices.sql
+++ a/installer/data/mysql/uk-UA/mandatory/sample_notices.sql
@@ -85,7 +85,9 @@ INSERT INTO `letter` (module, code, name, title, content, message_transport_type
('suggestions', 'NOTIFY_MANAGER', 'Notify manager of a suggestion', "A suggestion has been assigned to you", "Dear [% borrower.firstname %] [% borrower.surname %],\nA suggestion has been assigned to you: [% suggestion.title %].\nThank you,\n[% branch.branchname %]", 'email'),
-('members', 'PROBLEM_REPORT','OPAC problem report','OPAC problem report','Username: <>\n\nProblem page: <>\n\nTitle: <>\n\nMessage: <>','email')
+('members', 'PROBLEM_REPORT','OPAC problem report','OPAC problem report','Username: <>\n\nProblem page: <>\n\nTitle: <>\n\nMessage: <>','email'),
+
+('reserves','LOST_WAITING_HOLD','Waiting hold marked lost','Your waiting hold has been marked lost',"Dear [% borrower.firstname %] [% borrowers.surname %],\n\nYour hold awaiting pickup is no longer available. The item is lost.\n\nPlease contact the library for more information.\n\nThank you,\n\n[% branch.branchname %]",'email')
;
INSERT INTO `letter` (module, code, name, title, content, is_html, message_transport_type)
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
@@ -665,6 +665,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 interface, split the holds queue into separate tables by
- pref: HoldsSplitQueue
choices:
--- a/t/db_dependent/Reserves.t
+++ a/t/db_dependent/Reserves.t
@@ -1220,13 +1220,14 @@ subtest 'MergeHolds' => 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
@@ -1237,6 +1238,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 %],
Your hold awaiting pickup is no longer available. The item is lost.
Please contact the library for more information.
Thank you,
[% branch.branchname %]") });
+
is( $hold->item_level_hold, 0, 'Biblio-level hold placed' );
# set hold as waiting and assign item
@@ -1304,7 +1307,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({
@@ -1338,6 +1349,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 {
--