From 6bd3193933475b0510001cca878328c37842e0a7 Mon Sep 17 00:00:00 2001 From: einhverfr Date: Fri, 3 Nov 2006 01:03:22 +0000 Subject: RP.pm progress git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@471 4979c152-3d1c-0410-bac9-87ea11338e46 --- LedgerSMB/RP.pm | 81 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 42 insertions(+), 39 deletions(-) (limited to 'LedgerSMB') diff --git a/LedgerSMB/RP.pm b/LedgerSMB/RP.pm index f6f848d4..71432f58 100755 --- a/LedgerSMB/RP.pm +++ b/LedgerSMB/RP.pm @@ -1654,59 +1654,62 @@ sub aging { sub get_customer { - my ($self, $myconfig, $form) = @_; + my ($self, $myconfig, $form) = @_; - # connect to database - my $dbh = $form->dbconnect($myconfig); + my $dbh = $form->{dbh}; - my $query = qq|SELECT name, email, cc, bcc - FROM $form->{ct} ct - WHERE ct.id = $form->{"$form->{ct}_id"}|; - ($form->{$form->{ct}}, $form->{email}, $form->{cc}, $form->{bcc}) = $dbh->selectrow_array($query); + my $query = qq| + SELECT name, email, cc, bcc FROM $form->{ct} ct + WHERE ct.id = ?|; + $sth = $dbh->prepare($query); + $sth->execute($form->{"$form->{ct}_id"}); + ($form->{$form->{ct}}, $form->{email}, $form->{cc}, $form->{bcc}) + = $sth->fetchrow_array(); - $dbh->disconnect; + $dbh->commit; } sub get_taxaccounts { - my ($self, $myconfig, $form) = @_; + my ($self, $myconfig, $form) = @_; - # connect to database - my $dbh = $form->dbconnect($myconfig); - my $ARAP = uc $form->{db}; + my $dbh = $form->{dbh}; + my $ARAP = uc $form->{db}; - # get tax accounts - my $query = qq|SELECT DISTINCT c.accno, c.description - FROM chart c - JOIN tax t ON (c.id = t.chart_id) - WHERE c.link LIKE '%${ARAP}_tax%' - ORDER BY c.accno|; - my $sth = $dbh->prepare($query); - $sth->execute || $form->dberror; + # get tax accounts + my $query = qq| + SELECT DISTINCT c.accno, c.description + FROM chart c + JOIN tax t ON (c.id = t.chart_id) + WHERE c.link LIKE '%${ARAP}_tax%' + ORDER BY c.accno|; + my $sth = $dbh->prepare($query); + $sth->execute || $form->dberror; - my $ref = (); - while ($ref = $sth->fetchrow_hashref(NAME_lc) ) { - push @{ $form->{taxaccounts} }, $ref; - } - $sth->finish; + my $ref = (); + while ($ref = $sth->fetchrow_hashref(NAME_lc) ) { + push @{ $form->{taxaccounts} }, $ref; + } + $sth->finish; - # get gifi tax accounts - my $query = qq|SELECT DISTINCT g.accno, g.description - FROM gifi g - JOIN chart c ON (c.gifi_accno= g.accno) - JOIN tax t ON (c.id = t.chart_id) - WHERE c.link LIKE '%${ARAP}_tax%' - ORDER BY accno|; - my $sth = $dbh->prepare($query); - $sth->execute || $form->dberror; + # get gifi tax accounts + my $query = qq| + SELECT DISTINCT g.accno, g.description + FROM gifi g + JOIN chart c ON (c.gifi_accno= g.accno) + JOIN tax t ON (c.id = t.chart_id) + WHERE c.link LIKE '%${ARAP}_tax%' + ORDER BY accno|; + my $sth = $dbh->prepare($query); + $sth->execute || $form->dberror; - while ($ref = $sth->fetchrow_hashref(NAME_lc) ) { - push @{ $form->{gifi_taxaccounts} }, $ref; - } - $sth->finish; + while ($ref = $sth->fetchrow_hashref(NAME_lc) ) { + push @{ $form->{gifi_taxaccounts} }, $ref; + } + $sth->finish; - $dbh->disconnect; + $dbh->commit; } -- cgit v1.2.3