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,longtable,afterpage,caption}
\r
23 \usepackage{graphicx} % required for logo graphic
\r
25 \addtolength{\voffset}{-0.0cm} % top margin to top of header
\r
26 \addtolength{\hoffset}{-0.6cm} % left margin on page
\r
27 \addtolength{\topmargin}{-1.25cm} % top margin to top of header
\r
28 \setlength{\headheight}{2.0cm} % height of header
\r
29 \setlength{\headsep}{1.0cm} % between header and text
\r
30 \setlength{\footskip}{1.0cm} % bottom of footer from bottom of text
\r
32 %\addtolength{\textwidth}{2.1in} % width of text
\r
33 \setlength{\textwidth}{19.5cm}
\r
34 \setlength{\textheight}{19.5cm}
\r
35 \setlength{\oddsidemargin}{-0.9cm} % odd page left margin
\r
36 \setlength{\evensidemargin}{-0.9cm} % even page left margin
\r
40 \renewcommand{\headrulewidth}{0pt}
\r
41 \renewcommand{\footrulewidth}{1pt}
\r
43 % Adjust the inset of the mailing address
\r
44 \newcommand{\addressinset}[1][]{\hspace{1.0cm}}
\r
46 % Adjust the inset of the return address and logo
\r
47 \newcommand{\returninset}[1][]{\hspace{-0.25cm}}
\r
49 % New command for address lines i.e. skip them if blank
\r
50 \newcommand{\addressline}[1]{\ifthenelse{\equal{#1}{}}{}{#1\newline}}
\r
52 % Inserts dollar symbol
\r
53 \newcommand{\dollar}[1][]{\symbol{36}}
\r
55 % Remove plain style header/footer
\r
56 \fancypagestyle{plain}{
\r
61 % Define fancy header/footer for first and subsequent pages
\r
63 \ifthenelse{\equal{\thepage}{1}}
\r
71 [@-- $smallfooter --@]
\r
77 \ifthenelse{\equal{\thepage}{1}}
\r
81 \small{\thepage\ of \pageref{LastPage}}
\r
86 \ifthenelse{\equal{\thepage}{1}}
\r
91 \includegraphics{[@-- $logo_file --@]} &
\r
92 \begin{minipage}[b]{5.5cm}
\r
93 [@-- $returnaddress --@]
\r
99 %\includegraphics{[@-- $logo_file --@]} % Uncomment if you want the logo on all pages.
\r
104 \ifthenelse{\equal{\thepage}{1}}
\r
106 \begin{tabular}{ccc}
\r
107 Invoice date & Invoice \#& Customer\#\\
\r
109 \textbf{[@-- $date --@]} & \textbf{[@-- $invnum --@]} & \textbf{[@-- $custnum --@]} \\\hline
\r
110 \rule{0pt}{5ex} &~~ \huge{\textsc{Invoice}} & \\
\r
117 \begin{tabular}{lll}
\r
118 Invoice date & Invoice \#& Customer\#\\
\r
119 \textbf{[@-- $date --@]} & \textbf{[@-- $invnum --@]} & \textbf{[@-- $custnum --@]}\\
\r
128 %% Font options are:
\r
129 %% bch Bitsream Charter
\r
131 %% phv Adobe Helvetica
\r
132 %% pnc New Century Schoolbook
\r
136 \renewcommand{\familydefault}{phv}
\r
139 % Commands for freeside description...
\r
140 \newcommand{\FSdesc}[3]{
\r
141 \multicolumn{1}{c}{\rule{0pt}{2.5ex}\textbf{#1}} &
\r
142 \multicolumn{6}{l}{\textbf{#2}} &
\r
143 \multicolumn{1}{r}{\textbf{\dollar #3}}\\
\r
145 % ...extended description...
\r
146 \newcommand{\FSextdesc}[1]{
\r
147 \multicolumn{1}{l}{\rule{0pt}{1.0ex}} &
\r
148 %% \multicolumn{2}{l}{\small{~-~#1}}\\
\r
151 % ...and total line items.
\r
152 \newcommand{\FStotaldesc}[2]{
\r
153 & \multicolumn{6}{l}{#1} & #2\\
\r
159 %% Headers and footers defined for the first page
\r
161 %% The LH Heading comprising logo
\r
162 %% UNCOMMENT the following FOUR lines and change the path if necssary to provide a logo
\r
164 %% The Heading comprising isue date, customer ref & INVOICE name
\r
166 %% Header & footer changes for subsequent pages
\r
170 \begin{tabular}{ll}
\r
171 \addressinset \rule{0cm}{0cm} &
\r
173 \begin{minipage}[t]{5.0cm}
\r
175 \textbf{[@-- $payname --@]}\\
\r
176 \addressline{[@-- $company --@]}
\r
177 \addressline{[@-- $address1 --@]}
\r
178 \addressline{[@-- $address2 --@]}
\r
179 \addressline{[@-- $city --@], [@-- $state --@]~~[@-- $zip --@]}
\r
180 \addressline{[@-- $country --@]}
\r
185 \begin{minipage}[t]{6.4cm}
\r
187 Terms: [@-- $terms --@]\\
\r
188 [@-- $po_line --@]\\
\r
195 foreach my $section ( @sections ) {
\r
196 if ($section->{'pretotal'}) {
\r
197 $OUT .= '\begin{flushright}';
\r
198 $OUT .= '\large\textsc{'. $section->{'pretotal'}. '}\\\\';
\r
199 $OUT .= '\\end{flushright}';
\r
201 $OUT .= '\captionsetup{singlelinecheck=false,justification=raggedright,font={Large,sc,bf}}';
\r
202 $OUT .= '\begin{longtable}{cllllllr}';
\r
203 $OUT .= '\caption*{ ';
\r
204 $OUT .= ($section->{'description'}) ? $section->{'description'}: 'Charges';
\r
207 $OUT .= '\rule{0pt}{2.5ex}';
\r
208 $OUT .= '\makebox[1.4cm]{\textbf{Ref}} & ';
\r
209 $OUT .= '\multicolumn{6}{l}{\makebox[12.8cm][l]{\textbf{Description}}} & ';
\r
210 $OUT .= '\makebox[2.5cm][r]{\textbf{Amount}} \\\\';
\r
212 $OUT .= '\endfirsthead';
\r
213 $OUT .= '\multicolumn{7}{r}{\rule{0pt}{2.5ex}Continued from previous page}\\\\';
\r
215 $OUT .= '\rule{0pt}{2.5ex}';
\r
216 $OUT .= '\makebox[1.4cm]{\textbf{Ref}} & ';
\r
217 $OUT .= '\multicolumn{6}{l}{\makebox[12.8cm][l]{\textbf{Description}}} & ';
\r
218 $OUT .= '\makebox[2.5cm][r]{\textbf{Amount}} \\\\';
\r
220 $OUT .= '\endhead';
\r
221 $OUT .= '\multicolumn{7}{r}{\rule{0pt}{2.5ex}Continued on next page...}\\\\';
\r
222 $OUT .= '\endfoot';
\r
225 if (scalar(@sections) > 1) {
\r
226 $OUT .= '\FStotaldesc{' . $section->{'description'} . ' Total}' .
\r
227 '{' . $section->{'subtotal'} . '}' . "\n";
\r
230 if ($section == $sections[$#sections]) {
\r
231 foreach my $line (@total_items) {
\r
232 $OUT .= '\FStotaldesc{' . $line->{'total_item'} . '}' .
\r
233 '{' . $line->{'total_amount'} . '}' . "\n";
\r
238 $OUT .= '\endlastfoot';
\r
241 grep { ( scalar( @sections ) > 1
\r
242 ? $section->{'description'} eq $_->{'section'}->{'description'}
\r
247 my $ext_description = $line->{'ext_description'};
\r
249 # Don't break-up small packages.
\r
250 my $rowbreak = @$ext_description < 5 ? '*' : '';
\r
252 $OUT .= "\\hline\n";
\r
253 $OUT .= '\FSdesc{' . $line->{'ref'} . '}{' . $line->{'description'} . '}' .
\r
254 '{' . $line->{'amount'} . "}${rowbreak}\n";
\r
256 foreach my $ext_desc (@$ext_description) {
\r
257 if ( $ext_desc !~ /[^\\]&/ ) {
\r
258 $ext_desc = substr($ext_desc, 0, 80) . '...'
\r
259 if (length($ext_desc) > 80);
\r
260 $ext_desc = '\small{'. $ext_desc. '}';
\r
262 $OUT .= '\FSextdesc{' . $ext_desc . '}' . "${rowbreak}\n";
\r
267 $OUT .= '\end{longtable}';
\r
269 if ($section->{'posttotal'}) {
\r
270 $OUT .= '\begin{flushright}';
\r
271 $OUT .= '\normalfont\large\bfseries\textsc{'. $section->{'posttotal'}. '}\\\\';
\r
272 $OUT .= '\\end{flushright}';
\r