Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 5c0d66f1

Von Bernd Bleßmann vor fast 4 Jahren hinzugefügt

  • ID 5c0d66f1bac1c81ba16077a27f17508bc8bf2375
  • Vorgänger 2729421a
  • Nachfolger bee7d33f

Auftrags-Controller: auch bei E-Mail erzeugtes Dokument im WebDAV/DMS speichern

Unterschiede anzeigen:

SL/Controller/Order.pm
316 316
    $self->js->flash('info', t8('The PDF has been printed'));
317 317
  }
318 318

  
319
  # copy file to webdav folder
320
  if ($self->order->number && $::instance_conf->get_webdav_documents) {
321
    my $webdav = SL::Webdav->new(
322
      type     => $self->type,
323
      number   => $self->order->number,
324
    );
325
    my $webdav_file = SL::Webdav::File->new(
326
      webdav   => $webdav,
327
      filename => $pdf_filename,
328
    );
329
    eval {
330
      $webdav_file->store(data => \$pdf);
331
      1;
332
    } or do {
333
      $self->js->flash('error', t8('Storing PDF to webdav folder failed: #1', $@));
334
    }
335
  }
336
  if ($self->order->number && $::instance_conf->get_doc_storage) {
337
    eval {
338
      SL::File->save(object_id     => $self->order->id,
339
                     object_type   => $self->type,
340
                     mime_type     => 'application/pdf',
341
                     source        => 'created',
342
                     file_type     => 'document',
343
                     file_name     => $pdf_filename,
344
                     file_contents => $pdf);
345
      1;
346
    } or do {
347
      $self->js->flash('error', t8('Storing PDF in storage backend failed: #1', $@));
348
    }
319
  my @warnings = store_pdf_to_webdav_and_filemanegement($self->order, $pdf, $pdf_filename);
320
  if (scalar @warnings) {
321
    $self->js->flash('warning', $_) for @warnings;
349 322
  }
350 323

  
351 324
  $self->save_history('PRINTED');
......
448 421
      return $self->js->flash('error', t8('Conversion to PDF failed: #1', $errors[0]))->render($self);
449 422
    }
450 423

  
424
    my @warnings = store_pdf_to_webdav_and_filemanegement($self->order, $pdf, $::form->{attachment_filename});
425
    if (scalar @warnings) {
426
      flash_later('warning', $_) for @warnings;
427
    }
428

  
451 429
    my $sfile = SL::SessionFile::Random->new(mode => "w");
452 430
    $sfile->fh->print($pdf);
453 431
    $sfile->fh->close;
......
2140 2118
  )->save;
2141 2119
}
2142 2120

  
2121
sub store_pdf_to_webdav_and_filemanegement {
2122
  my($order, $content, $filename) = @_;
2123

  
2124
  my @errors;
2125

  
2126
  # copy file to webdav folder
2127
  if ($order->number && $::instance_conf->get_webdav_documents) {
2128
    my $webdav = SL::Webdav->new(
2129
      type     => $order->type,
2130
      number   => $order->number,
2131
    );
2132
    my $webdav_file = SL::Webdav::File->new(
2133
      webdav   => $webdav,
2134
      filename => $filename,
2135
    );
2136
    eval {
2137
      $webdav_file->store(data => \$content);
2138
      1;
2139
    } or do {
2140
      push @errors, t8('Storing PDF to webdav folder failed: #1', $@);
2141
    };
2142
  }
2143
  if ($order->id && $::instance_conf->get_doc_storage) {
2144
    eval {
2145
      SL::File->save(object_id     => $order->id,
2146
                     object_type   => $order->type,
2147
                     mime_type     => 'application/pdf',
2148
                     source        => 'created',
2149
                     file_type     => 'document',
2150
                     file_name     => $filename,
2151
                     file_contents => $content);
2152
      1;
2153
    } or do {
2154
      push @errors, t8('Storing PDF in storage backend failed: #1', $@);
2155
    };
2156
  }
2157

  
2158
  return @errors;
2159
}
2160

  
2143 2161
1;
2144 2162

  
2145 2163
__END__

Auch abrufbar als: Unified diff