From 6550f5070171fd6497754dec7d15dd2339e18909 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Wed, 11 Nov 2015 13:20:51 +0100 Subject: [PATCH] Auftrags-Controller: Webdav --- SL/Controller/Order.pm | 32 ++++++++++++++++++++++++++++++++ locale/de/all | 1 + 2 files changed, 33 insertions(+) diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 6c71422ac..80dc814c6 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -9,6 +9,7 @@ use SL::Locale::String; use SL::SessionFile::Random; use SL::PriceSource; use SL::Form; +use SL::Webdav; use SL::DB::Order; use SL::DB::Customer; @@ -153,6 +154,24 @@ sub action_create_pdf { my $pdf_filename = $form->generate_attachment_filename(); + # copy file to webdav folder + if ($self->order->ordnumber && $::instance_conf->get_webdav_documents) { + my $webdav = SL::Webdav->new( + type => $self->type, + number => $self->order->ordnumber, + ); + my $webdav_file = SL::Webdav::File->new( + webdav => $webdav, + filename => $pdf_filename, + ); + eval { + $webdav_file->store(data => \$pdf); + 1; + } or do { + $self->js->flash('error', t8('Storing PDF to webdav folder failed: #1', $@)); + } + } + $self->js ->run('download_pdf', $pdf_filename, $key) ->flash('info', t8('The PDF has been created'))->render($self); @@ -651,6 +670,19 @@ sub _pre_render { } + if ($self->order->ordnumber && $::instance_conf->get_webdav) { + my $webdav = SL::Webdav->new( + type => $self->type, + number => $self->order->ordnumber, + ); + my $webdav_path = $webdav->webdav_path; + my @all_objects = $webdav->get_all_objects; + @{ $self->{template_args}->{WEBDAV} } = map { { name => $_->filename, + type => t8('File'), + link => File::Spec->catdir($webdav_path, $_->filename), + } } @all_objects; + } + $::request->{layout}->use_javascript("${_}.js") for qw(ckeditor/ckeditor ckeditor/adapters/jquery); } diff --git a/locale/de/all b/locale/de/all index 580cfff76..b3ac925b6 100755 --- a/locale/de/all +++ b/locale/de/all @@ -2576,6 +2576,7 @@ $self->{texts} = { 'Stocked Qty' => 'Lagermenge', 'Stop task server' => 'Task-Server beenden', 'Stopping the task server failed. Output:' => 'Das Beenden des Task-Servers schlug fehl.', + 'Storing PDF to webdav folder failed: #1' => 'Speichern der PDF im WebDAV Ordner fehlgeschlagen: #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', -- 2.20.1