1 %% file: Standard Multipage.tex
\r
2 %% Purpose: Multipage bill template for e-Bills
\r
4 %% Created by Mark Asplen-Taylor
\r
5 %% Asplen Management Ltd
\r
8 %% Modified for Freeside by Kristian Hoffman
\r
11 %% 0.1 4/12/00 Created
\r
12 %% 0.2 18/10/01 More fields added
\r
13 %% 1.0 16/11/01 RELEASED
\r
14 %% 1.2 16/10/02 Invoice number added
\r
15 %% 1.3 2/12/02 Logo graphic added
\r
16 %% 1.4 7/2/03 Multipage headers/footers added
\r
17 %% n/a forked for Freeside; checked into CVS
\r
20 \documentclass[letterpaper]{article}
\r
22 \usepackage{fancyhdr,lastpage,ifthen,array,longtable,afterpage,caption,multirow,bigstrut}
\r
23 \usepackage[breakwords]{truncate} % to avoid overflowing boxes
\r
24 \usepackage{graphicx} % required for logo graphic
\r
25 \usepackage[utf8]{inputenc} % multilanguage support
\r
26 \usepackage[T1]{fontenc}
\r
27 [@-- if ( length($watermark) ) {
\r
29 \usepackage{background}
\r
35 contents=' . $watermark . '
\r
41 \addtolength{\voffset}{-0.0cm} % top margin to top of header
\r
42 \addtolength{\hoffset}{-0.6cm} % left margin on page
\r
43 \addtolength{\topmargin}{[@-- defined($topmargin) ? $topmargin : '-1.00cm' --@]}
\r
44 \setlength{\headheight}{2.0cm} % height of header
\r
45 \setlength{\headsep}{[@-- defined($headsep) ? $headsep : '1.0cm' --@]}
\r
46 \setlength{\footskip}{1.0cm} % bottom of footer from bottom of text
\r
48 %\addtolength{\textwidth}{2.1in} % width of text
\r
49 \setlength{\textwidth}{19.5cm}
\r
50 \setlength{\textheight}{[@-- defined($textheight) ? $textheight : '19.5cm' --@]}
\r
51 \setlength{\oddsidemargin}{-0.9cm} % odd page left margin
\r
52 \setlength{\evensidemargin}{-0.9cm} % even page left margin
\r
56 \renewcommand{\headrulewidth}{0pt}
\r
57 \renewcommand{\footrulewidth}{1pt}
\r
59 \renewcommand{\footrule}{
\r
61 $coupon ? '\ifthenelse{\equal{\thepage}{1}}' : '';
\r
66 \vbox to 0pt{\rule{\headwidth}{\footrulewidth}\vss}
\r
70 \newcommand{\extracouponspace}{[@-- defined($extracouponspace) ? $extracouponspace : '2.7in' --@]}
\r
72 % Adjust the inset of the mailing address
\r
73 \newcommand{\addressinset}[1][]{\hspace{1.0cm}}
\r
75 % Adjust the inset of the return address and logo
\r
76 \newcommand{\returninset}[1][]{\hspace{-0.25cm}}
\r
78 % New command for address lines i.e. skip them if blank
\r
79 \newcommand{\addressline}[1]{\ifthenelse{\equal{#1}{}}{}{#1\\}}
\r
81 % Inserts dollar symbol
\r
82 \newcommand{\dollar}[1][]{\symbol{36}}
\r
84 % Remove plain style header/footer
\r
85 \fancypagestyle{plain}{
\r
90 % Define fancy header/footer for first and subsequent pages
\r
92 \ifthenelse{\equal{\thepage}{1}}
\r
96 $OUT .= '\vspace{-\extracouponspace}';
\r
97 $OUT .= '\rule[0.5em]{\textwidth}{\footrulewidth}\\\\';
\r
100 (defined($couponfootsep) ? $couponfootsep : '0.2in') .
\r
104 --@] [@-- $smallerfooter ? '\scriptsize{' : '\small{' --@]
\r
106 }[@-- $coupon ? '\vspace{\extracouponspace}' : '' --@]
\r
109 [@-- $smallerfooter ? '\scriptsize{' : '\small{' --@]
\r
110 [@-- $smallfooter --@]
\r
116 \ifthenelse{\equal{\thepage}{1}}
\r
120 \small{\thepage~[@-- emt('of') --@]~\pageref{LastPage}}
\r
125 \ifthenelse{\equal{\thepage}{1}}
\r
129 \begin{tabular}{ll}
\r
130 \begin{minipage}[b]{5.5cm}
\r
131 [@-- $returnaddress --@]
\r
133 \includegraphics{[@-- $logo_file --@]}\\
\r
138 %\includegraphics{[@-- $logo_file --@]} % Uncomment if you want the logo on all pages.
\r
143 \ifthenelse{\equal{\thepage}{1}}
\r
145 \begin{tabular}{ccc}
\r
146 [@-- join(' & ', ( $no_date ? '' : emt('Invoice date') ),
\r
147 ( $no_number ? '' : emt('Invoice #') ),
\r
152 \textbf{[@-- $date --@]} & \textbf{[@-- $invnum --@]} & \textbf{[@-- $custnum --@]} \\\hline
\r
153 \rule{0pt}{5ex} &~~ \huge{\textsc{[@-- emt($notice_name) --@]}} & \\
\r
160 \begin{tabular}{lll}
\r
161 [@-- join(' & ', emt('Invoice date'), emt('Invoice #'), emt('Customer #') ) --@]\\
\r
162 \textbf{[@-- $date --@]} & \textbf{[@-- $invnum --@]} & \textbf{[@-- $custnum --@]}\\
\r
171 %% Font options are:
\r
172 %% bch Bitsream Charter
\r
174 %% phv Adobe Helvetica
\r
175 %% pnc New Century Schoolbook
\r
179 \renewcommand{\familydefault}{phv}
\r
182 % Commands for freeside table header...
\r
184 \newcommand{\FSdescriptionlength} { [@-- $unitprices ? '8.2cm' : '12.8cm' --@] }
\r
185 \newcommand{\FSdescriptioncolumncount} { [@-- $unitprices ? '4' : '6' --@] }
\r
186 \newcommand{\FSunitcolumns}{ [@--
\r
188 ? '\makebox[2.5cm][r]{\textbf{~~' . emt('Unit Price') . '}} &' .
\r
189 '\makebox[1.4cm]{\textbf{~' . emt('Quantity') . '}} & '
\r
192 \newcommand{\FShead}{
\r
195 \makebox[1.4cm]{} &
\r
196 \multicolumn{\FSdescriptioncolumncount}{l}{
\r
197 \truncate{\FSdescriptionlength}{\textbf{[@-- emt('Description') --@]}}
\r
200 \makebox[1.6cm][r]{\textbf{[@-- emt('Amount') --@]}} \\
\r
204 \newcommand{\FSusagehead}{
\r
207 \makebox[1.4cm]{} &
\r
208 \multicolumn{4}{l}{
\r
209 \truncate{\FSdescriptionlength}{\textbf{[@-- emt('Description') --@]}}
\r
211 \textbf{~~[@-- emt('Calls') --@]} &
\r
212 \textbf{~~[@-- emt('Duration') --@]} &
\r
213 \textbf{~~[@-- emt('Amount') --@]} \\
\r
217 % ...description...
\r
218 \newcommand{\FSdesc}[5]{
\r
219 \multicolumn{1}{c}{\rule{0pt}{2.5ex}\textbf{#1}} &
\r
220 \multicolumn{[@-- $unitprices ? '4' : '6' --@]}{l}{
\r
221 \truncate{\FSdescriptionlength}{\textbf{#2}}
\r
223 [@-- $unitprices ? ' \multicolumn{1}{r}{\textbf{#3}} &'."\n".
\r
224 ' \multicolumn{1}{r}{\textbf{#4}} &'."\n"
\r
227 \multicolumn{1}{r}{\textbf{#5}}\\
\r
229 % ...extended description...
\r
230 \newcommand{\FSextdesc}[1]{
\r
231 \multicolumn{1}{l}{\rule{0pt}{1.0ex}} &
\r
232 \multicolumn{6}{l}{
\r
233 \truncate{12.8cm}{\small{~~~#1}}
\r
236 % ...call detail (multiple columns already)...
\r
237 \newcommand{\FScalldetail}[1]{
\r
238 \multicolumn{1}{l}{\rule{0pt}{1.0ex}} &
\r
243 % ...and total line items (which use the full 12.8cm length, ignoring
\r
244 % unitprice/quantity
\r
245 \newcommand{\FStotaldesc}[2]{
\r
246 & \multicolumn{6}{l}{
\r
247 \truncate{12.8cm}{#1}
\r
251 % ...usage class summary
\r
252 \newcommand{\FSusagedesc}[4]{
\r
253 \multicolumn{1}{c}{\rule{0pt}{2.5ex}} &
\r
254 \multicolumn{4}{l}{\textbf{#1}} &
\r
255 \multicolumn{1}{r}{\textbf{#2}} &
\r
256 \multicolumn{1}{r}{\textbf{#3}} &
\r
257 \multicolumn{1}{r}{\textbf{#4}}
\r
262 % Headers and footers defined for the first page
\r
263 \addressinset \rule{0.5cm}{0cm}
\r
265 \begin{minipage}[t]{7.0cm}
\r
266 \vspace{[@-- defined($addresssep) ? $addresssep : '0.25cm' --@]}
\r
267 \textbf{[@-- $payname --@]}\\
\r
268 \addressline{[@-- $company --@]}
\r
269 \addressline{[@-- $address1 --@]}
\r
270 \addressline{[@-- $address2 --@]}
\r
271 \addressline{[@-- $city --@], [@-- $state --@]~~[@-- $zip --@]}
\r
272 \addressline{[@-- $country --@]}
\r
276 \begin{minipage}[t]{6.4cm}
\r
278 if ($ship_enable) {
\r
279 $OUT .= '\textbf{' . emt('Service Address') . '}\\\\';
\r
280 $OUT .= "\\addressline{$ship_company}";
\r
281 $OUT .= "\\addressline{$ship_address1}";
\r
282 $OUT .= "\\addressline{$ship_address2}";
\r
283 $OUT .= "\\addressline{$ship_city, $ship_state~~$ship_zip}";
\r
284 $OUT .= "\\addressline{$ship_country}";
\r
291 [@-- $terms ? emt('Terms') . ': ' . emt($terms) : '' --@]\\
\r
292 [@-- $po_line --@]\\
\r
301 foreach my $section ( grep { !$summary || $_->{description} ne $finance_section } @sections ) {
\r
302 if ($section->{'pretotal'} && !$summary) {
\r
303 $OUT .= '\begin{flushright}';
\r
304 $OUT .= '\large\textsc{'. $section->{'pretotal'}. '}\\\\';
\r
305 $OUT .= '\\end{flushright}';
\r
307 $OUT .= '\pagebreak' if $section->{'post_total'};
\r
308 unless ($section->{'summarized'} ) {
\r
309 $OUT .= '\captionsetup{singlelinecheck=false,justification=raggedright,font={Large,sc,bf}}';
\r
310 $OUT .= '\ifthenelse{\equal{\thepage}{1}}{\setlength{\LTextracouponspace}{\extracouponspace}}{\setlength{\LTextracouponspace}{0pt}}'
\r
312 $OUT .= '\begin{longtable}{cllllllr}';
\r
313 $OUT .= '\caption*{ ';
\r
314 if ($section->{'location'}) {
\r
315 $OUT .= $section->{'location'}{'label_prefix'}. ': '
\r
316 if length($section->{'location'}{'label_prefix'});
\r
317 $OUT .= $section->{'location'}{'address1'};
\r
318 $OUT .= ', ' . $section->{'location'}{'address2'}
\r
319 if length($section->{'location'}{'address2'});
\r
321 $section->{'location'}{'city'} . ', ' .
\r
322 $section->{'location'}{'state'} . '~' .
\r
323 $section->{'location'}{'zip'};
\r
324 } elsif ( $section->{'description'} ) {
\r
325 $OUT .= ($section->{'description'});
\r
327 $OUT .= emt('Charges');
\r
330 if ($section->{header_generator}) {
\r
331 $OUT .= &{$section->{header_generator}}();
\r
332 } elsif ( $section->{usage_section} ) {
\r
333 $OUT .= '\FSusagehead';
\r
337 $OUT .= '\endfirsthead';
\r
338 $OUT .= '\multicolumn{7}{r}{\rule{0pt}{2.5ex}'.emt('Continued from previous page').'}\\\\';
\r
339 if ($section->{header_generator}) {
\r
340 $OUT .= &{$section->{header_generator}}();
\r
341 } elsif ( $section->{usage_section} ) {
\r
342 $OUT .= '\FSusagehead';
\r
346 $OUT .= '\endhead';
\r
347 $OUT .= '\multicolumn{7}{r}{\rule{0pt}{2.5ex}'.emt('Continued on next page...').'}\\\\';
\r
348 $OUT .= '\endfoot';
\r
351 if (scalar(@sections) > 1 and !$section->{no_subtotal}) {
\r
352 if ($section->{total_generator}) {
\r
353 $OUT .= &{$section->{total_generator}}($section);
\r
355 $OUT .= '\FStotaldesc{' . $section->{'description'} . ' Total}' .
\r
356 '{' . $section->{'subtotal'} . '}' . "\n";
\r
360 #if ($section == $sections[$#sections]) {
\r
361 foreach my $line (grep {$_->{section}->{description} eq $section->{description}} @total_items) {
\r
362 if ($section->{total_line_generator}) {
\r
363 $OUT .= &{$section->{total_line_generator}}($line);
\r
365 $OUT .= '\FStotaldesc{' . $line->{'total_item'} . '}' .
\r
366 '{' . $line->{'total_amount'} . '}' . "\n";
\r
372 $OUT .= '\endlastfoot';
\r
376 grep { ( scalar( @sections ) > 1
\r
377 ? $section->{'description'} eq $_->{'section'}->{'description'}
\r
382 my $ext_description = $line->{'ext_description'};
\r
384 # Don't break-up small packages.
\r
385 my $rowbreak = @$ext_description < 5 ? '*' : '';
\r
387 $OUT .= "\\hline\n" if (($line->{'ref'} || 0) ne $lastref);
\r
388 if ($section->{description_generator}) {
\r
389 $OUT .= &{$section->{description_generator}}($line);
\r
390 } elsif ($section->{usage_section}) {
\r
391 my $minutes = sprintf('%d', $line->{'duration'} / 60);
\r
392 my $seconds = $line->{'duration'} % 60;
\r
393 $OUT .= '\FSusagedesc
\r
394 {' . $line->{'description'} . '}
\r
395 {' . $line->{'quantity'} . '}
\r
396 {' . $minutes . 'm ' . $seconds . 's' . '}
\r
397 {' . $line->{'amount'} . '}';
\r
401 '{' . $line->{'description'} . '}' ;
\r
402 if ( $unitprices and length($line->{'unit_amount'}) ) {
\r
403 # then show the unit amount and quantity
\r
405 '{\\dollar' . $line->{'unit_amount'} . '}'.
\r
406 '{' . $line->{'quantity'} . '}';
\r
408 # leave those columns blank
\r
411 $OUT .= '{\\dollar' . $line->{'amount'} . "}${rowbreak}\n";
\r
413 $lastref = $line->{'ref'} || 0;
\r
415 foreach my $ext_desc (@$ext_description) {
\r
416 if ($section->{extended_description_generator}) {
\r
417 $OUT .= &{$section->{extended_description_generator}}($ext_desc);
\r
418 } elsif ( $ext_desc !~ /[^\\]&/ ) {
\r
419 $OUT .= '\FSextdesc{' . $ext_desc . "}$rowbreak\n";
\r
420 } else { # call detail
\r
421 $OUT .= '\FScalldetail{' . $ext_desc . "}$rowbreak\n";
\r
427 $OUT .= '\end{longtable}';
\r
429 if ($section->{'posttotal'}) {
\r
430 $OUT .= '\begin{flushright}';
\r
431 $OUT .= '\normalfont\large\bfseries\textsc{'. $section->{'posttotal'}. '}\\\\';
\r
432 $OUT .= '\\end{flushright}';
\r
438 \begin{minipage}[t]{\textwidth}
\r
439 [@-- length($summary)
\r
442 ? '\scriptsize{ '.$notes.' }'
\r
446 [@-- $coupon ? '\ifthenelse{\equal{\thepage}{1}}{\rule{0pt}{\extracouponspace}}{}' : '' --@]
\r