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

(-)a/C4/Letters.pm (+22 lines)
Lines 1085-1090 sub GetMessageTransportTypes { Link Here
1085
    return $mtts;
1085
    return $mtts;
1086
}
1086
}
1087
1087
1088
=head2 ResendMessage
1089
1090
  Attempt to resend a message.
1091
1092
  my $message_id = C4::Letters::ResendMessage(123);
1093
1094
  Updates the message to 'pending' status so that
1095
  it will be resent later on.
1096
1097
  returns 1 on success, 0 on failure
1098
1099
=cut
1100
1101
sub ResendMessage {
1102
    my $message_id = shift;
1103
1104
    return ((C4::Letters::_set_message_status( {
1105
                message_id => $message_id,
1106
                status => 'pending',
1107
         } ) > 0) ? 1:0);
1108
}
1109
1088
=head2 _add_attachements
1110
=head2 _add_attachements
1089
1111
1090
named parameters:
1112
named parameters:
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt (-2 / +2 lines)
Lines 17-23 Link Here
17
17
18
    $(".notice").hide();
18
    $(".notice").hide();
19
    $(".notice-title").click(function(e){
19
    $(".notice-title").click(function(e){
20
        $(this).next(".notice").toggle();
20
        $(this).closest("tr").children().children(".notice").toggle();
21
        e.preventDefault();
21
        e.preventDefault();
22
    });
22
    });
23
    
23
    
Lines 71-77 Link Here
71
		<td>
71
		<td>
72
            [% IF ( QUEUED_MESSAGE.status == 'sent' ) %]sent
72
            [% IF ( QUEUED_MESSAGE.status == 'sent' ) %]sent
73
            [% ELSIF ( QUEUED_MESSAGE.status == 'pending' ) %]pending
73
            [% ELSIF ( QUEUED_MESSAGE.status == 'pending' ) %]pending
74
            [% ELSIF ( QUEUED_MESSAGE.status == 'failed' ) %]failed
74
            [% 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>
75
            [% ELSIF ( QUEUED_MESSAGE.status == 'deleted' ) %]deleted
75
            [% ELSIF ( QUEUED_MESSAGE.status == 'deleted' ) %]deleted
76
            [% ELSE %][% QUEUED_MESSAGE.status %][% END %]
76
            [% ELSE %][% QUEUED_MESSAGE.status %][% END %]
77
        </td>
77
        </td>
(-)a/members/notices.pl (+16 lines)
Lines 52-57 $template->param( picture => 1 ) if $picture; Link Here
52
# Getting the messages
52
# Getting the messages
53
my $queued_messages = C4::Letters::GetQueuedMessages({borrowernumber => $borrowernumber});
53
my $queued_messages = C4::Letters::GetQueuedMessages({borrowernumber => $borrowernumber});
54
54
55
# Bug 12426 - Allow resending of messages in Notices tab
56
if ($input->param('resendnotice')) {
57
    foreach my $message (@$queued_messages){
58
        # resendnotice must be in this borrower's queue - we don't want to make it
59
        # possible to change any message just by changing resendnotice id.
60
        if ($message->{message_id} == $input->param('resendnotice')) {
61
            # We also only want to resend messages in failed status
62
            last unless $message->{status} eq "failed";
63
64
            # Modify the message in $queued_message to have its new pending status
65
            $message->{status} = 'pending' if (C4::Letters::ResendMessage($message->{message_id}));
66
            last;
67
        }
68
    }
69
}
70
55
if (C4::Context->preference('ExtendedPatronAttributes')) {
71
if (C4::Context->preference('ExtendedPatronAttributes')) {
56
    my $attributes = GetBorrowerAttributes($borrowernumber);
72
    my $attributes = GetBorrowerAttributes($borrowernumber);
57
    $template->param(
73
    $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 => 69;
21
use Test::More tests => 70;
22
use Test::MockModule;
22
use Test::MockModule;
23
use Test::Warn;
23
use Test::Warn;
24
24
Lines 137-142 is( Link Here
137
    'message marked failed if tried to send SMS message for borrower with no smsalertnumber set (bug 11208)'
137
    'message marked failed if tried to send SMS message for borrower with no smsalertnumber set (bug 11208)'
138
);
138
);
139
139
140
# ResendMessage
141
C4::Letters::ResendMessage($messages->[0]->{message_id});
142
$messages = C4::Letters::GetQueuedMessages({ borrowernumber => $borrowernumber });
143
is($messages->[0]->{status},'pending', 'ResendMessage sets status to pending correctly (bug 12426)');
144
140
# GetLetters
145
# GetLetters
141
my $letters = C4::Letters::GetLetters();
146
my $letters = C4::Letters::GetLetters();
142
is( @$letters, 0, 'GetLetters returns the correct number of letters' );
147
is( @$letters, 0, 'GetLetters returns the correct number of letters' );
143
- 

Return to bug 12426