X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FDownloadZip.pm;h=33514c4a7e0b106e2ea6b672efd3e0186837e1b0;hb=0f521b3d8ea765b3e39f2f817e5f4f97a23d562c;hp=06f62213c089f5d94e7abe1afb053edf4a4301bc;hpb=05e0e8ca1544e1ca706a99e51f9caf9a2f56f6af;p=kivitendo-erp.git diff --git a/SL/Controller/DownloadZip.pm b/SL/Controller/DownloadZip.pm index 06f62213c..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,29 +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($_->get_file ), 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 ) { @@ -108,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,