From 31378f48eb1742809789dd2e9670f8564850cce1 Mon Sep 17 00:00:00 2001 From: Werner Hahn Date: Mon, 25 Sep 2017 12:12:44 +0200 Subject: [PATCH] WebshopApi: Bilder hochladen --- SL/File.pm | 17 +++++++++++++++++ SL/File/Backend/Webdav.pm | 7 ++++++- js/kivi.File.js | 6 ++++++ templates/webpages/file/upload_dialog.html | 14 +++++++++++++- 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/SL/File.pm b/SL/File.pm index 5efb403bd..677be676b 100644 --- a/SL/File.pm +++ b/SL/File.pm @@ -8,8 +8,10 @@ use Clone qw(clone); use SL::File::Backend; use SL::File::Object; use SL::DB::History; +use SL::DB::ShopImage; use SL::DB::File; use SL::Helper::UserPreferences; +use SL::Controller::Helper::ThumbnailCreator qw(file_probe_type); use SL::JSON; use constant RENAME_OK => 0; @@ -240,6 +242,21 @@ sub _save { $file->mtime(DateTime->now_local); $file->save; + #ShopImage + if($file->object_type eq "shop_image"){ + my $image_content = $params{file_contents}; + my $thumbnail = file_probe_type($image_content); + my $shopimage = SL::DB::ShopImage->new(); + $shopimage->assign_attributes( + file_id => $file->id, + thumbnail_content => $thumbnail->{thumbnail_img_content}, + org_file_height => $thumbnail->{file_image_height}, + org_file_width => $thumbnail->{file_image_width}, + thumbnail_content_type => $thumbnail->{thumbnail_img_content_type}, + object_id => $file->object_id, + ); + $shopimage->save; + } if ($params{file_type} eq 'document' && $params{source} ne 'created') { SL::DB::History->new( addition => 'IMPORT', diff --git a/SL/File/Backend/Webdav.pm b/SL/File/Backend/Webdav.pm index 1a2209f41..871b61f58 100644 --- a/SL/File/Backend/Webdav.pm +++ b/SL/File/Backend/Webdav.pm @@ -128,7 +128,9 @@ my %type_to_path = ( assembly => 'erzeugnisse', letter => 'briefe', general_ledger => 'dialogbuchungen', + gl_transaction => 'dialogbuchungen', accounts_payable => 'kreditorenbuchungen', + shop_image => 'shopbilder', ); my %type_to_model = ( @@ -146,7 +148,9 @@ my %type_to_model = ( assembly => 'Part', letter => 'Letter', general_ledger => 'GLTransaction', + gl_transaction => 'GLTransaction', accounts_payable => 'GLTransaction', + shop_image => 'Part', ); my %model_to_number = ( @@ -156,7 +160,8 @@ my %model_to_number = ( PurchaseInvoice => 'invnumber', Part => 'partnumber', Letter => 'letternumber', - GLTransaction => 'reference' + GLTransaction => 'reference', + ShopImage => 'partnumber', ); sub webdav_path { diff --git a/js/kivi.File.js b/js/kivi.File.js index addacde82..11adf7646 100644 --- a/js/kivi.File.js +++ b/js/kivi.File.js @@ -170,6 +170,12 @@ namespace('kivi.File', function(ns) { return false; } + ns.delete_file = function(id,controller_action) { + $.post('controller.pl', { action: controller_action, id: id }, function(data) { + kivi.eval_json_result(data); + }); + }; + ns.unimport = function(id,type,file_type,checkbox_class) { var checkboxes = $('.'+checkbox_class).filter(function () { return $(this).prop('checked'); }); diff --git a/templates/webpages/file/upload_dialog.html b/templates/webpages/file/upload_dialog.html index eceb6b1d8..2bf48aafc 100644 --- a/templates/webpages/file/upload_dialog.html +++ b/templates/webpages/file/upload_dialog.html @@ -1,11 +1,23 @@ [%- USE L -%][%- USE LxERP -%][%- USE JavaScript -%]
+ [% SET multiple = 'true' %] + [% IF SELF.object_type == 'shop_image' %][% multiple = 'false' %][% END %] + + [% IF SELF.object_type == 'shop_image' %] + + + + + + + + + [% END %]
[%- LxERP.t8("Filename") %]: -
[% LxERP.t8("Title") %][% L.input_tag("title",'') %]
[% LxERP.t8("Description") %][% L.input_tag("description",'') %]

-- 2.20.1