From 06187016fd78ba41fb82846b9e8d461405f316b6 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 7 Oct 2009 23:44:26 +0000 Subject: [PATCH] naming follow-up notices from the event rather than creting a slew of separate templates, RT#5217 --- FS/FS/cust_bill.pm | 312 +++++++++++++++------ FS/FS/part_event/Action/cust_bill_send_reminder.pm | 31 ++ conf/invoice_html | 2 +- conf/invoice_latex | 2 +- conf/invoice_template | 2 +- httemplate/misc/email-statement.cgi | 19 -- httemplate/misc/send-invoice.cgi | 30 ++ httemplate/misc/send-statement.cgi | 28 ++ httemplate/search/cust_event.html | 23 +- httemplate/view/cust_bill-pdf.cgi | 22 +- httemplate/view/cust_bill-ps.cgi | 21 +- httemplate/view/cust_bill.cgi | 37 ++- httemplate/view/cust_statement.html | 9 +- 13 files changed, 399 insertions(+), 139 deletions(-) create mode 100644 FS/FS/part_event/Action/cust_bill_send_reminder.pm delete mode 100755 httemplate/misc/email-statement.cgi create mode 100644 httemplate/misc/send-invoice.cgi create mode 100755 httemplate/misc/send-statement.cgi diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 57066b474..e7c0be892 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -770,6 +770,10 @@ text attachment arrayref, optional email subject, optional +=item notice_name + +notice name instead of "Invoice", optional + =back Returns an argument list to be passed to L. @@ -790,13 +794,19 @@ sub generate_email { 'subject' => (($args{'subject'}) ? $args{'subject'} : 'Invoice'), ); - my %cdrs = ( 'unsquelch_cdr' => $conf->exists('voip-cdr_email') ); + my %opt = ( + 'unsquelch_cdr' => $conf->exists('voip-cdr_email'), + 'template' => $args{'template'}, + 'notice_name' => ( $args{'notice_name'} || 'Invoice' ), + ); + + my $cust_main = $self->cust_main; if (ref($args{'to'}) eq 'ARRAY') { $return{'to'} = $args{'to'}; } else { $return{'to'} = [ grep { $_ !~ /^(POST|FAX)$/ } - $self->cust_main->invoicing_list + $cust_main->invoicing_list ]; } @@ -830,7 +840,7 @@ sub generate_email { if ( ref($args{'print_text'}) eq 'ARRAY' ) { $data = $args{'print_text'}; } else { - $data = [ $self->print_text('', $args{'template'}, %cdrs) ]; + $data = [ $self->print_text(\%opt) ]; } } @@ -848,7 +858,7 @@ sub generate_email { my $content_id = join('.', rand()*(2**32), $$, time). "\@$from"; my $logo; - my $agentnum = $self->cust_main->agentnum; + my $agentnum = $cust_main->agentnum; if ( defined($args{'template'}) && length($args{'template'}) && $conf->exists( 'logo_'. $args{'template'}. '.png', $agentnum ) ) @@ -877,11 +887,7 @@ sub generate_email { ' ', ' ', ' ', - $self->print_html({ time => '', - template => $args{'template'}, - cid => $content_id, - %cdrs, - }), + $self->print_html({ 'cid'=>$content_id, %opt }), ' ', '', ], @@ -890,7 +896,7 @@ sub generate_email { ); my @otherparts = (); - if ( $self->cust_main->email_csv_cdr ) { + if ( $cust_main->email_csv_cdr ) { push @otherparts, build MIME::Entity 'Type' => 'text/csv', @@ -929,7 +935,7 @@ sub generate_email { $related->add_part($image); - my $pdf = build MIME::Entity $self->mimebuild_pdf('', $args{'template'}, %cdrs); + my $pdf = build MIME::Entity $self->mimebuild_pdf(\%opt); $return{'mimeparts'} = [ $related, $pdf, @otherparts ]; @@ -957,7 +963,7 @@ sub generate_email { #mime parts arguments a la MIME::Entity->build(). $return{'mimeparts'} = [ - { $self->mimebuild_pdf('', $args{'template'}, %cdrs) } + { $self->mimebuild_pdf(\%opt) } ]; } @@ -977,7 +983,7 @@ sub generate_email { if ( ref($args{'print_text'}) eq 'ARRAY' ) { $return{'body'} = $args{'print_text'}; } else { - $return{'body'} = [ $self->print_text('', $args{'template'}, %cdrs) ]; + $return{'body'} = [ $self->print_text(\%opt) ]; } } @@ -1006,22 +1012,27 @@ sub mimebuild_pdf { ); } -=item send [ TEMPLATENAME [ , AGENTNUM [ , INVOICE_FROM ] ] ] +=item send HASHREF | [ TEMPLATE [ , AGENTNUM [ , INVOICE_FROM [ , AMOUNT ] ] ] ] Sends this invoice to the destinations configured for this customer: sends email, prints and/or faxes. See L. -TEMPLATENAME, if specified, is the name of a suffix for alternate invoices. +Options can be passed as a hashref (recommended) or as a list of up to +four values for templatename, agentnum, invoice_from and amount. -AGENTNUM, if specified, means that this invoice will only be sent for customers +I