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

(-)a/C4/Letters.pm (-7 / +6 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
    
1100
        return ((C4::Letters::_set_message_status( {
1100
    return ((C4::Letters::_set_message_status( {
1101
                    message_id => $message_id,
1101
                message_id => $message_id,
1102
                    status => 'pending',
1102
                status => 'pending',
1103
             } ) > 0) ? 1:0);
1103
         } ) > 0) ? 1:0);
1104
    }
1104
    
1105
    return 0;
1106
}
1105
}
1107
1106
1108
=head2 _add_attachements
1107
=head2 _add_attachements
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt (-1 / +12 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
            
77
            [% IF ( QUEUED_MESSAGE.status != 'pending' ) %]
78
            <div class="notice">
79
                <form action="/cgi-bin/koha/members/notices.pl?borrowernumber=[% borrowernumber %]" method="POST">
80
                    <input type="hidden" name="op" value="resend_notice" />
81
                    <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
82
                    <input type="hidden" name="message_id" value="[% QUEUED_MESSAGE.message_id %]" />
83
                    <a href="#" onclick="$(this).closest('form').submit();return false;" title="Attempt to resend the notice">Resend</a>
84
                </form>
85
            </div>
86
            [% END %]
76
        </td>
87
        </td>
77
        <td><span title="[% QUEUED_MESSAGE.time_queued %]">[% QUEUED_MESSAGE.time_queued | $KohaDates with_hours => 1 %]</span></td>
88
        <td><span title="[% QUEUED_MESSAGE.time_queued %]">[% QUEUED_MESSAGE.time_queued | $KohaDates with_hours => 1 %]</span></td>
78
	    </tr>
89
	    </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 (-4 / +1 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 => 68;
22
use Test::MockModule;
22
use Test::MockModule;
23
use Test::Warn;
23
use Test::Warn;
24
24
Lines 141-148 my $resent = C4::Letters::ResendMessage($messages->[0]->{message_id}); Link Here
141
my $message = C4::Letters::GetMessage( $messages->[0]->{message_id});
141
my $message = C4::Letters::GetMessage( $messages->[0]->{message_id});
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});
145
is( $resent, 0, 'The message should not have been resent again' );
146
$resent = C4::Letters::ResendMessage();
144
$resent = C4::Letters::ResendMessage();
147
is( $resent, undef, 'ResendMessage should return undef if not message_id given' );
145
is( $resent, undef, 'ResendMessage should return undef if not message_id given' );
148
146
149
- 

Return to bug 12426