Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision a873249c

Von Moritz Bunkus vor fast 14 Jahren hinzugefügt

  • ID a873249c8c3c32006540d8636102c195dd4d9448
  • Vorgänger f35ddfbe
  • Nachfolger 50e62c57

Zahlen beim CSV-Export ohne Tausendertrennzeichen formatieren

Fix für Bug 1393.

Unterschiede anzeigen:

SL/Locale.pm
480 480
  $self->{raw_io_active} = 0;
481 481
}
482 482

  
483
sub set_numberformat_wo_thousands_separator {
484
  my $self     = shift;
485
  my $myconfig = shift || \%::myconfig;
486

  
487
  $self->{saved_numberformat} = $myconfig->{numberformat};
488
  $myconfig->{numberformat}   =~ s/^1[,\.]/1/;
489
}
490

  
491
sub restore_numberformat {
492
  my $self     = shift;
493
  my $myconfig = shift || \%::myconfig;
494

  
495
  $myconfig->{numberformat} = $self->{saved_numberformat} if $self->{saved_numberformat};
496
}
497

  
483 498
1;
bin/mozilla/ap.pl
1342 1342
                       'attachment_basename'  => $locale->text('vendor_invoice_list') . strftime('_%Y%m%d', localtime time),
1343 1343
    );
1344 1344
  $report->set_options_from_form();
1345
  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
1345 1346

  
1346 1347
  # add sort and escape callback, this one we use for the add sub
1347 1348
  $form->{callback} = $href .= "&sort=$form->{sort}";
bin/mozilla/ar.pl
1440 1440
                       'attachment_basename'  => $locale->text('invoice_list') . strftime('_%Y%m%d', localtime time),
1441 1441
    );
1442 1442
  $report->set_options_from_form();
1443
  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
1443 1444

  
1444 1445
  # add sort and escape callback, this one we use for the add sub
1445 1446
  $form->{callback} = $href .= "&sort=$form->{sort}";
bin/mozilla/bankaccounts.pl
1 1
use strict;
2 2

  
3
use List::MoreUtils qw(any);
3 4
use POSIX qw(strftime);
4 5

  
5 6
use SL::BankAccount;
......
125 126
                       'attachment_basename'   => $locale->text('bankaccounts') . strftime('_%Y%m%d', localtime time),
126 127
    );
127 128
  $report->set_options_from_form();
129
  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
128 130

  
129 131
  $report->set_columns(%column_defs);
130 132
  $report->set_column_order(@columns);
bin/mozilla/ca.pl
106 106
                       'std_column_visibility' => 1,
107 107
    );
108 108
  $report->set_options_from_form();
109
  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
109 110

  
110 111
  $report->set_columns(%column_defs);
111 112
  $report->set_column_order(@columns);
......
593 594
                       'std_column_visibility' => 1,
594 595
    );
595 596
  $report->set_options_from_form();
597
  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
596 598

  
597 599
  $report->set_columns(%column_defs);
598 600
  $report->set_column_order(@columns);
bin/mozilla/ct.pl
208 208
                       'attachment_basename'   => $attachment_basename . strftime('_%Y%m%d', localtime time),
209 209
    );
210 210
  $report->set_options_from_form();
211
  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
211 212

  
212 213
  $report->set_columns(%column_defs);
213 214
  $report->set_column_order(@columns);
bin/mozilla/do.pl
551 551
                       'attachment_basename'  => $attachment_basename . strftime('_%Y%m%d', localtime time),
552 552
    );
553 553
  $report->set_options_from_form();
554
  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
554 555

  
555 556
  # add sort and escape callback, this one we use for the add sub
556 557
  $form->{callback} = $href .= "&sort=$form->{sort}";
bin/mozilla/fu.pl
300 300
                       'attachment_basename'  => $locale->text('follow_up_list') . strftime('_%Y%m%d', localtime time),
301 301
    );
302 302
  $report->set_options_from_form();
303
  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
303 304

  
304 305
  my $idx      = 0;
305 306
  my $callback = build_std_url('action=report', grep { $form->{$_} } @report_params);
bin/mozilla/gl.pl
541 541
                       'attachment_basename'  => $locale->text('general_ledger_list') . strftime('_%Y%m%d', localtime time),
542 542
    );
543 543
  $report->set_options_from_form();
544
  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
544 545

  
545 546
  # add sort to callback
546 547
  $form->{callback} = "$callback&sort=" . E($form->{sort}) . "&sortdir=" . E($form->{sortdir});
bin/mozilla/ic.pl
1235 1235
                       'attachment_basename'   => $attachment_basenames{$form->{searchitems}} . strftime('_%Y%m%d', localtime time),
1236 1236
  );
1237 1237
  $report->set_options_from_form();
1238
  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
1238 1239

  
1239 1240
  $report->set_columns(%column_defs);
