'unsquelch_cdr' => $conf->exists('voip-cdr_email'),
'template' => $args{'template'},
'notice_name' => ( $args{'notice_name'} || 'Invoice' ),
+ 'no_coupon' => $args{'no_coupon'},
);
my $cust_main = $self->cust_main;
my $self = qsearchs('cust_bill', { 'invnum' => $opt{invnum} } )
or die "invalid invoice number: " . $opt{invnum};
- my @args = ( $opt{template} );
- push @args, $opt{invoice_from}
- if exists($opt{invoice_from}) && $opt{invoice_from};
+ my %args = ( 'template' => $opt{template} );
+ $args{$_} = $opt{$_}
+ foreach grep { exists($opt{$_}) && $opt{$_} }
+ qw( invoice_from notice_name no_coupon );
- my $error = $self->email( @args );
+ my $error = $self->email( \%args );
die $error if $error;
}
sub email {
my $self = shift;
- my( $template, $invoice_from, $notice_name );
+ my( $template, $invoice_from, $notice_name, $no_coupon );
if ( ref($_[0]) ) {
my $opt = shift;
$template = $opt->{'template'} || '';
$invoice_from = $opt->{'invoice_from'};
$notice_name = $opt->{'notice_name'} || 'Invoice';
+ $no_coupon = $opt->{'no_coupon'} || 0;
} else {
$template = scalar(@_) ? shift : '';
$invoice_from = shift if scalar(@_);
$notice_name = 'Invoice';
+ $no_coupon = 0;
}
$invoice_from ||= $self->_agent_invoice_from || #XXX should go away
'subject' => $subject,
'template' => $template,
'notice_name' => $notice_name,
+ 'no_coupon' => $no_coupon,
)
);
die "can't email invoice: $error\n" if $error;
my $template = $params{template} ? $params{template} : $self->_agent_template;
my $templatefile = "invoice_$format";
$templatefile .= "_$template"
- if length($template);
+ if length($template) && $conf->exists($templatefile."_$template");
my @invoice_template = map "$_\n", $conf->config($templatefile)
or die "cannot load config data $templatefile";
warn "$me substituting variables in notes, footer, smallfooter\n"
if $DEBUG > 1;
- foreach my $include (qw( notes footer smallfooter coupon )) {
+ my @include = (qw( notes footer smallfooter ));
+ push @include, 'coupon' unless $params{'no_coupon'};
+ foreach my $include (@include) {
my $inc_file = $conf->key_orbase("invoice_${format}$include", $template);
my @inc_src;
my $error = '';
if ( ( exists($opt->{'manual'}) && $opt->{'manual'} )
- || ! $conf->exists('invoice_html_statement')
+ #|| ! $conf->exists('invoice_html_statement')
|| ! $cust_bill
)
{
} else {
- warn "payment_receipt is on, but no payment_receipt_msgnum or invoice_html_statement is configured\n";
+ warn "payment_receipt is on, but no payment_receipt_msgnum\n";
}
};
$error = $queue->insert(
- 'invnum' => $cust_bill->invnum,
- 'template' => 'statement',
+ 'invnum' => $cust_bill->invnum,
+ 'template' => 'statement',
+ 'notice_name' => 'Statement',
+ 'no_coupon' => 1,
);
}
+++ /dev/null
-<STYLE TYPE="text/css">
-.invoice { font-family: sans-serif; font-size: 10pt }
-.invoice_header { font-size: 10pt }
-.invoice_headerright TH { border-top: 2px solid #000000; border-bottom: 2px solid #000000 }
-.invoice_headerright TD { font-size: 10pt; empty-cells: show }
-.invoice_longtable table { cellspacing: none }
-.invoice_longtable TH { border-top: 2px solid #000000; border-bottom: 1px solid #000000; padding-left: none; padding-right: none; font-size: 10pt }
-.invoice_desc TD { border-top: 2px solid #000000; font-weight: bold; font-size: 10pt }
-.invoice_extdesc TD { font-size: 8pt }
-.invoice_totaldesc TD { font-size: 10pt; empty-cells: show }
-</STYLE>
-
-<table class="invoice" bgcolor="#ffffff" WIDTH=768 CELLSPACING=8><tr><td>
-
- <table class="invoice_header" width="100%">
- <tr>
- <td><img src="<%= $cid ? "cid:$cid" : "cust_bill-logo.cgi?invnum=$invnum;template=$template" %>"></td>
- <td align="left"><%= $returnaddress %></td>
- <td align="right">
- <table CLASS="invoice_headerright" cellspacing=0>
- <tr>
- <td align="right">
- Invoice date<BR>
- <B><%= $date %></B>
- </td>
- <td>
- </td>
- <td align="left">
- Invoice number<BR>
- <B><%= $invnum %></B>
- </td>
- </tr>
- <tr>
- <th> </th>
- <th colspan=1 align="center">
- <FONT SIZE="+3">S</FONT><FONT SIZE="+2">TATEMENT</FONT>
- </th>
- <th> </th>
- </tr>
- </table>
- </td>
- </tr>
-
- <tr>
- <td>
- </td>
- <td align="left">
- <b><%= $payname %></b><BR>
- <%= join('<BR>', grep length($_), $company,
- $address1,
- $address2,
- "$city, $state $zip",
- $country,
- )
- %>
- </td>
- <td align="right">
- Terms: <%= $terms %><BR>
- <%= $po_line %>
- </td>
- </tr>
-
- </table>
-
- <p><b><font size="+1">C</font><font size="+0">HARGES</font></b>
- <p>
- <table class="invoice_longtable" CELLSPACING=0 WIDTH="100%">
- <tr>
- <th align="center">Ref</th>
- <th align="left">Description</th>
- <th align="right">Amount</th>
- </tr>
- <%=
-
- foreach my $line ( @detail_items ) {
- $OUT .=
- '<tr class="invoice_desc">'.
- '<td align="center">'. $line->{'ref'}. '</td>'.
- '<td align="left">'. $line->{'description'}. '</td>'.
- '<td align="right">'. $line->{'amount'}. '</td>'.
- '</tr>'
- ;
- foreach my $ext_desc ( @{$line->{'ext_description'} } ) {
- $OUT .=
- '<tr class="invoice_extdesc">'.
- '<td></td>'.
- '<td align="left">- '. $ext_desc. '</td>'.
- '<td></td>'.
- '</tr>'
- }
- }
-
- my $style = 'border-top: 3px solid #000000;';
- my $linenum = 0;
-
- foreach my $line ( @total_items ) {
-
- $style .= 'border-bottom: 3px solid #000000;'
- if ++$linenum == scalar(@total_items);
-
- $OUT .=
- '<tr class="invoice_totaldesc">'.
- qq(<td style="$style"> </td>).
- qq(<td align="left" style="$style">).
- $line->{'total_item'}. '</td>'.
- qq(<td align="right" style="$style">).
- $line->{'total_amount'}. '</td>'.
- '</tr>'
- ;
-
- $style='';
-
- }
-
- %>
- </table>
- <br><br>
-
-<%= $notes %>
-
- <hr NOSHADE SIZE=2 COLOR="#000000">
- <p align="center"><%= $footer %>
-
-</td></tr></table>
+++ /dev/null
-%% file: Standard Multipage.tex\r
-%% Purpose: Multipage bill template for e-Bills\r
-%% \r
-%% Created by Mark Asplen-Taylor\r
-%% Asplen Management Ltd\r
-%% www.asplen.co.uk\r
-%%\r
-%% Modified for Freeside by Kristian Hoffman\r
-%%\r
-%% Changes\r
-%% 0.1 4/12/00 Created\r
-%% 0.2 18/10/01 More fields added\r
-%% 1.0 16/11/01 RELEASED\r
-%% 1.2 16/10/02 Invoice number added\r
-%% 1.3 2/12/02 Logo graphic added\r
-%% 1.4 7/2/03 Multipage headers/footers added\r
-%% n/a forked for Freeside; checked into CVS\r
-%%\r
-\r
-\documentclass[letterpaper]{article}\r
-\r
-\usepackage{fancyhdr,lastpage,ifthen,longtable,afterpage}\r
-\usepackage{graphicx} % required for logo graphic\r
-\r
-\addtolength{\voffset}{-0.0cm} % top margin to top of header\r
-\addtolength{\hoffset}{-0.6cm} % left margin on page\r
-\addtolength{\topmargin}{-1.25cm} % top margin to top of header\r
-\setlength{\headheight}{2.0cm} % height of header\r
-\setlength{\headsep}{1.0cm} % between header and text\r
-\setlength{\footskip}{1.0cm} % bottom of footer from bottom of text\r
-\r
-%\addtolength{\textwidth}{2.1in} % width of text\r
-\setlength{\textwidth}{19.5cm}\r
-\setlength{\textheight}{19.5cm}\r
-\setlength{\oddsidemargin}{-0.9cm} % odd page left margin\r
-\setlength{\evensidemargin}{-0.9cm} % even page left margin\r
-\r
-\renewcommand{\headrulewidth}{0pt}\r
-\renewcommand{\footrulewidth}{1pt}\r
-\r
-% Adjust the inset of the mailing address\r
-\newcommand{\addressinset}[1][]{\hspace{1.0cm}}\r
-\r
-% Adjust the inset of the return address and logo\r
-\newcommand{\returninset}[1][]{\hspace{-0.25cm}}\r
-\r
-% New command for address lines i.e. skip them if blank\r
-\newcommand{\addressline}[1]{\ifthenelse{\equal{#1}{}}{}{#1\newline}}\r
-\r
-% Inserts dollar symbol\r
-\newcommand{\dollar}[1][]{\symbol{36}}\r
-\r
-% Remove plain style header/footer\r
-\fancypagestyle{plain}{\r
- \fancyhead{}\r
-}\r
-\fancyhf{}\r
-\r
-% Define fancy header/footer for first and subsequent pages\r
-\fancyfoot[C]{\r
- \ifthenelse{\equal{\thepage}{1}}\r
- { % First page\r
- \small{\r
-[@-- $footer --@]\r
- }\r
- }\r
- { % ... pages\r
- \small{\r
-[@-- $smallfooter --@]\r
- }\r
- }\r
-}\r
-\r
-\fancyfoot[R]{\r
- \ifthenelse{\equal{\thepage}{1}}\r
- { % First page\r
- }\r
- { % ... pages\r
- \small{\thepage\ of \pageref{LastPage}}\r
- }\r
-}\r
-\r
-\fancyhead[L]{\r
- \ifthenelse{\equal{\thepage}{1}}\r
- { % First page\r
- \returninset\r
- \makebox{\r
- \begin{tabular}{ll}\r
- \includegraphics{[@-- $logo_file --@]} &\r
- \begin{minipage}[b]{5.5cm}\r
-[@-- $returnaddress --@]\r
- \end{minipage}\r
- \end{tabular}\r
- }\r
- }\r
- { % ... pages\r
- %\includegraphics{[@-- $conf_dir --@]/logo.eps} % Uncomment if you want the logo on all pages.\r
- }\r
-}\r
-\r
-\fancyhead[R]{\r
- \ifthenelse{\equal{\thepage}{1}}\r
- { % First page\r
- \begin{tabular}{rcl}\r
- Invoice date & & Invoice number \\\r
- \vspace{0.2cm}\r
- \textbf{[@-- $date --@]} & & \textbf{[@-- $invnum --@]} \\\hline\r
- \rule{0pt}{5ex} &~~ \huge{\textsc{Statement}} & \\\r
- \vspace{-0.2cm}\r
- & & \\\hline\r
- \end{tabular}\r
- }\r
- { % ... pages\r
- \small{\r
- \begin{tabular}{ll}\r
- Invoice date & Invoice number\\\r
- \textbf{[@-- $date --@]} & \textbf{[@-- $invnum --@]}\\\r
- \end{tabular}\r
- }\r
- }\r
-}\r
-\r
-\pagestyle{fancy}\r
-\r
-\r
-%% Font options are:\r
-%% bch Bitsream Charter\r
-%% put Utopia\r
-%% phv Adobe Helvetica\r
-%% pnc New Century Schoolbook\r
-%% ptm Times\r
-%% pcr Courier\r
-\r
-\renewcommand{\familydefault}{phv}\r
-\r
-\r
-% Commands for freeside description...\r
-\newcommand{\FSdesc}[3]{\r
- \multicolumn{1}{c}{\rule{0pt}{2.5ex}\textbf{#1}} &\r
- \textbf{#2} &\r
- \multicolumn{1}{r}{\textbf{\dollar #3}}\\\r
-}\r
-% ...extended description...\r
-\newcommand{\FSextdesc}[1]{\r
- \multicolumn{1}{l}{\rule{0pt}{1.0ex}} &\r
- \multicolumn{2}{l}{\small{~-~#1}}\\\r
-}\r
-% ...and total line items.\r
-\newcommand{\FStotaldesc}[2]{\r
- & \multicolumn{1}{l}{#1} & #2\\\r
-}\r
-\r
-\r
-\begin{document}\r
-%\r
-%% Headers and footers defined for the first page\r
-%\r
-%% The LH Heading comprising logo\r
-%% UNCOMMENT the following FOUR lines and change the path if necssary to provide a logo\r
-%\r
-%% The Heading comprising isue date, customer ref & INVOICE name\r
-%\r
-%% Header & footer changes for subsequent pages\r
-%\r
-%\r
-%\r
-\begin{tabular}{ll}\r
-\addressinset \rule{0cm}{0cm} &\r
-\makebox{\r
-\begin{minipage}[t]{5.0cm}\r
-\vspace{0.25cm}\r
-\textbf{[@-- $payname --@]}\\\r
-\addressline{[@-- $company --@]}\r
-\addressline{[@-- $address1 --@]}\r
-\addressline{[@-- $address2 --@]}\r
-\addressline{[@-- $city --@], [@-- $state --@]~~[@-- $zip --@]}\r
-\addressline{[@-- $country --@]}\r
-\end{minipage}}\r
-\end{tabular}\r
-\hfill\r
-\makebox{\r
-\begin{minipage}[t]{6.4cm}\r
-\begin{flushright}\r
-Terms: [@-- $terms --@]\\\r
-[@-- $po_line --@]\\\r
-\end{flushright}\r
-\end{minipage}}\r
-\vspace{1.5cm}\r
-%\r
-\section*{\textsc{Charges}}\r
-\begin{longtable}{clr}\r
-\hline\r
-\rule{0pt}{2.5ex}\r
-\makebox[1.4cm]{\textbf{Ref}} & \r
-\makebox[12.8cm][l]{\textbf{Description}} & \r
-\makebox[2.5cm][r]{\textbf{Amount}} \\\r
-\hline\r
-\endfirsthead\r
-\multicolumn{3}{r}{\rule{0pt}{2.5ex}Continued from previous page}\\\r
-\hline\r
-\rule{0pt}{2.5ex}\r
-\makebox[1.4cm]{\textbf{Ref}} & \r
-\makebox[12.8cm][l]{\textbf{Description}} & \r
-\makebox[2.5cm][r]{\textbf{Amount}} \\\r
-\hline\r
-\endhead\r
-\multicolumn{3}{r}{\rule{0pt}{2.5ex}Continued on next page...}\\\r
-\endfoot\r
-\hline\r
-[@--\r
-\r
- foreach my $line (@total_items) {\r
- $OUT .= '\FStotaldesc{' . $line->{'total_item'} . '}' .\r
- '{' . $line->{'total_amount'} . '}' . "\n";\r
- }\r
-\r
---@]\r
-\hline\r
-\endlastfoot\r
-[@--\r
-\r
- foreach my $line (@detail_items) {\r
- my $ext_description = $line->{'ext_description'};\r
-\r
- # Don't break-up small packages.\r
- my $rowbreak = @$ext_description < 5 ? '*' : '';\r
-\r
- $OUT .= "\\hline\n";\r
- $OUT .= '\FSdesc{' . $line->{'ref'} . '}{' . $line->{'description'} . '}' .\r
- '{' . $line->{'amount'} . "}${rowbreak}\n";\r
-\r
- foreach my $ext_desc (@$ext_description) {\r
- $ext_desc = substr($ext_desc, 0, 80) . '...'\r
- if (length($ext_desc) > 80);\r
- $OUT .= '\FSextdesc{' . $ext_desc . '}' . "${rowbreak}\n";\r
- }\r
-\r
- }\r
-\r
---@]\r
-\end{longtable}\r
-\vfill\r
-[@-- $notes --@]\r
-\end{document}\r
+++ /dev/null
-
- Statement
- { substr("Page $page of $total_pages ", 0, 19); } { use Date::Format; time2str("%x", $date); } Invoice #{ $invnum; }
-
-
-{ $company_name; }
-{ $company_address; }
-
-
-{ $address[0]; }
-{ $address[1]; }
-{ $address[2]; }
-{ $address[3]; }
-{ $address[4]; }
-{ $address[5]; }
-
-{
- join("\n",
- map {
- my ( $desc, $price ) = @{$_};
- " ". substr( $desc. " "x65, 0, 65). " ". substr( $price. " "x11, 0, 11);
- } invoice_lines(31)
- );
-}
-
- -=> { $company_name; } <=-