@@ -, +, @@
in the patron account
---
C4/Letters.pm | 22 ++++++++++++++++++++
.../prog/en/modules/members/notices.tt | 4 ++--
members/notices.pl | 16 ++++++++++++++
t/db_dependent/Letters.t | 7 ++++++-
4 files changed, 46 insertions(+), 3 deletions(-)
--- a/C4/Letters.pm
+++ a/C4/Letters.pm
@@ -1085,6 +1085,28 @@ sub GetMessageTransportTypes {
return $mtts;
}
+=head2 ResendMessage
+
+ Attempt to resend a message.
+
+ my $message_id = C4::Letters::ResendMessage(123);
+
+ Updates the message to 'pending' status so that
+ it will be resent later on.
+
+ returns 1 on success, 0 on failure
+
+=cut
+
+sub ResendMessage {
+ my $message_id = shift;
+
+ return ((C4::Letters::_set_message_status( {
+ message_id => $message_id,
+ status => 'pending',
+ } ) > 0) ? 1:0);
+}
+
=head2 _add_attachements
named parameters:
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt
@@ -17,7 +17,7 @@
$(".notice").hide();
$(".notice-title").click(function(e){
- $(this).next(".notice").toggle();
+ $(this).closest("tr").children().children(".notice").toggle();
e.preventDefault();
});
@@ -71,7 +71,7 @@
[% IF ( QUEUED_MESSAGE.status == 'sent' ) %]sent
[% ELSIF ( QUEUED_MESSAGE.status == 'pending' ) %]pending
- [% ELSIF ( QUEUED_MESSAGE.status == 'failed' ) %]failed
+ [% ELSIF ( QUEUED_MESSAGE.status == 'failed' ) %]failed
[% ELSIF ( QUEUED_MESSAGE.status == 'deleted' ) %]deleted
[% ELSE %][% QUEUED_MESSAGE.status %][% END %]
|
--- a/members/notices.pl
+++ a/members/notices.pl
@@ -52,6 +52,22 @@ $template->param( picture => 1 ) if $picture;
# Getting the messages
my $queued_messages = C4::Letters::GetQueuedMessages({borrowernumber => $borrowernumber});
+# Bug 12426 - Allow resending of messages in Notices tab
+if ($input->param('resendnotice')) {
+ foreach my $message (@$queued_messages){
+ # resendnotice must be in this borrower's queue - we don't want to make it
+ # possible to change any message just by changing resendnotice id.
+ if ($message->{message_id} == $input->param('resendnotice')) {
+ # We also only want to resend messages in failed status
+ last unless $message->{status} eq "failed";
+
+ # Modify the message in $queued_message to have its new pending status
+ $message->{status} = 'pending' if (C4::Letters::ResendMessage($message->{message_id}));
+ last;
+ }
+ }
+}
+
if (C4::Context->preference('ExtendedPatronAttributes')) {
my $attributes = GetBorrowerAttributes($borrowernumber);
$template->param(
--- a/t/db_dependent/Letters.t
+++ a/t/db_dependent/Letters.t
@@ -18,7 +18,7 @@
# along with Koha; if not, see .
use Modern::Perl;
-use Test::More tests => 69;
+use Test::More tests => 70;
use Test::MockModule;
use Test::Warn;
@@ -137,6 +137,11 @@ is(
'message marked failed if tried to send SMS message for borrower with no smsalertnumber set (bug 11208)'
);
+# ResendMessage
+C4::Letters::ResendMessage($messages->[0]->{message_id});
+$messages = C4::Letters::GetQueuedMessages({ borrowernumber => $borrowernumber });
+is($messages->[0]->{status},'pending', 'ResendMessage sets status to pending correctly (bug 12426)');
+
# GetLetters
my $letters = C4::Letters::GetLetters();
is( @$letters, 0, 'GetLetters returns the correct number of letters' );
--