ef92cf3fd92104af9c029456010b6df3dbf3ea7b
[freeside.git] / conf / invoice_latex
1 %% file: Standard Multipage.tex\r
2 %% Purpose: Multipage bill template for e-Bills\r
3 %% \r
4 %% Created by Mark Asplen-Taylor\r
5 %% Asplen Management Ltd\r
6 %% www.asplen.co.uk\r
7 %%\r
8 %% Modified for Freeside by Kristian Hoffman\r
9 %%\r
10 %% Changes\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
18 %%\r
19 \r
20 \documentclass[letterpaper]{article}\r
21 \r
22 \usepackage{fancyhdr,lastpage,ifthen,longtable,afterpage,multirow,bigstrut}\r
23 \usepackage{graphicx}                   % required for logo graphic\r
24 \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
31 \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
37 \r
38 \renewcommand{\headrulewidth}{0pt}\r
39 \renewcommand{\footrulewidth}{1pt}\r
40 \r
41 \renewcommand{\footrule}{\r
42 [@--\r
43   $coupon ? '\ifthenelse{\equal{\thepage}{1}}' : '';\r
44 --@]\r
45   {\r
46   }\r
47   {\r
48     \vbox to 0pt{\rule{\headwidth}{\footrulewidth}\vss}\r
49   }\r
50 }\r
51 \r
52 \newcommand{\extracouponspace}{4.8cm}\r
53 \r
54 % Adjust the inset of the mailing address\r
55 \newcommand{\addressinset}[1][]{\hspace{1.0cm}}\r
56 \r
57 % Adjust the inset of the return address and logo\r
58 \newcommand{\returninset}[1][]{\hspace{-0.25cm}}\r
59 \r
60 % New command for address lines i.e. skip them if blank\r
61 \newcommand{\addressline}[1]{\ifthenelse{\equal{#1}{}}{}{#1\\}}\r
62 \r
63 % Inserts dollar symbol\r
64 \newcommand{\dollar}[1][]{\symbol{36}}\r
65 \r
66 % Remove plain style header/footer\r
67 \fancypagestyle{plain}{\r
68   \fancyhead{}\r
69 }\r
70 \fancyhf{}\r
71 \r
72 % Define fancy header/footer for first and subsequent pages\r
73 \fancyfoot[C]{\r
74   \ifthenelse{\equal{\thepage}{1}}\r
75   { % First page\r
76 [@--\r
77   if ($coupon) {\r
78     $OUT .= '\vspace{-\extracouponspace}';\r
79     $OUT .= '\rule[0.5em]{\textwidth}{\footrulewidth}\\\\';\r
80     $OUT .= $coupon;\r
81   }\r
82   '';\r
83 --@] \small{\r
84 [@-- $footer --@]\r
85     }[@-- $coupon ? '\vspace{\extracouponspace}' : '' --@]\r
86   }\r
87   { % ... pages\r
88     \small{\r
89 [@-- $smallfooter --@]\r
90     }\r
91   }\r
92 }\r
93 \r
94 \fancyfoot[R]{\r
95   \ifthenelse{\equal{\thepage}{1}}\r
96   { % First page\r
97   }\r
98   { % ... pages\r
99     \small{\thepage\ of \pageref{LastPage}}\r
100   }\r
101 }\r
102 \r
103 \fancyhead[L]{\r
104   \ifthenelse{\equal{\thepage}{1}}\r
105   { % First page\r
106     \returninset\r
107     \makebox{\r
108       \begin{tabular}{ll}\r
109         \includegraphics{[@-- $conf_dir --@]/logo.eps} &\r
110         \begin{minipage}[b]{5.5cm}\r
111 [@-- $returnaddress --@]\r
112         \end{minipage}\r
113       \end{tabular}\r
114     }\r
115   }\r
116   { % ... pages\r
117     %\includegraphics{[@-- $conf_dir --@]/logo.eps}     % Uncomment if you want the logo on all pages.\r
118   }\r
119 }\r
120 \r
121 \fancyhead[R]{\r
122   \ifthenelse{\equal{\thepage}{1}}\r
123   { % First page\r
124     \begin{tabular}{ccc}\r
125     Invoice date & Invoice \#& Customer\#\\\r
126     \vspace{0.2cm}\r
127     \textbf{[@-- $date --@]} & \textbf{[@-- $invnum --@]} & \textbf{[@-- $custnum --@]} \\\hline\r
128     \rule{0pt}{5ex} &~~ \huge{\textsc{Invoice}} & \\\r
129     \vspace{-0.2cm}\r
130      & & \\\hline\r
131     \end{tabular}\r
132   }\r
133   { % ... pages\r
134     \small{\r
135       \begin{tabular}{lll}\r
136       Invoice date & Invoice \#& Customer\#\\\r
137       \textbf{[@-- $date --@]} & \textbf{[@-- $invnum --@]} & \textbf{[@-- $custnum --@]}\\\r
138       \end{tabular}\r
139     }\r
140   }\r
141 }\r
142 \r
143 \pagestyle{fancy}\r
144 \r
145 \r
146 %% Font options are:\r
147 %%      bch     Bitsream Charter\r
148 %%      put     Utopia\r
149 %%      phv     Adobe Helvetica\r
150 %%      pnc     New Century Schoolbook\r
151 %%      ptm     Times\r
152 %%      pcr     Courier\r
153 \r
154 \renewcommand{\familydefault}{phv}\r
155 \r
156 \r
157 % Commands for freeside description...\r
158 \newcommand{\FSdesc}[5]{\r
159   \multicolumn{1}{c}{\rule{0pt}{2.5ex}\textbf{#1}} &\r
160   \multicolumn{4}{l}{\textbf{#2}} &\r
161   \multicolumn{1}{l}{\textbf{#3}} &\r
162   \multicolumn{1}{r}{\textbf{#4}} &\r
163   \multicolumn{1}{r}{\textbf{\dollar #5}}\\\r
164 }\r
165 % ...extended description...\r
166 \newcommand{\FSextdesc}[1]{\r
167   \multicolumn{1}{l}{\rule{0pt}{1.0ex}} &\r
168 %%  \multicolumn{2}{l}{\small{~-~#1}}\\\r
169 #1\\\r
170 }\r
171 % ...and total line items.\r
172 \newcommand{\FStotaldesc}[2]{\r
173   & \multicolumn{6}{l}{#1} & #2\\\r
174 }\r
175 \r
176 \r
177 \begin{document}\r
178 %\r
179 %%      Headers and footers defined for the first page\r
180 %\r
181 %%      The LH Heading comprising logo\r
182 %%      UNCOMMENT the following FOUR lines and change the path if necssary to provide a logo\r
183 %\r
184 %%      The Heading comprising isue date, customer ref & INVOICE name\r
185 %\r
186 %%      Header & footer changes for subsequent pages\r
187 %\r
188 %\r
189 %\r
190 [@-- $coupon ? '\enlargethispage{-\extracouponspace}' : '' --@]\r
191 \addressinset \rule{0.5cm}{0cm} \r
192 \makebox{\r
193 \begin{minipage}[t]{5.0cm}\r
194 \vspace{0.25cm}\r
195 \textbf{[@-- $payname --@]}\\\r
196 \addressline{[@-- $company --@]}\r
197 \addressline{[@-- $address1 --@]}\r
198 \addressline{[@-- $address2 --@]}\r
199 \addressline{[@-- $city --@], [@-- $state --@]~~[@-- $zip --@]}\r
200 \addressline{[@-- $country --@]}\r
201 \end{minipage}}\r
202 \hfill\r
203 \makebox{\r
204 \begin{minipage}[t]{6.4cm}\r
205 \begin{flushright}\r
206 [@--\r
207   if ($ship_enable) {\r
208     $OUT .= '\textbf{Service Address}\\\\';\r
209     $OUT .= "\\addressline{$ship_company}";\r
210     $OUT .= "\\addressline{$ship_address1}";\r
211     $OUT .= "\\addressline{$ship_address2}";\r
212     $OUT .= "\\addressline{$ship_city, $ship_state~~$ship_zip}";\r
213     $OUT .= "\\addressline{$ship_country}";\r
214     $OUT .= '~\\\\';\r
215     $OUT .= "\\textbf{ID:}~~$agent_custid\\\\" if $agent_custid;\r
216     $OUT .= "\\textbf{Fax:}~~$ship_fax\\\\" if $ship_fax;\r
217     $OUT .= '~\\\\' if ($ship_fax or $agent_custid);\r
218   }else{\r
219     $OUT .= '';\r
220   }\r
221 --@]\r
222 Terms: [@-- $terms --@]\\\r
223 [@-- $po_line --@]\\\r
224 \end{flushright}\r
225 \end{minipage}}\r
226 \vspace{1.5cm}\r
227 %\r
228 \section*{\textsc{Charges}}\r
229 \begin{longtable}{cllllllr}\r
230 \hline\r
231 \rule{0pt}{2.5ex}\r
232 \makebox[1.4cm]{\textbf{Ref}} & \r
233 \makebox[2.0cm][l]{\textbf{Description}}&\r
234 \makebox[2.0cm][l]{}&\r
235 \makebox[2.0cm][l]{}&\r
236 \makebox[2.0cm][l]{}&\r
237 \makebox[2.0cm][l]{\textbf{[@-- $unitprices ? '~~Unit Price' : '' --@]}}&\r
238 \makebox[2.0cm]{\textbf{[@-- $unitprices ? '~Quantity' : '' --@]}}&\r
239 \makebox[2.0cm][r]{\textbf{Amount}} \\\r
240 %\r
241 \hline\r
242 \endfirsthead\r
243 \multicolumn{7}{r}{\rule{0pt}{2.5ex}Continued from previous page}\\\r
244 \hline\r
245 \rule{0pt}{2.5ex}\r
246 \makebox[1.4cm]{\textbf{Ref}} & \r
247 \makebox[2.0cm][l]{\textbf{Description}}&\r
248 \makebox[2.0cm][l]{}&\r
249 \makebox[2.0cm][l]{}&\r
250 \makebox[2.0cm][l]{}&\r
251 \makebox[2.0cm][l]{\textbf{[@-- $unitprices ? '~~Unit Price' : '' --@]}}&\r
252 \makebox[2.0cm]{\textbf{[@-- $unitprices ? '~Quantity' : '' --@]}}&\r
253 \makebox[2.0cm][r]{\textbf{Amount}} \\\r
254 \hline\r
255 \endhead\r
256 \multicolumn{7}{r}{\rule{0pt}{2.5ex}Continued on next page...}\\\r
257 \endfoot\r
258 \hline\r
259 [@--\r
260 \r
261   foreach my $line (@total_items) {\r
262     $OUT .= '\FStotaldesc{' . $line->{'total_item'} . '}' .\r
263             '{' . $line->{'total_amount'} . '}' . "\n";\r
264   }\r
265 \r
266 --@]\r
267 \hline\r
268 \endlastfoot\r
269 [@--\r
270 \r
271   foreach my $line (@detail_items) {\r
272     my $ext_description = $line->{'ext_description'};\r
273 \r
274     # Don't break-up small packages.\r
275     my $rowbreak = @$ext_description < 5 ? '*' : '';\r
276 \r
277     $OUT .= "\\hline\n";\r
278     $OUT .= '\FSdesc{' . $line->{'ref'} . '}{' . $line->{'description'} . '}' .\r
279             '{' . ( $unitprices ? $line->{'unit_amount'} : '' ) . '}'.\r
280             '{' . ( $unitprices ? $line->{'quantity'} : ''  ) . '}' .\r
281             '{' . $line->{'amount'} . "}${rowbreak}\n";\r
282 \r
283     foreach my $ext_desc (@$ext_description) {\r
284       if ( $ext_desc !~ /[^\\]&/ ) {   \r
285         $ext_desc = substr($ext_desc, 0, 80) . '...'\r
286           if (length($ext_desc) > 80);\r
287         $ext_desc = '\multicolumn{6}{l}{\small{~~~'. $ext_desc. '}}';\r
288       }else{\r
289         $ext_desc = "~~~$ext_desc";\r
290       }\r
291       $OUT .= '\FSextdesc{' . $ext_desc . '}' . "${rowbreak}\n";\r
292     }\r
293 \r
294   }\r
295 \r
296 --@]\r
297 \end{longtable}\r
298 \vfill\r
299 [@-- $notes --@]\r
300 \end{document}\r