Revision 96670fe8
Von Moritz Bunkus vor etwa 8 Jahren hinzugefügt
SL/Controller/MassInvoiceCreatePrint.pm | ||
---|---|---|
56 | 56 |
} |
57 | 57 |
|
58 | 58 |
my $db = SL::DB::Invoice->new->db; |
59 |
my @invoices; |
|
59 | 60 |
|
60 |
if (!$db->do_transaction(sub { |
|
61 |
my @invoices; |
|
61 |
if (!$db->with_transaction(sub { |
|
62 | 62 |
foreach my $id (@sales_delivery_order_ids) { |
63 | 63 |
my $delivery_order = SL::DB::DeliveryOrder->new(id => $id)->load; |
64 | 64 |
|
... | ... | |
66 | 66 |
push @invoices, $invoice; |
67 | 67 |
} |
68 | 68 |
|
69 |
my $key = sprintf('%d-%d', Time::HiRes::gettimeofday()); |
|
70 |
$::auth->set_session_value("MassInvoiceCreatePrint::ids-${key}" => [ map { $_->id } @invoices ]); |
|
71 |
|
|
72 |
flash_later('info', t8('The invoices have been created. They\'re pre-selected below.')); |
|
73 |
$self->redirect_to(action => 'list_invoices', ids => $key); |
|
74 |
|
|
75 | 69 |
1; |
76 | 70 |
})) { |
77 | 71 |
$::lxdebug->message(LXDebug::WARN(), "Error: " . $db->error); |
78 | 72 |
$::form->error($db->error); |
79 | 73 |
} |
74 |
|
|
75 |
my $key = sprintf('%d-%d', Time::HiRes::gettimeofday()); |
|
76 |
$::auth->set_session_value("MassInvoiceCreatePrint::ids-${key}" => [ map { $_->id } @invoices ]); |
|
77 |
|
|
78 |
flash_later('info', t8('The invoices have been created. They\'re pre-selected below.')); |
|
79 |
$self->redirect_to(action => 'list_invoices', ids => $key); |
|
80 | 80 |
} |
81 | 81 |
|
82 | 82 |
sub action_list_invoices { |
Auch abrufbar als: Unified diff
»with_transaction« anstelle von »do_transaction« verwenden
Es sollte so selten wie möglich »do_transaction« verwndet werden, damit
man sich immer angewöhnt, »with_transaction« zu nutzen.
Hintergründe und Unterschiede zwischen den beiden Funktionen sind in der
Dokumentation von SL/DB.pm beschrieben.