Revision a422993f
Von Sven Schöling vor mehr als 8 Jahren hinzugefügt
SL/Form.pm | ||
---|---|---|
1436 | 1436 |
undef $standard_dbh; |
1437 | 1437 |
} |
1438 | 1438 |
|
1439 |
$standard_dbh ||= SL::DB->create(undef, 'KIVITENDO')->dbh;
|
|
1439 |
$standard_dbh ||= SL::DB->client->dbh;
|
|
1440 | 1440 |
|
1441 | 1441 |
$main::lxdebug->leave_sub(2); |
1442 | 1442 |
|
... | ... | |
3036 | 3036 |
|
3037 | 3037 |
my ($i, $id); |
3038 | 3038 |
|
3039 |
my $dbh = $self->dbconnect_noauto($myconfig); |
|
3039 |
SL::DB->client->with_transaction(sub { |
|
3040 |
my $dbh = SL::DB->client->dbh; |
|
3040 | 3041 |
|
3041 |
my $query = qq|DELETE FROM status |
|
3042 |
WHERE (formname = ?) AND (trans_id = ?)|; |
|
3043 |
my $sth = prepare_query($self, $dbh, $query); |
|
3042 |
my $query = qq|DELETE FROM status
|
|
3043 |
WHERE (formname = ?) AND (trans_id = ?)|;
|
|
3044 |
my $sth = prepare_query($self, $dbh, $query);
|
|
3044 | 3045 |
|
3045 |
if ($self->{formname} =~ /(check|receipt)/) { |
|
3046 |
for $i (1 .. $self->{rowcount}) { |
|
3047 |
do_statement($self, $sth, $query, $self->{formname}, $self->{"id_$i"} * 1); |
|
3046 |
if ($self->{formname} =~ /(check|receipt)/) { |
|
3047 |
for $i (1 .. $self->{rowcount}) { |
|
3048 |
do_statement($self, $sth, $query, $self->{formname}, $self->{"id_$i"} * 1); |
|
3049 |
} |
|
3050 |
} else { |
|
3051 |
do_statement($self, $sth, $query, $self->{formname}, $self->{id}); |
|
3048 | 3052 |
} |
3049 |
} else { |
|
3050 |
do_statement($self, $sth, $query, $self->{formname}, $self->{id}); |
|
3051 |
} |
|
3052 |
$sth->finish(); |
|
3053 |
$sth->finish(); |
|
3053 | 3054 |
|
3054 |
my $printed = ($self->{printed} =~ /\Q$self->{formname}\E/) ? "1" : "0"; |
|
3055 |
my $emailed = ($self->{emailed} =~ /\Q$self->{formname}\E/) ? "1" : "0"; |
|
3055 |
my $printed = ($self->{printed} =~ /\Q$self->{formname}\E/) ? "1" : "0";
|
|
3056 |
my $emailed = ($self->{emailed} =~ /\Q$self->{formname}\E/) ? "1" : "0";
|
|
3056 | 3057 |
|
3057 |
my %queued = split / /, $self->{queued}; |
|
3058 |
my @values; |
|
3058 |
my %queued = split / /, $self->{queued};
|
|
3059 |
my @values;
|
|
3059 | 3060 |
|
3060 |
if ($self->{formname} =~ /(check|receipt)/) { |
|
3061 |
if ($self->{formname} =~ /(check|receipt)/) {
|
|
3061 | 3062 |
|
3062 |
# this is a check or receipt, add one entry for each lineitem |
|
3063 |
my ($accno) = split /--/, $self->{account}; |
|
3064 |
$query = qq|INSERT INTO status (trans_id, printed, spoolfile, formname, chart_id) |
|
3065 |
VALUES (?, ?, ?, ?, (SELECT c.id FROM chart c WHERE c.accno = ?))|; |
|
3066 |
@values = ($printed, $queued{$self->{formname}}, $self->{prinform}, $accno); |
|
3067 |
$sth = prepare_query($self, $dbh, $query); |
|
3063 |
# this is a check or receipt, add one entry for each lineitem
|
|
3064 |
my ($accno) = split /--/, $self->{account};
|
|
3065 |
$query = qq|INSERT INTO status (trans_id, printed, spoolfile, formname, chart_id)
|
|
3066 |
VALUES (?, ?, ?, ?, (SELECT c.id FROM chart c WHERE c.accno = ?))|;
|
|
3067 |
@values = ($printed, $queued{$self->{formname}}, $self->{prinform}, $accno);
|
|
3068 |
$sth = prepare_query($self, $dbh, $query);
|
|
3068 | 3069 |
|
3069 |
for $i (1 .. $self->{rowcount}) { |
|
3070 |
if ($self->{"checked_$i"}) { |
|
3071 |
do_statement($self, $sth, $query, $self->{"id_$i"}, @values); |
|
3070 |
for $i (1 .. $self->{rowcount}) { |
|
3071 |
if ($self->{"checked_$i"}) { |
|
3072 |
do_statement($self, $sth, $query, $self->{"id_$i"}, @values); |
|
3073 |
} |
|
3072 | 3074 |
} |
3073 |
} |
|
3074 |
$sth->finish(); |
|
3075 |
|
|
3076 |
} else { |
|
3077 |
$query = qq|INSERT INTO status (trans_id, printed, emailed, spoolfile, formname) |
|
3078 |
VALUES (?, ?, ?, ?, ?)|; |
|
3079 |
do_query($self, $dbh, $query, $self->{id}, $printed, $emailed, |
|
3080 |
$queued{$self->{formname}}, $self->{formname}); |
|
3081 |
} |
|
3075 |
$sth->finish(); |
|
3082 | 3076 |
|
3083 |
$dbh->commit; |
|
3084 |
$dbh->disconnect; |
|
3077 |
} else { |
|
3078 |
$query = qq|INSERT INTO status (trans_id, printed, emailed, spoolfile, formname) |
|
3079 |
VALUES (?, ?, ?, ?, ?)|; |
|
3080 |
do_query($self, $dbh, $query, $self->{id}, $printed, $emailed, |
|
3081 |
$queued{$self->{formname}}, $self->{formname}); |
|
3082 |
} |
|
3083 |
1; |
|
3084 |
}) or do { die SL::DB->client->error }; |
|
3085 | 3085 |
|
3086 | 3086 |
$main::lxdebug->leave_sub(); |
3087 | 3087 |
} |
... | ... | |
3167 | 3167 |
$main::lxdebug->enter_sub(); |
3168 | 3168 |
|
3169 | 3169 |
my $self = shift; |
3170 |
my $dbh = shift || $self->get_standard_dbh; |
|
3170 |
my $dbh = shift || SL::DB->client->dbh; |
|
3171 |
SL::DB->client->with_transaction(sub { |
|
3171 | 3172 |
|
3172 |
if(!exists $self->{employee_id}) { |
|
3173 |
&get_employee($self, $dbh); |
|
3174 |
} |
|
3175 |
|
|
3176 |
my $query = |
|
3177 |
qq|INSERT INTO history_erp (trans_id, employee_id, addition, what_done, snumbers) | . |
|
3178 |
qq|VALUES (?, (SELECT id FROM employee WHERE login = ?), ?, ?, ?)|; |
|
3179 |
my @values = (conv_i($self->{id}), $self->{login}, |
|
3180 |
$self->{addition}, $self->{what_done}, "$self->{snumbers}"); |
|
3181 |
do_query($self, $dbh, $query, @values); |
|
3173 |
if(!exists $self->{employee_id}) { |
|
3174 |
&get_employee($self, $dbh); |
|
3175 |
} |
|
3182 | 3176 |
|
3183 |
$dbh->commit; |
|
3177 |
my $query = |
|
3178 |
qq|INSERT INTO history_erp (trans_id, employee_id, addition, what_done, snumbers) | . |
|
3179 |
qq|VALUES (?, (SELECT id FROM employee WHERE login = ?), ?, ?, ?)|; |
|
3180 |
my @values = (conv_i($self->{id}), $self->{login}, |
|
3181 |
$self->{addition}, $self->{what_done}, "$self->{snumbers}"); |
|
3182 |
do_query($self, $dbh, $query, @values); |
|
3183 |
1; |
|
3184 |
}) or do { die SL::DB->client->error }; |
|
3184 | 3185 |
|
3185 | 3186 |
$main::lxdebug->leave_sub(); |
3186 | 3187 |
} |
Auch abrufbar als: Unified diff
Form: single-dbh (partiell)
standard_dbh->rollback fehlt noch