From 4e31d54c9b910f2019c4ec4100f6c3a0c3c83aeb Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 18 Jun 2019 14:24:27 +0100 Subject: [PATCH] Bug 22566: Clarify intent of reports and add warnings Signed-off-by: Nick Clemens Signed-off-by: Martin Renvoize (cherry picked from commit 4e4f0b637c66ca04a07473c347cc741d456c20c5) Signed-off-by: Fridolin Somers --- misc/cronjobs/stockrotation.pl | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/misc/cronjobs/stockrotation.pl b/misc/cronjobs/stockrotation.pl index 5cf6374b12..87d6a9ec59 100755 --- a/misc/cronjobs/stockrotation.pl +++ b/misc/cronjobs/stockrotation.pl @@ -166,6 +166,11 @@ exit 1 unless ($ok); $send_email++ if ($send_all); # if we send all, then we must want emails. +if ( $send_email && !$admin_email && ($report eq 'full')) { + printf("Sending the full report by email requires --admin-email.\n"); + exit 1; +} + =head2 Helpers =head3 execute @@ -441,14 +446,12 @@ sub emit { # We have a report to send, or we want to send even empty # reports. - # Send to branch + # Select email address to send to my $addressee; if ( $part->{email_address} ) { $addressee = $part->{email_address}; } elsif ( !$part->{no_branch_email} ) { - -#push @emails, "***We tried to send a branch report, but we have no email address for this branch.***\n\n"; $addressee = C4::Context->preference('KohaAdminEmailAddress') if ( C4::Context->preference('KohaAdminEmailAddress') ); } @@ -476,17 +479,15 @@ sub emit { } ) or warn -"can't enqueue letter $part->{letter} for $params->{admin_email}"; + "can't enqueue letter $part->{letter} for $params->{admin_email}"; } } else { - $addressee ||= - defined( $params->{admin_email} ) - ? $params->{admin_email} . "\n" - : 'No recipient found' . "\n"; my $email = "-------- Email message --------" . "\n\n"; $email .= "To: $addressee\n"; + $email .= "Cc: " . $params->{admin_email} . "\n" + if ( $params->{admin_email} ); $email .= "Subject: " . $part->{letter}->{title} . "\n\n" . $part->{letter}->{content}; -- 2.39.5