Bug 11696: ensure that print overdue notices use the print template

This reordering avoids the case where a print notice is sent with an
email or sms template is no email or SMS is defined.

Test plan:
Check print, sms and email for an overdue rule
Don't define an email address and generate an overdue for a user
Define 3 templates for the notice used
Launch the cronjob script and verify the print notice is generated using
the print template.

Signed-off-by: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This commit is contained in:
Jonathan Druart 2014-02-06 11:41:35 +01:00 committed by Galen Charlton
parent 7f1bb7c6b2
commit 7ca4f590ac
2 changed files with 11 additions and 1 deletions

View file

@ -23,6 +23,8 @@ use strict;
#use warnings; FIXME - Bug 2505
use Date::Calc qw/Today Date_to_Days/;
use Date::Manip qw/UnixDate/;
use List::MoreUtils qw( uniq );
use C4::Circulation;
use C4::Context;
use C4::Accounts;
@ -928,6 +930,12 @@ sub GetOverdueMessageTransportTypes {
while ( my $mtt = $sth->fetchrow ) {
push @mtts, $mtt;
}
# Put 'print' in first if exists
# It avoid to sent a print notice with an email or sms template is no email or sms is defined
@mtts = uniq( 'print', @mtts )
if grep {/^print$/} @mtts;
return \@mtts;
}

View file

@ -38,6 +38,8 @@ $dbh->do(q|
('', 'PT', 1, 'email'),
('', 'PT', 2, 'email'),
('', 'PT', 2, 'sms'),
('', 'PT', 3, 'sms'),
('', 'PT', 3, 'email'),
('', 'PT', 3, 'print'),
('', 'YA', 2, 'sms')
|);
@ -69,7 +71,7 @@ $mtts = C4::Overdues::GetOverdueMessageTransportTypes('', 'PT', 2);
is_deeply( $mtts, ['email', 'sms'], 'GetOverdueMessageTransportTypes: second overdue is by email and sms for PT (default)' );
$mtts = C4::Overdues::GetOverdueMessageTransportTypes('', 'PT', 3);
is_deeply( $mtts, ['print'], 'GetOverdueMessageTransportTypes: third overdue is by print for PT (default)' );
is_deeply( $mtts, ['print', 'sms', 'email'], 'GetOverdueMessageTransportTypes: third overdue is by print, sms and email for PT (default). With print in first.' );
done_testing;