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{graphicx} % required for logo graphic
\r
24 \usepackage[utf8]{inputenc} % multilanguage support
\r
25 \usepackage[T1]{fontenc}
\r
26 [@-- if ( length($watermark) ) {
\r
28 \usepackage{background}
\r
34 contents=' . $watermark . '
\r
40 \addtolength{\voffset}{-0.0cm} % top margin to top of header
\r
41 \addtolength{\hoffset}{-0.6cm} % left margin on page
\r
42 \addtolength{\topmargin}{[@-- defined($topmargin) ? $topmargin : '-1.00cm' --@]}
\r
43 \setlength{\headheight}{2.0cm} % height of header
\r
44 \setlength{\headsep}{[@-- defined($headsep) ? $headsep : '1.0cm' --@]}
\r
45 \setlength{\footskip}{1.0cm} % bottom of footer from bottom of text
\r
47 %\addtolength{\textwidth}{2.1in} % width of text
\r
48 \setlength{\textwidth}{19.5cm}
\r
49 \setlength{\textheight}{[@-- defined($textheight) ? $textheight : '19.5cm' --@]}
\r
50 \setlength{\oddsidemargin}{-0.9cm} % odd page left margin
\r
51 \setlength{\evensidemargin}{-0.9cm} % even page left margin
\r
55 \renewcommand{\headrulewidth}{0pt}
\r
56 \renewcommand{\footrulewidth}{1pt}
\r
58 \renewcommand{\footrule}{
\r
60 $coupon ? '\ifthenelse{\equal{\thepage}{1}}' : '';
\r
65 \vbox to 0pt{\rule{\headwidth}{\footrulewidth}\vss}
\r
69 \newcommand{\extracouponspace}{[@-- defined($extracouponspace) ? $extracouponspace : '2.7in' --@]}
\r
71 % Adjust the inset of the mailing address
\r
72 \newcommand{\addressinset}[1][]{\hspace{1.0cm}}
\r
74 % Adjust the inset of the return address and logo
\r
75 \newcommand{\returninset}[1][]{\hspace{-0.25cm}}
\r
77 % New command for address lines i.e. skip them if blank
\r
78 \newcommand{\addressline}[1]{\ifthenelse{\equal{#1}{}}{}{#1\\}}
\r
80 % Inserts dollar symbol
\r
81 \newcommand{\dollar}[1][]{\symbol{36}}
\r
83 % Remove plain style header/footer
\r
84 \fancypagestyle{plain}{
\r
89 % Define fancy header/footer for first and subsequent pages
\r
91 \ifthenelse{\equal{\thepage}{1}}
\r
95 $OUT .= '\vspace{-\extracouponspace}';
\r
96 $OUT .= '\rule[0.5em]{\textwidth}{\footrulewidth}\\\\';
\r
99 (defined($couponfootsep) ? $couponfootsep : '0.2in') .
\r
103 --@] [@-- $smallerfooter ? '\scriptsize{' : '\small{' --@]
\r
105 }[@-- $coupon ? '\vspace{\extracouponspace}' : '' --@]
\r
108 [@-- $smallerfooter ? '\scriptsize{' : '\small{' --@]
\r
109 [@-- $smallfooter --@]
\r
115 \ifthenelse{\equal{\thepage}{1}}
\r
119 \small{\thepage\ of \pageref{LastPage}}
\r
124 \ifthenelse{\equal{\thepage}{1}}
\r
128 \begin{tabular}{ll}
\r
129 \begin{minipage}[b]{5.5cm}
\r
130 [@-- $returnaddress --@]
\r
132 \includegraphics{[@-- $logo_file --@]}\\
\r
137 %\includegraphics{[@-- $logo_file --@]} % Uncomment if you want the logo on all pages.
\r
142 \ifthenelse{\equal{\thepage}{1}}
\r
144 \begin{tabular}{ccc}
\r
145 [@-- join(' & ', ( $no_date ? '' : emt('Invoice date') ),
\r
146 ( $no_number ? '' : emt('Invoice #') ),
\r
151 \textbf{[@-- $date --@]} & \textbf{[@-- $invnum --@]} & \textbf{[@-- $custnum --@]} \\\hline
\r
152 \rule{0pt}{5ex} &~~ \huge{\textsc{[@-- emt($notice_name) --@]}} & \\
\r
159 \begin{tabular}{lll}
\r
160 [@-- join(' & ', emt('Invoice date'), emt('Invoice #'), emt('Customer #') ) --@]\\
\r
161 \textbf{[@-- $date --@]} & \textbf{[@-- $invnum --@]} & \textbf{[@-- $custnum --@]}\\
\r
170 %% Font options are:
\r
171 %% bch Bitsream Charter
\r
173 %% phv Adobe Helvetica
\r
174 %% pnc New Century Schoolbook
\r
178 \renewcommand{\familydefault}{phv}
\r
181 % Commands for freeside table header...
\r
183 \newcommand{\FSdescriptionlength} { [@-- $unitprices ? '8.2cm' : '12.8cm' --@] }
\r
184 \newcommand{\FSdescriptioncolumncount} { [@-- $unitprices ? '4' : '6' --@] }
\r
185 \newcommand{\FSunitcolumns}{ [@--
\r
187 ? '\makebox[2.5cm][r]{\textbf{~~' . emt('Unit Price') . '}} &' .
\r
188 '\makebox[1.4cm]{\textbf{~' . emt('Quantity') . '}} & '
\r
191 \newcommand{\FShead}{
\r
194 \makebox[1.4cm]{} &
\r
195 \multicolumn{\FSdescriptioncolumncount}{l}{\makebox[\FSdescriptionlength][l]{\textbf{[@-- emt('Description') --@]}}}&
\r
197 \makebox[1.6cm][r]{\textbf{[@-- emt('Amount') --@]}} \\
\r
201 \newcommand{\FSusagehead}{
\r
204 \makebox[1.4cm]{} &
\r
205 \multicolumn{4}{l}{
\r
206 \makebox[\FSdescriptionlength][l]{\textbf{[@-- emt('Description') --@]}}
\r
208 \textbf{~~[@-- emt('Calls') --@]} &
\r
209 \textbf{~~[@-- emt('Duration') --@]} &
\r
210 \textbf{~~[@-- emt('Amount') --@]} \\
\r
214 % ...description...
\r
215 \newcommand{\FSdesc}[5]{
\r
216 \multicolumn{1}{c}{\rule{0pt}{2.5ex}\textbf{#1}} &
\r
217 \multicolumn{[@-- $unitprices ? '4' : '6' --@]}{l}{\textbf{#2}} &
\r
218 [@-- $unitprices ? ' \multicolumn{1}{r}{\textbf{#3}} &'."\n".
\r
219 ' \multicolumn{1}{r}{\textbf{#4}} &'."\n"
\r
222 \multicolumn{1}{r}{\textbf{#5}}\\
\r
224 % ...extended description...
\r
225 \newcommand{\FSextdesc}[1]{
\r
226 \multicolumn{1}{l}{\rule{0pt}{1.0ex}} &
\r
227 %% \multicolumn{2}{l}{\small{~-~#1}}\\
\r
230 % ...and total line items.
\r
231 \newcommand{\FStotaldesc}[2]{
\r
232 & \multicolumn{6}{l}{#1} & #2\\
\r
235 % ...usage class summary
\r
236 \newcommand{\FSusagedesc}[4]{
\r
237 \multicolumn{1}{c}{\rule{0pt}{2.5ex}} &
\r
238 \multicolumn{4}{l}{\textbf{#1}} &
\r
239 \multicolumn{1}{r}{\textbf{#2}} &
\r
240 \multicolumn{1}{r}{\textbf{#3}} &
\r
241 \multicolumn{1}{r}{\textbf{#4}}
\r
246 % Headers and footers defined for the first page
\r
247 \addressinset \rule{0.5cm}{0cm}
\r
249 \begin{minipage}[t]{7.0cm}
\r
250 \vspace{[@-- defined($addresssep) ? $addresssep : '0.25cm' --@]}
\r
251 \textbf{[@-- $payname --@]}\\
\r
252 \addressline{[@-- $company --@]}
\r
253 \addressline{[@-- $address1 --@]}
\r
254 \addressline{[@-- $address2 --@]}
\r
255 \addressline{[@-- $city --@], [@-- $state --@]~~[@-- $zip --@]}
\r
256 \addressline{[@-- $country --@]}
\r
260 \begin{minipage}[t]{6.4cm}
\r
262 if ($ship_enable) {
\r
263 $OUT .= '\textbf{' . emt('Service Address') . '}\\\\';
\r
264 $OUT .= "\\addressline{$ship_company}";
\r
265 $OUT .= "\\addressline{$ship_address1}";
\r
266 $OUT .= "\\addressline{$ship_address2}";
\r
267 $OUT .= "\\addressline{$ship_city, $ship_state~~$ship_zip}";
\r
268 $OUT .= "\\addressline{$ship_country}";
\r
275 [@-- $terms ? emt('Terms') .": $terms" : '' --@]\\
\r
276 [@-- $po_line --@]\\
\r
285 foreach my $section ( grep { !$summary || $_->{description} ne $finance_section } @sections ) {
\r
286 if ($section->{'pretotal'} && !$summary) {
\r
287 $OUT .= '\begin{flushright}';
\r
288 $OUT .= '\large\textsc{'. $section->{'pretotal'}. '}\\\\';
\r
289 $OUT .= '\\end{flushright}';
\r
291 $OUT .= '\pagebreak' if $section->{'post_total'};
\r
292 unless ($section->{'summarized'} ) {
\r
293 $OUT .= '\captionsetup{singlelinecheck=false,justification=raggedright,font={Large,sc,bf}}';
\r
294 $OUT .= '\ifthenelse{\equal{\thepage}{1}}{\setlength{\LTextracouponspace}{\extracouponspace}}{\setlength{\LTextracouponspace}{0pt}}'
\r
296 $OUT .= '\begin{longtable}{cllllllr}';
\r
297 $OUT .= '\caption*{ ';
\r
298 if ($section->{'location'}) {
\r
299 $OUT .= $section->{'location'}{'label_prefix'}. ': '
\r
300 if length($section->{'location'}{'label_prefix'});
\r
301 $OUT .= $section->{'location'}{'address1'};
\r
302 $OUT .= ', ' . $section->{'location'}{'address2'}
\r
303 if length($section->{'location'}{'address2'});
\r
305 $section->{'location'}{'city'} . ', ' .
\r
306 $section->{'location'}{'state'} . '~' .
\r
307 $section->{'location'}{'zip'};
\r
308 } elsif ( $section->{'description'} ) {
\r
309 $OUT .= ($section->{'description'});
\r
311 $OUT .= emt('Charges');
\r
314 if ($section->{header_generator}) {
\r
315 $OUT .= &{$section->{header_generator}}();
\r
316 } elsif ( $section->{usage_section} ) {
\r
317 $OUT .= '\FSusagehead';
\r
321 $OUT .= '\endfirsthead';
\r
322 $OUT .= '\multicolumn{7}{r}{\rule{0pt}{2.5ex}'.emt('Continued from previous page').'}\\\\';
\r
323 if ($section->{header_generator}) {
\r
324 $OUT .= &{$section->{header_generator}}();
\r
325 } elsif ( $section->{usage_section} ) {
\r
326 $OUT .= '\FSusagehead';
\r
330 $OUT .= '\endhead';
\r
331 $OUT .= '\multicolumn{7}{r}{\rule{0pt}{2.5ex}'.emt('Continued on next page...').'}\\\\';
\r
332 $OUT .= '\endfoot';
\r
335 if (scalar(@sections) > 1 and !$section->{no_subtotal}) {
\r
336 if ($section->{total_generator}) {
\r
337 $OUT .= &{$section->{total_generator}}($section);
\r
339 $OUT .= '\FStotaldesc{' . $section->{'description'} . ' Total}' .
\r
340 '{' . $section->{'subtotal'} . '}' . "\n";
\r
344 #if ($section == $sections[$#sections]) {
\r
345 foreach my $line (grep {$_->{section}->{description} eq $section->{description}} @total_items) {
\r
346 if ($section->{total_line_generator}) {
\r
347 $OUT .= &{$section->{total_line_generator}}($line);
\r
349 $OUT .= '\FStotaldesc{' . $line->{'total_item'} . '}' .
\r
350 '{' . $line->{'total_amount'} . '}' . "\n";
\r
356 $OUT .= '\endlastfoot';
\r
360 grep { ( scalar( @sections ) > 1
\r
361 ? $section->{'description'} eq $_->{'section'}->{'description'}
\r
366 my $ext_description = $line->{'ext_description'};
\r
368 # Don't break-up small packages.
\r
369 my $rowbreak = @$ext_description < 5 ? '*' : '';
\r
371 $OUT .= "\\hline\n" if (($line->{'ref'} || 0) ne $lastref);
\r
372 if ($section->{description_generator}) {
\r
373 $OUT .= &{$section->{description_generator}}($line);
\r
374 } elsif ($section->{usage_section}) {
\r
375 my $minutes = sprintf('%d', $line->{'duration'} / 60);
\r
376 my $seconds = $line->{'duration'} % 60;
\r
377 $OUT .= '\FSusagedesc
\r
378 {' . $line->{'description'} . '}
\r
379 {' . $line->{'quantity'} . '}
\r
380 {' . $minutes . 'm ' . $seconds . 's' . '}
\r
381 {' . $line->{'amount'} . '}';
\r
385 '{' . $line->{'description'} . '}' ;
\r
386 if ( $unitprices and length($line->{'unit_amount'}) ) {
\r
387 # then show the unit amount and quantity
\r
389 '{\\dollar' . $line->{'unit_amount'} . '}'.
\r
390 '{' . $line->{'quantity'} . '}';
\r
392 # leave those columns blank
\r
395 $OUT .= '{\\dollar' . $line->{'amount'} . "}${rowbreak}\n";
\r
397 $lastref = $line->{'ref'} || 0;
\r
399 foreach my $ext_desc (@$ext_description) {
\r
400 if ($section->{extended_description_generator}) {
\r
401 $OUT .= &{$section->{extended_description_generator}}($ext_desc);
\r
403 if ( $ext_desc !~ /[^\\]&/ ) {
\r
404 $ext_desc = substr($ext_desc, 0, 80) . '...'
\r
405 if (length($ext_desc) > 80);
\r
406 $ext_desc = '\multicolumn{6}{l}{\small{~~~'. $ext_desc. '}}';
\r
408 $ext_desc = "~~~$ext_desc";
\r
410 $OUT .= '\FSextdesc{' . $ext_desc . '}' . "${rowbreak}\n";
\r
416 $OUT .= '\end{longtable}';
\r
418 if ($section->{'posttotal'}) {
\r
419 $OUT .= '\begin{flushright}';
\r
420 $OUT .= '\normalfont\large\bfseries\textsc{'. $section->{'posttotal'}. '}\\\\';
\r
421 $OUT .= '\\end{flushright}';
\r
427 \begin{minipage}[t]{\textwidth}
\r
428 [@-- length($summary)
\r
431 ? '\scriptsize{ '.$notes.' }'
\r
435 [@-- $coupon ? '\ifthenelse{\equal{\thepage}{1}}{\rule{0pt}{\extracouponspace}}{}' : '' --@]
\r