%% Asplen Management Ltd\r
%% www.asplen.co.uk\r
%%\r
-%% Modified for Freeside by Ivan Kohler\r
+%% Modified for Freeside by Kristian Hoffman\r
%%\r
%% Changes\r
%% 0.1 4/12/00 Created\r
%% 1.2 16/10/02 Invoice number added\r
%% 1.3 2/12/02 Logo graphic added\r
%% 1.4 7/2/03 Multipage headers/footers added\r
-%% n/a 10/12/03 forked for Freeside; checked into CVS\r
+%% n/a forked for Freeside; checked into CVS\r
%%\r
\r
\documentclass[letterpaper]{article}\r
\usepackage{fancyhdr,lastpage,ifthen,longtable,afterpage}\r
\usepackage{graphicx} % required for logo graphic\r
\r
-\addtolength{\voffset}{-0.0in} % top margin to top of header\r
-\addtolength{\hoffset}{-0.60in} %left margin on page\r
-\addtolength{\topmargin}{-0.6in} % top margin to top of header\r
-\setlength{\headheight}{1in} % height of header\r
-\setlength{\headsep}{0.5in} % between header and text\r
-\addtolength{\textheight}{-0.4in} % height of main text\r
+\addtolength{\voffset}{-0.0cm} % top margin to top of header\r
+\addtolength{\hoffset}{-0.6cm} % left margin on page\r
+\addtolength{\topmargin}{-1.25cm} % top margin to top of header\r
+\setlength{\headheight}{2.0cm} % height of header\r
+\setlength{\headsep}{1.0cm} % between header and text\r
+\setlength{\footskip}{1.0cm} % bottom of footer from bottom of text\r
\r
-\addtolength{\textheight}{-0.5in} % height of main text\r
-\setlength{\footskip}{0.5in} % bottom of footer from bottom of text\r
-\r
-\addtolength{\textwidth}{2.1in} % width of text\r
-\setlength{\oddsidemargin}{0in} % odd page left margin\r
-\setlength{\evensidemargin}{0in} % even page left margin\r
+%\addtolength{\textwidth}{2.1in} % width of text\r
+\setlength{\textwidth}{19.5cm}\r
+\setlength{\textheight}{19.5cm}\r
+\setlength{\oddsidemargin}{-0.9cm} % odd page left margin\r
+\setlength{\evensidemargin}{-0.9cm} % even page left margin\r
\r
\renewcommand{\headrulewidth}{0pt}\r
\renewcommand{\footrulewidth}{1pt}\r
\r
- % New command for address lines i.e. skip them if blank\r
+% Adjust the inset of the mailing address\r
+\newcommand{\addressinset}[1][]{\hspace{1.0cm}}\r
+\r
+% Adjust the inset of the return address and logo\r
+\newcommand{\returninset}[1][]{\hspace{-0.25cm}}\r
\r
+% New command for address lines i.e. skip them if blank\r
\newcommand{\addressline}[1]{\ifthenelse{\equal{#1}{}}{}{#1\newline}}\r
-\newcommand{\dollar}[1][]{\symbol{36}} % Inserts dollar symbol\r
+\r
+% Inserts dollar symbol\r
+\newcommand{\dollar}[1][]{\symbol{36}}\r
+\r
+% Remove plain style header/footer\r
+\fancypagestyle{plain}{\r
+ \fancyhead{}\r
+}\r
+\fancyhf{}\r
+\r
+% Define fancy header/footer for first and subsequent pages\r
+\fancyfoot[C]{\r
+ \ifthenelse{\equal{\thepage}{1}}\r
+ { % First page\r
+ \small{\r
+[@-- $footer --@]\r
+ }\r
+ }\r
+ { % ... pages\r
+ \small{\r
+[@-- $smallfooter --@]\r
+ }\r
+ }\r
+}\r
+\r
+\fancyfoot[R]{\r
+ \ifthenelse{\equal{\thepage}{1}}\r
+ { % First page\r
+ }\r
+ { % ... pages\r
+ \small{\thepage\ of \pageref{LastPage}}\r
+ }\r
+}\r
+\r
+\fancyhead[L]{\r
+ \ifthenelse{\equal{\thepage}{1}}\r
+ { % First page\r
+ \returninset\r
+ \makebox{\r
+ \begin{tabular}{ll}\r
+ \includegraphics{[@-- $logo_file --@]} &\r
+ \begin{minipage}[b]{5.5cm}\r
+[@-- $returnaddress --@]\r
+ \end{minipage}\r
+ \end{tabular}\r
+ }\r
+ }\r
+ { % ... pages\r
+ %\includegraphics{[@-- $logo_file --@]} % Uncomment if you want the logo on all pages.\r
+ }\r
+}\r
+\r
+\fancyhead[R]{\r
+ \ifthenelse{\equal{\thepage}{1}}\r
+ { % First page\r
+ \begin{tabular}{ccc}\r
+ Invoice date & Invoice \#& Customer\#\\\r
+ \vspace{0.2cm}\r
+ \textbf{[@-- $date --@]} & \textbf{[@-- $invnum --@]} & \textbf{[@-- $custnum --@]} \\\hline\r
+ \rule{0pt}{5ex} &~~ \huge{\textsc{Invoice}} & \\\r
+ \vspace{-0.2cm}\r
+ & & \\\hline\r
+ \end{tabular}\r
+ }\r
+ { % ... pages\r
+ \small{\r
+ \begin{tabular}{lll}\r
+ Invoice date & Invoice \#& Customer\#\\\r
+ \textbf{[@-- $date --@]} & \textbf{[@-- $invnum --@]} & \textbf{[@-- $custnum --@]}\\\r
+ \end{tabular}\r
+ }\r
+ }\r
+}\r
\r
\pagestyle{fancy}\r
\r
+\r
%% Font options are:\r
%% bch Bitsream Charter\r
%% put Utopia\r
%% ptm Times\r
%% pcr Courier\r
\r
-\renewcommand{\familydefault}{phv} \r
+\renewcommand{\familydefault}{phv}\r
+\r
+\r
+% Commands for freeside description...\r
+\newcommand{\FSdesc}[3]{\r
+ \multicolumn{1}{c}{\rule{0pt}{2.5ex}\textbf{#1}} &\r
+ \textbf{#2} &\r
+ \multicolumn{1}{r}{\textbf{\dollar #3}}\\\r
+}\r
+% ...extended description...\r
+\newcommand{\FSextdesc}[1]{\r
+ \multicolumn{1}{l}{\rule{0pt}{1.0ex}} &\r
+ \multicolumn{2}{l}{\small{~-~#1}}\\\r
+}\r
+% ...and total line items.\r
+\newcommand{\FStotaldesc}[2]{\r
+ & \multicolumn{1}{l}{#1} & #2\\\r
+}\r
+\r
\r
\begin{document}\r
%\r
%% Headers and footers defined for the first page\r
-\fancyfoot[CO,CE]{\small{\r
-\begin{tabular}{c}\r
-$footer\r
-\end{tabular}}}\r
%\r
%% The LH Heading comprising logo\r
%% UNCOMMENT the following FOUR lines and change the path if necssary to provide a logo\r
-\fancyhead[LO,LE]{\r
-\begin{tabular}{l}\r
-\includegraphics{/usr/local/etc/freeside/logo.eps}\r
-\end{tabular}}\r
%\r
%% The Heading comprising isue date, customer ref & INVOICE name\r
-\fancyhead[RO,RE]{\r
-\begin{tabular}{rcl}\r
-Invoice date & & Invoice number \\\r
-\vspace{0.2cm}\r
-\textbf{$date} & & \textbf{$invnum} \\\hline\r
-\rule{0pt}{5ex} &~~ \huge{\textsc{Invoice}}& \\\r
-\vspace{-0.2cm}\r
- & & \\\hline\r
-\end{tabular}}\r
%\r
%% Header & footer changes for subsequent pages\r
%\r
-\afterpage{ \fancyfoot[RO,RE]{\small{\thepage\ of \pageref{LastPage}}} }\r
-\afterpage{ \fancyfoot[CO,CE]{\small{$org_company}} }\r
-\afterpage{ \fancyhead[LO,LE]{\small{}} }\r
-\afterpage{ \fancyhead[RO,RE]{\small{\r
-\begin{tabular}{ll}\r
-Date & Account number\\\r
-\textbf{ $date_of_bill} & \textbf{ $customer_ref}\\\r
-\end{tabular}}} }\r
%\r
%\r
+\begin{tabular}{ll}\r
+\addressinset \rule{0cm}{0cm} &\r
\makebox{\r
-\begin{minipage}[t]{2.9in}\r
-\vspace{0.20in}\r
-\textbf{$payname}\\\r
-\addressline{$company}\r
-\addressline{$address1}\r
-\addressline{$address2}\r
-\addressline{$city, $state $zip}\r
-\addressline{$country}\r
+\begin{minipage}[t]{5.0cm}\r
+\vspace{0.25cm}\r
+\textbf{[@-- $payname --@]}\\\r
+\addressline{[@-- $company --@]}\r
+\addressline{[@-- $address1 --@]}\r
+\addressline{[@-- $address2 --@]}\r
+\addressline{[@-- $city --@], [@-- $state --@]~~[@-- $zip --@]}\r
+\addressline{[@-- $country --@]}\r
\end{minipage}}\r
+\end{tabular}\r
\hfill\r
\makebox{\r
-\begin{minipage}[t]{2.5in}\r
+\begin{minipage}[t]{6.4cm}\r
\begin{flushright}\r
-Terms: $terms\\\r
-$po_line\\\r
+Terms: [@-- $terms --@]\\\r
+[@-- $po_line --@]\\\r
\end{flushright}\r
\end{minipage}}\r
-\vspace{0.5cm}\r
+\vspace{1.5cm}\r
%\r
-\section*{\textsc{Charges}}\r
-\begin{longtable}{|c|l|c|r|r|}\r
-\hline\r
-\rule{0pt}{2.5ex}\r
-\makebox[1.4cm]{\textbf{Ref}} & \r
-\makebox[7.9cm][l]{\textbf{Description}} & \r
-\makebox[1.3cm][c]{\textbf{Quantity}} & \r
-\makebox[2.5cm][r]{\textbf{Unit Price}} & \r
-\makebox[2.5cm][r]{\textbf{Amount}} \\\r
-\hline\r
-\endfirsthead\r
-\multicolumn{5}{r}{\rule{0pt}{2.5ex}Continued from previous page}\\\r
-\hline\r
-\rule{0pt}{2.5ex}\r
-\makebox[1.4cm]{\textbf{Ref}} & \r
-\makebox[7.9cm][l]{\textbf{Description}} & \r
-\makebox[1.3cm][c]{\textbf{Quantity}} & \r
-\makebox[2.5cm][r]{\textbf{Unit Price}} & \r
-\makebox[2.5cm][r]{\textbf{Amount}} \\\r
-\hline\r
-\endhead\r
-\multicolumn{5}{r}{\rule{0pt}{2.5ex}/cont...}\\\r
-\endfoot\r
-%%TotalDetails\r
- & \multicolumn{3}{l}{$total_item} & $total_amount\\\r
-%%EndTotalDetails\r
-\hline\r
-\endlastfoot\r
-%%Detail\r
-\rule{0pt}{2.5ex}$ref & \r
-\begin{tabular}{l}\r
-$description\tabularnewline\r
-\end{tabular}\r
-& $quantity & \dollar $amount & \dollar $amount\\\hline\r
-%%EndDetail\r
-\end{longtable}\r
+[@--\r
+ foreach my $section ( @sections ) {\r
+ $OUT .= '\section*{\textsc{';\r
+ $OUT .= ($section->{'description'}) ? $section->{'description'} : 'Charges';\r
+ $OUT .= '}}\begin{longtable}{clr}';\r
+ $OUT .= '\hline';\r
+ $OUT .= '\rule{0pt}{2.5ex}';\r
+ $OUT .= '\makebox[1.4cm]{\textbf{Ref}} & ';\r
+ $OUT .= '\makebox[12.8cm][l]{\textbf{Description}} & ';\r
+ $OUT .= '\makebox[2.5cm][r]{\textbf{Amount}} \\\\';\r
+ $OUT .= '\hline';\r
+ $OUT .= '\endfirsthead';\r
+ $OUT .= '\multicolumn{3}{r}{\rule{0pt}{2.5ex}Continued from previous page}\\\\';\r
+ $OUT .= '\hline';\r
+ $OUT .= '\rule{0pt}{2.5ex}';\r
+ $OUT .= '\makebox[1.4cm]{\textbf{Ref}} & ';\r
+ $OUT .= '\makebox[12.8cm][l]{\textbf{Description}} & ';\r
+ $OUT .= '\makebox[2.5cm][r]{\textbf{Amount}} \\\\';\r
+ $OUT .= '\hline';\r
+ $OUT .= '\endhead';\r
+ $OUT .= '\multicolumn{3}{r}{\rule{0pt}{2.5ex}Continued on next page...}\\\\';\r
+ $OUT .= '\endfoot';\r
+ $OUT .= '\hline';\r
+\r
+ if (scalar(@sections) > 1) {\r
+ $OUT .= '\FStotaldesc{' . $section->{'description'} . ' Total}' .\r
+ '{' . $section->{'subtotal'} . '}' . "\n";\r
+ }\r
+\r
+ if ($section == $sections[$#sections]) {\r
+ foreach my $line (@total_items) {\r
+ $OUT .= '\FStotaldesc{' . $line->{'total_item'} . '}' .\r
+ '{' . $line->{'total_amount'} . '}' . "\n";\r
+ }\r
+ }\r
+\r
+ $OUT .= '\hline';\r
+ $OUT .= '\endlastfoot';\r
+\r
+ foreach my $line (\r
+ grep { ( scalar( @sections ) > 1 \r
+ ? $section->{'description'} eq $_->{'section'}->{'description'}\r
+ : 1\r
+ ) }\r
+ @detail_items )\r
+ {\r
+ my $ext_description = $line->{'ext_description'};\r
+ \r
+ # Don't break-up small packages.\r
+ my $rowbreak = @$ext_description < 5 ? '*' : '';\r
+ \r
+ $OUT .= "\\hline\n";\r
+ $OUT .= '\FSdesc{' . $line->{'ref'} . '}{' . $line->{'description'} . '}' .\r
+ '{' . $line->{'amount'} . "}${rowbreak}\n";\r
+\r
+ foreach my $ext_desc (@$ext_description) {\r
+ $ext_desc = substr($ext_desc, 0, 80) . '...'\r
+ if (length($ext_desc) > 80);\r
+ $OUT .= '\FSextdesc{' . $ext_desc . '}' . "${rowbreak}\n";\r
+ }\r
+\r
+ }\r
+\r
+ $OUT .= '\end{longtable}';\r
+\r
+ }\r
+\r
+--@]\r
\vfill\r
-$notes\r
+[@-- $notes --@]\r
\end{document}\r