X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FDownloadZip.pm;h=33514c4a7e0b106e2ea6b672efd3e0186837e1b0;hb=95b5d54bac9dc0cb47c67444c9e19c1d68b0d520;hp=5bac4ba2e2132a791c9c9f0c004224cb28e525ba;hpb=65922b0d6c4a14e29354f65c60dea2176d10f941;p=kivitendo-erp.git diff --git a/SL/Controller/DownloadZip.pm b/SL/Controller/DownloadZip.pm index 5bac4ba2e..33514c4a7 100644 --- a/SL/Controller/DownloadZip.pm +++ b/SL/Controller/DownloadZip.pm @@ -20,7 +20,7 @@ sub action_download_orderitems_files { # in kivitendo.conf some regex may be defined: # For no values just let it commented out # PA = Produktionsauftrag, L = Lieferschein, ML = Materialliste - # If you want several options, please seperate the letter with '|'. Example: '^(PA|L).*' + # If you want several options, please separate the letter with '|'. Example: '^(PA|L).*' #set_sales_documenttype_for_delivered_quantity = '^(LS).*' #set_purchase_documenttype_for_delivered_quantity = '^(EL).*' # @@ -43,31 +43,20 @@ sub action_download_orderitems_files { #my $name_encoding = 'cp850'; my $name_encoding = 'UTF-8'; - # today only sales_order implementation ! - if ( $object_id && $object_type eq 'sales_order' && $element_type eq 'part' ) { + if ( $object_id + && ($object_type =~ m{^(?:sales_order|purchase_order|sales_quotation|request_quotation)$}) + && ($element_type eq 'part')) { my $orderitems = SL::DB::Manager::OrderItem->get_all(query => ['order.id' => $object_id ], with_objects => [ 'order', 'part' ], sort_by => 'part.partnumber ASC'); - my $part_id = 0; foreach my $item ( @{$orderitems} ) { - next if $part_id == $item->parts_id; - my @files = SL::File->get_all(object_id => $item->parts_id, object_type => $element_type, ); - my @wanted_files; - ## also for filtering if needed: - # if ( $doctype ) { - # @wanted_files = grep { $_->{file_name} =~ /$doctype/ } @files; - # } else { - @wanted_files = @files; - # } - if ( scalar (@wanted_files) > 0 ) { - $zip->addDirectory($item->part->partnumber); - $zip->addFile(SL::File->get_file_path(dbfile => $_ ), - Encode::encode($name_encoding,$item->part->partnumber.'/'.$_->{file_name}) - ) for @wanted_files; - } + next unless @files; + + $zip->addDirectory($item->part->partnumber); + $zip->addFile($_->get_file, Encode::encode($name_encoding, $item->part->partnumber . '/' . $_->db_file->file_name)) for @files; } } unless ( $zip->writeToFileNamed($sfile->file_name) == Archive::Zip::AZ_OK ) { @@ -110,7 +99,7 @@ THis method must be inserted into the customer branch: ns.downloadOrderitemsAtt = function(type,id) { var rowcount = $('input[name=rowcount]').val() - 1; - var data = { + var data = { action: 'FileManagement/download_zip', type: type, object_id: id, @@ -118,7 +107,7 @@ THis method must be inserted into the customer branch: }; if ( rowcount == 0 ) { kivi.display_flash('error', kivi.t8('No articles have been added yet.')); - return false; + return false; } for (var i = 1; i <= rowcount; i++) { data['parts_id_'+i] = $('#id_' + i).val();