diff options
author | ivan <ivan> | 2007-11-08 00:59:35 +0000 |
---|---|---|
committer | ivan <ivan> | 2007-11-08 00:59:35 +0000 |
commit | 82ac92e9804b65f209ee5d38f826c4b9c2897ce9 (patch) | |
tree | aa26adbc269d0ef25cd47778bbeb9b198f1c8089 /FS | |
parent | a65a7cdc7bb1126134cd6d0116001278d60ef60e (diff) |
for new installs, centralize some stuff that was spread around different config files.
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/Conf.pm | 15 | ||||
-rw-r--r-- | FS/FS/cust_bill.pm | 144 | ||||
-rw-r--r-- | FS/FS/cust_main.pm | 20 | ||||
-rwxr-xr-x | FS/bin/freeside-expiration-alerter | 4 |
4 files changed, 127 insertions, 56 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index adc5b0ee6..ed05811bb 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -732,7 +732,7 @@ worry that config_items is freeside-specific and icky. { 'key' => 'home', - 'section' => 'required', + 'section' => 'shell', 'description' => 'For new users, prefixed to username to create a directory name. Should have a leading but not a trailing slash.', 'type' => 'text', }, @@ -746,8 +746,8 @@ worry that config_items is freeside-specific and icky. { '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.', + 'section' => 'billing', + 'description' => 'Text template file for invoices. Used if no invoice_html template is defined, and also seen by users using non-HTML capable mail clients. See the <a href="http://www.sisd.com/mediawiki/index.php/Freeside:1.7:Documentation:Administration#Plaintext_invoice_templates">billing documentation</a> for details.', 'type' => 'textarea', }, @@ -949,7 +949,7 @@ worry that config_items is freeside-specific and icky. { 'key' => 'shells', - 'section' => 'required', + 'section' => 'shell', 'description' => 'Legal shells (think /etc/shells). You probably want to `cut -d: -f7 /etc/passwd | sort | uniq\' initially so that importing doesn\'t fail with `Illegal shell\' errors, then remove any special entries afterwords. A blank line specifies that an empty shell is permitted.', 'type' => 'textarea', }, @@ -1700,6 +1700,13 @@ worry that config_items is freeside-specific and icky. }, { + 'key' => 'company_address', + 'section' => 'required', + 'description' => 'Your company address', + 'type' => 'textarea', + }, + + { 'key' => 'address2-search', 'section' => 'UI', 'description' => 'Enable a "Unit" search box which searches the second address field', diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 07aa367e5..ccbcdf28e 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -1681,8 +1681,10 @@ sub print_text { #setup template variables package FS::cust_bill::_template; #! - use vars qw( $custnum $invnum $date $agent @address $overdue - $page $total_pages @buf ); + use vars qw( $company_name $company_address + $custnum $invnum $date $agent @address $overdue + $page $total_pages @buf + ); $custnum = $self->custnum; $invnum = $self->invnum; @@ -1730,6 +1732,10 @@ sub print_text { # && $self->printed > 0 # ); + $FS::cust_bill::_template::company_name = $conf->config('company_name'); + $FS::cust_bill::_template::company_address = + join("\n", $conf->config('company_address') ). "\n"; + #and subroutine for the template sub FS::cust_bill::_template::invoice_lines { my $lines = shift || scalar(@buf); @@ -1814,34 +1820,49 @@ sub print_latex { my $returnaddress; if ( length($conf->config_orbase('invoice_latexreturnaddress', $template)) ) { + $returnaddress = join("\n", $conf->config_orbase('invoice_latexreturnaddress', $template) ); + + } elsif ( grep /\S/, $conf->config('company_address') ) { + + $returnaddress = + join( '\\*'."\n", map s/( {2,})/'~' x length($1)/eg, + $conf->config('company_address') + ); + } else { + + my $warning = "Couldn't find a return address; ". + "do you need to set the company_address configuration value?"; + warn "$warning\n"; $returnaddress = '~'; + #$returnaddress = $warning; + } my %invoice_data = ( - 'custnum' => $self->custnum, - 'invnum' => $self->invnum, - 'date' => time2str('%b %o, %Y', $self->_date), - 'today' => time2str('%b %o, %Y', $today), - 'agent' => _latex_escape($cust_main->agent->agent), - 'payname' => _latex_escape($cust_main->payname), - 'company' => _latex_escape($cust_main->company), - 'address1' => _latex_escape($cust_main->address1), - 'address2' => _latex_escape($cust_main->address2), - 'city' => _latex_escape($cust_main->city), - 'state' => _latex_escape($cust_main->state), - 'zip' => _latex_escape($cust_main->zip), - 'footer' => join("\n", $conf->config_orbase('invoice_latexfooter', $template) ), - 'smallfooter' => join("\n", $conf->config_orbase('invoice_latexsmallfooter', $template) ), - 'returnaddress' => $returnaddress, - 'quantity' => 1, - 'terms' => $self->terms, - #'notes' => join("\n", $conf->config('invoice_latexnotes') ), + 'company_name' => $conf->config('company_name'), + 'company_address' => join("\n", $conf->config('company_address') ). "\n", + 'custnum' => $self->custnum, + 'invnum' => $self->invnum, + 'date' => time2str('%b %o, %Y', $self->_date), + 'today' => time2str('%b %o, %Y', $today), + 'agent' => _latex_escape($cust_main->agent->agent), + 'payname' => _latex_escape($cust_main->payname), + 'company' => _latex_escape($cust_main->company), + 'address1' => _latex_escape($cust_main->address1), + 'address2' => _latex_escape($cust_main->address2), + 'city' => _latex_escape($cust_main->city), + 'state' => _latex_escape($cust_main->state), + 'zip' => _latex_escape($cust_main->zip), + 'returnaddress' => $returnaddress, + 'quantity' => 1, + 'terms' => $self->terms, + #'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", + 'conf_dir' => "$FS::UID::conf_dir/conf.$FS::UID::datasrc", ); my $countrydefault = $conf->config('countrydefault') || 'US'; @@ -1851,18 +1872,24 @@ sub print_latex { $invoice_data{'country'} = _latex_escape(code2country($cust_main->country)); } - $invoice_data{'notes'} = - join("\n", -# #do variable substitutions in notes -# map { my $b=$_; $b =~ s/\$(\w+)/$invoice_data{$1}/eg; $b } - $conf->config_orbase('invoice_latexnotes', $template) - ); - warn "invoice notes: ". $invoice_data{'notes'}. "\n" - if $DEBUG; + #do variable substitution in notes, footer, smallfooter + foreach my $include (qw( notes footer smallfooter )) { + + my $inc_tt = new Text::Template ( + TYPE => 'ARRAY', + SOURCE => [ map "$_\n", + $conf->config_orbase("invoice_latex$include", $template ) + ], + DELIMITERS => [ '[@--', '--@]' ], + ) or die "can't create new Text::Template object: $Text::Template::ERROR"; - $invoice_data{'footer'} =~ s/\n+$//; - $invoice_data{'smallfooter'} =~ s/\n+$//; - $invoice_data{'notes'} =~ s/\n+$//; + $inc_tt->compile() + or die "can't compile template: $Text::Template::ERROR"; + + $invoice_data{$include} = $inc_tt->fill_in( HASH => \%invoice_data ); + + $invoice_data{$include} =~ s/\n+$//; + } $invoice_data{'po_line'} = ( $cust_main->payby eq 'BILL' && $cust_main->payinfo ) @@ -2217,31 +2244,37 @@ sub print_html { or die 'While compiling ' . $templatefile . ': ' . $Text::Template::ERROR; my %invoice_data = ( - 'custnum' => $self->custnum, - 'invnum' => $self->invnum, - 'date' => time2str('%b %o, %Y', $self->_date), - 'today' => time2str('%b %o, %Y', $today), - 'agent' => encode_entities($cust_main->agent->agent), - 'payname' => encode_entities($cust_main->payname), - 'company' => encode_entities($cust_main->company), - 'address1' => encode_entities($cust_main->address1), - 'address2' => encode_entities($cust_main->address2), - 'city' => encode_entities($cust_main->city), - 'state' => encode_entities($cust_main->state), - 'zip' => encode_entities($cust_main->zip), - 'terms' => $self->terms, - 'cid' => $cid, - 'template' => $template, -# 'conf_dir' => "$FS::UID::conf_dir/conf.$FS::UID::datasrc", + 'company_name' => $conf->config('company_name'), + 'company_address' => join("\n", $conf->config('company_address') ). "\n", + 'custnum' => $self->custnum, + 'invnum' => $self->invnum, + 'date' => time2str('%b %o, %Y', $self->_date), + 'today' => time2str('%b %o, %Y', $today), + 'agent' => encode_entities($cust_main->agent->agent), + 'payname' => encode_entities($cust_main->payname), + 'company' => encode_entities($cust_main->company), + 'address1' => encode_entities($cust_main->address1), + 'address2' => encode_entities($cust_main->address2), + 'city' => encode_entities($cust_main->city), + 'state' => encode_entities($cust_main->state), + 'zip' => encode_entities($cust_main->zip), + 'terms' => $self->terms, + 'cid' => $cid, + 'template' => $template, +# 'conf_dir' => "$FS::UID::conf_dir/conf.$FS::UID::datasrc", ); if ( defined( $conf->config_orbase('invoice_htmlreturnaddress', $template) ) && length( $conf->config_orbase('invoice_htmlreturnaddress', $template) ) ) { + $invoice_data{'returnaddress'} = join("\n", $conf->config('invoice_htmlreturnaddress', $template) ); - } else { + + } elsif ( grep /\S/, + $conf->config_orbase( 'invoice_latexreturnaddress', $template ) ) { + $invoice_data{'returnaddress'} = join("\n", map { s/~/ /g; @@ -2253,6 +2286,19 @@ sub print_html { $template ) ); + + } elsif ( grep /\S/, $conf->config('company_address') ) { + + $invoice_data{'returnaddress'} = + join("\n", $conf->config('company_address') ); + + } else { + + my $warning = "Couldn't find a return address; ". + "do you need to set the company_address configuration value?"; + warn "$warning\n"; + #$invoice_data{'returnaddress'} = $warning; + } my $countrydefault = $conf->config('countrydefault') || 'US'; diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 06f2c4636..214e943bd 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -5752,6 +5752,10 @@ sub notify { $notify_template->compile() or die "can't compile template: Text::Template::ERROR"; + $FS::notify_template::_template::company_name = $conf->config('company_name'); + $FS::notify_template::_template::company_address = + join("\n", $conf->config('company_address') ). "\n"; + my $paydate = $customer->paydate; $FS::notify_template::_template::first = $customer->first; $FS::notify_template::_template::last = $customer->last; @@ -5805,7 +5809,7 @@ I<$payby> - a description of the method of payment for the customer # would be nice to use FS::payby::shortname I<$payinfo> - the masked account information used to collect for this customer I<$expdate> - the expiration of the customer payment method in seconds from epoch -I<$returnaddress> - the return address defaults to invoice_latexreturnaddress +I<$returnaddress> - the return address defaults to invoice_latexreturnaddress or company_address =cut @@ -5855,12 +5859,22 @@ sub generate_letter { my $retadd = join("\n", $conf->config_orbase( 'invoice_latexreturnaddress', $self->agent_template) ); - - $letter_data{returnaddress} = length($retadd) ? $retadd : '~'; + if ( length($retadd) ) { + $letter_data{returnaddress} = $retadd; + } elsif ( grep /\S/, $conf->config('company_address') ) { + $letter_data{returnaddress} = + join( '\\*'."\n", map s/( {2,})/'~' x length($1)/eg, + $conf->config('company_address') + ); + } else { + $letter_data{returnaddress} = '~'; + } } $letter_data{conf_dir} = "$FS::UID::conf_dir/conf.$FS::UID::datasrc"; + $letter_data{company_name} = $conf->config('company_name'); + my $dir = $FS::UID::conf_dir."cache.". $FS::UID::datasrc; my $fh = new File::Temp( TEMPLATE => 'letter.'. $self->custnum. '.XXXXXXXX', DIR => $dir, diff --git a/FS/bin/freeside-expiration-alerter b/FS/bin/freeside-expiration-alerter index e49bd62aa..ffd75f9a5 100755 --- a/FS/bin/freeside-expiration-alerter +++ b/FS/bin/freeside-expiration-alerter @@ -138,6 +138,10 @@ foreach my $customer (@customers) } $FS::alerter::_template::expdate = $expire_time; + $FS::alerter::_template::company_name = $conf->config('company_name'); + $FS::alerter::_template::company_address = + join("\n", $conf->config('company_address') ). "\n"; + my $message = new Mail::Internet ( 'Header' => $header, 'Body' => [ $alerter->fill_in( PACKAGE => 'FS::alerter::_template' ) ], |