From a0f5ae295297e1b17ab89640346fc06cfb1e5892 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Sat, 9 Aug 2014 17:39:27 -0700 Subject: [PATCH] two-sided printing of invoice batches, #29927 --- FS/FS/Conf.pm | 7 +++++++ FS/FS/bill_batch.pm | 9 +++++++++ FS/FS/cust_bill.pm | 2 ++ 3 files changed, 18 insertions(+) diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 35b88eaad..3d7ffe7cd 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -1527,6 +1527,13 @@ and customer address. Include units.', 'type' => 'checkbox', }, + { + 'key' => 'invoice_print_pdf-duplex', + 'section' => 'invoicing', + 'description' => 'Insert blank pages so that spooled invoices are each an even number of pages. Use this for double-sided printing.', + 'type' => 'checkbox', + }, + { 'key' => 'invoice_default_terms', 'section' => 'invoicing', diff --git a/FS/FS/bill_batch.pm b/FS/FS/bill_batch.pm index 1a46db0b2..239341cf3 100644 --- a/FS/FS/bill_batch.pm +++ b/FS/FS/bill_batch.pm @@ -65,6 +65,8 @@ sub print_pdf { qsearch('cust_bill_batch', { batchnum => $self->batchnum }); return "No invoices in batch ".$self->batchnum.'.' if !@invoices; + my $duplex = FS::Conf->exists('invoice_print_pdf-duplex'); + my $pdf_out; my $num = 0; foreach my $invoice (@invoices) { @@ -77,6 +79,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++; diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 7f1290fcf..31422f00d 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -1565,6 +1565,8 @@ sub fax_invoice { Place this invoice into the open batch (see C). If there isn't an open batch, one will be created. +HASHREF may contain any options to be passed to C. + =cut sub batch_invoice { -- 2.11.0