thank you IE8
[freeside.git] / conf / invoice_latex
index 2acd710..7facc19 100644 (file)
@@ -19,7 +19,7 @@
 \r
 \documentclass[letterpaper]{article}\r
 \r
-\usepackage{fancyhdr,lastpage,ifthen,longtable,afterpage,caption,multirow,bigstrut}\r
+\usepackage{fancyhdr,lastpage,ifthen,fslongtable,afterpage,caption,multirow,bigstrut}\r
 \usepackage{graphicx}                  % required for logo graphic\r
 \r
 \addtolength{\voffset}{-0.0cm}         % top margin to top of header\r
@@ -51,7 +51,7 @@
   }\r
 }\r
 \r
-\newcommand{\extracouponspace}{4.8cm}\r
+\newcommand{\extracouponspace}{3.6cm}\r
 \r
 % Adjust the inset of the mailing address\r
 \newcommand{\addressinset}[1][]{\hspace{1.0cm}}\r
 \renewcommand{\familydefault}{phv}\r
 \r
 \r
-% Commands for freeside description...\r
+% Commands for freeside table header...\r
+\r
+\newcommand{\FSdescriptionlength} { [@-- $unitprices ? '8.2cm' : '12.8cm' --@] }\r
+\newcommand{\FSdescriptioncolumncount} { [@-- $unitprices ? '4' : '6' --@] }\r
+\newcommand{\FSunitcolumns}{ [@-- $unitprices ? '\makebox[2.5cm][l]{\textbf{~~Unit Price}}&\makebox[1.4cm]{\textbf{~Quantity}}&' : '' --@] }\r
+\r
+\newcommand{\FShead}{\r
+  \hline\r
+  \rule{0pt}{2.5ex}\r
+  \makebox[1.4cm]{\textbf{Ref}} &\r
+%  \makebox[2.9cm][l]{\textbf{Description}}&\r
+%  \makebox[1.4cm][l]{}&\r
+%  \makebox[1.4cm][l]{}&\r
+%  \makebox[2.5cm][l]{}&\r
+  \multicolumn{\FSdescriptioncolumncount}{l}{\makebox[\FSdescriptionlength][l]{\textbf{Description}}}&\r
+  \FSunitcolumns\r
+  \makebox[1.6cm][r]{\textbf{Amount}} \\\r
+  \hline\r
+}\r
+\r
+% ...description...\r
 \newcommand{\FSdesc}[5]{\r
   \multicolumn{1}{c}{\rule{0pt}{2.5ex}\textbf{#1}} &\r
   \multicolumn{4}{l}{\textbf{#2}} &\r
 \newcommand{\FSextdesc}[1]{\r
   \multicolumn{1}{l}{\rule{0pt}{1.0ex}} &\r
 %%  \multicolumn{2}{l}{\small{~-~#1}}\\\r
-  ~~~#1\\\r
+#1\\\r
 }\r
 % ...and total line items.\r
 \newcommand{\FStotaldesc}[2]{\r
 \r
 \r
 \begin{document}\r
-%\r
-%%     Headers and footers defined for the first page\r
-%\r
-%%     The LH Heading comprising logo\r
-%%     UNCOMMENT the following FOUR lines and change the path if necssary to provide a logo\r
-%\r
-%%     The Heading comprising isue date, customer ref & INVOICE name\r
-%\r
-%%     Header & footer changes for subsequent pages\r
-%\r
-%\r
-%\r
-[@-- $coupon ? '\enlargethispage{-\extracouponspace}' : '' --@]\r
+%      Headers and footers defined for the first page\r
 \addressinset \rule{0.5cm}{0cm} \r
 \makebox{\r
-\begin{minipage}[t]{5.0cm}\r
+\begin{minipage}[t]{7.0cm}\r
 \vspace{0.25cm}\r
 \textbf{[@-- $payname --@]}\\\r
 \addressline{[@-- $company --@]}\r
 \hfill\r
 \makebox{\r
 \begin{minipage}[t]{6.4cm}\r
-\begin{flushright}\r
 [@--\r
   if ($ship_enable) {\r
     $OUT .= '\textbf{Service Address}\\\\';\r
     $OUT .= '';\r
   }\r
 --@]\r
+\begin{flushright}\r
 Terms: [@-- $terms --@]\\\r
 [@-- $po_line --@]\\\r
 \end{flushright}\r
@@ -232,35 +240,18 @@ Terms: [@-- $terms --@]\\
       $OUT .= '\large\textsc{'. $section->{'pretotal'}. '}\\\\';\r
       $OUT .= '\\end{flushright}';\r
     }\r
+    $OUT .= '\pagebreak' if $section{'post_total'};\r
     $OUT .= '\captionsetup{singlelinecheck=false,justification=raggedright,font={Large,sc,bf}}';\r
+    $OUT .= '\ifthenelse{\equal{\thepage}{1}}{\setlength{\LTextracouponspace}{\extracouponspace}}{\setlength{\LTextracouponspace}{0pt}}'\r
+      if $coupon;\r
     $OUT .= '\begin{longtable}{cllllllr}';\r
     $OUT .= '\caption*{ ';\r
     $OUT .= ($section->{'description'}) ? $section->{'description'}: 'Charges';\r
     $OUT .= '}\\\\';\r
-    $OUT .= '\hline';\r
-    $OUT .= '\rule{0pt}{2.5ex}';\r
-    $OUT .= '\makebox[1.4cm]{\textbf{Ref}} & ';\r
-    $OUT .= '\makebox[2.0cm][l]{\textbf{Description}}& ';\r
-    $OUT .= '\makebox[2.0cm][l]{}& ';\r
-    $OUT .= '\makebox[2.0cm][l]{}& ';\r
-    $OUT .= '\makebox[2.0cm][l]{}& ';\r
-    $OUT .= '\makebox[2.0cm][l]{\textbf{'. ($unitprices ? '~~Unit Price' : ''). '}&';\r
-    $OUT .= '\makebox[2.0cm]{\textbf{'. ($unitprices ? '~Quantity' : ''). '}&';\r
-    $OUT .= '\makebox[2.0cm][r]{\textbf{Amount}} \\\\';\r
-    $OUT .= '\hline';\r
+    $OUT .= '\FShead';\r
     $OUT .= '\endfirsthead';\r
     $OUT .= '\multicolumn{7}{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[2.0cm][l]{\textbf{Description}}& ';\r
-    $OUT .= '\makebox[2.0cm][l]{}& ';\r
-    $OUT .= '\makebox[2.0cm][l]{}& ';\r
-    $OUT .= '\makebox[2.0cm][l]{}& ';\r
-    $OUT .= '\makebox[2.0cm][l]{\textbf{'. ($unitprices ? '~~Unit Price' : ''). '}&';\r
-    $OUT .= '\makebox[2.0cm]{\textbf{'. ($unitprices ? '~Quantity' : ''). '}&';\r
-    $OUT .= '\makebox[2.0cm][r]{\textbf{Amount}} \\\\';\r
-    $OUT .= '\hline';\r
+    $OUT .= '\FShead';\r
     $OUT .= '\endhead';\r
     $OUT .= '\multicolumn{7}{r}{\rule{0pt}{2.5ex}Continued on next page...}\\\\';\r
     $OUT .= '\endfoot';\r
@@ -281,6 +272,7 @@ Terms: [@-- $terms --@]\\
     $OUT .= '\hline';\r
     $OUT .= '\endlastfoot';\r
 \r
+    my $lastref = 0;\r
     foreach my $line (\r
       grep { ( scalar( @sections ) > 1 \r
              ? $section->{'description'} eq $_->{'section'}->{'description'}\r
@@ -293,17 +285,22 @@ Terms: [@-- $terms --@]\\
       # 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
+      $OUT .= "\\hline\n" if ($line->{'ref'} && $line->{'ref'} ne $lastref);\r
+      $OUT .= '\FSdesc'.\r
+              '{' . ( $line->{'ref'} ne $lastref ? $line->{'ref'} : '' ) . '}'.\r
+              '{' . $line->{'description'} . '}' .\r
               '{' . ( $unitprices ? $line->{'unit_amount'} : '' ) . '}'.\r
               '{' . ( $unitprices ? $line->{'quantity'} : ''  ) . '}' .\r
               '{' . $line->{'amount'} . "}${rowbreak}\n";\r
+      $lastref = $line->{'ref'};\r
 \r
       foreach my $ext_desc (@$ext_description) {\r
         if ( $ext_desc !~ /[^\\]&/ ) {\r
           $ext_desc = substr($ext_desc, 0, 80) . '...'\r
             if (length($ext_desc) > 80);\r
-          $ext_desc = '\small{'. $ext_desc. '}';\r
+          $ext_desc = '\multicolumn{6}{l}{\small{~~~'. $ext_desc. '}}';\r
+        }else{\r
+          $ext_desc = "~~~$ext_desc";\r
         }\r
         $OUT .= '\FSextdesc{' . $ext_desc . '}' . "${rowbreak}\n";\r
       }\r
@@ -321,5 +318,8 @@ Terms: [@-- $terms --@]\\
 \r
 --@]\r
 \vfill\r
-[@-- $notes --@]\r
+\begin{minipage}[t]{\textwidth}\r
+  [@-- $notes --@]\r
+  [@-- $coupon ? '\ifthenelse{\equal{\thepage}{1}}{\rule{0pt}{\extracouponspace}}{}' : '' --@]\r
+\end{minipage}\r
 \end{document}\r