typeset tear-off remittance coupon
[freeside.git] / conf / invoice_latex
index aadd326..7e5ecdd 100644 (file)
@@ -19,7 +19,7 @@
 \r
 \documentclass[letterpaper]{article}\r
 \r
-\usepackage{fancyhdr,lastpage,ifthen,longtable,afterpage,caption}\r
+\usepackage{fancyhdr,lastpage,ifthen,longtable,afterpage,caption,multirow,bigstrut}\r
 \usepackage{graphicx}                  % required for logo graphic\r
 \r
 \addtolength{\voffset}{-0.0cm}         % top margin to top of header\r
 \renewcommand{\headrulewidth}{0pt}\r
 \renewcommand{\footrulewidth}{1pt}\r
 \r
+\renewcommand{\footrule}{\r
+[@--\r
+  $coupon ? '\ifthenelse{\equal{\thepage}{1}}' : '';\r
+--@]\r
+  {\r
+  }\r
+  {\r
+    \vbox to 0pt{\rule{\headwidth}{\footrulewidth}\vss}\r
+  }\r
+}\r
+\r
+\newcommand{\extracouponspace}{4.8cm}\r
+\r
 % Adjust the inset of the mailing address\r
 \newcommand{\addressinset}[1][]{\hspace{1.0cm}}\r
 \r
 \fancyfoot[C]{\r
   \ifthenelse{\equal{\thepage}{1}}\r
   { % First page\r
-    \small{\r
+[@--\r
+  if ($coupon) {\r
+    $OUT .= '\vspace{-\extracouponspace}';\r
+    $OUT .= '\rule[0.5em]{\textwidth}{\footrulewidth}\\\\';\r
+    $OUT .= $coupon;\r
+  }\r
+  '';\r
+--@] \small{\r
 [@-- $footer --@]\r
-    }\r
+    }[@-- $coupon ? '\vspace{\extracouponspace}' : '' --@]\r
   }\r
   { % ... pages\r
     \small{\r
 %\r
 %\r
 %\r
+[@-- $coupon ? '\enlargethispage{-\extracouponspace}' : '' --@]\r
 \begin{tabular}{ll}\r
 \addressinset \rule{0cm}{0cm} &\r
 \makebox{\r
@@ -227,12 +248,12 @@ Terms: [@-- $terms --@]\\
               '{' . $section->{'subtotal'} . '}' . "\n";\r
     }\r
 \r
-    if ($section == $sections[$#sections]) {\r
-      foreach my $line (@total_items) {\r
+    #if ($section == $sections[$#sections]) {\r
+      foreach my $line (grep {$_->{section}->{description} eq $section->{description}} @total_items) {\r
         $OUT .= '\FStotaldesc{' . $line->{'total_item'} . '}' .\r
                 '{' . $line->{'total_amount'} . '}' . "\n";\r
       }\r
-    }\r
+    #}\r
 \r
     $OUT .= '\hline';\r
     $OUT .= '\endlastfoot';\r