View | Details | Raw Unified | Return to bug 12426
Collapse All | Expand All

(-)a/C4/Letters.pm (+22 lines)
Lines 1060-1065 sub GetMessageTransportTypes { Link Here
1060
    return $mtts;
1060
    return $mtts;
1061
}
1061
}
1062
1062
1063
=head2 ResendMessage
1064
1065
  Attempt to resend a message.
1066
  
1067
  my $message_id = C4::Letters::ResendMessage(123);
1068
  
1069
  Updates the message to 'pending' status so that
1070
  it will be resent later on.
1071
1072
  returns 1 on success, 0 on failure
1073
1074
=cut
1075
1076
sub ResendMessage {
1077
    my $message_id = shift;
1078
    
1079
    return ((C4::Letters::_set_message_status( {
1080
                message_id => $message_id,
1081
                status => 'pending',
1082
         } ) > 0) ? 1:0);
1083
}
1084
1063
=head2 _add_attachements
1085
=head2 _add_attachements
1064
1086
1065
named parameters:
1087
named parameters:
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt (-2 / +2 lines)
Lines 16-22 Link Here
16
16
17
    $(".notice").hide();
17
    $(".notice").hide();
18
    $(".notice-title").click(function(e){
18
    $(".notice-title").click(function(e){
19
        $(this).next(".notice").toggle();
19
        $(this).closest("tr").children().children(".notice").toggle();
20
        e.preventDefault();
20
        e.preventDefault();
21
    });
21
    });
22
    
22
    
Lines 70-76 Link Here
70
		<td>
70
		<td>
71
            [% IF ( QUEUED_MESSAGE.status == 'sent' ) %]sent
71
            [% IF ( QUEUED_MESSAGE.status == 'sent' ) %]sent
72
            [% ELSIF ( QUEUED_MESSAGE.status == 'pending' ) %]pending
72
            [% ELSIF ( QUEUED_MESSAGE.status == 'pending' ) %]pending
73
            [% ELSIF ( QUEUED_MESSAGE.status == 'failed' ) %]failed
73
            [% ELSIF ( QUEUED_MESSAGE.status == 'failed' ) %]failed <div class="notice"><a href="/cgi-bin/koha/members/notices.pl?borrowernumber=[% borrowernumber %]&resendnotice=[% QUEUED_MESSAGE.message_id %]" title="Attempt to resend the notice">Resend</a></div>
74
            [% ELSIF ( QUEUED_MESSAGE.status == 'deleted' ) %]deleted
74
            [% ELSIF ( QUEUED_MESSAGE.status == 'deleted' ) %]deleted
75
            [% ELSE %][% QUEUED_MESSAGE.status %][% END %]
75
            [% ELSE %][% QUEUED_MESSAGE.status %][% END %]
76
        </td>
76
        </td>
(-)a/members/notices.pl (+16 lines)
Lines 53-58 $template->param( picture => 1 ) if $picture; Link Here
53
# Getting the messages
53
# Getting the messages
54
my $queued_messages = C4::Letters::GetQueuedMessages({borrowernumber => $borrowernumber});
54
my $queued_messages = C4::Letters::GetQueuedMessages({borrowernumber => $borrowernumber});
55
55
56
# Bug 12426 - Allow resending of messages in Notices tab
57
if ($input->param('resendnotice')) {
58
    foreach my $message (@$queued_messages){
59
        # resendnotice must be in this borrower's queue - we don't want to make it
60
        # possible to change any message just by changing resendnotice id.
61
        if ($message->{message_id} == $input->param('resendnotice')) {
62
            # We also only want to resend messages in failed status
63
            last unless $message->{status} eq "failed";
64
65
            # Modify the message in $queued_message to have its new pending status
66
            $message->{status} = 'pending' if (C4::Letters::ResendMessage($message->{message_id}));
67
            last;
68
        }
69
    }
70
}
71
56
if (C4::Context->preference('ExtendedPatronAttributes')) {
72
if (C4::Context->preference('ExtendedPatronAttributes')) {
57
    my $attributes = GetBorrowerAttributes($borrowernumber);
73
    my $attributes = GetBorrowerAttributes($borrowernumber);
58
    $template->param(
74
    $template->param(
(-)a/t/db_dependent/Letters.t (-2 / +6 lines)
Lines 18-24 Link Here
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
use Test::More tests => 65;
21
use Test::More tests => 66;
22
use Test::MockModule;
22
use Test::MockModule;
23
use Test::Warn;
23
use Test::Warn;
24
24
Lines 136-141 is( Link Here
136
    'message marked failed if tried to send SMS message for borrower with no smsalertnumber set (bug 11208)'
136
    'message marked failed if tried to send SMS message for borrower with no smsalertnumber set (bug 11208)'
137
);
137
);
138
138
139
# ResendMessage
140
C4::Letters::ResendMessage($messages->[0]->{message_id});
141
$messages = C4::Letters::GetQueuedMessages({ borrowernumber => $borrowernumber });
142
is($messages->[0]->{status},'pending', 'ResendMessage sets status to pending correctly (bug 12426)');
143
139
# GetLetters
144
# GetLetters
140
my $letters = C4::Letters::GetLetters();
145
my $letters = C4::Letters::GetLetters();
141
is( @$letters, 0, 'GetLetters returns the correct number of letters' );
146
is( @$letters, 0, 'GetLetters returns the correct number of letters' );
142
- 

Return to bug 12426