summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/Conf.pm8
-rw-r--r--FS/FS/cust_bill.pm62
-rw-r--r--FS/FS/part_bill_event.pm2
3 files changed, 40 insertions, 32 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index e1384bd4c..91fea7ef7 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -174,8 +174,12 @@ sub config_items {
my $self = shift;
#quelle kludge
@config_items,
- map { new FS::ConfItem {
- 'key' => basename($_),
+ map {
+ my $basename = basename($_);
+ $basename =~ /^(.*)$/;
+ $basename = $1;
+ new FS::ConfItem {
+ 'key' => $basename,
'section' => 'billing',
'description' => 'Alternate template file for invoices. See the <a href="../docs/billing.html">billing documentation</a> for details.',
'type' => 'textarea',
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index 092c174b4..0a8d4a4ae 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -1,7 +1,7 @@
package FS::cust_bill;
use strict;
-use vars qw( @ISA $conf $invoice_template $money_char );
+use vars qw( @ISA $conf $money_char );
use vars qw( $lpr $invoice_from $smtpmachine );
use vars qw( $processor );
use vars qw( $xaction $E_NoErr );
@@ -30,21 +30,6 @@ $FS::UID::callback{'FS::cust_bill'} = sub {
$money_char = $conf->config('money_char') || '$';
- my @invoice_template = $conf->config('invoice_template')
- or die "cannot load config file invoice_template";
- $invoice_lines = 0;
- foreach ( grep /invoice_lines\(\d+\)/, @invoice_template ) { #kludgy
- /invoice_lines\((\d+)\)/;
- $invoice_lines += $1;
- }
- die "no invoice_lines() functions in template?" unless $invoice_lines;
- $invoice_template = new Text::Template (
- TYPE => 'ARRAY',
- SOURCE => [ map "$_\n", @invoice_template ],
- ) or die "can't create new Text::Template object: $Text::Template::ERROR";
- $invoice_template->compile()
- or die "can't compile template: $Text::Template::ERROR";
-
$lpr = $conf->config('lpr');
$invoice_from = $conf->config('invoice_from');
$smtpmachine = $conf->config('smtpmachine');
@@ -383,7 +368,7 @@ emails or print. See L<FS::cust_main_invoice>.
=cut
sub send {
- my $self = shift;
+ my($self,$template) = @_;
#my @print_text = $cust_bill->print_text; #( date )
my @invoicing_list = $self->cust_main->invoicing_list;
@@ -401,7 +386,7 @@ sub send {
] );
my $message = new Mail::Internet (
'Header' => $header,
- 'Body' => [ $self->print_text ], #( date)
+ 'Body' => [ $self->print_text('', $template) ], #( date)
);
$!=0;
$message->smtpsend( Host => $smtpmachine )
@@ -702,7 +687,7 @@ L<Time::Local> and L<Date::Parse> for conversion functions.
sub print_text {
- my( $self, $today ) = ( shift, shift );
+ my( $self, $today, $template ) = @_;
$today ||= time;
# my $invnum = $self->invnum;
my $cust_main = qsearchs('cust_main', { 'custnum', $self->custnum } );
@@ -811,8 +796,25 @@ sub print_text {
push @buf,['Balance Due', $money_char.
sprintf("%10.2f", $balance_due ) ];
+ #create the template
+ my $templatefile = 'invoice_template';
+ $templatefile .= "_$template" if $template;
+ my @invoice_template = $conf->config($templatefile)
+ or die "cannot load config file $templatefile";
+ $invoice_lines = 0;
+ foreach ( grep /invoice_lines\(\d+\)/, @invoice_template ) { #kludgy
+ /invoice_lines\((\d+)\)/;
+ $invoice_lines += $1;
+ }
+ die "no invoice_lines() functions in template?" unless $invoice_lines;
+ my $invoice_template = new Text::Template (
+ TYPE => 'ARRAY',
+ SOURCE => [ map "$_\n", @invoice_template ],
+ ) or die "can't create new Text::Template object: $Text::Template::ERROR";
+ $invoice_template->compile()
+ or die "can't compile template: $Text::Template::ERROR";
+
#setup template variables
-
package FS::cust_bill::_template; #!
use vars qw( $invnum $date $page $total_pages @address $overdue @buf );
@@ -847,13 +849,13 @@ sub print_text {
$FS::cust_bill::_template::address[$l++] = $cust_main->country
unless $cust_main->country eq 'US';
- #overdue? (variable for the template)
- $FS::cust_bill::_template::overdue = (
- $balance_due > 0
- && $today > $self->_date
-# && $self->printed > 1
- && $self->printed > 0
- );
+ # #overdue? (variable for the template)
+ # $FS::cust_bill::_template::overdue = (
+ # $balance_due > 0
+ # && $today > $self->_date
+ ## && $self->printed > 1
+ # && $self->printed > 0
+ # );
#and subroutine for the template
@@ -864,7 +866,9 @@ sub print_text {
}
( 1 .. $lines );
}
-
+
+
+ #and fill it in
$FS::cust_bill::_template::page = 1;
my $lines;
my @collect;
@@ -883,7 +887,7 @@ sub print_text {
=head1 VERSION
-$Id: cust_bill.pm,v 1.23 2002-03-18 19:49:10 ivan Exp $
+$Id: cust_bill.pm,v 1.24 2002-03-18 21:40:17 ivan Exp $
=head1 BUGS
diff --git a/FS/FS/part_bill_event.pm b/FS/FS/part_bill_event.pm
index 40f7fc79d..a31b09b36 100644
--- a/FS/FS/part_bill_event.pm
+++ b/FS/FS/part_bill_event.pm
@@ -154,7 +154,7 @@ sub check {
#quelle kludge
if ( $self->plandata =~ /^templatename\s+(.*)$/ ) {
my $name= $1;
- unless ( $conf->config("invoice_template_$name") ) {
+ unless ( $conf->exists("invoice_template_$name") ) {
$conf->set(
"invoice_template_$name" =>
join("\n", $conf->config('invoice_template') )