X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/875f08f3a3e043b19a874e3fa3530d777017a754..b735f45033d8daef70ee2c82365a86cc06281f4c:/SL/AP.pm diff --git a/SL/AP.pm b/SL/AP.pm index 4187c72cf..6bc1095b4 100644 --- a/SL/AP.pm +++ b/SL/AP.pm @@ -390,7 +390,7 @@ sub ap_transactions { my ($self, $myconfig, $form) = @_; # connect to database - my $dbh = $form->dbconnect($myconfig); + my $dbh = $form->get_standard_dbh($myconfig); my $query = qq|SELECT a.id, a.invnumber, a.transdate, a.duedate, a.amount, a.paid, | . @@ -400,7 +400,14 @@ sub ap_transactions { qq| e.name AS employee, | . qq| v.vendornumber, v.country, v.ustid, | . qq| tz.description AS taxzone, | . - qq| pt.description AS payment_terms | . + qq| pt.description AS payment_terms, | . + qq{ ( SELECT ch.accno || ' -- ' || ch.description + FROM acc_trans at + LEFT JOIN chart ch ON ch.id = at.chart_id + WHERE ch.link ~ 'AP[[:>:]]' + AND at.trans_id = a.id + LIMIT 1 + ) AS charts } . qq|FROM ap a | . qq|JOIN vendor v ON (a.vendor_id = v.id) | . qq|LEFT JOIN employee e ON (a.employee_id = e.id) | . @@ -474,17 +481,9 @@ sub ap_transactions { $query .= " ORDER BY $sortorder"; - my $sth = $dbh->prepare($query); - $sth->execute(@values) || - $form->dberror($query . " (" . join(", ", @values) . ")"); + my @result = selectall_hashref_query($form, $dbh, $query, @values); - $form->{AP} = []; - while (my $ap = $sth->fetchrow_hashref(NAME_lc)) { - push @{ $form->{AP} }, $ap; - } - - $sth->finish; - $dbh->disconnect; + $form->{AP} = [ @result ]; $main::lxdebug->leave_sub(); }