Revision d8f857c7
Von Sven Schöling vor etwa 15 Jahren hinzugefügt
SL/AP.pm | ||
---|---|---|
390 | 390 |
my ($self, $myconfig, $form) = @_; |
391 | 391 |
|
392 | 392 |
# connect to database |
393 |
my $dbh = $form->dbconnect($myconfig);
|
|
393 |
my $dbh = $form->get_standard_dbh($myconfig);
|
|
394 | 394 |
|
395 | 395 |
my $query = |
396 | 396 |
qq|SELECT a.id, a.invnumber, a.transdate, a.duedate, a.amount, a.paid, | . |
... | ... | |
400 | 400 |
qq| e.name AS employee, | . |
401 | 401 |
qq| v.vendornumber, v.country, v.ustid, | . |
402 | 402 |
qq| tz.description AS taxzone, | . |
403 |
qq| pt.description AS payment_terms | . |
|
403 |
qq| pt.description AS payment_terms, | . |
|
404 |
qq{ ch.accno || ' -- ' || ch.description AS charts } . |
|
404 | 405 |
qq|FROM ap a | . |
405 | 406 |
qq|JOIN vendor v ON (a.vendor_id = v.id) | . |
406 | 407 |
qq|LEFT JOIN employee e ON (a.employee_id = e.id) | . |
407 | 408 |
qq|LEFT JOIN project pr ON (a.globalproject_id = pr.id) | . |
408 | 409 |
qq|LEFT JOIN tax_zones tz ON (tz.id = v.taxzone_id)| . |
409 |
qq|LEFT JOIN payment_terms pt ON (pt.id = v.payment_id)|; |
|
410 |
qq|LEFT JOIN payment_terms pt ON (pt.id = v.payment_id)| . |
|
411 |
qq|LEFT JOIN acc_trans at ON (at.trans_id = a.id)| . |
|
412 |
qq|INNER JOIN chart ch ON (ch.id = at.chart_id AND ch.link ~ 'AP[[:>:]]')|; |
|
410 | 413 |
|
411 | 414 |
my $where = ''; |
412 | 415 |
my @values; |
... | ... | |
474 | 477 |
|
475 | 478 |
$query .= " ORDER BY $sortorder"; |
476 | 479 |
|
477 |
my $sth = $dbh->prepare($query); |
|
478 |
$sth->execute(@values) || |
|
479 |
$form->dberror($query . " (" . join(", ", @values) . ")"); |
|
480 |
my @result = selectall_hashref_query($form, $dbh, $query, @values); |
|
480 | 481 |
|
481 |
$form->{AP} = []; |
|
482 |
while (my $ap = $sth->fetchrow_hashref(NAME_lc)) { |
|
483 |
push @{ $form->{AP} }, $ap; |
|
484 |
} |
|
485 |
|
|
486 |
$sth->finish; |
|
487 |
$dbh->disconnect; |
|
482 |
$form->{AP} = [ @result ]; |
|
488 | 483 |
|
489 | 484 |
$main::lxdebug->leave_sub(); |
490 | 485 |
} |
Auch abrufbar als: Unified diff
Einkaufsrechnungen Buchungskonto