RT#42393: Verification cust_pay_pending handling in history & report
[freeside.git] / conf / invoice_latex
index 40ec703..c1d04d6 100644 (file)
 \documentclass[letterpaper]{article}\r
 \r
 \usepackage{fancyhdr,lastpage,ifthen,array,longtable,afterpage,caption,multirow,bigstrut}\r
+\usepackage[breakwords]{truncate} % to avoid overflowing boxes\r
 \usepackage{graphicx}                  % required for logo graphic\r
 \usepackage[utf8]{inputenc}             % multilanguage support\r
 \usepackage[T1]{fontenc}\r
+[@-- if ( length($watermark) ) {\r
+  $OUT .= '\r
+\usepackage{background}\r
+\backgroundsetup{\r
+  placement=center,\r
+  opacity=0.25,\r
+  color=black,\r
+  angle=0,\r
+  contents=' . $watermark . '\r
+}';\r
+}\r
+'';\r
+--@]\r
 \r
 \addtolength{\voffset}{-0.0cm}         % top margin to top of header\r
 \addtolength{\hoffset}{-0.6cm}         % left margin on page\r
-\addtolength{\topmargin}{[@-- defined($topmargin) ? $topmargin : '-1.25cm' --@]}\r
+\addtolength{\topmargin}{[@-- defined($topmargin) ? $topmargin : '-1.00cm' --@]}\r
 \setlength{\headheight}{2.0cm}                 % height of header\r
 \setlength{\headsep}{[@-- defined($headsep) ? $headsep : '1.0cm' --@]}\r
 \setlength{\footskip}{1.0cm}           % bottom of footer from bottom of text\r
@@ -53,7 +67,7 @@
   }\r
 }\r
 \r
-\newcommand{\extracouponspace}{[@-- defined($extracouponspace) ? $extracouponspace : '3.6cm' --@]}\r
+\newcommand{\extracouponspace}{[@-- defined($extracouponspace) ? $extracouponspace : '2.7in' --@]}\r
 \r
 % Adjust the inset of the mailing address\r
 \newcommand{\addressinset}[1][]{\hspace{1.0cm}}\r
@@ -82,7 +96,9 @@
     $OUT .= '\vspace{-\extracouponspace}';\r
     $OUT .= '\rule[0.5em]{\textwidth}{\footrulewidth}\\\\';\r
     $OUT .= $coupon;\r
-    $OUT .= '\vspace{'. $couponfootsep. '}' if defined($couponfootsep);\r
+    $OUT .= '\vspace{'.\r
+      (defined($couponfootsep) ? $couponfootsep : '0.2in') .\r
+      '}';\r
   }\r
   '';\r
 --@] [@-- $smallerfooter ? '\scriptsize{' : '\small{' --@]\r
     \returninset\r
     \makebox{\r
       \begin{tabular}{ll}\r
-        \includegraphics{[@-- $logo_file --@]} & [@-- $verticalreturnaddress ? '\\\\' : '' --@]\r
         \begin{minipage}[b]{5.5cm}\r
 [@-- $returnaddress --@]\r
-        \end{minipage}\\\r
+        \end{minipage} &\r
+        \includegraphics{[@-- $logo_file --@]}\\\r
       \end{tabular}\r
     }\r
   }\r
   \hline\r
   \rule{0pt}{2.5ex}\r
   \makebox[1.4cm]{} &\r
-  \multicolumn{\FSdescriptioncolumncount}{l}{\makebox[\FSdescriptionlength][l]{\textbf{[@-- emt('Description') --@]}}}&\r
+  \multicolumn{\FSdescriptioncolumncount}{l}{\r
+    \truncate{\FSdescriptionlength}{\textbf{[@-- emt('Description') --@]}}\r
+  } &\r
   \FSunitcolumns\r
   \makebox[1.6cm][r]{\textbf{[@-- emt('Amount') --@]}} \\\r
   \hline\r
 }\r
 \r
