summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/Conf.pm15
-rw-r--r--FS/FS/cust_bill.pm144
-rw-r--r--FS/FS/cust_main.pm20
-rwxr-xr-xFS/bin/freeside-expiration-alerter4
-rw-r--r--conf/alerter_template14
-rw-r--r--conf/company_address2
-rw-r--r--conf/company_name1
-rw-r--r--conf/impending_recur_template10
-rw-r--r--conf/invoice_latexfooter2
-rw-r--r--conf/invoice_latexnotes2
-rw-r--r--conf/invoice_latexreturnaddress3
-rw-r--r--conf/invoice_latexsmallfooter2
-rw-r--r--conf/invoice_template9
-rw-r--r--conf/invoice_template_statement9
-rw-r--r--conf/welcome_letter6
15 files changed, 155 insertions, 88 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index adc5b0e..ed05811 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 07aa367..ccbcdf2 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&nbsp;%o,&nbsp;%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&nbsp;%o,&nbsp;%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/~/&nbsp;/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 06f2c46..214e943 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 e49bd62..ffd75f9 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' ) ],
diff --git a/conf/alerter_template b/conf/alerter_template
index 5177e4e..6fb66b7 100644
--- a/conf/alerter_template
+++ b/conf/alerter_template
@@ -1,20 +1,18 @@
-Ivan Kohler
-12345 Test Lane
-Truckee, CA 96161
+{ $company_name; }
+{ $company_address; }
{ $first; } { $last; }:
We thank you for your continuing patronage. This notice is to remind you
-that your { $payby } used to pay SISD.COM for Internet
-service will expire on { use Date::Format; time2str("%x", $expdate); }. Please provide us with new billing
-information so that we may continue your service uninterrupted.
+that your { $payby } used to pay { $company_name; } for Internet
+service will expire on { use Date::Format; time2str("%B %o, %Y", $expdate); }. Please provide us with new
+billing information so that we may continue your service uninterrupted.
Very Truly Yours,
- SISD Service Team
-
+ { $company_name; } Service Team
diff --git a/conf/company_address b/conf/company_address
new file mode 100644
index 0000000..3824862
--- /dev/null
+++ b/conf/company_address
@@ -0,0 +1,2 @@
+1234 Example Lane
+Exampleton, CA 54321
diff --git a/conf/company_name b/conf/company_name
new file mode 100644
index 0000000..2cd5323
--- /dev/null
+++ b/conf/company_name
@@ -0,0 +1 @@
+ExampleCo
diff --git a/conf/impending_recur_template b/conf/impending_recur_template
index 9075ac8..deb396a 100644
--- a/conf/impending_recur_template
+++ b/conf/impending_recur_template
@@ -1,20 +1,20 @@
-Ivan Kohler
-12345 Test Lane
-Truckee, CA 96161
+{ $company_name; }
+{ $company_address; }
{ $first; } { $last; }:
We thank you for your continuing patronage. This notice is to remind you
-that your { $packages->[0] } Internet service will expire on { use Date::Format; time2str("%x", $recurdates->[0]); }.
+that your { $packages->[0] } Internet service
+will expire on { use Date::Format; time2str("%B %o, %Y", $recurdates->[0]); }.
At that time we will begin charging you on a recurring basis so that we may
continue your service uninterrupted.
Very Truly Yours,
- SISD Service Team
+ { $company_name; } Service Team
diff --git a/conf/invoice_latexfooter b/conf/invoice_latexfooter
index 527c356..2e32123 100644
--- a/conf/invoice_latexfooter
+++ b/conf/invoice_latexfooter
@@ -1 +1 @@
-Ivan Kohler~~~Freeside - open-source billing
+[@-- $company_name --@]
diff --git a/conf/invoice_latexnotes b/conf/invoice_latexnotes
index 46af6d6..5303d3c 100644
--- a/conf/invoice_latexnotes
+++ b/conf/invoice_latexnotes
@@ -3,6 +3,6 @@
%%
\section*{\textsc{Notes}}
\begin{enumerate}
-\item Please make your check payable to \textbf{Ivan Kohler}.
+\item Please make your check payable to \textbf{[@-- $company_name --@]}.
\item If you have any questions please email or telephone.
\end{enumerate}
diff --git a/conf/invoice_latexreturnaddress b/conf/invoice_latexreturnaddress
deleted file mode 100644
index 95067e2..0000000
--- a/conf/invoice_latexreturnaddress
+++ /dev/null
@@ -1,3 +0,0 @@
-Ivan Kohler\\*
-12345 Test Lane\\*
-Truckee, CA~~96161
diff --git a/conf/invoice_latexsmallfooter b/conf/invoice_latexsmallfooter
index 527c356..2e32123 100644
--- a/conf/invoice_latexsmallfooter
+++ b/conf/invoice_latexsmallfooter
@@ -1 +1 @@
-Ivan Kohler~~~Freeside - open-source billing
+[@-- $company_name --@]
diff --git a/conf/invoice_template b/conf/invoice_template
index 4b2c64b..b33c4dd 100644
--- a/conf/invoice_template
+++ b/conf/invoice_template
@@ -1,11 +1,10 @@
Invoice
- { substr("Page $page of $total_pages ", 0, 19); } { use Date::Format; time2str("%x", $date); } FS-{ $invnum; }
+ { substr("Page $page of $total_pages ", 0, 19); } { use Date::Format; time2str("%x", $date); } Invoice #{ $invnum; }
-Ivan Kohler
-12345 Test Lane
-Truckee, CA 96161
+{ $company_name; }
+{ $company_address; }
{ $address[0]; }
@@ -24,4 +23,4 @@ Truckee, CA 96161
);
}
- -=> Freeside - open-source billing for ISPs - http://www.sisd.com/freeside <=-
+ -=> { $company_name; } <=-
diff --git a/conf/invoice_template_statement b/conf/invoice_template_statement
index 674416a..db02915 100644
--- a/conf/invoice_template_statement
+++ b/conf/invoice_template_statement
@@ -1,11 +1,10 @@
Statement
- { substr("Page $page of $total_pages ", 0, 19); } { use Date::Format; time2str("%x", $date); } FS-{ $invnum; }
+ { substr("Page $page of $total_pages ", 0, 19); } { use Date::Format; time2str("%x", $date); } Invoice #{ $invnum; }
-Ivan Kohler
-12345 Test Lane
-Truckee, CA 96161
+{ $company_name; }
+{ $company_address; }
{ $address[0]; }
@@ -24,4 +23,4 @@ Truckee, CA 96161
);
}
- -=> Freeside - open-source billing for ISPs - http://www.sisd.com/freeside <=-
+ -=> { $company_name; } <=-
diff --git a/conf/welcome_letter b/conf/welcome_letter
index 3fcf04e..be7b484 100644
--- a/conf/welcome_letter
+++ b/conf/welcome_letter
@@ -113,9 +113,9 @@
% Your content goes here
Dear [@-- $first --@] [@-- $last --@]:\\
\\
- Thank you for choosing Freeside. We aim to meet all the billing needs of
- [@-- $company --@]. Please do not hesitate to contact us for any additional
- service or features you require.\\
+ Thank you for choosing [@-- $company_name --@]. We aim to meet all of your
+ needs. Please do not hesitate to contact us for any additional
+ services or assistance.\\
\end{document}