103 |
103 |
my ($callback, $href, @columns);
|
104 |
104 |
|
105 |
105 |
# can't currently be configured from report, empty line between main sortings
|
106 |
|
my $addemptylines = '1';
|
|
106 |
my $addemptylines = 1;
|
107 |
107 |
|
108 |
108 |
if ( $form->{customer} =~ /--/ ) {
|
109 |
109 |
# Felddaten kommen aus Dropdownbox
|
... | ... | |
265 |
265 |
'data' => $form->{AR}
|
266 |
266 |
);
|
267 |
267 |
|
|
268 |
my $num_visible_columns = scalar $report->get_visible_columns;
|
|
269 |
my %empty_row = (
|
|
270 |
description => {
|
|
271 |
data => '',
|
|
272 |
class => 'listrowempty',
|
|
273 |
colspan => $num_visible_columns,
|
|
274 |
},
|
|
275 |
);
|
|
276 |
|
268 |
277 |
# add sort and escape callback, this one we use for the add sub
|
269 |
278 |
$form->{callback} = $href .= "&sort=$form->{mainsort}";
|
270 |
279 |
|
... | ... | |
313 |
322 |
if ( $form->{l_headers_mainsort} eq "Y" && ( $idx == 0 or $ar->{ $form->{'mainsort'} } ne $form->{AR}->[$idx - 1]->{ $form->{'mainsort'} } )) {
|
314 |
323 |
my $headerrow = {
|
315 |
324 |
# use $emptyname for mainsort header if mainsort is empty
|
316 |
|
data => $ar->{$form->{'mainsort'}} || $locale->text('empty'),
|
317 |
|
class => "listmainsortheader",
|
|
325 |
data => $ar->{$form->{'mainsort'}} || $locale->text('empty'),
|
|
326 |
class => "listmainsortheader",
|
|
327 |
colspan => $num_visible_columns,
|
318 |
328 |
};
|
319 |
329 |
$report->add_data([ { description => $headerrow } ]);
|
320 |
330 |
|
... | ... | |
335 |
345 |
) {
|
336 |
346 |
my $headerrow = {
|
337 |
347 |
# if subsort name is defined, use that name in header, otherwise use $emptyname
|
338 |
|
data => $ar->{$form->{'subsort'}} || $locale->text('empty'),
|
339 |
|
class => "listsubsortheader",
|
|
348 |
data => $ar->{$form->{'subsort'}} || $locale->text('empty'),
|
|
349 |
class => "listsubsortheader",
|
|
350 |
colspan => $num_visible_columns,
|
340 |
351 |
};
|
341 |
352 |
$report->add_data([ { description => $headerrow } ]);
|
342 |
353 |
};
|
... | ... | |
382 |
393 |
map { $ar->{$_} = $form->format_amount(\%myconfig, $ar->{$_}, 3) } qw(weight);
|
383 |
394 |
map { $ar->{$_} = $form->format_amount(\%myconfig, $ar->{$_}, $form->{"decimalplaces"} )} qw(lastcost sellprice sellprice_total lastcost_total);
|
384 |
395 |
|
385 |
|
my $row = { };
|
386 |
|
|
387 |
|
foreach my $column (@columns) {
|
388 |
|
$row->{$column} = {
|
389 |
|
'data' => $ar->{$column},
|
390 |
|
'align' => $column_alignment{$column},
|
391 |
|
};
|
392 |
|
}
|
393 |
|
|
394 |
|
$row->{description}->{class} = 'listsortdescription';
|
395 |
|
|
396 |
|
$row->{invnumber}->{link} = build_std_url("script=is.pl", 'action=edit')
|
397 |
|
. "&id=" . E($ar->{id}) . "&callback=${callback}";
|
398 |
|
|
399 |
396 |
# Einzelzeilen nur zeigen wenn l_parts gesetzt ist, nützlich, wenn man nur
|
400 |
397 |
# Subtotals und Totals sehen möchte
|
401 |
|
my $row_set = $form->{l_parts} ? [ $row ] : [ ];
|
|
398 |
if ($form->{l_parts}) {
|
|
399 |
my %row = (
|
|
400 |
map { ($_ => { data => $ar->{$_}, align => $column_alignment{$_} }) } @columns
|
|
401 |
);
|
|
402 |
|
|
403 |
$row{invnumber}->{link} = build_std_url("script=is.pl", 'action=edit') . "&id=" . E($ar->{id}) . "&callback=${callback}";
|
|
404 |
|
|
405 |
$report->add_data(\%row);
|
|
406 |
}
|
402 |
407 |
|
403 |
408 |
# hier wird bei l_subtotal nicht differenziert zwischen mainsort und subsort
|
404 |
409 |
# macht man l_subtotal_mainsort aus wird l_subtotal_subsort auch nicht ausgeführt
|
405 |
|
if (($form->{l_subtotal_mainsort} eq 'Y')
|
|
410 |
if ( ($form->{l_subtotal_mainsort} eq 'Y')
|
|
411 |
&& ($form->{l_subtotal_subsort} eq 'Y')
|
406 |
412 |
&& (($idx == (scalar @{ $form->{AR} } - 1)) # last element always has a subtotal
|
407 |
413 |
|| ($ar->{ $form->{'subsort'} } ne $form->{AR}->[$idx + 1]->{ $form->{'subsort'} })
|
408 |
414 |
|| ($ar->{ $form->{'mainsort'} } ne $form->{AR}->[$idx + 1]->{ $form->{'mainsort'} })
|
409 |
415 |
)) { # if value that is sorted by changes, print subtotal
|
410 |
416 |
|
411 |
|
if ($form->{l_subtotal_subsort} eq 'Y') {
|
412 |
|
push @{ $row_set }, create_subtotal_row_invoice(\%subtotals2, \@columns, \%column_alignment, \@subtotal_columns, 'listsubsortsubtotal', $ar->{ $form->{'subsort'} }) ;
|
413 |
|
push @{ $row_set }, insert_empty_row() if $form->{l_parts} and $addemptylines;
|
414 |
|
};
|
|
417 |
$report->add_data(create_subtotal_row_invoice(\%subtotals2, \@columns, \%column_alignment, \@subtotal_columns, $form->{l_parts} ? 'listsubtotal' : undef, $ar->{ $form->{'subsort'} }));
|
|
418 |
$report->add_data({ %empty_row }) if $form->{l_parts} and $addemptylines;
|
415 |
419 |
}
|
416 |
420 |
|
417 |
421 |
# if last mainsort is reached or mainsort has changed, add mainsort subtotal and empty row
|
418 |
|
if (($form->{l_subtotal_mainsort} eq 'Y')
|
|
422 |
if ( ($form->{l_subtotal_mainsort} eq 'Y')
|
|
423 |
&& ($form->{l_subtotal_mainsort} eq 'Y')
|
|
424 |
&& ($form->{mainsort} ne $form->{subsort})
|
419 |
425 |
&& (($idx == (scalar @{ $form->{AR} } - 1)) # last element always has a subtotal
|
420 |
426 |
|| ($ar->{ $form->{'mainsort'} } ne $form->{AR}->[$idx + 1]->{ $form->{'mainsort'} })
|
421 |
427 |
)) { # if value that is sorted by changes, print subtotal
|
422 |
|
if ($form->{l_subtotal_mainsort} eq 'Y' and $form->{mainsort} ne $form->{subsort} ) {
|
423 |
428 |
# subtotal is overriden if mainsort and subsort are equal, don't print
|
424 |
429 |
# subtotal line even if it is selected
|
425 |
|
push @{ $row_set }, create_subtotal_row_invoice(\%subtotals1, \@columns, \%column_alignment, \@subtotal_columns, 'listmainsortsubtotal', $ar->{$form->{mainsort}});
|
426 |
|
push @{ $row_set }, insert_empty_row() if $addemptylines; # insert empty row after mainsort
|
427 |
|
};
|
|
430 |
$report->add_data(create_subtotal_row_invoice(\%subtotals1, \@columns, \%column_alignment, \@subtotal_columns, 'listsubtotal', $ar->{$form->{mainsort}}));
|
|
431 |
$report->add_data({ %empty_row }) if $addemptylines; # insert empty row after mainsort
|
428 |
432 |
}
|
429 |
433 |
|
430 |
|
$report->add_data($row_set);
|
431 |
|
|
432 |
434 |
$idx++;
|
433 |
435 |
}
|
434 |
436 |
if ( $form->{l_total} eq "Y" ) {
|
... | ... | |
440 |
442 |
$main::lxdebug->leave_sub();
|
441 |
443 |
}
|
442 |
444 |
|
443 |
|
|
444 |
|
sub insert_empty_row {
|
445 |
|
my $dummyrow;
|
446 |
|
$dummyrow->{description}->{data} = "";
|
447 |
|
my $dummyrowset = [ $dummyrow ];
|
448 |
|
return $dummyrow;
|
449 |
|
};
|
450 |
|
|
451 |
|
|
452 |
|
|
453 |
445 |
sub create_subtotal_row_invoice {
|
454 |
446 |
$main::lxdebug->enter_sub();
|
455 |
447 |
|
... | ... | |
459 |
451 |
my %myconfig = %main::myconfig;
|
460 |
452 |
my $locale = $main::locale;
|
461 |
453 |
|
462 |
|
my $row = { map { $_ => { 'data' => '', 'class' => $class, 'align' => $column_alignment->{$_}, } } @{ $columns } };
|
|
454 |
my $row = { map { $_ => { data => '', class => $class, align => $column_alignment->{$_}, } } @{ $columns } };
|
463 |
455 |
|
464 |
456 |
# set name as "empty" if no value is given, except if we are dealing with the
|
465 |
457 |
# absolute total, then just write "Total sum"
|
Verkaufsbericht besser an kivitendo-Farben anpassen
Fixt #2056.