From a2a4580f8674116b73c6525e5854562eb62e5df7 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 17 Aug 2022 09:00:22 +0100 Subject: [PATCH] Bug 31028: Add trigger and notice to resolve This patch adds a sample notice and sets up the trigger to notify the concern reporter when a concern is marked as resolved. The notification itself is optional at resolve time. --- Koha/Catalog/Concern.pm | 19 ++++++++++++++++++- .../data/mysql/atomicupdate/bug_31028.pl | 7 +++++++ .../mysql/en/mandatory/sample_notices.yml | 18 ++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/Koha/Catalog/Concern.pm b/Koha/Catalog/Concern.pm index 8c2f75767b..c229d318c5 100644 --- a/Koha/Catalog/Concern.pm +++ b/Koha/Catalog/Concern.pm @@ -102,6 +102,23 @@ sub resolve { # Optionally add to message_queue here to notify reporter if ( $params->{notify} ) { + my $letter = C4::Letters::GetPreparedLetter( + module => 'catalog', + letter_code => 'CONCERN_RESOLVE', + branchcode => $self->resolver->branchcode, + tables => { catalog_concerns => $self->id } + ); + + if ($letter) { + my $message_id = C4::Letters::EnqueueLetter( + { + letter => $letter, + borrowernumber => $self->reporter_id, + message_transport_type => 'email', + } + ); + C4::Letters::SendQueuedMessages( { message_id => $message_id } ); + } } @@ -137,7 +154,7 @@ sub store { { letter => $letter, message_transport_type => 'email', - to_address => C4::Preference('CatalogerEmails'), + to_address => C4::Context->preference('CatalogerEmails'), reply_address => $self->reporter->notice_email_address, } ); diff --git a/installer/data/mysql/atomicupdate/bug_31028.pl b/installer/data/mysql/atomicupdate/bug_31028.pl index f2f80b501e..6be890a4de 100644 --- a/installer/data/mysql/atomicupdate/bug_31028.pl +++ b/installer/data/mysql/atomicupdate/bug_31028.pl @@ -55,5 +55,12 @@ return { } ); + $dbh->do( + q{ + INSERT IGNORE INTO letter(module,code,branchcode,name,is_html,title,content,message_transport_type) + VALUES ( 'catalog', 'CONCERN_RESOLVE', '', 'Concern resolved', '1', 'Catalog concern resolved', "Dear [% INCLUDE 'patron-title.inc' patron => catalog_concern.reporter %],\r\n\r\nThe library has now marked your concern with [% INCLUDE 'biblio-title.inc' biblio=catalog_concern.biblio link = 0 %] as resolved.\r\n\r\nThe following comment was left: \r\n[% catalog_concern.resolution_message %]\r\n\r\nThankyou", 'email' ); + } + ); + }, } diff --git a/installer/data/mysql/en/mandatory/sample_notices.yml b/installer/data/mysql/en/mandatory/sample_notices.yml index dabbee2893..c50cf131ac 100644 --- a/installer/data/mysql/en/mandatory/sample_notices.yml +++ b/installer/data/mysql/en/mandatory/sample_notices.yml @@ -59,6 +59,24 @@ tables: - "" - "You can mark this concern as resolved from the concern management page." + - module: catalog + code: CONCERN_RESOLVE + branchcode: "" + name: "Concern resolved" + is_html: 1 + title: "Catalog concern resolved" + message_transport_type: email + lang: default + content: + - "Dear [% INCLUDE 'patron-title.inc' patron => catalog_concern.reporter %]," + - "" + - "The library has now marked your concern with [% INCLUDE 'biblio-title.inc' biblio=catalog_concern.biblio link = 0 %] as resolved." + - "" + - "The following comment was left: " + - "[% catalog_concern.resolution_message %]" + - "" + - "Thankyou" + - module: circulation code: ACCOUNT_CREDIT branchcode: "" -- 2.20.1