From 2b6cebe1c233ce310e5d5d84beb4b0acb11a2ab3 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 13 Jun 2018 19:08:33 +0000 Subject: [PATCH] Bug 20937: Truncate items for print notices when user has an email To test: 1 - Set PrintNotciesMaxLines to 1 2 - Checkout 2 (or more) items to a patron and make them overdue to trigger a notice 3 - Make sure the patron has an email 4 - Make sure the notice you are sending is set to 'print' as the type 5 - Run overdue_notices.pl without the 'nomail' option 6 - Find the message and note all items have been added 7 - Apply patch 8 - Clear the message queue 9 - Re-run overdue_notices.pl 10 - Confirm the message now has only 1 item. --- misc/cronjobs/overdue_notices.pl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl index 8c42335..b7683c2 100755 --- a/misc/cronjobs/overdue_notices.pl +++ b/misc/cronjobs/overdue_notices.pl @@ -683,13 +683,16 @@ END_SQL # email or sms is requested but not exist, do a print. $effective_mtt = 'print'; } + my @notice_items = @items; + splice @notice_items, $PrintNoticesMaxLines if $effective_mtt eq 'print' && scalar @notice_items > $PrintNoticesMaxLines; + #catch the case where we are sending a print to someone with an email my $letter_exists = C4::Letters::getletter( 'circulation', $overdue_rules->{"letter$i"}, $branchcode, $effective_mtt ) ? 1 : 0; my $letter = parse_overdues_letter( { letter_code => $overdue_rules->{"letter$i"}, borrowernumber => $borrowernumber, branchcode => $branchcode, - items => \@items, + items => \@notice_items, substitute => { # this appears to be a hack to overcome incomplete features in this code. bib => $library->branchname, # maybe 'bib' is a typo for 'lib'? 'items.content' => $titles, -- 2.1.4