X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/1b3ad7949687a373d832e0447f772e86363525f5..30e4d5bfd0fbb9c65c7ce4097da09ef9902406dd:/SL/Form.pm
diff --git a/SL/Form.pm b/SL/Form.pm
index f313999c3..6226017f2 100644
--- a/SL/Form.pm
+++ b/SL/Form.pm
@@ -697,11 +697,13 @@ sub header {
push @header, "" if -f $self->{favicon};
push @header, '',
'',
- '',
+ '',
'',
'',
'',
- '';
+ '',
+ '',
+ '';
push @header, $self->{javascript} if $self->{javascript};
push @header, map { $_->show_javascript } @{ $self->{AJAX} || [] };
push @header, "" if $self->{fokus};
@@ -1118,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');
@@ -1324,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;
}
@@ -1333,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;
@@ -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);