+\newcommand{\FSusagehead}{\r
+  \hline\r
+  \rule{0pt}{2.5ex}\r
+  \makebox[1.4cm]{} &\r
+  \multicolumn{4}{l}{\r
+    \truncate{\FSdescriptionlength}{\textbf{[@-- emt('Description') --@]}}\r
+  } &\r
+  \textbf{~~[@-- emt('Calls') --@]} &\r
+  \textbf{~~[@-- emt('Duration') --@]} &\r
+  \textbf{~~[@-- emt('Amount') --@]} \\\r
+  \hline\r
+}\r
+\r
 % ...description...\r
 \newcommand{\FSdesc}[5]{\r
   \multicolumn{1}{c}{\rule{0pt}{2.5ex}\textbf{#1}} &\r
-  \multicolumn{[@-- $unitprices ? '4' : '6' --@]}{l}{\textbf{#2}} &\r
+  \multicolumn{[@-- $unitprices ? '4' : '6' --@]}{l}{\r
+    \truncate{\FSdescriptionlength}{\textbf{#2}}\r
+  } &\r
 [@-- $unitprices ? '  \multicolumn{1}{r}{\textbf{#3}} &'."\n".\r
                    '  \multicolumn{1}{r}{\textbf{#4}} &'."\n"\r
                  : ''\r
 % ...extended description...\r
 \newcommand{\FSextdesc}[1]{\r
   \multicolumn{1}{l}{\rule{0pt}{1.0ex}} &\r
-%%  \multicolumn{2}{l}{\small{~-~#1}}\\\r
-#1\\\r
+  \multicolumn{6}{l}{\r
+    \truncate{12.8cm}{\small{~~~#1}}\r
+  } \\\r
+}\r
+% ...call detail (multiple columns already)...\r
+\newcommand{\FScalldetail}[1]{\r
+  \multicolumn{1}{l}{\rule{0pt}{1.0ex}} &\r
+  ~~~#1\r
+  \\\r
 }\r
-% ...and total line items.\r
+}\r
+% ...and total line items (which use the full 12.8cm length, ignoring\r
+% unitprice/quantity\r
 \newcommand{\FStotaldesc}[2]{\r
-  & \multicolumn{6}{l}{#1} & #2\\\r
+  & \multicolumn{6}{l}{\r
+    \truncate{12.8cm}{#1}\r
+  } & #2\\\r
 }\r
 \r
+% ...usage class summary\r
+\newcommand{\FSusagedesc}[4]{\r
+  \multicolumn{1}{c}{\rule{0pt}{2.5ex}} &\r
+  \multicolumn{4}{l}{\textbf{#1}} &\r
+  \multicolumn{1}{r}{\textbf{#2}} &\r
+  \multicolumn{1}{r}{\textbf{#3}} &\r
+  \multicolumn{1}{r}{\textbf{#4}}\r
+  \\\r
+}\r
 \r
 \begin{document}\r
 %      Headers and footers defined for the first page\r
   }\r
 --@]\r
 \begin{flushright}\r
-[@-- $terms ? emt('Terms') .": $terms" : '' --@]\\\r
+[@-- $terms ? emt('Terms') . ': ' . emt($terms) : '' --@]\\\r
 [@-- $po_line --@]\\\r
 \end{flushright}\r
 \end{minipage}}\r
       $OUT .= '}\\\\';\r
       if ($section->{header_generator}) {\r
         $OUT .= &{$section->{header_generator}}();\r
+      } elsif ( $section->{usage_section} ) {\r
+        $OUT .= '\FSusagehead';\r
       } else {\r
         $OUT .= '\FShead';\r
       }\r
       $OUT .= '\multicolumn{7}{r}{\rule{0pt}{2.5ex}'.emt('Continued from previous page').'}\\\\';\r
       if ($section->{header_generator}) {\r
         $OUT .= &{$section->{header_generator}}();\r
+      } elsif ( $section->{usage_section} ) {\r
+        $OUT .= '\FSusagehead';\r
       } else {\r
         $OUT .= '\FShead';\r
       }\r
         $OUT .= "\\hline\n" if (($line->{'ref'} || 0) ne $lastref);\r
         if ($section->{description_generator}) {\r
           $OUT .= &{$section->{description_generator}}($line);\r
+        } elsif ($section->{usage_section}) {\r
+          my $minutes = sprintf('%d', $line->{'duration'} / 60);\r
+          my $seconds = $line->{'duration'} % 60;\r
+          $OUT .= '\FSusagedesc\r
+            {' . $line->{'description'} . '}\r
+            {' . $line->{'quantity'} . '}\r
+            {' . $minutes . 'm ' . $seconds . 's' . '}\r
+            {' . $line->{'amount'} . '}';\r
         } else {\r
           $OUT .= '\FSdesc'.\r
                   '{}'.\r
         foreach my $ext_desc (@$ext_description) {\r
           if ($section->{extended_description_generator}) {\r
             $OUT .= &{$section->{extended_description_generator}}($ext_desc);\r
-          } else {\r
-            if ( $ext_desc !~ /[^\\]&/ ) {\r
-              $ext_desc = substr($ext_desc, 0, 80) . '...'\r
-                if (length($ext_desc) > 80);\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
+          } elsif ( $ext_desc !~ /[^\\]&/ ) {\r
+            $OUT .= '\FSextdesc{' . $ext_desc . "}$rowbreak\n";\r
+          } else { # call detail\r
+            $OUT .= '\FScalldetail{' . $ext_desc . "}$rowbreak\n";\r
           }\r
         }\r
 \r