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.25cm' --@]}
\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 : '3.6cm' --@]}
\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
98 $OUT .= '\vspace{'. $couponfootsep. '}' if defined($couponfootsep);
\r
101 --@] [@-- $smallerfooter ? '\scriptsize{' : '\small{' --@]
\r
103 }[@-- $coupon ? '\vspace{\extracouponspace}' : '' --@]
\r
106 [@-- $smallerfooter ? '\scriptsize{' : '\small{' --@]
\r
107 [@-- $smallfooter --@]
\r
113 \ifthenelse{\equal{\thepage}{1}}
\r
117 \small{\thepage\ of \pageref{LastPage}}
\r
122 \ifthenelse{\equal{\thepage}{1}}
\r
126 \begin{tabular}{ll}
\r
127 \includegraphics{[@-- $logo_file --@]} & [@-- $verticalreturnaddress ? '\\\\' : '' --@]
\r
128 \begin{minipage}[b]{5.5cm}
\r
129 [@-- $returnaddress --@]
\r
135 %\includegraphics{[@-- $logo_file --@]} % Uncomment if you want the logo on all pages.
\r
140 \ifthenelse{\equal{\thepage}{1}}
\r
142 \begin{tabular}{ccc}
\r
143 [@-- join(' & ', ( $no_date ? '' : emt('Invoice date') ),
\r
144 ( $no_number ? '' : emt('Invoice #') ),
\r
149 \textbf{[@-- $date --@]} & \textbf{[@-- $invnum --@]} & \textbf{[@-- $custnum --@]} \\\hline
\r
150 \rule{0pt}{5ex} &~~ \huge{\textsc{[@-- emt($notice_name) --@]}} & \\
\r
157 \begin{tabular}{lll}
\r
158 [@-- join(' & ', emt('Invoice date'), emt('Invoice #'), emt('Customer #') ) --@]\\
\r
159 \textbf{[@-- $date --@]} & \textbf{[@-- $invnum --@]} & \textbf{[@-- $custnum --@]}\\
\r
168 %% Font options are:
\r
169 %% bch Bitsream Charter
\r
171 %% phv Adobe Helvetica
\r
172 %% pnc New Century Schoolbook
\r
176 \renewcommand{\familydefault}{phv}
\r
179 % Commands for freeside table header...
\r
181 \newcommand{\FSdescriptionlength} { [@-- $unitprices ? '8.2cm' : '12.8cm' --@] }
\r
182 \newcommand{\FSdescriptioncolumncount} { [@-- $unitprices ? '4' : '6' --@] }
\r
183 \newcommand{\FSunitcolumns}{ [@--
\r
185 ? '\makebox[2.5cm][r]{\textbf{~~' . emt('Unit Price') . '}} &' .
\r
186 '\makebox[1.4cm]{\textbf{~' . emt('Quantity') . '}} & '
\r
189 \newcommand{\FShead}{
\r
192 \makebox[1.4cm]{} &
\r
193 \multicolumn{\FSdescriptioncolumncount}{l}{\makebox[\FSdescriptionlength][l]{\textbf{[@-- emt('Description') --@]}}}&
\r
195 \makebox[1.6cm][r]{\textbf{[@-- emt('Amount') --@]}} \\
\r
199 % ...description...
\r
200 \newcommand{\FSdesc}[5]{
\r
201 \multicolumn{1}{c}{\rule{0pt}{2.5ex}\textbf{#1}} &
\r
202 \multicolumn{[@-- $unitprices ? '4' : '6' --@]}{l}{\textbf{#2}} &
\r
203 [@-- $unitprices ? ' \multicolumn{1}{r}{\textbf{#3}} &'."\n".
\r
204 ' \multicolumn{1}{r}{\textbf{#4}} &'."\n"
\r
207 \multicolumn{1}{r}{\textbf{#5}}\\
\r
209 % ...extended description...
\r
210 \newcommand{\FSextdesc}[1]{
\r
211 \multicolumn{1}{l}{\rule{0pt}{1.0ex}} &
\r
212 %% \multicolumn{2}{l}{\small{~-~#1}}\\
\r
215 % ...and total line items.
\r
216 \newcommand{\FStotaldesc}[2]{
\r
217 & \multicolumn{6}{l}{#1} & #2\\
\r
222 % Headers and footers defined for the first page
\r
223 \addressinset \rule{0.5cm}{0cm}
\r
225 \begin{minipage}[t]{7.0cm}
\r
226 \vspace{[@-- defined($addresssep) ? $addresssep : '0.25cm' --@]}
\r
227 \textbf{[@-- $payname --@]}\\
\r
228 \addressline{[@-- $company --@]}
\r
229 \addressline{[@-- $address1 --@]}
\r
230 \addressline{[@-- $address2 --@]}
\r
231 \addressline{[@-- $city --@], [@-- $state --@]~~[@-- $zip --@]}
\r
232 \addressline{[@-- $country --@]}
\r
236 \begin{minipage}[t]{6.4cm}
\r
238 if ($ship_enable) {
\r
239 $OUT .= '\textbf{' . emt('Service Address') . '}\\\\';
\r
240 $OUT .= "\\addressline{$ship_company}";
\r
241 $OUT .= "\\addressline{$ship_address1}";
\r
242 $OUT .= "\\addressline{$ship_address2}";
\r
243 $OUT .= "\\addressline{$ship_city, $ship_state~~$ship_zip}";
\r
244 $OUT .= "\\addressline{$ship_country}";
\r
251 [@-- $terms ? emt('Terms') .": $terms" : '' --@]\\
\r
252 [@-- $po_line --@]\\
\r
261 foreach my $section ( grep { !$summary || $_->{description} ne $finance_section } @sections ) {
\r
262 if ($section->{'pretotal'} && !$summary) {
\r
263 $OUT .= '\begin{flushright}';
\r
264 $OUT .= '\large\textsc{'. $section->{'pretotal'}. '}\\\\';
\r
265 $OUT .= '\\end{flushright}';
\r
267 $OUT .= '\pagebreak' if $section->{'post_total'};
\r
268 unless ($section->{'summarized'} ) {
\r
269 $OUT .= '\captionsetup{singlelinecheck=false,justification=raggedright,font={Large,sc,bf}}';
\r
270 $OUT .= '\ifthenelse{\equal{\thepage}{1}}{\setlength{\LTextracouponspace}{\extracouponspace}}{\setlength{\LTextracouponspace}{0pt}}'
\r
272 $OUT .= '\begin{longtable}{cllllllr}';
\r
273 $OUT .= '\caption*{ ';
\r
274 if ($section->{'location'}) {
\r
275 $OUT .= $section->{'location'}{'label_prefix'}. ': '
\r
276 if length($section->{'location'}{'label_prefix'});
\r
277 $OUT .= $section->{'location'}{'address1'};
\r
278 $OUT .= ', ' . $section->{'location'}{'address2'}
\r
279 if length($section->{'location'}{'address2'});
\r
281 $section->{'location'}{'city'} . ', ' .
\r
282 $section->{'location'}{'state'} . '~' .
\r
283 $section->{'location'}{'zip'};
\r
284 } elsif ( $section->{'description'} ) {
\r
285 $OUT .= ($section->{'description'});
\r
287 $OUT .= emt('Charges');
\r
290 if ($section->{header_generator}) {
\r
291 $OUT .= &{$section->{header_generator}}();
\r
295 $OUT .= '\endfirsthead';
\r
296 $OUT .= '\multicolumn{7}{r}{\rule{0pt}{2.5ex}'.emt('Continued from previous page').'}\\\\';
\r
297 if ($section->{header_generator}) {
\r
298 $OUT .= &{$section->{header_generator}}();
\r
302 $OUT .= '\endhead';
\r
303 $OUT .= '\multicolumn{7}{r}{\rule{0pt}{2.5ex}'.emt('Continued on next page...').'}\\\\';
\r
304 $OUT .= '\endfoot';
\r
307 if (scalar(@sections) > 1 and !$section->{no_subtotal}) {
\r
308 if ($section->{total_generator}) {
\r
309 $OUT .= &{$section->{total_generator}}($section);
\r
311 $OUT .= '\FStotaldesc{' . $section->{'description'} . ' Total}' .
\r
312 '{' . $section->{'subtotal'} . '}' . "\n";
\r
316 #if ($section == $sections[$#sections]) {
\r
317 foreach my $line (grep {$_->{section}->{description} eq $section->{description}} @total_items) {
\r
318 if ($section->{total_line_generator}) {
\r
319 $OUT .= &{$section->{total_line_generator}}($line);
\r
321 $OUT .= '\FStotaldesc{' . $line->{'total_item'} . '}' .
\r
322 '{' . $line->{'total_amount'} . '}' . "\n";
\r
328 $OUT .= '\endlastfoot';
\r
332 grep { ( scalar( @sections ) > 1
\r
333 ? $section->{'description'} eq $_->{'section'}->{'description'}
\r
338 my $ext_description = $line->{'ext_description'};
\r
340 # Don't break-up small packages.
\r
341 my $rowbreak = @$ext_description < 5 ? '*' : '';
\r
343 $OUT .= "\\hline\n" if (($line->{'ref'} || 0) ne $lastref);
\r
344 if ($section->{description_generator}) {
\r
345 $OUT .= &{$section->{description_generator}}($line);
\r
349 '{' . $line->{'description'} . '}' ;
\r
350 if ( $unitprices and length($line->{'unit_amount'}) ) {
\r
351 # then show the unit amount and quantity
\r
353 '{\\dollar' . $line->{'unit_amount'} . '}'.
\r
354 '{' . $line->{'quantity'} . '}';
\r
356 # leave those columns blank
\r
359 $OUT .= '{\\dollar' . $line->{'amount'} . "}${rowbreak}\n";
\r
361 $lastref = $line->{'ref'} || 0;
\r
363 foreach my $ext_desc (@$ext_description) {
\r
364 if ($section->{extended_description_generator}) {
\r
365 $OUT .= &{$section->{extended_description_generator}}($ext_desc);
\r
367 if ( $ext_desc !~ /[^\\]&/ ) {
\r
368 $ext_desc = substr($ext_desc, 0, 80) . '...'
\r
369 if (length($ext_desc) > 80);
\r
370 $ext_desc = '\multicolumn{6}{l}{\small{~~~'. $ext_desc. '}}';
\r
372 $ext_desc = "~~~$ext_desc";
\r
374 $OUT .= '\FSextdesc{' . $ext_desc . '}' . "${rowbreak}\n";
\r
380 $OUT .= '\end{longtable}';
\r
382 if ($section->{'posttotal'}) {
\r
383 $OUT .= '\begin{flushright}';
\r
384 $OUT .= '\normalfont\large\bfseries\textsc{'. $section->{'posttotal'}. '}\\\\';
\r
385 $OUT .= '\\end{flushright}';
\r
391 \begin{minipage}[t]{\textwidth}
\r
392 [@-- length($summary)
\r
395 ? '\scriptsize{ '.$notes.' }'
\r
399 [@-- $coupon ? '\ifthenelse{\equal{\thepage}{1}}{\rule{0pt}{\extracouponspace}}{}' : '' --@]
\r