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

(-)a/C4/Letters.pm (-7 / +4 lines)
Lines 1096-1108 sub ResendMessage { Link Here
1096
1096
1097
    my $message = GetMessage( $message_id );
1097
    my $message = GetMessage( $message_id );
1098
    return unless $message;
1098
    return unless $message;
1099
    if ( $message->{status} eq 'failed' ) {
1099
    return ((C4::Letters::_set_message_status( {
1100
        return ((C4::Letters::_set_message_status( {
1100
                message_id => $message_id,
1101
                    message_id => $message_id,
1101
                status => 'pending',
1102
                    status => 'pending',
1102
         } ) > 0) ? 1:0);
1103
             } ) > 0) ? 1:0);
1104
    }
1105
    return 0;
1106
}
1103
}
1107
1104
1108
=head2 _add_attachements
1105
=head2 _add_attachements
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt (-1 / +11 lines)
Lines 70-78 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 <div class="notice"><a href="/cgi-bin/koha/members/notices.pl?borrowernumber=[% borrowernumber %]&amp;op=resend_notice&amp;message_id=[% QUEUED_MESSAGE.message_id %]" title="Attempt to resend the notice">Resend</a></div>
73
            [% ELSIF ( QUEUED_MESSAGE.status == 'failed' ) %]failed
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
            [% IF ( QUEUED_MESSAGE.status != 'pending' ) %]
77
            <div class="notice">
78
                <form action="/cgi-bin/koha/members/notices.pl?borrowernumber=[% borrowernumber %]" method="POST">
79
                    <input type="hidden" name="op" value="resend_notice" />
80
                    <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
81
                    <input type="hidden" name="message_id" value="[% QUEUED_MESSAGE.message_id %]" />
82
                    <a href="#" onclick="$(this).closest('form').submit();return false;" title="Attempt to resend the notice">Resend</a>
83
                </form>
84
            </div>
85
            [% END %]
76
        </td>
86
        </td>
77
        <td><span title="[% QUEUED_MESSAGE.time_queued %]">[% QUEUED_MESSAGE.time_queued | $KohaDates with_hours => 1 %]</span></td>
87
        <td><span title="[% QUEUED_MESSAGE.time_queued %]">[% QUEUED_MESSAGE.time_queued | $KohaDates with_hours => 1 %]</span></td>
78
	    </tr>
88
	    </tr>
(-)a/members/notices.pl (+2 lines)
Lines 58-63 if ( $op eq 'resend_notice' ) { Link Here
58
    my $message = C4::Letters::GetMessage( $message_id );
58
    my $message = C4::Letters::GetMessage( $message_id );
59
    if ( $message->{borrowernumber} = $borrowernumber ) {
59
    if ( $message->{borrowernumber} = $borrowernumber ) {
60
        C4::Letters::ResendMessage( $message_id );
60
        C4::Letters::ResendMessage( $message_id );
61
        # redirect to self to avoid form submission on refresh
62
        print $input->redirect("/cgi-bin/koha/members/notices.pl?borrowernumber=$borrowernumber");
61
    }
63
    }
62
}
64
}
63
65
(-)a/t/db_dependent/Letters.t (-2 / +1 lines)
Lines 142-148 my $message = C4::Letters::GetMessage( $messages->[0]->{message_id}); Link Here
142
is( $resent, 1, 'The message should have been resent' );
142
is( $resent, 1, 'The message should have been resent' );
143
is($message->{status},'pending', 'ResendMessage sets status to pending correctly (bug 12426)');
143
is($message->{status},'pending', 'ResendMessage sets status to pending correctly (bug 12426)');
144
$resent = C4::Letters::ResendMessage($messages->[0]->{message_id});
144
$resent = C4::Letters::ResendMessage($messages->[0]->{message_id});
145
is( $resent, 0, 'The message should not have been resent again' );
145
is( $resent, 1, 'The message should be resent again regardless of status' );
146
$resent = C4::Letters::ResendMessage();
146
$resent = C4::Letters::ResendMessage();
147
is( $resent, undef, 'ResendMessage should return undef if not message_id given' );
147
is( $resent, undef, 'ResendMessage should return undef if not message_id given' );
148
148
149
- 

Return to bug 12426