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,fslongtable,afterpage,caption,multirow,bigstrut}
\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 \renewcommand{\footrule}{
\r
45 $coupon ? '\ifthenelse{\equal{\thepage}{1}}' : '';
\r
50 \vbox to 0pt{\rule{\headwidth}{\footrulewidth}\vss}
\r
54 \newcommand{\extracouponspace}{3.6cm}
\r
56 % Adjust the inset of the mailing address
\r
57 \newcommand{\addressinset}[1][]{\hspace{1.0cm}}
\r
59 % Adjust the inset of the return address and logo
\r
60 \newcommand{\returninset}[1][]{\hspace{-0.25cm}}
\r
62 % New command for address lines i.e. skip them if blank
\r
63 \newcommand{\addressline}[1]{\ifthenelse{\equal{#1}{}}{}{#1\\}}
\r
65 % Inserts dollar symbol
\r
66 \newcommand{\dollar}[1][]{\symbol{36}}
\r
68 % Remove plain style header/footer
\r
69 \fancypagestyle{plain}{
\r
74 % Define fancy header/footer for first and subsequent pages
\r
76 \ifthenelse{\equal{\thepage}{1}}
\r
80 $OUT .= '\vspace{-\extracouponspace}';
\r
81 $OUT .= '\rule[0.5em]{\textwidth}{\footrulewidth}\\\\';
\r
87 }[@-- $coupon ? '\vspace{\extracouponspace}' : '' --@]
\r
91 [@-- $smallfooter --@]
\r
97 \ifthenelse{\equal{\thepage}{1}}
\r
101 \small{\thepage\ of \pageref{LastPage}}
\r
106 \ifthenelse{\equal{\thepage}{1}}
\r
110 \begin{tabular}{ll}
\r
111 \includegraphics{[@-- $logo_file --@]} &
\r
112 \begin{minipage}[b]{5.5cm}
\r
113 [@-- $returnaddress --@]
\r
119 %\includegraphics{[@-- $logo_file --@]} % Uncomment if you want the logo on all pages.
\r
124 \ifthenelse{\equal{\thepage}{1}}
\r
126 \begin{tabular}{ccc}
\r
127 Invoice date & Invoice \#& Customer\#\\
\r
129 \textbf{[@-- $date --@]} & \textbf{[@-- $invnum --@]} & \textbf{[@-- $custnum --@]} \\\hline
\r
130 \rule{0pt}{5ex} &~~ \huge{\textsc{Invoice}} & \\
\r
137 \begin{tabular}{lll}
\r
138 Invoice date & Invoice \#& Customer\#\\
\r
139 \textbf{[@-- $date --@]} & \textbf{[@-- $invnum --@]} & \textbf{[@-- $custnum --@]}\\
\r
148 %% Font options are:
\r
149 %% bch Bitsream Charter
\r
151 %% phv Adobe Helvetica
\r
152 %% pnc New Century Schoolbook
\r
156 \renewcommand{\familydefault}{phv}
\r
159 % Commands for freeside table header...
\r
161 \newcommand{\FSdescriptionlength} { [@-- $unitprices ? '8.2cm' : '12.8cm' --@] }
\r
162 \newcommand{\FSdescriptioncolumncount} { [@-- $unitprices ? '4' : '6' --@] }
\r
163 \newcommand{\FSunitcolumns}{ [@-- $unitprices ? '\makebox[2.5cm][l]{\textbf{~~Unit Price}}&\makebox[1.4cm]{\textbf{~Quantity}}&' : '' --@] }
\r
165 \newcommand{\FShead}{
\r
168 \makebox[1.4cm]{\textbf{Ref}} &
\r
169 % \makebox[2.9cm][l]{\textbf{Description}}&
\r
170 % \makebox[1.4cm][l]{}&
\r
171 % \makebox[1.4cm][l]{}&
\r
172 % \makebox[2.5cm][l]{}&
\r
173 \multicolumn{\FSdescriptioncolumncount}{l}{\makebox[\FSdescriptionlength][l]{\textbf{Description}}}&
\r
175 \makebox[1.6cm][r]{\textbf{Amount}} \\
\r
179 % ...description...
\r
180 \newcommand{\FSdesc}[5]{
\r
181 \multicolumn{1}{c}{\rule{0pt}{2.5ex}\textbf{#1}} &
\r
182 \multicolumn{4}{l}{\textbf{#2}} &
\r
183 \multicolumn{1}{l}{\textbf{#3}} &
\r
184 \multicolumn{1}{r}{\textbf{#4}} &
\r
185 \multicolumn{1}{r}{\textbf{\dollar #5}}\\
\r
187 % ...extended description...
\r
188 \newcommand{\FSextdesc}[1]{
\r
189 \multicolumn{1}{l}{\rule{0pt}{1.0ex}} &
\r
190 %% \multicolumn{2}{l}{\small{~-~#1}}\\
\r
193 % ...and total line items.
\r
194 \newcommand{\FStotaldesc}[2]{
\r
195 & \multicolumn{6}{l}{#1} & #2\\
\r
201 %% Headers and footers defined for the first page
\r
203 %% The LH Heading comprising logo
\r
204 %% UNCOMMENT the following FOUR lines and change the path if necssary to provide a logo
\r
206 %% The Heading comprising isue date, customer ref & INVOICE name
\r
208 %% Header & footer changes for subsequent pages
\r
212 \addressinset \rule{0.5cm}{0cm}
\r
214 \begin{minipage}[t]{7.0cm}
\r
216 \textbf{[@-- $payname --@]}\\
\r
217 \addressline{[@-- $company --@]}
\r
218 \addressline{[@-- $address1 --@]}
\r
219 \addressline{[@-- $address2 --@]}
\r
220 \addressline{[@-- $city --@], [@-- $state --@]~~[@-- $zip --@]}
\r
221 \addressline{[@-- $country --@]}
\r
225 \begin{minipage}[t]{6.4cm}
\r
227 if ($ship_enable) {
\r
228 $OUT .= '\textbf{Service Address}\\\\';
\r
229 $OUT .= "\\addressline{$ship_company}";
\r
230 $OUT .= "\\addressline{$ship_address1}";
\r
231 $OUT .= "\\addressline{$ship_address2}";
\r
232 $OUT .= "\\addressline{$ship_city, $ship_state~~$ship_zip}";
\r
233 $OUT .= "\\addressline{$ship_country}";
\r
240 Terms: [@-- $terms --@]\\
\r
241 [@-- $po_line --@]\\
\r
248 foreach my $section ( @sections ) {
\r
249 if ($section->{'pretotal'}) {
\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 $OUT .= '\captionsetup{singlelinecheck=false,justification=raggedright,font={Large,sc,bf}}';
\r
256 $OUT .= '\ifthenelse{\equal{\thepage}{1}}{\setlength{\LTextracouponspace}{\extracouponspace}}{\setlength{\LTextracouponspace}{0pt}}'
\r
258 $OUT .= '\begin{longtable}{cllllllr}';
\r
259 $OUT .= '\caption*{ ';
\r
260 $OUT .= ($section->{'description'}) ? $section->{'description'}: 'Charges';
\r
263 $OUT .= '\endfirsthead';
\r
264 $OUT .= '\multicolumn{7}{r}{\rule{0pt}{2.5ex}Continued from previous page}\\\\';
\r
266 $OUT .= '\endhead';
\r
267 $OUT .= '\multicolumn{7}{r}{\rule{0pt}{2.5ex}Continued on next page...}\\\\';
\r
268 $OUT .= '\endfoot';
\r
271 if (scalar(@sections) > 1) {
\r
272 $OUT .= '\FStotaldesc{' . $section->{'description'} . ' Total}' .
\r
273 '{' . $section->{'subtotal'} . '}' . "\n";
\r
276 #if ($section == $sections[$#sections]) {
\r
277 foreach my $line (grep {$_->{section}->{description} eq $section->{description}} @total_items) {
\r
278 $OUT .= '\FStotaldesc{' . $line->{'total_item'} . '}' .
\r
279 '{' . $line->{'total_amount'} . '}' . "\n";
\r
284 $OUT .= '\endlastfoot';
\r
288 grep { ( scalar( @sections ) > 1
\r
289 ? $section->{'description'} eq $_->{'section'}->{'description'}
\r
294 my $ext_description = $line->{'ext_description'};
\r
296 # Don't break-up small packages.
\r
297 my $rowbreak = @$ext_description < 5 ? '*' : '';
\r
299 $OUT .= "\\hline\n" if ($line->{'ref'} && $line->{'ref'} ne $lastref);
\r
301 '{' . ( $line->{'ref'} ne $lastref ? $line->{'ref'} : '' ) . '}'.
\r
302 '{' . $line->{'description'} . '}' .
\r
303 '{' . ( $unitprices ? $line->{'unit_amount'} : '' ) . '}'.
\r
304 '{' . ( $unitprices ? $line->{'quantity'} : '' ) . '}' .
\r
305 '{' . $line->{'amount'} . "}${rowbreak}\n";
\r
306 $lastref = $line->{'ref'};
\r
308 foreach my $ext_desc (@$ext_description) {
\r
309 if ( $ext_desc !~ /[^\\]&/ ) {
\r
310 $ext_desc = substr($ext_desc, 0, 80) . '...'
\r
311 if (length($ext_desc) > 80);
\r
312 $ext_desc = '\multicolumn{6}{l}{\small{~~~'. $ext_desc. '}}';
\r
314 $ext_desc = "~~~$ext_desc";
\r
316 $OUT .= '\FSextdesc{' . $ext_desc . '}' . "${rowbreak}\n";
\r
321 $OUT .= '\end{longtable}';
\r
323 if ($section->{'posttotal'}) {
\r
324 $OUT .= '\begin{flushright}';
\r
325 $OUT .= '\normalfont\large\bfseries\textsc{'. $section->{'posttotal'}. '}\\\\';
\r
326 $OUT .= '\\end{flushright}';
\r