Revision 2df28e2b
Von Sven Schöling vor mehr als 8 Jahren hinzugefügt
SL/DO.pm | ||
---|---|---|
47 | 47 |
use SL::RecordLinks; |
48 | 48 |
use SL::IC; |
49 | 49 |
use SL::TransNumber; |
50 |
use SL::DB; |
|
50 | 51 |
use SL::Util qw(trim); |
51 | 52 |
|
52 | 53 |
use strict; |
... | ... | |
260 | 261 |
} |
261 | 262 |
|
262 | 263 |
sub save { |
264 |
my ($self) = @_; |
|
265 |
$main::lxdebug->enter_sub(); |
|
266 |
|
|
267 |
my $rc = SL::DB->client->with_transaction(\&_save, $self); |
|
268 |
|
|
269 |
$main::lxdebug->leave_sub(); |
|
270 |
return $rc; |
|
271 |
} |
|
272 |
|
|
273 |
sub _save { |
|
263 | 274 |
$main::lxdebug->enter_sub(); |
264 | 275 |
|
265 | 276 |
my ($self) = @_; |
... | ... | |
267 | 278 |
my $myconfig = \%main::myconfig; |
268 | 279 |
my $form = $main::form; |
269 | 280 |
|
270 |
# connect to database, turn off autocommit |
|
271 |
my $dbh = $form->get_standard_dbh($myconfig); |
|
281 |
my $dbh = SL::DB->client->dbh; |
|
272 | 282 |
my $restricter = SL::HTML::Restrict->create; |
273 | 283 |
|
274 | 284 |
my ($query, @values, $sth, $null); |
... | ... | |
538 | 548 |
'type' => $form->{type} eq 'sales_delivery_order' ? 'sales' : 'purchase', |
539 | 549 |
'dbh' => $dbh,); |
540 | 550 |
|
541 |
my $rc = $dbh->commit(); |
|
542 |
|
|
543 | 551 |
$form->{saved_donumber} = $form->{donumber}; |
544 | 552 |
$form->{saved_ordnumber} = $form->{ordnumber}; |
545 | 553 |
$form->{saved_cusordnumber} = $form->{cusordnumber}; |
... | ... | |
548 | 556 |
|
549 | 557 |
$main::lxdebug->leave_sub(); |
550 | 558 |
|
551 |
return $rc;
|
|
559 |
return 1;
|
|
552 | 560 |
} |
553 | 561 |
|
554 | 562 |
sub mark_orders_if_delivered { |
... | ... | |
562 | 570 |
my $myconfig = \%main::myconfig; |
563 | 571 |
my $form = $main::form; |
564 | 572 |
|
565 |
my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); |
|
573 |
SL::DB->client->with_transaction(sub { |
|
574 |
my $dbh = $params{dbh} || SL::DB->client->dbh; |
|
566 | 575 |
|
567 |
my %ship = $self->get_shipped_qty('dbh' => $dbh, 'do_id' => $form->{id}, 'delivered' => 1); |
|
576 |
my %ship = $self->get_shipped_qty('dbh' => $dbh, 'do_id' => $form->{id}, 'delivered' => 1);
|
|
568 | 577 |
|
569 |
foreach my $oe_id (keys %ship) { |
|
570 |
do_query($form, $dbh,"UPDATE oe SET delivered = ".($ship{$oe_id}->{delivered}?"TRUE":"FALSE")." WHERE id = ?", $oe_id); |
|
571 |
} |
|
572 |
$dbh->commit() if (!$params{dbh});
|
|
578 |
foreach my $oe_id (keys %ship) {
|
|
579 |
do_query($form, $dbh,"UPDATE oe SET delivered = ".($ship{$oe_id}->{delivered}?"TRUE":"FALSE")." WHERE id = ?", $oe_id);
|
|
580 |
}
|
|
581 |
}); |
|
573 | 582 |
|
574 | 583 |
$main::lxdebug->leave_sub(); |
575 | 584 |
} |
... | ... | |
590 | 599 |
my $myconfig = \%main::myconfig; |
591 | 600 |
my $form = $main::form; |
592 | 601 |
|
593 |
my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); |
|
602 |
SL::DB->client->with_transaction(sub { |
|
603 |
my $dbh = $params{dbh} || SL::DB->client->dbh; |
|
594 | 604 |
|
595 |
my $query = qq|UPDATE delivery_orders SET closed = TRUE WHERE id IN (| . join(', ', ('?') x scalar(@{ $params{ids} })) . qq|)|; |
|
605 |
my $query = qq|UPDATE delivery_orders SET closed = TRUE WHERE id IN (| . join(', ', ('?') x scalar(@{ $params{ids} })) . qq|)|;
|
|
596 | 606 |
|
597 |
do_query($form, $dbh, $query, map { conv_i($_) } @{ $params{ids} }); |
|
607 |
do_query($form, $dbh, $query, map { conv_i($_) } @{ $params{ids} }); |
|
608 |
}); |
|
598 | 609 |
|
599 |
$dbh->commit() unless ($params{dbh}); |
|
600 | 610 |
$form->new_lastmtime('delivery_orders'); |
601 | 611 |
|
602 | 612 |
$main::lxdebug->leave_sub(); |
Auch abrufbar als: Unified diff
DO: single-dbh