package BP;
use SL::DBUtils;
+use SL::DB;
use strict;
$sth->finish;
}
- $dbh->disconnect;
-
$main::lxdebug->leave_sub();
}
my ($self, $myconfig, $form) = @_;
# connect to database
- my $dbh = $form->dbconnect($myconfig);
+ my $dbh = SL::DB->client->dbh;
my $query =
qq|SELECT DISTINCT ON (s.chart_id) c.accno, c.description | .
}
$sth->finish;
- $dbh->disconnect;
$main::lxdebug->leave_sub();
}
my ($self, $myconfig, $form) = @_;
- # connect to database
- my $dbh = $form->dbconnect($myconfig);
+ my $dbh = SL::DB->client->dbh;
my ($query, $arap, @values);
my $invnumber = "invnumber";
}
$sth->finish;
- $dbh->disconnect;
$main::lxdebug->leave_sub();
}
my $spool = $::lx_office_conf{paths}->{spool};
- # connect to database, turn AutoCommit off
- my $dbh = $form->dbconnect_noauto($myconfig);
+ SL::DB->client->with_transaction(sub {
+ my $dbh = SL::DB->client->dbh;
- my $query;
+ my $query;
- if ($form->{type} =~ /(check|receipt)/) {
- $query = qq|DELETE FROM status WHERE spoolfile = ?|;
- } else {
- $query =
- qq|UPDATE status SET spoolfile = NULL, printed = '1' | .
- qq|WHERE spoolfile = ?|;
- }
- my $sth = $dbh->prepare($query) || $form->dberror($query);
-
- foreach my $i (1 .. $form->{rowcount}) {
- if ($form->{"checked_$i"}) {
- $sth->execute($form->{"spoolfile_$i"}) || $form->dberror($query);
- $sth->finish;
+ if ($form->{type} =~ /(check|receipt)/) {
+ $query = qq|DELETE FROM status WHERE spoolfile = ?|;
+ } else {
+ $query =
+ qq|UPDATE status SET spoolfile = NULL, printed = '1' | .
+ qq|WHERE spoolfile = ?|;
}
- }
+ my $sth = $dbh->prepare($query) || $form->dberror($query);
- # commit
- my $rc = $dbh->commit;
- $dbh->disconnect;
+ foreach my $i (1 .. $form->{rowcount}) {
+ if ($form->{"checked_$i"}) {
+ $sth->execute($form->{"spoolfile_$i"}) || $form->dberror($query);
+ $sth->finish;
+ }
+ }
- if ($rc) {
foreach my $i (1 .. $form->{rowcount}) {
if ($form->{"checked_$i"}) {
unlink(qq|$spool/$form->{"spoolfile_$i"}|);
}
}
- }
+ });
$main::lxdebug->leave_sub();
-
- return $rc;
+ return 1;
}
sub print_spool {
my $spool = $::lx_office_conf{paths}->{spool};
# connect to database
- my $dbh = $form->dbconnect($myconfig);
+ my $dbh = SL::DB->client->dbh;
my $query =
qq|UPDATE status SET printed = '1' | .
}
}
- $dbh->disconnect;
-
$main::lxdebug->leave_sub();
}