1240 1241
  $report->set_column_order(@columns);
bin/mozilla/oe.pl
864 864
                       'attachment_basename'  => $attachment_basename . strftime('_%Y%m%d', localtime time),
865 865
    );
866 866
  $report->set_options_from_form();
867
  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
867 868

  
868 869
  # add sort and escape callback, this one we use for the add sub
869 870
  $form->{callback} = $href .= "&sort=$form->{sort}";
bin/mozilla/projects.pl
169 169
                       'attachment_basename' => $locale->text('project_list') . strftime('_%Y%m%d', localtime time),
170 170
    );
171 171
  $report->set_options_from_form();
172
  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
172 173

  
173 174
  CVar->add_custom_variables_to_report('module'         => 'Projects',
174 175
                                       'trans_id_field' => 'id',
bin/mozilla/rp.pl
807 807
        </tr>
808 808
        <tr>
809 809
          <td>| . $locale->text('Review of Aging list') . qq|</td>
810
          <td><select name="review_of_aging_list"> 
810
          <td><select name="review_of_aging_list">
811 811
              <option></option>
812 812
              <option>0-30</option>
813 813
              <option>30-60</option>
......
1368 1368
                       'pdf_template'         => 'rp/html_report_susa',
1369 1369
    );
1370 1370
  $report->set_options_from_form();
1371
  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
1371 1372

  
1372 1373
  # add sort and escape callback, this one we use for the add sub
1373 1374
  $form->{callback} = $href .= "&sort=$form->{sort}";
......
1519 1520
                       'std_column_visibility' => 1,
1520 1521
    );
1521 1522
  $report->set_options_from_form();
1523
  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
1522 1524

  
1523 1525
  $report->set_columns(%column_defs);
1524 1526
  $report->set_column_order(@columns);
......
1719 1721
                       'title'                => $form->{title},
1720 1722
                       'attachment_basename'  => $attachment_basename . strftime('_%Y%m%d', localtime time),
1721 1723
    );
1724
  $report->set_options_from_form();
1725
  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
1722 1726

  
1723 1727
  my $previous_ctid = 0;
1724 1728
  my $row_idx       = 0;
......
1775 1779
                         'raw_bottom_info_text' => $raw_bottom_info_text);
1776 1780
  }
1777 1781

  
1778
  $report->set_options_from_form();
1779

  
1780 1782
  $report->generate_with_headers();
1781 1783

  
1782 1784
  $main::lxdebug->leave_sub();
......
2433 2435
    );
2434 2436
  $report->set_options_from_form();
2435 2437

  
2438
  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
2439

  
2436 2440
  $report->set_columns(%column_defs);
2437 2441
  $report->set_column_order(@columns);
2438 2442

  
bin/mozilla/sepa.pl
248 248
                       'attachment_basename'   => $locale->text('banktransfers') . strftime('_%Y%m%d', localtime time),
249 249
    );
250 250
  $report->set_options_from_form();
251
  $locale->set_numberformat_wo_thousands_separator(\%::myconfig) if lc($report->{options}->{output_format}) eq 'csv';
251 252

  
252 253
  $report->set_columns(%column_defs);
253 254
  $report->set_column_order(@columns);
bin/mozilla/vk.pl
87 87
  my ($callback, $href, @columns);
88 88

  
89 89
  $form->{customer} = $form->unescape($form->{customer});
90
  
90

  
91 91
  ($form->{customername}, $form->{customer_id}) = split(/--/, $form->{customer});
92 92

  
93 93
  # decimalplaces überprüfen oder auf Default 2 setzen
......
137 137
    'marge_total'             => { 'text' => $locale->text('Sales margin'), },
138 138
    'marge_percent'           => { 'text' => $locale->text('Sales margin %'), },
139 139
  );
140
  
140

  
141 141
  my %column_alignment = map { $_ => 'right' } qw(lastcost sellprice sellprice_total lastcost_total unit discount marge_total marge_percent qty);
142 142

  
143 143
  $form->{"l_type"} = "Y";
......
188 188
                       'attachment_basename'  => $locale->text('Sales Report') . strftime('_%Y%m%d', localtime time),
189 189
    );
190 190
  $report->set_options_from_form();
191
  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
191 192

  
192 193
  $report->set_columns(%column_defs);
193 194
  $report->set_column_order(@columns);
......
222 223
    $ar->{sellprice} = $ar->{sellprice} / $ar->{price_factor};
223 224
    $ar->{lastcost} = $ar->{lastcost} / $ar->{price_factor};
224 225
    $ar->{sellprice_total} = $ar->{qty} * $ar->{sellprice};
225
    $ar->{lastcost_total}  = $ar->{qty} * $ar->{lastcost}; 
226
    $ar->{lastcost_total}  = $ar->{qty} * $ar->{lastcost};
