[freeside-commits] branch FREESIDE_2_3_BRANCH updated. f0a918182a46c98638cfd5ce09b050f5db22dd56

Ivan ivan at 420.am
Wed Jan 30 00:13:57 PST 2013


The branch, FREESIDE_2_3_BRANCH has been updated
       via  f0a918182a46c98638cfd5ce09b050f5db22dd56 (commit)
      from  b13e93e2d39a361eff97a4edf5a391535dd5012e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit f0a918182a46c98638cfd5ce09b050f5db22dd56
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Wed Jan 30 00:13:56 2013 -0800

    per-agent lpr command, RT#18549

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index dc3d693..0df38a2 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -1541,6 +1541,7 @@ and customer address. Include units.',
     'section'     => 'required',
     'description' => 'Print command for paper invoices, for example `lpr -h\'',
     'type'        => 'text',
+    'per_agent'   => 1,
   },
 
   {
diff --git a/FS/FS/Misc.pm b/FS/FS/Misc.pm
index dfdf8eb..5e12419 100644
--- a/FS/FS/Misc.pm
+++ b/FS/FS/Misc.pm
@@ -801,16 +801,32 @@ sub _pslatex {
 
 }
 
-=item do_print ARRAYREF
+=item do_print ARRAYREF [, OPTION => VALUE ... ]
 
 Sends the lines in ARRAYREF to the printer.
 
+Options available are:
+
+=over 4
+
+=item agentnum
+
+Uses this agent's 'lpr' configuration setting override instead of the global
+value.
+
+=item lpr
+
+Uses this command instead of the configured lpr command (overrides both the
+global value and agentnum).
+
 =cut
 
 sub do_print {
-  my $data = shift;
+  my( $data, %opt ) = @_;
 
-  my $lpr = $conf->config('lpr');
+  my $lpr = ( exists($opt{'lpr'}) && $opt{'lpr'} )
+              ? $opt{'lpr'}
+              : $conf->config('lpr', $opt{'agentnum'} );
 
   my $outerr = '';
   run3 $lpr, $data, \$outerr, \$outerr;
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index 8c68d65..77126cc 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -1541,7 +1541,10 @@ sub print {
     $self->batch_invoice(\%opt);
   }
   else {
-    do_print $self->lpr_data(\%opt);
+    do_print(
+      $self->lpr_data(\%opt),
+      'agentnum' => $self->cust_main->agentnum,
+    );
   }
 }
 
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 5b37605..b2f93c5 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -4920,7 +4920,10 @@ sub queueable_print {
 
 sub print {
   my ($self, $template) = (shift, shift);
-  do_print [ $self->print_ps($template) ];
+  do_print(
+    [ $self->print_ps($template) ],
+    'agentnum' => $self->agentnum,
+  );
 }
 
 #these three subs should just go away once agent stuff is all config overrides
diff --git a/FS/FS/msg_template.pm b/FS/FS/msg_template.pm
index 4d28bbc..82d9a7e 100644
--- a/FS/FS/msg_template.pm
+++ b/FS/FS/msg_template.pm
@@ -484,13 +484,15 @@ Render a PDF and send it to the printer.  OPTIONS are as for 'render'.
 =cut
 
 sub print {
-  my $file = render(@_);
-  my @lpr = $conf->config('lpr');
-  run ([@lpr, '-r'], '<', $file)
+  my( $self, %opt ) = @_;
+  my $file = $self->render(%opt);
+
+  my $lpr = $conf->config('lpr', $opt{'cust_main'}->agentnum );
+
+  run ( $lpr, '<', $file)
     or die "lpr error:\n$?\n";
 }
 
-
 # helper sub for package dates
 my $ymd = sub { $_[0] ? time2str('%Y-%m-%d', $_[0]) : '' };
 

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Conf.pm         |    1 +
 FS/FS/Misc.pm         |   22 +++++++++++++++++++---
 FS/FS/cust_bill.pm    |    5 ++++-
 FS/FS/cust_main.pm    |    5 ++++-
 FS/FS/msg_template.pm |   10 ++++++----
 5 files changed, 34 insertions(+), 9 deletions(-)




More information about the freeside-commits mailing list