}
my $db = SL::DB::Invoice->new->db;
+ my @invoices;
- if (!$db->do_transaction(sub {
- my @invoices;
+ if (!$db->with_transaction(sub {
foreach my $id (@sales_delivery_order_ids) {
my $delivery_order = SL::DB::DeliveryOrder->new(id => $id)->load;
push @invoices, $invoice;
}
- my $key = sprintf('%d-%d', Time::HiRes::gettimeofday());
- $::auth->set_session_value("MassInvoiceCreatePrint::ids-${key}" => [ map { $_->id } @invoices ]);
-
- flash_later('info', t8('The invoices have been created. They\'re pre-selected below.'));
- $self->redirect_to(action => 'list_invoices', ids => $key);
-
1;
})) {
$::lxdebug->message(LXDebug::WARN(), "Error: " . $db->error);
$::form->error($db->error);
}
+
+ my $key = sprintf('%d-%d', Time::HiRes::gettimeofday());
+ $::auth->set_session_value("MassInvoiceCreatePrint::ids-${key}" => [ map { $_->id } @invoices ]);
+
+ flash_later('info', t8('The invoices have been created. They\'re pre-selected below.'));
+ $self->redirect_to(action => 'list_invoices', ids => $key);
}
sub action_list_invoices {
invoice_ids => [ ],
conversion_errors => [ ],
print_errors => [ ],
+ session_id => $::auth->get_session_id,
)->update_next_run_at;
}
my $printer = SL::DB::Printer->new(id => $params{printer_id})->load;
- my $command = SL::Template::create(type => 'ShellCommand', form => Form->new(''))->parse($printer->printer_command);
-
- open my $out, '|-', $command or die $!;
- binmode $out;
- print $out $merged_pdf;
- close $out;
+ $printer->print_document(content => $merged_pdf);
flash_later('info', t8('The documents have been sent to the printer \'#1\'.', $printer->printer_description));
return $self->redirect_to(action => 'list_invoices', printer_id => $params{printer_id});