Revision 30b8dc10
Von Moritz Bunkus vor fast 3 Jahren hinzugefügt
SL/Controller/Order.pm | ||
---|---|---|
280 | 280 |
my $groupitems = $::form->{print_options}->{groupitems}; |
281 | 281 |
my $printer_id = $::form->{print_options}->{printer_id}; |
282 | 282 |
|
283 |
# only pdf and opendocument by now
|
|
284 |
if (none { $format eq $_ } qw(pdf opendocument opendocument_pdf)) { |
|
283 |
# only PDF, OpenDocument & HTML for now
|
|
284 |
if (none { $format eq $_ } qw(pdf opendocument opendocument_pdf html)) {
|
|
285 | 285 |
return $self->js->flash('error', t8('Format \'#1\' is not supported yet/anymore.', $format))->render; |
286 | 286 |
} |
287 | 287 |
|
... | ... | |
297 | 297 |
$form->{format} = $format; |
298 | 298 |
$form->{formname} = $formname; |
299 | 299 |
$form->{language} = '_' . $self->order->language->template_code if $self->order->language; |
300 |
my $pdf_filename = $form->generate_attachment_filename();
|
|
300 |
my $doc_filename = $form->generate_attachment_filename();
|
|
301 | 301 |
|
302 |
my $pdf;
|
|
303 |
my @errors = $self->generate_pdf(\$pdf, { format => $format,
|
|
302 |
my $doc;
|
|
303 |
my @errors = $self->generate_doc(\$doc, { format => $format,
|
|
304 | 304 |
formname => $formname, |
305 | 305 |
language => $self->order->language, |
306 | 306 |
printer_id => $printer_id, |
307 | 307 |
groupitems => $groupitems }); |
308 | 308 |
if (scalar @errors) { |
309 |
return $self->js->flash('error', t8('Conversion to PDF failed: #1', $errors[0]))->render;
|
|
309 |
return $self->js->flash('error', t8('Generating the document failed: #1', $errors[0]))->render;
|
|
310 | 310 |
} |
311 | 311 |
|
312 | 312 |
if ($media eq 'screen') { |
313 | 313 |
# screen/download |
314 |
$self->js->flash('info', t8('The PDF has been created'));
|
|
314 |
$self->js->flash('info', t8('The document has been created.'));
|
|
315 | 315 |
$self->send_file( |
316 |
\$pdf,
|
|
317 |
type => SL::MIME->mime_type_from_ext($pdf_filename),
|
|
318 |
name => $pdf_filename,
|
|
316 |
\$doc,
|
|
317 |
type => SL::MIME->mime_type_from_ext($doc_filename),
|
|
318 |
name => $doc_filename,
|
|
319 | 319 |
js_no_render => 1, |
320 | 320 |
); |
321 | 321 |
|
... | ... | |
324 | 324 |
my $printer_id = $::form->{print_options}->{printer_id}; |
325 | 325 |
SL::DB::Printer->new(id => $printer_id)->load->print_document( |
326 | 326 |
copies => $copies, |
327 |
content => $pdf,
|
|
327 |
content => $doc,
|
|
328 | 328 |
); |
329 | 329 |
|
330 |
$self->js->flash('info', t8('The PDF has been printed'));
|
|
330 |
$self->js->flash('info', t8('The document has been printed.'));
|
|
331 | 331 |
} |
332 | 332 |
|
333 |
my @warnings = $self->store_pdf_to_webdav_and_filemanagement($pdf, $pdf_filename);
|
|
333 |
my @warnings = $self->store_doc_to_webdav_and_filemanagement($doc, $doc_filename);
|
|
334 | 334 |
if (scalar @warnings) { |
335 | 335 |
$self->js->flash('warning', $_) for @warnings; |
336 | 336 |
} |
... | ... | |
367 | 367 |
my $pdf_filename = $form->generate_attachment_filename(); |
368 | 368 |
|
369 | 369 |
my $pdf; |
370 |
my @errors = $self->generate_pdf(\$pdf, { format => $format,
|
|
370 |
my @errors = $self->generate_doc(\$pdf, { format => $format,
|
|
371 | 371 |
formname => $formname, |
372 | 372 |
language => $self->order->language, |
373 | 373 |
}); |
... | ... | |
475 | 475 |
$::form->{media} = 'email'; |
476 | 476 |
|
477 | 477 |
if (($::form->{attachment_policy} // '') !~ m{^(?:old_file|no_file)$}) { |
478 |
my $pdf;
|
|
479 |
my @errors = $self->generate_pdf(\$pdf, {media => $::form->{media},
|
|
478 |
my $doc;
|
|
479 |
my @errors = $self->generate_doc(\$doc, {media => $::form->{media},
|
|
480 | 480 |
format => $::form->{print_options}->{format}, |
481 | 481 |
formname => $::form->{print_options}->{formname}, |
482 | 482 |
language => $self->order->language, |
483 | 483 |
printer_id => $::form->{print_options}->{printer_id}, |
484 | 484 |
groupitems => $::form->{print_options}->{groupitems}}); |
485 | 485 |
if (scalar @errors) { |
486 |
return $self->js->flash('error', t8('Conversion to PDF failed: #1', $errors[0]))->render($self);
|
|
486 |
return $self->js->flash('error', t8('Generating the document failed: #1', $errors[0]))->render($self);
|
|
487 | 487 |
} |
488 | 488 |
|
489 |
my @warnings = $self->store_pdf_to_webdav_and_filemanagement($pdf, $::form->{attachment_filename});
|
|
489 |
my @warnings = $self->store_doc_to_webdav_and_filemanagement($doc, $::form->{attachment_filename});
|
|
490 | 490 |
if (scalar @warnings) { |
491 | 491 |
flash_later('warning', $_) for @warnings; |
492 | 492 |
} |
493 | 493 |
|
494 | 494 |
my $sfile = SL::SessionFile::Random->new(mode => "w"); |
495 |
$sfile->fh->print($pdf);
|
|
495 |
$sfile->fh->print($doc);
|
|
496 | 496 |
$sfile->fh->close; |
497 | 497 |
|
498 | 498 |
$::form->{tmpfile} = $sfile->file_name; |
... | ... | |
500 | 500 |
} |
501 | 501 |
|
502 | 502 |
$::form->{id} = $self->order->id; # this is used in SL::Mailer to create a linked record to the mail |
503 |
$::form->send_email(\%::myconfig, 'pdf');
|
|
503 |
$::form->send_email(\%::myconfig, $::form->{print_options}->{format});
|
|
504 | 504 |
|
505 | 505 |
# internal notes |
506 | 506 |
my $intnotes = $self->order->intnotes; |
... | ... | |
1885 | 1885 |
no_queue => 1, |
1886 | 1886 |
no_postscript => 1, |
1887 | 1887 |
no_opendocument => 0, |
1888 |
no_html => 1},
|
|
1888 |
no_html => 0},
|
|
1889 | 1889 |
); |
1890 | 1890 |
|
1891 | 1891 |
foreach my $item (@{$self->order->orderitems}) { |
... | ... | |
2071 | 2071 |
} |
2072 | 2072 |
} |
2073 | 2073 |
|
2074 |
sub generate_pdf {
|
|
2075 |
my ($self, $pdf_ref, $params) = @_;
|
|
2074 |
sub generate_doc {
|
|
2075 |
my ($self, $doc_ref, $params) = @_;
|
|
2076 | 2076 |
|
2077 | 2077 |
my $order = $self->order; |
2078 | 2078 |
my @errors = (); |
... | ... | |
2094 | 2094 |
if ($print_form->{format} =~ /(opendocument|oasis)/i) { |
2095 | 2095 |
$template_ext = 'odt'; |
2096 | 2096 |
$template_type = 'OpenDocument'; |
2097 |
} elsif ($print_form->{format} =~ m{html}i) { |
|
2098 |
$template_ext = 'html'; |
|
2099 |
$template_type = 'HTML'; |
|
2097 | 2100 |
} |
2098 | 2101 |
|
2099 | 2102 |
# search for the template |
... | ... | |
2115 | 2118 |
eval { |
2116 | 2119 |
$print_form->prepare_for_printing; |
2117 | 2120 |
|
2118 |
$$pdf_ref = SL::Helper::CreatePDF->create_pdf(
|
|
2121 |
$$doc_ref = SL::Helper::CreatePDF->create_pdf(
|
|
2119 | 2122 |
format => $print_form->{format}, |
2120 | 2123 |
template_type => $template_type, |
2121 | 2124 |
template => $template_file, |
... | ... | |
2310 | 2313 |
)->save; |
2311 | 2314 |
} |
2312 | 2315 |
|
2313 |
sub store_pdf_to_webdav_and_filemanagement {
|
|
2316 |
sub store_doc_to_webdav_and_filemanagement {
|
|
2314 | 2317 |
my ($self, $content, $filename) = @_; |
2315 | 2318 |
|
2316 | 2319 |
my $order = $self->order; |
... | ... | |
2330 | 2333 |
$webdav_file->store(data => \$content); |
2331 | 2334 |
1; |
2332 | 2335 |
} or do { |
2333 |
push @errors, t8('Storing PDF to webdav folder failed: #1', $@);
|
|
2336 |
push @errors, t8('Storing the document to the WebDAV folder failed: #1', $@);
|
|
2334 | 2337 |
}; |
2335 | 2338 |
} |
2336 | 2339 |
if ($order->id && $::instance_conf->get_doc_storage) { |
2337 | 2340 |
eval { |
2338 | 2341 |
SL::File->save(object_id => $order->id, |
2339 | 2342 |
object_type => $order->type, |
2340 |
mime_type => 'application/pdf',
|
|
2343 |
mime_type => SL::MIME->mime_type_from_ext($filename),
|
|
2341 | 2344 |
source => 'created', |
2342 | 2345 |
file_type => 'document', |
2343 | 2346 |
file_name => $filename, |
2344 | 2347 |
file_contents => $content); |
2345 | 2348 |
1; |
2346 | 2349 |
} or do { |
2347 |
push @errors, t8('Storing PDF in storage backend failed: #1', $@);
|
|
2350 |
push @errors, t8('Storing the document in the storage backend failed: #1', $@);
|
|
2348 | 2351 |
}; |
2349 | 2352 |
} |
2350 | 2353 |
|
js/kivi.Order.js | ||
---|---|---|
96 | 96 |
|
97 | 97 |
$('#print_options_form table').first().remove().appendTo('#email_form_print_options'); |
98 | 98 |
|
99 |
$('select#format').change(kivi.Order.adjust_email_attachment_name_for_template_format); |
|
100 |
kivi.Order.adjust_email_attachment_name_for_template_format(); |
|
101 |
|
|
99 | 102 |
var to_focus = $('#email_form_to').val() === '' ? 'to' : 'subject'; |
100 | 103 |
$('#email_form_' + to_focus).focus(); |
101 | 104 |
}; |
... | ... | |
155 | 158 |
email_dialog.dialog("close"); |
156 | 159 |
}; |
157 | 160 |
|
161 |
ns.adjust_email_attachment_name_for_template_format = function() { |
|
162 |
var $filename_elt = $('#email_form_attachment_filename'); |
|
163 |
var $format_elt = $('select#format'); |
|
164 |
|
|
165 |
if (!$filename_elt || !$format_elt) |
|
166 |
return; |
|
167 |
|
|
168 |
var format = $format_elt.val().toLowerCase(); |
|
169 |
var new_ext = format == 'html' ? 'html' : format == 'opendocument' ? 'odt' : 'pdf'; |
|
170 |
var filename = $filename_elt.val(); |
|
171 |
|
|
172 |
$filename_elt.val(filename.replace(/[^.]+$/, new_ext)); |
|
173 |
}; |
|
174 |
|
|
158 | 175 |
ns.set_number_in_title = function(elt) { |
159 | 176 |
$('#nr_in_title').html($(elt).val()); |
160 | 177 |
}; |
locale/de/all | ||
---|---|---|
1622 | 1622 |
'General ledger transactions can only be changed on the day they are posted.' => 'Dialogbuchungen können nur am Buchungstag geändert werden.', |
1623 | 1623 |
'General settings' => 'Allgemeine Einstellungen', |
1624 | 1624 |
'Generate and print sales delivery orders' => 'Erzeuge und drucke Lieferscheine', |
1625 |
'Generating the document failed: #1' => 'Das Dokument konnte nicht erzeugt werden: #1', |
|
1625 | 1626 |
'Germany' => 'Deutschland', |
1626 | 1627 |
'Get one order' => 'Hole eine Bestellung', |
1627 | 1628 |
'Get one order by shopordernumber' => 'Hole eine Bestellung über Shopbestellnummer', |
... | ... | |
3261 | 3262 |
'Storage Type for shopimages' => 'Speichertyp für Shopbilder', |
3262 | 3263 |
'Storing PDF in storage backend failed: #1' => 'Speichern der PDF-Datei im Datei-Speicher fehlgeschlagen: #1', |
3263 | 3264 |
'Storing PDF to webdav folder failed: #1' => 'Speichern der PDF im WebDAV Ordner fehlgeschlagen: #1', |
3265 |
'Storing the document in the storage backend failed: #1' => 'Das Ablegen des Dokuments im Dokumentenspeicher schlug fehl: #1', |
|
3266 |
'Storing the document to the WebDAV folder failed: #1' => 'Das Ablegen des Dokuments im WebDAV-Ordner schlug fehl: #1', |
|
3264 | 3267 |
'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.', |
3265 | 3268 |
'Storno' => 'Storno', |
3266 | 3269 |
'Storno (one letter abbreviation)' => 'S', |
... | ... | |
3510 | 3513 |
'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%>.', |
3511 | 3514 |
'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', |
3512 | 3515 |
'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', |
3516 |
'The document has been created.' => 'Das Dokument wurde erzeugt.', |
|
3517 |
'The document has been printed.' => 'Das Dokument wurde gedruckt.', |
|
3513 | 3518 |
'The documents have been sent to the printer \'#1\'.' => 'Die Dokumente sind zum Drucker \'#1\' geschickt', |
3514 | 3519 |
'The dunnings have been printed.' => 'Die Mahnung(en) wurden gedruckt.', |
3515 | 3520 |
'The email has been sent.' => 'Die E-Mail wurde verschickt.', |
Auch abrufbar als: Unified diff
Order-Controller: Unterstützung für Drucken & E-Mailen von HTML-Vorlagen