RT# 83450 - added fields interface and map_location to export
[freeside.git] / conf / quotation_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,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
26 \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
33 \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
39 \r
40 \LTchunksize=40\r
41 \r
42 \r
43 \begin{document}\r
44 \r
45 \r
46 \renewcommand{\headrulewidth}{0pt}\r
47 \renewcommand{\footrulewidth}{1pt}\r
48 \r
49 \renewcommand{\footrule}{\r
50 [@--\r
51   $coupon ? '\ifthenelse{\equal{\thepage}{1}}' : '';\r
52 --@]\r
53   {\r
54   }\r
55   {\r
56     \vbox to 0pt{\rule{\headwidth}{\footrulewidth}\vss}\r
57   }\r
58 }\r
59 \r
60 \newcommand{\extracouponspace}{[@-- defined($extracouponspace) ? $extracouponspace : '3.6cm' --@]}\r
61 \r
62 % Adjust the inset of the mailing address\r
63 \newcommand{\addressinset}[1][]{\hspace{1.0cm}}\r
64 \r
65 % Adjust the inset of the return address and logo\r
66 \newcommand{\returninset}[1][]{\hspace{-0.25cm}}\r
67 \r
68 % New command for address lines i.e. skip them if blank\r
69 \newcommand{\addressline}[1]{\ifthenelse{\equal{#1}{}}{}{#1\\}}\r
70 \r
71 % Inserts dollar symbol\r
72 \newcommand{\dollar}[1][]{\symbol{36}}\r
73 \r
74 % Remove plain style header/footer\r
75 \fancypagestyle{plain}{\r
76   \fancyhead{}\r
77 }\r
78 \fancyhf{}\r
79 \r
80 % Define fancy header/footer for first and subsequent pages\r
81 \fancyfoot[C]{\r
82   \ifthenelse{\equal{\thepage}{1}}\r
83   { % First page\r
84 [@--\r
85   if ($coupon) {\r
86     $OUT .= '\vspace{-\extracouponspace}';\r
87     $OUT .= '\rule[0.5em]{\textwidth}{\footrulewidth}\\\\';\r
88     $OUT .= $coupon;\r
89     $OUT .= '\vspace{'. $couponfootsep. '}' if defined($couponfootsep);\r
90   }\r
91   '';\r
92 --@] [@-- $smallerfooter ? '\scriptsize{' : '\small{' --@]\r
93 [@-- $footer --@]\r
94     }[@-- $coupon ? '\vspace{\extracouponspace}' : '' --@]\r
95   }\r
96   { % ... pages\r
97     [@-- $smallerfooter ? '\scriptsize{' : '\small{' --@]\r
98 [@-- $smallfooter --@]\r
99     }\r
100   }\r
101 }\r
102 \r
103 \fancyfoot[R]{\r
104   \ifthenelse{\equal{\thepage}{1}}\r
105   { % First page\r
106   }\r
107   { % ... pages\r
108     \small{\thepage\ of \pageref{LastPage}}\r
109   }\r
110 }\r
111 \r
112 \fancyhead[L]{\r
113   \ifthenelse{\equal{\thepage}{1}}\r
114   { % First page\r
115     \returninset\r
116     \makebox{\r
117       \begin{tabular}{ll}\r
118         \includegraphics{[@-- $logo_file --@]} & [@-- $verticalreturnaddress ? '\\\\' : '' --@]\r
119         \begin{minipage}[b]{5.5cm}\r
120 [@-- $returnaddress --@]\r
121         \end{minipage}\\\r
122       \end{tabular}\r
123     }\r
124   }\r
125   { % ... pages\r
126     %\includegraphics{[@-- $logo_file --@]}     % Uncomment if you want the logo on all pages.\r
127   }\r
128 }\r
129 \r
130 \fancyhead[R]{\r
131   \ifthenelse{\equal{\thepage}{1}}\r
132   { % First page\r
133     \begin{tabular}{ccc}\r
134     [@-- join(' & ', emt('Quotation date'), emt('Quotation #'), $custnum ? emt('Customer #') : emt('Prospect #') ) --@]\\\r
135     \vspace{0.2cm}\r
136     \textbf{[@-- $date --@]} & \textbf{[@-- $quotationnum --@]} & \textbf{[@-- $custnum || $prospectnum --@]} \\\hline\r
137     \rule{0pt}{5ex} &~~ \huge{\textsc{[@-- emt($notice_name) --@]}} & \\\r
138     \vspace{-0.2cm}\r
139      & & \\\hline\r
140     \end{tabular}\r
141   }\r
142   { % ... pages\r
143     \small{\r
144       \begin{tabular}{lll}\r
145       [@-- join(' & ', emt('Quotation date'), emt('Quotation #'), $custnum ? emt('Customer #') : emt('Prospect #') ) --@]\\\r
146       \textbf{[@-- $date --@]} & \textbf{[@-- $quotationnum --@]} & \textbf{[@-- $custnum || $prospectnum --@]}\\\r
147       \end{tabular}\r
148     }\r
149   }\r
150 }\r
151 \r
152 \pagestyle{fancy}\r
153 \r
154 \r
155 %% Font options are:\r
156 %%      bch     Bitsream Charter\r
157 %%      put     Utopia\r
158 %%      phv     Adobe Helvetica\r
159 %%      pnc     New Century Schoolbook\r
160 %%      ptm     Times\r
161 %%      pcr     Courier\r
162 \r
163 \renewcommand{\familydefault}{phv}\r
164 \r
165 \r
166 % Commands for freeside table header...\r
167 \r
168 \newcommand{\FSdescriptionlength} { [@-- $unitprices ? '8.2cm' : '12.8cm' --@] }\r
169 \newcommand{\FSdescriptioncolumncount} { [@-- $unitprices ? '4' : '6' --@] }\r
170 \newcommand{\FSunitcolumns}{ [@-- \r
171   $unitprices \r
172   ? '\makebox[2.5cm][l]{\textbf{~~'.emt('Unit Price').'}}&\makebox[1.4cm]{\textbf{~'.emt('Quantity').'}}&' \r
173   : '' --@] }\r
174 \r
175 \newcommand{\FShead}{\r
176   \hline\r
177   \rule{0pt}{2.5ex}\r
178   \makebox[1.4cm]{} &\r
179   \multicolumn{\FSdescriptioncolumncount}{l}{\makebox[\FSdescriptionlength][l]{\textbf{[@-- emt('Description') --@]}}}&\r
180   \FSunitcolumns\r
181   \makebox[1.6cm][r]{\textbf{[@-- emt('Amount') --@]}} \\\r
182   \hline\r
183 }\r
184 \r
185 % ...description...\r
186 \newcommand{\FSdesc}[5]{\r
187   \multicolumn{1}{c}{\rule{0pt}{2.5ex}\textbf{#1}} &\r
188   \multicolumn{[@-- $unitprices ? '4' : '6' --@]}{l}{\textbf{#2}} &\r
189 [@-- $unitprices ? '  \multicolumn{1}{l}{\textbf{#3}} &'."\n".\r
190                    '  \multicolumn{1}{r}{\textbf{#4}} &'."\n"\r
191                  : ''\r
192 --@]\r
193   \multicolumn{1}{r}{\textbf{\dollar #5}}\\\r
194 }\r
195 % ...extended description...\r
196 \newcommand{\FSextdesc}[1]{\r
197   \multicolumn{1}{l}{\rule{0pt}{1.0ex}} &\r
198 %%  \multicolumn{2}{l}{\small{~-~#1}}\\\r
199 #1\\\r
200 }\r
201 % ...and total line items.\r
202 \newcommand{\FStotaldesc}[2]{\r
203   & \multicolumn{6}{l}{#1} & #2\\\r
204 }\r
205 \r
206 \r
207 %       Headers and footers defined for the first page\r
208 \addressinset \rule{0.5cm}{0cm} \r
209 \makebox{\r
210 \begin{minipage}[t]{7.0cm}\r
211 \vspace{[@-- defined($addresssep) ? $addresssep : '0.25cm' --@]}\r
212 \textbf{[@-- $payname --@]}\\\r
213 \addressline{[@-- $company --@]}\r
214 \addressline{[@-- $address1 --@]}\r
215 \addressline{[@-- $address2 --@]}\r
216 \addressline{[@-- $city --@], [@-- $state --@]~~[@-- $zip --@]}\r
217 \addressline{[@-- $country --@]}\r
218 \end{minipage}}\r
219 \hfill\r
220 \makebox{\r
221 \begin{minipage}[t]{6.4cm}\r
222 [@--\r
223   if ($ship_enable) {\r
224     $OUT .= '\textbf{' . emt('Service Address') . '}\\\\';\r
225     $OUT .= "\\addressline{$ship_company}";\r
226     $OUT .= "\\addressline{$ship_address1}";\r
227     $OUT .= "\\addressline{$ship_address2}";\r
228     $OUT .= "\\addressline{$ship_city, $ship_state~~$ship_zip}";\r
229     $OUT .= "\\addressline{$ship_country}";\r
230     $OUT .= '~\\\\';\r
231   }else{\r
232     $OUT .= '';\r
233   }\r
234 --@]\r
235 \begin{flushright}\r
236 [@-- $terms ? emt('Terms') .": $terms" : '' --@]\\\r
237 [@-- $po_line --@]\\\r
238 \end{flushright}\r
239 \end{minipage}}\r
240 \vspace{1.5cm}\r
241 %\r
242 [@-- $summary --@]\r
243 %\r
244 \section*{}\r
245 [@--\r
246   foreach my $section ( grep { !$summary || $_->{description} ne $finance_section } @sections ) {\r
247     if ($section->{'pretotal'} && !$summary) {\r
248       $OUT .= '\begin{flushright}';\r
249       $OUT .= '\large\textsc{'. $section->{'pretotal'}. '}\\\\';\r
250       $OUT .= '\\end{flushright}';\r
251     }\r
252     $OUT .= '\pagebreak' if $section->{'post_total'};\r
253     unless ($section->{'summarized'} ) {\r
254       $OUT .= '\captionsetup{singlelinecheck=false,justification=raggedright,font={Large,sc,bf}}';\r
255       $OUT .= '\ifthenelse{\equal{\thepage}{1}}{\setlength{\LTextracouponspace}{\extracouponspace}}{\setlength{\LTextracouponspace}{0pt}}'\r
256         if $coupon;\r
257       $OUT .= '\begin{longtable}{cllllllr}';\r
258       $OUT .= '\caption*{ ';\r
259       $OUT .= ($section->{'description'}) ? $section->{'description'}: emt('Charges');\r
260       $OUT .= '}\\\\';\r
261       if ($section->{header_generator}) {\r
262         $OUT .= &{$section->{header_generator}}();\r
263       } else {\r
264         $OUT .= '\FShead';\r
265       }\r
266       $OUT .= '\endfirsthead';\r
267       $OUT .= '\multicolumn{7}{r}{\rule{0pt}{2.5ex}'.emt('Continued from previous page').'}\\\\';\r
268       if ($section->{header_generator}) {\r
269         $OUT .= &{$section->{header_generator}}();\r
270       } else {\r
271         $OUT .= '\FShead';\r
272       }\r
273       $OUT .= '\endhead';\r
274       $OUT .= '\multicolumn{7}{r}{\rule{0pt}{2.5ex}'.emt('Continued on next page...').'}\\\\';\r
275       $OUT .= '\endfoot';\r
276       $OUT .= '\hline';\r
277 \r
278       if (scalar(@sections) > 1 and !$section->{no_subtotal}) {\r
279         if ($section->{total_generator}) {\r
280           $OUT .= &{$section->{total_generator}}($section);\r
281         } else {\r
282           $OUT .= '\FStotaldesc{' . $section->{'description'} . ' Total}' .\r
283                   '{' . $section->{'subtotal'} . '}' . "\n";\r
284         }\r
285       }\r
286 \r
287       foreach my $line (grep {$_->{section}->{description} eq $section->{description}} @total_items) {\r
288         if ($section->{total_line_generator}) {\r
289           $OUT .= &{$section->{total_line_generator}}($line);\r
290         } else {\r
291           $OUT .= '\FStotaldesc{' . $line->{'total_item'} . '}' .\r
292                   '{' . $line->{'total_amount'} . '}' . "\n";\r
293           $OUT .= '\hline' . "\n" if $line->{'break_after'};\r
294         }\r
295       }\r
296 \r
297       $OUT .= '\endlastfoot';\r
298 \r
299       my $lastref = 0;\r
300       foreach my $line (\r
301         grep { ( scalar( @sections ) > 1 \r
302                ? $section->{'description'} eq $_->{'section'}->{'description'}\r
303                : 1\r
304              ) }\r
305         @detail_items )\r
306       {\r
307         my $ext_description = $line->{'ext_description'};\r
308   \r
309         # Don't break-up small packages.\r
310         my $rowbreak = @$ext_description < 5 ? '*' : '';\r
311   \r
312         $OUT .= "\\hline\n" if ($line->{'ref'} && $line->{'ref'} ne $lastref);\r
313         if ($section->{description_generator}) {\r
314           $OUT .= &{$section->{description_generator}}($line);\r
315         } else {\r
316           $OUT .= '\FSdesc'.\r
317                   '{}'. #'{' . ( $line->{'ref'} ne $lastref ? $line->{'ref'} : '' ) . '}'.\r
318                   '{' . $line->{'description'} . '}' .\r
319                   '{' . ( $unitprices ? $line->{'unit_amount'} : '' ) . '}'.\r
320                   '{' . ( $unitprices ? $line->{'quantity'} : ''  ) . '}' .\r
321                   '{' . $line->{'amount'} . "}${rowbreak}\n";\r
322         }\r
323         $lastref = $line->{'ref'};\r
324 \r
325         foreach my $ext_desc (@$ext_description) {\r
326           if ($section->{extended_description_generator}) {\r
327             $OUT .= &{$section->{extended_description_generator}}($ext_desc);\r
328           } else {\r
329             if ( $ext_desc !~ /[^\\]&/ ) {\r
330               $ext_desc = substr($ext_desc, 0, 80) . '...'\r
331                 if (length($ext_desc) > 80);\r
332               $ext_desc = '\multicolumn{6}{l}{\small{~~~'. $ext_desc. '}}';\r
333             }else{\r
334               $ext_desc = "~~~$ext_desc";\r
335             }\r
336             $OUT .= '\FSextdesc{' . $ext_desc . '}' . "${rowbreak}\n";\r
337           }\r
338         }\r
339 \r
340       }\r
341 \r
342       $OUT .= '\end{longtable}';\r
343     }\r
344     if ($section->{'posttotal'}) {\r
345       $OUT .= '\begin{flushright}';\r
346       $OUT .= '\normalfont\large\bfseries\textsc{'. $section->{'posttotal'}. '}\\\\';\r
347       $OUT .= '\\end{flushright}';\r
348     }\r
349   }\r
350 \r
351 --@]\r
352 \vfill\r
353 \begin{minipage}[t]{\textwidth}\r
354   [@-- length($summary)\r
355          ? ''\r
356         : ( $smallernotes\r
357               ? '\scriptsize{ '.$notes.' }'\r
358               : $notes\r
359           )\r
360   --@]\r
361   [@-- $coupon ? '\ifthenelse{\equal{\thepage}{1}}{\rule{0pt}{\extracouponspace}}{}' : '' --@]\r
362 \end{minipage}\r
363 \end{document}\r