X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_bill.pm;h=769839b30a50dbda17e91a5048af3a8e0df53aaf;hb=bfd85806a865e8428c99aadbe4fd11a7af19f731;hp=bb582cfd9d3b67935cfa2b5c75792aa85a52f67e;hpb=af7fa01c4148ae3616f08b0cfe81518a7b0cb5a2;p=freeside.git diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index bb582cfd9..769839b30 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -843,7 +843,9 @@ sub send { my $invoice_from = scalar(@_) ? shift - : ( $self->_agent_invoice_from || $conf->config('invoice_from') ); + : ( $self->_agent_invoice_from || #XXX should go away + $conf->config('invoice_from', $self->cust_main->agentnum ) + ); my $balance_over = ( scalar(@_) && $_[0] !~ /^\s*$/ ) ? shift : 0; @@ -899,7 +901,10 @@ sub email { my $invoice_from = scalar(@_) ? shift - : ( $self->_agent_invoice_from || $conf->config('invoice_from') ); + : ( $self->_agent_invoice_from || #XXX should go away + $conf->config('invoice_from', $self->cust_main->agentnum ) + ); + my @invoicing_list = grep { $_ !~ /^(POST|FAX)$/ } $self->cust_main->invoicing_list; @@ -907,10 +912,13 @@ sub email { #better to notify this person than silence @invoicing_list = ($invoice_from) unless @invoicing_list; + my $subject = $self->email_subject($template); + my $error = send_email( $self->generate_email( 'from' => $invoice_from, 'to' => [ grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ], + 'subject' => $subject, 'template' => $template, ) ); @@ -919,6 +927,24 @@ sub email { } +sub email_subject { + my $self = shift; + + #my $template = scalar(@_) ? shift : ''; + #per-template? + + my $subject = $conf->config('invoice_subject', $self->cust_main->agentnum) + || 'Invoice'; + + my $cust_main = $self->cust_main; + my $name = $cust_main->name; + my $name_short = $cust_main->name_short; + my $invoice_number = $self->invnum; + my $invoice_date = $self->_date_pretty; + + eval qq("$subject"); +} + =item lpr_data [ TEMPLATENAME ] Returns the postscript or plaintext for this invoice as an arrayref. @@ -1760,6 +1786,7 @@ sub print_generic { s/~/ /g; s/\\\\\*?\s*$/
/; s/\\hyphenation\{[\w\s\-]+}//; + s/\\([&])/$1/g; $_; } @_ }, @@ -1854,7 +1881,7 @@ sub print_generic { ) ) ); - } elsif ( grep /\S/, $conf->config('company_address') ) { + } elsif ( grep /\S/, $conf->config('company_address', $self->cust_main->agentnum) ) { my $convert_map = $convert_maps{$format}{'returnaddress'}; $returnaddress = join( "\n", &$convert_map( @@ -1862,8 +1889,8 @@ sub print_generic { s/$/\\\\\*/; $_ } - ( $conf->config('company_name'), - $conf->config('company_address'), + ( $conf->config('company_name', $self->cust_main->agentnum), + $conf->config('company_address', $self->cust_main->agentnum), ) ) ); @@ -1879,8 +1906,8 @@ sub print_generic { } my %invoice_data = ( - 'company_name' => scalar( $conf->config('company_name') ), - 'company_address' => join("\n", $conf->config('company_address') ). "\n", + 'company_name' => scalar( $conf->config('company_name', $self->cust_main->agentnum) ), + 'company_address' => join("\n", $conf->config('company_address', $self->cust_main->agentnum) ). "\n", 'custnum' => $cust_main->display_custnum, 'invnum' => $self->invnum, 'date' => time2str($date_format, $self->_date), @@ -1898,7 +1925,7 @@ sub print_generic { 'returnaddress' => $returnaddress, #'quantity' => 1, 'terms' => $self->terms, - 'template' => $params{'template'}, + 'template' => $template, #params{'template'}, #'notes' => join("\n", $conf->config('invoice_latexnotes') ), # better hang on to conf_dir for a while 'conf_dir' => "$FS::UID::conf_dir/conf.$FS::UID::datasrc", @@ -2586,7 +2613,18 @@ Returns a string with the invoice number and date, for example: sub invnum_date_pretty { my $self = shift; - 'Invoice #'. $self->invnum. ' ('. time2str('%x', $self->_date). ')'; + 'Invoice #'. $self->invnum. ' ('. $self->_date_pretty. ')'; +} + +=item _date_pretty + +Returns a string with the date, for example: "3/20/2008" + +=cut + +sub _date_pretty { + my $self = shift; + time2str('%x', $self->_date); } sub _items_sections {