226 227
    # marge_percent wird neu berechnet, da Wert in invoice leer ist (Bug)
227 228
    $ar->{marge_percent} = $ar->{sellprice_total} ? (($ar->{sellprice_total}-$ar->{lastcost_total}) / $ar->{sellprice_total}) : 0;
228 229
    # marge_total neu berechnen
......
243 244
      $report->add_data($headerrow_set);
244 245

  
245 246
      # add empty row after main header
246
#      my $emptyheaderrow->{description}->{data} = ""; 
247
#      my $emptyheaderrow->{description}->{data} = "";
247 248
#      $emptyheaderrow->{description}->{class} = "listmainsortheader";
248 249
#      my $emptyheaderrow_set = [ $emptyheaderrow ];
249
#      $report->add_data($emptyheaderrow_set) if $form->{l_headers} eq "Y"; 
250
#      $report->add_data($emptyheaderrow_set) if $form->{l_headers} eq "Y";
250 251
    };
251 252

  
252 253
    # subsort überschriften
253
    if ( $idx == 0 
254
    if ( $idx == 0
254 255
      or $ar->{ $form->{'subsort'} }  ne $form->{AR}->[$idx - 1]->{ $form->{'subsort'} }
255 256
      or $ar->{ $form->{'mainsort'} } ne $form->{AR}->[$idx - 1]->{ $form->{'mainsort'} }
256 257
    ) {
......
271 272
    map { $subtotals1{$_} += $ar->{$_};
272 273
          $subtotals2{$_} += $ar->{$_};
273 274
        } @subtotal_columns;
274
         
275
    map { $totals{$_}    += $ar->{$_} } @total_columns;  
275

  
276
    map { $totals{$_}    += $ar->{$_} } @total_columns;
276 277

  
277 278
    $subtotals2{sellprice} = $subtotals2{sellprice_total} / $subtotals2{qty} if $subtotals2{qty} != 0;
278 279
    $subtotals1{sellprice} = $subtotals1{sellprice_total} / $subtotals1{qty} if $subtotals1{qty} != 0;
......
298 299
        'align' => $column_alignment{$column},
299 300
      };
300 301
    }
301
  
302

  
302 303
   $row->{description}->{class} = 'listsortdescription';
303 304

  
304 305
    $row->{invnumber}->{link} = build_std_url("script=is.pl", 'action=edit')
......
317 318
      } else {
318 319
        $name = 'name';
319 320
      };
320
      
321

  
321 322
      if ($form->{l_subtotal} eq 'Y' ) {
322 323
        push @{ $row_set }, create_subtotal_row_invoice(\%subtotals2, \@columns, \%column_alignment, \@subtotal_columns, 'listsubsortsubtotal', $ar->{$name}) ;
323 324
        push @{ $row_set }, insert_empty_row();
324 325
      };
325 326
    }
326 327

  
327
    # if mainsort has changed, add mainsort subtotal and empty row 
328
    # if mainsort has changed, add mainsort subtotal and empty row
328 329
    if (($form->{l_subtotal} eq 'Y')
329 330
        && (($idx == (scalar @{ $form->{AR} } - 1))   # last element always has a subtotal
330 331
            || ($ar->{ $form->{'mainsort'} } ne $form->{AR}->[$idx + 1]->{ $form->{'mainsort'} })
......
340 341
        push @{ $row_set }, insert_empty_row();
341 342
      };
342 343
    }
343
  
344

  
344 345
    $report->add_data($row_set);
345 346

  
346 347
    $idx++;
......
373 374
  my %myconfig = %main::myconfig;
374 375

  
375 376
  my $row = { map { $_ => { 'data' => '', 'class' => $class, 'align' => $column_alignment->{$_}, } } @{ $columns } };
376
  
377

  
377 378
  $row->{description}->{data} = "Summe " . $name;
378 379

  
379 380
  map { $row->{$_}->{data} = $form->format_amount(\%myconfig, $totals->{$_}, 2) } qw(marge_total marge_percent);
bin/mozilla/wh.pl
721 721
                       'title'                => $form->{title},
722 722
                       'attachment_basename'  => strftime($locale->text('warehouse_journal_list') . '_%Y%m%d', localtime time));
723 723
  $report->set_options_from_form();
724
  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
724 725

  
725 726
  my $all_units = AM->retrieve_units(\%myconfig, $form);
726 727
  my @contents  = WH->get_warehouse_journal(%filter);
......
869 870
                       'title'                => $form->{title},
870 871
                       'attachment_basename'  => strftime($locale->text('warehouse_report_list') . '_%Y%m%d', localtime time));
871 872
  $report->set_options_from_form();
873
  $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
872 874

  
873 875
  my $all_units = AM->retrieve_units(\%myconfig, $form);
874 876
  my @contents  = WH->get_warehouse_report(%filter);

Auch abrufbar als: Unified diff