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

(-)a/misc/cronjobs/stockrotation.pl (-9 / +9 lines)
Lines 166-171 exit 1 unless ($ok); Link Here
166
166
167
$send_email++ if ($send_all);    # if we send all, then we must want emails.
167
$send_email++ if ($send_all);    # if we send all, then we must want emails.
168
168
169
if ( $send_email && !$admin_email && ($report eq 'full')) {
170
    printf("Sending the full report by email requires --admin-email.\n");
171
    exit 1;
172
}
173
169
=head2 Helpers
174
=head2 Helpers
170
175
171
=head3 execute
176
=head3 execute
Lines 441-454 sub emit { Link Here
441
            # We have a report to send, or we want to send even empty
446
            # We have a report to send, or we want to send even empty
442
            # reports.
447
            # reports.
443
448
444
            # Send to branch
449
            # Select email address to send to
445
            my $addressee;
450
            my $addressee;
446
            if ( $part->{email_address} ) {
451
            if ( $part->{email_address} ) {
447
                $addressee = $part->{email_address};
452
                $addressee = $part->{email_address};
448
            }
453
            }
449
            elsif ( !$part->{no_branch_email} ) {
454
            elsif ( !$part->{no_branch_email} ) {
450
451
#push @emails, "***We tried to send a branch report, but we have no email address for this branch.***\n\n";
452
                $addressee = C4::Context->preference('KohaAdminEmailAddress')
455
                $addressee = C4::Context->preference('KohaAdminEmailAddress')
453
                  if ( C4::Context->preference('KohaAdminEmailAddress') );
456
                  if ( C4::Context->preference('KohaAdminEmailAddress') );
454
            }
457
            }
Lines 476-492 sub emit { Link Here
476
                        }
479
                        }
477
                      )
480
                      )
478
                      or warn
481
                      or warn
479
"can't enqueue letter $part->{letter} for $params->{admin_email}";
482
                      "can't enqueue letter $part->{letter} for $params->{admin_email}";
480
                }
483
                }
481
            }
484
            }
482
            else {
485
            else {
483
                $addressee ||=
484
                  defined( $params->{admin_email} )
485
                  ? $params->{admin_email} . "\n"
486
                  : 'No recipient found' . "\n";
487
                my $email =
486
                my $email =
488
                  "-------- Email message --------" . "\n\n";
487
                  "-------- Email message --------" . "\n\n";
489
                $email .= "To: $addressee\n";
488
                $email .= "To: $addressee\n";
489
                $email .= "Cc: " . $params->{admin_email} . "\n"
490
                  if ( $params->{admin_email} );
490
                $email .= "Subject: "
491
                $email .= "Subject: "
491
                  . $part->{letter}->{title} . "\n\n"
492
                  . $part->{letter}->{title} . "\n\n"
492
                  . $part->{letter}->{content};
493
                  . $part->{letter}->{content};
493
- 

Return to bug 22566