fix latex template bogosity
[freeside.git] / conf / invoice_latex
index d1b471a..34ae4cb 100644 (file)
@@ -86,7 +86,7 @@
     \returninset\r
     \makebox{\r
       \begin{tabular}{ll}\r
-        \includegraphics{[@-- $conf_dir --@]/logo.eps} &\r
+        \includegraphics{[@-- $logo_file --@]} &\r
         \begin{minipage}[b]{5.5cm}\r
 [@-- $returnaddress --@]\r
         \end{minipage}\r
     }\r
   }\r
   { % ... pages\r
-    %\includegraphics{[@-- $conf_dir --@]/logo.eps}    % Uncomment if you want the logo on all 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}{rcl}\r
-    Invoice date & & Invoice number \\\r
+    \begin{tabular}{ccc}\r
+    Invoice date & Invoice \#& Customer\#\\\r
     \vspace{0.2cm}\r
-    \textbf{[@-- $date --@]} & & \textbf{[@-- $invnum --@]} \\\hline\r
+    \textbf{[@-- $date --@]} & \textbf{[@-- $invnum --@]} & \textbf{[@-- $custnum --@]} \\\hline\r
     \rule{0pt}{5ex} &~~ \huge{\textsc{Invoice}} & \\\r
     \vspace{-0.2cm}\r
      & & \\\hline\r
   }\r
   { % ... pages\r
     \small{\r
-      \begin{tabular}{ll}\r
-      Invoice date & Invoice number\\\r
-      \textbf{[@-- $date --@]} & \textbf{[@-- $invnum --@]}\\\r
+      \begin{tabular}{lll}\r
+      Invoice date & Invoice \#& Customer\#\\\r
+      \textbf{[@-- $date --@]} & \textbf{[@-- $invnum --@]} & \textbf{[@-- $custnum --@]}\\\r
       \end{tabular}\r
     }\r
   }\r
@@ -187,58 +187,79 @@ Terms: [@-- $terms --@]\\
 \end{minipage}}\r
 \vspace{1.5cm}\r
 %\r
-\section*{\textsc{Charges}}\r
-\begin{longtable}{clr}\r
-\hline\r
-\rule{0pt}{2.5ex}\r
-\makebox[1.4cm]{\textbf{Ref}} & \r
-\makebox[12.8cm][l]{\textbf{Description}} & \r
-\makebox[2.5cm][r]{\textbf{Amount}} \\\r
-\hline\r
-\endfirsthead\r
-\multicolumn{3}{r}{\rule{0pt}{2.5ex}Continued from previous page}\\\r
-\hline\r
-\rule{0pt}{2.5ex}\r
-\makebox[1.4cm]{\textbf{Ref}} & \r
-\makebox[12.8cm][l]{\textbf{Description}} & \r
-\makebox[2.5cm][r]{\textbf{Amount}} \\\r
-\hline\r
-\endhead\r
-\multicolumn{3}{r}{\rule{0pt}{2.5ex}Continued on next page...}\\\r
-\endfoot\r
-\hline\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
-  foreach my $line (@total_items) {\r
-    $OUT .= '\FStotaldesc{' . $line->{'total_item'} . '}' .\r
-            '{' . $line->{'total_amount'} . '}' . "\n";\r
-  }\r
+    if (scalar(@sections) > 1) {\r
+      $OUT .= '\FStotaldesc{' . $section->{'description'} . ' Total}' .\r
+              '{' . $section->{'subtotal'} . '}' . "\n";\r
+    }\r
 \r
---@]\r
-\hline\r
-\endlastfoot\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
-  foreach my $line (@detail_items) {\r
-    my $ext_description = $line->{'ext_description'};\r
+    $OUT .= '\hline';\r
+    $OUT .= '\endlastfoot';\r
 \r
-    # Don't break-up small packages.\r
-    my $rowbreak = @$ext_description < 5 ? '*' : '';\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
-    $OUT .= "\\hline\n";\r
-    $OUT .= '\FSdesc{' . $line->{'ref'} . '}{' . $line->{'description'} . '}' .\r
-            '{' . $line->{'amount'} . "}${rowbreak}\n";\r
+      if (@$ext_description) {\r
+        $OUT .= '\multicolumn{1}{l}{\rule{0pt}{1.0ex}} &';\r
+        $OUT .= '\multicolumn{2}{l}{\small{\begin{tabular}{llllll}';#cheating at 6\r
+        foreach my $ext_desc (@$ext_description) {\r
+          $ext_desc = substr($ext_desc, 0, 80) . '...'\r
+            if (length($ext_desc) > 80);\r
+          $OUT .= "$ext_desc \\\\${rowbreak}\n";\r
+        }\r
+        $OUT .="\\end{tabular}}}\\\\${rowbreak}\n";\r
+      }\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
+    $OUT .= '\end{longtable}';\r
+\r
   }\r
 \r
 --@]\r
-\end{longtable}\r
 \vfill\r
 [@-- $notes --@]\r
 \end{document}\r