@@ -, +, @@ cancelled --- Koha/Recall.pm | 27 ++++++++++++++- ...RECALL_MANUAL_CANCEL_message_attributes.pl | 12 +++++++ ...RECALL_MANUAL_CANCEL_message_transports.pl | 12 +++++++ ...g_30295-add_RECALL_MANUAL_CANCEL_notice.pl | 24 +++++++++++++ .../mysql/en/mandatory/sample_notices.yml | 34 +++++++++++++++++++ .../sample_notices_message_attributes.sql | 3 +- .../sample_notices_message_transports.sql | 4 ++- .../en/includes/messaging-preference-form.inc | 1 + .../bootstrap/en/modules/opac-messaging.tt | 1 + 9 files changed, 115 insertions(+), 3 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_30295-add_RECALL_MANUAL_CANCEL_message_attributes.pl create mode 100644 installer/data/mysql/atomicupdate/bug_30295-add_RECALL_MANUAL_CANCEL_message_transports.pl create mode 100644 installer/data/mysql/atomicupdate/bug_30295-add_RECALL_MANUAL_CANCEL_notice.pl --- a/Koha/Recall.pm +++ a/Koha/Recall.pm @@ -18,7 +18,8 @@ package Koha::Recall; # along with Koha; if not, see . use Modern::Perl; - +use C4::Letters; +use C4::Members::Messaging; use Koha::Database; use Koha::DateUtils qw( dt_from_string ); use Koha::Biblios; @@ -451,6 +452,30 @@ sub set_cancelled { my ( $self ) = @_; $self->update({ status => 'cancelled', completed => 1, completed_date => dt_from_string }); C4::Log::logaction( 'RECALLS', 'CANCEL', $self->id, "Recall cancelled", 'INTRANET' ) if ( C4::Context->preference('RecallsLog') ); + + # send notice to recaller to pick up item + my $letter = C4::Letters::GetPreparedLetter( + module => 'circulation', + letter_code => 'RECALL_MANUAL_CANCEL', + branchcode => $self->pickup_library_id, + lang => $self->patron->lang, + tables => { + biblio => $self->biblio_id, + borrowers => $self->patron_id, + branches => $self->pickup_library_id, + }, + ); + + my $messaging_preferences = C4::Members::Messaging::GetMessagingPreferences({ borrowernumber => $self->patron_id, message_name => 'Recall_Cancelled' }); + while ( my ( $transport, $letter_code ) = each %{ $messaging_preferences->{transports} } ) { + if ( $transport eq 'email' ){ + C4::Message->enqueue($letter, $self->patron->unblessed, 'email'); + } + if ( $transport eq 'sms' ){ + C4::Message->enqueue($letter, $self->patron->unblessed, 'sms'); + } + } + return $self; } --- a/installer/data/mysql/atomicupdate/bug_30295-add_RECALL_MANUAL_CANCEL_message_attributes.pl +++ a/installer/data/mysql/atomicupdate/bug_30295-add_RECALL_MANUAL_CANCEL_message_attributes.pl @@ -0,0 +1,12 @@ +use Modern::Perl; + +return { + bug_number => "30295", + description => "Adding message attributes for RECALL_MANUAL_CANCEL", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + + $dbh->do(q{ INSERT IGNORE INTO message_attributes (message_attribute_id, message_name, takes_days) VALUES (14, 'Recall_Cancelled', 0) }); + }, +}; --- a/installer/data/mysql/atomicupdate/bug_30295-add_RECALL_MANUAL_CANCEL_message_transports.pl +++ a/installer/data/mysql/atomicupdate/bug_30295-add_RECALL_MANUAL_CANCEL_message_transports.pl @@ -0,0 +1,12 @@ +use Modern::Perl; + +return { + bug_number => "30295", + description => "Adding message transports for RECALL_MANUAL_CANCEL notice", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + + $dbh->do(q{ INSERT IGNORE INTO message_transports (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code, branchcode) VALUES (14, "email", 0, "circulation", "RECALL_MANUAL_CANCEL", null), (14, "sms", 0, "circulation", "RECALL_MANUAL_CANCEL", null) }); + }, +}; --- a/installer/data/mysql/atomicupdate/bug_30295-add_RECALL_MANUAL_CANCEL_notice.pl +++ a/installer/data/mysql/atomicupdate/bug_30295-add_RECALL_MANUAL_CANCEL_notice.pl @@ -0,0 +1,24 @@ +use Modern::Perl; + +return { + bug_number => "30295", + description => "Add RECALL_MANUAL_CANCEL email and sms notice", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + + $dbh->do(q{ INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`) VALUES ('circulation','RECALL_MANUAL_CANCEL','','Recall has been cancelled','0','Recall has been cancelled','Dear [% borrower.firstname %] [% borrower.surname %], + +We regret to inform you that the item you have recalled cannot be provided. Your recall was cancelled. + +Title: [% biblio.title %] +Author: [% biblio.author %] +Location: [% branch.branchname %]','sms'), ('circulation','RECALL_MANUAL_CANCEL','','Recall has been cancelled','0','Recall has been cancelled','Dear [% borrower.firstname %] [% borrower.surname %], + +We regret to inform you that the item you have recalled cannot be provided. Your recall was cancelled. + +Title: [% biblio.title %] +Author: [% biblio.author %] +Location: [% branch.branchname %]','email') }); + }, +}; --- a/installer/data/mysql/en/mandatory/sample_notices.yml +++ a/installer/data/mysql/en/mandatory/sample_notices.yml @@ -2221,3 +2221,37 @@ tables: - "[% IF borrower.categorycode %]
  • Temporary patron category: [% borrower.categorycode %]
  • [% END %]" - "" - "

    " + + - module: circulation + code: RECALL_MANUAL_CANCEL + branchcode: "" + name: "Recall has been cancelled" + is_html: 0 + title: "Recall has been cancelled" + message_transport_type: email + lang: default + content: + - "Dear [% borrower.firstname %] [% borrower.surname %]," + - "" + - "We regret to inform you that the item you have recalled cannot be provided. Your recall was cancelled." + - "" + - "Title: [% biblio.title %]" + - "Author: [% biblio.author %]" + - "Location: [% branch.branchname %]" + + - module: circulation + code: RECALL_MANUAL_CANCEL + branchcode: "" + name: "Recall has been cancelled" + is_html: 0 + title: "Recall has been cancelled" + message_transport_type: sms + lang: default + content: + - "Dear [% borrower.firstname %] [% borrower.surname %]," + - "" + - "We regret to inform you that the item you have recalled cannot be provided. Your recall was cancelled." + - "" + - "Title: [% biblio.title %]" + - "Author: [% biblio.author %]" + - "Location: [% branch.branchname %]" --- a/installer/data/mysql/mandatory/sample_notices_message_attributes.sql +++ a/installer/data/mysql/mandatory/sample_notices_message_attributes.sql @@ -12,4 +12,5 @@ values (10, 'Hold_Reminder', 0), (11, 'Ill_update', 0), (12, 'Recall_Waiting', 0), -(13, 'Recall_Requested', 0); +(13, 'Recall_Requested', 0), +(14, 'Recall_Cancelled', 0); --- a/installer/data/mysql/mandatory/sample_notices_message_transports.sql +++ a/installer/data/mysql/mandatory/sample_notices_message_transports.sql @@ -45,4 +45,6 @@ values (12, "email", 0, "circulation", "PICKUP_RECALLED_ITEM"), (12, "sms", 0, "circulation", "PICKUP_RECALLED_ITEM"), (13, "email", 0, "circulation", "RETURN_RECALLED_ITEM"), -(13, "sms", 0, "circulation", "RETURN_RECALLED_ITEM"); +(13, "sms", 0, "circulation", "RETURN_RECALLED_ITEM"), +(14, "email", 0, "circulation", "RECALL_MANUAL_CANCEL"), +(14, "sms", 0, "circulation", "RECALL_MANUAL_CANCEL"); --- a/koha-tmpl/intranet-tmpl/prog/en/includes/messaging-preference-form.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/messaging-preference-form.inc @@ -36,6 +36,7 @@ [% ELSIF ( messaging_preference.Auto_Renewals ) %]Auto renewal [% ELSIF ( Koha.Preference('UseRecalls') && messaging_preference.Recall_Waiting ) %]Recall awaiting pickup [% ELSIF ( Koha.Preference('UseRecalls') && messaging_preference.Recall_Requested ) %]Return recalled item + [% ELSIF ( Koha.Preference('UseRecalls') && messaging_preference.Recall_Cancelled ) %]Recall cancelled [% ELSE %]Unknown [% END %] --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt @@ -80,6 +80,7 @@ [% ELSIF ( messaging_preference.Auto_Renewals ) %]Auto renewal [% ELSIF ( Koha.Preference('UseRecalls') && messaging_preference.Recall_Waiting ) %]Recall awaiting pickup [% ELSIF ( Koha.Preference('UseRecalls') && messaging_preference.Recall_Requested ) %]Return recalled item + [% ELSIF ( Koha.Preference('UseRecalls') && messaging_preference.Recall_Cancelled ) %]Recall cancelled [% ELSE %]Unknown [% END %] [% IF ( messaging_preference.takes_days ) %]