X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FForm.pm;h=a5c2abec9c2fa668dfdfcace3b82416def13f079;hb=8add0ccd27ab0ff17256b74dccd1f761c0d09182;hp=e44f3977d6f3f8d33b7497f12b582591114a1442;hpb=7274f9c8e8c61b00ff7a4e2bad6accec85015a73;p=kivitendo-erp.git diff --git a/SL/Form.pm b/SL/Form.pm index e44f3977d..a5c2abec9 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -251,6 +251,7 @@ sub new { my $self = {}; + no warnings 'once'; if ($LXDebug::watch_form) { require SL::Watchdog; tie %{ $self }, 'SL::Watchdog'; @@ -700,7 +701,9 @@ sub header { '', '', '', - ''; + '', + '', + ''; push @header, $self->{javascript} if $self->{javascript}; push @header, map { $_->show_javascript } @{ $self->{AJAX} || [] }; push @header, "" if $self->{fokus}; @@ -845,8 +848,8 @@ sub _prepare_html_template { $additional_params->{"conf_payments_changeable"} = $::lx_office_conf{features}->{payments_changeable}; $additional_params->{"INSTANCE_CONF"} = $::instance_conf; - if (%main::debug_options) { - map { $additional_params->{'DEBUG_' . uc($_)} = $main::debug_options{$_} } keys %main::debug_options; + if (my $debug_options = $::lx_office_conf{debug}{options}) { + map { $additional_params->{'DEBUG_' . uc($_)} = $debug_options->{$_} } keys %$debug_options; } if ($main::auth && $main::auth->{RIGHTS} && $main::auth->{RIGHTS}->{$self->{login}}) { @@ -1117,8 +1120,7 @@ sub format_amount_units { return ''; } - AM->retrieve_all_units(); - my $all_units = $main::all_units; + my $all_units = AM->retrieve_all_units; if (('' eq ref $conv_units) && ($conv_units =~ /convertible/)) { $conv_units = AM->convertible_units($all_units, $part_unit_name, $conv_units eq 'convertible_not_smaller'); @@ -1323,7 +1325,7 @@ sub parse_template { if ($self->{OUT}) { open(OUT, ">", $self->{OUT}) or $self->error("$self->{OUT} : $!"); } else { - open(OUT, ">&", \*STDOUT) or $self->error("STDOUT : $!"); + *OUT = ($::dispatcher->get_standard_filehandles)[1]; $self->header; } @@ -1332,7 +1334,7 @@ sub parse_template { $self->error("$self->{IN} : " . $template->get_error()); } - close OUT; + close OUT if $self->{OUT}; if ($self->{media} eq 'file') { copy(join('/', $self->{cwd}, $userspath, $self->{tmpfile}), $out =~ m|^/| ? $out : join('/', $self->{cwd}, $out)) if $template->uses_temp_file; @@ -1410,6 +1412,7 @@ sub parse_template { if ($self->{OUT}) { open OUT, '>', $self->{OUT} or $self->error($self->cleanup . "$self->{OUT} : $!"); print OUT while ; + close OUT; seek IN, 0, 0; } else { @@ -1424,10 +1427,8 @@ Content-Length: $numbytes |; - open(OUT, ">&", \*STDOUT) or $self->error($self->cleanup . "$!: STDOUT"); - $::locale->with_raw_io(*OUT, sub { print while }); + $::locale->with_raw_io(\*STDOUT, sub { print while }); } - close OUT; } close(IN); @@ -2887,11 +2888,28 @@ sub create_links { } # now get the account numbers - $query = qq|SELECT c.accno, c.description, c.link, c.taxkey_id, tk.tax_id - FROM chart c, taxkeys tk - WHERE (c.link LIKE ?) AND (c.id = tk.chart_id) AND tk.id = - (SELECT id FROM taxkeys WHERE (taxkeys.chart_id = c.id) AND (startdate <= $transdate) ORDER BY startdate DESC LIMIT 1) - ORDER BY c.accno|; +# $query = qq|SELECT c.accno, c.description, c.link, c.taxkey_id, tk.tax_id +# FROM chart c, taxkeys tk +# WHERE (c.link LIKE ?) AND (c.id = tk.chart_id) AND tk.id = +# (SELECT id FROM taxkeys WHERE (taxkeys.chart_id = c.id) AND (startdate <= $transdate) ORDER BY startdate DESC LIMIT 1) +# ORDER BY c.accno|; + +# same query as above, but without expensive subquery for each row. about 80% faster + $query = qq| + SELECT c.accno, c.description, c.link, c.taxkey_id, tk2.tax_id + FROM chart c + -- find newest entries in taxkeys + INNER JOIN ( + SELECT chart_id, MAX(startdate) AS startdate + FROM taxkeys + WHERE (startdate <= $transdate) + GROUP BY chart_id + ) tk ON (c.id = tk.chart_id) + -- and load all of those entries + INNER JOIN taxkeys tk2 + ON (tk.chart_id = tk2.chart_id AND tk.startdate = tk2.startdate) + WHERE (c.link LIKE ?) + ORDER BY c.accno|; $sth = $dbh->prepare($query); @@ -2950,6 +2968,9 @@ sub create_links { $self->{$key} = $ref->{$key}; } + # remove any trailing whitespace + $self->{currency} =~ s/\s*$//; + my $transdate = "current_date"; if ($self->{transdate}) { $transdate = $dbh->quote($self->{transdate}); @@ -3126,6 +3147,9 @@ sub lastname_used { map { $self->{$_} = $ref->{$_} } values %column_map; + # remove any trailing whitespace + $self->{currency} =~ s/\s*$// if $self->{currency}; + $main::lxdebug->leave_sub(); }