\r
\documentclass[letterpaper]{article}\r
\r
-\usepackage{fancyhdr,lastpage,ifthen,longtable,afterpage}\r
+\usepackage{fancyhdr,lastpage,ifthen,array,longtable,afterpage,caption,multirow,bigstrut}\r
+\usepackage[breakwords]{truncate} % to avoid overflowing boxes\r
\usepackage{graphicx} % required for logo graphic\r
+\usepackage[utf8]{inputenc} % multilanguage support\r
+\usepackage[T1]{fontenc}\r
+[@-- if ( length($watermark) ) {\r
+ $OUT .= '\r
+\usepackage{background}\r
+\backgroundsetup{\r
+ placement=center,\r
+ opacity=0.25,\r
+ color=black,\r
+ angle=0,\r
+ contents=' . $watermark . '\r
+}';\r
+}\r
+'';\r
+--@]\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
+\addtolength{\topmargin}{[@-- defined($topmargin) ? $topmargin : '-1.00cm' --@]}\r
\setlength{\headheight}{2.0cm} % height of header\r
-\setlength{\headsep}{1.0cm} % between header and text\r
+\setlength{\headsep}{[@-- defined($headsep) ? $headsep : '1.0cm' --@]}\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{\textheight}{[@-- defined($textheight) ? $textheight : '19.5cm' --@]}\r
\setlength{\oddsidemargin}{-0.9cm} % odd page left margin\r
\setlength{\evensidemargin}{-0.9cm} % even page left margin\r
\r
+\LTchunksize=40\r
+\r
\renewcommand{\headrulewidth}{0pt}\r
\renewcommand{\footrulewidth}{1pt}\r
\r
+\renewcommand{\footrule}{\r
+[@--\r
+ $coupon ? '\ifthenelse{\equal{\thepage}{1}}' : '';\r
+--@]\r
+ {\r
+ }\r
+ {\r
+ \vbox to 0pt{\rule{\headwidth}{\footrulewidth}\vss}\r
+ }\r
+}\r
+\r
+\newcommand{\extracouponspace}{[@-- defined($extracouponspace) ? $extracouponspace : '2.7in' --@]}\r
+\r
% Adjust the inset of the mailing address\r
\newcommand{\addressinset}[1][]{\hspace{1.0cm}}\r
\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
+\newcommand{\addressline}[1]{\ifthenelse{\equal{#1}{}}{}{#1\\}}\r
\r
% Inserts dollar symbol\r
\newcommand{\dollar}[1][]{\symbol{36}}\r
\fancyfoot[C]{\r
\ifthenelse{\equal{\thepage}{1}}\r
{ % First page\r
- \small{\r
+[@--\r
+ if ($coupon) {\r
+ $OUT .= '\vspace{-\extracouponspace}';\r
+ $OUT .= '\rule[0.5em]{\textwidth}{\footrulewidth}\\\\';\r
+ $OUT .= $coupon;\r
+ $OUT .= '\vspace{'.\r
+ (defined($couponfootsep) ? $couponfootsep : '0.2in') .\r
+ '}';\r
+ }\r
+ '';\r
+--@] [@-- $smallerfooter ? '\scriptsize{' : '\small{' --@]\r
[@-- $footer --@]\r
- }\r
+ }[@-- $coupon ? '\vspace{\extracouponspace}' : '' --@]\r
}\r
{ % ... pages\r
- \small{\r
+ [@-- $smallerfooter ? '\scriptsize{' : '\small{' --@]\r
[@-- $smallfooter --@]\r
}\r
}\r
{ % First page\r
}\r
{ % ... pages\r
- \small{\thepage\ of \pageref{LastPage}}\r
+ \small{\thepage~[@-- emt('of') --@]~\pageref{LastPage}}\r
}\r
}\r
\r
\returninset\r
\makebox{\r
\begin{tabular}{ll}\r
- \includegraphics{[@-- $conf_dir --@]/logo.eps} &\r
- \begin{minipage}[b]{3.5cm}\r
+ \begin{minipage}[b]{5.5cm}\r
[@-- $returnaddress --@]\r
- \end{minipage}\r
+ \end{minipage} &\r
+ \includegraphics{[@-- $logo_file --@]}\\\r
\end{tabular}\r
}\r
}\r
{ % ... pages\r
- %\includegraphics{[@-- $conf_dir --@]/logo.eps} % Uncomment if you want the logo on all pages.\r
+ %\includegraphics{[@-- $logo_file --@]} % 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
+ \begin{tabular}{ccc}\r
+ [@-- join(' & ', ( $no_date ? '' : emt('Invoice date') ),\r
+ ( $no_number ? '' : emt('Invoice #') ),\r
+ emt('Customer #')\r
+ )\r
+ --@]\\\r
\vspace{0.2cm}\r
- \textbf{[@-- $date --@]} & & \textbf{[@-- $invnum --@]} \\\hline\r
- \rule{0pt}{5ex} &~~ \huge{\textsc{Invoice}} & \\\r
+ \textbf{[@-- $date --@]} & \textbf{[@-- $invnum --@]} & \textbf{[@-- $custnum --@]} \\\hline\r
+ \rule{0pt}{5ex} &~~ \huge{\textsc{[@-- emt($notice_name) --@]}} & \\\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
+ \begin{tabular}{lll}\r
+ [@-- join(' & ', emt('Invoice date'), emt('Invoice #'), emt('Customer #') ) --@]\\\r
+ \textbf{[@-- $date --@]} & \textbf{[@-- $invnum --@]} & \textbf{[@-- $custnum --@]}\\\r
\end{tabular}\r
}\r
}\r
\renewcommand{\familydefault}{phv}\r
\r
\r
-% Commands for freeside description...\r
-\newcommand{\FSdesc}[3]{\r
+% Commands for freeside table header...\r
+\r
+\newcommand{\FSdescriptionlength} { [@-- $unitprices ? '8.2cm' : '12.8cm' --@] }\r
+\newcommand{\FSdescriptioncolumncount} { [@-- $unitprices ? '4' : '6' --@] }\r
+\newcommand{\FSunitcolumns}{ [@-- \r
+ $unitprices\r
+ ? '\makebox[2.5cm][r]{\textbf{~~' . emt('Unit Price') . '}} &' .\r
+ '\makebox[1.4cm]{\textbf{~' . emt('Quantity') . '}} & ' \r
+ : '' --@] }\r
+\r
+\newcommand{\FShead}{\r
+ \hline\r
+ \rule{0pt}{2.5ex}\r
+ \makebox[1.4cm]{} &\r
+ \multicolumn{\FSdescriptioncolumncount}{l}{\r
+ \truncate{\FSdescriptionlength}{\textbf{[@-- emt('Description') --@]}}\r
+ } &\r
+ \FSunitcolumns\r
+ \makebox[1.6cm][r]{\textbf{[@-- emt('Amount') --@]}} \\\r
+ \hline\r
+}\r
+\r
+\newcommand{\FSusagehead}{\r
+ \hline\r
+ \rule{0pt}{2.5ex}\r
+ \makebox[1.4cm]{} &\r
+ \multicolumn{4}{l}{\r
+ \truncate{\FSdescriptionlength}{\textbf{[@-- emt('Description') --@]}}\r
+ } &\r
+ \textbf{~~[@-- emt('Calls') --@]} &\r
+ \textbf{~~[@-- emt('Duration') --@]} &\r
+ \textbf{~~[@-- emt('Amount') --@]} \\\r
+ \hline\r
+}\r
+\r
+% ...description...\r
+\newcommand{\FSdesc}[5]{\r
\multicolumn{1}{c}{\rule{0pt}{2.5ex}\textbf{#1}} &\r
- \textbf{#2} &\r
- \multicolumn{1}{r}{\textbf{\dollar #3}}\\\r
+ \multicolumn{[@-- $unitprices ? '4' : '6' --@]}{l}{\r
+ \truncate{\FSdescriptionlength}{\textbf{#2}}\r
+ } &\r
+[@-- $unitprices ? ' \multicolumn{1}{r}{\textbf{#3}} &'."\n".\r
+ ' \multicolumn{1}{r}{\textbf{#4}} &'."\n"\r
+ : ''\r
+--@]\r
+ \multicolumn{1}{r}{\textbf{#5}}\\\r
}\r
% ...extended description...\r
\newcommand{\FSextdesc}[1]{\r
\multicolumn{1}{l}{\rule{0pt}{1.0ex}} &\r
- \multicolumn{2}{l}{\small{~-~#1}}\\\r
+ \multicolumn{6}{l}{\r
+ \truncate{12.8cm}{\small{~~~#1}}\r
+ } \\\r
}\r
-% ...and total line items.\r
+% ...call detail (multiple columns already)...\r
+\newcommand{\FScalldetail}[1]{\r
+ \multicolumn{1}{l}{\rule{0pt}{1.0ex}} &\r
+ ~~~#1\r
+ \\\r
+}\r
+}\r
+% ...and total line items (which use the full 12.8cm length, ignoring\r
+% unitprice/quantity\r
\newcommand{\FStotaldesc}[2]{\r
- & \multicolumn{1}{l}{#1} & #2\\\r
+ & \multicolumn{6}{l}{\r
+ \truncate{12.8cm}{#1}\r
+ } & #2\\\r
}\r
\r
+% ...usage class summary\r
+\newcommand{\FSusagedesc}[4]{\r
+ \multicolumn{1}{c}{\rule{0pt}{2.5ex}} &\r
+ \multicolumn{4}{l}{\textbf{#1}} &\r
+ \multicolumn{1}{r}{\textbf{#2}} &\r
+ \multicolumn{1}{r}{\textbf{#3}} &\r
+ \multicolumn{1}{r}{\textbf{#4}}\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
+% Headers and footers defined for the first page\r
+\addressinset \rule{0.5cm}{0cm} \r
\makebox{\r
-\begin{minipage}[t]{5.0cm}\r
-\vspace{0.25cm}\r
+\begin{minipage}[t]{7.0cm}\r
+\vspace{[@-- defined($addresssep) ? $addresssep : '0.25cm' --@]}\r
\textbf{[@-- $payname --@]}\\\r
\addressline{[@-- $company --@]}\r
\addressline{[@-- $address1 --@]}\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
+[@--\r
+ if ($ship_enable) {\r
+ $OUT .= '\textbf{' . emt('Service Address') . '}\\\\';\r
+ $OUT .= "\\addressline{$ship_company}";\r
+ $OUT .= "\\addressline{$ship_address1}";\r
+ $OUT .= "\\addressline{$ship_address2}";\r
+ $OUT .= "\\addressline{$ship_city, $ship_state~~$ship_zip}";\r
+ $OUT .= "\\addressline{$ship_country}";\r
+ $OUT .= '~\\\\';\r
+ }else{\r
+ $OUT .= '';\r
+ }\r
+--@]\r
\begin{flushright}\r
-Terms: [@-- $terms --@]\\\r
+[@-- $terms ? emt('Terms') . ': ' . emt($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
+[@-- $summary --@]\r
+%\r
+\section*{}\r
[@--\r
+ foreach my $section ( grep { !$summary || $_->{description} ne $finance_section } @sections ) {\r
+ if ($section->{'pretotal'} && !$summary) {\r
+ $OUT .= '\begin{flushright}';\r
+ $OUT .= '\large\textsc{'. $section->{'pretotal'}. '}\\\\';\r
+ $OUT .= '\\end{flushright}';\r
+ }\r
+ $OUT .= '\pagebreak' if $section->{'post_total'};\r
+ unless ($section->{'summarized'} ) {\r
+ $OUT .= '\captionsetup{singlelinecheck=false,justification=raggedright,font={Large,sc,bf}}';\r
+ $OUT .= '\ifthenelse{\equal{\thepage}{1}}{\setlength{\LTextracouponspace}{\extracouponspace}}{\setlength{\LTextracouponspace}{0pt}}'\r
+ if $coupon;\r
+ $OUT .= '\begin{longtable}{cllllllr}';\r
+ $OUT .= '\caption*{ ';\r
+ if ($section->{'location'}) {\r
+ $OUT .= $section->{'location'}{'label_prefix'}. ': '\r
+ if length($section->{'location'}{'label_prefix'});\r
+ $OUT .= $section->{'location'}{'address1'};\r
+ $OUT .= ', ' . $section->{'location'}{'address2'}\r
+ if length($section->{'location'}{'address2'});\r
+ $OUT .= ', ' .\r
+ $section->{'location'}{'city'} . ', ' .\r
+ $section->{'location'}{'state'} . '~' .\r
+ $section->{'location'}{'zip'};\r
+ } elsif ( $section->{'description'} ) {\r
+ $OUT .= ($section->{'description'});\r
+ } else {\r
+ $OUT .= emt('Charges');\r
+ }\r
+ $OUT .= '}\\\\';\r
+ if ($section->{header_generator}) {\r
+ $OUT .= &{$section->{header_generator}}();\r
+ } elsif ( $section->{usage_section} ) {\r
+ $OUT .= '\FSusagehead';\r
+ } else {\r
+ $OUT .= '\FShead';\r
+ }\r
+ $OUT .= '\endfirsthead';\r
+ $OUT .= '\multicolumn{7}{r}{\rule{0pt}{2.5ex}'.emt('Continued from previous page').'}\\\\';\r
+ if ($section->{header_generator}) {\r
+ $OUT .= &{$section->{header_generator}}();\r
+ } elsif ( $section->{usage_section} ) {\r
+ $OUT .= '\FSusagehead';\r
+ } else {\r
+ $OUT .= '\FShead';\r
+ }\r
+ $OUT .= '\endhead';\r
+ $OUT .= '\multicolumn{7}{r}{\rule{0pt}{2.5ex}'.emt('Continued on next page...').'}\\\\';\r
+ $OUT .= '\endfoot';\r
+ $OUT .= '\hline';\r
\r
- foreach my $line (@total_items) {\r
- $OUT .= '\FStotaldesc{' . $line->{'total_item'} . '}' .\r
- '{' . $line->{'total_amount'} . '}' . "\n";\r
- }\r
+ if (scalar(@sections) > 1 and !$section->{no_subtotal}) {\r
+ if ($section->{total_generator}) {\r
+ $OUT .= &{$section->{total_generator}}($section);\r
+ } else {\r
+ $OUT .= '\FStotaldesc{' . $section->{'description'} . ' Total}' .\r
+ '{' . $section->{'subtotal'} . '}' . "\n";\r
+ }\r
+ }\r
\r
---@]\r
-\hline\r
-\endlastfoot\r
-[@--\r
+ #if ($section == $sections[$#sections]) {\r
+ foreach my $line (grep {$_->{section}->{description} eq $section->{description}} @total_items) {\r
+ if ($section->{total_line_generator}) {\r
+ $OUT .= &{$section->{total_line_generator}}($line);\r
+ } else {\r
+ $OUT .= '\FStotaldesc{' . $line->{'total_item'} . '}' .\r
+ '{' . $line->{'total_amount'} . '}' . "\n";\r
+ }\r
+ }\r
+ #}\r
\r
- foreach my $line (@detail_items) {\r
- my $ext_description = $line->{'ext_description'};\r
+ $OUT .= '\hline';\r
+ $OUT .= '\endlastfoot';\r
\r
- # Don't break-up small packages.\r
- my $rowbreak = @$ext_description < 5 ? '*' : '';\r
+ my $lastref = 0;\r
+ foreach my $line (\r
+ grep { ( scalar( @sections ) > 1 \r
+ ? $section->{'description'} eq $_->{'section'}->{'description'}\r
+ : 1\r
+ ) }\r
+ @detail_items )\r
+ {\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" if (($line->{'ref'} || 0) ne $lastref);\r
+ if ($section->{description_generator}) {\r
+ $OUT .= &{$section->{description_generator}}($line);\r
+ } elsif ($section->{usage_section}) {\r
+ my $minutes = sprintf('%d', $line->{'duration'} / 60);\r
+ my $seconds = $line->{'duration'} % 60;\r
+ $OUT .= '\FSusagedesc\r
+ {' . $line->{'description'} . '}\r
+ {' . $line->{'quantity'} . '}\r
+ {' . $minutes . 'm ' . $seconds . 's' . '}\r
+ {' . $line->{'amount'} . '}';\r
+ } else {\r
+ $OUT .= '\FSdesc'.\r
+ '{}'.\r
+ '{' . $line->{'description'} . '}' ;\r
+ if ( $unitprices and length($line->{'unit_amount'}) ) {\r
+ # then show the unit amount and quantity\r
+ $OUT .= \r
+ '{\\dollar' . $line->{'unit_amount'} . '}'.\r
+ '{' . $line->{'quantity'} . '}';\r
+ } else {\r
+ # leave those columns blank\r
+ $OUT .= '{}{}';\r
+ }\r
+ $OUT .= '{\\dollar' . $line->{'amount'} . "}${rowbreak}\n";\r
+ }\r
+ $lastref = $line->{'ref'} || 0;\r
\r
- $OUT .= "\\hline\n";\r
- $OUT .= '\FSdesc{' . $line->{'ref'} . '}{' . $line->{'description'} . '}' .\r
- '{' . $line->{'amount'} . "}${rowbreak}\n";\r
+ foreach my $ext_desc (@$ext_description) {\r
+ if ($section->{extended_description_generator}) {\r
+ $OUT .= &{$section->{extended_description_generator}}($ext_desc);\r
+ } elsif ( $ext_desc !~ /[^\\]&/ ) {\r
+ $OUT .= '\FSextdesc{' . $ext_desc . "}$rowbreak\n";\r
+ } else { # call detail\r
+ $OUT .= '\FScalldetail{' . $ext_desc . "}$rowbreak\n";\r
+ }\r
+ }\r
\r
- foreach my $ext_desc (@$ext_description) {\r
- $ext_desc = substr($ext_desc, 0, 70) . '...'\r
- if (length($ext_desc) > 70);\r
- $OUT .= '\FSextdesc{' . $ext_desc . '}' . "${rowbreak}\n";\r
- }\r
+ }\r
\r
+ $OUT .= '\end{longtable}';\r
+ }\r
+ if ($section->{'posttotal'}) {\r
+ $OUT .= '\begin{flushright}';\r
+ $OUT .= '\normalfont\large\bfseries\textsc{'. $section->{'posttotal'}. '}\\\\';\r
+ $OUT .= '\\end{flushright}';\r
+ }\r
}\r
\r
--@]\r
-\end{longtable}\r
\vfill\r
-[@-- $notes --@]\r
+\begin{minipage}[t]{\textwidth}\r
+ [@-- length($summary)\r
+ ? ''\r
+ : ( $smallernotes\r
+ ? '\scriptsize{ '.$notes.' }'\r
+ : $notes\r
+ )\r
+ --@]\r
+ [@-- $coupon ? '\ifthenelse{\equal{\thepage}{1}}{\rule{0pt}{\extracouponspace}}{}' : '' --@]\r
+\end{minipage}\r
\end{document}\r