diff options
author | ivan <ivan> | 2009-01-06 17:49:21 +0000 |
---|---|---|
committer | ivan <ivan> | 2009-01-06 17:49:21 +0000 |
commit | 1c67a5729ce38a912bb9b9a25616947eca4a16ce (patch) | |
tree | c770157aad0419b0daa29cf4e29b7627ffd981e2 | |
parent | 400bd5a55be5219c5ebc50ecb991a8c6614a2095 (diff) |
add invoice_subject config with some subsitution vars, RT#4481
-rw-r--r-- | FS/FS/Conf.pm | 7 | ||||
-rw-r--r-- | FS/FS/cust_bill.pm | 33 | ||||
-rw-r--r-- | FS/FS/cust_main.pm | 53 |
3 files changed, 92 insertions, 1 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 887ae06d3..19be2fe7b 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -641,6 +641,13 @@ worry that config_items is freeside-specific and icky. }, { + 'key' => 'invoice_subject', + 'section' => 'billing', + 'description' => 'Subject: header on email invoices. Defaults to "Invoice". The following substitutions are available: $name, $name_short, $invoice_number, and $invoice_date.', + 'type' => 'text', + }, + + { 'key' => 'invoice_template', 'section' => 'required', 'description' => 'Required template file for invoices. See the <a href="http://www.sisd.com/mediawiki/index.php/Freeside:1.7:Documentation:Administration#Plaintext_invoice_templates">billing documentation</a> for details.', diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index c79141738..70c7a7f9c 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -845,10 +845,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, ) ); @@ -857,6 +860,23 @@ sub email { } +sub email_subject { + my $self = shift; + + #my $template = scalar(@_) ? shift : ''; + #per-template? + + my $subject = $conf->config('invoice_subject') || '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. @@ -2472,7 +2492,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 { diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index c0cdfba0a..41bc88295 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -4379,6 +4379,35 @@ sub ship_name { } } +=item name_short + +Returns a name string for this customer, either "Company" or "First Last". + +=cut + +sub name_short { + my $self = shift; + $self->company !~ /^\s*$/ ? $self->company : $self->contact_firstlast; +} + +=item ship_name_short + +Returns a name string for this (service/shipping) contact, either "Company" +or "First Last". + +=cut + +sub ship_name_short { + my $self = shift; + if ( $self->get('ship_last') ) { + $self->ship_company !~ /^\s*$/ + ? $self->ship_company + : $self->ship_contact_firstlast; + } else { + $self->name_company_or_firstlast; + } +} + =item contact Returns this customer's full (billing) contact name only, "Last, First" @@ -4403,6 +4432,30 @@ sub ship_contact { : $self->contact; } +=item contact_firstlast + +Returns this customers full (billing) contact name only, "First Last". + +=cut + +sub contact_firstlast { + my $self = shift; + $self->first. ' '. $self->get('last'); +} + +=item ship_contact_firstlast + +Returns this customer's full (shipping) contact name only, "First Last". + +=cut + +sub ship_contact_firstlast { + my $self = shift; + $self->get('ship_last') + ? $self->first. ' '. $self->get('ship_last') + : $self->contact_firstlast; +} + =item country_full Returns this customer's full country name |