Revision 0bf4e031
Von Werner Hahn vor mehr als 7 Jahren hinzugefügt
SL/Controller/File.pm | ||
---|---|---|
44 | 44 |
__PACKAGE__->run_before('check_object_params', only => [ qw(list ajax_delete ajax_importdialog ajax_import ajax_unimport ajax_upload ajax_files_uploaded) ]); |
45 | 45 |
|
46 | 46 |
my %file_types = ( |
47 |
'sales_quotation' => { gen => 1, gltype => '', dir => 'SalesQuotation', model => 'Order', right => 'import_ar' }, |
|
48 |
'sales_order' => { gen => 1, gltype => '', dir => 'SalesOrder', model => 'Order', right => 'import_ar' }, |
|
49 |
'sales_delivery_order' => { gen => 1, gltype => '', dir => 'SalesDeliveryOrder', model => 'DeliveryOrder', right => 'import_ar' }, |
|
50 |
'invoice' => { gen => 1, gltype => 'ar', dir => 'SalesInvoice', model => 'Invoice', right => 'import_ar' }, |
|
51 |
'credit_note' => { gen => 1, gltype => '', dir => 'CreditNote', model => 'Invoice', right => 'import_ar' }, |
|
52 |
'request_quotation' => { gen => 3, gltype => '', dir => 'RequestForQuotation', model => 'Order', right => 'import_ap' }, |
|
53 |
'purchase_order' => { gen => 3, gltype => '', dir => 'PurchaseOrder', model => 'Order', right => 'import_ap' }, |
|
54 |
'purchase_delivery_order' => { gen => 3, gltype => '', dir => 'PurchaseDeliveryOrder', model => 'DeliveryOrder', right => 'import_ap' }, |
|
55 |
'purchase_invoice' => { gen => 2, gltype => 'ap', dir => 'PurchaseInvoice', model => 'PurchaseInvoice', right => 'import_ap' }, |
|
56 |
'vendor' => { gen => 0, gltype => '', dir => 'Vendor', model => 'Vendor', right => 'xx' }, |
|
57 |
'customer' => { gen => 1, gltype => '', dir => 'Customer', model => 'Customer', right => 'xx' }, |
|
58 |
'part' => { gen => 0, gltype => '', dir => 'Part', model => 'Part', right => 'xx' }, |
|
59 |
'gl_transaction' => { gen => 2, gltype => 'gl', dir => 'GeneralLedger', model => 'GLTransaction', right => 'import_ap' }, |
|
60 |
'draft' => { gen => 0, gltype => '', dir => 'Draft', model => 'Draft', right => 'xx' }, |
|
61 |
'csv_customer' => { gen => 1, gltype => '', dir => 'Reports', model => 'Customer', right => 'xx' }, |
|
62 |
'csv_vendor' => { gen => 1, gltype => '', dir => 'Reports', model => 'Vendor', right => 'xx' }, |
|
47 |
'sales_quotation' => { gen => 1, gltype => '', dir =>'SalesQuotation', model => 'Order', right => 'import_ar' }, |
|
48 |
'sales_order' => { gen => 1, gltype => '', dir =>'SalesOrder', model => 'Order', right => 'import_ar' }, |
|
49 |
'sales_delivery_order' => { gen => 1, gltype => '', dir =>'SalesDeliveryOrder', model => 'DeliveryOrder', right => 'import_ar' }, |
|
50 |
'invoice' => { gen => 1, gltype => 'ar', dir =>'SalesInvoice', model => 'Invoice', right => 'import_ar' }, |
|
51 |
'credit_note' => { gen => 1, gltype => '', dir =>'CreditNote', model => 'Invoice', right => 'import_ar' }, |
|
52 |
'request_quotation' => { gen => 3, gltype => '', dir =>'RequestForQuotation', model => 'Order', right => 'import_ap' }, |
|
53 |
'purchase_order' => { gen => 3, gltype => '', dir =>'PurchaseOrder', model => 'Order', right => 'import_ap' }, |
|
54 |
'purchase_delivery_order' => { gen => 3, gltype => '', dir =>'PurchaseDeliveryOrder',model => 'DeliveryOrder', right => 'import_ap' }, |
|
55 |
'purchase_invoice' => { gen => 2, gltype => 'ap', dir =>'PurchaseInvoice', model => 'PurchaseInvoice',right => 'import_ap' }, |
|
56 |
'vendor' => { gen => 0, gltype => '', dir =>'Vendor', model => 'Vendor', right => 'xx' }, |
|
57 |
'customer' => { gen => 1, gltype => '', dir =>'Customer', model => 'Customer', right => 'xx' }, |
|
58 |
'part' => { gen => 0, gltype => '', dir =>'Part', model => 'Part', right => 'xx' }, |
|
59 |
'gl_transaction' => { gen => 2, gltype => 'gl', dir =>'GeneralLedger', model => 'GLTransaction', right => 'import_ap' }, |
|
60 |
'draft' => { gen => 0, gltype => '', dir =>'Draft', model => 'Draft', right => 'xx' }, |
|
61 |
'csv_customer' => { gen => 1, gltype => '', dir =>'Reports', model => 'Customer', right => 'xx' }, |
|
62 |
'csv_vendor' => { gen => 1, gltype => '', dir =>'Reports', model => 'Vendor', right => 'xx' }, |
|
63 |
'shop_image' => { gen => 0, gltype => '', dir =>'ShopImages', model => 'Part', right => 'xx' }, |
|
63 | 64 |
); |
64 | 65 |
|
65 | 66 |
#--- 4 locale ---# |
... | ... | |
252 | 253 |
source => $source, |
253 | 254 |
file_type => $self->file_type, |
254 | 255 |
file_name => $basefile, |
255 |
); |
|
256 |
|
|
257 |
if ($existobj) { |
|
258 |
push @existing, $existobj->id.'_'.$sfile->file_name; |
|
259 |
} else { |
|
260 |
my $fileobj = SL::File->save(object_id => $self->object_id, |
|
261 |
object_type => $self->object_type, |
|
262 |
mime_type => $mime_type, |
|
263 |
source => $source, |
|
264 |
file_type => $self->file_type, |
|
265 |
file_name => $basefile, |
|
266 |
## two possibilities: which is better ? content or sessionfile ?? |
|
267 |
#file_contents => ${$upfiles[$idx]->{data}}, |
|
268 |
file_path => $sfile->file_name |
|
256 |
); |
|
257 |
|
|
258 |
if ($existobj) { |
|
259 |
push @existing, $existobj->id.'_'.$sfile->file_name; |
|
260 |
} else { |
|
261 |
my $fileobj = SL::File->save(object_id => $self->object_id, |
|
262 |
object_type => $self->object_type, |
|
263 |
mime_type => $mime_type, |
|
264 |
source => $source, |
|
265 |
file_type => $self->file_type, |
|
266 |
file_name => $basefile, |
|
267 |
title => $::form->{title}, |
|
268 |
description => $::form->{description}, |
|
269 |
## two possibilities: what is better ? content or sessionfile ?? |
|
270 |
file_contents => ${$upfiles[$idx]->{data}}, |
|
271 |
file_path => $sfile->file_name |
|
272 |
); |
|
273 |
unlink($sfile->file_name); |
|
274 |
} |
|
275 |
1; |
|
276 |
} or do { |
|
277 |
$self->js->flash( 'error', t8('internal error (see details)')) |
|
278 |
->flash_detail('error', $@)->render; |
|
279 |
return; |
|
280 |
} |
|
281 |
} |
|
282 |
} |
|
283 |
$self->existing(\@existing); |
|
284 |
$self->_do_list(1); |
|
285 |
} |
|
286 |
|
|
287 |
sub action_download { |
|
288 |
my ($self) = @_; |
|
289 |
my ($id,$version) = split /_/, $::form->{id}; |
|
290 |
my $file = SL::File->get(id => $id ); |
|
291 |
$file->version($version) if $version; |
|
292 |
my $ref = $file->get_content; |
|
269 | 293 |
); |
270 | 294 |
unlink($sfile->file_name); |
271 | 295 |
} |
SL/Controller/Helper/ThumbnailCreator.pm | ||
---|---|---|
24 | 24 |
); |
25 | 25 |
|
26 | 26 |
sub file_create_thumbnail { |
27 |
my ($self) = @_;
|
|
28 |
croak "No picture set yet" if !$self->file_content;
|
|
29 |
|
|
30 |
my $image = GD::Image->new($self->file_content);
|
|
27 |
my ($thumb) = @_;
|
|
28 |
croak "No picture set yet" if !$thumb->{content};
|
|
29 |
$main::lxdebug->dump(0, 'WH: CTHUMB ', $thumb); |
|
30 |
my $image = GD::Image->new($thumb->{content});
|
|
31 | 31 |
my ($width, $height) = $image->getBounds; |
32 | 32 |
my $max_dim = 64; |
33 | 33 |
my $curr_max = max $width, $height, 1; |
... | ... | |
38 | 38 |
|
39 | 39 |
$thumbnail->copyResized($image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); |
40 | 40 |
|
41 |
$self->thumbnail_img_content($thumbnail->png); |
|
42 |
$self->thumbnail_img_content_type('image/png'); |
|
43 |
$self->thumbnail_img_width($new_width); |
|
44 |
$self->thumbnail_img_height($new_height); |
|
45 |
return 1; |
|
41 |
$thumb->{thumbnail_img_content} = $thumbnail->png; |
|
42 |
$thumb->{thumbnail_img_content_type} = "image/png"; |
|
43 |
$thumb->{thumbnail_img_width} = $new_width; |
|
44 |
$thumb->{thumbnail_img_height} = $new_height; |
|
45 |
#$self->thumbnail_img_content($thumbnail->png); |
|
46 |
#$self->thumbnail_img_content_type('image/png'); |
|
47 |
#$self->thumbnail_img_width($new_width); |
|
48 |
#$self->thumbnail_img_height($new_height); |
|
49 |
return $thumb; |
|
46 | 50 |
|
47 | 51 |
} |
48 | 52 |
|
... | ... | |
66 | 70 |
} |
67 | 71 |
|
68 | 72 |
sub file_probe_type { |
69 |
my ($self) = @_; |
|
70 |
|
|
71 |
return (t8("No file uploaded yet")) if !$self->file_content; |
|
72 |
my $mime_type = File::MimeInfo::Magic::magic($self->file_content); |
|
73 |
|
|
74 |
my $info = Image::Info::image_info(\$self->{file_content}); |
|
73 |
my ($content) = @_; |
|
74 |
#$main::lxdebug->dump(0, 'WH: FPT Content', $content); |
|
75 |
return (t8("No file uploaded yet")) if !$content; |
|
76 |
#my $mime_type = File::MimeInfo::Magic::magic($content); |
|
77 |
#$main::lxdebug->dump(0, 'WH: MIME ', $mime_type); |
|
78 |
my $info = Image::Info::image_info(\$content); |
|
79 |
#$main::lxdebug->dump(0, 'WH: INFO', $info); |
|
75 | 80 |
if (!$info || $info->{error} || !$info->{file_media_type} || !$supported_mime_types{ $info->{file_media_type} }) { |
76 | 81 |
$::lxdebug->warn("Image::Info error: " . $info->{error}) if $info && $info->{error}; |
77 | 82 |
return (t8('Unsupported image type (supported types: #1)', join(' ', sort keys %supported_mime_types))); |
78 | 83 |
} |
79 | 84 |
|
80 |
$self->file_content_type($info->{file_media_type}); |
|
81 |
$self->files_img_width($info->{width}); |
|
82 |
$self->files_img_height($info->{height}); |
|
83 |
$self->files_mtime(DateTime->now_local); |
|
85 |
my $thumbnail; |
|
86 |
$thumbnail->{file_content_type} = $info->{file_media_type}; |
|
87 |
$thumbnail->{file_image_width} = $info->{width}; |
|
88 |
$thumbnail->{file_image_height} = $info->{height}; |
|
89 |
$thumbnail->{content} = $content; |
|
90 |
#$self->file_content_type($info->{file_media_type}); |
|
91 |
#$self->files_img_width($info->{width}); |
|
92 |
#$self->files_img_height($info->{height}); |
|
93 |
#$self->files_mtime(DateTime->now_local); |
|
84 | 94 |
|
85 |
$self->file_create_thumbnail;
|
|
95 |
$thumbnail = &file_create_thumbnail($thumbnail);
|
|
86 | 96 |
|
87 |
return ();
|
|
97 |
return $thumbnail;
|
|
88 | 98 |
} |
89 | 99 |
|
90 | 100 |
sub file_update_type_and_dimensions { |
SL/Controller/ShopPart.pm | ||
---|---|---|
10 | 10 |
use SL::Locale::String qw(t8); |
11 | 11 |
use SL::DB::ShopPart; |
12 | 12 |
use SL::DB::File; |
13 |
use SL::DB::ShopImage; |
|
13 | 14 |
use SL::Controller::FileUploader; |
14 | 15 |
use SL::DB::Default; |
15 | 16 |
use SL::Helper::Flash; |
... | ... | |
65 | 66 |
|
66 | 67 |
sub action_show_files { |
67 | 68 |
my ($self) = @_; |
69 |
$main::lxdebug->message(0, "WH:ShowFiles "); |
|
70 |
$main::lxdebug->dump(0, 'WH:FORM ',$::form); |
|
71 |
$main::lxdebug->dump(0, 'WH:FORM ',$::form->{part}); |
|
68 | 72 |
|
69 |
my $images = SL::DB::Manager::File->get_all_sorted( where => [ trans_id => $::form->{id}, modul => $::form->{modul}, file_content_type => { like => 'image/%' } ], sort_by => 'position' ); |
|
73 |
#my $images = SL::DB::Manager::File->get_all_sorted( where => [ trans_id => $::form->{id}, modul => $::form->{modul}, file_content_type => { like => 'image/%' } ], sort_by => 'position' ); |
|
74 |
#my $images = SL::DB::Manager::ShopImage->get_all_sorted( where => [ partnumber => $::form->{part}{partnumber}, ], with_object => 'file', sort_by => 'position' ); |
|
75 |
my $images = SL::DB::Manager::ShopImage->get_all( where => [ 'files.object_id' => $::form->{id}, ], with_objects => 'file', sort_by => 'position' ); |
|
76 |
$main::lxdebug->dump(0, 'WH:ShowFiles1 ',$images); |
|
70 | 77 |
|
71 | 78 |
$self->render('shop_part/_list_images', { header => 0 }, IMAGES => $images); |
72 | 79 |
} |
... | ... | |
143 | 150 |
|
144 | 151 |
my $categories = $shop->connector->get_categories; |
145 | 152 |
|
146 |
$main::lxdebug->dump(0, 'WH:KAT ',$categories); |
|
147 | 153 |
$self->js |
148 | 154 |
->run( |
149 | 155 |
'kivi.shop_part.shop_part_dialog', |
... | ... | |
303 | 309 |
sub action_list_articles { |
304 | 310 |
my ($self) = @_; |
305 | 311 |
|
306 |
my %filter = ($::form->{filter} ? parse_filter($::form->{filter}) : query => [ transferred => 0 ]); |
|
312 |
my %filter = ($::form->{filter} ? parse_filter($::form->{filter}) : query => [ transferred => 0 ]);
|
|
307 | 313 |
my $transferred = $::form->{filter}->{transferred_eq_ignore_empty} ne '' ? $::form->{filter}->{transferred_eq_ignore_empty} : ''; |
308 |
my $sort_by = $::form->{sort_by} ? $::form->{sort_by} : 'part.partnumber'; |
|
314 |
my $sort_by = $::form->{sort_by} ? $::form->{sort_by} : 'part.partnumber';
|
|
309 | 315 |
$sort_by .=$::form->{sort_dir} ? ' DESC' : ' ASC'; |
310 | 316 |
|
311 | 317 |
my $articles = SL::DB::Manager::ShopPart->get_all(where => [ 'shop.obsolete' => 0 ],with_objects => [ 'part','shop' ], sort_by => $sort_by ); |
... | ... | |
390 | 396 |
#TODO Price must be formatted. Translations for $price_grp_str |
391 | 397 |
my $price; |
392 | 398 |
if ($price_src_str eq "master_data") { |
393 |
my $part = SL::DB::Manager::Part->get_all( where => [id => $self->shop_part->part_id], with_objects => ['prices'],limit => 1)->[0]; |
|
394 |
$price = $part->$price_src_id; |
|
399 |
my $part = SL::DB::Manager::Part->get_all( where => [id => $self->shop_part->part_id], with_objects => ['prices'],limit => 1)->[0];
|
|
400 |
$price = $part->$price_src_id;
|
|
395 | 401 |
$price_src_str = $price_src_id; |
396 |
}else{ |
|
397 |
my $part = SL::DB::Manager::Part->get_all( where => [id => $self->shop_part->part_id, 'prices.'.pricegroup_id => $price_src_id], with_objects => ['prices'],limit => 1)->[0]; |
|
398 |
my $pricegrp = SL::DB::Manager::Pricegroup->find_by( id => $price_src_id )->pricegroup; |
|
399 |
$price = $part->prices->[0]->price;
|
|
402 |
}else{
|
|
403 |
my $part = SL::DB::Manager::Part->get_all( where => [id => $self->shop_part->part_id, 'prices.'.pricegroup_id => $price_src_id], with_objects => ['prices'],limit => 1)->[0];
|
|
404 |
my $pricegrp = SL::DB::Manager::Pricegroup->find_by( id => $price_src_id )->pricegroup;
|
|
405 |
$price = $part->prices->[0]->price;
|
|
400 | 406 |
$price_src_str = $pricegrp; |
401 | 407 |
} |
402 | 408 |
return($price,$price_src_str); |
SL/DB/Helper/Mappings.pm | ||
---|---|---|
196 | 196 |
schema_info => 'schema_info', |
197 | 197 |
shipto => 'shipto', |
198 | 198 |
shops => 'shop', |
199 |
shop_images => 'shop_image', |
|
199 | 200 |
shop_orders => 'shop_order', |
200 | 201 |
shop_order_items => 'shop_order_item', |
201 | 202 |
shop_parts => 'shop_part', |
SL/DB/Manager/ShopImage.pm | ||
---|---|---|
1 |
# This file has been auto-generated only because it didn't exist. |
|
2 |
# Feel free to modify it at will; it will not be overwritten automatically. |
|
3 |
|
|
4 |
package SL::DB::Manager::ShopImage; |
|
5 |
|
|
6 |
use strict; |
|
7 |
|
|
8 |
use parent qw(SL::DB::Helper::Manager); |
|
9 |
use SL::DB::Helper::Sorted; |
|
10 |
|
|
11 |
sub object_class { 'SL::DB::ShopImage' } |
|
12 |
|
|
13 |
__PACKAGE__->make_manager_methods; |
|
14 |
|
|
15 |
1; |
SL/DB/MetaSetup/Default.pm | ||
---|---|---|
55 | 55 |
doc_storage_for_attachments => { type => 'text', default => 'Filesystem' }, |
56 | 56 |
doc_storage_for_documents => { type => 'text', default => 'Filesystem' }, |
57 | 57 |
doc_storage_for_images => { type => 'text', default => 'Filesystem' }, |
58 |
doc_storage_for_shopimages => { type => 'text', default => 'Filesystem' }, |
|
58 | 59 |
doc_webdav => { type => 'boolean', default => 'false' }, |
59 | 60 |
dunning_ar => { type => 'integer' }, |
60 | 61 |
dunning_ar_amount_fee => { type => 'integer' }, |
SL/DB/MetaSetup/ShopImage.pm | ||
---|---|---|
1 |
# This file has been auto-generated. Do not modify it; it will be overwritten |
|
2 |
# by rose_auto_create_model.pl automatically. |
|
3 |
package SL::DB::ShopImage; |
|
4 |
|
|
5 |
use strict; |
|
6 |
|
|
7 |
use parent qw(SL::DB::Object); |
|
8 |
|
|
9 |
__PACKAGE__->meta->table('shop_images'); |
|
10 |
|
|
11 |
__PACKAGE__->meta->columns( |
|
12 |
file_id => { type => 'integer' }, |
|
13 |
id => { type => 'serial', not_null => 1 }, |
|
14 |
itime => { type => 'timestamp', default => 'now()' }, |
|
15 |
mtime => { type => 'timestamp' }, |
|
16 |
org_file_height => { type => 'integer' }, |
|
17 |
org_file_width => { type => 'integer' }, |
|
18 |
position => { type => 'integer' }, |
|
19 |
thumbnail_content => { type => 'bytea' }, |
|
20 |
thumbnail_content_type => { type => 'text' }, |
|
21 |
); |
|
22 |
|
|
23 |
__PACKAGE__->meta->primary_key_columns([ 'id' ]); |
|
24 |
|
|
25 |
__PACKAGE__->meta->allow_inline_column_values(1); |
|
26 |
|
|
27 |
__PACKAGE__->meta->foreign_keys( |
|
28 |
file => { |
|
29 |
class => 'SL::DB::File', |
|
30 |
key_columns => { file_id => 'id' }, |
|
31 |
}, |
|
32 |
); |
|
33 |
|
|
34 |
1; |
|
35 |
; |
SL/DB/ShopImage.pm | ||
---|---|---|
1 |
# This file has been auto-generated only because it didn't exist. |
|
2 |
# Feel free to modify it at will; it will not be overwritten automatically. |
|
3 |
|
|
4 |
package SL::DB::ShopImage; |
|
5 |
|
|
6 |
use strict; |
|
7 |
|
|
8 |
use SL::DB::MetaSetup::ShopImage; |
|
9 |
use SL::DB::Manager::ShopImage; |
|
10 |
|
|
11 |
__PACKAGE__->meta->initialize; |
|
12 |
|
|
13 |
1; |
SL/File.pm | ||
---|---|---|
8 | 8 |
use SL::File::Backend; |
9 | 9 |
use SL::File::Object; |
10 | 10 |
use SL::DB::History; |
11 |
use SL::DB::ShopImage; |
|
11 | 12 |
use SL::DB::File; |
12 | 13 |
use SL::Helper::UserPreferences; |
14 |
use SL::Controller::Helper::ThumbnailCreator qw(file_probe_type); |
|
13 | 15 |
use SL::JSON; |
14 | 16 |
|
15 | 17 |
use constant RENAME_OK => 0; |
... | ... | |
189 | 191 |
|
190 | 192 |
sub _save { |
191 | 193 |
my ($self, %params) = @_; |
194 |
$main::lxdebug->dump(0, 'WH: PARAMS', \%params); |
|
192 | 195 |
my $file = $params{dbfile}; |
193 | 196 |
my $exists = 0; |
194 | 197 |
|
... | ... | |
240 | 243 |
|
241 | 244 |
$file->mtime(DateTime->now_local); |
242 | 245 |
$file->save; |
246 |
#ShopImage |
|
247 |
if($file->object_type eq "shop_image"){ |
|
248 |
my $image_content = $params{file_contents}; |
|
249 |
my $thumbnail = file_probe_type($image_content); |
|
250 |
$main::lxdebug->dump(0, 'WH: THUMB ',$thumbnail); |
|
251 |
my $shopimage = SL::DB::ShopImage->new(); |
|
252 |
$shopimage->assign_attributes( |
|
253 |
file_id => $file->id, |
|
254 |
thumbnail_content => $thumbnail->{thumbnail_img_content}, |
|
255 |
org_file_height => $thumbnail->{file_image_height}, |
|
256 |
org_file_width => $thumbnail->{file_image_width}, |
|
257 |
thumbnail_content_type => $thumbnail->{thumbnail_img_content_type}, |
|
258 |
); |
|
259 |
$shopimage->save; |
|
260 |
} |
|
243 | 261 |
if ($params{file_type} eq 'document' && $params{source} ne 'created') { |
244 | 262 |
SL::DB::History->new( |
245 | 263 |
addition => 'IMPORT', |
SL/File/Backend/Webdav.pm | ||
---|---|---|
128 | 128 |
assembly => 'erzeugnisse', |
129 | 129 |
letter => 'briefe', |
130 | 130 |
general_ledger => 'dialogbuchungen', |
131 |
gl_transaction => 'dialogbuchungen', |
|
131 | 132 |
accounts_payable => 'kreditorenbuchungen', |
133 |
shop_image => 'shopbilder', |
|
132 | 134 |
); |
133 | 135 |
|
134 | 136 |
my %type_to_model = ( |
... | ... | |
146 | 148 |
assembly => 'Part', |
147 | 149 |
letter => 'Letter', |
148 | 150 |
general_ledger => 'GLTransaction', |
151 |
gl_transaction => 'GLTransaction', |
|
149 | 152 |
accounts_payable => 'GLTransaction', |
153 |
shop_image => 'Part', |
|
150 | 154 |
); |
151 | 155 |
|
152 | 156 |
my %model_to_number = ( |
... | ... | |
156 | 160 |
PurchaseInvoice => 'invnumber', |
157 | 161 |
Part => 'partnumber', |
158 | 162 |
Letter => 'letternumber', |
159 |
GLTransaction => 'reference' |
|
163 |
GLTransaction => 'reference', |
|
164 |
ShopImage => 'partnumber', |
|
160 | 165 |
); |
161 | 166 |
|
162 | 167 |
sub webdav_path { |
js/kivi.shop_part.js | ||
---|---|---|
144 | 144 |
$('.ui-dialog-titlebar button.ui-dialog-titlebar-close').prop('disabled', '') |
145 | 145 |
}; |
146 | 146 |
|
147 |
ns.imageUpload = function(id,type,filetype,upload_title,gl) { |
|
148 |
kivi.popup_dialog({ url: 'controller.pl', |
|
149 |
data: { action: 'File/ajax_upload', |
|
150 |
file_type: filetype, |
|
151 |
object_type: type, |
|
152 |
object_id: id, |
|
153 |
is_global: gl |
|
154 |
}, |
|
155 |
id: 'files_upload', |
|
156 |
dialog: { title: upload_title, width: 650, height: 240 } }); |
|
157 |
return true; |
|
158 |
} |
|
159 |
|
|
160 |
|
|
147 | 161 |
ns.setup = function() { |
148 | 162 |
kivi.shop_part.massUploadInitialize(); |
149 | 163 |
kivi.submit_ajax_form('controller.pl?action=ShopPart/mass_upload','[name=shop_parts]'); |
sql/Pg-upgrade2/shopimages.sql | ||
---|---|---|
1 |
-- @tag:shopimages |
|
2 |
-- @description: Tabelle für Shopbilder und zusätzliche Konfiguration und valid_type für Filemanagement |
|
3 |
-- @charset: UTF-8 |
|
4 |
-- @depends: release_3_4_1 files shop_parts |
|
5 |
-- @ignore: 0 |
|
6 |
|
|
7 |
CREATE TABLE shop_images( |
|
8 |
id SERIAL PRIMARY KEY, |
|
9 |
file_id INTEGER REFERENCES files(id) ON DELETE CASCADE, |
|
10 |
position INTEGER, |
|
11 |
thumbnail_content BYTEA, |
|
12 |
thumbnail_width INTEGER, |
|
13 |
thumbnail_height INTEGER, |
|
14 |
thumbnail_content_type TEXT, |
|
15 |
itime TIMESTAMP DEFAULT now(), |
|
16 |
mtime TIMESTAMP |
|
17 |
); |
|
18 |
|
|
19 |
CREATE TRIGGER mtime_shop_images BEFORE UPDATE ON shop_images FOR EACH ROW EXECUTE PROCEDURE set_mtime(); |
|
20 |
|
|
21 |
ALTER TABLE defaults ADD COLUMN doc_storage_for_shopimages text default 'Filesystem'; |
|
22 |
|
|
23 |
ALTER TABLE files |
|
24 |
DROP CONSTRAINT valid_type; |
|
25 |
ALTER TABLE files |
|
26 |
ADD CONSTRAINT valid_type CHECK ( |
|
27 |
(object_type = 'credit_note' ) OR (object_type = 'invoice' ) OR (object_type = 'sales_order' ) |
|
28 |
OR (object_type = 'sales_quotation' ) OR (object_type = 'sales_delivery_order' ) OR (object_type = 'request_quotation' ) |
|
29 |
OR (object_type = 'purchase_order' ) OR (object_type = 'purchase_delivery_order' ) OR (object_type = 'purchase_invoice' ) |
|
30 |
OR (object_type = 'vendor' ) OR (object_type = 'customer' ) OR (object_type = 'part' ) |
|
31 |
OR (object_type = 'gl_transaction' ) OR (object_type = 'dunning' ) OR (object_type = 'dunning1' ) |
|
32 |
OR (object_type = 'dunning2' ) OR (object_type = 'dunning3' ) OR (object_type = 'draft' ) |
|
33 |
OR (object_type = 'statement' ) OR (object_type = 'shop_image' ) |
|
34 |
); |
sql/Pg-upgrade2/shopimages_2.sql | ||
---|---|---|
1 |
-- @tag:shopimages_2 |
|
2 |
-- @description: Umbennung der Spalten für Weite und Breite in die Weite und Breite des orginal Bildes |
|
3 |
-- @charset: UTF-8 |
|
4 |
-- @depends: release_3_4_1 files shop_parts shopimages |
|
5 |
-- @ignore: 0 |
|
6 |
|
|
7 |
ALTER TABLE shop_images RENAME thumbnail_width TO org_file_width; |
|
8 |
ALTER TABLE shop_images RENAME thumbnail_height TO org_file_height; |
templates/webpages/client_config/_features.html | ||
---|---|---|
58 | 58 |
onchange="return checkavailable_filebackend(this);") %]</td> |
59 | 59 |
<td>[% LxERP.t8('Use this storage backend for uploaded images') %]</td> |
60 | 60 |
</tr> |
61 |
<tr> |
|
62 |
<td align="right">[% LxERP.t8('Storage Type for shopimages') %]</td> |
|
63 |
<td>[% L.select_tag('defaults.doc_storage_for_shopimages', |
|
64 |
[ [ 'None', LxERP.t8('None') ], [ 'Filesystem', LxERP.t8('Files') ],[ 'Webdav', LxERP.t8('WebDAV') ],[ 'ExtDMS', LxERP.t8('ext.DMS') ],[ 'DB', LxERP.t8('Database') ] ], |
|
65 |
default = SELF.defaults.doc_storage_for_shopimages, |
|
66 |
onchange="return checkavailable_filebackend(this);") %]</td> |
|
67 |
<td>[% LxERP.t8('Use this storage backend for uploaded images') %]</td> |
|
68 |
</tr> |
|
61 | 69 |
<tr> |
62 | 70 |
<td align="right">[% LxERP.t8('Delete printfiles') %]</td> |
63 | 71 |
<td>[% L.yes_no_tag('defaults.doc_delete_printfiles', SELF.defaults.doc_delete_printfiles) %]</td> |
templates/webpages/file/upload_dialog.html | ||
---|---|---|
1 | 1 |
[%- USE L -%][%- USE LxERP -%][%- USE JavaScript -%] |
2 |
|
|
2 |
xx |
|
3 | 3 |
<form method="post" id="upload_form" enctype="multipart/form-data" action="controller.pl"> |
4 |
[% SET multiple = 'true' %] |
|
5 |
[% IF SELF.object_type == 'shop_image' %][% multiple = 'false' %][% END %] |
|
4 | 6 |
<table> |
5 | 7 |
<tr> |
6 | 8 |
<td>[%- LxERP.t8("Filename") %]:</td><td> |
7 |
<input type="file" name="uploadfiles[]" multiple="true" id="upload_files" size="45" accept="[% SELF.accept_types %]" onchange="kivi.File.allow_upload_submit();"></td>
|
|
9 |
<input type="file" name="uploadfiles[]" multiple="[% multiple %]" id="upload_files" size="45" accept="[% SELF.accept_types %]" onchange="kivi.File.allow_upload_submit();"></td>
|
|
8 | 10 |
</tr> |
11 |
[% IF SELF.object_type == 'shop_image' %] |
|
12 |
<tr> |
|
13 |
<td>[% LxERP.t8("Title") %]</td> |
|
14 |
<td>[% L.input_tag("title",'') %]</td> |
|
15 |
</tr> |
|
16 |
<tr> |
|
17 |
<td>[% LxERP.t8("Description") %]</td> |
|
18 |
<td>[% L.input_tag("description",'') %]</td> |
|
19 |
</tr> |
|
20 |
[% END %] |
|
9 | 21 |
</table> |
10 | 22 |
|
11 | 23 |
<p> |
templates/webpages/shop_part/_list_images.html | ||
---|---|---|
15 | 15 |
</thead> |
16 | 16 |
<tbody> |
17 | 17 |
[%- FOREACH img = IMAGES %] |
18 |
[% # Dumper.dump_html(img) %] |
|
18 | 19 |
<tr class="listrow" id="image_id_[% img.id %]"> |
19 | 20 |
<td><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]" class="dragdrop"></td> |
20 |
<td width="70px"><img src="data:[% img.thumbnail_img_content_type %];base64,[% img.thumbnail_img_content.encode_base64 %]" alt="[% img.title %]"></td>
|
|
21 |
<td>[% HTML.escape(img.title) %]</td> |
|
22 |
<td>[% HTML.escape(img.description) %]</td> |
|
23 |
<td>[% HTML.escape(img.filename) %]</td> |
|
24 |
<td>[% HTML.escape(img.files_img_width) _ ' x ' _ HTML.escape(img.files_img_height) %]</td>
|
|
21 |
<td width="70px"><img src="data:[% img.thumbnail_content_type %];base64,[% img.thumbnail_content.encode_base64 %]" alt="[% img.file.title %]"></td>
|
|
22 |
<td>[% HTML.escape(img.file.title) %]</td>
|
|
23 |
<td>[% HTML.escape(img.file.description) %]</td>
|
|
24 |
<td>[% HTML.escape(img.file.file_name) %]</td>
|
|
25 |
<td>[% HTML.escape(img.org_file_width) _ ' x ' _ HTML.escape(img.org_file_height) %]</td>
|
|
25 | 26 |
<td>[% L.button_tag("kivi.FileUploader.delete_file(" _ img.id _ ", 'ShopPart/ajax_delete_file')", LxERP.t8('Delete'), confirm=LxERP.t8("Are you sure?")) %] [% L.button_tag("kivi.FileUploader.add_file(" _ img.id _ "," _ FORM.id _ ",'shop_part','ShopPart/ajax_update_file','jpg|png|tif|gif')", LxERP.t8('Edit')) %] </td> |
26 | 27 |
</tr> |
27 | 28 |
[% END %] |
... | ... | |
30 | 31 |
|
31 | 32 |
[% L.sortable_element('#images_list tbody', url=SELF.url_for(action='reorder'), with='image_id') %] |
32 | 33 |
<p> |
33 |
[% L.button_tag("kivi.FileUploader.add_file(''," _ FORM.id _ ",'shop_part','ShopPart/ajax_upload_file','jpg|png|tif|gif')", LxERP.t8('Fileupload')) %]
|
|
34 |
[% L.button_tag("kivi.shop_part.imageUpload(" _ FORM.id _ ",'shop_image','image','Upload shopimage',0);", LxERP.t8('Upload shopimage') ) %]
|
|
34 | 35 |
</p> |
Auch abrufbar als: Unified diff
Shopmodul: Bilder hochladen