Revision 54ce5144
Von Martin Helmling vor fast 8 Jahren hinzugefügt
SL/Controller/MassInvoiceCreatePrint.pm | ||
---|---|---|
13 | 13 |
use SL::DB::DeliveryOrder; |
14 | 14 |
use SL::DB::Order; |
15 | 15 |
use SL::DB::Printer; |
16 |
use SL::Helper::MassPrintCreatePDF qw(:all); |
|
16 | 17 |
use SL::Helper::CreatePDF qw(:all); |
17 | 18 |
use SL::Helper::Flash; |
18 | 19 |
use SL::Locale::String; |
19 | 20 |
use SL::SessionFile; |
20 | 21 |
use SL::System::TaskServer; |
21 |
|
|
22 | 22 |
use Rose::Object::MakeMethods::Generic |
23 | 23 |
( |
24 | 24 |
'scalar --get_set_init' => [ qw(invoice_models invoice_ids sales_delivery_order_models printers default_printer_id today) ], |
... | ... | |
130 | 130 |
record_ids => [ map { $_->id } @records[0..$num - 1] ], |
131 | 131 |
printer_id => $::form->{printer_id}, |
132 | 132 |
copy_printer_id => $::form->{copy_printer_id}, |
133 |
bothsided => ($::form->{bothsided}?1:0), |
|
133 | 134 |
transdate => $::form->{transdate}, |
134 | 135 |
status => SL::BackgroundJob::MassRecordCreationAndPrinting->WAITING_FOR_EXECUTION(), |
135 | 136 |
num_created => 0, |
... | ... | |
172 | 173 |
$sfile->fh->close; |
173 | 174 |
|
174 | 175 |
my $type = 'Invoices'; |
175 |
my $file_name = t8($type) . '-' . DateTime->today_local->strftime('%Y%m%d%H%M%S') . '.pdf';
|
|
176 |
my $file_name = t8($type) . '-' . DateTime->now_local->strftime('%Y%m%d%H%M%S') . '.pdf';
|
|
176 | 177 |
$file_name =~ s{[^\w\.]+}{_}g; |
177 | 178 |
|
178 | 179 |
return $self->send_file( |
... | ... | |
187 | 188 |
# |
188 | 189 |
|
189 | 190 |
sub init_printers { SL::DB::Manager::Printer->get_all_sorted } |
191 |
#sub init_att { require SL::Controller::Attachments; SL::Controller::Attachments->new() } |
|
190 | 192 |
sub init_invoice_ids { [] } |
191 | 193 |
sub init_today { DateTime->today_local } |
192 | 194 |
|
... | ... | |
268 | 270 |
# helpers |
269 | 271 |
# |
270 | 272 |
|
271 |
sub create_pdfs { |
|
272 |
my ($self, %params) = @_; |
|
273 |
|
|
274 |
my @pdf_file_names; |
|
275 |
foreach my $invoice (@{ $params{invoices} }) { |
|
276 |
my %create_params = ( |
|
277 |
template => $self->find_template(name => 'invoice', printer_id => $params{printer_id}), |
|
278 |
variables => Form->new(''), |
|
279 |
return => 'file_name', |
|
280 |
variable_content_types => { longdescription => 'html', |
|
281 |
partnotes => 'html', |
|
282 |
notes => 'html',} |
|
283 |
); |
|
284 |
|
|
285 |
$create_params{variables}->{$_} = $params{variables}->{$_} for keys %{ $params{variables} }; |
|
286 |
|
|
287 |
$invoice->flatten_to_form($create_params{variables}, format_amounts => 1); |
|
288 |
$create_params{variables}->prepare_for_printing; |
|
289 |
|
|
290 |
push @pdf_file_names, $self->create_pdf(%create_params); |
|
291 |
} |
|
292 |
|
|
293 |
return @pdf_file_names; |
|
294 |
} |
|
295 | 273 |
|
296 | 274 |
sub download_or_print_documents { |
297 | 275 |
my ($self, %params) = @_; |
... | ... | |
300 | 278 |
|
301 | 279 |
eval { |
302 | 280 |
my %pdf_params = ( |
303 |
invoices => $params{invoices}, |
|
304 |
printer_id => $params{printer_id}, |
|
281 |
documents => $params{invoices}, |
|
305 | 282 |
variables => { |
306 | 283 |
type => 'invoice', |
307 | 284 |
formname => 'invoice', |
308 | 285 |
format => 'pdf', |
309 | 286 |
media => $params{printer_id} ? 'printer' : 'file', |
287 |
printer_id => $params{printer_id}, |
|
310 | 288 |
}); |
311 | 289 |
|
312 | 290 |
@pdf_file_names = $self->create_pdfs(%pdf_params); |
... | ... | |
314 | 292 |
unlink @pdf_file_names; |
315 | 293 |
|
316 | 294 |
if (!$params{printer_id}) { |
317 |
my $file_name = t8("Invoices") . '-' . DateTime->today_local->strftime('%Y%m%d%H%M%S') . '.pdf';
|
|
295 |
my $file_name = t8("Invoices") . '-' . DateTime->now_local->strftime('%Y%m%d%H%M%S') . '.pdf';
|
|
318 | 296 |
$file_name =~ s{[^\w\.]+}{_}g; |
319 | 297 |
|
320 | 298 |
return $self->send_file( |
Auch abrufbar als: Unified diff
Dateimanagement: Massendruck
Der Massendruck per BackgroundJob nutzt nun das FileManagement
Die erzeugten Dateien werden ggf. mit PDF Anhängen erweitert
und entsprechend abgespeichert.
Per Flag kann dem massendruck mitgeteilt werden,
dass eine leere Seite ggf hinzugefügt wird
(Template in templates/print/Standard/emptyPage.pdf o.ä.),
damit nächster Lieferschein auf neuem Blatt beginnt.
pdfinfo wird beim installationscheck gesucht,
leere Seite in Druckvorlagen
Vereinheitlichen der HTML -> PDF Konvertierung
Der HASH "variable_content_types" wird an unterschiedlichsten Stellen mit
unterschiedlichen oder unvollständiger Information befüllt.
Nun wird es an zentraler Stelle gemacht