commit a873249c8c3c32006540d8636102c195dd4d9448
Author: Moritz Bunkus <m.bunkus@linet.de>
Date:   Mon Dec 27 16:23:34 2010 +0100

    Zahlen beim CSV-Export ohne Tausendertrennzeichen formatieren
    
    Fix für Bug 1393.

diff --git a/SL/Locale.pm b/SL/Locale.pm
index 4fde61654..b1c8205e8 100644
--- a/SL/Locale.pm
+++ b/SL/Locale.pm
@@ -480,4 +480,19 @@ sub with_raw_io {
   $self->{raw_io_active} = 0;
 }
 
+sub set_numberformat_wo_thousands_separator {
+  my $self     = shift;
+  my $myconfig = shift || \%::myconfig;
+
+  $self->{saved_numberformat} = $myconfig->{numberformat};
+  $myconfig->{numberformat}   =~ s/^1[,\.]/1/;
+}
+
+sub restore_numberformat {
+  my $self     = shift;
+  my $myconfig = shift || \%::myconfig;
+
+  $myconfig->{numberformat} = $self->{saved_numberformat} if $self->{saved_numberformat};
+}
+
 1;
diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl
index 8b32585a0..06541ef05 100644
--- a/bin/mozilla/ap.pl
+++ b/bin/mozilla/ap.pl
@@ -1342,6 +1342,7 @@ sub ap_transactions {
                        'attachment_basename'  => $locale->text('vendor_invoice_list') . strftime('_%Y%m%d', localtime time),
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   # add sort and escape callback, this one we use for the add sub
   $form->{callback} = $href .= "&sort=$form->{sort}";
diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl
index f0c3f4f18..e2777bd49 100644
--- a/bin/mozilla/ar.pl
+++ b/bin/mozilla/ar.pl
@@ -1440,6 +1440,7 @@ sub ar_transactions {
                        'attachment_basename'  => $locale->text('invoice_list') . strftime('_%Y%m%d', localtime time),
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   # add sort and escape callback, this one we use for the add sub
   $form->{callback} = $href .= "&sort=$form->{sort}";
diff --git a/bin/mozilla/bankaccounts.pl b/bin/mozilla/bankaccounts.pl
index 0815954dc..f8bbb3a84 100644
--- a/bin/mozilla/bankaccounts.pl
+++ b/bin/mozilla/bankaccounts.pl
@@ -1,5 +1,6 @@
 use strict;
 
+use List::MoreUtils qw(any);
 use POSIX qw(strftime);
 
 use SL::BankAccount;
@@ -125,6 +126,7 @@ sub bank_account_list {
                        'attachment_basename'   => $locale->text('bankaccounts') . strftime('_%Y%m%d', localtime time),
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   $report->set_columns(%column_defs);
   $report->set_column_order(@columns);
diff --git a/bin/mozilla/ca.pl b/bin/mozilla/ca.pl
index a58ac1e26..31c77da10 100644
--- a/bin/mozilla/ca.pl
+++ b/bin/mozilla/ca.pl
@@ -106,6 +106,7 @@ sub chart_of_accounts {
                        'std_column_visibility' => 1,
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   $report->set_columns(%column_defs);
   $report->set_column_order(@columns);
@@ -593,6 +594,7 @@ sub list_transactions {
                        'std_column_visibility' => 1,
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   $report->set_columns(%column_defs);
   $report->set_column_order(@columns);
diff --git a/bin/mozilla/ct.pl b/bin/mozilla/ct.pl
index 447641177..63aa8313f 100644
--- a/bin/mozilla/ct.pl
+++ b/bin/mozilla/ct.pl
@@ -208,6 +208,7 @@ sub list_names {
                        'attachment_basename'   => $attachment_basename . strftime('_%Y%m%d', localtime time),
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   $report->set_columns(%column_defs);
   $report->set_column_order(@columns);
diff --git a/bin/mozilla/do.pl b/bin/mozilla/do.pl
index 0d5941cb0..cde1c602e 100644
--- a/bin/mozilla/do.pl
+++ b/bin/mozilla/do.pl
@@ -551,6 +551,7 @@ sub orders {
                        'attachment_basename'  => $attachment_basename . strftime('_%Y%m%d', localtime time),
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   # add sort and escape callback, this one we use for the add sub
   $form->{callback} = $href .= "&sort=$form->{sort}";
diff --git a/bin/mozilla/fu.pl b/bin/mozilla/fu.pl
index ac9e81f2e..ec322413f 100644
--- a/bin/mozilla/fu.pl
+++ b/bin/mozilla/fu.pl
@@ -300,6 +300,7 @@ sub report {
                        'attachment_basename'  => $locale->text('follow_up_list') . strftime('_%Y%m%d', localtime time),
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   my $idx      = 0;
   my $callback = build_std_url('action=report', grep { $form->{$_} } @report_params);
diff --git a/bin/mozilla/gl.pl b/bin/mozilla/gl.pl
index f7810c76b..e642f7e42 100644
--- a/bin/mozilla/gl.pl
+++ b/bin/mozilla/gl.pl
@@ -541,6 +541,7 @@ sub generate_report {
                        'attachment_basename'  => $locale->text('general_ledger_list') . strftime('_%Y%m%d', localtime time),
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   # add sort to callback
   $form->{callback} = "$callback&sort=" . E($form->{sort}) . "&sortdir=" . E($form->{sortdir});
diff --git a/bin/mozilla/ic.pl b/bin/mozilla/ic.pl
index 5a012b7a3..d83d40942 100644
--- a/bin/mozilla/ic.pl
+++ b/bin/mozilla/ic.pl
@@ -1235,6 +1235,7 @@ sub generate_report {
                        'attachment_basename'   => $attachment_basenames{$form->{searchitems}} . strftime('_%Y%m%d', localtime time),
   );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   $report->set_columns(%column_defs);
   $report->set_column_order(@columns);
diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl
index 3867c1b41..0a0ce98d3 100644
--- a/bin/mozilla/oe.pl
+++ b/bin/mozilla/oe.pl
@@ -864,6 +864,7 @@ sub orders {
                        'attachment_basename'  => $attachment_basename . strftime('_%Y%m%d', localtime time),
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   # add sort and escape callback, this one we use for the add sub
   $form->{callback} = $href .= "&sort=$form->{sort}";
diff --git a/bin/mozilla/projects.pl b/bin/mozilla/projects.pl
index f854a4af9..8f5991e2f 100644
--- a/bin/mozilla/projects.pl
+++ b/bin/mozilla/projects.pl
@@ -169,6 +169,7 @@ sub project_report {
                        'attachment_basename' => $locale->text('project_list') . strftime('_%Y%m%d', localtime time),
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   CVar->add_custom_variables_to_report('module'         => 'Projects',
                                        'trans_id_field' => 'id',
diff --git a/bin/mozilla/rp.pl b/bin/mozilla/rp.pl
index e1b0773f7..b0831022c 100644
--- a/bin/mozilla/rp.pl
+++ b/bin/mozilla/rp.pl
@@ -807,7 +807,7 @@ $jsscript
         </tr>
         <tr>
           <td>| . $locale->text('Review of Aging list') . qq|</td>
-          <td><select name="review_of_aging_list"> 
+          <td><select name="review_of_aging_list">
               <option></option>
               <option>0-30</option>
               <option>30-60</option>
@@ -1368,6 +1368,7 @@ sub generate_trial_balance {
                        'pdf_template'         => 'rp/html_report_susa',
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   # add sort and escape callback, this one we use for the add sub
   $form->{callback} = $href .= "&sort=$form->{sort}";
@@ -1519,6 +1520,7 @@ sub list_accounts {
                        'std_column_visibility' => 1,
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   $report->set_columns(%column_defs);
   $report->set_column_order(@columns);
@@ -1719,6 +1721,8 @@ sub aging {
                        'title'                => $form->{title},
                        'attachment_basename'  => $attachment_basename . strftime('_%Y%m%d', localtime time),
     );
+  $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   my $previous_ctid = 0;
   my $row_idx       = 0;
@@ -1775,8 +1779,6 @@ sub aging {
                          'raw_bottom_info_text' => $raw_bottom_info_text);
   }
 
-  $report->set_options_from_form();
-
   $report->generate_with_headers();
 
   $main::lxdebug->leave_sub();
@@ -2433,6 +2435,8 @@ sub list_payments {
     );
   $report->set_options_from_form();
 
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
+
   $report->set_columns(%column_defs);
   $report->set_column_order(@columns);
 
diff --git a/bin/mozilla/sepa.pl b/bin/mozilla/sepa.pl
index f6041fbcd..fd45f80a1 100755
--- a/bin/mozilla/sepa.pl
+++ b/bin/mozilla/sepa.pl
@@ -248,6 +248,7 @@ sub bank_transfer_list {
                        'attachment_basename'   => $locale->text('banktransfers') . strftime('_%Y%m%d', localtime time),
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%::myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   $report->set_columns(%column_defs);
   $report->set_column_order(@columns);
diff --git a/bin/mozilla/vk.pl b/bin/mozilla/vk.pl
index 021761ee9..16fcc78b7 100644
--- a/bin/mozilla/vk.pl
+++ b/bin/mozilla/vk.pl
@@ -87,7 +87,7 @@ sub invoice_transactions {
   my ($callback, $href, @columns);
 
   $form->{customer} = $form->unescape($form->{customer});
-  
+
   ($form->{customername}, $form->{customer_id}) = split(/--/, $form->{customer});
 
   # decimalplaces überprüfen oder auf Default 2 setzen
@@ -137,7 +137,7 @@ sub invoice_transactions {
     'marge_total'             => { 'text' => $locale->text('Sales margin'), },
     'marge_percent'           => { 'text' => $locale->text('Sales margin %'), },
   );
-  
+
   my %column_alignment = map { $_ => 'right' } qw(lastcost sellprice sellprice_total lastcost_total unit discount marge_total marge_percent qty);
 
   $form->{"l_type"} = "Y";
@@ -188,6 +188,7 @@ sub invoice_transactions {
                        'attachment_basename'  => $locale->text('Sales Report') . strftime('_%Y%m%d', localtime time),
     );
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   $report->set_columns(%column_defs);
   $report->set_column_order(@columns);
@@ -222,7 +223,7 @@ sub invoice_transactions {
     $ar->{sellprice} = $ar->{sellprice} / $ar->{price_factor};
     $ar->{lastcost} = $ar->{lastcost} / $ar->{price_factor};
     $ar->{sellprice_total} = $ar->{qty} * $ar->{sellprice};
-    $ar->{lastcost_total}  = $ar->{qty} * $ar->{lastcost}; 
+    $ar->{lastcost_total}  = $ar->{qty} * $ar->{lastcost};
     # marge_percent wird neu berechnet, da Wert in invoice leer ist (Bug)
     $ar->{marge_percent} = $ar->{sellprice_total} ? (($ar->{sellprice_total}-$ar->{lastcost_total}) / $ar->{sellprice_total}) : 0;
     # marge_total neu berechnen
@@ -243,14 +244,14 @@ sub invoice_transactions {
       $report->add_data($headerrow_set);
 
       # add empty row after main header
-#      my $emptyheaderrow->{description}->{data} = ""; 
+#      my $emptyheaderrow->{description}->{data} = "";
 #      $emptyheaderrow->{description}->{class} = "listmainsortheader";
 #      my $emptyheaderrow_set = [ $emptyheaderrow ];
-#      $report->add_data($emptyheaderrow_set) if $form->{l_headers} eq "Y"; 
+#      $report->add_data($emptyheaderrow_set) if $form->{l_headers} eq "Y";
     };
 
     # subsort überschriften
-    if ( $idx == 0 
+    if ( $idx == 0
       or $ar->{ $form->{'subsort'} }  ne $form->{AR}->[$idx - 1]->{ $form->{'subsort'} }
       or $ar->{ $form->{'mainsort'} } ne $form->{AR}->[$idx - 1]->{ $form->{'mainsort'} }
     ) {
@@ -271,8 +272,8 @@ sub invoice_transactions {
     map { $subtotals1{$_} += $ar->{$_};
           $subtotals2{$_} += $ar->{$_};
         } @subtotal_columns;
-         
-    map { $totals{$_}    += $ar->{$_} } @total_columns;  
+
+    map { $totals{$_}    += $ar->{$_} } @total_columns;
 
     $subtotals2{sellprice} = $subtotals2{sellprice_total} / $subtotals2{qty} if $subtotals2{qty} != 0;
     $subtotals1{sellprice} = $subtotals1{sellprice_total} / $subtotals1{qty} if $subtotals1{qty} != 0;
@@ -298,7 +299,7 @@ sub invoice_transactions {
         'align' => $column_alignment{$column},
       };
     }
-  
+
    $row->{description}->{class} = 'listsortdescription';
 
     $row->{invnumber}->{link} = build_std_url("script=is.pl", 'action=edit')
@@ -317,14 +318,14 @@ sub invoice_transactions {
       } else {
         $name = 'name';
       };
-      
+
       if ($form->{l_subtotal} eq 'Y' ) {
         push @{ $row_set }, create_subtotal_row_invoice(\%subtotals2, \@columns, \%column_alignment, \@subtotal_columns, 'listsubsortsubtotal', $ar->{$name}) ;
         push @{ $row_set }, insert_empty_row();
       };
     }
 
-    # if mainsort has changed, add mainsort subtotal and empty row 
+    # if mainsort has changed, add mainsort subtotal and empty row
     if (($form->{l_subtotal} eq 'Y')
         && (($idx == (scalar @{ $form->{AR} } - 1))   # last element always has a subtotal
             || ($ar->{ $form->{'mainsort'} } ne $form->{AR}->[$idx + 1]->{ $form->{'mainsort'} })
@@ -340,7 +341,7 @@ sub invoice_transactions {
         push @{ $row_set }, insert_empty_row();
       };
     }
-  
+
     $report->add_data($row_set);
 
     $idx++;
@@ -373,7 +374,7 @@ sub create_subtotal_row_invoice {
   my %myconfig = %main::myconfig;
 
   my $row = { map { $_ => { 'data' => '', 'class' => $class, 'align' => $column_alignment->{$_}, } } @{ $columns } };
-  
+
   $row->{description}->{data} = "Summe " . $name;
 
   map { $row->{$_}->{data} = $form->format_amount(\%myconfig, $totals->{$_}, 2) } qw(marge_total marge_percent);
diff --git a/bin/mozilla/wh.pl b/bin/mozilla/wh.pl
index 30ee32676..c990e632f 100644
--- a/bin/mozilla/wh.pl
+++ b/bin/mozilla/wh.pl
@@ -721,6 +721,7 @@ sub generate_journal {
                        'title'                => $form->{title},
                        'attachment_basename'  => strftime($locale->text('warehouse_journal_list') . '_%Y%m%d', localtime time));
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   my $all_units = AM->retrieve_units(\%myconfig, $form);
   my @contents  = WH->get_warehouse_journal(%filter);
@@ -869,6 +870,7 @@ sub generate_report {
                        'title'                => $form->{title},
                        'attachment_basename'  => strftime($locale->text('warehouse_report_list') . '_%Y%m%d', localtime time));
   $report->set_options_from_form();
+  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
 
   my $all_units = AM->retrieve_units(\%myconfig, $form);
   my @contents  = WH->get_warehouse_report(%filter);
