Revision eeaebcf9
Von Jan Büren vor mehr als 3 Jahren hinzugefügt
SL/Controller/Order.pm | ||
---|---|---|
338 | 338 |
->run('kivi.ActionBar.setEnabled', '#save_and_email_action') |
339 | 339 |
->render; |
340 | 340 |
} |
341 |
sub action_preview_pdf { |
|
342 |
my ($self) = @_; |
|
343 |
|
|
344 |
my $errors = $self->save(); |
|
345 |
if (scalar @{ $errors }) { |
|
346 |
$self->js->flash('error', $_) foreach @{ $errors }; |
|
347 |
return $self->js->render(); |
|
348 |
} |
|
349 |
|
|
350 |
$self->js_reset_order_and_item_ids_after_save; |
|
351 |
|
|
352 |
my $format = 'pdf'; |
|
353 |
my $media = 'screen'; |
|
354 |
my $formname = $self->type; |
|
355 |
|
|
356 |
# only pdf |
|
357 |
# create a form for generate_attachment_filename |
|
358 |
my $form = Form->new; |
|
359 |
$form->{$self->nr_key()} = $self->order->number; |
|
360 |
$form->{type} = $self->type; |
|
361 |
$form->{format} = $format; |
|
362 |
$form->{formname} = $formname; |
|
363 |
$form->{language} = '_' . $self->order->language->template_code if $self->order->language; |
|
364 |
my $pdf_filename = $form->generate_attachment_filename(); |
|
365 |
|
|
366 |
my $pdf; |
|
367 |
my @errors = generate_pdf($self->order, \$pdf, { format => $format, |
|
368 |
formname => $formname, |
|
369 |
language => $self->order->language, |
|
370 |
}); |
|
371 |
if (scalar @errors) { |
|
372 |
return $self->js->flash('error', t8('Conversion to PDF failed: #1', $errors[0]))->render; |
|
373 |
} |
|
374 |
$self->save_history('PREVIEWED'); |
|
375 |
$self->js->flash('info', t8('The PDF has been previewed')); |
|
376 |
# screen/download |
|
377 |
$self->send_file( |
|
378 |
\$pdf, |
|
379 |
type => SL::MIME->mime_type_from_ext($pdf_filename), |
|
380 |
name => $pdf_filename, |
|
381 |
js_no_render => 0, |
|
382 |
); |
|
383 |
} |
|
341 | 384 |
|
342 | 385 |
# open the email dialog |
343 | 386 |
sub action_save_and_show_email_dialog { |
... | ... | |
1847 | 1890 |
action => [ |
1848 | 1891 |
t8('Export'), |
1849 | 1892 |
], |
1893 |
action => [ |
|
1894 |
t8('Save and preview PDF'), |
|
1895 |
call => [ 'kivi.Order.save', 'preview_pdf', $::instance_conf->get_order_warn_duplicate_parts, |
|
1896 |
$::instance_conf->get_order_warn_no_deliverydate, |
|
1897 |
], |
|
1898 |
], |
|
1850 | 1899 |
action => [ |
1851 | 1900 |
t8('Save and print'), |
1852 | 1901 |
call => [ 'kivi.Order.show_print_options', $::instance_conf->get_order_warn_duplicate_parts ], |
Auch abrufbar als: Unified diff
Order-Controller: Neue Action preview_pdf (Druckvorschau für PDFs)