my $groupitems = $::form->{print_options}->{groupitems};
my $printer_id = $::form->{print_options}->{printer_id};
- # only pdf and opendocument by now
- if (none { $format eq $_ } qw(pdf opendocument opendocument_pdf)) {
+ # only PDF, OpenDocument & HTML for now
+ if (none { $format eq $_ } qw(pdf opendocument opendocument_pdf html)) {
return $self->js->flash('error', t8('Format \'#1\' is not supported yet/anymore.', $format))->render;
}
$form->{format} = $format;
$form->{formname} = $formname;
$form->{language} = '_' . $self->order->language->template_code if $self->order->language;
- my $pdf_filename = $form->generate_attachment_filename();
+ my $doc_filename = $form->generate_attachment_filename();
- my $pdf;
- my @errors = $self->generate_pdf(\$pdf, { format => $format,
+ my $doc;
+ my @errors = $self->generate_doc(\$doc, { format => $format,
formname => $formname,
language => $self->order->language,
printer_id => $printer_id,
groupitems => $groupitems });
if (scalar @errors) {
- return $self->js->flash('error', t8('Conversion to PDF failed: #1', $errors[0]))->render;
+ return $self->js->flash('error', t8('Generating the document failed: #1', $errors[0]))->render;
}
if ($media eq 'screen') {
# screen/download
- $self->js->flash('info', t8('The PDF has been created'));
+ $self->js->flash('info', t8('The document has been created.'));
$self->send_file(
- \$pdf,
- type => SL::MIME->mime_type_from_ext($pdf_filename),
- name => $pdf_filename,
+ \$doc,
+ type => SL::MIME->mime_type_from_ext($doc_filename),
+ name => $doc_filename,
js_no_render => 1,
);
my $printer_id = $::form->{print_options}->{printer_id};
SL::DB::Printer->new(id => $printer_id)->load->print_document(
copies => $copies,
- content => $pdf,
+ content => $doc,
);
- $self->js->flash('info', t8('The PDF has been printed'));
+ $self->js->flash('info', t8('The document has been printed.'));
}
- my @warnings = $self->store_pdf_to_webdav_and_filemanagement($pdf, $pdf_filename);
+ my @warnings = $self->store_doc_to_webdav_and_filemanagement($doc, $doc_filename);
if (scalar @warnings) {
$self->js->flash('warning', $_) for @warnings;
}
my $pdf_filename = $form->generate_attachment_filename();
my $pdf;
- my @errors = $self->generate_pdf(\$pdf, { format => $format,
+ my @errors = $self->generate_doc(\$pdf, { format => $format,
formname => $formname,
language => $self->order->language,
});
$::form->{media} = 'email';
if (($::form->{attachment_policy} // '') !~ m{^(?:old_file|no_file)$}) {
- my $pdf;
- my @errors = $self->generate_pdf(\$pdf, {media => $::form->{media},
+ my $doc;
+ my @errors = $self->generate_doc(\$doc, {media => $::form->{media},
format => $::form->{print_options}->{format},
formname => $::form->{print_options}->{formname},
language => $self->order->language,
printer_id => $::form->{print_options}->{printer_id},
groupitems => $::form->{print_options}->{groupitems}});
if (scalar @errors) {
- return $self->js->flash('error', t8('Conversion to PDF failed: #1', $errors[0]))->render($self);
+ return $self->js->flash('error', t8('Generating the document failed: #1', $errors[0]))->render($self);
}
- my @warnings = $self->store_pdf_to_webdav_and_filemanagement($pdf, $::form->{attachment_filename});
+ my @warnings = $self->store_doc_to_webdav_and_filemanagement($doc, $::form->{attachment_filename});
if (scalar @warnings) {
flash_later('warning', $_) for @warnings;
}
my $sfile = SL::SessionFile::Random->new(mode => "w");
- $sfile->fh->print($pdf);
+ $sfile->fh->print($doc);
$sfile->fh->close;
$::form->{tmpfile} = $sfile->file_name;
}
$::form->{id} = $self->order->id; # this is used in SL::Mailer to create a linked record to the mail
- $::form->send_email(\%::myconfig, 'pdf');
+ $::form->send_email(\%::myconfig, $::form->{print_options}->{format});
# internal notes
my $intnotes = $self->order->intnotes;
no_queue => 1,
no_postscript => 1,
no_opendocument => 0,
- no_html => 1},
+ no_html => 0},
);
foreach my $item (@{$self->order->orderitems}) {
}
}
-sub generate_pdf {
- my ($self, $pdf_ref, $params) = @_;
+sub generate_doc {
+ my ($self, $doc_ref, $params) = @_;
my $order = $self->order;
my @errors = ();
if ($print_form->{format} =~ /(opendocument|oasis)/i) {
$template_ext = 'odt';
$template_type = 'OpenDocument';
+ } elsif ($print_form->{format} =~ m{html}i) {
+ $template_ext = 'html';
+ $template_type = 'HTML';
}
# search for the template
eval {
$print_form->prepare_for_printing;
- $$pdf_ref = SL::Helper::CreatePDF->create_pdf(
+ $$doc_ref = SL::Helper::CreatePDF->create_pdf(
format => $print_form->{format},
template_type => $template_type,
template => $template_file,
)->save;
}
-sub store_pdf_to_webdav_and_filemanagement {
+sub store_doc_to_webdav_and_filemanagement {
my ($self, $content, $filename) = @_;
my $order = $self->order;
$webdav_file->store(data => \$content);
1;
} or do {
- push @errors, t8('Storing PDF to webdav folder failed: #1', $@);
+ push @errors, t8('Storing the document to the WebDAV folder failed: #1', $@);
};
}
if ($order->id && $::instance_conf->get_doc_storage) {
eval {
SL::File->save(object_id => $order->id,
object_type => $order->type,
- mime_type => 'application/pdf',
+ mime_type => SL::MIME->mime_type_from_ext($filename),
source => 'created',
file_type => 'document',
file_name => $filename,
file_contents => $content);
1;
} or do {
- push @errors, t8('Storing PDF in storage backend failed: #1', $@);
+ push @errors, t8('Storing the document in the storage backend failed: #1', $@);
};
}
'General ledger transactions can only be changed on the day they are posted.' => 'Dialogbuchungen können nur am Buchungstag geändert werden.',
'General settings' => 'Allgemeine Einstellungen',
'Generate and print sales delivery orders' => 'Erzeuge und drucke Lieferscheine',
+ 'Generating the document failed: #1' => 'Das Dokument konnte nicht erzeugt werden: #1',
'Germany' => 'Deutschland',
'Get one order' => 'Hole eine Bestellung',
'Get one order by shopordernumber' => 'Hole eine Bestellung über Shopbestellnummer',
'Storage Type for shopimages' => 'Speichertyp für Shopbilder',
'Storing PDF in storage backend failed: #1' => 'Speichern der PDF-Datei im Datei-Speicher fehlgeschlagen: #1',
'Storing PDF to webdav folder failed: #1' => 'Speichern der PDF im WebDAV Ordner fehlgeschlagen: #1',
+ 'Storing the document in the storage backend failed: #1' => 'Das Ablegen des Dokuments im Dokumentenspeicher schlug fehl: #1',
+ 'Storing the document to the WebDAV folder failed: #1' => 'Das Ablegen des Dokuments im WebDAV-Ordner schlug fehl: #1',
'Storing the emails in the journal is currently disabled in the client configuration.' => 'Das Speichern von versendeten E-Mails ist derzeit in der Mandantenkonfigurierung abgeschaltet.',
'Storno' => 'Storno',
'Storno (one letter abbreviation)' => 'S',
'The display of (mainly) picker results can be configured. To insert the value of one option use <%Name%>.' => 'Die Anzeigenamen von (hauptsächlich) Auswahl-Ergebnissen (Picker) können konfiguriert werden. Um einen Wert einer Option in die Anzeige aufzunehmen, verwenden Sie <%Name%>.',
'The document has been changed by another user. No mail was sent. Please reopen it in another window and copy the changes to the new window' => 'Die Daten wurden bereits von einem anderen Benutzer verändert. Deshalb ist das Dokument ungültig und es wurde keine E-Mail verschickt. Bitte öffnen Sie das Dokument erneut in einem extra Fenster und übertragen Sie die Daten',
'The document has been changed by another user. Please reopen it in another window and copy the changes to the new window' => 'Die Daten wurden bereits von einem anderen Benutzer verändert. Deshalb ist das Dokument ungültig. Bitte öffnen Sie das Dokument erneut in einem extra Fenster und übertragen Sie die Daten',
+ 'The document has been created.' => 'Das Dokument wurde erzeugt.',
+ 'The document has been printed.' => 'Das Dokument wurde gedruckt.',
'The documents have been sent to the printer \'#1\'.' => 'Die Dokumente sind zum Drucker \'#1\' geschickt',
'The dunnings have been printed.' => 'Die Mahnung(en) wurden gedruckt.',
'The email has been sent.' => 'Die E-Mail wurde verschickt.',