Bug 20937: Truncate items for print notices when user has an email
authorNick Clemens <nick@bywatersolutions.com>
Wed, 27 Feb 2019 17:45:47 +0000 (12:45 -0500)
committerLucas Gass <lucas@bywatersolutions.com>
Tue, 16 Apr 2019 20:47:55 +0000 (20:47 +0000)
To test:
 1 - Set PrintNoticesMaxLines 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.
11 - Set PrintNoticesMaxLines to 0
12 - Clear the message queue
13 - Re-run overdue_notices.pl
14 - Confirm the message has 2 items as expected

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit 083f789b9548ec70d86dc48911df1bc9febda619)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit 746b3930d5556d14d4fcc6a64612561edf8fef96)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

misc/cronjobs/overdue_notices.pl

index 8c42335..d74edb5 100755 (executable)
@@ -683,6 +683,8 @@ END_SQL
                         # email or sms is requested but not exist, do a print.
                         $effective_mtt = 'print';
                     }
+                    splice @items, $PrintNoticesMaxLines if $effective_mtt eq 'print' && $PrintNoticesMaxLines && scalar @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(