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
45 /Title (Invoice \#[@-- $invnum --@])
\r
51 \addtolength{\voffset}{-0.0cm} % top margin to top of header
\r
52 \addtolength{\hoffset}{-0.6cm} % left margin on page
\r
53 \addtolength{\topmargin}{[@-- defined($topmargin) ? $topmargin : '-1.00cm' --@]}
\r
54 \setlength{\headheight}{2.0cm} % height of header
\r
55 \setlength{\headsep}{[@-- defined($headsep) ? $headsep : '1.0cm' --@]}
\r
56 \setlength{\footskip}{1.0cm} % bottom of footer from bottom of text
\r
58 %\addtolength{\textwidth}{2.1in} % width of text
\r
59 \setlength{\textwidth}{19.5cm}
\r
60 \setlength{\textheight}{[@-- defined($textheight) ? $textheight : '19.5cm' --@]}
\r
61 \setlength{\oddsidemargin}{-0.9cm} % odd page left margin
\r
62 \setlength{\evensidemargin}{-0.9cm} % even page left margin
\r
70 \renewcommand{\headrulewidth}{0pt}
\r
71 \renewcommand{\footrulewidth}{1pt}
\r
73 \renewcommand{\footrule}{
\r
75 $coupon ? '\ifthenelse{\equal{\thepage}{1}}' : '';
\r
80 \vbox to 0pt{\rule{\headwidth}{\footrulewidth}\vss}
\r
84 \newcommand{\extracouponspace}{[@-- defined($extracouponspace) ? $extracouponspace : '2.7in' --@]}
\r
86 % Adjust the inset of the mailing address
\r
87 \newcommand{\addressinset}[1][]{\hspace{1.0cm}}
\r
89 % Adjust the inset of the return address and logo
\r
90 \newcommand{\returninset}[1][]{\hspace{-0.25cm}}
\r
92 % New command for address lines i.e. skip them if blank
\r
93 \newcommand{\addressline}[1]{\ifthenelse{\equal{#1}{}}{}{#1\\}}
\r
95 % Inserts dollar symbol
\r
96 \newcommand{\dollar}[1][]{\symbol{36}}
\r
98 % Remove plain style header/footer
\r
99 \fancypagestyle{plain}{
\r
104 % Define fancy header/footer for first and subsequent pages
\r
106 \ifthenelse{\equal{\thepage}{1}}
\r
110 $OUT .= '\vspace{-\extracouponspace}';
\r
111 $OUT .= '\rule[0.5em]{\textwidth}{\footrulewidth}\\\\';
\r
113 $OUT .= '\vspace{'.
\r
114 (defined($couponfootsep) ? $couponfootsep : '0.2in') .
\r
118 --@] [@-- $smallerfooter ? '\scriptsize{' : '\small{' --@]
\r
120 }[@-- $coupon ? '\vspace{\extracouponspace}' : '' --@]
\r
123 [@-- $smallerfooter ? '\scriptsize{' : '\small{' --@]
\r
124 [@-- $smallfooter --@]
\r
130 \ifthenelse{\equal{\thepage}{1}}
\r
134 \small{\thepage~[@-- emt('of') --@]~\pageref{LastPage}}
\r
139 \ifthenelse{\equal{\thepage}{1}}
\r
143 \begin{tabular}{ll}
\r
144 \begin{minipage}[b]{5.5cm}
\r
145 [@-- $returnaddress --@]
\r
147 \includegraphics{[@-- $logo_file --@]}\\
\r
152 %\includegraphics{[@-- $logo_file --@]} % Uncomment if you want the logo on all pages.
\r
157 \ifthenelse{\equal{\thepage}{1}}
\r
159 \begin{tabular}{ccc}
\r
160 [@-- join(' & ', ( $no_date ? '' : emt('Invoice date') ),
\r
161 ( $no_number ? '' : emt('Invoice #') ),
\r
166 \textbf{[@-- $date --@]} & \textbf{[@-- $invnum --@]} & \textbf{[@-- $custnum --@]} \\\hline
\r
167 \rule{0pt}{5ex} &~~ \huge{\textsc{[@-- emt($notice_name) --@]}} & \\
\r
174 \begin{tabular}{lll}
\r
175 [@-- join(' & ', emt('Invoice date'), emt('Invoice #'), emt('Customer #') ) --@]\\
\r
176 \textbf{[@-- $date --@]} & \textbf{[@-- $invnum --@]} & \textbf{[@-- $custnum --@]}\\
\r
185 %% Font options are:
\r
186 %% bch Bitsream Charter
\r
188 %% phv Adobe Helvetica
\r
189 %% pnc New Century Schoolbook
\r
193 \renewcommand{\familydefault}{phv}
\r
196 % Commands for freeside table header...
\r
198 \newcommand{\FSdescriptionlength} { [@-- $unitprices ? '8.2cm' : '12.8cm' --@] }
\r
199 \newcommand{\FSdescriptioncolumncount} { [@-- $unitprices ? '4' : '6' --@] }
\r
200 \newcommand{\FSunitcolumns}{ [@--
\r
202 ? '\makebox[2.5cm][r]{\textbf{~~' . emt('Unit Price') . '}} &' .
\r
203 '\makebox[1.4cm]{\textbf{~' . emt('Quantity') . '}} & '
\r
206 \newcommand{\FShead}{
\r
209 \makebox[1.4cm]{} &
\r
210 \multicolumn{\FSdescriptioncolumncount}{l}{
\r
211 \truncate{\FSdescriptionlength}{\textbf{[@-- emt('Description') --@]}}
\r
214 \makebox[1.6cm][r]{\textbf{[@-- emt('Amount') --@]}} \\
\r
218 \newcommand{\FSusagehead}{
\r
221 \makebox[1.4cm]{} &
\r
222 \multicolumn{4}{l}{
\r
223 \truncate{\FSdescriptionlength}{\textbf{[@-- emt('Description') --@]}}
\r
225 \textbf{~~[@-- emt('Calls') --@]} &
\r
226 \textbf{~~[@-- emt('Duration') --@]} &
\r
227 \textbf{~~[@-- emt('Amount') --@]} \\
\r
231 % ...description...
\r
232 \newcommand{\FSdesc}[5]{
\r
233 \multicolumn{1}{c}{\rule{0pt}{2.5ex}\textbf{#1}} &
\r
234 \multicolumn{[@-- $unitprices ? '4' : '6' --@]}{l}{
\r
235 \truncate{\FSdescriptionlength}{\textbf{#2}}
\r
237 [@-- $unitprices ? ' \multicolumn{1}{r}{\textbf{#3}} &'."\n".
\r
238 ' \multicolumn{1}{r}{\textbf{#4}} &'."\n"
\r
241 \multicolumn{1}{r}{\textbf{#5}}\\
\r
243 % ...extended description...
\r
244 \newcommand{\FSextdesc}[1]{
\r
245 \multicolumn{1}{l}{\rule{0pt}{1.0ex}} &
\r
246 \multicolumn{6}{l}{
\r
247 \truncate{12.8cm}{\small{~~~#1}}
\r
250 % ...call detail (multiple columns already)...
\r
251 \newcommand{\FScalldetail}[1]{
\r
252 \multicolumn{1}{l}{\rule{0pt}{1.0ex}} &
\r
257 % ...and total line items (which use the full 12.8cm length, ignoring
\r
258 % unitprice/quantity
\r
259 \newcommand{\FStotaldesc}[2]{
\r
260 & \multicolumn{6}{l}{
\r
261 \truncate{12.8cm}{#1}
\r
265 % ...usage class summary
\r
266 \newcommand{\FSusagedesc}[4]{
\r
267 \multicolumn{1}{c}{\rule{0pt}{2.5ex}} &
\r
268 \multicolumn{4}{l}{\textbf{#1}} &
\r
269 \multicolumn{1}{r}{\textbf{#2}} &
\r
270 \multicolumn{1}{r}{\textbf{#3}} &
\r
271 \multicolumn{1}{r}{\textbf{#4}}
\r
275 % Headers and footers defined for the first page
\r
276 \addressinset \rule{0.5cm}{0cm}
\r
278 \begin{minipage}[t]{7.0cm}
\r
279 \vspace{[@-- defined($addresssep) ? $addresssep : '0.25cm' --@]}
\r
280 \textbf{[@-- $payname --@]}\\
\r
281 \addressline{[@-- $company --@]}
\r
282 \addressline{[@-- $address1 --@]}
\r
283 \addressline{[@-- $address2 --@]}
\r
284 \addressline{[@-- $city --@], [@-- $state --@]~~[@-- $zip --@]}
\r
285 \addressline{[@-- $country --@]}
\r
289 \begin{minipage}[t]{6.4cm}
\r
291 if ($ship_enable) {
\r
292 $OUT .= '\textbf{' . emt('Service Address') . '}\\\\';
\r
293 $OUT .= "\\addressline{$ship_company}";
\r
294 $OUT .= "\\addressline{$ship_address1}";
\r
295 $OUT .= "\\addressline{$ship_address2}";
\r
296 $OUT .= "\\addressline{$ship_city, $ship_state~~$ship_zip}";
\r
297 $OUT .= "\\addressline{$ship_country}";
\r
304 [@-- $terms ? emt('Terms') . ': ' . emt($terms) : '' --@]\\
\r
305 [@-- $po_line --@]\\
\r
314 foreach my $section ( grep { !$summary || $_->{description} ne $finance_section } @sections ) {
\r
315 if ($section->{'pretotal'} && !$summary) {
\r
316 $OUT .= '\begin{flushright}';
\r
317 $OUT .= '\large\textsc{'. $section->{'pretotal'}. '}\\\\';
\r
318 $OUT .= '\\end{flushright}';
\r
320 $OUT .= '\pagebreak' if $section->{'post_total'};
\r
321 unless ($section->{'summarized'} ) {
\r
322 $OUT .= '\captionsetup{singlelinecheck=false,justification=raggedright,font={Large,sc,bf}}';
\r
323 $OUT .= '\ifthenelse{\equal{\thepage}{1}}{\setlength{\LTextracouponspace}{\extracouponspace}}{\setlength{\LTextracouponspace}{0pt}}'
\r
325 $OUT .= '\begin{longtable}{cllllllr}';
\r
326 $OUT .= '\caption*{ ';
\r
327 if ($section->{'location'}) {
\r
328 $OUT .= $section->{'location'}{'label_prefix'}. ': '
\r
329 if length($section->{'location'}{'label_prefix'});
\r
330 $OUT .= $section->{'location'}{'address1'};
\r
331 $OUT .= ', ' . $section->{'location'}{'address2'}
\r
332 if length($section->{'location'}{'address2'});
\r
334 $section->{'location'}{'city'} . ', ' .
\r
335 $section->{'location'}{'state'} . '~' .
\r
336 $section->{'location'}{'zip'};
\r
337 } elsif ( $section->{'description'} ) {
\r
338 $OUT .= ($section->{'description'});
\r
340 $OUT .= emt('Charges');
\r
343 if ($section->{header_generator}) {
\r
344 $OUT .= &{$section->{header_generator}}();
\r
345 } elsif ( $section->{usage_section} ) {
\r
346 $OUT .= '\FSusagehead';
\r
350 $OUT .= '\endfirsthead';
\r
351 $OUT .= '\multicolumn{7}{r}{\rule{0pt}{2.5ex}'.emt('Continued from previous page').'}\\\\';
\r
352 if ($section->{header_generator}) {
\r
353 $OUT .= &{$section->{header_generator}}();
\r
354 } elsif ( $section->{usage_section} ) {
\r
355 $OUT .= '\FSusagehead';
\r
359 $OUT .= '\endhead';
\r
360 $OUT .= '\multicolumn{7}{r}{\rule{0pt}{2.5ex}'.emt('Continued on next page...').'}\\\\';
\r
361 $OUT .= '\endfoot';
\r
364 if (scalar(@sections) > 1 and !$section->{no_subtotal}) {
\r
365 if ($section->{total_generator}) {
\r
366 $OUT .= &{$section->{total_generator}}($section);
\r
368 $OUT .= '\FStotaldesc{' . $section->{'description'} . ' Total}' .
\r
369 '{' . $section->{'subtotal'} . '}' . "\n";
\r
373 #if ($section == $sections[$#sections]) {
\r
374 foreach my $line (grep {$_->{section}->{description} eq $section->{description}} @total_items) {
\r
375 if ($section->{total_line_generator}) {
\r
376 $OUT .= &{$section->{total_line_generator}}($line);
\r
378 $OUT .= '\FStotaldesc{' . $line->{'total_item'} . '}' .
\r
379 '{' . $line->{'total_amount'} . '}' . "\n";
\r
385 $OUT .= '\endlastfoot';
\r
389 grep { ( scalar( @sections ) > 1
\r
390 ? $section->{'description'} eq $_->{'section'}->{'description'}
\r
395 my $ext_description = $line->{'ext_description'};
\r
397 # Don't break-up small packages.
\r
398 my $rowbreak = @$ext_description < 5 ? '*' : '';
\r
400 $OUT .= "\\hline\n" if (($line->{'ref'} || 0) ne $lastref);
\r
401 if ($section->{description_generator}) {
\r
402 $OUT .= &{$section->{description_generator}}($line);
\r
403 } elsif ($section->{usage_section}) {
\r
404 my $minutes = sprintf('%d', $line->{'duration'} / 60);
\r
405 my $seconds = $line->{'duration'} % 60;
\r
406 $OUT .= '\FSusagedesc
\r
407 {' . $line->{'description'} . '}
\r
408 {' . $line->{'quantity'} . '}
\r
409 {' . $minutes . 'm ' . $seconds . 's' . '}
\r
410 {' . $line->{'amount'} . '}';
\r
414 '{' . $line->{'description'} . '}' ;
\r
415 if ( $unitprices and length($line->{'unit_amount'}) ) {
\r
416 # then show the unit amount and quantity
\r
418 '{\\dollar' . $line->{'unit_amount'} . '}'.
\r
419 '{' . $line->{'quantity'} . '}';
\r
421 # leave those columns blank
\r
424 $OUT .= '{\\dollar' . $line->{'amount'} . "}${rowbreak}\n";
\r
426 $lastref = $line->{'ref'} || 0;
\r
428 foreach my $ext_desc (@$ext_description) {
\r
429 if ($section->{extended_description_generator}) {
\r
430 $OUT .= &{$section->{extended_description_generator}}($ext_desc);
\r
431 } elsif ( $ext_desc !~ /[^\\]&/ ) {
\r
432 $OUT .= '\FSextdesc{' . $ext_desc . "}$rowbreak\n";
\r
433 } else { # call detail
\r
434 $OUT .= '\FScalldetail{' . $ext_desc . "}$rowbreak\n";
\r
440 $OUT .= '\end{longtable}';
\r
442 if ($section->{'posttotal'}) {
\r
443 $OUT .= '\begin{flushright}';
\r
444 $OUT .= '\normalfont\large\bfseries\textsc{'. $section->{'posttotal'}. '}\\\\';
\r
445 $OUT .= '\\end{flushright}';
\r
452 my @location_summary_sections =
\r
455 && $_->{locationnum}
\r
456 && $_->{description}
\r
457 && $_->{description} ne $finance_section
\r
459 if ( $multisection eq 'location' && scalar(@location_summary_sections) > 1 ) {
\r
464 \captionsetup{singlelinecheck=false,justification=raggedright,font={Large,sc,bf}}
\r
465 \ifthenelse{\equal{\thepage}{1}}{\setlength{\LTextracouponspace}{\extracouponspace}}{\setlength{\LTextracouponspace}{0pt}}
\r
467 \begin{longtable}{cllllllr}
\r
468 \caption*{ '. emt('Summary of New Charges by Location') .' }
\r
473 \makebox[1.4cm]{} &
\r
474 \multicolumn{6}{l}{
\r
475 \truncate{13.0cm}{\textbf{'. emt('Location') .'}}
\r
477 \makebox[1.6cm][r]{\textbf{'. emt('Amount') .'}} \\\\
\r
481 \multicolumn{7}{r}{\rule{0pt}{2.5ex}'. emt('Continued from previous page') .'}
\r
485 \multicolumn{7}{r}{\rule{0pt}{2.5ex}'. emt('Continued on next page...') .'}
\r
493 for my $section (@location_summary_sections) {
\r
496 \makebox[1.4cm]{} &
\r
497 \multicolumn{6}{l}{
\r
498 \truncate{12.0cm}{\textbf{'. $section->{description} .'}}
\r
500 \makebox[1.6cm][r]{\textbf{'. $section->{subtotal} .'}} \\\\
\r
504 $OUT .= '\end{longtable}';
\r
508 \begin{minipage}[t]{\textwidth}
\r
509 [@-- length($summary)
\r
512 ? '\scriptsize{ '.$notes.' }'
\r
516 [@-- $coupon ? '\ifthenelse{\equal{\thepage}{1}}{\rule{0pt}{\extracouponspace}}{}' : '' --@]
\r