- shift @lines; # remove headers
- for my $line ( @lines ) {
- my @row_data = split $delimiter, $line;
- my $row = $doc->getRow( $table, $i );
- # Note scalar(@$row_data) should be equal to $nb_cols
- for ( my $j = 0 ; $j < scalar(@row_data) ; $j++ ) {
- my $value = Encode::encode( 'UTF8', $row_data[$j] );
- $doc->cellValue( $row, $j, $value );
- }
- $i++;
+ # Process
+ generate_ods($ods_filepath, $ods_content);
+}
+
+sub send_files {
+ my ( $params ) = @_;
+ my $directory = $params->{directory};
+ my $files = $params->{files};
+ my $to = $params->{to};
+ my $from = $params->{from};
+ return unless $to and $from;
+
+ my $mail = MIME::Lite->new(
+ From => $from,
+ To => $to,
+ Subject => 'Print notices for ' . $today_syspref,
+ Type => 'multipart/mixed',
+ );
+
+ while ( my ( $type, $filenames ) = each %$files ) {
+ for my $filename ( @$filenames ) {
+ my $mimetype = $type eq 'html'
+ ? 'text/html'
+ : $type eq 'csv'
+ ? 'text/csv'
+ : $type eq 'ods'
+ ? 'application/vnd.oasis.opendocument.spreadsheet'
+ : undef;
+
+ next unless $mimetype;
+
+ my $filepath = File::Spec->catdir( $directory, $filename );
+
+ next unless $filepath or -f $filepath;
+
+ $mail->attach(
+ Type => $mimetype,
+ Path => $filepath,
+ Filename => $filename,
+ Encoding => 'base64',
+ );