X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FTemplate.pm;h=4a59273a06564bc329157352a000a785faf27c48;hb=602e46bca5192e4df0d2fa9d3564f61a8f82496c;hp=8300458b7960d4133b520e779a5483515bab12ab;hpb=526173c2827375e04540a626a339d249a3648239;p=kivitendo-erp.git diff --git a/SL/Template.pm b/SL/Template.pm index 8300458b7..4a59273a0 100644 --- a/SL/Template.pm +++ b/SL/Template.pm @@ -169,24 +169,27 @@ sub parse_foreach { my $ary = $self->_get_loop_variable($var, 1, @indices); - my $sum = 0; - my $current_page = 1; + my $sum = 0; + my $current_page = 1; my ($current_line, $corrent_row) = (0, 1); + my $description_array = $self->_get_loop_variable("description", 1); + my $longdescription_array = $self->_get_loop_variable("longdescription", 1); + my $linetotal_array = $self->_get_loop_variable("linetotal", 1); + + $form->{TEMPLATE_ARRAYS}->{cumulatelinetotal} = []; for (my $i = 0; $i < scalar(@{$ary}); $i++) { - $form->{"__first__"} = $i == 0; - $form->{"__last__"} = ($i + 1) == scalar(@{$ary}); - $form->{"__odd__"} = (($i + 1) % 2) == 1; + $form->{"__first__"} = $i == 1; + $form->{"__last__"} = ($i + 1) == scalar(@{$ary}); + $form->{"__odd__"} = (($i + 1) % 2) == 1; $form->{"__counter__"} = $i + 1; - if ((scalar(@{$form->{"description"}}) == scalar(@{$ary})) && - $self->{"chars_per_line"}) { - my $lines = - int(length($form->{"description"}->[$i]) / $self->{"chars_per_line"}); + if (scalar @{$description_array} == scalar @{$ary} && $self->{"chars_per_line"} != 0) { + my $lines = int(length($description_array->[$i]) / $self->{"chars_per_line"}); my $lpp; - $form->{"description"}->[$i] =~ s/(\\newline\s?)*$//; - my $_description = $form->{"description"}->[$i]; + $description_array->[$i] =~ s/(\\newline\s?)*$//; + my $_description = $description_array->[$i]; while ($_description =~ /\\newline/) { $lines++; $_description =~ s/\\newline//; @@ -200,7 +203,7 @@ sub parse_foreach { } # Yes we need a manual page break -- or the user has forced one - if ((($current_line + $lines) > $lpp) || ($form->{"description"}->[$i] =~ //) || ($form->{"longdescription"}->[$i] =~ //)) { + if ((($current_line + $lines) > $lpp) || ($description_array->[$i] =~ //) || ($longdescription_array->[$i] =~ //)) { my $pb = $self->{"pagebreak_block"}; # replace the special variables <%sumcarriedforward%> @@ -219,12 +222,12 @@ sub parse_foreach { } $current_line += $lines; } - if ($i < scalar(@{$form->{"linetotal"}})) { - $sum += $form->parse_amount($self->{"myconfig"}, - $form->{"linetotal"}->[$i]); + + if ($i < scalar(@{$linetotal_array})) { + $sum += $form->parse_amount($self->{"myconfig"}, $linetotal_array->[$i]); } - $form->{"cumulatelinetotal"}[$i] = $form->format_amount($self->{"myconfig"}, $sum, 2); + $form->{TEMPLATE_ARRAYS}->{cumulatelinetotal}->[$i] = $form->format_amount($self->{"myconfig"}, $sum, 2); my $new_text = $self->parse_block($text, (@indices, $i)); return undef unless (defined($new_text)); @@ -523,8 +526,10 @@ sub convert_to_postscript { $form->{tmpfile} =~ s/\Q$userspath\E\///g; + my $latex = $self->_get_latex_path(); + for (my $run = 1; $run <= 2; $run++) { - system("latex --interaction=nonstopmode $form->{tmpfile} " . + system("${latex} --interaction=nonstopmode $form->{tmpfile} " . "> $form->{tmpfile}.err"); if ($?) { $self->{"error"} = $form->cleanup(); @@ -562,8 +567,10 @@ sub convert_to_pdf { $form->{tmpfile} =~ s/\Q$userspath\E\///g; + my $latex = $self->_get_latex_path(); + for (my $run = 1; $run <= 2; $run++) { - system("pdflatex --interaction=nonstopmode $form->{tmpfile} " . + system("${latex} --interaction=nonstopmode $form->{tmpfile} " . "> $form->{tmpfile}.err"); if ($?) { $self->{"error"} = $form->cleanup(); @@ -577,6 +584,10 @@ sub convert_to_pdf { $self->cleanup(); } +sub _get_latex_path { + return $main::latex_bin || 'pdflatex'; +} + sub get_mime_type() { my ($self) = @_;