X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fbill_batch.pm;h=fcafc4dbea0c4b12fd79da23238e4ee89e6cbb1c;hb=c9666df6c2717f98a5088b39f1babc55c4d8e771;hp=ec5c194562c9e204817eca8e029106ccc3670bdf;hpb=982ded2d929bdcdfa72efa810273f3bc753bf036;p=freeside.git diff --git a/FS/FS/bill_batch.pm b/FS/FS/bill_batch.pm index ec5c19456..fcafc4dbe 100644 --- a/FS/FS/bill_batch.pm +++ b/FS/FS/bill_batch.pm @@ -65,6 +65,9 @@ sub print_pdf { qsearch('cust_bill_batch', { batchnum => $self->batchnum }); return "No invoices in batch ".$self->batchnum.'.' if !@invoices; + my $conf = FS::Conf->new; + my $duplex = $conf->exists('invoice_print_pdf-duplex'); + my $pdf_out; my $num = 0; foreach my $invoice (@invoices) { @@ -77,6 +80,13 @@ sub print_pdf { else { $pdf_out = CAM::PDF->new($part); } + if ( $duplex ) { + my $n = $pdf_out->numPages; + if ( $n % 2 == 1 ) { + # then insert a blank page so we end on an even number + $pdf_out->duplicatePage($n, 1); + } + } if($job) { # update progressbar $num++; @@ -84,6 +94,7 @@ sub print_pdf { die $error if $error; } } + $job->update_statustext(100, 'Combining invoices') if $job; return $pdf_out->toPDF; } @@ -144,6 +155,11 @@ sub process_print_pdf { my $batch = FS::bill_batch->by_key($param->{batchnum}); die "batch '$param->{batchnum}' not found!\n" if !$batch; + if ( $param->{'close'} ) { + my $error = $batch->close; + die $error if $error; + } + my $pdf = $batch->print_pdf($job); $batch->pdf($pdf); my $error = $batch->replace;