Revision cd002768
Von Sven Schöling vor mehr als 8 Jahren hinzugefügt
SL/IC.pm | ||
---|---|---|
43 | 43 |
use SL::HTML::Restrict; |
44 | 44 |
use SL::TransNumber; |
45 | 45 |
use SL::Util qw(trim); |
46 |
use SL::DB; |
|
46 | 47 |
|
47 | 48 |
use strict; |
48 | 49 |
|
... | ... | |
236 | 237 |
sub _save { |
237 | 238 |
my ($self, $myconfig, $form) = @_; |
238 | 239 |
my @values; |
239 |
# connect to database, turn off AutoCommit |
|
240 |
|
|
240 | 241 |
my $dbh = SL::DB->client->dbh; |
241 | 242 |
my $restricter = SL::HTML::Restrict->create; |
242 | 243 |
|
... | ... | |
583 | 584 |
} |
584 | 585 |
|
585 | 586 |
sub delete { |
587 |
my ($self, $myconfig, $form) = @_; |
|
586 | 588 |
$main::lxdebug->enter_sub(); |
587 | 589 |
|
590 |
my $rc = SL::DB->client->with_transaction(\&_delete, $self, $myconfig, $form); |
|
591 |
|
|
592 |
$main::lxdebug->leave_sub(); |
|
593 |
return $rc; |
|
594 |
} |
|
595 |
|
|
596 |
sub _delete { |
|
588 | 597 |
my ($self, $myconfig, $form) = @_; |
589 | 598 |
my @values = (conv_i($form->{id})); |
590 |
# connect to database, turn off AutoCommit |
|
591 |
my $dbh = $form->get_standard_dbh; |
|
592 | 599 |
|
593 | 600 |
my %columns = ( "assembly" => "id", "parts" => "id" ); |
594 | 601 |
|
595 | 602 |
for my $table (qw(prices makemodel inventory assembly translation parts)) { |
596 | 603 |
my $column = defined($columns{$table}) ? $columns{$table} : "parts_id"; |
597 |
do_query($form, $dbh, qq|DELETE FROM $table WHERE $column = ?|, @values);
|
|
604 |
do_query($form, SL::DB->client->dbh, qq|DELETE FROM $table WHERE $column = ?|, @values);
|
|
598 | 605 |
} |
599 | 606 |
|
600 |
# commit |
|
601 |
my $rc = $dbh->commit; |
|
602 |
|
|
603 |
$main::lxdebug->leave_sub(); |
|
604 |
|
|
605 |
return $rc; |
|
607 |
return 1; |
|
606 | 608 |
} |
607 | 609 |
|
608 | 610 |
sub assembly_item { |
... | ... | |
640 | 642 |
$where .= qq| ORDER BY p.description|; |
641 | 643 |
} |
642 | 644 |
|
643 |
# connect to database |
|
644 |
my $dbh = $form->get_standard_dbh; |
|
645 |
|
|
646 | 645 |
my $query = |
647 | 646 |
qq|SELECT p.id, p.partnumber, p.description, p.sellprice, |
648 | 647 |
p.weight, p.onhand, p.unit, pg.partsgroup, p.lastcost, |
... | ... | |
651 | 650 |
LEFT JOIN partsgroup pg ON (p.partsgroup_id = pg.id) |
652 | 651 |
LEFT JOIN price_factors pfac ON pfac.id = p.price_factor_id |
653 | 652 |
WHERE $where|; |
654 |
$form->{item_list} = selectall_hashref_query($form, $dbh, $query, @values);
|
|
653 |
$form->{item_list} = selectall_hashref_query($form, SL::DB->client->dbh, $query, @values);
|
|
655 | 654 |
|
656 | 655 |
$main::lxdebug->leave_sub(); |
657 | 656 |
} |
... | ... | |
1227 | 1226 |
} |
1228 | 1227 |
|
1229 | 1228 |
sub update_prices { |
1229 |
my ($self, $myconfig, $form) = @_; |
|
1230 | 1230 |
$main::lxdebug->enter_sub(); |
1231 | 1231 |
|
1232 |
my $num_updated = SL::DB->client->with_transaction(\&_update_prices, $self, $myconfig, $form); |
|
1233 |
|
|
1234 |
$main::lxdebug->leave_sub(); |
|
1235 |
return $num_updated; |
|
1236 |
} |
|
1237 |
|
|
1238 |
sub _update_prices { |
|
1232 | 1239 |
my ($self, $myconfig, $form) = @_; |
1233 | 1240 |
|
1234 | 1241 |
my ($where, @where_values) = $self->_create_filter_for_priceupdate(); |
1235 | 1242 |
my $num_updated = 0; |
1236 | 1243 |
|
1237 | 1244 |
# connect to database |
1238 |
my $dbh = $form->get_standard_dbh;
|
|
1245 |
my $dbh = SL::DB->client->dbh;
|
|
1239 | 1246 |
|
1240 | 1247 |
for my $column (qw(sellprice listprice)) { |
1241 | 1248 |
next if ($form->{$column} eq ""); |
... | ... | |
1295 | 1302 |
$sth_add->finish(); |
1296 | 1303 |
$sth_multiply->finish(); |
1297 | 1304 |
|
1298 |
my $rc= $dbh->commit; |
|
1299 |
|
|
1300 |
$main::lxdebug->leave_sub(); |
|
1301 |
|
|
1302 | 1305 |
return $num_updated; |
1303 | 1306 |
} |
1304 | 1307 |
|
Auch abrufbar als: Unified diff
IC: single-dbh für delete und update_prices