Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 2278a139

Von Moritz Bunkus vor etwa 3 Jahren hinzugefügt

  • ID 2278a139f7c51d02df4d893c764d6364b36e7c61
  • Vorgänger e8dd0687
  • Nachfolger 16ef08a0

Order-Controller: PDF-Handling-Funktionen in Objektmethoden umgewandelt

Erlaubt die einfachere Wiederverwendung, wenn man z.B. mit Mixins für
Kundenanpassungen arbeiten möchte.

Unterschiede anzeigen:

SL/Controller/Order.pm
299 299
  my $pdf_filename          = $form->generate_attachment_filename();
300 300

  
301 301
  my $pdf;
302
  my @errors = generate_pdf($self->order, \$pdf, { format     => $format,
303
                                                   formname   => $formname,
304
                                                   language   => $self->order->language,
305
                                                   printer_id => $printer_id,
306
                                                   groupitems => $groupitems });
302
  my @errors = $self->generate_pdf(\$pdf, { format     => $format,
303
                                            formname   => $formname,
304
                                            language   => $self->order->language,
305
                                            printer_id => $printer_id,
306
                                            groupitems => $groupitems });
307 307
  if (scalar @errors) {
308 308
    return $self->js->flash('error', t8('Conversion to PDF failed: #1', $errors[0]))->render;
309 309
  }
......
329 329
    $self->js->flash('info', t8('The PDF has been printed'));
330 330
  }
331 331

  
332
  my @warnings = store_pdf_to_webdav_and_filemanagement($self->order, $pdf, $pdf_filename);
332
  my @warnings = $self->store_pdf_to_webdav_and_filemanagement($pdf, $pdf_filename);
333 333
  if (scalar @warnings) {
334 334
    $self->js->flash('warning', $_) for @warnings;
335 335
  }
......
366 366
  my $pdf_filename          = $form->generate_attachment_filename();
367 367

  
368 368
  my $pdf;
369
  my @errors = generate_pdf($self->order, \$pdf, { format     => $format,
370
                                                   formname   => $formname,
371
                                                   language   => $self->order->language,
372
                                                 });
369
  my @errors = $self->generate_pdf(\$pdf, { format     => $format,
370
                                            formname   => $formname,
371
                                            language   => $self->order->language,
372
                                          });
373 373
  if (scalar @errors) {
374 374
    return $self->js->flash('error', t8('Conversion to PDF failed: #1', $errors[0]))->render;
375 375
  }
......
470 470

  
471 471
  if (($::form->{attachment_policy} // '') !~ m{^(?:old_file|no_file)$}) {
472 472
    my $pdf;
473
    my @errors = generate_pdf($self->order, \$pdf, {media      => $::form->{media},
474
                                                    format     => $::form->{print_options}->{format},
475
                                                    formname   => $::form->{print_options}->{formname},
476
                                                    language   => $self->order->language,
477
                                                    printer_id => $::form->{print_options}->{printer_id},
478
                                                    groupitems => $::form->{print_options}->{groupitems}});
473
    my @errors = $self->generate_pdf(\$pdf, {media      => $::form->{media},
474
                                            format     => $::form->{print_options}->{format},
475
                                            formname   => $::form->{print_options}->{formname},
476
                                            language   => $self->order->language,
477
                                            printer_id => $::form->{print_options}->{printer_id},
478
                                            groupitems => $::form->{print_options}->{groupitems}});
479 479
    if (scalar @errors) {
480 480
      return $self->js->flash('error', t8('Conversion to PDF failed: #1', $errors[0]))->render($self);
481 481
    }
482 482

  
483
    my @warnings = store_pdf_to_webdav_and_filemanagement($self->order, $pdf, $::form->{attachment_filename});
483
    my @warnings = $self->store_pdf_to_webdav_and_filemanagement($pdf, $::form->{attachment_filename});
484 484
    if (scalar @warnings) {
485 485
      flash_later('warning', $_) for @warnings;
486 486
    }
......
2066 2066
}
2067 2067

  
2068 2068
sub generate_pdf {
2069
  my ($order, $pdf_ref, $params) = @_;
2069
  my ($self, $pdf_ref, $params) = @_;
2070 2070

  
2071
  my $order  = $self->order;
2071 2072
  my @errors = ();
2072 2073

  
2073 2074
  my $print_form = Form->new('');
......
2304 2305
}
2305 2306

  
2306 2307
sub store_pdf_to_webdav_and_filemanagement {
2307
  my($order, $content, $filename) = @_;
2308
  my ($self, $content, $filename) = @_;
2308 2309

  
2310
  my $order = $self->order;
2309 2311
  my @errors;
2310 2312

  
2311 2313
  # copy file to webdav folder

Auch abrufbar als: Unified diff