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
27 \addtolength{\voffset}{-0.0cm} % top margin to top of header
\r
28 \addtolength{\hoffset}{-0.6cm} % left margin on page
\r
29 \addtolength{\topmargin}{[@-- defined($topmargin) ? $topmargin : '-1.25cm' --@]}
\r
30 \setlength{\headheight}{2.0cm} % height of header
\r
31 \setlength{\headsep}{[@-- defined($headsep) ? $headsep : '1.0cm' --@]}
\r
32 \setlength{\footskip}{1.0cm} % bottom of footer from bottom of text
\r
34 %\addtolength{\textwidth}{2.1in} % width of text
\r
35 \setlength{\textwidth}{19.5cm}
\r
36 \setlength{\textheight}{[@-- defined($textheight) ? $textheight : '19.5cm' --@]}
\r
37 \setlength{\oddsidemargin}{-0.9cm} % odd page left margin
\r
38 \setlength{\evensidemargin}{-0.9cm} % even page left margin
\r
42 \renewcommand{\headrulewidth}{0pt}
\r
43 \renewcommand{\footrulewidth}{1pt}
\r
45 \renewcommand{\footrule}{
\r
47 $coupon ? '\ifthenelse{\equal{\thepage}{1}}' : '';
\r
52 \vbox to 0pt{\rule{\headwidth}{\footrulewidth}\vss}
\r
56 \newcommand{\extracouponspace}{[@-- defined($extracouponspace) ? $extracouponspace : '3.6cm' --@]}
\r
58 % Adjust the inset of the mailing address
\r
59 \newcommand{\addressinset}[1][]{\hspace{1.0cm}}
\r
61 % Adjust the inset of the return address and logo
\r
62 \newcommand{\returninset}[1][]{\hspace{-0.25cm}}
\r
64 % New command for address lines i.e. skip them if blank
\r
65 \newcommand{\addressline}[1]{\ifthenelse{\equal{#1}{}}{}{#1\\}}
\r
67 % Inserts dollar symbol
\r
68 \newcommand{\dollar}[1][]{\symbol{36}}
\r
70 % Remove plain style header/footer
\r
71 \fancypagestyle{plain}{
\r
76 % Define fancy header/footer for first and subsequent pages
\r
78 \ifthenelse{\equal{\thepage}{1}}
\r
82 $OUT .= '\vspace{-\extracouponspace}';
\r
83 $OUT .= '\rule[0.5em]{\textwidth}{\footrulewidth}\\\\';
\r
85 $OUT .= '\vspace{'. $couponfootsep. '}' if defined($couponfootsep);
\r
88 --@] [@-- $smallerfooter ? '\scriptsize{' : '\small{' --@]
\r
90 }[@-- $coupon ? '\vspace{\extracouponspace}' : '' --@]
\r
93 [@-- $smallerfooter ? '\scriptsize{' : '\small{' --@]
\r
94 [@-- $smallfooter --@]
\r
100 \ifthenelse{\equal{\thepage}{1}}
\r
104 \small{\thepage\ of \pageref{LastPage}}
\r
109 \ifthenelse{\equal{\thepage}{1}}
\r
113 \begin{tabular}{ll}
\r
114 \includegraphics{[@-- $logo_file --@]} & [@-- $verticalreturnaddress ? '\\\\' : '' --@]
\r
115 \begin{minipage}[b]{5.5cm}
\r
116 [@-- $returnaddress --@]
\r
122 %\includegraphics{[@-- $logo_file --@]} % Uncomment if you want the logo on all pages.
\r
127 \ifthenelse{\equal{\thepage}{1}}
\r
129 \begin{tabular}{ccc}
\r
130 [@-- join(' & ', ( $no_date ? '' : emt('Invoice date') ),
\r
131 ( $no_number ? '' : emt('Invoice #') ),
\r
136 \textbf{[@-- $date --@]} & \textbf{[@-- $invnum --@]} & \textbf{[@-- $custnum --@]} \\\hline
\r
137 \rule{0pt}{5ex} &~~ \huge{\textsc{[@-- emt($notice_name) --@]}} & \\
\r
144 \begin{tabular}{lll}
\r
145 [@-- join(' & ', emt('Invoice date'), emt('Invoice #'), emt('Customer #') ) --@]\\
\r
146 \textbf{[@-- $date --@]} & \textbf{[@-- $invnum --@]} & \textbf{[@-- $custnum --@]}\\
\r
155 %% Font options are:
\r
156 %% bch Bitsream Charter
\r
158 %% phv Adobe Helvetica
\r
159 %% pnc New Century Schoolbook
\r
163 \renewcommand{\familydefault}{phv}
\r
166 % Commands for freeside table header...
\r
168 \newcommand{\FSdescriptionlength} { [@-- $unitprices ? '8.2cm' : '12.8cm' --@] }
\r
169 \newcommand{\FSdescriptioncolumncount} { [@-- $unitprices ? '4' : '6' --@] }
\r
170 \newcommand{\FSunitcolumns}{ [@--
\r
172 ? '\makebox[2.5cm][r]{\textbf{~~' . emt('Unit Price') . '}} &' .
\r
173 '\makebox[1.4cm]{\textbf{~' . emt('Quantity') . '}} & '
\r
176 \newcommand{\FShead}{
\r
179 \makebox[1.4cm]{\textbf{Ref}} &
\r
180 \multicolumn{\FSdescriptioncolumncount}{l}{\makebox[\FSdescriptionlength][l]{\textbf{[@-- emt('Description') --@]}}}&
\r
182 \makebox[1.6cm][r]{\textbf{[@-- emt('Amount') --@]}} \\
\r
186 % ...description...
\r
187 \newcommand{\FSdesc}[5]{
\r
188 \multicolumn{1}{c}{\rule{0pt}{2.5ex}\textbf{#1}} &
\r
189 \multicolumn{[@-- $unitprices ? '4' : '6' --@]}{l}{\textbf{#2}} &
\r
190 [@-- $unitprices ? ' \multicolumn{1}{r}{\textbf{#3}} &'."\n".
\r
191 ' \multicolumn{1}{r}{\textbf{#4}} &'."\n"
\r
194 \multicolumn{1}{r}{\textbf{#5}}\\
\r
196 % ...extended description...
\r
197 \newcommand{\FSextdesc}[1]{
\r
198 \multicolumn{1}{l}{\rule{0pt}{1.0ex}} &
\r
199 %% \multicolumn{2}{l}{\small{~-~#1}}\\
\r
202 % ...and total line items.
\r
203 \newcommand{\FStotaldesc}[2]{
\r
204 & \multicolumn{6}{l}{#1} & #2\\
\r
209 % Headers and footers defined for the first page
\r
210 \addressinset \rule{0.5cm}{0cm}
\r
212 \begin{minipage}[t]{7.0cm}
\r
213 \vspace{[@-- defined($addresssep) ? $addresssep : '0.25cm' --@]}
\r
214 \textbf{[@-- $payname --@]}\\
\r
215 \addressline{[@-- $company --@]}
\r
216 \addressline{[@-- $address1 --@]}
\r
217 \addressline{[@-- $address2 --@]}
\r
218 \addressline{[@-- $city --@], [@-- $state --@]~~[@-- $zip --@]}
\r
219 \addressline{[@-- $country --@]}
\r
223 \begin{minipage}[t]{6.4cm}
\r
225 if ($ship_enable) {
\r
226 $OUT .= '\textbf{' . emt('Service Address') . '}\\\\';
\r
227 $OUT .= "\\addressline{$ship_company}";
\r
228 $OUT .= "\\addressline{$ship_address1}";
\r
229 $OUT .= "\\addressline{$ship_address2}";
\r
230 $OUT .= "\\addressline{$ship_city, $ship_state~~$ship_zip}";
\r
231 $OUT .= "\\addressline{$ship_country}";
\r
238 [@-- $terms ? emt('Terms') .": $terms" : '' --@]\\
\r
239 [@-- $po_line --@]\\
\r
248 foreach my $section ( grep { !$summary || $_->{description} ne $finance_section } @sections ) {
\r
249 if ($section->{'pretotal'} && !$summary) {
\r
250 $OUT .= '\begin{flushright}';
\r
251 $OUT .= '\large\textsc{'. $section->{'pretotal'}. '}\\\\';
\r
252 $OUT .= '\\end{flushright}';
\r
254 $OUT .= '\pagebreak' if $section->{'post_total'};
\r
255 unless ($section->{'summarized'} ) {
\r
256 $OUT .= '\captionsetup{singlelinecheck=false,justification=raggedright,font={Large,sc,bf}}';
\r
257 $OUT .= '\ifthenelse{\equal{\thepage}{1}}{\setlength{\LTextracouponspace}{\extracouponspace}}{\setlength{\LTextracouponspace}{0pt}}'
\r
259 $OUT .= '\begin{longtable}{cllllllr}';
\r
260 $OUT .= '\caption*{ ';
\r
261 if ($section->{'location'}) {
\r
262 $OUT .= $section->{'location'}{'label_prefix'}. ': '
\r
263 if length($section->{'location'}{'label_prefix'});
\r
264 $OUT .= $section->{'location'}{'address1'};
\r
265 $OUT .= ', ' . $section->{'location'}{'address2'}
\r
266 if length($section->{'location'}{'address2'});
\r
268 $section->{'location'}{'city'} . ', ' .
\r
269 $section->{'location'}{'state'} . '~' .
\r
270 $section->{'location'}{'zip'};
\r
271 } elsif ( $section->{'description'} ) {
\r
272 $OUT .= ($section->{'description'});
\r
274 $OUT .= emt('Charges');
\r
277 if ($section->{header_generator}) {
\r
278 $OUT .= &{$section->{header_generator}}();
\r
282 $OUT .= '\endfirsthead';
\r
283 $OUT .= '\multicolumn{7}{r}{\rule{0pt}{2.5ex}'.emt('Continued from previous page').'}\\\\';
\r
284 if ($section->{header_generator}) {
\r
285 $OUT .= &{$section->{header_generator}}();
\r
289 $OUT .= '\endhead';
\r
290 $OUT .= '\multicolumn{7}{r}{\rule{0pt}{2.5ex}'.emt('Continued on next page...').'}\\\\';
\r
291 $OUT .= '\endfoot';
\r
294 if (scalar(@sections) > 1 and !$section->{no_subtotal}) {
\r
295 if ($section->{total_generator}) {
\r
296 $OUT .= &{$section->{total_generator}}($section);
\r
298 $OUT .= '\FStotaldesc{' . $section->{'description'} . ' Total}' .
\r
299 '{' . $section->{'subtotal'} . '}' . "\n";
\r
303 #if ($section == $sections[$#sections]) {
\r
304 foreach my $line (grep {$_->{section}->{description} eq $section->{description}} @total_items) {
\r
305 if ($section->{total_line_generator}) {
\r
306 $OUT .= &{$section->{total_line_generator}}($line);
\r
308 $OUT .= '\FStotaldesc{' . $line->{'total_item'} . '}' .
\r
309 '{' . $line->{'total_amount'} . '}' . "\n";
\r
315 $OUT .= '\endlastfoot';
\r
319 grep { ( scalar( @sections ) > 1
\r
320 ? $section->{'description'} eq $_->{'section'}->{'description'}
\r
325 my $ext_description = $line->{'ext_description'};
\r
327 # Don't break-up small packages.
\r
328 my $rowbreak = @$ext_description < 5 ? '*' : '';
\r
330 $OUT .= "\\hline\n" if ($line->{'ref'} && $line->{'ref'} ne $lastref);
\r
331 if ($section->{description_generator}) {
\r
332 $OUT .= &{$section->{description_generator}}($line);
\r
335 '{' . ( $line->{'ref'} ne $lastref ? $line->{'ref'} : '' ) . '}'.
\r
336 '{' . $line->{'description'} . '}' ;
\r
337 if ( $unitprices and length($line->{'unit_amount'}) ) {
\r
338 # then show the unit amount and quantity
\r
340 '{\\dollar' . $line->{'unit_amount'} . '}'.
\r
341 '{' . $line->{'quantity'} . '}';
\r
343 # leave those columns blank
\r
346 $OUT .= '{\\dollar' . $line->{'amount'} . "}${rowbreak}\n";
\r
348 $lastref = $line->{'ref'};
\r
350 foreach my $ext_desc (@$ext_description) {
\r
351 if ($section->{extended_description_generator}) {
\r
352 $OUT .= &{$section->{extended_description_generator}}($ext_desc);
\r
354 if ( $ext_desc !~ /[^\\]&/ ) {
\r
355 $ext_desc = substr($ext_desc, 0, 80) . '...'
\r
356 if (length($ext_desc) > 80);
\r
357 $ext_desc = '\multicolumn{6}{l}{\small{~~~'. $ext_desc. '}}';
\r
359 $ext_desc = "~~~$ext_desc";
\r
361 $OUT .= '\FSextdesc{' . $ext_desc . '}' . "${rowbreak}\n";
\r
367 $OUT .= '\end{longtable}';
\r
369 if ($section->{'posttotal'}) {
\r
370 $OUT .= '\begin{flushright}';
\r
371 $OUT .= '\normalfont\large\bfseries\textsc{'. $section->{'posttotal'}. '}\\\\';
\r
372 $OUT .= '\\end{flushright}';
\r
378 \begin{minipage}[t]{\textwidth}
\r
379 [@-- length($summary)
\r
382 ? '\scriptsize{ '.$notes.' }'
\r
386 [@-- $coupon ? '\ifthenelse{\equal{\thepage}{1}}{\rule{0pt}{\extracouponspace}}{}' : '' --@]
\r