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

(-)a/misc/cronjobs/gather_print_notices.pl (-15 / +15 lines)
Lines 20-27 use Getopt::Long qw( GetOptions ); Link Here
20
use C4::Log qw( cronlogaction );
20
use C4::Log qw( cronlogaction );
21
21
22
use Koha::DateUtils qw( dt_from_string output_pref );
22
use Koha::DateUtils qw( dt_from_string output_pref );
23
use Koha::Email;
23
use Koha::Util::OpenDocument qw( generate_ods );
24
use Koha::Util::OpenDocument qw( generate_ods );
24
use MIME::Lite;
25
25
26
my (
26
my (
27
    $help,
27
    $help,
Lines 151-157 sub print_notices { Link Here
151
    my $format = $params->{format} // 'html';
151
    my $format = $params->{format} // 'html';
152
152
153
    die "Format $format is not known"
153
    die "Format $format is not known"
154
        unless $format =~ m[^html$|^csv$|^ods$];
154
        unless $format =~ m/^html$|^csv$|^ods$/;
155
155
156
    my ( @filenames, $messages_by_branch );
156
    my ( @filenames, $messages_by_branch );
157
157
Lines 287-297 sub send_files { Link Here
287
    my $from = $params->{from};
287
    my $from = $params->{from};
288
    return unless $to and $from;
288
    return unless $to and $from;
289
289
290
    my $mail = MIME::Lite->new(
290
    my $email = Koha::Email->create(
291
        From     => $from,
291
        {
292
        To       => $to,
292
            from    => $from,
293
        Subject  => 'Print notices for ' . $today_syspref,
293
            to      => $to,
294
        Type     => 'multipart/mixed',
294
            subject => 'Print notices for ' . $today_syspref,
295
        }
295
    );
296
    );
296
297
297
    while ( my ( $type, $filenames ) = each %$files ) {
298
    while ( my ( $type, $filenames ) = each %$files ) {
Lines 306-325 sub send_files { Link Here
306
307
307
            next unless $mimetype;
308
            next unless $mimetype;
308
309
309
            my $filepath = File::Spec->catdir( $directory, $filename );
310
            my $filepath = File::Spec->catfile( $directory, $filename );
310
311
311
            next unless $filepath or -f $filepath;
312
            next unless $filepath or -f $filepath;
312
313
313
            $mail->attach(
314
            $email->attach_file(
314
              Type     => $mimetype,
315
                $filepath,
315
              Path     => $filepath,
316
                content_type => $mimetype,
316
              Filename => $filename,
317
                name         => $filename,
317
              Encoding => 'base64',
318
                disposition  => 'attachment',
318
            );
319
            );
319
        }
320
        }
320
    }
321
    }
321
322
322
    $mail->send;
323
    $email->send_or_die;
323
}
324
}
324
325
325
=head1 NAME
326
=head1 NAME
326
- 

Return to bug 29501