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,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}{[@-- defined($topmargin) ? $topmargin : '-1.25cm' --@]}
\r
28 \setlength{\headheight}{2.0cm} % height of header
\r
29 \setlength{\headsep}{[@-- defined($headsep) ? $headsep : '1.0cm' --@]}
\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}{[@-- defined($textheight) ? $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}{[@-- defined($extracouponspace) ? $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
83 $OUT .= '\vspace{'. $couponfootsep. '}' if defined($couponfootsep);
\r
86 --@] [@-- $smallerfooter ? '\scriptsize{' : '\small{' --@]
\r
88 }[@-- $coupon ? '\vspace{\extracouponspace}' : '' --@]
\r
91 [@-- $smallerfooter ? '\scriptsize{' : '\small{' --@]
\r
92 [@-- $smallfooter --@]
\r
98 \ifthenelse{\equal{\thepage}{1}}
\r
102 \small{\thepage\ of \pageref{LastPage}}
\r
107 \ifthenelse{\equal{\thepage}{1}}
\r
111 \begin{tabular}{ll}
\r
112 \includegraphics{[@-- $logo_file --@]} & [@-- $verticalreturnaddress ? '\\\\' : '' --@]
\r
113 \begin{minipage}[b]{5.5cm}
\r
114 [@-- $returnaddress --@]
\r
120 %\includegraphics{[@-- $logo_file --@]} % Uncomment if you want the logo on all pages.
\r
125 \ifthenelse{\equal{\thepage}{1}}
\r
127 \begin{tabular}{ccc}
\r
128 Invoice date & Invoice \#& Customer\#\\
\r
130 \textbf{[@-- $date --@]} & \textbf{[@-- $invnum --@]} & \textbf{[@-- $custnum --@]} \\\hline
\r
131 \rule{0pt}{5ex} &~~ \huge{\textsc{[@-- $notice_name || 'Invoice' --@]}} & \\
\r
138 \begin{tabular}{lll}
\r
139 Invoice date & Invoice \#& Customer\#\\
\r
140 \textbf{[@-- $date --@]} & \textbf{[@-- $invnum --@]} & \textbf{[@-- $custnum --@]}\\
\r
149 %% Font options are:
\r
150 %% bch Bitsream Charter
\r
152 %% phv Adobe Helvetica
\r
153 %% pnc New Century Schoolbook
\r
157 \renewcommand{\familydefault}{phv}
\r
160 % Commands for freeside table header...
\r
162 \newcommand{\FSdescriptionlength} { [@-- $unitprices ? '8.2cm' : '12.8cm' --@] }
\r
163 \newcommand{\FSdescriptioncolumncount} { [@-- $unitprices ? '4' : '6' --@] }
\r
164 \newcommand{\FSunitcolumns}{ [@-- $unitprices ? '\makebox[2.5cm][l]{\textbf{~~Unit Price}}&\makebox[1.4cm]{\textbf{~Quantity}}&' : '' --@] }
\r
166 \newcommand{\FShead}{
\r
169 \makebox[1.4cm]{\textbf{Ref}} &
\r
170 % \makebox[2.9cm][l]{\textbf{Description}}&
\r
171 % \makebox[1.4cm][l]{}&
\r
172 % \makebox[1.4cm][l]{}&
\r
173 % \makebox[2.5cm][l]{}&
\r
174 \multicolumn{\FSdescriptioncolumncount}{l}{\makebox[\FSdescriptionlength][l]{\textbf{Description}}}&
\r
176 \makebox[1.6cm][r]{\textbf{Amount}} \\
\r
180 % ...description...
\r
181 \newcommand{\FSdesc}[5]{
\r
182 \multicolumn{1}{c}{\rule{0pt}{2.5ex}\textbf{#1}} &
\r
183 \multicolumn{[@-- $unitprices ? '4' : '6' --@]}{l}{\textbf{#2}} &
\r
184 [@-- $unitprices ? ' \multicolumn{1}{l}{\textbf{#3}} &'."\n".
\r
185 ' \multicolumn{1}{r}{\textbf{#4}} &'."\n"
\r
188 \multicolumn{1}{r}{\textbf{\dollar #5}}\\
\r
190 % ...extended description...
\r
191 \newcommand{\FSextdesc}[1]{
\r
192 \multicolumn{1}{l}{\rule{0pt}{1.0ex}} &
\r
193 %% \multicolumn{2}{l}{\small{~-~#1}}\\
\r
196 % ...and total line items.
\r
197 \newcommand{\FStotaldesc}[2]{
\r
198 & \multicolumn{6}{l}{#1} & #2\\
\r
203 % Headers and footers defined for the first page
\r
204 \addressinset \rule{0.5cm}{0cm}
\r
206 \begin{minipage}[t]{7.0cm}
\r
207 \vspace{[@-- defined($addresssep) ? $addresssep : '0.25cm' --@]}
\r
208 \textbf{[@-- $payname --@]}\\
\r
209 \addressline{[@-- $company --@]}
\r
210 \addressline{[@-- $address1 --@]}
\r
211 \addressline{[@-- $address2 --@]}
\r
212 \addressline{[@-- $city --@], [@-- $state --@]~~[@-- $zip --@]}
\r
213 \addressline{[@-- $country --@]}
\r
217 \begin{minipage}[t]{6.4cm}
\r
219 if ($ship_enable) {
\r
220 $OUT .= '\textbf{Service Address}\\\\';
\r
221 $OUT .= "\\addressline{$ship_company}";
\r
222 $OUT .= "\\addressline{$ship_address1}";
\r
223 $OUT .= "\\addressline{$ship_address2}";
\r
224 $OUT .= "\\addressline{$ship_city, $ship_state~~$ship_zip}";
\r
225 $OUT .= "\\addressline{$ship_country}";
\r
232 Terms: [@-- $terms --@]\\
\r
233 [@-- $po_line --@]\\
\r
242 foreach my $section ( grep { !$summary || $_->{description} ne $finance_section } @sections ) {
\r
243 if ($section->{'pretotal'} && !$summary) {
\r
244 $OUT .= '\begin{flushright}';
\r
245 $OUT .= '\large\textsc{'. $section->{'pretotal'}. '}\\\\';
\r
246 $OUT .= '\\end{flushright}';
\r
248 $OUT .= '\pagebreak' if $section->{'post_total'};
\r
249 unless ($section->{'summarized'} ) {
\r
250 $OUT .= '\captionsetup{singlelinecheck=false,justification=raggedright,font={Large,sc,bf}}';
\r
251 $OUT .= '\ifthenelse{\equal{\thepage}{1}}{\setlength{\LTextracouponspace}{\extracouponspace}}{\setlength{\LTextracouponspace}{0pt}}'
\r
253 $OUT .= '\begin{longtable}{cllllllr}';
\r
254 $OUT .= '\caption*{ ';
\r
255 $OUT .= ($section->{'description'}) ? $section->{'description'}: 'Charges';
\r
257 if ($section->{header_generator}) {
\r
258 $OUT .= &{$section->{header_generator}}();
\r
262 $OUT .= '\endfirsthead';
\r
263 $OUT .= '\multicolumn{7}{r}{\rule{0pt}{2.5ex}Continued from previous page}\\\\';
\r
264 if ($section->{header_generator}) {
\r
265 $OUT .= &{$section->{header_generator}}();
\r
269 $OUT .= '\endhead';
\r
270 $OUT .= '\multicolumn{7}{r}{\rule{0pt}{2.5ex}Continued on next page...}\\\\';
\r
271 $OUT .= '\endfoot';
\r
274 if (scalar(@sections) > 1) {
\r
275 if ($section->{total_generator}) {
\r
276 $OUT .= &{$section->{total_generator}}($section);
\r
278 $OUT .= '\FStotaldesc{' . $section->{'description'} . ' Total}' .
\r
279 '{' . $section->{'subtotal'} . '}' . "\n";
\r
283 #if ($section == $sections[$#sections]) {
\r
284 foreach my $line (grep {$_->{section}->{description} eq $section->{description}} @total_items) {
\r
285 if ($section->{total_line_generator}) {
\r
286 $OUT .= &{$section->{total_line_generator}}($line);
\r
288 $OUT .= '\FStotaldesc{' . $line->{'total_item'} . '}' .
\r
289 '{' . $line->{'total_amount'} . '}' . "\n";
\r
295 $OUT .= '\endlastfoot';
\r
299 grep { ( scalar( @sections ) > 1
\r
300 ? $section->{'description'} eq $_->{'section'}->{'description'}
\r
305 my $ext_description = $line->{'ext_description'};
\r
307 # Don't break-up small packages.
\r
308 my $rowbreak = @$ext_description < 5 ? '*' : '';
\r
310 $OUT .= "\\hline\n" if ($line->{'ref'} && $line->{'ref'} ne $lastref);
\r
311 if ($section->{description_generator}) {
\r
312 $OUT .= &{$section->{description_generator}}($line);
\r
315 '{' . ( $line->{'ref'} ne $lastref ? $line->{'ref'} : '' ) . '}'.
\r
316 '{' . $line->{'description'} . '}' .
\r
317 '{' . ( $unitprices ? $line->{'unit_amount'} : '' ) . '}'.
\r
318 '{' . ( $unitprices ? $line->{'quantity'} : '' ) . '}' .
\r
319 '{' . $line->{'amount'} . "}${rowbreak}\n";
\r
321 $lastref = $line->{'ref'};
\r
323 foreach my $ext_desc (@$ext_description) {
\r
324 if ($section->{extended_description_generator}) {
\r
325 $OUT .= &{$section->{extended_description_generator}}($ext_desc);
\r
327 if ( $ext_desc !~ /[^\\]&/ ) {
\r
328 $ext_desc = substr($ext_desc, 0, 80) . '...'
\r
329 if (length($ext_desc) > 80);
\r
330 $ext_desc = '\multicolumn{6}{l}{\small{~~~'. $ext_desc. '}}';
\r
332 $ext_desc = "~~~$ext_desc";
\r
334 $OUT .= '\FSextdesc{' . $ext_desc . '}' . "${rowbreak}\n";
\r
340 $OUT .= '\end{longtable}';
\r
342 if ($section->{'posttotal'}) {
\r
343 $OUT .= '\begin{flushright}';
\r
344 $OUT .= '\normalfont\large\bfseries\textsc{'. $section->{'posttotal'}. '}\\\\';
\r
345 $OUT .= '\\end{flushright}';
\r
351 \begin{minipage}[t]{\textwidth}
\r
352 [@-- length($summary)
\r
355 ? '\scriptsize{ '.$notes.' }'
\r
359 [@-- $coupon ? '\ifthenelse{\equal{\thepage}{1}}{\rule{0pt}{\extracouponspace}}{}' : '' --@]
\r