- if ( grep { $_ eq 'POST' } @invoicing_list ) { #postal
- @print_text = $self->print_ps('', $template)
- if $conf->config('invoice_latex');
- my $lpr = $conf->config('lpr');
- open(LPR, "|$lpr")
- or die "Can't open pipe to $lpr: $!\n";
- print LPR @print_text;
- close LPR
- or die $! ? "Error closing $lpr: $!\n"
- : "Exit status $? from $lpr\n";
+ if ( grep { $_ =~ /^(POST|FAX)$/ } @invoicing_list ) {
+ my $lpr_data;
+ if ($conf->config('invoice_latex')) {
+ $lpr_data = [ $self->print_ps('', $template) ];
+ } else {
+ $lpr_data = \@print_text;
+ }
+
+ if ( grep { $_ eq 'POST' } @invoicing_list ) { #postal
+ my $lpr = $conf->config('lpr');
+ open(LPR, "|$lpr")
+ or die "Can't open pipe to $lpr: $!\n";
+ print LPR @{$lpr_data};
+ close LPR
+ or die $! ? "Error closing $lpr: $!\n"
+ : "Exit status $? from $lpr\n";
+ }
+
+ if ( grep { $_ eq 'FAX' } @invoicing_list ) { #fax
+ unless ($conf->exists('invoice_latex')) {
+ die 'FAX invoice destination not supported with plain text invoices.'
+ }
+ my $dialstring = $self->cust_main->getfield('fax');
+ #Check $dialstring?
+ my $error = send_fax(docdata => $lpr_data, dialstring => $dialstring);
+ die $error if $error;
+ }
+